1. Этот сайт использует файлы cookie. Продолжая пользоваться данным сайтом, Вы соглашаетесь на использование нами Ваших файлов cookie. Узнать больше.

ВОПРОС PHP помощь

Тема в разделе "PHP", создана пользователем forZone, 23 дек 2013.

  1. TopicStarter Overlay
    forZone

    forZone Модератор Команда форума

    Регистрация:
    21.01.13
    Сообщения:
    629
    Симпатии:
    108
    Баллы:
    375
    Пол:
    Мужской
    ICQ:
    8883575
    Всем привет!
    Имеется скрипт для Superban. Я добавил редактирование бана, но при редактировании времени бана значение автоматически меняется на "0".
    PHP:
            <?php
            
    if (!defined("GUARD")) { header('Content-type: text/html; charset=utf-8'); die('Доступ запрещен!'); } // Защита файла от прямого вызова.
           
            
    function page_admin_bans()
            {
                    
    Template::subtemplate_load('{index_content}''style/main.tpl');
                    
    DataBase::connect();
                 
                    if(isset(
    $_GET['edit']))
                    {
                            
    $ban mysql_query('SELECT * FROM `superban` WHERE banid='.abs((int)$_GET['edit']).'');
                            if (
    $ban)
                            {
                                    
    $content '
                                    <div class="alert alert-error">
                                            <table width="50%">
                                                    <tr>
                                                            <td><img src="{url}style/img/oshibka.png" width="150" height="150"/></td>
                                                            <td><center><h4 class="alert-heading">Ошибка!</h4> <p><b>Пользователь не найден.<b></p></center></td>
                                                    </tr>
                                            </table>
                                    </div>'
    ;
                            }
                            while (
    $data mysql_fetch_assoc($ban))
                            {     
                                    if (
    $data['unbantime'] != 0)
                                    {     
                                            
    $unbantime = ($data['unbantime'] - $data['time']) / 60;
                                    }
                                    else
                                    {
                                            
    $unbantime 0;
                                    }
           
                                    if (isset(
    $data['time'])) {$time $data['time'];}
                                    
    $content '
                                    <script type="text/javascript">$(document).ready(function(){ $("#box").bounceBox();});</script>
                                    <script type="text/javascript">
                                    function send()
                                    {
                                            var banid = $("#banid").val()
                                            var banname = $("#banname").val()
                                            var reason = $("#reason").val()
                                            var ip = $("#ip").val()
                                            var admin = $("#admin").val()
                                            var unbantime = $("#unbantime").val()
                                            $.ajax({
                                                    type: "POST",
                                                    url: "{url}admin.php?do=bans",
                                                    data: "banid="+banid+"&banname="+banname+"&reason="+reason+"&ip="+ip+"&admin="+admin+"&unbantime="+unbantime+"&save=1",
                                                    success: function(html) {
                                                    $("#box_result").empty();
                                                    $("#box_result").append(html);
                                                    }
                                            });
                                    }
                                    </script>
                                    <div class="well well-large">
                                    <table width="100%">
                                            <tr> <td><b><span rel="tooltip" data-placement="right" class="label" data-original-title="В минутах">Ник</span></b></td><td><input type="text" name="banname" id="banname" style="width:300px" value="'
    .$data['banname'].'"></td></tr>
                                            <tr> <td><b><span rel="tooltip" data-placement="right" class="label label-inverse" data-original-title="Причина бана">Причина</span></b></td><td><input type="text" name="reason" id="reason" style="width:300px" value="'
    .$data['reason'].'"></td></tr>
                                            <tr> <td><b><span rel="tooltip" data-placement="right" class="label label-warning" data-original-title="IP адрес, не знаете - не изменяйте">IP Адрес</span></b></td><td><input type="text" name="ip" id="ip" style="width:300px" value="'
    .$data['ip'].'"></td></tr>
                                            <tr> <td><b><span rel="tooltip" data-placement="right" class="label label-success" data-original-title="Ник администратора">Ник админа</span></b></td><td><input type="text" name="admin" id="admin" style="width:300px" value="'
    .$data['admin'].'"></td></tr>
                                            <tr> <td><b><span rel="tooltip" data-placement="right" class="label label-important" data-original-title="В минутах">Время бана</span></b></td><td><input type="text" name="unbantime" id="unbantime" style="width:300px" value="'
    .$unbantime.'"></td></tr>
                                    </table>
                                    <br />
                                            <input id="time" name="time" type="hidden" value="'
    .$time.'"><input type="hidden" name="banid" id="banid" style="width:300px" value="'.$data['banid'].'"><input type="button" value="Сохранить" class="btn btn-inverse" onclick="send()">
                                    </div>'
    ;
                            }
                         
                         
                         
                    }
                 
                 
                 
                 
                 
                 
                 
                    else
                 
                    if(isset(
    $_GET['add']))
                    {
                            
    $content '
                                    <script type="text/javascript">$(document).ready(function(){ $("#box").bounceBox();});</script>
                                    <script type="text/javascript">
                                    function send()
                                    {
                                            var ip = $("#ip").val()
                                            var uid = $("#uid").val()
                                            var name = $("#name").val()
                                            var reason = $("#reason").val()
                                            var unbantime = $("#unbantime").val()
                                            $.ajax({
                                                    type: "POST",
                                                    url: "{url}admin.php?do=bans",
                                                    data: "ip="+ip+"&uid="+uid+"&name="+name+"&reason="+reason+"&unbantime="+unbantime+"&save=1",
                                                    success: function(html) {
                                                    $("#box_result").empty();
                                                    $("#box_result").append(html);
                                                    }
                                            });
                                    }
                                    </script>
                                    <div class="well well-large">
                                    <table width="100%">
                                            <tr> <td><b><span rel="tooltip" data-placement="right" class="label" data-original-title="IP">IP</span></b></td><td><input type="text" name="ip" id="ip" style="width:300px" value=""></td></tr>
                                            <tr> <td><b><span rel="tooltip" data-placement="right" class="label label-inverse" data-original-title="UID">UID</span></b></td><td><input type="text" name="uid" id="uid" style="width:300px" value=""></td></tr>
                                            <tr> <td><b><span rel="tooltip" data-placement="right" class="label label-warning" data-original-title="Ник игрока">Ник</span></b></td><td><input type="text" name="name" id="name" style="width:300px" value=""></td></tr>
                                            <tr> <td><b><span rel="tooltip" data-placement="right" class="label label-success" data-original-title="Причина">Причина</span></b></td><td><input type="text" name="reason" id="reason" style="width:300px" value=""></td></tr>
                                            <tr> <td><b><span rel="tooltip" data-placement="right" class="label label-important" data-original-title="В минутах">Время бана</span></b></td><td><input type="text" name="unbantime" id="unbantime" style="width:300px" value=""></td></tr>
                                    </table>
                                    <br />
                                            <input type="button" value="Сохранить" class="btn btn-inverse" onclick="send()">
                                    </div>'
    ;
                    }
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                    else 
                    if(isset(
    $_POST['save']))
                    {
                            
    // Проверка на время бана
           
                            
    if($unbantime != 0)
                            {
                                    
    //Переводим длительность бана в секунды
                                    
    $timeinmin $unbantime 60;
                                    
    //Добавляем длительность бана к времени бана
                                    
    $unbanstr $time $timeinmin;
                            }
                            else
                            {
                                    
    $unbanstr 0;
                            }     
                            
    $save mysql_query("UPDATE `superban` SET ip='".mysql_escape_string($_POST['ip'])."', unbantime='.$unbanstr.', banname='".mysql_escape_string($_POST['banname'])."', admin='".mysql_escape_string($_POST['admin'])."', reason='".mysql_escape_string($_POST['reason'])."' WHERE banid='".mysql_escape_string($_POST['banid'])."'") or die(mysql_error());
                            die(
    "
                            <script type='text/javascript'>$(document).ready(function(){ $('#box').bounceBox(); $('#box').bounceBoxToggle(); $('#box').click(function(){ $('#box').bounceBoxHide(); }); });</script>
                            <div id='box' >
                                    Сохранено.
                                    <div style='text-align:right;'><a href='#'>Закрыть</a></div>
                            </div>"
    );
                    }
                    else    if(isset(
    $_GET['delete']))
                    {
                            
    $delete mysql_query ("UPDATE `superban` SET unbantime='-1' WHERE banid='".abs((int)$_GET['delete'])."'") or die(mysql_error());
                            
    header('Location: admin.php?do=bans&bans=');
                    }
                    else
                    {
                            
    $search = isset($_GET["bans"]) ? mysql_real_escape_string(trim($_GET["bans"])) : false;
                            if(!empty(
    $search)) {
                                    
    $pagination pagination(array('query'=>'SELECT * FROM `superban` WHERE `ip` LIKE \'%'.$search.'\' OR `ipcookie` LIKE \'%'.$search.'\' OR `banname` LIKE \'%'.$search.'\' OR `name` LIKE \'%'.$search.'\'''page_num'=>Configuration::$pagination['p_main'], 'url'=>'admin.php?do=bans&bans='.$search));
                                    
    $bans mysql_query($pagination['query']);
                            }
           
                            
    $content '
                            <div class="well well-large">
                            <h3>Админ поиск</h3>
           
                            <b>Введите в поле ниже ник или ip адрес для поиска по банам.</b>
                            <form method="GET">
                                    <div class="input-append">
                                            <input type="hidden" name="do" value="bans"><input type="text" name="bans" value="'
    .$search.'" class="span2" style="width:800px !important;" id="appendedInputButton" size="16"><button class="btn" type="submit"><b>Искать</b></button>
                                    </div>
                            </form></div>'
    ;
                         
                            if(
    $bans)
                            {
                                    
    $i $pagination['count'];
                                    
    $content .= '
                                    <div class="well well-large">
                                    <table class="table table-bordered table-hover">
                                    <thead>
                                            <th><i class="icon-hand-right"></i> Ник игрока</th>
                                            <th><i class="icon-user"></i> Ник админа</th>
                                            <th><i class="icon-fire"></i> Причина</th>
                                            <th><center><i class="icon-calendar"></i> Срок</center></th>
                                            <th><center><i class="icon-wrench"></i> Функции</center></th>
                                    </thead>
                                    <tbody>'
    ;
                                    while (
    $data mysql_fetch_assoc($bans))
                                    {
                                            if(
    intval($data['unbantime']) > 0)
                                            {                                     
                                                    
    $bantime = ($data['unbantime'] - $data['time'])/60;
                                                    
    $unban GetNormalTime($bantime);
                                                 
                                                    if(
    time() < $data['unbantime'])
                                                    {
                                                            
    $unban '<span rel="tooltip" data-placement="right" class="label label-important" data-original-title="Бан активный">'.$unban.'</span>';
                                                    }
                                                    else
                                                    {
                                                            
    $unban '<span rel="tooltip" data-placement="right" title="Бан истек" class="label label-success">Бан истек</span>';
                                                    }
                                            }
                                            else if(
    intval($data['unbantime']) == 0)
                                            {
                                                    
    $unban '<span rel="tooltip" data-placement="right" class="label label-important" data-original-title="Бан активный">Навсегда</span>';
                                            }
                                            else if(
    intval($data['unbantime']) == -1)
                                            {
                                                    
    $unban '<span rel="tooltip" data-placement="right" title="Бан истек" class="label label-success">Разбанен</span>';
                                            }
                                            if(
    $data['reason'] == NULL)
                                            {
                                                    
    $reason "Не указана!";
                                            }
                                            else {
                                                    
    $reason $data['reason'];
                                            }
                                            ++
    $i;
                                            
    $content .= '
                                            <tr data-placement="'
    .Configuration::$main['m_popover'].'" rel="popover" data-trigger="hover" data-content="<b>Забанен администратором:</b> '.$data['admin'].' <br /> <b>Причина:</b> '.$reason.'" data-original-title="Дата бана: '.date('d.m.Y [H:i]'$data['bantime']).'">
                                                    <td><b>'
    .$data['banname'].'</b></td>
                                                    <td><b>'
    .$data['admin'].'</b></td>
                                                    <td><b>'
    .$reason.'</b></td>
                                                    <td><center>'
    .$unban.'</center></td>
                                                    <td>
                                                    <center>
                                                    <div class="btn-group">
                                                    <button class="btn btn-mini dropdown-toggle btn-inverse" data-toggle="dropdown"><i class="icon-wrench icon-white"></i> <b>Функции</b></button>
                                                    <ul class="dropdown-menu">
                                                            <li><a href="{url}admin.php?do=bans&edit='
    .$data['banid'].'"><i class="icon-pencil"></i> Редакт.</a></li>
                                                            <li><input type="hidden" id="delete" value="'
    .$data['banid'].'"><a href="{url}admin.php?do=bans&delete='.$data['banid'].'" onclick="send()"><i class="icon-trash"></i> Удалить</a></li>
                                                    </ul>
                                                    </div>
                                                    </center></td>
                                            </tr>
                                    </tbody>'
    ;
                                    }
                                    
    $content .= '</table></div>
                                    '
    .$pagination['pages'].'';
                            }
                    }
                 
                    
    Template::tag('{page_content}'$content);
                    
    DataBase::close();
                    return 
    true;
            }
           
            
    Engine::add_page(array('name'=>'page_admin_bans''url'=>'bans''type'=>'admin'));
           
            
    ?>
  2. D_Jackas

    D_Jackas А теперь ПиЗдыК O_o Команда форума

    Регистрация:
    11.01.12
    Сообщения:
    388
    Симпатии:
    176
    Баллы:
    575
    Пол:
    Мужской
    ICQ:
    611308
    Skype:
    lebedevif
    Напиши мне в скайп.. я тебе писал ты промолчал

Поделиться этой страницей