Новичок
Покинул форум
Сообщений всего: 4
Дата рег-ции: Март 2018
Помог: 0 раз(а)
|
Ребята выручайте, запутался в 3 соснах, вернее в 3 файлах. Отблагодарю!
Ситуация следующая:
Имеется таблица, в которой некорректно работают 2 последние колонки, а именно ежесуточное обновление процентов и количество дней.
[img]https://prnt.sc/o8915z[/img]
Как сделать чтобы эти колонки обновлялись каждые сутки ума не приложу, всё что пробовал не получается. Хотя в конце заданного депозитом срока срабатывает автообновление страницы так, как нужно.
Вот первый файл с помощью которого открываем депозит на необходимый срок:
Спойлер (Отобразить)CODE ( htmlphp):
скопировать код в буфер обмена
<?php if($login) { if($_GET['add'] == "deposit") { $plan = intval($_POST['plan']); $sum = sprintf("%01.2f", $_POST['sum']); $reinv = sprintf("%01.2f", $_POST['reinv']); $paysys = intval($_POST['paysys']); if($plan && $sum) { $result = mysql_query("SELECT * FROM plans WHERE id = ".$plan." LIMIT 1"); if(!$row['id']) { print '<p class="er">Choose a tariff plan</p>'; } elseif($sum < $row['minsum'] || ($sum > $row['maxsum'] && $row['maxsum'] != 0)) { print '<p class="er">The amount does not match the rate plan</p>'; } elseif($sum > $pmbalance && $paysys == 1) { print '<p class="er">You have insufficient funds in the Perfect Money account, we recommend <a href="/enter/"> refill </a> it.</p>'; } elseif($sum > $pebalance && $paysys == 2) { print '<p class="er">You have insufficient funds in the Payeer account, we recommend <a href="/enter/"> refill </a> it.</p>'; } elseif($sum > $btbalance && $paysys == 3) { print '<p class="er">You have insufficient funds in the Bitcoin, we recommend <a href="/enter/"> refill </a> it.</p>'; } elseif($reinv < 0 && $reinv > 100) { print '<p class="er">Percentage of reinvestment delivery has to be from 0 to 100</p>'; } else { if($row['bonusdeposit']) { $depo = sprintf("%01.2f", $sum + $sum / 100 * $row['bonusdeposit']); } else { $depo = $sum; } // Вычисляем даты if(cfgSET('datestart') <= time()) { $weekend = $row['weekend']; if($day == 0 && $weekend == 1) { } elseif($day == 6 && $weekend == 1) { } else { $nad = 0; } if($row['period'] == 1) { $nextdate = $lastdate + 7776000 + $nad; } elseif($row['period'] == 2) { $nextdate = $lastdate + 15552000 + $nad; } elseif($row['period'] == 3) { $nextdate = $lastdate + 31104000 + $nad; } elseif($row['period'] == 4) { $nextdate = $lastdate + 2592000 + $nad; } } else { if($row['period'] == 1) { $nextdate = cfgSET('datestart') + 7776000; } elseif($row['period'] == 2) { $nextdate = cfgSET('datestart') + 15552000; } elseif($row['period'] == 3) { $nextdate = cfgSET('datestart') + 31104000; } elseif($row['period'] == 4) { $nextdate = cfgSET('datestart') + 2592000; } } $sql = "INSERT INTO `deposits` (username, user_id, date, plan, sum, paysys, lastdate, nextdate, reinvest) VALUES ('".$login."', ".$user_id.", ".time().", ".$plan.", ".$depo.", ".$paysys.", ".$lastdate.", ".$nextdate.", ".$reinv.")"; if($paysys == 1) { mysql_query('UPDATE users SET pm_balance = pm_balance - '.$sum.' WHERE id = '.$user_id.' LIMIT 1'); } elseif($paysys == 2) { mysql_query('UPDATE users SET lr_balance = lr_balance - '.$sum.' WHERE id = '.$user_id.' LIMIT 1'); } elseif($paysys == 3) { mysql_query('UPDATE users SET bt_balance = bt_balance - '.$sum.' WHERE id = '.$user_id.' LIMIT 1'); } // Начисляем бонус if($row['bonusbalance']) { $bonus = sprintf("%01.2f", $sum / 100 * $row['bonusbalance']); mysql_query('UPDATE users SET pm_balance = pm_balance + '.$bonus.' WHERE id = '.$user_id.' LIMIT 1'); } // Начисляем нашим "любимым" рефералам if($uref) { // Подсчитываем кол-во уровней if($countlvl) { $i = 0; $uid = $user_id; $query = "SELECT * FROM reflevels ORDER BY id ASC"; if($i < $countlvl) { $lvlperc = $row['sum']; // Процент уровня $ps = sprintf("%01.2f", $sum / 100 * $lvlperc); // Сумма рефских if($uref) { // Смотрим есть ли индивидуальный процент у данного реферала $get_refp = mysql_query("SELECT ref_percent FROM users WHERE id = ".intval($urefp)." LIMIT 1"); $urefp = $rowrefp['ref_percent']; if($i == 0 && $urefp) { $ps = sprintf("%01.2f", $sum / 100 * $urefp); // Сумма рефских } mysql_query('UPDATE users SET pm_balance = pm_balance + '.$ps.', reftop = reftop + '.$ps.' WHERE id = '.$uref.' LIMIT 1'); mysql_query('UPDATE users SET ref_money = ref_money + '.$ps.' WHERE id = '.$uid.' LIMIT 1'); // Получаем данные следующего panel $get_ref = mysql_query("SELECT id, ref FROM users WHERE id = ".intval($uref)." LIMIT 1"); $uref = $rowref['ref']; $uid = $rowref['id']; } } $i++; } } } // Закончили с рефералами print '<p class="erok">Deposit is open! <a href="/deposits/">deposits to top »</a></p>'; } } else { print '<br><p class="er">Select a data plan, the payment system and enter the amount of the deposit</p>'; } } ?> <form method="post" action="?add=deposit"> <?php $result = mysql_query("SELECT * FROM plans WHERE status = 0 ORDER BY id ASC"); $i = 0; print "
<ul class=\"plans\"> <li> <p class=\"radio\"><input type=\"radio\" name=\"plan\" value=\"".$row['id']."\" checked /> </p>"; print "<p class=\"title\"><span class=\"orange bold\">".$row['percent']."%</span> per "; if($row['period'] == 1) { print "month"; } elseif($row['period'] == 2) { print "month"; } elseif($row['period'] == 4) { print "month"; } else { print "month"; } print ", for ".$row['days']; if($row['period'] == 4) { print " days"; } elseif($row['period'] == 1) { print " days"; } elseif($row['period'] == 2) { print " days"; } elseif($row['period'] == 3) { print " days"; } print "</p> <p class=\"limits\">Min : <span class=\"bold\">$".$row['minsum']."</span><br />Max : <span class=\"bold\">$".$row['maxsum']."</span></p> </li> </ul>
<tr> <td height=\"1\" bgcolor=\"#cccccc\"></td> </tr> <tr> <td height=\"15\"><script language=\"JavaScript\"><!-- var per['".$row['percent']."']; var cou['".$row['days']."']; //--></script></td> </tr>"; $i++; } if(!$i) { print '<p class="warn">At the moment, the administrator has not created a tariff plans for deposits</p>'; } ?> <div style="margin-top: 15px;"></div> <script language="JavaScript"> <!-- function CheBal(val) { if(val == 1) { document.getElementById("sum").value = '<?php print $pmbalance; ?>'; } else if(val == 2) { document.getElementById("sum").value = '<?php print $pebalance; ?>'; } else if(val == 3) { document.getElementById("sum").value = '<?php print $btbalance; ?>'; } else { } } //--> </script> <table width="100%"> <div class="clr"></div> <p class="line small"></p> <label class="left separated upper">Amount ($): </label> <input id="sum" class="right mid separated" type="text" name="sum" value="<?php print $pmbalance; ?>" onblur="if (value == '') {value='Amount'}" onfocus="if (value == 'Amount') {value =''}" autocomplete="off" placeholder="Amount" /> <div class="clr"></div> <p class="line small"></p> <label class="left separated upper">Payment System: </label> <select class="right mid separated" id="paysys" onChange="CheBal();" name="paysys"> <?php if('$cfgPerfect') { print '<option value="1" selected>PerfectMoney - $'.$pmbalance.'</option>'; } if(cfgSET('cfgPEsid') && cfgSET('cfgPEkey')) { print '<option value="2">Payeer - $'.$pebalance.'</option>'; } $result = mysql_query("SELECT * FROM `paysystems` WHERE id > 2 ORDER BY id ASC"); print '<option value="'.$row['id'].'">'.$row['name'].' - $'.$btbalance.'</option> '; } ?> </select> <div class="clr"></div> <p class="line small"></p> <?php if(cfgSET('cfgReInv') == "on") { print '<tr> <label class="left separated upper">Reinvestment (%): </label> <input class="right mid separated" type="text" name="reinv" value="0" /> </tr>'; } ?> <div class="clr"></div> <p class="line small"></p> <div align="center" style="padding-top: 10px;padding-bottom: 10px;"><input type='submit' name='submit' value=' Submit application ' /></div> </table> </form> <?php } else { print "<p class=\"er\">To access this page you need to login</p>"; include "../login/login_ru.php"; } ?>
Второй файл с самой таблицей в которой и нужно ежесуточно обновлять allpercin и count (89 и 90 строка)
Спойлер (Отобразить)
CODE ( htmlphp):
скопировать код в буфер обмена
<?php if($login) { if($_GET['close']) { $result = mysql_query("SELECT * FROM deposits WHERE id = ".intval($_GET['close'])." AND user_id = ".$user_id." AND status = 0 LIMIT 1"); $result2 = mysql_query("SELECT * FROM plans WHERE id = ".$row['plan']." LIMIT 1"); if(!$row['id'] || !$row2['id']) { print '<p class="er"> An error occurred when closing the Deposit.</p>'; } elseif($row2['back'] != 1 || $row2['close'] != 1) { print '<p class="er">This Deposit cannot be closed prematurely.</p>'; } else { $sum = sprintf("%01.2f", $row['sum'] - $row['sum'] / 100 * $row2['close_percent']); if($row['paysys'] == 1) { mysql_query('UPDATE users SET pm_balance = pm_balance + '.$sum.' WHERE id = '.$row['user_id'].' LIMIT 1'); }elseif($row['paysys'] == 2) { mysql_query('UPDATE users SET lr_balance = lr_balance + '.$sum.' WHERE id = '.$row['user_id'].' LIMIT 1'); }elseif($row['paysys'] == 3) { mysql_query('UPDATE users SET bt_balance = bt_balance + '.$sum.' WHERE id = '.$row['user_id'].' LIMIT 1'); } mysql_query("DELETE FROM deposits WHERE id = ".$row['id']." LIMIT 1"); print '<p class="erok">The Deposit was closed prematurely.</p>'; } } ?> <?php $it = 0; $s = 0; $result = mysql_query("SELECT * FROM deposits WHERE user_id = ".$user_id." ORDER BY id ASC"); print ' <div class="col-md-8" style="width: 100%;padding-right: 0px;padding-left: 0px;bottom: 25px;top: -20;top: -20;"> <article class="widget"> <header class="widget__header one-btn"> <div class="widget__title" style=" width: 100%;"> <i class="pe-7f-piggy"></i><h3>Pending deposits</h3> </div> </header> <div class="widget__content table-responsive"> <table class="table table-striped media-table"> <thead> <tr> <th>Rate</th> <th>Date of contribution</th> <th>The end</th> <th>Payment System</th> <th>Contribution</th> <th>% monthly</th> <th>Daily profit</th> <th>Earned</th> <th>Status of payments</th> </tr> </thead><tbody>'; $result2 = mysql_query("SELECT * FROM plans WHERE id = ".$row['plan']." LIMIT 1"); $count = mysql_query('UPDATE deposits SET nextdate - lastdate WHERE id = '.$row['user_id'].' LIMIT 1'); $finish = $row['date'] + ($row2['days']*86400); $percinday = ($row['sum'] * ($row2['percent'] / 100)) / 30; $allpercin = $percinday * $row['count']; $statall = $row2['days']; if($it > 0) { $itnot1 = 'margin-top: 5px;'; } else { $itnot1 = 'margin-top: 0px;'; } print " <tr style=\"background-color:transparent; text-align: center;\"> <td style=\"padding: 0; text-align: center; width: 130px; vertical-align: middle;\">".$row2['name']."</td> <td>".date("d.m.Y H:i", $row['date'])."</td> <td>".date("d.m.Y H:i", $finish)."</td> <td>"; if($row['paysys'] == 1) { print "PerfectMoney"; } elseif($row['paysys'] == 2) { print "Payeer"; } elseif($row['paysys'] == 3) { print "Bitcoin"; } print "</td> <td>$".$row['sum']."</td> <td>".$row2['percent']."%</td> <td>".sprintf("%01.2f", $percinday)."</td> <td>".sprintf("%01.2f", $allpercin)."</td> <td style=\"color: white;\">".$row['count']."/".$statall."</td> </tr> <tr> <td align=\"center\" colspan=\"9\"><b>Left until the next payment: <span id=\"deptimer".$row['id']."\"></span></b> [ ".date("H:i d.m.Y", $finish)." ] "; if($row2['back'] == 1 && $row2['close'] == 1) { print " <a href=\"javascript: if(confirm('Do you want to close the account? At closing of the Deposit, you will be deducted with the Commission in the amount ".$row2['close_percent']."%')) top.location.href='?close=".$row['id']."';\"><i class=\"pe-7s-close\" style=\"color: white; font-size: 25px; vertical-align: middle\"></i>[ Close deposit ]</a>"; } print"</td> <tr> </tr> <td class=\"lineclock\" colspan=\"9\" style=\"padding-left: 1px; padding-right: 1px;\"> <div id=\"percentline".$row['id']."\" class=\"percentline\"> </div><script language=\"JavaScript\"> <!-- CalcTimePercent(".$row['id'].", ".$row['date'].", ".$finish.", ".time().", ".$row2['period']."); //--> </script> </td> </tr> "; $it++; $s = $s + $row['sum']; } print'<div style="background-color: rgba(0, 0, 0, 0.25); border-bottom: 1px transparent solid; text-align:center; font-size:20px; color: #53d769; height:21px;">Total deposits in the amount of <b>$'.$s.'</b></div>'; if($s == 0) { print '<div style="background-color: rgba(0, 0, 0, 0.25); border-bottom: 1px transparent solid; text-align:center; font-size:20px; color: #53d769; height:21px;">You have no open deposits, but you can <a href="/deposit/">to access</a> it.</div>'; } print' </tbody>
</table> </div> <!-- /widget__content --> </article><!-- /widget --> </div>'; ?> <?php } else { print "<p class=\"er\">To access this page you need to login</p>"; include "../login/login_ru.php"; } ?>
Третий .ini
Спойлер (Отобразить)
CODE ( htmlphp):
скопировать код в буфер обмена
if (( cfgSET( 'autopercent' ) == 'on' && cfgSET( 'datestart' ) < time( ) )) { $result = mysql_query( 'SELECT * FROM deposits WHERE nextdate <= ' . time( )); if ($row = mysql_fetch_array( $result )) { $result2 = mysql_query( 'SELECT * FROM plans WHERE id = ' . $row['plan'] . ' LIMIT 1' ); $row2 = mysql_fetch_array( $result2 ); if ($row['reinvest']) { $p = sprintf( '%01.2f', $row['sum'] * ($row2['percent'] / 100)) /30; $allp = sprintf( '%01.2f', $p * ( $row['count'] + 1 )); $re = sprintf( '%01.2f', $row['sum'] * ($row2['reinvest'] / 100)) /30; $p = $p - $re; mysql_query( 'UPDATE `deposits` SET sum = sum + ' . $re . ' WHERE id = ' . $row['id'] . ' LIMIT 1' ); } else { $p = sprintf( '%01.2f', $row['sum'] * ($row2['percent'] / 100)) /30; $allp = sprintf( '%01.2f', $p * ( $row['count'] + 1 )); } if($row['paysys'] == 1) { mysql_query( 'UPDATE users SET pm_balance = pm_balance + ' . $allp . ' WHERE id = ' . $row['user_id'] . ' LIMIT 1' ); mysql_query( 'INSERT INTO stat (user_id, date, plan, sum, paysys) VALUES (' . $row['user_id'] . ', ' . $row['nextdate'] . ', ' . $row['plan'] . ', ' . $allp . ', ' . $row['paysys'] . ')' ); if ($row2['days'] <= intval( $row['count'] + 1 )) { if ($row2['back'] == 1) { mysql_query( 'UPDATE users SET pm_balance = pm_balance + ' . $row['sum'] . ' WHERE id = ' . $row['user_id'] . ' LIMIT 1' ); mysql_query( 'DELETE FROM deposits WHERE id = ' . $row['id'] . ' LIMIT 1' ); } mysql_query( 'DELETE FROM deposits WHERE id = ' . $row['id'] . ' LIMIT 1' ); } } elseif($row['paysys'] == 2) { mysql_query( 'UPDATE users SET lr_balance = lr_balance + ' . $allp . ' WHERE id = ' . $row['user_id'] . ' LIMIT 1' ); mysql_query( 'INSERT INTO stat (user_id, date, plan, sum, paysys) VALUES (' . $row['user_id'] . ', ' . $row['nextdate'] . ', ' . $row['plan'] . ', ' . $allp . ', ' . $row['paysys'] . ')' ); if ($row2['days'] <= intval( $row['count'] + 1 )) { if ($row2['back'] == 1) { mysql_query( 'UPDATE users SET lr_balance = lr_balance + ' . $row['sum'] . ' WHERE id = ' . $row['user_id'] . ' LIMIT 1' ); mysql_query( 'DELETE FROM deposits WHERE id = ' . $row['id'] . ' LIMIT 1' ); } mysql_query( 'DELETE FROM deposits WHERE id = ' . $row['id'] . ' LIMIT 1' ); } } elseif($row['paysys'] == 3) { mysql_query( 'UPDATE users SET bt_balance = bt_balance + ' . $allp . ' WHERE id = ' . $row['user_id'] . ' LIMIT 1' ); mysql_query( 'INSERT INTO stat (user_id, date, plan, sum, paysys) VALUES (' . $row['user_id'] . ', ' . $row['nextdate'] . ', ' . $row['plan'] . ', ' . $allp . ', ' . $row['paysys'] . ')' ); if ($row2['days'] <= intval( $row['count'] + 1 )) { if ($row2['back'] == 1) { mysql_query( 'UPDATE users SET bt_balance = bt_balance + ' . $row['sum'] . ' WHERE id = ' . $row['user_id'] . ' LIMIT 1' ); mysql_query( 'DELETE FROM deposits WHERE id = ' . $row['id'] . ' LIMIT 1' ); } mysql_query( 'DELETE FROM deposits WHERE id = ' . $row['id'] . ' LIMIT 1' ); } } if (( date( 'w' ) == 5 && $row2['weekend'] == 1 )) { $plus = 173953; } else { $plus = 1153; } if ($row2['period'] == 1) { $nextdate = $row['nextdate'] + 7776000 + $plus; } elseif ($row2['period'] == 2) { $nextdate = $row['nextdate'] + 15552000 + $plus; } elseif ($row2['period'] == 3) { $nextdate = $row['nextdate'] + 31104000 + $plus; } elseif ($row2['period'] == 4) { $nextdate = $row['nextdate'] + 2592000; } mysql_query( 'UPDATE deposits SET count = count + 1, lastdate = ' . $row['nextdate'] . ', nextdate = ' . $nextdate . ' WHERE id = ' . $row['id'] . ' LIMIT 1' ); } } ?>
|