Вход Регистрация
Файл: vk/admin/group.php
Строк: 110
    <?php 
        
if($_GET['action'] == "delete" && isset($_GET['id'])){
            
$q $db->mysql_qw("SELECT * FROM groups WHERE id = ?;",$_GET['id']);
            if(
mysql_num_rows($q)>0){
                if(isset(
$_POST['delete'])){
                    
$db->mysql_qw("DELETE FROM groups WHERE id = ?;",$_GET['id']);
                    echo 
"
                        <div class='alert alert-success'>
                            <b>Группа успешно удалена!</b>
                        </div>
                    "
;
                }else{
                    echo 
"
                        <center>
                            <b>Вы действительно хотите удалить группу?</b>
                            <form method='post'>
                                <input type='hidden' name='delete' value='1'>
                                <input type='submit' class='btn btn-info' value='Удалить'>
                                <input type='button' class='btn btn-danger' value='Отменить' onClick='window.location.href="
?page=groups&gpage=".$_GET['gpage']."";'>
                            </form>
                        </center>
                    "
;
                }
            }else{
                echo 
"
                    <div class='alert alert-error'>
                        <b>Группа с данным ID не найдена!</b>
                    </div>
                "
;
            }
            exit();
        }
        if(
$_GET['action'] == "edit" && isset($_GET['id'])){
            if(isset(
$_POST['name'])){
                foreach(
$_POST as $key=>$val){
                    if(
$key == "created"){
                        
$val strtotime($val);
                    }
                    
$string .= ",".$key."='".$val."'";
                }
                
$string substr($string1);
                
mysql_query("UPDATE groups SET ".$string." WHERE id = ".$_GET['id'].";");
                echo 
"
                        <div class='alert alert-success'>
                            <b>Группа отредактирована!</b>
                        </div>
                "
;
            }
            
$q $db->mysql_qw("SELECT * FROM groups WHERE id = ?;",$_GET['id']);
            if(
mysql_num_rows($q)>0){
                while(
$val mysql_fetch_assoc($q)){
                    if(
$val['active'] == 1){
                        
$status "
                            <select name='active' class='tselect'>
                                <option value='0'>Остановлено</option>
                                <option value='1' selected>Запущено</option>
                            </select>
                        "
;
                    }else{
                        
$status "
                            <select name='active'>
                                <option value='0' selected>Остановлено</option>
                                <option value='1'>Запущено</option>
                            </select>
                        "
;
                    }
                    
$date date("H:i d.m.Y",$val['created']);
                    echo 
"
                        <form method='post'>
                        <table class='admint'>
                            <tr>
                                <td>Название</td>
                                <td><input type='text' name='name' value='"
.$val['name']."'></td>
                            </tr>
                            <tr>
                                <td>Фото</td>
                                <td><img src='"
.$val['g_photo']."'></td>
                            </tr>
                            <tr>
                                <td>Название группы</td>
                                <td><input type='text' name='g_name' value='"
.$val['g_name']."'></td>
                            </tr>
                            <tr>
                                <td>Владелец</td>
                                <td><input type='text' name='owner' value='"
.$val['owner']."'></td>
                            </tr>
                            <tr>
                                <td>Ссылка</td>
                                <td><input type='text' name='link' value='"
.$val['link']."'></td>
                            </tr>
                            <tr>
                                <td>Нужно вступлений</td>
                                <td><input type='text' name='users' value='"
.$val['users']."'></td>
                            </tr>
                            <tr>
                                <td>Вступило</td>
                                <td><input type='text' name='joined' value='"
.$val['joined']."'></td>
                            </tr>
                            <tr>
                                <td>Создан</td>
                                    <td><input type='text' name='created' value='"
.$date."'></td>
                            </tr>
                            <tr>
                                <td>Статус</td>
                                <td>"
.$status."</td>
                            </tr>                            
                        </table>
                        <br>
                        <input type='submit' class='btn btn-info' value='Сохранить'> <input type='button' class='btn btn-danger' value='Отменить' onClick='window.location.href="
?page=groups&gpage=".$_GET['gpage']."";'>
                        </form>
                    "
;
                }
            }else{
                echo 
"
                    <div class='alert alert-error'>
                        <b>Группа с данным ID не найдена!</b>
                    </div>
                "
;
            }
        }else{
            
$q $db->mysql_qw("SELECT * FROM groups;");
            
$on_page 10;
            
$pages ceil(mysql_num_rows($q) / $on_page);
            if(
$pages == 0){
                echo 
"<center><h3>Не создано ни одной группы</h3></center>";
            }else{
                if(!isset(
$_GET['gpage'])){
                    
$page_now 1;
                }else{
                    
$page_now $_GET['gpage'];
                }
                echo 
"Выберите страницу: ";
                for(
$c=1;$c<=$pages;$c++){
                    if(
$c == $page_now){
                        echo 
"<b>".$c."</b> ";
                    }else{
                        echo 
"<a href='?page=groups&gpage=".$c."'>".$c."</a> ";
                    }
                }
                
$sd $page_now $on_page $on_page;
                echo 
"
                    <table class='admint'>
                        <tr>
                            <td>Название</td>
                            <td>Фото</td>
                            <td>Название группы</td>
                            <td>Владелец</td>
                            <td>Ссылка</td>
                            <td>Нужно вступлений</td>
                            <td>Вступило</td>
                            <td>Создан</td>
                            <td>Статус</td>
                            <td></td>
                        </tr>
                "
;
                
$q $db->mysql_qw("SELECT * FROM groups LIMIT ?,?",$sd$on_page);
                while(
$val mysql_fetch_assoc($q)){
                    
$date date("H:i d.m.Y",$val['created']);
                    if(
$val['active'] == 1){
                        
$status "Активно";
                    }else{
                        
$status "Остановлено";
                    }
                    echo 
"
                        <tr>
                            <td>"
.$val['name']."</td>
                            <td><img src='"
.$val['g_photo']."'></td>
                            <td>"
.$val['g_name']."</td>
                            <td>"
.$val['owner']."</td>
                            <td>"
.$val['link']."</td>
                            <td>"
.$val['users']."</td>
                            <td>"
.$val['joined']."</td>
                            <td>"
.$date."</td>
                            <td>"
.$status."</td>
                            <td>
                                <a href='?page=groups&gpage="
.$page_now."&id=".$val['id']."&action=edit'><img src='http://cdn2.iconfinder.com/data/icons/diagona/icon/16/018.png' class='editt'></a>
                                <a href='?page=groups&gpage="
.$page_now."&id=".$val['id']."&action=delete'><img src='http://cdn2.iconfinder.com/data/icons/diagona/icon/16/101.png' class='deletet'></a>
                            </td>
                        </tr>
                    "
;
                }
                echo 
"</table>";
            }
        }
    
?>
Онлайн: 0
Реклама