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)

cono1717 06-21-2009 12:03 PM

Cutom Field on Custom Page??
 
How do I access a users selection from a custom field on a custom page.

Currently I have tried $auinfo[field7] $userinfo[field7] which brings up nothing and $bbuserinfo[field7] which brings up my selection when I want to see their selection.

Any help?

Thanks

Lynne 06-21-2009 02:33 PM

Are you sure field 7 is the correct field number? What does your template look like? What is the query you are using to get this users info? Did you make sure to JOIN with the userfield table?

cono1717 06-21-2009 05:33 PM

1) yes 7 is the correct number.

2) My template is the following.
ACTIVITY
HTML Code:

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
<title>$vboptions[bbtitle] - Activity Statistics</title>
</head>
<body$onload>
$header
$navbar
<div align="center">
<form action="activity.php" method="get">
<strong>Choose another timeframe:</strong><br />
<select name="m">$mbits</select> <select name="y">$ybits</select> <input type="submit" name="submit" value="Go" />
</form>
</div>
<br />

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
        <td class="tcat" colspan="6">
                Activity Statistics for $monthliteral
        </td>
</tr>
<tbody>
        <tr>
                <td class="thead">Rank</td>
                <td class="thead">Username</td>
                <td class="thead">Current Package</td>
                <td class="thead">Posts This Month</td>
                <td class="thead">Posts Required</td>
                <td class="thead">Action Needed?</td>

        </tr>
$userbits
</tbody>
</table>
$footer

</body>
</html>

ACTIVITY_bits
HTML Code:

<tr>
                <td class="alt1">$c</td>
                <td class="alt2"><a href="member.php?$session[sessionurl]u=$auinfo[userid]">$auinfo[username]</a>
                <td class="alt1">$auinfo[field5]</td>
                <td class="alt2">$auinfo[total]</td>
                <td class="alt2">30</td>
<if condition="is_member_of($bbuserinfo, 5, 6, 7)">
<if condition="$auinfo[total] == 30">
<td class="alt1">No Action Required</td>
<else />
<td class="alt1"><font color="#FF0000"><b>Action Required</b></font></td>
</if></if>
        </tr>

3)I am not sure what you mean here so I here is the 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 $db->query("
        SELECT COUNT(p.postid) AS total
            ,p.userid
            ,u.username
            ,u.joindate
        FROM
            " 
TABLE_PREFIX "post AS p
        LEFT JOIN
            " 
TABLE_PREFIX "user as u
                ON
                    u.userid = p.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);
        eval(
'$userbits .= "' fetch_template('ACTIVITY_bits') . '";');    
    }
    
    
$navbits construct_navbits(array('' => 'Activity Statistics'));
    eval(
'$navbar = "' fetch_template('navbar') . '";');
    
    eval(
'print_output("' fetch_template('ACTIVITY') . '");');    
}

?>

4) Don't get what you mean so probably not, someone else built this system I am just revamping it, only I can't find the guy that built it (non vBulletin member btw)

Thanks in advance,

C

Lynne 06-21-2009 05:57 PM

You have only queried to get the userid and username. Nowhere in your query have you grabbed the fields from the userfield table. You can't use them in your template if never grabbed them in your query. You'll need to do another JOIN to the userfield in your $getusers query in order to have them available to you.

cono1717 06-21-2009 07:59 PM

I am not very familiar with mysql so could you tell me what that query would be and where I would put it please?

Cryo 06-21-2009 08:14 PM

If you change your SQL query to this...

PHP Code:

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

It should work. The fields you list under the SELECT part of the query determines the results displayed. So if you don't specify you want a field to pull it won't be available in the results. Additionally, because userfields are stored in another table we need to add that with a reference.

cono1717 06-22-2009 08:12 AM

That gave me the following database error

Quote:

Database error in vBulletin 3.8.1:

Invalid SQL:

SELECT COUNT(p.postid) AS total
,p.userid
,u.username
,u.joindate
,f.field7
FROM
post AS p,
userfield AS f
LEFT JOIN
user as u
ON
u.userid = p.userid
WHERE
p.dateline > 1243814400
AND p.userid = f.userid
AND p.dateline < 1246320000
GROUP BY
userid
ORDER BY
total DESC
LIMIT
30000;

MySQL Error : Unknown column 'p.userid' in 'on clause'
Error Number : 1054
Request Date : Monday, June 22nd 2009 @ 09:11:30 AM
Error Date : Monday, June 22nd 2009 @ 09:11:30 AM
Script : http://www.geekstep.com/activity.php
Referrer :
IP Address : 80.47.176.108
Username : Connor
Classname : vB_Database
MySQL Version : 5.0.81-community

Dismounted 06-23-2009 10:01 AM

Find:
Code:

AND p.userid = f.userid
Replace With:
Code:

AND p.postuserid = f.userid

cono1717 06-23-2009 03:35 PM

New error now:-

Quote:

Database error in vBulletin 3.8.1:

Invalid SQL:

SELECT COUNT(p.postid) AS total
,p.userid
,u.username
,u.joindate
,f.field7
FROM
post AS p,
userfield AS f
LEFT JOIN
user as u
ON
u.userid = p.userid
WHERE
p.dateline > 1243814400
AND p.postuserid = f.userid
AND p.dateline < 1246320000
GROUP BY
userid
ORDER BY
total DESC
LIMIT
30000;

MySQL Error : Unknown column 'p.postuserid' in 'where clause'
Error Number : 1054
Request Date : Tuesday, June 23rd 2009 @ 04:34:56 PM
Error Date : Tuesday, June 23rd 2009 @ 04:34:56 PM
Script : http://www.geekstep.com/activity.php
Referrer :
IP Address : 80.47.2.106
Username : Connor
Classname : vB_Database
MySQL Version : 5.0.81-community

Dismounted 06-24-2009 06:49 AM

Actually. "p.userid" should be correct. Have you set a table prefix in your config.php?

cono1717 06-24-2009 12:03 PM

Quote:

// ****** TABLE PREFIX ******
// Prefix that your vBulletin tables have in the database.
$config['Database']['tableprefix'] = '';
Nope, no prefix...

cono1717 06-25-2009 12:31 PM

Sorry for the bump, the help has been great so far though!

Dismounted 06-25-2009 01:16 PM

Try this:
PHP Code:

$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
"
); 


cono1717 06-25-2009 01:26 PM

HUZZAH it works, just another quick question though, how do I make a statement if a value is less than something.

So say
HTML Code:

<if conditional=$auinfo[total] IS LESS THAN $auinfo[posts]>
Less than stuff here
<else />
Greater than stuff here
</if>

ALSO what is wrong with this template?

HTML Code:

<td class="alt2">
<if condition="$auinfo[field7] == I do not have a package">
N/A
</if>
<if condition="$auinfo[field7] == SHARED A">
One time 5 posts
</if>
<if condition="$auinfo[field7] == SHARED B">
15 P/M
</if>
<if condition="$auinfo[field7] == SHARED C">
20 P/M
</if>
<if condition="$auinfo[field7] == SHARED D">
20 P/M (VIP ONLY)
</if>
<if condition="$auinfo[field7] == RESELLER A">
25 P/M
</if>
<if condition="$auinfo[field7] == RESELLER B">
75 P/M
</if>
<if condition="$auinfo[field7] == RESELLER C">
200 P/M
</if>
<if condition="$auinfo[field7] == RESELLER D">
200 P/M (VIP ONLY)
</if>
<if condition="$auinfo[field7] == Custom/Other">
Consult Staff Area
</if>
</td>

The error is The following error occurred when attempting to evaluate this template:

Parse error: syntax error, unexpected T_DO in /home/geekstep/public_html/includes/adminfunctions_template.php(3938) : eval()'d code on line 9

This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.

Cryo 06-25-2009 06:10 PM

Less than...

PHP Code:

<if conditional="$auinfo[total] < $auinfo[posts]">
Less than stuff here
<else />
Greater than stuff here
</if> 

... should work. As far as your parsing errors it's most likely due to you not encapsulating the variables. For example,

PHP Code:

<if condition="$auinfo[field7] == I do not have a package"

should be...

PHP Code:

<if condition="$auinfo[field7] == 'I do not have a package'"

Note the single quotes around the value.

Dismounted 06-26-2009 06:22 AM

You should also quote the array key inside a template conditional.
PHP Code:

<if condition="$auinfo['field7'] == 'I do not have a package'"


cono1717 06-26-2009 12:27 PM

Now a new problem arises. I am trying to make a variable changeable depending on the users selection so that if their post count does not meet the requirements staff are noted.

Basically I want to make the following

HTML Code:


<if condition="$auinfo[field7] <(is less than) $conditional">
Post count not met
</if>

And obviously there is a else statement on there if they do meet it,

however the code I am using in my PHP file does not display the stuff set when I add $conditional into my template here is the code

PHP Code:

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;



cono1717 06-27-2009 12:49 PM

Bump

anyone please??

cono1717 06-28-2009 01:55 PM

Sorry for another bump but I really need help on this I am at wits end...

Cryo 06-28-2009 10:16 PM

Change...

PHP Code:

$conditional = (whatever); 

... to...

PHP Code:

$this->post[conditional

Then reference $post[conditional] in the template.

Edit: To clarify, this is what you would use if you're trying to utilize this in the postbit template.

Dismounted 06-29-2009 04:38 AM

Quote:

Originally Posted by cono1717 (Post 1837790)
Basically I want to make the following

HTML Code:


<if condition="$auinfo[field7] <(is less than) $conditional">
Post count not met
</if>

PHP Code:

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;



You're trying to do a comparison with a text field and a numeric field? :confused:

cono1717 06-29-2009 06:37 PM

No in the php file I was trying to set a number to the variable $conditional then use the HTML code to see if the number is lessthan the required number

Dismounted 06-30-2009 04:50 AM

And the problem is that $conditional currently does not contain anything, right?

cono1717 06-30-2009 10:45 AM

I think so, if you go to http://www.geekstep.com/activity.php?styleid=19 you will see that the column "posts required" is not showing any numbers which means that the action required field cannot function.

@Cryo :- Your suggestion did not work since it is a custom template not the postbit.

cono1717 07-01-2009 11:45 AM

Anymore suggestions please?

cono1717 07-02-2009 11:58 AM

Sorry will have to bump again I really need this please.

Lynne 07-02-2009 02:19 PM

Quote:

Originally Posted by cono1717 (Post 1841372)
Sorry will have to bump again I really need this please.

You've made several changes since you first posted your code. Why don't you post exactly what your code and template currently is now so we don't have to look back and try to figure it out.

cono1717 07-02-2009 04:04 PM

Ok here is the activity.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);
        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') . '");');    
}


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;
}

?>

Here is the ACTIVITY template

HTML Code:

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
<title>$vboptions[bbtitle] - Activity Statistics</title>
</head>
<body>
$header
$navbar
<div align="center">
<form action="activity.php" method="get">
<strong>Choose another timeframe:</strong><br />
<select name="m">$mbits</select> <select name="y">$ybits</select> <input type="submit" name="submit" value="Go" />
</form>
</div>
<br />

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
        <td class="tcat" colspan="6">
                Activity Statistics for $monthliteral
        </td>
</tr>
<tbody>
        <tr>
                <td class="thead">Rank</td>
                <td class="thead">Username</td>
                <td class="thead">Current Package</td>
                <td class="thead">Posts This Month</td>
                <td class="thead">Posts Required</td>
                <td class="thead">Action Needed?</td>

        </tr>
$userbits
</tbody>


</table>
<br /><center>
$vbphrase[accopy]
</center><br />
$footer

</body>
</html>

Here is the ACTIVITY_bits template (incase you need it)

HTML Code:

<tr>
                <td class="alt1">$c</td>
                <td class="alt2"><a href="member.php?$session[sessionurl]u=$auinfo[userid]">$auinfo[username]</a>
                <td class="alt1">$auinfo[field7]</td>
                <td class="alt2">$auinfo[total]</td>
                <td class="alt1">$conditional</td>
</tr>

They are the only templates that I use in the whole system.

Lynne 07-02-2009 10:08 PM

You've evaled your ACTIVITY_bits template before you've done all the php to define the variable $conditional. You need to define $conditional before you eval the template otherwise the information isn't available to you in that template.

cono1717 07-03-2009 12:11 PM

Ok I have moved the code and still nothing, here is the new activity.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
"
);  
//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 0;
    while(
$auinfo $db->fetch_array($getusers))
    {
        
$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') . '");');    
}




?>

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

If it is easier I could do it in the template system but I don't know if that would be possible

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:21 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.04712 seconds
  • Memory Usage 2,235KB
  • 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
  • (2)bbcode_code_printable
  • (8)bbcode_html_printable
  • (18)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete