Ситуация следующая:
Имеется таблица, в которой некорректно работают 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");
- $row = mysql_fetch_array($result);
- 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()) {
- $lastdate = time();
- $weekend = $row['weekend'];
- $day = date("w");
- 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 {
- $lastdate = time();
- 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.")";
- mysql_query($sql);
- 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) {
- // Подсчитываем кол-во уровней
- $countlvl = mysql_num_rows(mysql_query("SELECT * FROM reflevels"));
- if($countlvl) {
- $i = 0;
- $uid = $user_id;
- $query = "SELECT * FROM reflevels ORDER BY id ASC";
- $result = mysql_query($query);
- while($row = mysql_fetch_array($result)) {
- 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");
- $rowrefp = mysql_fetch_array($get_refp);
- $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");
- $rowref = mysql_fetch_array($get_ref);
- $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;
- while($row = mysql_fetch_array($result)) {
- 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");
- while($row = mysql_fetch_array($result)) {
- 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";
- }
- ?>