示例#1
0
        if ($user_comments) {
            $cus = count($user_comments);
            // only 3 comments in the cache
            foreach ($user_comments as $uc) {
                if ($c == 0 and $cus > 2) {
                    // do nothing
                } else {
                    $new_arr[] = (array) $uc;
                }
                $c++;
            }
        }
        // if user_comments
        $c = $new_arr ? count($new_arr) : 0;
        $new_arr[$c]['CID'] = $cid;
        $new_arr[$c]['PID'] = $pid;
        $new_arr[$c]['USERID'] = $userid;
        $new_arr[$c]['comment'] = $comment;
        $new_arr[$c]['date'] = $datesub;
        $profile = _profilenic($new_arr[$c]['USERID']);
        $new_arr[$c]['profilepic'] = $profile['profilepicture'];
        $new_arr[$c]['nick'] = $profile['username'];
        $new_arr[$c]['since'] = _datesince($new_arr[$c]['date']);
        $new_arr[$c]['comment'] = _getHash($new_arr[$c]['comment']);
        $data['user_comments'] = $new_arr;
        $data['comments'] = $num_comments + 1;
        $data = json_encode($data);
        file_put_contents($filename, $data);
    }
}
echo _getHash($comment);
示例#2
0
function sancomment($data)
{
    $ret = false;
    if (count($data) < 1) {
        return false;
    }
    $c = 0;
    foreach ($data as $d) {
        $ret[$c] = $d;
        $profile = _profilenic($d['USERID']);
        $ret[$c]['profilepic'] = $profile['profilepicture'];
        $ret[$c]['nick'] = $profile['username'];
        $ret[$c]['since'] = _datesince($d['date']);
        $ret[$c]['comment'] = _getHash($d['comment']);
        $c++;
    }
    return $ret;
}