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) {
        $new_article_name = $_POST['new_article_name'];
        $new_article_short_contents = $_POST['new_article_short_contents'];
        $new_article_contents = $_POST['new_article_contents'];
        $requestURI = $_SERVER['REQUEST_URI'];
        $arr = explode('/', $requestURI);
        $article_id = array_pop($arr);
        if (strlen($_FILES['article_picture']['type']) !== 0) {
            $article_picture_array = explode('/', $_FILES['article_picture']['type']);
            $article_picture_type = array_pop($article_picture_array);
            $picture_name = $article_id . 'new';
            copy($_FILES['article_picture']['tmp_name'], ROOT . '/uploads/articles/' . $picture_name . '.' . $article_picture_type);
            // копируем временный файл в аплоад папку (до окончания работы скрипта)
            $new_article_picture = '/uploads/articles/' . $picture_name . '.' . $article_picture_type;
        } else {
            $article_array = Article::getSingleArticle($article_id);
            $new_article_picture = $article_array['article_picture1'];
        }
        Article::editArticle($new_article_name, $new_article_short_contents, $new_article_contents, $new_article_picture, $article_id);
        unset($_POST['new_article_name'], $_POST['new_article_short_contents'], $_POST['new_article_contents']);
        header('Location: /articles-navigation/1');
    } else {
        header('Location: /articles-navigation/1');
    }
} else {
    header('Location: /articles-navigation/1');
}
Example #2
0
<?php

/**
 * Model: C.P.Sub 公告系統
 * Author: Cooltey Feng
 * Lastest Update: 2014/6/9
 */
$getData = $_POST;
$getFile = $_FILES;
// set Article
$getArticle = new Article($config_upload_folder, $config_article_file_path, $getLib);
$getId = $_GET['id'];
// set add function
$getResult = $getArticle->editArticle($getId, $getData, $getFile);
if ($getResult['status'] == true) {
    $success_msg_array = $getResult['msg'];
} else {
    $error_msg_array = $getResult['msg'];
}
// get single article
$getArticleResult = $getArticle->getArticle($getId);
if ($getArticleResult['status'] == true) {
    $getArticleData = $getArticleResult['data'];
    // get colum values
    $article_title = $getLib->setFilter($getArticleData['title']);
    $article_author = $getLib->setFilter($getArticleData['author']);
    $article_date = $getLib->setFilter($getArticleData['date']);
    $article_content = $getLib->setFilter($getArticleData['content']);
    $article_files = explode(",", $getArticleData['files']);
    $article_files_name = explode(",", $getArticleData['files_name']);
    if ($getArticleData['top'] == "1") {
Example #3
0
  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->editArticle($matches[1], $_POST)) {
        $this->layout_vars = array(
          'content' => "Congratulations, you edited a post. Everyone is so proud.");
      } else {
        $this->layout_vars = array(
	  'content' => "Couldn't write post. Fuuuuuu-");
      }
    }

  }