Beispiel #1
0
/**
 * 更新文章
 */
function mw_editPost($args)
{
    global $options_cache;
    escape($args);
    $username = $args[1];
    $password = $args[2];
    $user = login($username, $password);
    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';
    // 根据分类名称取分类id,注意只取第一个分类
    $sort_name = isset($data['categories']) && isset($data['categories'][0]) ? $data['categories'][0] : '';
    $Sort_Model = new Sort_Model();
    $sorts = $Sort_Model->getSorts();
    unset($Sort_Model);
    $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;
    }
    // 更新数据
    $Log_Model = new Log_Model();
    $Log_Model->updateLog($update_data, $id);
    // 更新标签
    if (isset($data['mt_keywords']) && !empty($data['mt_keywords'])) {
        $Tag_Model = new Tag_Model();
        $Tag_Model->updateTag($data['mt_keywords'], $id);
    }
    // 更新缓存
    Cache::getInstance()->updateCache();
    response('<boolean>1</boolean>');
}
Beispiel #2
0
$sortop = isset($_POST['sortop']) ? addslashes(trim($_POST['sortop'])) : 'n';
$allow_remark = isset($_POST['allow_remark']) ? addslashes(trim($_POST['allow_remark'])) : 'n';
$ishide = isset($_POST['ishide']) && !empty($_POST['ishide']) && !isset($_POST['pubdf']) ? addslashes($_POST['ishide']) : 'n';
$password = isset($_POST['password']) ? addslashes(trim($_POST['password'])) : '';
$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':