Snatchy Posted September 22, 2008 Share Posted September 22, 2008 Did anyone have any trouble with the auction cron not finishing the auctions? mine is just letting the numbers go into the negative. (example ; -1day15mins) instead of crediting the auction to the rightfull owner. Quote Link to comment Share on other sites More sharing options...
flipster Posted September 23, 2008 Share Posted September 23, 2008 Re: Auctions Cron yep i have that problem as well its so annoying Quote Link to comment Share on other sites More sharing options...
chaoswar4u Posted September 25, 2008 Share Posted September 25, 2008 Re: Auctions Cron If my memory serves me correctly this is due to the event add part of the cron failing. If you show me some code ill probs can see the error however from memory I cant remember what the exact fix is but Im aware it wasnt major. Quote Link to comment Share on other sites More sharing options...
HITMAN 17 Posted October 8, 2008 Share Posted October 8, 2008 Re: Auctions Cron this is auction cron file <?php include "../config.php"; if($_GET['code'] != $_CONFIG['code']) { die(""); } require "../mysql.php"; mysql_query("UPDATE auctions SET time=time-1 WHERE time>0",$c); $qqq=mysql_query("SELECT * FROM auctions WHERE time=0",$c); while($win=mysql_fetch_array($qqq)) { $time=$win['time']; $item=$win['itemname']; $winner=$win['bidder']; $owner=$win['owner']; $iname=mysql_result(mysql_query("SELECT itmname FROM items WHERE itmid={$item}", $c), 0, 0); if($win['bids']>0) { mysql_query("insert into inventory VALUES('',$item,$winner,1)",$c) or die(mysql_error()); mysql_query("INSERT INTO events VALUES('',$winner,UNIX_TIMESTAMP(),0,'You won the auction of the {$iname} for \${$win['current']}')",$c) or die(mysql_error()); mysql_query("INSERT INTO events VALUES('',$owner,UNIX_TIMESTAMP(),0,'Your {$iname} sold succesfully on the auction market with {$win['bids']} bids. You have been paid \${$win['current']}')",$c) or die(mysql_error()); mysql_query("UPDATE users SET new_events=new_events+1 WHERE owner={$userid}", $c); mysql_query("UPDATE users SET new_events=new_events+1 WHERE winner={$userid}", $c); mysql_query("update users set money=money+{$win['current']},auctionquota=auctionquota-1 where userid=$owner", $c); } if($win['bids']==0) { $owner=$win['owner']; mysql_query("INSERT INTO events VALUES('',$owner,UNIX_TIMESTAMP(),0,'Your auction has ended with no bidders. Your {$iname} has been returned to your inventory.')",$c) or die(mysql_error()); $winner=$win['owner']; mysql_query("insert into inventory VALUES('',$item,$winner,1)",$c) or die(mysql_error()); } } mysql_query("DELETE FROM auctions WHERE time=0", $c); print "Done!"; ?> Quote Link to comment Share on other sites More sharing options...
HITMAN 17 Posted October 11, 2008 Share Posted October 11, 2008 Re: Auctions Cron any fix please Quote Link to comment Share on other sites More sharing options...
phoenix201012 Posted January 23, 2011 Share Posted January 23, 2011 This is what i have mate. <?php include "config.php"; global $_CONFIG; if($_GET['code'] != $_CONFIG['code']) { die(""); } define("MONO_ON", 1); require "/class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $db->query("UPDATE users SET hospital=hospital-1 WHERE hospital>0"); $db->query("UPDATE `users` SET jail=jail-1 WHERE `jail` > 0"); $hc=$db->num_rows($db->query("SELECT * FROM users WHERE hospital > 0")); $jc=$db->num_rows($db->query("SELECT * FROM users WHERE jail > 0")); $db->query("UPDATE settings SET conf_value='$hc' WHERE conf_name='hospital_count'"); $db->query("UPDATE settings SET conf_value='$jc' WHERE conf_name='jail_count'"); $db->query("update auctions set time=time-1",$c); $qqq=$db->query("select * from auctions where time=0",$c); while($win=$db->fetch_row($qqq)) { $time=$win['time']; $item=$win['itemname']; $winner=$win['bidder']; $owner=$win['owner']; $iname=mysql_result($db->query("SELECT itmname FROM items WHERE itmid={$item}", $c), 0, 0); if($win['bids']>0) { $db->query("insert into inventory VALUES('',$item,$winner,1,0)",$c) or die($db->error()); $db->query("update users set money=money+{$win['current']},auctionquota=auctionquota-1 where userid=$owner", $c); } if($win['bids']==0) { $winner=$win['owner']; $db->query("insert into inventory VALUES('',$item,$winner,1)",$c) or die($db->error()); } } $db->query("delete from auctions where time < 0", $c); event_add($win['owner'],"Your auction has ended with no bidders. Your {$iname} has been returned to your inventory.",$c); event_add($winner,"You won the auction of the {$iname} for \${$win['current']}",$c); event_add($owner, "Your {$iname} sold succesfully on the auction market with {$win['bids']} bids. You have been paid \${$win['current']}", $c); ?> Quote Link to comment Share on other sites More sharing options...
thebobby Posted January 24, 2011 Share Posted January 24, 2011 mine but has error = error occured please try agaian.. this happens when i try to put on autcion <?php //Made by zeddicus, do NOT re-distribute. //Copyright 2010 include(DIRNAME(__FILE__).'/globals.php'); $_GET['page'] = isset($_GET['page']) ? trim($_GET['page']) : 'index'; switch($_GET['page']) { case 'index' : index(); break; case 'Bid' : Bid(); break; case 'Add' : Add(); break; default : index(); break; } function index() { global $h; $Data = mysql_query("SELECT g.`ID`,g.`SellerID`,g.`ItemID`,g.`Time`,g.`CurrentBid`,g.`BuyNow`,g.`TimeLeft`,i.`itmid`,i.`itmname` FROM `gAuction` g LEFT JOIN `items` i ON (g.`ItemID` = i.`itmid`)") or die(mysql_error()); echo (' <span style = "font-size:2em; font-family:Arial,Helvetica,sans-serif; color:#8B0000">Auction House</span> <hr width = "90%"> <table border = "0" class = "table" align = "center" width = "90%" style = "text-align:center" cellspacing = "1"> <tr> <th>Seller</th> <th>Item</th> <th>Time Left</th> <th>Current Bid</th> <th>Links</th> </tr>'); if(!mysql_num_rows($Data)) { echo ('<tr> <td colspan = "5">There are no auction being held at the present time.</td> </tr> </table>'); exit($h->endpage()); }else{ while($aData = mysql_fetch_array($Data)) { $time = $aData['Time'] - time() + $aData['TimeLeft']; echo (' <tr> <td>'.$aData['SellerID'].'</td> <td>'.stripslashes(htmlentities($aData['itmname'])).'</td> <td>'.time_format($time).'</td> <td width = "15%">$'.number_format($aData['CurrentBid']).'</td> <td width = "15%" align = "center"><a href = "Auction.php?page=Bid&ID='.$aData['ID'].'"><span style = "color:#8B0000">Bid</span></a>|| <a href = "iteminfo.php?ID='.$aData['ItemID'].'"><span style = "color:#8B0000">Info</span></a></td>'); } echo ('</tr> </table> '); } $h->endpage(); } function Bid() { global $h,$ir; echo (' <span style = "font-size:2em; font-family:Arial,Helvetica,sans-serif; color:#8B0000">Bidding on Item</span> <hr width = "90%">'); $Data = mysql_query("SELECT g.`ID`,g.`SellerID`,g.`ItemID`,g.`CurrentBid`,g.`BuyNow`,g.`TimeLeft`,i.`itmid`,i.`itmname` FROM `gAuction` g LEFT JOIN `items` i ON (g.`ItemID` = i.`itmid`) WHERE (g.`ID` = ".abs(intval($_GET['ID'])).")") or die(mysql_error()); if(!mysql_num_rows($Data) || !ctype_digit($_GET['ID'])) { echo ('An error has occurred, please go back and try again.'); exit($h->endpage()); } $Data = mysql_fetch_array($Data); if((isset($_POST['bid']))) { if(!ctype_digit($_POST['bid'])) { echo ('An error has occurred, please try again.'); exit($h->endpage()); } if($_POST['bid'] < $Data['CurrentBid'] || $ir['money'] < $_POST['bid']) { echo ('You\'ve bidded below the current bid, or you don\'t have enough cash to bid. <a href = "/Auction.php"><span style = "color:#8B0000">Go Back</span></a>'); exit($h->endpage()); } if($_POST['bid'] >= $Data['BuyNow'] && $Data['BuyNow'] > 0) { mysql_query("DELETE FROM `gAuction` WHERE (`ID` = ".abs(intval($_GET['ID'])).")"); //Auction Delete mysql_query("UPDATE `users` SET `money` = `money` - ".abs(intval($_POST['bid']))." WHERE (`userid` = ".$_SESSION['userid'].")"); //Take cash from user mysql_query("INSERT INTO `inventory` VALUES ('',".$Data['ItemID'].",".$_SESSION['userid'].",1)"); // Credit winner item event_add($Data['SellerID'],''.mysql_real_escape_string($ir['username']).' bought your item of the auction using your "Buy It Now Price" ($'.number_format($Data['BuyNow']).')'); mysql_query("UPDATE `users` SET `money` = `money` + ".abs(intval($_POST['bid']))." WHERE (`userid` = ".$Data['SellerID'].")"); //Give cash to user echo ('You\'ve successfully purchased the item from the Auction using the "Buy It Now" price!. <a href = "/index.php"><span style = "color:#8B0000">Go Home</span></a>'); }else{ mysql_query("UPDATE `gAuction` SET `CurrentBid` = ".abs(intval($_POST['bid']))." WHERE (`ID` = ".abs(intval($_GET['ID'])).")"); // mysql_query("INSERT INTO `gAuctionBids` VALUES ('',".$Data['ID'].",".$_SESSION['userid'].",".abs(intval($_POST['bid'])).")"); //insert bid mysql_query("UPDATE `users` SET `money` = `money` - ".abs(intval($_POST['bid']))." WHERE (`userid` = ".$_SESSION['userid'].")"); //Take cash from user echo ('Your bid has been confirmed. <a href = "/Auction.php"><span style = "color:#8B0000">Back to Auction</span></a>'); } } if($Data['BuyNow'] == 0) { $Buy = 'Disabled by user'; }else{ $Buy = number_format($Data['BuyNow']); } if($Data['BuyNow'] == 0) { $Sign = ''; }else{ $Sign = '$'; } echo (' <table class = "table" cellspacing = "1" width = "35%" align = "center" style = "text-align:center"> <form action = "Auction.php?page=Bid&ID='.$_GET['ID'].'" method = "post"> <tr> <td width = "25%">Item Name:</td> <td><span style = "color:#8B0000">'.htmlentities($Data['itmname']).'</span></td> </tr> <tr> <td width = "25%">Current Bid:</td> <td>'.number_format($Data['CurrentBid']).'</td> </tr> <tr> <td width = "25%">Buy Now Price:</td> <td>'.$Sign.''.$Buy.'</td> </tr> <tr> <td width = "25%">Enter Bid:</td> <td><input type = "text" name = "bid" value = "0" /></td> </tr> <tr> <td colspan = "2"><input type = "submit" value = "Place Bid" /></td> </tr> </form> </table> <a href = "/Auction.php"><span style = "color:#8B0000">Go Back</a>'); $h->endpage(); } function Add() { global $h; $Data = mysql_query("SELECT iv.`inv_itemid`,iv.`inv_userid`,iv.`inv_qty`,it.`itmid`,it.`itmname` FROM `inventory` iv LEFT JOIN `items` it ON (iv.`inv_itemid` = it.`itmid`) WHERE (`inv_userid` = ".$_SESSION['userid'].") AND (`inv_itemid` = ".abs(intval($_GET['ID'])).")") or die(mysql_error()); if(!mysql_num_rows($Data) || !ctype_digit($_GET['ID'])) { echo ('An error has occurred, please go back and try again.'); exit($h->endpage()); } $Data = mysql_fetch_array($Data); echo (' <span style = "font-size:2em; font-family:Arial,Helvetica,sans-serif; color:#8B0000">Adding Item To Auction</span> <hr width = "90%"> You have <span style = "color:#8B0000">[i]'.number_format($Data['inv_qty']).'[/i]</span> - <span style = "color:#8B0000">[i]'.htmlentities($Data['itmname']).'[/i]</span> <hr width = "90%">'); if((isset($_POST['time']))) { $One = mysql_query("SELECT `ID` FROM `gAuction` WHERE (`SellerID` = ".$_SESSION['userid'].")"); if(mysql_num_rows($One)) { echo ('Only one item at the auction please.'); exit($h->endpage()); } if(!in_array($_POST['time'], array('1Hour','6Hours','1Day','2Days'))) { echo ('An error has occured please go back and try again.'); exit($h->endpage()); } if($Data['inv_qty'] < 1) { echo ('It seems you don\'t have enough of this item to send it to auction.'); exit($h->endpage()); } if($_POST['time'] === '1Hour') { $time = '3600'; } elseif($_POST['time'] === '6Hours') { $time = '21600'; } elseif($_POST['time'] === '1Day') { $time = '86400'; } elseif($_POST['time'] === '2Days') { $time = '172800'; } mysql_query("INSERT INTO `gAuction` VALUES ('',".$_SESSION['userid'].",".$Data['itmid'].",".abs(intval($_POST['sbid'])).",".abs(intval($_POST['buy'])).",".$time.",unix_timestamp())") or die(mysql_error()); if($Data['inv_qty'] > 1) { mysql_query("UPDATE `inventory` SET `inv_qty` = `inv_qty` - 1 WHERE (`inv_userid` = ".$_SESSION['userid'].") AND (`inv_itemid` = ".$Data['itmid'].")") OR DIE(MYSQL_ERROR()); }else{ mysql_query("DELETE FROM `inventory` WHERE (`inv_userid` = ".$_SESSION['userid'].") AND (`inv_itemid` = ".$Data['itmid'].")")OR DIE(MYSQL_ERROR()); } echo ('You\'ve successfully add the item to the auction. <a href = "/Auction.php"><span style = "color:#8B0000">Click here to View</span></a>'); }else{ echo (' <table border = "0" class = "table" cellspacing = "1" width = "60%" align = "center" style = "text-align:center"> <form action = "Auction.php?page=Add&ID='.$_GET['ID'].'" method = "post"> <tr> <td colspan = "2">Select the amount off time you wish your auction to last.</td> </tr> <tr> <td colspan = "2">1 Hour<input type = "radio" name = "time" value = "1Hour" /> 6 Hours<input type = "radio" name = "time" value = "6Hours" /> 24 Hours<input type = "radio" name = "time" value = "1Day" /> 48 Hours<input type = "radio" name = "time" value = "2Days" /></td> </tr> <tr> <td>Starting Bid</td> <td><input type = "text" name = "sbid" value = "0" /></td> </tr> <tr> <td>Buy It Now Price:</td> <td><input type = "text" name = "buy" value = "0" />(Enter 0 to disable)</td> </tr> <tr> <td colspan = "2"><input type = "submit" value = "Add item to Auction" /></td> </tr> </form> </table> <a href = "/inventory.php"><span style = "color:#8B0000">Go Back</span></a>'); } $h->endpage(); } ?> Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted February 1, 2011 Share Posted February 1, 2011 Please wrap your code in code tags! As for the event_add failing, this doesn't surprise me. The event_add() can be found in global_func.php, yet I see no call for that file ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.