Файл: public_html/element_town_altar.php
Строк: 220
<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }
    $title = 'Город';
    if (readcache('element_user_mesto'.$user['lost_id']) != $title) writecache('element_user_mesto'.$user['lost_id'], $title);
    
    
    if (!$id) {
    $title = 'Город не найден';
    $error1 = '<span class="small">Выбранный Вами город не существует, либо был удален</span>';
    require_once 'element_error_page.php';
    exit;
    }
    
    if ($id != $user['lost_town'] AND $user['lost_privilege'] != 3) {
    $title = 'Доступ закрыт';
    $error1 = '<span class="small">Администрация ограничила доступ к этой странице</span>';
    require_once 'element_error_page.php';
    exit;
    }
    
    $cache_town = cache_town($id);
    
    if (!$cache_town) {
    $title = 'Город не найден';
    $error1 = '<span class="small">Выбранный Вами город не существует, либо был удален</span>';
    require_once 'element_error_page.php';
    exit;
    }
    
    $other_altar_time = (3600 * 12);        // Время активности общего алтаря
    //$other_altar_time = 100;        // Время активности общего алтаря
    $other_altar_cena = 50;                    // Цена активации общего алтаря
    $users_altar_cena = 5;                    // Цена активации личного алтаря
    $users_altar_time = (3600 * 4);            // Время активности личного алтаря
    
    $title = 'Алтарь "'.$cache_town['lost_name'].'"';
    require_once './element_include/element_head.php';
    require_once './element_include/element_header_user_true.php';
    require_once './element_function/element_function_town.php';
        if ($go == 'users_altar') {
            if ($user['lost_town_altar_time'] < time()) {
                if ($user['lost_money_gold'] < $users_altar_cena) $error = 'У Вас нехватает <img src="/images/icons/gold.png">'.($users_altar_cena - $user['lost_money_gold']).' золота<br/><a class="button w50 mt3" href="/payment">Купить золото</a>';
                
                if (!isset($error)) {
                    $user['lost_town_altar_time'] = time() + $users_altar_time;
                    update_money_exp($user, 0, 0, 0, -$users_altar_cena);
                    header('Location: /town/altar?id='.$id);
                    exit;
                } else echo '<div class="nfl p5 mt5 mb5 cntr small mlra red">'.$error.'</div>';
            }
        }
    
        if ($go == 'other') {
            if ($cache_town['lost_altar_time'] < time()) {
                if ($cache_town['lost_treas_gold'] < $other_altar_cena) $error = 'В казне города нехватает <img src="/images/icons/gold.png">'.($other_altar_cena - $cache_town['lost_treas_gold']).' золота<br/><a class="button w50 mt3" href="/town/treas?id='.$id.'">Пополнить казну</a>';
                if ($town_other[0] != 0 AND $town_other[0] != 6) $error = 'Активировать "Благословение города" может только правитель и монах города';
                    
                if (!isset($error)) {
                    $cache_town['lost_altar_time'] = time() + $other_altar_time;
                    $cache_town['lost_treas_gold'] = $cache_town['lost_treas_gold'] - $other_altar_cena;
                    writecache('element_town_id_'.$id,$cache_town);
                    town_list_update($id);
                    header('Location: /town/altar?id='.$id);
                    exit;
                } else echo '<div class="nfl p5 mt5 mb5 cntr small mlra red">'.$error.'</div>';
            }
        }
        
        if ($go == 'up_other') {
            $cena_gold = (($cache_town['lost_altar'] + 1) * 10);
            $cena_crist = (($cache_town['lost_altar'] + 1) * 10000);
            $cena_irrid = (($cache_town['lost_altar'] + 1));
            
            if ($town_other[0] != 0 AND $town_other[0] != 6) $error = 'Строить "Благословение города" могут только правитель и монах города';
            
            if ($cache_town['lost_treas_gold'] < $cena_gold) $error1 = '<img src="/images/icons/gold.png">'.($cena_gold - $cache_town['lost_treas_gold']).' золота';
            if ($cache_town['lost_treas_crist'] < $cena_crist) $error2 = '<img src="/images/icons/cristall.png">'.($cena_crist - $cache_town['lost_treas_crist']).' кристаллов';    
            if ($cache_town['lost_treas_iridiy'] < $cena_irrid) $error3 = '<img src="/images/icons/irridyi.png">'.($cena_irrid - $cache_town['lost_treas_iridiy']).' ирридия';    
            
            if (isset($error1) or isset($error2) or isset($error3)) $error = 'В казне города нехватает '.((isset($error1)) ? $error1.' ' : '').''.((isset($error2)) ? $error2.' ' : '').''.((isset($error3)) ? $error3.' ' : '').' <br/><a class="button w50 mt3" href="/town/treas?id='.$id.'">Пополнить казну</a>';
            
            if ($cache_town['lost_altar'] == $cache_town['lost_level']) $error = 'Уровень города не позволяет повысить алтарь города';
            
            if (!isset($error)) {
                $cache_town['lost_treas_gold'] = $cache_town['lost_treas_gold'] - $cena_gold;
                $cache_town['lost_treas_crist'] = $cache_town['lost_treas_crist'] - $cena_crist;
                $cache_town['lost_treas_iridiy'] = $cache_town['lost_treas_iridiy'] - $cena_irrid;
                $cache_town['lost_altar'] = $cache_town['lost_altar'] + 1;
                writecache('element_town_id_'.$id,$cache_town);
                town_list_update($id);
                header('Location: /town/altar?id='.$id);
                exit;
            } else echo '<div class="nfl p5 mt5 mb5 cntr small mlra red">'.$error.'</div>';
        }
    
    echo '<div class="nfl p5 mt5 mb5 small mlra">';
    echo '<div class="yellow1 mb5 cntr"><a href="/town?id='.$id.'">Вернуться в город</a></div>';
    
        echo '<div class="white mb5 mt5 cntr">';
        echo 'Алтарь города: <span class="lngreen">'.$cache_town['lost_altar'].'%</span><br/>';
        echo 'Казна города: <img src="/images/icons/gold.png"><span class="yellow1">'.nmb_2($cache_town['lost_treas_gold']).'</span>, ';
        echo '<img src="/images/icons/cristall.png"> <span class="yellow1">'.nmb_2($cache_town['lost_treas_crist']).'</span>, ';
        echo '<img src="/images/icons/irridyi.png"> <span class="yellow1">'.nmb_2($cache_town['lost_treas_iridiy']).'</span>';
        echo '</div>';
        
        if ($cache_town['lost_altar'] < $cache_town['lost_level'] AND $town_other[0] == 0 OR $cache_town['lost_altar'] < $cache_town['lost_level'] AND $town_other[0] == 6) {
            echo '<div class="line"></div>';
            echo '<div class="white mt5 mb5 cntr">';
            echo 'Построить алтарь города до <span class="lngreen">'.($cache_town['lost_altar'] + 1).'</span> уровня за <img src="/images/icons/gold.png">'.(($cache_town['lost_altar'] + 1) * 10).' золота, <img src="/images/icons/cristall.png">'.(($cache_town['lost_altar'] + 1) * 10000).' кристаллов, <img src="/images/icons/irridyi.png">'.(($cache_town['lost_altar'] + 1)).' ирридия?';
            echo '<br/><a class="button w50 mt3" href="/town/altar?id='.$id.'&go=up_other">Построить</a><br/>';
            echo '</div>';
        }
        
        // благословение города
        echo '<div class="line"></div>';
        echo '<div class="white mt5 mb5 cntr">';
        echo '<div class="yellow1 mb5 cntr">Благословение города: '.$cache_town['lost_altar'].'%</div>';
        
            if ($cache_town['lost_altar_time'] < time()) {
                echo ($town_other[0] == 0 OR $town_other[0] == 6) ? '<a class="button w80 mb5" href="/town/altar?id='.$id.'&go=other">Активировать за <img src="/images/icons/gold.png">50 на 12 часов</a><br/>' : '';
                echo '<span class="ccc">Не активен. <br/>Активировать алтарь может только правитель и монах города</span>';
            } else {
                $timel = $cache_town['lost_altar_time'] - time();
                $timel = date("Hч. iм. sс.", mktime(0, 0, $timel));
                echo '<span class="lngreen">Алтарь будет активен ещё: '.$timel.'</span>';
            }
            
        echo '</div>';
        
        // Дух алтаря
        echo '<div class="line"></div>';
        echo '<div class="white mt5 mb5 cntr">';
        echo '<div class="yellow1 mb5 cntr">Дар алтаря: '.$cache_town['lost_altar'].'%</div>';
        
            if ($user['lost_town_altar_time'] < time()) {
                echo '<a class="button w80" href="/town/altar?id='.$id.'&go=users_altar">Активировать за <img src="/images/icons/gold.png">5 на 4 часа</a><br/>';
            } else {
                $time2 = $user['lost_town_altar_time'] - time();
                $time2 = date("Hч. iм. sс.", mktime(0, 0, $time2));
                echo '<span class="lngreen">Алтарь будет активен ещё: '.$time2.'</span>';
            }
        
        echo '</div>';
    echo '</div>';
require_once './element_include/element_foot_user_true.php';
?>