예제 #1
0
         $json = file_get_contents($filename);
         $parray[0] = (array) json_decode($json);
         $post_exists = true;
     } else {
         $cache_enabled = false;
     }
 }
 $cache_enabled = true;
 if (!$cache_enabled) {
     $post_exists = does_post_exist($pid);
 }
 if ($post_exists) {
     $query = "SELECT * FROM posts_comments WHERE PID='" . mysql_real_escape_string($pid) . "' ORDER BY CID desc";
     $executequery = $conn->execute($query);
     $par = $executequery->getarray();
     $newArr = sancomment($par);
     STemplate::assign('comments', $newArr);
     STemplate::assign('totComments', count($newArr));
     if (!$cache_enabled) {
         $query = "SELECT A.*, B.username, B.profilepicture FROM posts A, members B WHERE A.PID='" . mysql_real_escape_string($pid) . "' AND A.USERID=B.USERID";
         $executequery = $conn->execute($query);
         $parray = $executequery->getarray();
     }
     $titleWithHash = _getHash($parray[0]['story']);
     $showAd = showAd($parray[0]['story']);
     // returns boolean.
     if ($parray[0]['profilepicture'] == "") {
         $parray[0]['profilepicture'] = 'noprofilepicture.jpg';
     }
     STemplate::assign('p', $parray[0]);
     STemplate::assign('titleWithHash', $titleWithHash);
예제 #2
0
        }
    }
    return $pageURL;
}
if (is_numeric($_REQUEST['pid'])) {
    $pid = intval(cleanit($_REQUEST['pid']));
    STemplate::assign('pid', $pid);
} else {
    $error = $lang['138'];
}
if ($error == "") {
    if (does_post_exist($pid)) {
        $query = "SELECT * FROM posts_comments WHERE PID='" . mysql_real_escape_string($pid) . "' ORDER BY CID desc";
        $executequery = $conn->execute($query);
        $parray = $executequery->getarray();
        $newArr = sancomment($parray);
        STemplate::assign('comments', $newArr);
        STemplate::assign('totComments', count($newArr));
        $query = "SELECT A.*, B.username, B.profilepicture FROM posts A, members B WHERE A.PID='" . mysql_real_escape_string($pid) . "' AND A.USERID=B.USERID";
        $executequery = $conn->execute($query);
        $parray = $executequery->getarray();
        $titleWithHash = _getHash($parray[0]['story']);
        if ($parray[0]['profilepicture'] == "") {
            $parray[0]['profilepicture'] = 'noprofilepicture.jpg';
        }
        STemplate::assign('p', $parray[0]);
        STemplate::assign('titleWithHash', $titleWithHash);
        $active = intval($parray[0]['active']);
        $videourl = trim($parray[0]['url']);
        $USERID = $parray[0]['USERID'];
        $category = intval($parray[0]['category']);
예제 #3
0
function getHashCountGetComments2($arr)
{
    global $config, $db;
    $re_write = false;
    $ctr = ($arr and count($arr) != 0) ? count($arr) : 0;
    for ($i = 0; $i < $ctr; $i++) {
        $pid = $arr[$i]['PID'];
        // get hash
        if (!isset($arr[$i]['story2'])) {
            // if story2 is not in the cache file, add it
            $story = $arr[$i]['story'];
            $story = _getHash($story);
            $arr[$i]['story2'] = $story;
            $re_write = true;
        }
        // comments
        if (!isset($arr[$i]['user_comments'])) {
            $query = "SELECT * FROM posts_comments WHERE PID='" . mysql_real_escape_string($pid) . "' ORDER BY CID desc LIMIT 0, 3";
            //$executequery = $conn->execute($query);
            //$parray = $executequery->getarray();
            $parray = $db->getAll($query, DB_FETCHMODE_ASSOC);
            //reverse it
            $z = count($parray);
            $na = array();
            foreach ($parray as $p) {
                $z = $z - 1;
                $na[] = $parray[$z];
            }
            $arr[$i]['user_comments'] = sancomment($na);
            $re_write = true;
        } else {
            // make sure it's an array
            $na = array();
            foreach ($arr[$i]['user_comments'] as $p) {
                $na[] = (array) $p;
                $z++;
            }
            $arr[$i]['user_comments'] = $na;
        }
        if (!isset($arr[$i]['comments'])) {
            $query = "SELECT count(PID) as totComments FROM posts_comments WHERE PID = '{$pid}'";
            //$executequery = $conn->Execute($query);
            $executequery = $db->getAll($query, DB_FETCHMODE_ASSOC);
            $arr[$i]['comments'] = $executequery[0]['totComments'];
            $re_write = true;
        }
        if ($re_write) {
            $filename = $config['basedir'] . '/themes/cache/' . $pid . '.txt';
            if (file_exists($filename)) {
                unlink($filename);
                $json = json_encode($arr[$i]);
                file_put_contents($filename, $json);
            }
        }
    }
    return $arr;
}