Вход Регистрация
Файл: anibiliwar.ru/new_year.php
Строк: 71
<?php

/**
 * New Year mod.
 * @package  Clash of titans by 3kzo
 */

include_once __DIR__ '/system/common.php';
include_once 
__DIR__ '/system/functions.php';
include_once 
__DIR__ '/system/user.php';

if (!
$user) {
    
header("location:/");
    exit;
}

$title 'Подарок';

include_once 
__DIR__ '/system/h.php';

$config = include_once __DIR__ '/system/new_year_config.php';


if (
$config['enabled'] === false) {
    
header("location:/");
    exit;
}

function 
simple_render($tpl,array $args null)
{

    if (
is_array($args)) {
        
extract($args);
    }


    include_once 
__DIR__ '/system/templates/'.$tpl.'.php';


}

function 
can_take($user_id)
{
    global 
$config;

    
$result mysql_query("select time from new_year where user_id = ".(int) abs($user_id)." order by time desc limit 1");
    
$result mysql_fetch_assoc($result);

    
$current_time time();

    
$next_take_aviable $result['time'] + ($config['delay'] * 7200);
    
#s$next_take_aviable = $result['time'];

    
return $current_time $next_take_aviable true  $next_take_aviable;
}

function 
submit()
{
    global 
$user,$config;
    
$rand mt_rand(1,3);

    switch (
$rand) {
        case 
1:
            
$r $config['rewards']['gold'];
            echo 
1;
            
mysql_query("update `users` set `g` = '".($user['g'] + $r['count'])."' where `id` = '".($user['id'])."'")
                or die (
mysql_error());

            break;

        case 
2:
            
$r $config['rewards']['silver'];

            
mysql_query("update `users` set `s` = '".($user['s'] + $r['count'])."' where `id` = '".($user['id'])."'")
                or die (
mysql_error())
            ;

            break;
                case 
4:
            
$r $config['rewards']['metal'];

            
mysql_query("update `users` set `metal` = '".($user['metal'] + $r['count'])."' where `id` = '".($user['id'])."'")
                or die (
mysql_error())
            ;

            break;

        case 
3:
            
$r $config['rewards']['top_item'];

            
$item =     mysql_query("
                    select * from items where skill = 200 order by RAND()
                "
);

            
$item mysql_fetch_assoc($item);

            
$params 200;

            
mysql_query('INSERT INTO `inv` (`user`,
                                                 `item`,
                                                `bonus`,
                                                 `_str`,
                                                 `_vit`,
                                                 `_agi`,
                                                 `_def`) VALUES ("'
.$user['id'].'",
                                                                  "'
.$item['id'].'",
                                                                       "'
.$params.'",
                                                                         "'
.$params.'",
                                                                         "'
.$params.'",
                                                                         "'
.$params.'",
                                                                         "'
.$params.'")') or die (mysql_error());



            break;

    }


    
mysql_query("insert into new_year (user_id,time,secret_name) values ({$user['id']},".time().",'{$r['secret_name']}')");


    
header('location:?refresh='.uniqid());
    exit;
}

if (isset(
$_GET['take'])) {
    return 
submit();
}


simple_render('new_year',[
        
'can_take'    => can_take($user['id'])
    ]);

include_once 
__DIR__ '/system/f.php';
Онлайн: 1
Реклама