Ejemplo n.º 1
0
$ui_options['stylesheets'][] = 'discussion_forum.css';
$ui_options['stylesheets'][] = 'rank.css';
//$ui_options['stylesheets'][] = 'codepress.css';
$ui_options['javascripts'][] = 'comments.js';
$ui_options['javascripts'][] = 'rank.js';
$ui_options['stylesheets'][] = 'photos.css';
//$ui_options['javascripts'][] = 'photos.js';
if ($_GET['category'] == 'create' && isset($_POST["category_name"]) && is_privilegied('articles_admin')) {
    create_category($_POST["category_name"]);
}
if ($_GET['category'] == 'remove' && isset($_GET['id']) && is_privilegied('articles_admin')) {
    remove_category($_GET['id']);
}
if ($_GET['article'] == 'submit' && isset($_POST) && is_privilegied('articles_admin')) {
    if (isset($_GET['id'])) {
        update_article($_POST, $_GET['id']);
    } else {
        create_article($_POST);
    }
}
if ($_GET['article'] == 'remove' && isset($_GET['id']) && is_privilegied('articles_admin')) {
    remove_article($_GET['id']);
}
switch ($_GET['action']) {
    case 'admin':
        // If an admin would like to do anything
        $ui_options['menu_path'] = array('artiklar', 'admin');
        // Use of privilegies. Which I don't know anything about. ---------------------------------------------------------------
        if (!is_privilegied('articles_admin')) {
            $out .= rounded_corners_top(array('color' => 'red'));
            $out .= '<h1>Den här delen är endast till för de med privilegier till artikelsystemet</h1>' . "\n";
Ejemplo n.º 2
0
<?php

include 'autoload.php';
$action = Request::post('action');
//add, edit, update, delete
switch ($action) {
    case 'add':
        add_article();
        break;
    case 'edit':
        edit_article();
        break;
    case 'update':
        update_article();
        break;
    case 'delete':
        delete_article();
        break;
}
function add_article()
{
    $ret = ['code' => 0, 'msg' => 'OK', 'data' => []];
    //第一步:插入数据库
    $val = Article::create_article();
    if (!is_numeric($val)) {
        $ret = ['code' => 999, 'msg' => $val, 'data' => []];
    } else {
        $ret = ['code' => 0, 'msg' => 'OK', 'data' => [$val]];
    }
    echo json_encode($ret);
}
<?php

require_once 'common.php';
require_once 'models/edit_news_translation.model.php';
$article_id = $_GET['article'];
$lang_id = $_GET['lang'];
$article = get_article($article_id, $lang_id);
$article = $article[0];
if ($article_id && $lang_id && $_POST) {
    $title = $_POST['title'];
    $addedby = $_POST['name'];
    $full_text = $_POST['article'];
    $lang = get_lang_by_name($lang_id);
    $data = array('title' => $title, 'addedby' => $addedby, 'full_text' => $full_text, 'article_id' => $article_id, 'lang_id' => $lang);
    $present = check_article($data);
    if ($present) {
        update_article($data);
    } else {
        set_article($data);
    }
    header('Location: edit_news_translation.php?article=' . $article_id . '&lang=' . $lang_id);
}
require_once 'templates/edit_news_translation.php';
/**
 * validate_article_data
 * 
 * 
 * 
 * 
 * 
 * 
 */
function validate_article_post_data()
{
    $article_data['error'] = array();
    // set status - archive, draft, published, withdrawn
    $status_list = array('A', 'D', 'P', 'W');
    $article_data = $_POST;
    if (isset($_POST['draft'])) {
        $article_data['status'] = 'D';
    } else {
        $article_data['status'] = 'P';
        if (isset($_POST['status'])) {
            $post_status = $_POST['status'];
            $article_data['status'] = in_array($post_status, $status_list) ? $_POST['status'] : 'A';
        }
    }
    // id
    $article_data['id'] = isset($_GET['article_id']) ? (int) $_GET['article_id'] : 0;
    // title - required
    if (isset($_POST['title']) && !empty($_POST['title'])) {
        $article_data['title'] = clean_input($_POST['title']);
    } else {
        $article_data['title'] = 'New article';
        $article_data['error'][] = "No title entered";
    }
    // url title - update url title only if article is new, url is empty, or update_url is checked
    if (empty($article_data['id']) || !empty($_POST['update_url']) || empty($_POST['url'])) {
        $article_data['url'] = create_url_title($article_data['title']);
    } else {
        $article_data['url'] = clean_input($_POST['url']);
    }
    // check for url duplicates
    $article_data['url'] = check_url_title($article_data['url'], $article_data['id']);
    // summary
    $article_data['summary'] = isset($_POST['summary']) ? clean_input($_POST['summary']) : '';
    // body - no need to clean html here
    $article_data['body'] = isset($_POST['body']) ? prepare_article_body($_POST['body']) : '';
    // author id
    $article_data['author_id'] = (int) $_POST['author_id'];
    // category_url
    $article_data['category_url'] = $_POST['category_url'];
    // category new
    if (!empty($_POST['category_new'])) {
        $new_category = clean_input($_POST['category_new']);
        $article_data['category_id'] = quick_insert_category($new_category);
        if (!is_int($article_data['category_id'])) {
            $article_data['error'][] = $article_data['category_id'];
        }
    } else {
        // category id
        $article_data['category_id'] = (int) $_POST['category_id'];
    }
    // error check category
    if (!isset($article_data['category_id'])) {
        $article_data['error'][] = "No category selected (or no new category entered)";
    }
    // date_uploaded
    if (isset($_POST['date_uploaded'])) {
        $article_data['date_uploaded'] = $_POST['date_uploaded'];
    } else {
        // ensure gmt date is saved
        $year = empty($_POST['year']) ? gmdate('Y') : $_POST['year'];
        $month = empty($_POST['month']) ? gmdate('m') : $_POST['month'];
        $day = empty($_POST['day']) ? gmdate('d') : $_POST['day'];
        $hour = empty($_POST['hour']) ? gmdate('H') : $_POST['hour'];
        $minute = empty($_POST['minute']) ? gmdate('i') : $_POST['minute'];
        // calculate GMT timestamp
        $ts_uploaded = strtotime($year . "-" . $month . "-" . $day . " " . $hour . ":" . $minute . ":00");
        $article_data['date_uploaded'] = gmdate('Y-m-d H:i:s', $ts_uploaded);
        // just to avoid messy errors we'll resend the date/time variables again
        /*
        $article_data['year'] 	= $_POST['year'];
        $article_data['month'] 	= $_POST['month'];
        $article_data['day'] 	= $_POST['day'];
        $article_data['hour'] 	= $_POST['hour'];
        $article_data['minute'] = $_POST['minute'];
        */
    }
    // date amended
    $article_data['date_amended'] = gmdate('Y-m-d H:i:s');
    // seo data
    $article_data['seo_title'] = isset($_POST['seo_title']) ? clean_input($_POST['seo_title']) : '';
    $article_data['seo_desc'] = isset($_POST['seo_desc']) ? clean_input($_POST['seo_desc']) : '';
    $article_data['seo_keywords'] = isset($_POST['seo_keywords']) ? clean_input($_POST['seo_keywords']) : '';
    $article_data['redirect_code'] = isset($_POST['redirect_code']) ? (int) $_POST['redirect_code'] : '';
    $article_data['redirect_url'] = isset($_POST['redirect_url']) ? clean_input($_POST['redirect_url']) : '';
    // validate redirect url
    if (!empty($_POST['redirect_url'])) {
        if (validate_url($_POST['redirect_url']) === false) {
            $article_data['error'][] = "Invalid redirect url entered: " . $_POST['redirect_url'];
            $article_data['redirect_url'] = '';
        } else {
            $article_data['redirect_url'] = $_POST['redirect_url'];
            // if redirect url is set then we automatically change status to archived
            $article_data['status'] = 'A';
        }
    }
    // comment settings
    $article_data['comments_hide'] = isset($_POST['comments_hide']) && !empty($_POST['comments_hide']) ? 1 : 0;
    $article_data['comments_disable'] = isset($_POST['comments_disable']) && !empty($_POST['comments_disable']) ? 1 : 0;
    // tags
    $article_data['tags'] = isset($_POST['tags']) && !empty($_POST['tags']) ? $_POST['tags'] : array();
    // attachments
    $article_data['attachments'] = isset($_POST['attachments']) && !empty($_POST['attachments']) ? $_POST['attachments'] : array();
    // tag new
    if (!empty($_POST['tag_new'])) {
        $new_tag = clean_input($_POST['tag_new']);
        $new_tag_ids = quick_insert_tags($new_tag);
        foreach ($new_tag_ids as $new_id) {
            if (is_int($new_id)) {
                $article_data['tags'][] = $new_id;
            } else {
                $article_data['error'][] = $new_id;
            }
        }
    }
    // any errors
    if (empty($article_data['error'])) {
        if (empty($article_data['id'])) {
            return insert_article($article_data);
        } else {
            return update_article($article_data);
        }
    } else {
        // we need to return timezone corrected dates to avoid errors
        $article_data = parse_article_dates($article_data);
        return stripslashes_deep($article_data);
    }
}
Ejemplo n.º 5
0
<?php

if ($access != 'VALID') {
    header('location:../../index.php');
}
//Contrôleur secondaire mise à jour d'un article
$retour = '';
if (!isset($_SESSION['admin'])) {
    header('location:../../index.php');
} else {
    include_once 'model/blog/fonctions_blog.php';
    include_once 'lib/images.php';
    $article = afficher_article($_GET['a']);
    if (isset($_POST['title'])) {
        if (empty($_FILES['img']['name'])) {
            $img = $article['Articleimage'];
        } else {
            $img = imageadd($_FILES['img']);
            unlink("../union-padelmvc/assets/img/" . $article['Articleimage']);
        }
        if (update_article($_GET['a'], $_POST['title'], $_POST['chapo'], $_POST['content'], $_POST['cat'], $_SESSION['auth'], $img)) {
            $retour = 'La modification a bien été effectuée';
        } else {
            $retour = 'Il y a eu une erreur lors de la mise à jour de l\'article';
        }
    }
    $url = "?module=blog&amp;action=articles";
    $action = "Retourner à la gestion des articles";
    $title = 'Edition de l\'article';
    include_once 'view/retour.php';
}
Ejemplo n.º 6
0
function edit_seo()
{
    if ($id = _post('id')) {
        if (update_article($id, _post('description'), _post('keywords')) > 0) {
            return ajax_echo('更新成功');
        }
    }
}