Esempio n. 1
0
 $ishide = isset($_POST['ishide']) && empty($_POST['ishide']) ? 'n' : addslashes($_POST['ishide']);
 $template = isset($_POST['template']) && $_POST['template'] != 'page' ? addslashes(trim($_POST['template'])) : '';
 $allow_remark = isset($_POST['allow_remark']) ? addslashes(trim($_POST['allow_remark'])) : 'n';
 LoginAuth::checkToken();
 $postTime = $emPage->postDate(Option::get('timezone'));
 //check alias
 if (!empty($alias)) {
     $logalias_cache = $CACHE->readCache('logalias');
     $alias = $emPage->checkAlias($alias, $logalias_cache, $pageId);
 }
 $logData = array('title' => $title, 'content' => $content, 'excerpt' => '', 'date' => $postTime, 'allow_remark' => $allow_remark, 'hide' => $ishide, 'alias' => $alias, 'type' => 'page', 'template' => $template);
 if ($pageId > 0) {
     //自动保存后,添加变为更新
     $emPage->updateLog($logData, $pageId);
 } else {
     $pageId = $emPage->addlog($logData);
 }
 $CACHE->updateCache(array('options', 'logalias'));
 switch ($action) {
     case 'autosave':
         echo "autosave_gid:{$pageId}_df:0_";
         break;
     case 'add':
     case 'edit':
         if ($action == 'add') {
             emDirect("./page.php?active_hide_n=1");
             //页面发布成功
         } else {
             emDirect("./page.php?active_savepage=1");
             //页面保存成功
         }
Esempio n. 2
0
/**
 * 保存新文章
 */
function mw_newPost($args)
{
    global $options_cache;
    escape($args);
    $user = login($args[1], $args[2]);
    define('UID', $user['uid']);
    $id = intval($args[0]);
    $username = $args[1];
    $password = $args[2];
    $data = $args[3];
    $publish = $args[4];
    $update_data['title'] = $data['title'];
    $update_data['content'] = htmlspecialchars_decode($data['description']);
    $update_data['author'] = UID;
    $update_data['hide'] = $publish == 1 ? 'n' : 'y';
    $update_data['excerpt'] = '';
    // 只取第一个分类
    $sort_name = isset($data['categories']) && isset($data['categories'][0]) ? $data['categories'][0] : '';
    $Sort_Model = new Sort_Model();
    $sorts = $Sort_Model->getSorts();
    $update_data['sortid'] = '-1';
    foreach ($sorts as $sort) {
        if ($sort_name == $sort['sortname']) {
            $update_data['sortid'] = $sort['sid'];
            break;
        }
    }
    // 发布时间
    if (isset($data['dateCreated']) && is_object($data['dateCreated'])) {
        $update_data['date'] = @gmmktime($data['dateCreated']->hour, $data['dateCreated']->minute, $data['dateCreated']->second, $data['dateCreated']->month, $data['dateCreated']->day, $data['dateCreated']->year) - $options_cache['timezone'] * 3600;
    } else {
        $update_data['date'] = time();
    }
    // 更新数据
    $Log_Model = new Log_Model();
    $new_id = $Log_Model->addlog($update_data);
    // 更新标签
    if (isset($data['mt_keywords']) && !empty($data['mt_keywords'])) {
        $Tag_Model = new Tag_Model();
        $Tag_Model->addTag($data['mt_keywords'], $new_id);
        unset($Tag_Model);
    }
    // 更新缓存
    Cache::getInstance()->updateCache();
    response("<i4>{$new_id}</i4>");
}
Esempio n. 3
0
$postTime = $Log_Model->postDate(Option::get('timezone'), $postDate, $date);
LoginAuth::checkToken();
//check alias
if (!empty($alias)) {
    $logalias_cache = $CACHE->readCache('logalias');
    $alias = $Log_Model->checkAlias($alias, $logalias_cache, $blogid);
}
$logData = array('title' => $title, 'alias' => $alias, 'content' => $content, 'excerpt' => $excerpt, 'author' => $author, 'sortid' => $sort, 'date' => $postTime, 'top ' => $top, 'sortop ' => $sortop, 'allow_remark' => $allow_remark, 'hide' => $ishide, 'checked' => $user_cache[UID]['ischeck'] == 'y' ? 'n' : 'y', 'password' => $password);
if ($blogid > 0) {
    //自动保存草稿后,添加变为更新
    $Log_Model->updateLog($logData, $blogid);
    $Tag_Model->updateTag($tagstring, $blogid);
    $dftnum = '';
} else {
    if (!($blogid = $Log_Model->isRepeatPost($title, $postTime))) {
        $blogid = $Log_Model->addlog($logData);
    }
    $Tag_Model->addTag($tagstring, $blogid);
    $dftnum = $Log_Model->getLogNum('y', '', 'blog', 1);
}
$CACHE->updateCache();
doAction('save_log', $blogid);
switch ($action) {
    case 'autosave':
        echo "autosave_gid:{$blogid}_df:{$dftnum}_";
        break;
    case 'add':
    case 'edit':
        $tbmsg = '';
        if ($ishide == 'y') {
            emDirect("./admin_log.php?pid=draft&active_savedraft=1");