vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Cutom Field on Custom Page?? (https://vborg.vbsupport.ru/showthread.php?t=216711)

Lynne 07-03-2009 02:03 PM

You can't move it there because $auinfo is not defined there. You need to move it to within the while statement. The while statement is what defines $auinfo - $auinfo = $db->fetch_array($getusers). So, after $auinfo is defined but before the template is evaled.

cono1717 07-03-2009 03:37 PM

Now things have gone weired :S


Before:- http://i41.tinypic.com/2yyw67a.jpg
After:- http://i40.tinypic.com/105ce8g.jpg
PHP File:

PHP Code:

<?php


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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''activity');

// ################### 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('ACTIVITY','ACTIVITY_bits''ACTIVITY_mbits''ACTIVITY_ybits''MEMBERINFO''memberinfo_profilefield');

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


// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

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


if(empty($_REQUEST['do']))
{

    
// sanitize the variables myself
    
if(empty($_REQUEST['m']))
    {
        
$month vbdate('n');
        
$monthliteral vbdate('F');
    }
    else
    {
        
$month intval($_REQUEST['m']);
        
$monthliteral $months["$_REQUEST[m]"];
    }
    
    if(empty(
$_REQUEST['y']))
    {
        
$year vbdate('Y');
    }
    else
    {
        
$year intval($_REQUEST['y']);
    }

    
// generate months dropdown
    
$months = array(
        
=> 'January',
        
=> 'February',
        
=> 'March',
        
=> 'April',
        
=> 'May',
        
=> 'June',
        
=> 'July',
        
=> 'August',
        
=> 'September',
        
10 => 'October',
        
11 => 'November',
        
12 => 'December'
    
);
    
    foreach(
$months AS $mkey => $mval)
    {
        if(
$mkey == $month)
        {
            
$checked ' selected="selected"';
        }
        eval(
'$mbits .= "' fetch_template('ACTIVITY_mbits') . '";');
        unset(
$checked);
    }
    
    
// generate years dropdown
    
for($i intval(vbdate('Y')); $i intval(vbdate('Y')) + 4$i++)
    {
        if(
$i == $year)
        {
            
$checked2 ' selected="selected"';
        }
        eval(
'$ybits .= "' fetch_template('ACTIVITY_ybits') . '";');
        unset(
$checked2);
    }            
    
    
// important cutoff data
    
$cutoffstart gmmktime(000$month1$year);
    
$cutoffend gmmktime(000$monthvbdate('t'$cutoffstart), $year);
    
    
//echo $cutoffstart . '=' . TIMENOW;
    
    
if($cutoffstart TIMENOW)
    {
        eval(
standard_error('This date is in the future. You cannot select it. Go back and select antoher.'));    
    }
    
    
// limit our records
    
$limit 30000;    

    
// run query
$getusers $vbulletin->db->query("
    SELECT COUNT(p.postid) AS total, p.userid, u.username, u.joindate, f.field7
    FROM " 
TABLE_PREFIX "post AS p
    LEFT JOIN " 
TABLE_PREFIX "user AS u USING (userid)
    LEFT JOIN " 
TABLE_PREFIX "userfield AS f USING (userid)
    WHERE p.dateline > 
$cutoffstart
        AND p.dateline < 
$cutoffend
    GROUP BY userid
    ORDER BY total DESC
    LIMIT 
$limit
"
);  

    
    
$c 0;
    while(
$auinfo $db->fetch_array($getusers))
//Let's define those variables

if ($auinfo['field7'] == "I don\'t have a package")
{
    
$conditional 0;
} else if (
$auinfo['field7'] == "SHARED A")
{
    
$conditional 5;
} else if (
$auinfo['field7'] == "SHARED B")
{
    
$conditional 15;
} else if (
$auinfo['field7'] == "SHARED C")
{
    
$conditional 20;
} else if (
$auinfo['field7'] == "SHARED D")
{
    
$conditional 20;
} else if (
$auinfo['field7'] == "RESELLER A")
{
    
$conditional 25;
}
 else if (
$auinfo['field7'] == "RESELLER B")
{
    
$conditional == 75;
} else if (
$auinfo['field7'] == "RESELLER C")
{
    
$conditional == 200;
}
 else if (
$auinfo['field7'] == "RESELLER D")
{
    
$conditional 200;
} else if (
$auinfo['field7'] == "Custom/Other")
{
    
$conditional 00;
}

    {
        
$c++;
        
$auinfo['joindate'] = vbdate($vbulletin->options['dateformat'], $auinfo['joindate'], true);

        eval(
'$userbits .= "' fetch_template('ACTIVITY_bits') . '";');    

    }

    
$navbits construct_navbits(array('' => 'Activity Statistics'));
    eval(
'$navbar = "' fetch_template('navbar') . '";');
    eval(
'$aufield7 = "' fetch_template('postbit') . '";');
    eval(
'print_output("' fetch_template('ACTIVITY') . '");');    
}




?>

Before Screenshot:- http://i41.tinypic.com/2yyw67a.jpg
After Screenshot:- http://i40.tinypic.com/105ce8g.jpg

Here's what happens you can see from the 'before' screenshot all of the usernames are generated with their post count however in the 'after' screenshot you can see the field works but only that field works, also selecting a month from the dropdown changes that number.

Lynne 07-03-2009 08:05 PM

You need to have your code within the parenthesis for your while statement. You don't have it there right now which is why it's all screwed up. Basically:

PHP Code:

while..
{
your conditions
the 
eval statement



cono1717 07-04-2009 11:05 AM

YAY that worked...kinda.

For some reason not all of the fields display properly.

PHP File
PHP Code:

<?php



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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''activity');

// ################### 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('ACTIVITY','ACTIVITY_bits''ACTIVITY_mbits''ACTIVITY_ybits''MEMBERINFO''memberinfo_profilefield');

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


// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

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


if(empty($_REQUEST['do']))
{

    
// sanitize the variables myself
    
if(empty($_REQUEST['m']))
    {
        
$month vbdate('n');
        
$monthliteral vbdate('F');
    }
    else
    {
        
$month intval($_REQUEST['m']);
        
$monthliteral $months["$_REQUEST[m]"];
    }
    
    if(empty(
$_REQUEST['y']))
    {
        
$year vbdate('Y');
    }
    else
    {
        
$year intval($_REQUEST['y']);
    }

    
// generate months dropdown
    
$months = array(
        
=> 'January',
        
=> 'February',
        
=> 'March',
        
=> 'April',
        
=> 'May',
        
=> 'June',
        
=> 'July',
        
=> 'August',
        
=> 'September',
        
10 => 'October',
        
11 => 'November',
        
12 => 'December'
    
);
    
    foreach(
$months AS $mkey => $mval)
    {
        if(
$mkey == $month)
        {
            
$checked ' selected="selected"';
        }
        eval(
'$mbits .= "' fetch_template('ACTIVITY_mbits') . '";');
        unset(
$checked);
    }
    
    
// generate years dropdown
    
for($i intval(vbdate('Y')); $i intval(vbdate('Y')) + 4$i++)
    {
        if(
$i == $year)
        {
            
$checked2 ' selected="selected"';
        }
        eval(
'$ybits .= "' fetch_template('ACTIVITY_ybits') . '";');
        unset(
$checked2);
    }            
    
    
// important cutoff data
    
$cutoffstart gmmktime(000$month1$year);
    
$cutoffend gmmktime(000$monthvbdate('t'$cutoffstart), $year);
    
    
//echo $cutoffstart . '=' . TIMENOW;
    
    
if($cutoffstart TIMENOW)
    {
        eval(
standard_error('This date is in the future. You cannot select it. Go back and select antoher.'));    
    }
    
    
// limit our records
    
$limit 30000;    

    
// run query
$getusers $vbulletin->db->query("
    SELECT COUNT(p.postid) AS total, p.userid, u.username, u.joindate, f.field7
    FROM " 
TABLE_PREFIX "post AS p
    LEFT JOIN " 
TABLE_PREFIX "user AS u USING (userid)
    LEFT JOIN " 
TABLE_PREFIX "userfield AS f USING (userid)
    WHERE p.dateline > 
$cutoffstart
        AND p.dateline < 
$cutoffend
    GROUP BY userid
    ORDER BY total DESC
    LIMIT 
$limit
"
);  

    
    
$c 0;
    while(
$auinfo $db->fetch_array($getusers))


    {
        
$c++;
        
$auinfo['joindate'] = vbdate($vbulletin->options['dateformat'], $auinfo['joindate'], true);
        
//Let's define those variables

if ($auinfo['field7'] == "I don\'t have a package")
{
    
$conditional 0;
} else if (
$auinfo['field7'] == "SHARED A")
{
    
$conditional 5;
} else if (
$auinfo['field7'] == "SHARED B")
{
    
$conditional 15;
} else if (
$auinfo['field7'] == "SHARED C")
{
    
$conditional 20;
} else if (
$auinfo['field7'] == "SHARED D")
{
    
$conditional 20;
} else if (
$auinfo['field7'] == "RESELLER A")
{
    
$conditional 25;
}
 else if (
$auinfo['field7'] == "RESELLER B")
{
    
$conditional == 75;
} else if (
$auinfo['field7'] == "RESELLER C")
{
    
$conditional == 200;
}
 else if (
$auinfo['field7'] == "RESELLER D")
{
    
$conditional 200;
} else if (
$auinfo['field7'] == "Custom/Other")
{
    
$conditional 00;
}
        eval(
'$userbits .= "' fetch_template('ACTIVITY_bits') . '";');    

    }

    
$navbits construct_navbits(array('' => 'Activity Statistics'));
    eval(
'$navbar = "' fetch_template('navbar') . '";');
    eval(
'$aufield7 = "' fetch_template('postbit') . '";');
    eval(
'print_output("' fetch_template('ACTIVITY') . '");');    
}




?>

Screenshot of errors:-
http://i41.tinypic.com/5kg1tx.jpg

Lynne 07-04-2009 02:21 PM

You should make sure to set conditional to 0 before entering your series of conditions to define it otherwise it will just use the variable it was set to before. If that isn't it, time for some debugging by spitting out a bunch of stuff along the way to see what is going on.

cono1717 07-04-2009 04:33 PM

1 Attachment(s)
I took your advice and went and told the PHP file that $conditional always = 0 unless otherwise stated, which worked now it's only RESELLER B & C that display 0

Here is their code

PHP Code:

 else if ($auinfo['field7'] == "RESELLER B")
{
    
$conditional == 75;


 else if (
$auinfo['field7'] == "RESELLER C")
{
    
$conditional == 200;


I have also debugged the page, not sure what you was looking for so I took a screenshot of the info:-

Lynne 07-04-2009 11:01 PM

I meant you should put some new variables into your code to help you debug stuff. Like actually print out field7 on the page so you can see why it is giving you 0 instead of values for B & C. (Can you visually see a difference right before B? You have the else if on a new line. Perhaps move that to the same line as the end parenthesis.)

cono1717 07-05-2009 02:54 PM

I tried moving the else if to the same line, no luck. As for your other question yes you can see the other values right before B&C and right after just B&C that don't work.

Lynne 07-05-2009 03:01 PM

This is your problem:
PHP Code:

$conditional == 200

It isn't supposed to be ==.

Are you using a proper editor when coding? Use one made for php (or html when you do html) and things like that will be quite obvious. I think it's a real necessity because you can't always test everything and a helpful editor will certainly point out some flaws you make before they come and get you later.

cono1717 07-05-2009 03:22 PM

I am using PHP designer but I guess it is technically not an error so it didn't flag it up. However:

Lynne, Dismounted and everyone else who has helped me is a star!

As you can probably tell this is fixed now THANKS A BUNCH! I REALLY APPRECIATE IT!


All times are GMT. The time now is 02:00 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01279 seconds
  • Memory Usage 1,882KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete