Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 11-17-2010, 06:41 AM
pokusek pokusek is offline
 
Join Date: Oct 2010
Posts: 154
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Problem With Custom Templates and PHP Inclusion

Hello. I want to create custom pages for my forum similar to http://tools.digitalpoint.com.
I read this manual but my PHP code somehow cannot be included. Can you help me, please?

Thank you very much!

My files:
nastroje.php
PHP Code:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT''nastroje');
define('CSRF_PROTECTION'true);  
// change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('nastroje');

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');

if (!
$vbulletin->userinfo['userid']){
print_no_permission();
}  
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################



if ($_REQUEST['do'] == 'whois'){

$navbits construct_navbits(array('' => 'WHOIS'));
$navbar render_navbar_template($navbits);
$pagetitle 'WHOIS';

$templater vB_Template::create('nastroje_whois');
vB_Template::preRegister('nastroje_whois',array('includedphp ' => $includedphp));  

}




if (empty(
$_REQUEST['do'])){
$navbits construct_navbits(array('' => 'N?stroje'));
$navbar render_navbar_template($navbits);
$pagetitle 'N?stroje';

$templater vB_Template::create('nastroje');
}


// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######


$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render());

?>
Active plugin called "nastroje_whois"
PHP Code:
ob_start();
include(
'nastroje/whois.php');
$includedphp ob_get_contents();
ob_end_clean(); 

Template nastroje_whois
PHP Code:
{vb:stylevar htmldoctype}
<
html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <
head>
    <
title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
    {
vb:raw headinclude}
    {
vb:raw headinclude_bottom}
  </
head>
  <
body>
    
    {
vb:raw header}
    
    {
vb:raw navbar}
    
    <
div id="pagetitle">
      <
h1>WHOIS</h1>
<
class="description">Slou?? k zji?t&#283;n? informac? o dom?n?ch z datab?ze WHOIS.</p> 
    
</div>
    
    <
h2 class="blockhead">WHOIS</h2>
    <
div class="blockbody">
      <
div class="blockrow">

{
vb:raw includedphp}


      </
div>
    </
div>
    
    {
vb:raw footer}
  </
body>
</
html
whois.php
PHP Code:
<?php

/*************************************************************************

php easy :: whois lookup script

==========================================================================

Author:      php easy code, www.phpeasycode.com

Web Site:    http://www.phpeasycode.com

Contact:     webmaster@phpeasycode.com

*************************************************************************/



$domain $_GET['domain'];



// For the full list of TLDs/Whois servers see http://www.iana.org/domains/root/db/ and http://www.whois365.com/en/listtld/

$whoisservers = array(

    
"ac" =>"whois.nic.ac",

    
"ae" =>"whois.nic.ae",

    
"aero"=>"whois.aero",

    
"af" =>"whois.nic.af",

    
"ag" =>"whois.nic.ag",

    
"al" =>"whois.ripe.net",

    
"am" =>"whois.amnic.net",

    
"arpa" =>"whois.iana.org",

    
"as" =>"whois.nic.as",

    
"asia" =>"whois.nic.asia",

    
"at" =>"whois.nic.at",

    
"au" =>"whois.aunic.net",

    
"az" =>"whois.ripe.net",

    
"ba" =>"whois.ripe.net",

    
"be" =>"whois.dns.be",

    
"bg" =>"whois.register.bg",

    
"bi" =>"whois.nic.bi",

    
"biz" =>"whois.biz",

    
"bj" =>"whois.nic.bj",

    
"br" =>"whois.registro.br",

    
"bt" =>"whois.netnames.net",

    
"by" =>"whois.ripe.net",

    
"bz" =>"whois.belizenic.bz",

    
"ca" =>"whois.cira.ca",

    
"cat" =>"whois.cat",

    
"cc" =>"whois.nic.cc",

    
"cd" =>"whois.nic.cd",

    
"ch" =>"whois.nic.ch",

    
"ci" =>"whois.nic.ci",

    
"ck" =>"whois.nic.ck",

    
"cl" =>"whois.nic.cl",

    
"cn" =>"whois.cnnic.net.cn",

    
"com" =>"whois.verisign-grs.com",

    
"coop" =>"whois.nic.coop",

    
"cx" =>"whois.nic.cx",

    
"cy" =>"whois.ripe.net",

    
"cz" =>"whois.nic.cz",

    
"de" =>"whois.denic.de",

    
"dk" =>"whois.dk-hostmaster.dk",

    
"dm" =>"whois.nic.cx",

    
"dz" =>"whois.ripe.net",

    
"edu" =>"whois.educause.edu",

    
"ee" =>"whois.eenet.ee",

    
"eg" =>"whois.ripe.net",

    
"es" =>"whois.ripe.net",

    
"eu" =>"whois.eu",

    
"fi" =>"whois.ficora.fi",

    
"fo" =>"whois.ripe.net",

    
"fr" =>"whois.nic.fr",

    
"gb" =>"whois.ripe.net",

    
"gd" =>"whois.adamsnames.com",

    
"ge" =>"whois.ripe.net",

    
"gg" =>"whois.channelisles.net",

    
"gi" =>"whois2.afilias-grs.net",

    
"gl" =>"whois.ripe.net",

    
"gm" =>"whois.ripe.net",

    
"gov" =>"whois.nic.gov",

    
"gr" =>"whois.ripe.net",

    
"gs" =>"whois.nic.gs",

    
"gw" =>"whois.nic.gw",

    
"gy" =>"whois.registry.gy",

    
"hk" =>"whois.hkirc.hk",

    
"hm" =>"whois.registry.hm",

    
"hn" =>"whois2.afilias-grs.net",

    
"hr" =>"whois.ripe.net",

    
"hu" =>"whois.nic.hu",

    
"ie" =>"whois.domainregistry.ie",

    
"il" =>"whois.isoc.org.il",

    
"in" =>"whois.inregistry.net",

    
"info" =>"whois.afilias.net",

    
"int" =>"whois.iana.org",

    
"io" =>"whois.nic.io",

    
"iq" =>"vrx.net",

    
"ir" =>"whois.nic.ir",

    
"is" =>"whois.isnic.is",

    
"it" =>"whois.nic.it",

    
"je" =>"whois.channelisles.net",

    
"jobs" =>"jobswhois.verisign-grs.com",

    
"jp" =>"whois.jprs.jp",

    
"ke" =>"whois.kenic.or.ke",

    
"kg" =>"www.domain.kg",

    
"ki" =>"whois.nic.ki",

    
"kr" =>"whois.nic.or.kr",

    
"kz" =>"whois.nic.kz",

    
"la" =>"whois.nic.la",

    
"li" =>"whois.nic.li",

    
"lt" =>"whois.domreg.lt",

    
"lu" =>"whois.dns.lu",

    
"lv" =>"whois.nic.lv",

    
"ly" =>"whois.nic.ly",

    
"ma" =>"whois.iam.net.ma",

    
"mc" =>"whois.ripe.net",

    
"md" =>"whois.ripe.net",

    
"me" =>"whois.meregistry.net",

    
"mg" =>"whois.nic.mg",

    
"mil" =>"whois.nic.mil",

    
"mn" =>"whois.nic.mn",

    
"mobi" =>"whois.dotmobiregistry.net",

    
"ms" =>"whois.adamsnames.tc",

    
"mt" =>"whois.ripe.net",

    
"mu" =>"whois.nic.mu",

    
"museum" =>"whois.museum",

    
"mx" =>"whois.nic.mx",

    
"my" =>"whois.mynic.net.my",

    
"na" =>"whois.na-nic.com.na",

    
"name" =>"whois.nic.name",

    
"net" =>"whois.verisign-grs.net",

    
"nf" =>"whois.nic.nf",

    
"nl" =>"whois.domain-registry.nl",

    
"no" =>"whois.norid.no",

    
"nu" =>"whois.nic.nu",

    
"nz" =>"whois.srs.net.nz",

    
"org" =>"whois.pir.org",

    
"pl" =>"whois.dns.pl",

    
"pm" =>"whois.nic.pm",

    
"pr" =>"whois.uprr.pr",

    
"pro" =>"whois.registrypro.pro",

    
"pt" =>"whois.dns.pt",

    
"re" =>"whois.nic.re",

    
"ro" =>"whois.rotld.ro",

    
"ru" =>"whois.ripn.net",

    
"sa" =>"whois.nic.net.sa",

    
"sb" =>"whois.nic.net.sb",

    
"sc" =>"whois2.afilias-grs.net",

    
"se" =>"whois.iis.se",

    
"sg" =>"whois.nic.net.sg",

    
"sh" =>"whois.nic.sh",

    
"si" =>"whois.arnes.si",

    
"sk" =>"whois.ripe.net",

    
"sm" =>"whois.ripe.net",

    
"st" =>"whois.nic.st",

    
"su" =>"whois.ripn.net",

    
"tc" =>"whois.adamsnames.tc",

    
"tel" =>"whois.nic.tel",

    
"tf" =>"whois.nic.tf",

    
"th" =>"whois.thnic.net",

    
"tj" =>"whois.nic.tj",

    
"tk" =>"whois.dot.tk",

    
"tl" =>"whois.nic.tl",

    
"tm" =>"whois.nic.tm",

    
"tn" =>"whois.ripe.net",

    
"to" =>"whois.tonic.to",

    
"tp" =>"whois.nic.tl",

    
"tr" =>"whois.nic.tr",

    
"travel" =>"whois.nic.travel",

    
"tv" => "tvwhois.verisign-grs.com",

    
"tw" =>"whois.twnic.net.tw",

    
"ua" =>"whois.net.ua",

    
"ug" =>"whois.co.ug",

    
"uk" =>"whois.nic.uk",

    
"us" =>"whois.nic.us",

    
"uy" =>"nic.uy",

    
"uz" =>"whois.cctld.uz",

    
"va" =>"whois.ripe.net",

    
"vc" =>"whois2.afilias-grs.net",

    
"ve" =>"whois.nic.ve",

    
"vg" =>"whois.adamsnames.tc",

    
"wf" =>"whois.nic.wf",

    
"ws" =>"whois.website.ws",

    
"yt" =>"whois.nic.yt",

    
"yu" =>"whois.ripe.net");



function 
LookupDomain($domain){

    global 
$whoisservers;

    
$domain_parts explode("."$domain);

    
$tld strtolower(array_pop($domain_parts));

    
$whoisserver $whoisservers[$tld];

    if(!
$whoisserver) {

        return 
"Error: No appropriate Whois server found for $domain domain!";

    }

    
$result QueryWhoisServer($whoisserver$domain);

    if(!
$result) {

        return 
"Error: No results retrieved from $whoisserver server for $domain domain!";

    }

    else {

        while(
strpos($result"Whois Server:") !== FALSE){

            
preg_match("/Whois Server: (.*)/"$result$matches);

            
$secondary $matches[1];

            if(
$secondary) {

                
$result QueryWhoisServer($secondary$domain);

                
$whoisserver $secondary;

            }

        }

    }

    return 
"$domain domain lookup results from $whoisserver server:\n\n" $result;

}



function 
LookupIP($ip) {

    
$whoisservers = array(

        
//"whois.afrinic.net", // Africa - returns timeout error :-(

        
"whois.lacnic.net"// Latin America and Caribbean - returns data for ALL locations worldwide :-)

        
"whois.apnic.net"// Asia/Pacific only

        
"whois.arin.net"// North America only

        
"whois.ripe.net" // Europe, Middle East and Central Asia only

    
);

    
$results = array();

    foreach(
$whoisservers as $whoisserver) {

        
$result QueryWhoisServer($whoisserver$ip);

        if(
$result && !in_array($result$results)) {

            
$results[$whoisserver]= $result;

        }

    }

    
$res "RESULTS FOUND: " count($results);

    foreach(
$results as $whoisserver=>$result) {

        
$res .= "\n\n-------------\nLookup results for $ip from $whoisserver server:\n\n$result";

    }

    return 
$res;

}



function 
ValidateIP($ip) {

    
$ipnums explode("."$ip);

    if(
count($ipnums) != 4) {

        return 
false;

    }

    foreach(
$ipnums as $ipnum) {

        if(!
is_numeric($ipnum) || ($ipnum 255)) {

            return 
false;

        }

    }

    return 
$ip;

}



function 
ValidateDomain($domain) {

    if(!
preg_match("/^([-a-z0-9]{2,100})\.([a-z\.]{2,8})$/i"$domain)) {

        return 
false;

    }

    return 
$domain;

}



function 
QueryWhoisServer($whoisserver$domain) {

    
$port 43;

    
$timeout 10;

    
$fp = @fsockopen($whoisserver$port$errno$errstr$timeout) or die("Socket Error " $errno " - " $errstr);

    if(
$whoisserver == "whois.verisign-grs.com"$domain "=".$domain// whois.verisign-grs.com requires the equals sign ("=") or it returns any result containing the searched string.

    
fputs($fp$domain "\r\n");

    
$out "";

    while(!
feof($fp)){

        
$out .= fgets($fp);

    }

    
fclose($fp);



    
$res "";

    if((
strpos(strtolower($out), "error") === FALSE) && (strpos(strtolower($out), "not allocated") === FALSE)) {

        
$rows explode("\n"$out);

        foreach(
$rows as $row) {

            
$row trim($row);

            if((
$row != '') && ($row{0} != '#') && ($row{0} != '%')) {

                
$res .= $row."\n";

            }

        }

    }

    return 
$res;

}

?>



<form action="<?=$_SERVER['PHP_SELF'];?>">

<p><b><label for="domain">domain:</label></b> <input type="text" name="domain" id="domain" value="<?=$domain;?>"> <input type="submit" value="Lookup"></p>

</form>

<?

if($domain) {

    $domain = trim($domain);

    if(substr(strtolower($domain), 0, 7) == "http://") $domain = substr($domain, 7);

    if(substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4);

    if(ValidateIP($domain)) {

        $result = LookupIP($domain);

    }

    elseif(ValidateDomain($domain)) {

        $result = LookupDomain($domain);

    }

    else die("Nevalidn? vstup!");

    echo "<pre>\n" . $result . "\n</pre>\n";

}

?>

</body>

</html>
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:14 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03196 seconds
  • Memory Usage 2,437KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)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)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete