Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles

Reply
 
Thread Tools
[HOW TO - vB4] Create your own vBulletin page
Lynne's Avatar
Lynne
Join Date: Sep 2004
Posts: 41,180

 

California/Idaho
Show Printable Version Email this Page Subscription
Lynne Lynne is offline 11-15-2009, 10:00 PM

This is an updated article on how to create your own vbulletin powered page. It's only for use with vB4.

This is NOT my work. I'm posting this from another thread where vB Style took the time to write this out. And his work is based on the article by Gary King here - How to create your own vBulletin-powered page! (uses vB templates)

Instructions to Create your Own Page:


1. Create the php page:
- Create a new file, whatever you want to call it (let's say test.php).
- Open up test.php and add the following (replace TEST with whatever template you want to show - WARNING: the template name is CASE SENSITIVE!!!):
Code:
<?php

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

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

define('THIS_SCRIPT', 'test');
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('TEST',
);

// 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');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits = construct_navbits(array('' => 'Test Page'));
$navbar = render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'My Page Title';

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

$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
print_output($templater->render());

?>
- Be sure to change 'TEST' to the actual template name (WARNING: the template name is CASE SENSITIVE!!!), and change 'test' to the filename or a unique name for the page. Also, change 'Test Page' and 'My Page Title' to whatever you want to show in the navbits, such as 'Viewing Member Profile' (just an example).

2. Create the Template:
- If you are in debug mode, create the template in your MASTER STYLE so it shows up in all your styles, otherwise make sure you create the template in the style you are using. If following the page above, call the template TEST (WARNING: the template name is CASE SENSITIVE!!!) with the following content:
HTML 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>{vb:raw pagetitle}</h1>
    </div>
    
    <h2 class="blockhead">Title</h2>
    <div class="blockbody">
      <div class="blockrow">
        Text
      </div>
    </div>
    
    {vb:raw footer}
  </body>
</html>
.
Instructions to Add your Page to the Who's Online List (WOL):
Create two plugins using the following hooks. Replace mypage and similar with your information.

1. hook location - online_location_process:
Code:
switch ($filename)
{
    case 'test.php':
        $userinfo['activity'] = 'mypage';
        break;
// add more cases here if you have more than one custom page. no need for multiple plugins. one plugin can handle all.
}
.
2. hook location online_location_unknown:
Code:
switch ($userinfo['activity'])
{
    case 'mypage':
        $userinfo['where'] = '<a href="test.php?'.$vbulletin->session->vars[sessionurl].'">My Page</a>';
        $userinfo['action'] = "Viewing My Page";
        $handled = true;
        break;
// add more cases here if you have more than one custom page. no need for multiple plugins. one plugin can handle all.
}
.
The colored part in the code above shows what you need to change in the plugins (both reds should be the same and both blues should be the same, whereas green can be whatever you want).


Please see this article for help with rendering templates - [vB4] Rendering templates and registering variables - a short guide
Reply With Quote
  #752  
Old 01-16-2012, 06:50 AM
SavSin SavSin is offline
 
Join Date: Jan 2012
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The page should look like this.
http://www.xvgaming.com/games/stats/bfstats.php
And here is the (second page) using this article to create the template
http://www.xvgaming.com/bfstatsbynam...M_0:0:21788544

Here is the php file (standalone) that makes it like bfstats.php

PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>
    <LINK REL=StyleSheet HREF="bfstats.css" TYPE="text/css">
</head>

<body>

<div id="wrapper">

<div id="branding">
    <a href="http://www.xvgaming.com/">
        <img src="http://www.xvgaming.com/images/xvgaming/xvgaming_logo2.png" alt="Logo">
    </a>    
</div>

<div id="navbar">
    <ul>
        <li class="homeborder"><a href="http://www.xvgaming.com/">Home</a></li>
        <li class="selected"><a href="http://www.xvgaming.com/forum.php">Forum</a></li>
        <li><a href="http://shop.xvgaming.com/">Shop</a></li>
    </ul>
</div>

<div id="lowerbranding">
&nbsp;
</div>

<div id="container">

    <div id="navlinks">

        <a href="http://www.xvgaming.com"><img src="http://www.xvgaming.com/images/xvgaming/images/misc/navbit-home.png"></a>&nbsp;
        <a href="#">Stats</a>&nbsp;
        <img src="http://www.xvgaming.com/images/xvgaming/images/misc/navbit-arrow-right.png">&nbsp;
        <a href="http://www.xvgaming.com/games/stats/bfstats.php">Battlefield</a>
        
    </div>

    <div id="content">
        
        <?php
            $host
="localhost";
            
$user="wanderzo_savsin";
            
$password="savsin3";
            
$database="wanderzo_battlefield";
            
            
mysql_connect($host$user$password);
            
            @
mysql_select_db($database) or die("Unable To select database");
            
            
$query "SELECT * FROM XpTable WHERE (player_total_xp > 75) ORDER BY player_total_xp DESC";
            
            
$result mysql_query($query);
            
            
$num mysql_numrows($result);
            
            
mysql_close();
        
?>
        
        <div id="topbar">
    
            <div id="prevlink">
            
                <?php
                $incriment 
$_GET['nextpage'];
                
$startid $incriment 0;
                
$statsperpage 15;
                
                    if(
$startid 0)
                    {
                
?>
                        <a class="button" href="http://www.xvgaming.com/games/stats/bfstats.php?nextpage=<?php echo $incriment-$statsperpage?>"> &laquo; Back </a>
                <?php
                    
}
                    else
                    {
                
?>
                        <a class="button" href="#">&laquo; Back </a>  
                <?php
                    
}
                
?>
            
            </div>
        
            <div id="steamform">
            
                <form method="get" action="bfstatsbyname.php">
                <label>Enter Your SteamID:</label>
                <input type="text" maxlength="20" name="SteamID" value="STEAM_0:1:23456789" onFocus="if(value == 'STEAM_0:1:23456789') {value=''}" onBlur="if(value=='') {value='STEAM_0:1:23456789'}"/>
                <button type="submit">Submit</button>
                <div class="spacer"></div>
                </form>
                
            </div>
            
            <div id="nextlink">
                
                <?php                
                    
if($startid $statsperpage $num)
                    {
                    
?>
                    <a class="button" href="http://www.xvgaming.com/games/stats/bfstats.php?nextpage=<?php echo $incriment $statsperpage?>">Next &raquo;</a>
                    <?php
                    
}
                    else
                    {
                    
?>
                    <a class="button" href="#">Next &raquo; </a>  
                    <?php
                    
}
                
?>
            
            </div>
            
            <div class="spacer"></div>
        
        </div>
        
        <table class="stats">
            <tr>
                <th class="stats">Rank</th>
                <th class="stats">Name</th>
                <th class="stats">XP</th>
                <th class="stats">Assault</th>
                <th class="stats">Special Ops</th>
                <th class="stats">Sniper</th>
                <th class="stats">Engineer</th>
                <th class="stats">Medic</th>
                <th class="stats">Support</th>
            </tr>
        <?php
        $i 
$startid;
        
$RankNumber $startid 1;
        
            while(
$i $num)
            {
                
$player_id=mysql_result($result$i"player_id");
                
$player_name=mysql_result($result,$i,"player_name");
                
$player_total_xp=mysql_result($result,$i,"player_total_xp");
                
$player_class_assault_xp=mysql_result($result,$i,"player_class_assault_xp");
                
$player_class_specops_xp=mysql_result($result,$i,"player_class_specops_xp");
                
$player_class_sniper_xp=mysql_result($result,$i,"player_class_sniper_xp");
                
$player_class_engineer_xp=mysql_result($result,$i,"player_class_engineer_xp");
                
$player_class_medic_xp=mysql_result($result,$i,"player_class_medic_xp");
                
$player_class_support_xp=mysql_result($result,$i,"player_class_support_xp");
                
                if(
$i < ($startid $statsperpage))
                {
        
?>
                    <tr>
                        <td class="stats"><?php echo $RankNumber?></td>
                        <td class="stats"><a href="http://www.xvgaming.com/games/stats/bfstatsbyname.php?SteamID=<?php echo $player_id?>&Rank=<?php echo $RankNumber?>"><?php echo $player_name?></a></td>
                        <td class="stats"><?php echo $player_total_xp?></td>
                        <td class="stats"><?php echo $player_class_assault_xp?></td>
                        <td class="stats"><?php echo $player_class_specops_xp?></td>
                        <td class="stats"><?php echo $player_class_sniper_xp?></td>
                        <td class="stats"><?php echo $player_class_engineer_xp?></td>
                        <td class="stats"><?php echo $player_class_medic_xp?></td>
                        <td class="stats"><?php echo $player_class_support_xp?></td>
                    </tr>
            
        <?php
                    $i
++;
                    
$RankNumber++;
                }
                else
                {                    
                    break;
                }
            }
        
?>
        </table>
        
    </div>
    
    <div class="spacer"></div>
    
    <div id="footer">
        
        <div id="footerprevlink">
        
            <?php
            $incriment 
$_GET['nextpage'];
            
$startid $incriment 0;
            
$statsperpage 15;
            
                if(
$startid 0)
                {
            
?>
                    <a class="button" href="http://www.xvgaming.com/games/stats/bfstats.php?nextpage=<?php echo $incriment-$statsperpage?>"> &laquo; Back </a>
            <?php
                
}
                else
                {
            
?>
                    <a class="button" href="#">&laquo; Back </a>  
            <?php
                
}
            
?>
        
        </div>
        
        <div id="footernextlink">
            
            <?php
                $incriment 
$_GET['nextpage'];
                
$startid $incriment 0;
                
                if(
$startid $statsperpage $num)
                {
                
?>
                <a class="button" href="http://www.xvgaming.com/games/stats/bfstats.php?nextpage=<?php echo $incriment $statsperpage?>">Next &raquo;</a>
                <?php
                
}
                else
                {
                
?>
                <a class="button" href="#">Next &raquo; </a>  
                <?php
                
}
            
?>
        
        </div>
        
        <div class="spacer"></div>
        
    </div>

    <div class="spacer"></div>
    
</div>

</div>

</body>

</html>
Here is a link to what it looks like when i do the stuff for the template. I think the issue is that when it loops to create the table rows. There is only one set of variables which get changed each loop. So I think i need to create seperate variables for each row(while it loops and register them all in the loop)

Atleast thats what i think is wrong with it. Here is the link and the php/template files

http://www.xvgaming.com/bfstats.php

PHP Code:
<?php

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

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

define('THIS_SCRIPT''bfstats');
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('BfStats',
);

// 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');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

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

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle 'Battlefield Stats';

$host="localhost";
$user="wanderzo_savsin";
$password="savsin3";
$database="wanderzo_battlefield";

mysql_connect($host$user$password);

@
mysql_select_db($database) or die("Unable To select database");

$query "SELECT * FROM XpTable WHERE (player_total_xp > 75) ORDER BY player_total_xp DESC";

$result mysql_query($query);

$num mysql_numrows($result);

mysql_close();

$incriment $_GET['nextpage'];
$startid $incriment 0;
$statsperpage 15;

if(
$startid 0)
{
    
$prevstatspage $incriment-$statsperpage;
    
$prevlink '<a class="button" href="http://www.xvgaming.com/bfstats.php?nextpage=';
    
$prevlink2 '"> &laquo; Back </a>';
}
else
{
    
$prevlink '<a class="button" href="http://www.xvgaming.com/bfstats.php#">&laquo; Back </a>';
}
            
if(
$startid $statsperpage $num)
{
    
$nextstatspage = ($incriment $statsperpage);
    
$nextlink '<a class="button" href="http://www.xvgaming.com/bfstats.php?nextpage=';
    
$nextlink2 '">Next &raquo;</a>';
}
else
{
    
$nextlink '<a class="button" href="http://www.xvgaming.com/bfstats.php#">Next &raquo; </a>';
}

$i $startid;
$RankNumber $startid 1;

while(
$i $num)
{
    
$player_id=mysql_result($result$i"player_id");
    
$player_name=mysql_result($result,$i,"player_name");
    
$player_total_xp=mysql_result($result,$i,"player_total_xp");
    
$player_class_assault_xp=mysql_result($result,$i,"player_class_assault_xp");
    
$player_class_specops_xp=mysql_result($result,$i,"player_class_specops_xp");
    
$player_class_sniper_xp=mysql_result($result,$i,"player_class_sniper_xp");
    
$player_class_engineer_xp=mysql_result($result,$i,"player_class_engineer_xp");
    
$player_class_medic_xp=mysql_result($result,$i,"player_class_medic_xp");
    
$player_class_support_xp=mysql_result($result,$i,"player_class_support_xp");
    
    if(
$i < ($startid $statsperpage))
    {
        
$starttablerow '<tr>';
            
$starttablecell1 '<td class="stats">';
            
$endtablecell1 '</td>';
            
            
$starttablecell2 '<td class="stats"><a href="http://www.xvgaming.com/bfstatsbyname.php?SteamID=';
            
$tablecell2center '">';
            
$endtablecell2 '</a></td>';
            
            
$starttablecell3 '<td class="stats">';
            
$endtablecell3 '</td>';
            
            
$starttablecell4 '<td class="stats">';
            
$endtablecell4 '</td>';
            
            
$starttablecell5 '<td class="stats">';
            
$endtablecell5 '</td>';
            
            
$starttablecell6 '<td class="stats">';
            
$endtablecell6 '</td>';
            
            
$starttablecell7 '<td class="stats">';
            
$endtablecell7 '</td>';
            
            
$starttablecell8 '<td class="stats">';
            
$endtablecell8 '</td>';
            
            
$starttablecell9 '<td class="stats">';
            
$endtablecell9 '</td>';
            
        
$endtablerow '</tr>';
        
        
$i++;
        
$RankNumber++;
    }
    else
    {                    
        break;
    }
}


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

$templater vB_Template::create('BfStats');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);


$templater->register('prevstatspage'$prevstatspage);
$templater->register('prevlink'$prevlink);
$templater->register('prevlink2'$prevlink2);

$templater->register('nextstatspage'$nextstatspage);
$templater->register('nextlink'$nextlink);
$templater->register('nextlink2'$nextlink2);

//Rank Info
$templater->register('RankNumber'$RankNumber);
$templater->register('player_id'$player_id);
$templater->register('player_name'$player_name);
$templater->register('player_total_xp'$player_total_xp);
$templater->register('player_class_assault_xp'$player_class_assault_xp);
$templater->register('player_class_specops_xp'$player_class_specops_xp);
$templater->register('player_class_sniper_xp'$player_class_sniper_xp);
$templater->register('player_class_engineer_xp'$player_class_engineer_xp);
$templater->register('player_class_medic_xp'$player_class_medic_xp);
$templater->register('player_class_support_xp'$player_class_support_xp);

//Start Table
$templater->register('starttablerow'$starttablerow);

//Open Table Rows
$templater->register('starttablecell1'$starttablecell1);
$templater->register('starttablecell2'$starttablecell2);
$templater->register('starttablecell3'$starttablecell3);
$templater->register('starttablecell4'$starttablecell4);
$templater->register('starttablecell5'$starttablecell5);
$templater->register('starttablecell6'$starttablecell6);
$templater->register('starttablecell7'$starttablecell7);
$templater->register('starttablecell8'$starttablecell8);
$templater->register('starttablecell9'$starttablecell9);

//Cell Centers
$templater->register('tablecell2center'$tablecell2center);

//End the table rows
$templater->register('endtablecell1'$endtablecell1);
$templater->register('endtablecell2'$endtablecell2);
$templater->register('endtablecell3'$endtablecell3);
$templater->register('endtablecell4'$endtablecell4);
$templater->register('endtablecell5'$endtablecell5);
$templater->register('endtablecell6'$endtablecell6);
$templater->register('endtablecell7'$endtablecell7);
$templater->register('endtablecell8'$endtablecell8);
$templater->register('endtablecell9'$endtablecell9);

//End table
$templater->register('endtablerow'$endtablerow);

print_output($templater->render());
?>
Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml"<vb:if condition="$vboptions['enablefacebookconnect']"> xmlns:fb="http://www.facebook.com/2008/fbml"</vb:if>  dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
	
	<LINK REL=StyleSheet HREF="games/stats/player_stats.css" TYPE="text/css">
		
	{vb:raw headinclude}
	<title>{vb:raw pagetitle}</title>

	<vb:if condition="$includecss">
		<vb:if condition="$vboptions['storecssasfile']">
			<vb:each from="includecss" value="file">
				{vb:cssfile {vb:raw file}}
			</vb:each>
		<vb:else />
			{vb:cssfile {vb:raw includecss}}
		</vb:if>
	</vb:if>
        {vb:raw headinclude_bottom}
</head>
<body>

	{vb:raw header}
	
	{vb:raw navbar}
	
	<div id="content">
		
		<div id="topbar">
	
			<div id="prevlink">
			
				{vb:raw prevlink}{vb:raw prevstatspage}{vb:raw prevlink2}
			
			</div>
		
			<div id="steamform">
			
				<form method="get" action="http://www.xvgaming.com/bfstatsbyname.php">
				<label>Enter Your SteamID:</label>
				<input type="text" maxlength="20" name="SteamID" value="STEAM_0:1:23456789" onFocus="if(value == 'STEAM_0:1:23456789') {value=''}" onBlur="if(value=='') {value='STEAM_0:1:23456789'}"/>
				<button type="submit">Submit</button>
				<div class="spacer"></div>
				</form>
				
			</div>
			
			<div id="nextlink">
				
				{vb:raw nextlink}{vb:raw nextstatspage}{vb:raw nextlink2}
			
			</div>
			
			<div class="spacer"></div>
		
		</div>
		
		<table class="stats">
			<tr>
				<th class="stats">Rank</th>
				<th class="stats">Name</th>
				<th class="stats">XP</th>
				<th class="stats">Assault</th>
				<th class="stats">Special Ops</th>
				<th class="stats">Sniper</th>
				<th class="stats">Engineer</th>
				<th class="stats">Medic</th>
				<th class="stats">Support</th>
			</tr>
			
			{vb:raw starttablerow}
				{vb:raw starttablecell1}{vb:raw RankNumber}{vb:raw endtablecell1}
				{vb:raw starttablecell2}{vb:raw player_id}{vb:raw tablecell2center}{vb:raw player_name}{vb:raw endtablecell2}
				{vb:raw starttablecell3}{vb:raw player_total_xp}{vb:raw endtablecell3}
				{vb:raw starttablecell4}{vb:raw player_class_assault_xp}{vb:raw endtablecell4}
				{vb:raw starttablecell5}{vb:raw player_class_specops_xp}{vb:raw startendtablecell5}
				{vb:raw starttablecell6}{vb:raw player_class_sniper_xp}{vb:raw endtablecell6}
				{vb:raw starttablecell7}{vb:raw player_class_engineer_xp}{vb:raw endtablecell7}
				{vb:raw starttablecell8}{vb:raw player_class_medic_xp}{vb:raw endtablecell8}
				{vb:raw starttablecell9}{vb:raw $player_class_support_xp}{vb:raw endtablecell9}
			{vb:raw endtablerow}
		</table>
		<div class="spacer">&nbsp;</div>
	</div>
	<div class="spacer"></div>
	{vb:raw footer}
	
</body>
</html>
So how would I be able to make the second bit of code using the templates to create the table rows like in the first standalone bfstats.php.

Thanks abunch in advanced.
Reply With Quote
  #753  
Old 01-16-2012, 09:51 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why are you doing all these start and stop table rows? Why not just:

PHP Code:
while($i $num)
{
    
$player_id=mysql_result($result$i"player_id");
    
$player_name=mysql_result($result,$i,"player_name");
    
$player_total_xp=mysql_result($result,$i,"player_total_xp");
    
$player_class_assault_xp=mysql_result($result,$i,"player_class_assault_xp");
    
$player_class_specops_xp=mysql_result($result,$i,"player_class_specops_xp");
    
$player_class_sniper_xp=mysql_result($result,$i,"player_class_sniper_xp");
    
$player_class_engineer_xp=mysql_result($result,$i,"player_class_engineer_xp");
    
$player_class_medic_xp=mysql_result($result,$i,"player_class_medic_xp");
    
$player_class_support_xp=mysql_result($result,$i,"player_class_support_xp");
    
    
$output.='<tr><td class="stats">' .$RankNumber'</td>
        <td class="stats">' 
.$player_id'</td>
        <td class="stats">' 
.$player_total_xp'</td>
        etc
        </tr>'
;

Then make sure to register $output and then in the template in place of:
HTML Code:
			{vb:raw starttablecell1}{vb:raw RankNumber}{vb:raw endtablecell1}
				{vb:raw starttablecell2}{vb:raw player_id}{vb:raw tablecell2center}{vb:raw player_name}{vb:raw endtablecell2}
....
				{vb:raw starttablecell9}{vb:raw $player_class_support_xp}{vb:raw endtablecell9}
HTML Code:
{vb:raw output}
Reply With Quote
  #754  
Old 01-17-2012, 12:35 AM
SavSin SavSin is offline
 
Join Date: Jan 2012
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That worked perfectly. And to answer your question This was my first dabble in PHP and MySql. Im trying to teach it to my self and work on different things. So THANKS a ton.

I have a friend that wants to make a chrome widget that will alert him to new PM's and thread subscriptions on a VB forum so im learning some things about php and vb.
Reply With Quote
  #755  
Old 01-22-2012, 05:59 PM
ClErK1991 ClErK1991 is offline
 
Join Date: May 2009
Location: Colombia
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks i like this
Reply With Quote
  #756  
Old 01-24-2012, 02:15 AM
Rocket2009 Rocket2009 is offline
 
Join Date: Mar 2009
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am still hoping for help. I have implemented dozens and dozens of pages using this process with lots of customization. Thanks Lyne. I have embedded newsfeeds, slideshows, spreadsheets, and etc. So I am fairly familiar with the method.

I am having trouble with one implementation. It looks beautiful, but it doesn't recognize me as logged in user.

I call the test.php (using the demo model terminology from the original post in this article) from another page, let's call that index.php (really a complex application). If I require_once global.php on test.php, it doesn't work (printing variables shows me as a guest). I can require_once global.php on index.php and it works and shows me as logged in. I can pass the security token obtained from index.php to either test.php via an assign function in that application has very similar to the templater register used by VB for test.php. I have seen the security value on the test.php (printing variables) and have rendered the security value into the template html output.

The result is that whenever I render an html page from this system (index.php calls test.php which uses template TEST to create an html page) it shows me as not logged in and the page source shows me as a guest. If I navigate to another forum page, I am still logged in.

So here are some questions and hopefully I can get some help for further study:

(1) If I can get a security token in the world of index.php such as

PHP Code:
<?php
$curdir 
getcwd ();
chdir('/home/touring7/public_html/forum/');
require_once(
'./global.php');
chdir ($curdir);

//Can pass these values to the html page or the external php page
$tokenkb $vbulletin->userinfo['securitytoken'];
//$uidkb = $vbulletin->userinfo['userid'];
I have tried assigned it to the html template (TEST) as:

HTML Code:
<input type="hidden" name="securitytoken" value="{tokenkb}" />
Note it has a slightly different format from an assign from test as it doesn't have vb:raw. But even though I see the value in the page source, it doesn't unlock the page and still shows me as a guest.

One of two options, in my mind. I am either doing something wrong with passing the security token in terms of the input statement. Do I need to pass more than the security token? -or- index.php is disabling or clearing the session so the security token doesn't log me into the system. Interestingly, remember that if I navigate to another forum page I am still logged in and everything is fine.

Does anyone have a suggestion on how to pass the security token. Does the syntax look OK. I have never unlocked a page in this manner.

Or is there a command or series of command I can search through in the world of index.php that would disable (temporarily) the session so it can't recognize a user as logged in. I might be able to disable or adjust this function.

Any advice or suggestions would be much appreciated.
Reply With Quote
  #757  
Old 01-24-2012, 04:33 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why are you focusing on passing the securitytoken? What about the userid - that is the variable you need.
Reply With Quote
  #758  
Old 01-25-2012, 01:00 AM
Rocket2009 Rocket2009 is offline
 
Join Date: Mar 2009
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Why are you focusing on passing the securitytoken? What about the userid - that is the variable you need.
Yes, I am sure I could pass userid to that page. My problem is that the Header and NavBar templates test to see if I am a member and since apparently I am not (security token is at guest), at this point, the header template prints out an empty login box and the navbar template puts a notice note on the page that says something like: "If this your first time on this site you may register ...".

My hack around this is to modify header to skip that assessment for this page (THIS_SCRIPT test) and not show anything in the upper right corner and to modify Navbar in the same manner to skip the messages for this page. So it's not elegant but it sort of works. The problem is that there are times that I get logged out after viewing this page (weird inconsistent behavior of tokens I think and browser caches).

My thought is that if I could log myself back in after going through this other application, which apparently tries to flush the session or some sort of thing, I would be golden and this page would work like the dozens of others and I wouldn't have to worry about being logged out.

So I thought if I used the security token I could log myself back in. This would be the cleanest approach forward. Any suggestions on how to do this, assuming you agree on the approach. I have seen some threads on remote login. Should I implement this on the test.php? Suggested thread for VB4 to help me do this? My security token notes were related to a post that Lynne made on this thread to use <input ...>.

If I can't get this to work, my latest brainstorm is to experiment with merging index.php (the launch code for the other application) and test.php (the code for rendering VB pages via the tutorial Lynne pulled together). I don't like this approach since it will be difficult to maintain through updates of the other application, even assuming I can get it to work. The other application renders global variables into templates as well. I think it was already a miracle that I could get the other application to call test.php and have them both render things into the TEST template.

Suggestions on approaches to stay logged in would be appreciated!

--------------- Added [DATE]1327535262[/DATE] at [TIME]1327535262[/TIME] ---------------

Additionally, does anyone have any idea of what types of php commands in the other application might be logging me off the vbulletin system? I might be able to search for those and circumvent them.

Thanks.
Reply With Quote
  #759  
Old 01-27-2012, 09:02 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've recently built a new page and want to put in ad locations. There's something about the variable "$ad_location" that won't let me do it. "$bad_location" works though. Is there some special handling you have to do to use that variable name?
Reply With Quote
  #760  
Old 01-28-2012, 12:45 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nerbert View Post
I've recently built a new page and want to put in ad locations. There's something about the variable "$ad_location" that won't let me do it. "$bad_location" works though. Is there some special handling you have to do to use that variable name?
What do you mean by "won't let you do it"? Where are you trying to use that variable?
Reply With Quote
  #761  
Old 01-28-2012, 01:14 AM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, the problem I'm having is that I don't use ads on my own forum but I'm working on a new page for someone else who does. So I don't know much about how to place ads, and it's hard to design a page that uses them and get a new set of locations in the adminCP. Anyway I'm fumbling my way through this by trial and error.

"$ad_location" seems to be reserved by vBulletin so you can't just use it any way you want. But as I said, I'm figuring this out.

I wish you could search for "ad location" but "ad" is too short!!!!!!

If I ever get this working maybe I should write an article.
Reply With Quote
Reply

Thread Tools

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 05:54 AM.


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.13935 seconds
  • Memory Usage 2,545KB
  • Queries Executed 26 (?)
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_code
  • (4)bbcode_html
  • (4)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (3)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (58)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (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_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
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete