Exemplo n.º 1
0
function message($code, $message)
{
    global $db, $cache, $starttime, $conf, $browser, $ajax, $uid, $gid, $user;
    if ($ajax) {
        echo xn_json_encode(array('code' => $code, 'message' => $message));
    } else {
        $header['title'] = '提示信息';
        include "./install/view/message.htm";
    }
    exit;
}
Exemplo n.º 2
0
function message($code, $message)
{
    global $db, $cache, $ajax, $starttime, $browser, $conf, $uid, $gid, $user, $header, $forumlist;
    // 防止 message 本身出现错误死循环
    static $called = FALSE;
    $called ? exit("code: {$code}, message: {$message}") : ($called = TRUE);
    if ($ajax) {
        echo xn_json_encode(array('code' => $code, 'message' => $message));
        runtime_save();
    } else {
        $header['title'] = '提示信息';
        include "./admin/view/message.htm";
    }
    exit;
}
Exemplo n.º 3
0
 $pid = param(2);
 $post = post_read($pid);
 empty($post) and message(-1, '帖子不存在:' . $pid);
 $tid = $post['tid'];
 $thread = thread_read($tid);
 empty($thread) and message(-1, '主题不存在:' . $tid);
 $fid = $thread['fid'];
 $forum = forum_read($fid);
 empty($forum) and message(1, '板块不存在:' . $fid);
 $isfirst = $post['isfirst'];
 !forum_access_user($fid, $gid, 'allowpost') and message(-1, '您(' . $user['groupname'] . ')无权限在此版块回帖');
 $allowupdate = forum_access_mod($fid, $gid, 'allowupdate');
 !$allowupdate and !$post['allowupdate'] and message(-1, '无权编辑该贴');
 if ($method == 'GET') {
     $forumlist_allowthread = forum_list_access_filter($forumlist, $gid, 'allowthread');
     $forumarr = xn_json_encode(arrlist_key_values($forumlist_allowthread, 'fid', 'name'));
     $post['message'] = htmlspecialchars($post['message']);
     // 将未插入帖子的附件加入到末尾。
     $attachlist = $imagelist = $filelist = array();
     if ($post['images'] || $post['files']) {
         $attachlist = attach_find_by_pid($post['pid']);
         list($imagelist, $filelist) = attach_list_not_in_message($attachlist, $post['message']);
         $post['message'] .= post_attach_list_add($imagelist, $filelist);
     }
     check_standard_browser();
     include './flarum/view/post_update.htm';
 } elseif ($method == 'POST') {
     $subject = htmlspecialchars(param('subject', '', FALSE));
     $message = param('message', '', FALSE);
     $seo_url = strtolower(param('seo_url'));
     empty($message) and message(2, '内容不能为空');
Exemplo n.º 4
0
function online_save($force = FALSE)
{
    global $uid, $gid, $sid, $fid, $longip, $time, $conf, $runtime, $g_online_data, $g_online_save;
    $arr = array();
    if ($force || $g_online_save) {
        $data = $g_online_data ? xn_json_encode($g_online_data) : '';
        strlen($data) > 255 and $data = '';
        $arr = array('sid' => $sid, 'uid' => $uid, 'gid' => $gid, 'fid' => $fid, 'url' => $_SERVER['REQUEST_URI'], 'ip' => $longip, 'useragent' => $_SERVER['HTTP_USER_AGENT'], 'data' => $data, 'last_date' => $time);
        online_replace($arr);
        // 如果设置为5分钟,则实时更新。比较耗费资源
        if ($conf['online_update_span'] < 300) {
            online_list_cache_delete($fid);
        }
    }
    return $arr;
}
Exemplo n.º 5
0
function xn_json_assoc_array_to_string($arr)
{
    $s = '';
    foreach ($arr as $k => $v) {
        $s .= ',"' . $k . '":' . xn_json_encode($v);
    }
    $s = substr($s, 1);
    $r = '{' . $s . '}';
    return $r;
}
Exemplo n.º 6
0
 public function set($k, $v, $life = 0)
 {
     if (!$this->link && !$this->connect()) {
         return FALSE;
     }
     $time = time();
     $expiry = $life ? $time + $life : 0;
     $v = addslashes(xn_json_encode($v));
     $r = $this->db->exec("REPLACE INTO `{$this->table}` SET k='{$k}',v='{$v}',expiry='{$expiry}'");
     if ($this->db->errno) {
         $this->error($this->db->errno, $this->db->errstr);
     }
     return $r !== FALSE;
 }
Exemplo n.º 7
0
<?php

// 创建新帖
!defined('DEBUG') and exit('Access Denied.');
include './xiunophp/xn_html_safe.func.php';
include './xiunophp/image.func.php';
$action = param(1);
$user = user_read($uid);
if ($action == 'update') {
    $pid = param(2);
    $post = post_read($pid);
    empty($post) and message(-1, '帖子不存在:' . $pid);
    $tid = $post['tid'];
    $thread = thread_read($tid);
    empty($thread) and message(-1, '主题不存在:' . $tid);
    $fid = $thread['fid'];
    $forum = forum_read($fid);
    empty($forum) and message(1, '板块不存在:' . $fid);
    $isfirst = $post['isfirst'];
    !forum_access_user($fid, $gid, 'allowpost') and message(-1, '您(' . $user['groupname'] . ')无权限在此版块回帖');
    $allowupdate = forum_access_mod($fid, $gid, 'allowupdate');
    !$allowupdate and !$post['allowupdate'] and message(-1, '无权编辑该贴');
    if ($method == 'GET') {
        $forumarr = xn_json_encode(arrlist_key_values($forumlist, 'fid', 'name'));
        $post['message'] = htmlspecialchars($post['message']);
        include './mobile/view/post_update.htm';
    }
} else {
    message(-1, '没有此功能');
}
Exemplo n.º 8
0
 public function set($k, $v, $life = 0)
 {
     if (!$this->link && !$this->connect()) {
         return FALSE;
     }
     $time = time();
     $expiry = $life ? $time + $life : 0;
     $v = addslashes(xn_json_encode($v));
     $r = $this->db->exec("REPLACE INTO `bbs_cache` SET k='{$k}',v='{$v}',expiry='{$expiry}'");
     return $r !== FALSE;
 }