Example #1
0
function render_comment_json($subject, $zid, $time, $cid, $body)
{
    global $can_moderate;
    global $auth_zid;
    $score = get_comment_score($cid);
    $rid = -1;
    if ($can_moderate) {
        $row = run_sql("select rid from comment_vote where cid = ? and zid = ?", array($cid, $auth_zid));
        if (count($row) == 0) {
            $rid = 0;
        } else {
            $rid = $row[0]["rid"];
        }
    }
    $s = "\$level{\n";
    $s .= "\$level\t\"cid\": {$cid},\n";
    $s .= "\$level\t\"zid\": \"{$zid}\",\n";
    $s .= "\$level\t\"time\": {$time},\n";
    $s .= "\$level\t\"score\": \"{$score}\",\n";
    $s .= "\$level\t\"rid\": {$rid},\n";
    $s .= "\$level\t\"subject\": \"" . addcslashes($subject, "\\\"") . "\",\n";
    $s .= "\$level\t\"comment\": \"" . addcslashes($body, "\\\"") . "\",\n";
    $s .= "\$level\t\"reply\": [\n";
    return $s;
}
Example #2
0
        $tag_arr = array_sort($tag_arr, 'tag_num', 'desc');
        if ($tag_arr) {
            foreach ($tag_arr as $key => $val) {
                if ($_CFG['tag_show_num'] > 0) {
                    if ($key + 1 <= $_CFG['tag_show_num']) {
                        $comment_tags[] = $val;
                    }
                } else {
                    $comment_tags[] = $val;
                }
            }
        }
        $smarty->assign('comment_tags', $comment_tags);
        /* 代码增加_start By www.ecshophome.com */
        include_once 'themes/' . $GLOBALS['_CFG']['template'] . '/plugin_comments/plugin_comments.php';
        $smarty->assign("comment_score", get_comment_score($goods['goods_id']));
        /* 代码增加_end By www.ecshophome.com */
    }
}
/* 记录浏览历史 */
if (!empty($_COOKIE['ECS']['history'])) {
    $history = explode(',', $_COOKIE['ECS']['history']);
    array_unshift($history, $goods_id);
    $history = array_unique($history);
    while (count($history) > $_CFG['history_number']) {
        array_pop($history);
    }
    setcookie('ECS[history]', implode(',', $history), gmtime() + 3600 * 24 * 30);
} else {
    setcookie('ECS[history]', $goods_id, gmtime() + 3600 * 24 * 30);
}
Example #3
0
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Pipecode.  If not, see <http://www.gnu.org/licenses/>.
//
include "render.php";
$cid = (int) $s2;
if (!http_post()) {
    die("error: post method required");
}
if ($auth_zid == "") {
    die("error: sign in to moderate");
}
if (!db_has_rec("comment", $cid)) {
    die("error: comment not found [{$cid}]");
}
if (db_has_rec("comment_vote", array("cid" => $cid, "zid" => $auth_zid))) {
    db_del_rec("comment_vote", array("cid" => $cid, "zid" => $auth_zid));
}
$rid = http_post_int("rid");
if ($rid > 0 && $rid <= 10) {
    $comment_vote = array();
    $comment_vote["cid"] = $cid;
    $comment_vote["zid"] = $auth_zid;
    $comment_vote["rid"] = $rid;
    $comment_vote["time"] = time();
    db_set_rec("comment_vote", $comment_vote);
}
$score = get_comment_score($cid);
writeln("{$cid} {$score}");