xgit simple git

nexus

nexus

clone git clone https://kb.hax.al/nexus

api/delete.php

1 <?php
2 require_once __DIR__ . '/../includes/bootstrap.php';
3 if (!$USER) json_out(['error'=>'Not logged in'],401);
4 if (!csrf_ok()) json_out(['error'=>'CSRF'],403);
5 $pid  = (int)post('post_id');
6 $post = DB::row('SELECT * FROM posts WHERE id=?',[$pid]);
7 if (!$post) json_out(['error'=>'Not found'],404);
8 if ($post['user_id']!==$USER['id'] && !is_admin()) json_out(['error'=>'Forbidden'],403);
9 DB::run('UPDATE posts SET deleted=1 WHERE id=?',[$pid]);
10 json_out(['ok'=>true]);