Setting up cron.php

Could you help us solve the problem? there is an advertising service adsvt.ru, need to configure cron.php

There are 2 functions of this crown:

  1. Every minute or every hour (at your discretion), you need to put crowns so that he transfers money from the frozen account to the main balance and updates the statistics of successful transactions on the main menu, etc.

  2. Every day, he must check the time of placing the banner, so that if a person for a week, he bought a day, counted and then removed the banners that defended their own.

The first item is working properly, but the second item is not, the fact is that when I buy a banner for a week, it is deleted every other day

The paths that I specified in CronTab-e on the hosting

wget -O /dev/null -t 1 -q 'https://adsvt.ru/cron.php?uid=d41d8cd98f00b204e9800998ecf8427e'

This fulfills point 1

wget -O /dev/null -t 1 -q 'https://adsvt.ru/cron.php?uid=d41d8cd98f00b204e9800998ecf8427e&mode=deldayip'

And this is for banners

And here is the code itself cron.php

<?php
define('BASE_DIR', $_SERVER['DOCUMENT_ROOT']);
define('TIME', time());

require_once(BASE_DIR . '/inc/init.php');

if (isset($_GET['uid']) && $_GET['uid'] == HASH_MD5) {
    $query = $mysqli->query("SELECT * FROM `" . PREFIX . "_banners` WHERE `status` = '1'");
    if ($query->num_rows) {
        while ($res = $query->fetch_assoc()) {
            if ($res['money'] <= 0) {
                $mysqli->query("UPDATE `" . PREFIX . "_banners` SET `status` = '0' WHERE `id` = '" . $res['id'] . "'");
                $mysqli->query("UPDATE `" . PREFIX . "_config` SET `success_work` = `success_work` + '1' WHERE `id` = '1'");
                continue;
            }
            $money = number_format($res['price'] / (($res['weeks'] * 7) * 24),7);
            if ($res['money'] < $money) {
                $money = $res['money'];
            }
            $money_frozen = $mysqli->query("SELECT `money_frozen` FROM `" . PREFIX . "_users` WHERE `id` = '" . $res['user_blocks'] . "' LIMIT 1")->fetch_assoc();
            if ($money_frozen['money_frozen'] >= $money) {
                //списание замороженных средств вебмастера и зачисление средств на баланс вебмастера
                $mysqli->query("UPDATE `" . PREFIX . "_users` SET `money_frozen` = `money_frozen` - '" . $money . "', `money` = `money` + '" . $money . "', `money_all` = `money_all` + '" . $money . "', `money_banner` = `money_banner` + '" . $money . "' WHERE `id` = '" . $res['user_blocks'] . "'");
            } else {
                //списание замороженных средств вебмастера и зачисление средств на баланс вебмастера
                $mysqli->query("UPDATE `" . PREFIX . "_users` SET `money_frozen` = '0', `money` = `money` + '" . $money . "', `money_all` = `money_all` + '" . $money . "', `money_banner` = `money_banner` + '" . $money . "' WHERE `id` = '" . $res['user_blocks'] . "'");
            }
            //обновление баланса сделки
            $mysqli->query("UPDATE `" . PREFIX . "_banners` SET `money` = `money` - '" . $money . "' WHERE `id` = '" . $res['id'] . "'");
            $mysqli->query("INSERT INTO `" . PREFIX . "_history` (`time_add`, `user_id`, `type`, `money`) VALUES (NOW(), '" . $res['user_blocks'] . "', 'banner', '" . $money . "')");
            $mysqli->query("UPDATE `" . PREFIX . "_config` SET `users_profit` = `users_profit` + '" . $money . "' WHERE `id` = '1'");
        }
    }
}



if (isset($_GET['uid']) && $_GET['uid'] == HASH_MD5 && $_GET['mode'] == 'iks') {
    $query = $mysqli->query("SELECT * FROM `" . PREFIX . "_blocks`");
    if ($query->num_rows) {
        while ($res = $query->fetch_assoc()) {
            $url = $res['url'];
            $mysqli->query("UPDATE `".PREFIX."_blocks` SET `tic` = '".YandexIks::getValueFromImage($url)."' WHERE id = '".(int)$res['id']."'");
        }
    }
}



if (isset($_GET['uid']) && $_GET['uid'] == HASH_MD5 && $_GET['mode'] == 'deldayip') {
    $query = $mysqli->query("DELETE FROM `" . PREFIX . "_blocks_view` WHERE time_add < (CURDATE()-2)");
    echo 1;
}
Author: KoVadim, 2020-07-02