View Single Post
  #5  
Old 07-21-2007, 05:01 PM
CP, CP, is offline
 
Join Date: Aug 2005
Location: UK London
Posts: 276
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas View Post
Well, I don't know what apexternal.php does do
Try require_once
It gives me a blank page... Well im using these two hacks here:

[ITech] vBExternal Lite: https://vborg.vbsupport.ru/showthread.php?t=147344
Deluxe vB User login and access control on non vB pages: https://vborg.vbsupport.ru/showthread.php?t=108026


the apexternal is below:
PHP Code:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # [ITech] vBExternal LITE
 * Created By Inferno Technologies
 * Copyright 2004-2007
 * All rights reserved
 * Project Development Team: Zero Tolerance, Acid Burn
\*======================================================================*/

// ---------------------------------------------------
// Start Set PHP Environment
// ---------------------------------------------------

error_reporting(E_ALL & ~E_NOTICE);

// ---------------------------------------------------
// End Set PHP Environment
// ---------------------------------------------------

// ---------------------------------------------------
// Start Define Important Constants
// ---------------------------------------------------

define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''apexternal');

// ---------------------------------------------------
// End Define Important Constants
// ---------------------------------------------------

// ---------------------------------------------------
// Start Cache Of Any Needed Templates/Phrase's
// ---------------------------------------------------

$phrasegroups = array();

$specialtemplates = array(
                
'options',
);

$actiontemplates = array();

$globaltemplates = array();

// ---------------------------------------------------
// End Cache Of Any Needed Templates/Phrase's
// ---------------------------------------------------

// ---------------------------------------------------
// Start Call DB & Establish Connection
// ---------------------------------------------------

if( !file_exists('./includes/config.php'))
{
    echo 
"includes/config.php does not exist. Cannot continue.";
    exit;
}

require_once(
'./includes/class_core.php');
require(
'./includes/config.php');

DEFINE('DIR','.');
DEFINE('TABLE_PREFIX',$config['Database']['tableprefix']);

$vbulletin =& new vB_Registry(); // Fake an OOP Object

switch (strtolower($config['Database']['dbtype']))
{
    
// load standard MySQL class
    
case 'mysql':
    case 
'':
    {
        
$db =& new vB_Database($vbulletin);
        break;
    }

    
// load MySQLi class
    
case 'mysqli':
    {
        
$db =& new vB_Database_MySQLi($vbulletin);
        break;
    }

    
// load extended, non MySQL class
    
default:
    {
        die(
'Fatal error: Database class not found');
    }
}

require_once(
'./includes/functions.php');


// make database connection
$db->connect(
    
$config['Database']['dbname'],
    
$config['MasterServer']['servername'],
    
$config['MasterServer']['port'],
    
$config['MasterServer']['username'],
    
$config['MasterServer']['password'],
    
$config['MasterServer']['usepconnect'],
    
$config['SlaveServer']['servername'],
    
$config['SlaveServer']['port'],
    
$config['SlaveServer']['username'],
    
$config['SlaveServer']['password'],
    
$config['SlaveServer']['usepconnect'],
    
$config['Mysqli']['ini_file']
);

$vbulletin->db =& $db;

// ---------------------------------------------------
// End Call DB & Establish Connection
// ---------------------------------------------------

// ---------------------------------------------------
// Start Require Globalized Settings
// ---------------------------------------------------

class vBulletinHook { function fetch_hook() { return false; } }

define('TIMENOW'time());
require_once(
'./includes/class_bbcode.php');
$Data "";       // Page Output Variable


$datastore_class = (!empty($config['Misc']['datastore'])) ? $config['Misc']['datastore'] : 'vB_Datastore';

if (
$datastore_class != 'vB_Datastore')
{
    require_once(
'./includes/class_datastore.php');
}
$vbulletin->datastore =& new $datastore_class($vbulletin$db);
$vbulletin->datastore->fetch($specialtemplates);

// ---------------------------------------------------
// End Require Globalized Settings
// ---------------------------------------------------

    // ---------------------------------------------------
    // Start Globalized Function - LoadTemplate
    // ---------------------------------------------------

    
function LoadTemplate($template ""){

    
$template "apexternal/{$template}";

        if(!
file_exists($template)){
        
RunError("System was unable to find the template '{$template}'");
        }

        if(!
$Handler fopen($template,'r')){
        
RunError("System was unable to open the template '{$template}'");
        }

    
$template fread($Handler,filesize($template));
    
fclose($Handler);

    return 
$template;
    }

    
// ---------------------------------------------------
    // End Globalized Function - LoadTemplate
    // ---------------------------------------------------

    // ---------------------------------------------------
    // Start Globalized Function - RunError
    // ---------------------------------------------------

    
function RunError($message ""){
    echo 
"<font size='1' face='verdana'>There was an error while processing apexternal:<br />{$message}</font>";
    exit;
    }

    
// ---------------------------------------------------
    // End Globalized Function - RunError
    // ---------------------------------------------------

    // ---------------------------------------------------
    // Start Globalized Function - ParseTemplate
    // ---------------------------------------------------

    
function ParseTemplate($template$parser = array(), $doGlobals 0){
    global 
$vbulletin;

        if(
is_array($parser)){
            foreach(
$parser as $find => $replace){
            
$template str_replace("{".$find."}"$replace$template);
            }
        } else if(
$doGlobals){
        
$RepGlobals = array(
                    
'url' => $vbulletin->options['bburl'],
                );

            foreach(
$RepGlobals as $find => $replace){
            
$template str_replace("{".$find."}"$replace$template);
            }

        }

    return 
$template;
    }

    
// ---------------------------------------------------
    // End Globalized Function - ParseTemplate
    // ---------------------------------------------------

    // ---------------------------------------------------
    // FUNCTION: output_NewestMembers
    // DETAIL:   Outputs newest X members in order of
        //           newest registered first. $a
    //           specifies amount to show (Default 5)
    // ---------------------------------------------------

    
function output_NewestMembers($a 5){
    global 
$db$Data;

    
// Define amount to show
    
$Amount = ($a)? intval($a) : 5;

    
// Load Template
    
$Template LoadTemplate("newest_members.html");

    
// Collect Data
    
$NewestMem $db->query("select username,posts,userid from ".TABLE_PREFIX."user order by joindate desc limit 0,$Amount");

        while(
$Member $db->fetch_array($NewestMem)){
        
$Data .= ParseTemplate($Template,
                            array(
                                
'username' => $Member['username'],
                                
'posts'    => vb_number_format($Member['posts']),
                                
'userid'   => $Member['userid'],
                            )
            );
        }

    
doOutput();
    }

    
// ---------------------------------------------------
    // FUNCTION: output_TopPosters
    // DETAIL:   Outputs Top X posts in order of
        //           highest post count descending. $a
    //           specifies amount to show (Default 5)
    // ---------------------------------------------------

    
function output_TopPosters($a 5){
    global 
$db$Data;

    
// Define amount to show
    
$Amount = ($a)? intval($a) : 5;

    
// Load Template
    
$Template LoadTemplate("newest_members.html");

    
// Collect Data
    
$TopPosters $db->query("select username,posts,userid from ".TABLE_PREFIX."user order by posts desc limit 0,$Amount");

        while(
$Member $db->fetch_array($TopPosters)){
        
$Data .= ParseTemplate($Template,
                            array(
                                
'username' => $Member['username'],
                                
'posts'    => vb_number_format($Member['posts']),
                                
'userid'   => $Member['userid'],
                            )
            );
        }

    
doOutput();
    }

    
// ---------------------------------------------------
    // FUNCTION: output_NewestThreads
    // DETAIL:   Outputs X newest threads ordered by
        //           start date descending. $a
    //           specifies amount to show (Default 5)
        //           and $f can specify certain forums
    //           to grab from (1,3,4), by default it pulls
        //           from all forums.
    // ---------------------------------------------------

    
function output_NewestThreads($a 5,$f ""){
    global 
$db$Data;

    
// Define amount to show
    
$Amount = ($a)? intval($a) : 5;

    
// Define Forum(s) To Pull From
    
$Forums = ($f)? $f'';
    
$SQL    '';

        if(
$Forums){
        
$SQL " where forumid in({$Forums})";
        }

    
// Load Template
    
$Template LoadTemplate("newest_threads.html");

    
// Collect Data
    
$NewestThreads $db->query("select * from ".TABLE_PREFIX."thread{$SQL} order by dateline desc limit 0,$Amount");

        while(
$Thread $db->fetch_array($NewestThreads)){
        
$Data .= ParseTemplate($Template,
                            array(
                                
'threadid'     => $Thread['threadid'],
                                
'threadname'   => $Thread['title'],
                                
'postuserid'   => $Thread['postuserid'],
                                
'postusername' => $Thread['postusername'],
                                
'replies'      => vb_number_format($Thread['replycount']),
                                
'views'        => vb_number_format($Thread['views']),
                                
'lastposter'   => $Thread['lastposter'],
                            )
            );
        }

    
doOutput();
    }

    
// ---------------------------------------------------
    // FUNCTION: output_NewestReplies
    // DETAIL:   Outputs X newest threads ordered by
        //           last post descending. $a
    //           specifies amount to show (Default 5)
        //           and $f can specify certain forums
    //           to grab from (1,3,4), by default it pulls
        //           from all forums.
    // ---------------------------------------------------

    
function output_NewestReplies($a 5,$f ""){
    global 
$db$Data;

    
// Define amount to show
    
$Amount = ($a)? intval($a) : 5;

    
// Define Forum(s) To Pull From
    
$Forums = ($f)? $f'';
    
$SQL    '';

        if(
$Forums){
        
$SQL " where forumid in({$Forums})";
        }

    
// Load Template
    
$Template LoadTemplate("newest_threads.html");

    
// Collect Data
    
$NewestReplies $db->query("select * from ".TABLE_PREFIX."thread{$SQL} order by lastpost desc limit 0,$Amount");

        while(
$Thread $db->fetch_array($NewestReplies)){
        
$Data .= ParseTemplate($Template,
                            array(
                                
'threadid'     => $Thread['threadid'],
                                
'threadname'   => $Thread['title'],
                                
'postuserid'   => $Thread['postuserid'],
                                
'postusername' => $Thread['postusername'],
                                
'replies'      => vb_number_format($Thread['replycount']),
                                
'views'        => vb_number_format($Thread['views']),
                                
'lastposter'   => $Thread['lastposter'],
                            )
            );
        }

    
doOutput();
    }


    
// ---------------------------------------------------
    // FUNCTION: output_News
    // DETAIL:   Outputs the first post from X threads
        //           from a specific forum (ordered by newest
        //           first)
    // ---------------------------------------------------

    
function output_News($a 5,$f ""){
    global 
$db$Data$vbulletin;

    
// Define amount to show
    
$Amount = ($a)? intval($a) : 5;

    
// Define Forum To Pull From
    
$Forum = ($f)? intval($f): '';

        if(!
$Forum){
        
RunError("No specified forum to pull news from.");
        }

    
// Load Template
    
$Template LoadTemplate("news.html");

    
// Collect Data
    
$NewestNews $db->query("
            select t.*,p.pagetext
            from "
.TABLE_PREFIX."thread t
            left join "
.TABLE_PREFIX."post p on(p.postid=t.firstpostid)
            where t.forumid = 
$Forum
            order by dateline desc
            limit 0,
$Amount");


    
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());

        while(
$News $db->fetch_array($NewestNews)){
        
$Data .= ParseTemplate($Template,
                            array(
                                
'threadid'     => $News['threadid'],
                                
'threadname'   => $News['title'],
                                
'postuserid'   => $News['postuserid'],
                                
'postusername' => $News['postusername'],
                                
'post'         => $bbcode_parser->parse(unhtmlspecialchars($News['pagetext']), $f),
                                
'comments'     => vb_number_format($News['replycount']),
                            )
            );
        }

    
doOutput();
    }


    
// ---------------------------------------------------
    // FUNCTION: output_UsersOnline
    // DETAIL:   Outputs All Users Online In The Forum
    // ---------------------------------------------------

    
function output_UsersOnline(){
    global 
$db$Data$vbulletin;

    
// Load Template
    
$Template LoadTemplate("users_online.html");

    
$cache = array();

    
// Collect Data
    
$datecut      TIMENOW $vbulletin->options['cookietimeout'];
    
$UsersOnline $db->query("
        SELECT
            user.username, (user.options) AS invisible, user.usergroupid,
            session.userid,
            IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
        FROM " 
TABLE_PREFIX "session AS session
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON(user.userid = session.userid)
        WHERE session.lastactivity > 
$datecut and user.userid > 0
        " 
iif($vbulletin->options['displayloggedin'] == 1"ORDER BY username ASC") . "
    "
);

        while(
$User $db->fetch_array($UsersOnline)){
            if(!
$cache[$User['userid']]){
            
$cache[$User['userid']] = $User['userid'];

            
$Data .= ParseTemplate($Template,
                                array(
                                    
'userid'     => $User['userid'],
                                    
'username'   => $User['username'],
                                )
                );
            }
        }

    unset(
$cache);
    
doOutput();
    }

    function 
doOutput(){
    global 
$Data$vbulletin;

    
$Data str_replace('images/',"{$vbulletin->options[bburl]}/images/",$Data);

    echo 
ParseTemplate($Data,"",1);
    
$Data "";
    }
?>

Cheers, thanks!
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02173 seconds
  • Memory Usage 2,043KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete