<?php if (isset($_GET['id'])) { require_once '../../module/Connexion.php'; require_once '../../module/model/article.php'; # execution de l'operation $article = new Article(); $result = $article->deleteArticle($_GET['id']); #tester le rendu if ($result) { header("location:../../admin/article/editer?id=" . $_GET['id']); } else { header("location:../../admin/article/editer?c=failed"); } } else { header("location:../../layout/Intrusion/url.inc"); }
<?php require_once "../../classes/article_class.php"; $postdata = file_get_contents("php://input"); $data = json_decode($postdata); if (!empty($data->id)) { $article = new Article($data->alias, $data->title, $data->category, $data->content, $data->url, $data->img_url, $data->meta_title, $data->meta_description, $data->meta_keywords); if ($article->articleExists()) { $article->deleteArticle($data->id); http_response_code("200"); echo json_encode(array("message" => "Article with title " . $article->getArticleName() . " as been deleted.")); } else { http_response_code("500"); echo json_encode(array("message" => "Article with title " . $article->getArticleName() . " hasn't been found")); } } else { // redirect to write the article http_response_code("500"); echo json_encode(array("error" => "error deleting article with id " . $data->id)); }
public static function delete($id) { Article::deleteArticle($id); }
public function actionDelete() { Article::deleteArticle($_GET['id']); return Controller::redirect('/admin/article'); }
function POST($matches) { $P = new Password(); if(!$P->isValid($_POST['password'])) { $this->layout_vars = array( 'content' => "The password you entered is incorrect."); } else { $A = new Article(); if($A->deleteArticle($matches[1])) { $this->layout_vars = array( 'content' => "Congratulations, you delete a post. Everyone is so proud."); } else { $this->layout_vars = array( 'content' => "Couldn't delete post. Fuuuuuu-"); } } }
<?php include_once ROOT . '/components/islogin.php'; include_once ROOT . '/models/AuthModel.php'; include_once ROOT . '/models/ArticleModel.php'; if (CheckForLogIn::isLogin()) { $regId = base64_decode(base64_decode($_COOKIE['h3'])); $user_info_array = GetMainUserInfo::GetInfo($regId); if ($user_info_array['is_admin'] == 1) { $requestURI = $_SERVER['REQUEST_URI']; $arr = explode('/', $requestURI); $article_id = array_pop($arr); Article::deleteArticle($article_id); $all_articles = Article::getList(); $articlesCount = count($all_articles); $get_id = ceil($articlesCount / 4); header('Location: /articles-navigation/1'); } else { header('Location: /articles-navigation/1'); } } else { header('Location: /articles-navigation/1'); }