A
A
Alex Lav2020-03-15 19:22:23
PHP
Alex Lav, 2020-03-15 19:22:23

How to make accruals occur regardless of the user visiting the site?

Help to edit the code, I will be very grateful in advance!!!!
I have a script that gives a bonus to a user for visiting the site.
What needs to be changed in the script so that the bonus is issued once every 24 hours,
regardless of whether the user has visited the site or not.
The script itself:

<?php if( ! defined( 'DATALIFEENGINE' ) ) die( "Hacking attempt!" );

if( file_exists( ENGINE_DIR . '/data/billing/plugin.bonuses.php' ) and ! $_COOKIE['billing_plugins_bonus_day'] )
{
  $plugin_config = include ENGINE_DIR . '/data/billing/plugin.bonuses.php';

  if( $plugin_config['t_status'] == '1' )
  {
    $plugin_lang = include ENGINE_DIR . '/modules/billing/plugins/bonuses/lang.php';

    $_SearchPay = $db->super_query( "SELECT `history_date` FROM " . USERPREFIX . "_billing_history
                        WHERE history_user_name='" . $member_id['name'] . "'
                          AND history_plugin='bonuses'
                          AND history_plugin_id='0'
                          ORDER BY history_date desc
                          LIMIT 1" );

    if( $_TIME > ( $_SearchPay['history_date'] + 86400 ) )
    {
      include ENGINE_DIR . '/modules/billing/OutAPI.php';

      if( ! $plugin_config['bonus3_alert_pm'] )
      {
        $BillingAPI->alert_pm = false;
      }

      if( ! $plugin_config['bonus3_alert_main'] )
      {
        $BillingAPI->alert_main = false;
      }

      $BillingAPI->PlusMoney(
        $member_id['name'],
        $plugin_config['t_bonus_sum'],
        $plugin_lang['info'],
        'bonuses'
      );

      SetCookie("billing_plugins_bonus_day", "1", $_TIME + 24 * 3600);

            unset($BillingAPI);

        }
    else
    {
            SetCookie("billing_plugins_bonus_day", "1", $_SearchPay['history_date'] + 86400);
        }

    unset($plugin_lang, $_SearchPay);
  }

  unset($plugin_config);
}

Thank you very much in advance!!!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Ernest Faizullin, 2020-03-15
@erniesto77

how did you try? No way.
In fact, to solve the problem, you need to use cron. But that is another story. In general, tasks cannot be posted on this site. And this is a task. And you didn’t even try to google, right here.

T
ThunderCat, 2020-03-15
@ThunderCat

What needs to be changed in the script so that the bonus is issued once every 24 hours,
regardless of whether the user has entered the site or not.
Finally, nothing, it's stupid to count the number of days from the beginning of your "attraction of unprecedented generosity" and issue this amount as coins. It can be shown only when the user has logged in, and at the same time it can be added to the database)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question