Paid-To-Click site, getting user data

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Dragonrider
Forum Newbie
Posts: 3
Joined: Sun Mar 21, 2004 5:33 pm
Location: By a computer!
Contact:

Paid-To-Click site, getting user data

Post by Dragonrider »

I've made friends with the admin of http://www.cash2read.net/ and we got into how he can't do diddly with any language, and that the site was quite buggy and alot of things didn't work so I told him I'd give it a shot. Well... After a few weeks of fiddling I got the 'pay all' part to work, but the 'pay requests' still doesn't want to work. I was actually adding a record into the database and it works when I do that so it looks like the problem isn't that I didn't get it to work (it didn't want to load ANYTHING at first), its that the requests table doesn't store their earnings at the time they click the request button. I will post the large file below and in the comments is my own records and the table structure. It looks like the button wants you to set a permanant number to it like when you click it enters into the record $0.05 instead of what your entire earnings are. So the main thing is that I got it working code wise but need it to take their earnings from the master table of members and round THAT down so that when they request all their money it will set it to all the money of the people who request it.

I give up on it LOL, my brains about to explode after trying to do it. I actually managed to freeze the server for a minute and a half while I had it try to load both tables one after the other, somehow it got stuck in a loop or something... This is the reverted file back to the closest I could get it to come.

Sorry for the length of this message and file length. Just wanted to ensure understanding.

Code: Select all

<?php
// This script is written by Cliff Riley as a patch to get Paypal Mass Pay working
//  as apparantly the company doesn't give a damn to fix this feature.

// SQL Data Structure
/*
 members - number,id,pass,first,last,email,address,city,state,zip,country,method,acc,
 earnings,pearnings,rearnings,tearnings,crl,points,ppoints,rpoints,tpoints,prl,trafex_credits,
 trafex_pcredits,trafex_rcredits,trafex_tcredits,trafex_get_credits,trafex_cost_credits,
 trafex_get_points,trafex_cost_points,trafex_maxurls,trafex_levels,trafex_get_earnings,
 trafex_cost_earnings,trafex_last,trafex_next,trafex_credited,trafex_session,trafex_code,
 trafex_max,exitex_credits,exitex_pcredits,exitex_rcredits,exitex_tcredits,exitex_get_credits,
 exitex_cost_credits,exitex_get_points,exitex_cost_points,exitex_maxurls,lotto_max_plays,
 lotto_plays,lotto_total,lotto_next,lotto_credited,lotto_last,exitex_levels,exitex_get_earnings,
 exitex_cost_earnings,exitex_last,vacation,notes,ref,refs,owedrefs,joindate,interests,clicks,
 lastclicked,nextclick,curad,curty,starttime,level,refpos,ip

 sample: '16','DragonRider','MYPASS','Cliff','Riley','dragonrider858@MYEMAIL','MYADDRESS',
 '','','','United States of America','','','1.103575','0.5297','0.245075','0.006','','0.0000',
 '0.0000','0.0000','0','','0','8910','0','0','','','','','','','','','158','1079709452','No',
 '1','code','3','5','5','0','0','','','','','','','0','26','1079797210','Yes','1079797211','',
 '','','20040213134205','No','','jpgu','64','0','20040130202933','Computers,Internet,Games,Personal Home Pages,Teenagers,Television,',
 '','1079895438','20040321135717','','','20040309172337','Gold','10','65.33.18.190'

 autoredeem - id,type,client,arq,ara,arc,art,iw,ih,ig,subject,
 url,sitename,image,ad,earnings,acc,date

 sample: '5','PayPal','dragonrider','','','Dollars','','468',
 '60','Main','','','','','','0.05','dragonrider@MYEMAIL','20040321161445'
*/

require("program.php");
adminlogin();
if ($submit == 'Download') {
header("Content-Type: download/this");
header("Content-Disposition: attachment; filename=paypal.txt");
echo $input;
exit();
}
?>
<html>
<head>
<body link="#0000FF" vlink="#000000">
<?php
$action = $_GET["action"];
if ($submit == 'Submit') {
  foreach($ids as $id => $temp) {
    if ($pay == 'requests') {
      list ($amount, $arid) = split ('&', $temp);
    	$sql = "DELETE FROM autoredeem WHERE id='$arid'";	
    	$result = mysql_query($sql);
    } else {
		  $amount = $temp;
    }
    $sql = "UPDATE members SET earnings=earnings-$amount WHERE id='$id'";
  	$result = mysql_query($sql);
		$sql = "INSERT INTO trans (username,type,amount,credittype,event,date) VALUES ('$id','Debit','$amount','Dollars','Payment','$now')";
  	$result = mysql_query($sql);
    $sql = "UPDATE system SET paid=paid+$amount WHERE id='Admin'";
  	$result = mysql_query($sql);
  }
	echo "Done<br>";
} else {
  if (!$minbal) $minbal = '0.01';
  if (!$limit) $limit = '1000';
  if (!$fee) $fee = '0';
?>

<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
  <td width="50%">
    Balances over<br>Limit<br>Fee<br>
	</td>
	<td width="50%" valign="top">
	  <form method="POST" action="<?php echo $PHP_SELF?>">
		<input type="text" name="minbal" value="<?php echo $minbal ?>"><br>
		<input type="text" name="limit" value="<?php echo $limit ?>"><br>
		<input type="text" name="fee" value="<?php echo $fee ?>"><br>
	</td>
</tr>
</table>
<center>
<input type="radio" name="pay" value="All">All
<input type="radio" name="pay" value="requests">Requests<br>
<input type="Submit" name="submit" value="View"></form>
</center>

<?php if ($_POST["minbal"]) { ?>

Download, then press submit and go to PayPal to use the file. <br>

<form method="post" action="<?php echo $PHP_SELF?>">
<input type="hidden" name="input" value="<?php
if ($fee != 0) {
$percent = $minbal * $fee / 100;
$minbal += $percent;
}					

if (!$pay) { $pay = 'requests'; }
if ($pay == 'All') {
$sql = "SELECT * FROM members WHERE earnings>=$minbal limit $limit"; 
$col = 'id';
$col2 = 'email';
} else {
$sql = "SELECT * FROM autoredeem WHERE earnings>=$minbal limit $limit"; 
$col = 'client';
$col2 = 'acc';
}

$result = mysql_query($sql,$db); 
while ($myrow = mysql_fetch_array($result, MYSQL_ASSOC)) {
if ($fee != 0) {
$percent = $myrow["earnings"] * $fee / 100;
$myrow["earnings"] -= $percent;
}
$id = $myrow[$col];
$ids[$id] = $myrow['earnings'];
echo $myrow[$col2]."\t".rounddown($myrow["earnings"],  2, '.', '')."\n";
}					
?>">

<?php
if (is_array($ids)) {
foreach($ids as $k => $v) {
        ?>
		<input type="hidden" name="ids[<?php echo $k ?>]" value="<?php echo $v ?>">
<?php				
}
}
?>
		<input type="hidden" name="pay" value="<?php echo $pay ?>">
<input type="Submit" name="submit" value="Download"><br>
<input type="Submit" name="submit" value="Submit">
    </form>
<?php				
}
}
?>
<?php
require('bottom.php');
?>
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

maybe t doesn't do any action ebcause you dont tell it to. you set $action, using $_GET["action"], and it should be $_POST['action'], but you bever do anythign with that.... Maybe you should!!
Dragonrider
Forum Newbie
Posts: 3
Joined: Sun Mar 21, 2004 5:33 pm
Location: By a computer!
Contact:

Post by Dragonrider »

I think thats supposed to be $submit = $_GET["submit"]; to pull the current action from the variables when you press submit... like submit= submit||view||download

that looks like it shouldn't be causing a problem as everything works other than the 'requests' part of the code... the 'all' payout part works! Just I get a blank file and no array full of names when I use the requests radio button.

Being short and to the point, I need to be able to read the entry named earnings from the table named members and have that returned under the array named their username.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

it shouldn't be $_GET[], try using $_POST[] instead
Dragonrider
Forum Newbie
Posts: 3
Joined: Sun Mar 21, 2004 5:33 pm
Location: By a computer!
Contact:

Post by Dragonrider »

As I thought it helped not at all... :)

Thanks so far though... Guess I just need to work on it a while longer...
Post Reply