vendredi 13 décembre 2019

How do I can exclude others ID from working php code

I want to use some php code on one of theme excluding others. for that I'm using this code, but it take effects on all of my themes... How can I exclude ID's on which I want to disable this function?

function extra_posts_forum(&$forum)
{

    global $unapproved, $lastpost_subject, $mybb, $fids, $hidelastpostinfo, $db, **$theme,** $lastpost, $templates, $cache, $parser, $cache;

    **if($theme['tid'] == "22")**
    if($forum['type'] == "f" && (THIS_SCRIPT =="index.php" || THIS_SCRIPT == "forumdisplay.php")) {


        $order = $mybb->settings['extra_posts_order'];
        if($order == 1) {
            $order_by = "t.views";
        }elseif($order == 2) {
            $order_by = "t.replies";
        }elseif($order == 3) {
            $order_by = "t.lastpost";
        }elseif($order == 4) {
            $order_by = "t_date";
        }else {
           $order_by = "t.lastpost";
        }
        $max_characters = $mybb->settings['extra_posts_characterscutoff'];
        if(!$max_characters) {
            $max_characters = 25;
        }
        $forum_array = array();
        $forums = $cache->read('forums');
        $fids = array();
        $fids[] = $forum['fid'];
        foreach($forums as $forum_key => $data) {
        if($data['type'] == "f") {
           if($data['parentlist']) {
             $parents = explode(",",  $data['parentlist']);
             if(in_array($forum['fid'], $parents)) {
                 //$fids[] = $data['fid'];
             }

           }
        }
        }
        $fids = implode(",", $fids);

        $query = $db->query("
        SELECT t.replies, t.views, t.dateline AS t_date, t.views, t.replies, t.tid AS thread_id, t.tid, t.fid, t.subject AS subject, t.lastpost, t.lastposter, t.lastposteruid, p.uid, p.pid, p.fid, p.tid, p.username, p.dateline, p.fid
        FROM ".TABLE_PREFIX."threads t
        LEFT JOIN ".TABLE_PREFIX."posts p ON (p.tid=t.tid AND t.lastposteruid=p.uid AND p.dateline = t.lastpost AND p.fid=t.fid)
        WHERE t.fid IN ({$fids}) AND t.visible !='-2'
        ORDER BY {$order_by} DESC
        LIMIT {$mybb->settings['extra_posts_num']}
        ");
        while($results = $db->fetch_array($query)) {
           //$forum['extra_lastposts'] .= "<br />1234";

           $lastpost_link = get_thread_link($results['thread_id'], 0, "lastpost");
           $lastpost_profilelink = build_profile_link($results['lastposter'],$results['lastposteruid']);
           $lastpost_date = my_date('relative', $results['lastpost']);
           $lastpost_subject = $full_lastpost_subject = $parser->parse_badwords($results['subject']);
                    if(my_strlen($lastpost_subject) > $max_characters)
                    {
                        $lastpost_subject = my_substr($lastpost_subject, 0, $max_characters)."...";
                    }
                    //$forum['extra_lastposts'] .= "<br />".$lastpost_date;
           //if(0 > $counter++) {
             eval("\$forum['extra_lastposts'] .= \"".$templates->get("forumbit_depth2_forum_lastpost")."\";"); 
               //print_r($results);
           //}         
        }
    }

I've added only global$theme and than if($theme['tid'] == "X") where X is ID of my theme... but if you provide the ID of the template on which I want to use this code, nothing will be displayed on the rest ...

Now the question is how other which function I mst to add to exclude this code from working on other IDs?

Aucun commentaire:

Enregistrer un commentaire