Example #1
0
function push_news()
{
    global $push_news_limit;
    global $NPDS_Prefix;
    settype($push_news_limit, "integer");
    $result = sql_query("SELECT sid, title, ihome, catid FROM " . $NPDS_Prefix . "stories ORDER BY sid DESC limit {$push_news_limit}");
    if ($result) {
        echo "document.write('<a name=\"article\"></a>');\n";
        echo "document.write('<li><b>" . push_translate("Latest Articles") . "</b></li><br />');\n";
        $ibid = sql_num_rows($result);
        for ($m = 0; $m < $ibid; $m++) {
            list($sid, $title, $ihome, $catid) = sql_fetch_row($result);
            if (ctrl_aff($ihome, $catid)) {
                $title = str_replace("'", "\\'", $title);
                echo "document.write('&nbsp;-&nbsp;<a href=javascript:onclick=register(\"npds-push\",\"op=new_show&sid={$sid}&offset={$m}\"); style=\"font-size: 11px;\">" . htmlspecialchars(aff_langue($title), ENT_COMPAT | ENT_HTML401, cur_charset) . "</a><br />');\n";
            }
        }
    }
    echo "document.write('<br />');\n";
    sql_free_result($result);
}
Example #2
0
function news_aff($type_req, $sel, $storynum, $oldnum)
{
    global $NPDS_Prefix;
    // Astuce pour afficher le nb de News correct même si certaines News ne sont pas visibles (membres, groupe de membres)
    // En fait on * le Nb de News par le Nb de groupes
    $row_Q2 = Q_select("SELECT COUNT(groupe_id) AS total FROM " . $NPDS_Prefix . "groupes", 86400);
    list(, $NumG) = each($row_Q2);
    if ($NumG['total'] < 2) {
        $coef = 2;
    } else {
        $coef = $NumG['total'];
    }
    settype($storynum, "integer");
    if ($type_req == 'index') {
        $Xstorynum = $storynum * $coef;
        $result = Q_select("SELECT sid, catid, ihome FROM " . $NPDS_Prefix . "stories {$sel} ORDER BY sid DESC LIMIT {$Xstorynum}", 3600);
        $Znum = $storynum;
    }
    if ($type_req == 'old_news') {
        $Xstorynum = $oldnum * $coef;
        $result = Q_select("SELECT sid, catid, ihome FROM " . $NPDS_Prefix . "stories {$sel} ORDER BY time DESC LIMIT {$storynum},{$Xstorynum}", 3600);
        $Znum = $oldnum;
    }
    if ($type_req == 'big_story' or $type_req == 'big_topic') {
        $Xstorynum = $oldnum * $coef;
        $result = Q_select("SELECT sid, catid, ihome FROM " . $NPDS_Prefix . "stories {$sel} ORDER BY counter DESC LIMIT {$storynum},{$Xstorynum}", 3600);
        $Znum = $oldnum;
    }
    if ($type_req == 'libre') {
        $Xstorynum = $oldnum * $coef;
        $result = Q_select("SELECT sid, catid, ihome FROM " . $NPDS_Prefix . "stories {$sel}", 3600);
        $Znum = $oldnum;
    }
    if ($type_req == 'archive') {
        $Xstorynum = $oldnum * $coef;
        $result = Q_select("SELECT sid, catid, ihome FROM " . $NPDS_Prefix . "stories {$sel}", 3600);
        $Znum = $oldnum;
    }
    $ibid = 0;
    settype($tab, 'array');
    while (list(, $myrow) = each($result)) {
        $s_sid = $myrow['sid'];
        $catid = $myrow['catid'];
        $ihome = $myrow['ihome'];
        if ($ibid == $Znum) {
            break;
        }
        if ($type_req == "libre") {
            $catid = 0;
        }
        if ($type_req == "archive") {
            $ihome = 0;
        }
        if (ctrl_aff($ihome, $catid)) {
            if ($type_req == "index" or $type_req == "libre") {
                $result2 = sql_query("SELECT sid, catid, aid, title, time, hometext, bodytext, comments, counter, topic, informant, notes FROM " . $NPDS_Prefix . "stories WHERE sid='{$s_sid}' AND archive='0'");
            }
            if ($type_req == "archive") {
                $result2 = sql_query("SELECT sid, catid, aid, title, time, hometext, bodytext, comments, counter, topic, informant, notes FROM " . $NPDS_Prefix . "stories WHERE sid='{$s_sid}' AND archive='1'");
            }
            if ($type_req == "old_news") {
                $result2 = sql_query("SELECT sid, title, time, comments, counter FROM " . $NPDS_Prefix . "stories WHERE sid='{$s_sid}' AND archive='0'");
            }
            if ($type_req == "big_story" or $type_req == "big_topic") {
                $result2 = sql_query("SELECT sid, title FROM " . $NPDS_Prefix . "stories WHERE sid='{$s_sid}' AND archive='0'");
            }
            $tab[$ibid] = sql_fetch_row($result2);
            if (is_array($tab[$ibid])) {
                $ibid++;
            }
        }
    }
    @sql_free_result($result);
    return $tab;
}
Example #3
0
 if ($SuperCache) {
     $cache_clef = "[objet]==> {$q}";
     $CACHE_TIMINGS[$cache_clef] = 3600;
     $cache_obj = new cacheManager();
     $tab_sid = $cache_obj->startCachingObjet($cache_clef);
     if ($tab_sid != "") {
         $x = count($tab_sid);
     }
 } else {
     $cache_obj = new SuperCacheEmpty();
 }
 if ($cache_obj->genereting_output == 1 or $cache_obj->genereting_output == -1 or !$SuperCache) {
     $result = sql_query($q);
     if ($result) {
         while (list($sid, $aid, $title, $time, $url, $topic, $informant, $ihome) = sql_fetch_row($result)) {
             if (ctrl_aff($ihome, 0)) {
                 $tab_sid[$x]['sid'] = $sid;
                 $tab_sid[$x]['aid'] = $aid;
                 $tab_sid[$x]['title'] = $title;
                 $tab_sid[$x]['time'] = $time;
                 $tab_sid[$x]['url'] = $url;
                 $tab_sid[$x]['topic'] = $topic;
                 $tab_sid[$x]['informant'] = $informant;
                 $x++;
             }
         }
     }
 }
 if ($SuperCache) {
     $cache_obj->endCachingObjet($cache_clef, $tab_sid);
 }