Jump to content
MakeWebGames

Having a issue


athena26

Recommended Posts

Sim hasn't replied to me yet but he said he will check everything. 

 

Having a crazy issue with battle ladder

<?php

include __DIR__."/config.php";

global $_CONFIG;

$code = null;

if (isset($argv)) {

    parse_str($argv[1], $params);

    $code = $params['code'];

} else {

    $code = array_key_exists('code', $_GET) && ctype_alnum($_GET['code']) ? $_GET['code'] : null;

}

if($code != $_CONFIG['code']) { exit; }

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;

include "global_func.php";

   $fetch = $db->query("SELECT * FROM `battle_ladders` ORDER BY `ladderLevel` ASC");

   while($ft = $db->fetch_row($fetch))

    {

      $count = 0;

      $sql = $db->query(sprintf("SELECT * FROM `battle_members` LEFT JOIN `users` ON `userid` = `bmemberUser` WHERE `bmemberLadder` = '%u' ORDER BY `bmemberScore` DESC LIMIT 10", $ft['ladderId']));

      while($r = $db->fetch_row($sql))

       {

         $count ++;

         $cash = ((((rand(50, 75) / 10) * $r['level']) / $count) * ($ft['ladderLevel'] + 1));

         $points = ((((rand(1, 2) / 10) * $r['level']) / $count) * ($ft['ladderLevel'] + 1));

         if($r['userid'])

          {

            $db->query(sprintf("UPDATE `users` SET `money` = `money` + '%d', `crystals` = `crystals` + '%d' WHERE `userid` = '%u'", $cash, $points, $r['bmemberUser']));

            event_add($r['bmemberUser'], 'You have earned $'.number_format($cash).' and '.number_format($points).' Points for achieveing rank #'.$count.' in the '.$ft['ladderName'].' ladder!');

          }

       }

    }

   $db->query("TRUNCATE TABLE battle_members;");

   


   

?>

 

This is my battle Cron and somehow it's awarding over 100million crystals. 

Link to comment
Share on other sites

Well I think i found the bug .. that's causing the doubling issue . I think it's docrime.php there's a queries that is doubling. 

 

$db->query("UPDATE users SET money=money+{$r['crimeSUCCESSMUNY']}, crystals=crystals+{$r['crimeSUCCESSCRYS']}, exp=exp+$formula, crimexp=crimexp+{$r['crimeXP']}, crimes=crimes+1 WHERE userid=$userid");
           

I'm not sure if this is the error but I think it is ..

Link to comment
Share on other sites

On 6/14/2021 at 10:37 AM, athena26 said:

Well I think i found the bug .. that's causing the doubling issue . I think it's docrime.php there's a queries that is doubling. 

 

$db->query("UPDATE users SET money=money+{$r['crimeSUCCESSMUNY']}, crystals=crystals+{$r['crimeSUCCESSCRYS']}, exp=exp+$formula, crimexp=crimexp+{$r['crimeXP']}, crimes=crimes+1 WHERE userid=$userid");
           

I'm not sure if this is the error but I think it is ..

No, that’s not it. It’s only updating 1 time

Edited by KyleMassacre
Link to comment
Share on other sites

32 minutes ago, Sim said:

Mind telling us what it was

mainmenu.php
Not 100% sure what was doing it, guessing its the clock function maybe.
Rewrote and bug gone 🙂

<?php     
global $db,$c,$ir, $set, $userid;
$hc = $db->query("SELECT * FROM users WHERE hospital > 0");
$hospitalcount = $db->num_rows($hc);
$jc = $db->query("SELECT * FROM users WHERE jail > 0");
$jailcount = $db->num_rows($jc);
$worksho = $db->query("SELECT * FROM itemscreated WHERE iUSER=$userid");
$workshop = $db->num_rows($worksho);
$ec=$ir['new_events'];
$mc=$ir['new_mail'];
if($ir['hospital'])
{
print "

<div class='navipart'>
<div class='navitop'><p>
<img src='images/navi_txt.gif' alt='' />
</p></div>

<div class='navi_mid'><ul>



<li> <a class='link1' href='index.php'>Home</a></li>
<li> <a class='link1' href='shops.php'>Medical Shop</a></li>
<li><a class='link1' href='jail.php'>Jail ({$jailcount})</a></li>
<li> <a class='link1' href='hospital.php'>Hospital ({$hospitalcount})</a></li> 
<li> <a class='link1' href='inventory.php'>Inventory</a></li>
<li> <a class='link1' href='workshop.php'>Workshop ($workshop)</a></li>";
}
elseif($ir['jail'])
{

print "

<div class='navipart'>
<div class='navitop'><p>
<img src='images/navi_txt.gif' alt='' />
</p></div>

<div class='navi_mid'><ul>


<li><a class='link1' href='jail.php'>Jail ({$jailcount})</a></li>";
}
else
{
    
print "


<div class='navipart'>
<div class='navitop'><p>
<img src='images/navi_txt.gif' alt='' />
</p></div>

<div class='navi_mid'><ul>


<li><a class='link1' href='index.php'>Home</a></li>
<li><a class='link1' href='inventory.php'>Inventory</a></li>
<li><a class='link1' href='workshop.php'>Workshop ($workshop)</a></li>";
}
if($ec > 0) { print "<li> <a class='link1' href='events.php'>Events ($ec)</a></li>"; }
else { print "<li> <a class='link1' href='events.php'>Events (0)</a></li>"; }
if($mc > 0) { print "<li> <a class='link1' href='mailbox.php'>Mailbox ($mc)</a></li>"; }
else { print "<li> <a class='link1' href='mailbox.php'>Mailbox (0)</a></li>";
}
if($ir['chathide'] == 1){
    print"<li><a class='link1' href='chat.php'>Chat</a></li>";
}
if($ir['new_announcements'])
{
print "<li> <a class='link1' href='announcements.php' style='font-weight: 800;'>Announcements ({$ir['new_announcements']})</a></li>";
}
else
{
print "<li> <a class='link1' href='announcements.php'>Announcements (0)</a></li>";
}


if($ir['jail'] and !$ir['hospital'])
{
print "<li> <a class='link1' href='gym.php'>Jail Gym</a></li>
<li><a class='link1' href='inventory.php'>Inventory</a></li>

<li> <a class='link1' href='hospital.php'>Hospital({$hospitalcount})</a></li>";
}
else if (!$ir['hospital'])
{
print "<li> <a class='link1' href='explore.php'>Explore</a></li>
<li> <a class='link1' href='gym.php'>Gym</a></li>
<li> <a class='link1' href='criminal.php'>Crimes</a></li>
<li> <a class='link1' href='gta.php'>GTA</a></li>
<li> <a class='link1' href='job.php'>Your Job</a></li>
<li> <a class='link1' href='business_home.php'>Your Business</a></li>
<li> <a class='link1' href='stocks.php'>Stock Market</a></li>  
<li> <a class='link1' href='competition.php'>Game Events</a></li>

<li> <a class='link1' href='contest.php'>Contest</a></li>
<li> <a class='link1' href='hospital.php'>Hospital  ({$hospitalcount})</a></li>
<li> <a class='link1' href='jail.php'>Jail ({$jailcount})</a></li>";
}
else
{
print "<li> <a class='link1' href='jail.php'>Jail ({$jailcount})</a></li>";
}
print "<li> <a class='link1' href='forums.php'>Forums</a></li>";

print "
<li> <a class='link1' href='newspaper.php'>Newspaper</a></li>
<li> <a class='link1' href='search.php'>Search</a></li>";
if(!$ir['jail'] && $ir['gang'])
{
print "<li> <a class='link1' href='zFamily.php?p=myFam'><font color = green>Your Gang</a></li>


</div>

<div><img src='images/navi_btm.gif' alt='' /></div>
</div>  


";
}
if($ir['user_level'] > 1)
{
print "


<div class='navipart'>
<div class='navitop'><p>
<img src='images/staff_links.gif' alt='' /> 
</p></div>
<div class='navi_mid'><ul>


<li> <a class='link1' href='staff.php'>Staff Panel</a></li>

";

if ($userid == '1') {
    echo "<li> <a class='link1' href='ownerpanel.php'>Owner Panel</a></li>";;
}

print "

</div>
<div><img src='images/navi_btm.gif' alt='' /></div>
</div>";


print "

<div class='navipart'>
<div class='navitop'><p>
<img src='images/staff_online.gif' alt='' />
</p></div>
<div class='navi_mid'><ul> 
";
$q=$db->query("SELECT * FROM users WHERE laston>(unix_timestamp()-15*60) AND user_level>1 ORDER BY userid ASC");
while($r=$db->fetch_row($q))
{
$la=time()-$r['laston'];
$unit="secs";
if($la >= 60)
{
$la=(int) ($la/60);
$unit="mins";
}
if($la >= 60)
{
$la=(int) ($la/60);
$unit="hours";
if($la >= 24)
{
$la=(int) ($la/24);
$unit="days";
}
}
print "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> ($la $unit)<br>
</div><div><img src='images/navi_btm.gif' alt='' /></div> </div>  

";
}
}
if($ir['donatordays'])
{
print "


<div class='navipart'>
<div class='navitop'><p>
<img src='images/donators_only.gif' alt='' />
</p></div>
<div class='navi_mid'><ul> 

<li> <a class='link1' href='friendslist.php'>Friends List</a></li>
<li> <a class='link1' href='blacklist.php'>Black List</a></li>
<li> <a class='link1' href='ddreward.php'>Daily Rewards</a></li>
<li> <a class='link1' href='vipgym.php'>VIP Gym</a></li>

</div>

<div><img src='images/navi_btm.gif' alt='' /></div>
</div>  


";
}
print "


<div class='navipart'>
<div class='navitop'><p>
<img src='images/other_links.gif' alt='' />
</p></div>
<div class='navi_mid'><ul> 


<li> <a class='link1' href='preferences.php'>Preferences</a></li>
<li> <a class='link1' href='preport.php'>Player Report</a></li>
<li> <a class='link1' href='helptutorial.php'>Help Tutorial</a></li>
<li> <a class='link1' href='gamerules.php'>Game Rules</a></li>
<li> <a class='link1' href='viewuser.php?u={$ir['userid']}'>My Profile</a></li>
<li> <a class='link1' href='logout.php'>Logout</a></li>

</div>

<div><img src='images/navi_btm.gif' alt='' /></div>
</div>  


" ; 

echo("<table border='1' width='85%' bordercolor='white'>
<tr style='background: url('.$bimage.');'><th><font color=gold>Time and Date</th></tr><tr><td style='background:  url('.$bimage.');'><font color=gold>".date ('F j, Y')."<br />".date('g:i  a')."</td></tr></table>");



?>

Welcome to see if you can figure it out, This is the before i fixed it mainmenu.php

After looking through it i still cant see the issue lol.
All i know is i removed and rewrote and bang, double issue fixed.
Spooky.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...