T
T
taastvac2020-06-25 16:27:58
PHP
taastvac, 2020-06-25 16:27:58

Need to set up cron.php?

Hello, there is an advertising service https://adsvt.ru, you need to configure cron.php

There are 2 functions for this cron:
1: Every minute or every hour (at your discretion) you need to put crons so that he transfers money from a frozen account to the main balance and updated 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 bought for a week, he would count for a day and then delete the banners that defended their own.

The fact is that the cron works, money is debited from the frozen account to the main balance, but there is a problem with banners, for example, I bought a banner for a week, and it is deleted in a day, I don’t know how to fix this problem

The path that I indicated in crontab-e for cron execution
wget -O /dev/null -t 1 -q ' https://adsvt.ru/cron.php?uid=d41d8cd98f00b204e980... '

The cron script itself

<?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;
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question