Exemple #1
0
         die(json_encode(['status' => false, 'err' => $Pub]));
     }
     break;
 case 'delete':
     $PostID = sanitize_id($data['id']);
     $QNA = new QNA($PostID);
     // check if question exists
     $question = $QNA->get_question();
     if (!is_object($question)) {
         die(json_encode(['status' => false, 'err' => 'Question was not found.']));
     }
     if (USER_ID !== $question->uid) {
         die(json_encode(['status' => false, 'id' => $PostID, 'err' => 'Authentication error.']));
     }
     $QNA = new QNA($PostID);
     $delete = $QNA->delete();
     if ($delete === true) {
         die(json_encode(['status' => true]));
     }
     break;
 case 'edit':
     $PostID = sanitize_id($data['id']);
     $content = $data['content'];
     $title = $data['title'];
     // check if question exists
     $QNA = new QNA($PostID);
     $question = $QNA->get_question();
     if (!is_object($question)) {
         die(json_encode(['status' => false, 'err' => 'Question was not found.']));
     }
     if (USER_ID !== $question->uid && !$session->adminCheck()) {