<?php
/*
Created a script AlyOha
Especially for the ROTORCMS
Email: goodalyo@gmail.com
Скрипт написан AlyOha
Специально под ROTORCMS
Email: goodalyo@gmail.com
*/
function gift_for_visiting () {
if (is_user()) {
global $udata;
$value = '';
$bonusemoney = 5000;
$timeplus = SITETIME + 86400;
$attendance = $udata['users_attendance'];
$realhour = date_fixed(SITETIME, 'H');
$realminute = date_fixed(SITETIME, 'i');
$totaltime = ($realhour * 60 + $realminute) * 60;
$tomorrow = $timeplus - $totaltime;
$today = $tomorrow - 86400;
if ($attendance < $today) {
DB::run()->query("update `users` set `users_attendance`=? where `users_login`=? limit 1", array($timeplus, $udata['users_login']));
} elseif ($attendance >= $today && $attendance < $tomorrow) {
DB::run()->query("update `users` set `users_money`=`users_money`+?, `users_attendance`=? where `users_login`=? limit 1", array($bonusemoney, $timeplus, $udata['users_login']));
$value = '<img src="' . BASEDIR . 'images/img/balloon.gif" alt="image" /> <b>За регулярное посещение сайта получен бонус!</b><br />';
}
}
return $value;
}
?>