also try running the code in a seperate page from pafiledb, without the pafiledb code, to see if your code will work on its own, if it does then you know its not this code
[Resolved] Loop logic and math problems...I think...
You asked for it, but I'll snip out a bunch of HTML-only code! (And I'll have to post in two halves, since the "whole picture" is too many characters.)
<?php
//Pull user id from cookie
$xnum = $HTTP_COOKIE_VARS['bbuserid'];
if ($action == "admin") {
} else {
error_reporting(7);
global $jabsecure;
$jabsecure = "Y";
$jabgoogle = "N";
/* GoogleBot Notification - 2003/01/14 JAB*/
if(eregi("googlebot",$HTTP_USER_AGENT)) {
$jabgoogle = "Y";
if ($QUERY_STRING != "")
{$url = "http://".$SERVER_NAME.$PHP_SELF.'?'.$QUERY_STRING;}
else
{$url = "http://".$SERVER_NAME.$PHP_SELF;}
$today = date("F j, Y, g:i a");
mail("jbristor@computersage.com", "Googlebot detected on [url]http://[/url]$SERVER_NAME", "$today - Google crawled $url ");
}
/* End GoogleBot -- JAB */
chdir("c:/phpdev/www/html/modules/forums");
$templatesused='forumhome_birthdaybit,error_nopermission,forumhome_pmloggedin,forumhome_welcometext,forumhome_logoutcode,forumhome_newposts,forumhome_todayposts,forumhome_logincode,forumhome_loggedinuser,forumhome_loggedinusers,forumhome_lastpostby,forumhome_moderator,forumhome_forumbit_level1_nopost,forumhome_forumbit_level1_post,forumhome_forumbit_level2_nopost,forumhome_forumbit_level2_post,forumhome,forumhome_unregmessage';
$loadbirthdays = 1;
$loadmaxusers = 1;
require('./global.php');
$permissions=getpermissions();
/* Not Logged In */
/* Logged in But No Permissions.. Has a bug */
/* Logged in and Have permissions */
if (($action <> "download") && ($jabgoogle <> "Y")) {
header("HTTP/1.0 200 OK");
header("HTTP/1.1 200 OK");
header("Content-type: text/html");
// no caching
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); // always modified
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0
}
/* Not Logged In, No permissions go to message */
If (($permissions[0]<=1 || $permissions[0]==3 ) && ($jabgoogle <> "Y")) {
?>
<body onload=javascript:window.location.href="../../../segue.html">
<?php
exit;
} elseif ((($permissions[0]==2 && $permissions[0]<=4)) && ($jabgoogle <> "Y")){
/* Logged in but doesn't have permissions including Trial Guys */
?>
<script type="text/javascript">
</SCRIPT>
<body onload=javascript:window.history.back();javascript:window.location.href="../../../segue.html">
<?php
exit;
} elseif (($permissions[0]==8) && ($action == "file") && ($category <> "1") && ($jabgoogle <> "Y")){
/* Logged in Trial Guys -- No Permission but for three files */
?>
<body onload=javascript:window.history.back();javascript:window.location.href="../../../html/pafiledb3/pafiledb.php">
<?php
exit;
} elseif (($permissions[0]==8) && ($action == "viewall") && ($jabgoogle <> "Y")){
/* Logged in Trial Guys -- No Permission but for three files */
?>
<body onload=javascript:window.history.back();javascript:window.location.href="../../../html/pafiledb3/pafiledb.php">
<?php
exit;
} else {
$starttime = microtime();
$starttime = explode(" ",$starttime);
$starttime = $starttime[1] + $starttime[0];
session_save_path("./sessions");
$logged = "";
if ($action == "download") {
chdir("c:/phpdev/www/html/pafiledb3");
require "./includes/mysql.php";
//If the month has changed from what is stored in the database
if ($config[15] != date(M)) {
//Update month in database
$config[15] = date(M);
$pafiledb_sql->query($db, "UPDATE $db[prefix]_settings SET settings_month = '$config[15]' WHERE settings_id = '1'", 0);
//Reset file downloads for all Monthly Members
$query = "UPDATE user SET filedownloads = 0 WHERE usergroupid = 10;";
$result = mysql_query($query) or die(mysql_error());
}
//Get number of downloads for current member
$query = "SELECT usergroupid, filedownloads FROM user WHERE userid = $xnum;";
$result = mysql_query($query);
$total_downloads = mysql_fetch_array($result);
$member_usergroup = $total_downloads[0];
$member_downloads = $total_downloads[1];
$pafiledb_sql->connect($db);
$config = $pafiledb_sql->query($db,"SELECT * FROM $db[prefix]_settings",1);
//If the user has a Monthly Membership
if ($member_usergroup == 10) {
if ($member_downloads >= "5") { //if downloads are 5
//Deny user download and redirect to upgrade page
chdir("c:/phpdev/www/html/modules/forums");
?>
<body onload=javascript:window.location.href="../../../segue.html">
<?php
exit;
} else { //if downloads are less than 5
//Allow user to download file
include "./includes/download.php";
//Increment file counter by 1
$member_downloads++;
//Update file counter field in database
$query = "UPDATE user SET filedownloads = $member_downloads WHERE userid = $xnum;";
$result = mysql_query($query);
}
// } else {
// include "./includes/download.php";
}
ob_end_clean();
exit();
}
/* You are allowed Logged In and Permission */
}
chdir("c:/phpdev/www/html/pafiledb3");
}
/************************************************************************/
/*
paFileDB 3.0
©2001 PHP Arena
Written by Todd
[email]todd@phparena.uni.cc[/email]
[url]http://www.phparena.uni.cc[/url]
Keep all copyright links on the script visible
Please read the license included with this script for more information.
*/
if (file_exists("./install.php")) {
die("Error: The file install.php (paFileDB installer) still exists on the server! This is a security risk! Please delete the file to continue using paFileDB.");
}
/* this section is for Global Vars should they get turned off
$action = $_GET['action'];
if (empty($action)) {$action = $_POST['action'];}
$file = $_GET['file'];
if (empty($file)) {$file = $_POST['file'];}
$id = $_GET['id'];
if (empty($id)) {$id = $_POST['id'];}
$login = $_GET['login'];
if (empty($login)) {$login = $_POST['login'];}
$ad = $_GET['ad'];
if (empty($ad)) {$ad = $_POST['ad'];}
$edit = $_GET['edit'];
if (empty($edit)) {$edit = $_POST['edit'];}
$logged = $_POST['logged'];
$formpass = $_POST['formpass'];
$formname = $_POST['formname'];
$delete = $_GET['delete'];
if (empty($delete)) {$delete = $_POST['delete'];}
$upload = $_POST['upload'];
$add = $_POST['add'];
$select = $_GET['select'];
if (empty($select)) {$select = $_POST['select'];}
$category = $_GET['category'];
if (empty($category)) {$category = $_POST['category'];}
$rate = $_POST['rate'];
$rating = $_POST['rating'];
end of global vars */
$starttime = microtime();
$starttime = explode(" ",$starttime);
$starttime = $starttime[1] + $starttime[0];
session_save_path("./sessions");
if ($action == "admin") {
session_start();
}
$logged = "";
/*
if ($action == "download") {
require "./includes/mysql.php";
$pafiledb_sql->connect($db);
$config = $pafiledb_sql->query($db,"SELECT * FROM $db[prefix]_settings",1);
include "./includes/download.php";
ob_end_clean();
exit();
}
*/
require "./includes/mysql.php";
require "./includes/functions.php";
$pafiledb_sql->connect($db);
$config = $pafiledb_sql->query($db,"SELECT * FROM $db[prefix]_settings",1);
require "./lang/$config[13].php";
include "./includes/admin/auth.php";
if ($logged == 1 && $ad == "backupdb") {
include "includes/admin/backupdb.php";
exit();
}
?>
<!-- HTML Header Tags Here //-->
<!-- HTML Left Side Navigation Here //-->
2nd half:
<?php
if ($logged == 1 && $ad != "logout") {
$width = 100;
} else {
$width = 80;
}
switch ($action) {
case category:
include "./includes/category.php";
break;
case file:
include "./includes/file.php";
break;
case viewall:
include "./includes/viewall.php";
break;
case search:
include "./includes/search.php";
break;
case license:
include "./includes/license.php";
break;
case rate:
include "./includes/rate.php";
break;
case admin:
include "./includes/admin.php";
break;
case email:
include "./includes/email.php";
break;
case stats:
include "./includes/stats.php";
break;
default:
include "./includes/main.php";
break;
}
?>
</center>
<?php jumpmenu($db,$HTTP_SERVER_VARS['REQUEST_URI'],$pafiledb_sql,$str); ?>
</td>
</tr>
</table>
<!--End page table-->
<!--Begin main table : Moved past Olde Header for readablility -->
<table width="100%" height="99%" border="0" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="100%" height="100%" valign="top">
<!-- End of Readibility Move -->
<!--Begin footer table-->
<table width="100%" height="30" border="0" cellpadding="2" cellspacing="0" class="footer">
<tr>
<td width="100%" valign="center" align="center"></td>
</tr>
<tr>
<td width="100%" valign="center" align="center">
<?php
$endtime = microtime();
$endtime = explode(" ",$endtime);
$endtime = $endtime[1] + $endtime[0];
$stime = $endtime - $starttime;
if ($config[12] == 1) {
?>
<table width="30%" border="1" cellpadding="2" class="stats" bordercolor="#3366CC">
<tr>
<td width="50%" align="left"><?php echo $str[exectime]; ?>:</td>
<td width="50%" align="right"><?php echo round($stime,4); ?> Seconds</td>
</tr>
<tr>
<td width="50%" align="left"><?php echo $str[numqueries]; ?>:</td>
<td width="50%" align="right"><?php echo $query_count; ?> Queries</td>
</tr>
</table>
<?php
if ($showqueries == 1) {
?>
<p>
<table width="100%" border="1" cellpadding="2" class="headertable" bordercolor="#3366CC">
<tr><td width="100%" class="headercell" align="center"><b>Queries Used</b></td></tr>
<?php echo $queries_used; ?>
</table>
<?php
}
}
?>
</table>
<!--End footer table-->
<!--End main table-->
</td>
</tr>
</table>
</td>
<td bgcolor="#ffffff"><img src="../../../html/images/pixel.gif" width=1 height=1 border=0 alt=""></td>
</tr>
</table>
</td>
</tr>
</table>
<br><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="CCCCCC">
<tr>
<td width="90%" align="center">
<a class="footer" href="../../../html/index.php"> Home </a> |
<a class="footer" href="../../../html/modules.php?name=Articles&file=article&sid=2"> About </a> |
<a class="footer" href="../../../html/modules.php?name=Articles&file=article&sid=3"> Contact Us </a> |
<a class="footer" href="../../../html/modules.php?name=Articles&file=article&sid=4"> Terms of Service </a> |
<a class="footer" href="../../../html/modules.php?name=Articles&file=article&sid=5"> Privacy Policy </a> |
<a class="footer" href="../../../html/modules.php?name=Articles&file=article&sid=6"> Integrity Policy </a> |
<a class="footer" href="../../../html/modules.php?name=Articles&file=article&sid=1"> Site Map </a> |
<a class="footer" href="../../../html/modules/forums/member.php?s=&action=logout"> Log Out</a>
</td>
</tr>
<tr align="center">
<td colspan="9">
<p style="margin-top: 0; margin-bottom:0">
<img border="0" src="../../../html/images/gradient_bkgrnd_fill_footer2.gif" width="100%" height="73">
</td>
</tr>
</table>
<form name="subform" method="POST" action="https://payflowlink.verisign.com/payflowlink.cfm">
<input type="hidden" name="LOGIN" value="computersage">
<input type="hidden" name="PARTNER" value="VeriSign">
<input type="hidden" name="AMOUNT" value="495.00">
<input type="hidden" name="TYPE" value="S">
</form>
I've tried running it seperately, but too much of the pafiledb code is needed in order to make it function correctly and allow me access to the directory. By the time I was done, I had copied so much of the code over that it seemed useless...
in mysql.php (the file required), is there and ob_start() function in there? because i cant find ob_start(), and i cant find the reason ob_end_clean() is in there if there is no ob_start() ... could you enlighten me please lol, thx
There is no ob_start() function in mysql.php. So I can't tell you why there is an ob_end_clean() function either.
As you can see, this someone else's modification of the paFileDB script which I'm working with. I will do a search for the function in the other files in the meantime.
try moving the ob_end_clean() function above your code, then try echoing the variables
Ahhh...echo'd variables! Now we can get somewhere.
Moving the line above the code has somehow prevented the file download from actually starting, but it is now allowing me to see the echoed variables. I'm going to assume that moving it back once this is all fixed will remedy that:
Test #1
In the database, I have the following values for my test subject:
usergroupid = 11
filedownloads = 1
When I run the code, I get the following echo's (these are the ones you suggested adding in a previous post, with an additional one to verify that the query was setup correctly):
SELECT usergroupid, filedownloads FROM user WHERE userid = 1088;
membergroup: 11
memberdownloads: 1
A Member Other Than Monthly
So if the user is not a monthly member, it should let them download the file.
Test #2
Now, if I change my database values to that of a monthly member ( corresponds to usergroupid):
usergroupid = 10
filedownloads = 1
I get the following echos:
SELECT usergroupid, filedownloads FROM user WHERE userid = 1088;
membergroup: 10
memberdownloads: 0
your a monthly member, and are allowed to download
The problem seems to be with the filedownloads field, but I don't understand why in test #1, the query would pull the correct value from the filedownloads field and in test #2, it would display it as 0?
Do you see anything that might be interferring?
try putting filedownloads to 5 manually, then try echoing the vars... see what happens then? should help
Okay, I changed filedownloads to 5 manually and ran the script again. These are the results:
SELECT usergroupid, filedownloads FROM user WHERE userid = 1088;
membergroup: 10
memberdownloads: 0
your a monthly member, and are allowed to download
Which of course, is not correct. I mean, the test user is a monthly member, but they are over their file download limit, so it should have denied them the download. What the heck is going on here?!?!
Oh, AND the filedownloads field in the database was set to 1 after I ran the script, instead of the 5 I manually changed it to...
Ok maybye this is the problem, the only thing i see going on here is that before you run the download section, your field is being set to "0", then when it download incremented by 1, the only reeason i c for that is the code where you check for monthly change, change this:
//If the month has changed from what is stored in the database
if ($config[15] != date(M)) {
//Update month in database
$config[15] = date(M);
$pafiledb_sql->query($db, "UPDATE $db[prefix]_settings SET settings_month = '$config[15]' WHERE settings_id = '1'", 0);
//Reset file downloads for all Monthly Members
$query = "UPDATE user SET filedownloads = 0 WHERE usergroupid = 10;";
$result = mysql_query($query) or die(mysql_error());
}
to this:
//If the month has changed from what is stored in the database
if ($config[15] != date("M")) {
//Update month in database
$config[15] = date("M");
$pafiledb_sql->query($db, "UPDATE $db[prefix]_settings SET settings_month = '$config[15]' WHERE settings_id = '1'", 0);
//Reset file downloads for all Monthly Members
$query = "UPDATE user SET filedownloads = '0' WHERE usergroupid = '10';";
$result = mysql_query($query) or die(mysql_error());
}
Then run the code to see if it works
I decided to add this line to the code to display the fields I'm pulling from the database from the array directly:
print"membergroup from db: ".$total_downloads['usergroupid']." <br>memberdownloads from db: ".$total_downloads['filedownloads']."<br>";
And these are the results, with filedownloads manually set to 5 in the database:
SELECT usergroupid, filedownloads FROM user WHERE userid = 1088;
membergroup from db: 10
memberdownloads from db: 0
membergroup: 10
memberdownloads: 0
your a monthly member, and are allowed to download
So, it seems to point to the field in the database itself, right? Man, I am just frustrated and confused...
try what i said before your last post
Yea, sorry about that. Looks like we cross posted.
I just tried it and got the same results.
It's as if the query isn't pulling out that field...
lol its ok, try echoing:
date("M");
$config[15];
check if they are the same...
Argh! I think that's it...don't go to far and let me try and fix this...:rolleyes:
God bless you! lol
The $config[15] variable was not getting set before I was doing the comparison, so when the code ran to that part, it was always running and would messup the rest of it....
[knocks head on table several times]
So now I'm off to move that ob_end_clean function back to its place and test it all over again.
Thank you so much!
haha great, your very welcome , remember to mark this post as resolved btw
Just did, a little bit ago.
Thanks again!
[So jumping for joy...]