Вход Регистрация
Файл: admin/shop.php
Строк: 305
<?php
$title 
'Магазин';
require_once(
$_SERVER["DOCUMENT_ROOT"]."/inc/head.php");
if ((
$adm_id == || $adm_id == || $adm_id == 6) && $sys['modules']['shop'] == 1) {

    switch (
$act) {

        case 
'category':

            if (
$adm_id == 1) {

                echo 
'<div class="title">Категории товаров ('.$count_shop_kat.')</div>';

                
$type 1;
                
$num_u $connect->prepare("select count(*) from `kat` where `type` = ? and `id` = ?");
                
$stmt_count $connect->prepare("select count(*) from `shop` where `kat` = ?"); 
                
$strow $connect->prepare("select * from `kat` where `id` = ?");

                if (isset(
$_GET['edit'])) {
                    
$num_u->execute(array($type$_GET['edit']));
                    if (
$num_u->fetchColumn()) {
                        
$strow->execute(array($_GET['edit']));
                        
$row $strow->fetch();
                        if (isset(
$_POST['cancel'])) {
                            
header('location: /adm/shop/category');
                        }
                        elseif (isset(
$_POST['red'])) {
                            
$error '';
                            if (empty(
$_POST['name'])) {
                                
$error.= 'Введите название!<br/>';
                            }
                            if (
$error) {
                                echo 
'<div class="menu">'.$error.'</div>';
                            } else {
                                
$stmt $connect->prepare("update `kat` set `name` = ? where `id` = ?");
                                if (
$stmt->execute(array($_POST['name'], $_GET['edit']))) {
                                    
header('location: /adm/shop/category');
                                } else {
                                    echo 
'<div class="menu">Произошла ошибка!</div>';
                                }
                            }
                        }
                        echo 
'<div class="menu">
                        <form action="" method="POST">
                        Название:<br/><input type="text" name="name" value="'
.$row['name'].'"><br/>
                        <input type="submit" name="red" value="Сохранить ('
.intval($_GET['edit']).')">
                        <input type="submit" name="cancel" value="Отмена">
                        </form></div>'
;
                    } else {
                        
header('location: /adm/shop/category');
                    }
                }
                elseif (isset(
$_GET['del'])) {
                    
$num_u->execute(array($type$_GET['del']));
                    
$stmt_count->execute(array($_GET['del']));
                    if (
$num_u->fetchColumn() && !$stmt_count->fetchColumn()) {
                        if (isset(
$_POST['yes'])) {
                            
$stmt $connect->prepare("delete from `kat` where `id` = ?");
                            if (
$stmt->execute(array($_GET['del']))) {
                                
header('location: /adm/shop/category');
                            } else {
                                echo 
'<div class="menu">Произошла ошибка!</div>';
                            }
                        }
                        elseif (isset(
$_POST['no'])) {
                            
header('location: /adm/shop/category');
                        }

                        echo 
'<div class="menu">
                        <form action="" method="POST">
                        <input type="submit" name="yes" value="Удалить ('
.intval($_GET['del']).')"/> 
                        <input type="submit" name="no" value="Отмена"/>
                        </form></div>'
;
                    } else {
                        
header('location: /adm/shop/category');
                    }
                }
 
                if (
$count_shop_kat == 0) {
                    echo 
'<div class="menu">Категорий нет!</div>';
                } else {

                    
$page = new Pagination($count_shop_kat10);

                    
$data $connect->prepare("select * from `kat` where `type` = :type order by `id` desc limit :start, 10");
                    
$data->bindValue(':type'$typePDO::PARAM_INT);
                    
$data->bindValue(':start'$page->startPDO::PARAM_INT);
                    
$data->execute();
                    
$sql $data->fetchAll();

                    foreach (
$sql as $row) {

                        
$stmt_count->execute(array($row['id']));
                        
$count $stmt_count->fetchColumn();

                        echo 
'<div class="menu">
                        <div class="forlink wa-bottom"><a href="/shop/category/'
.$row['id'].'" class="links"><img src="/img/folder.png" alt="folder">'.$row['name'].'</a></div>
                        Товаров в магазине: '
.$count.'
                        <div class="butt2">
                        '
.(!$count '<a href="?del='.$row['id'].'">Удалить</a>' '').'
                        <a href="?edit='
.$row['id'].'">Редактировать</a>
                        </div>
                        </div>'
;

                    }

                    
$page->navigation();

                }

                echo 
'<div class="title">Новая категория</div>';

                if (isset(
$_POST['submit'])) {
                    
$error '';
                    if (empty(
$_POST['name'])) {
                        
$error.= 'Введите название!<br/>';
                    }
                    if (
$error) {
                        echo 
'<div class="menu">'.$error.'</div>';
                    } else {
                        
$stmt $connect->prepare("insert into `kat` set `type` = ?, `name` = ?");
                        if (
$stmt->execute(array($type$_POST['name']))) {
                            
header('location: /adm/shop/category'); 
                        } else {
                            echo 
'<div class="menu">Произошла ошибка!</div>';
                        }
                    }
                }
                echo 
'<div class="menu">
                <form action="" method="POST">
                Название:<br/><input type="text" name="name"><br/>
                <input type="submit" name="submit" value="Добавить">
                </form></div>'
;

                echo 
'<div class="forlink"><a href="/adm/shop" class="links"><img src="/img/shop.png" alt="shop">Магазин</a></div>';

            } else {
                
header('Location: /adm/shop');
            }

            break;

        default:

            if (
$adm_id == 1) {

                echo 
'<div class="title">Настройки</div>';

                if (isset(
$_POST['settings'])) {
 
                    
$error '';

                    if (empty(
$_POST['shop_prefix'])) {
                        
$error.= 'Введите префикс к файлам товаров!<br/>';
                    }
                    if (empty(
$_POST['sdays'])) {
                        
$error.= 'Укажите период обработки платежей!<br/>';
                    }
                    if (empty(
$_POST['shop_text_s'])) {
                        
$error.= 'Укажите количество символов в описании товара к ссылке!<br/>';
                    }
                    elseif (
$_POST['shop_text_s'] < 10) {
                        
$error.= 'Количество символов в описании товара к ссылке должно быть больше 10!<br/>';
                    }
                    if (empty(
$_POST['wscr'])) {
                        
$error.= 'Укажите размер превью скриншота!<br/>';
                    }
                    elseif (!
sizeConv($_POST['wscr'])) {
                        
$error.= 'Неверный формат размера превью скриншота: вводить нужно в формате ШИРИНАxВЫСОТА!<br/>';
                    }
                    if (empty(
$_POST['icon_wscr'])) {
                        
$error.= 'Укажите размер иконки товара!<br/>';
                    }
                    elseif (!
sizeConv($_POST['icon_wscr'])) {
                        
$error.= 'Неверный формат размера иконки товара: вводить нужно в формате ШИРИНАxВЫСОТА!<br/>';
                    }
                    if (empty(
$_POST['shop_attach'])) {
                        
$error.= 'Укажите максимальное количество скриншотов!<br/>';
                    }
                    if (empty(
$_POST['stags'])) {
                        
$error.= 'Укажите максимальное количество тегов!<br/>';
                    }
                    if (empty(
$_POST['scena'])) {
                        
$error.= 'Укажите минимальную стоимость товара!<br/>';
                    }
                    elseif (
$_POST['scena'] < 1) {
                        
$error.= 'Минимальная стоимость товара не может быть меньше 1!<br/>';
                    }
                    if (
$error) {
                        echo 
'<div class="menu">'.$error.'</div>';
                    } else {

                        
$sys['system']['wscr'] = $_POST['wscr'];
                        
$sys['system']['icon_wscr'] = $_POST['icon_wscr'];
                        
$sys['system']['shop_prefix'] = str2url($_POST['shop_prefix']);
                        
$sys['system']['sdays'] = ceil(abs($_POST['sdays']));
                        
$sys['system']['shop_attach'] = ceil(abs($_POST['shop_attach']));
                        
$sys['system']['stags'] = ceil(abs($_POST['stags']));
                        
$sys['system']['scena'] = floatval(abs($_POST['scena']));
                        
$sys['system']['shop_text_s'] = ceil(abs($_POST['shop_text_s']));
                        
$sys['modules']['mod_p'] = intval($_POST['mod_p']);
                        
$sys['modules']['shop_free'] = intval($_POST['shop_free']);
                        
$sys['modules']['wmid_buy'] = intval($_POST['wmid_buy']);
                        
$sys['modules']['wmid_sell'] = intval($_POST['wmid_sell']);

                        
write_ini_file(FILE_CONFIG$sys);

                        
header('Location: /adm/shop');

                    }

                }

                echo 
'<div class="menu">
                <form action="" method="POST">
                Автомодерация товаров:<br/><select name="mod_p"><option value="1">Вкл.</option><option '
.($sys['modules']['mod_p'] == 'selected' '').' value="3">Откл.</option></select><br/>
                Возможность загружать бесплатное:<br/><select name="shop_free"><option value="1">Вкл.</option><option '
.($sys['modules']['shop_free'] == 'selected' '').' value="0">Откл.</option></select><br/>
                Подтверждение WMID для продавцов:<br/><select name="wmid_sell"><option value="1">Вкл.</option><option '
.($sys['modules']['wmid_sell'] == 'selected' '').' value="0">Откл.</option></select><br/>
                Подтверждение WMID для покупателей:<br/><select name="wmid_buy"><option value="1">Вкл.</option><option '
.($sys['modules']['wmid_buy'] == 'selected' '').' value="0">Откл.</option></select><br/>
                Префикс к файлам товаров:<br/><input type="text" name="shop_prefix" value="'
.$sys['system']['shop_prefix'].'"><br/>
                Период обработки платежей (В днях):<br/><input type="text" name="sdays" value="'
.$sys['system']['sdays'].'"><br/>
                Символов в описании товара к ссылке:<br/><input type="text" name="shop_text_s" value="'
.$sys['system']['shop_text_s'].'"><br/>
                Размер превью скриншота:<br/><input type="text" name="wscr" value="'
.$sys['system']['wscr'].'"><br/>
                Размер иконки товара:<br/><input type="text" name="icon_wscr" value="'
.$sys['system']['icon_wscr'].'"><br/>
                Максимальное количество скриншотов:<br/><input type="text" name="shop_attach" value="'
.$sys['system']['shop_attach'].'"><br/>
                Максимальное количество тегов:<br/><input type="text" name="stags" value="'
.$sys['system']['stags'].'"><br/>
                Минимальная стоимость товара:<br/><input type="text" name="scena" value="'
.$sys['system']['scena'].'"><br/>
                <input type="submit" name="settings" value="Сохранить">
                </form></div>'
;

                echo 
'<div class="forlink"><a href="/adm/shop/category" class="links"><img src="/img/folder.png" alt="folder">Категории товаров<div class="chi">'.$count_shop_kat.'</div></a></div>';

            }

            echo 
'<div class="title">Магазин ('.$count_shop $new_mod_shop.')</div> 
            <div class="menu">
            <form action="" method="GET">
            <input type="text" name="search" value="'
.$search.'">
            <input type="submit" value="Поиск">
            </form></div>'
;

            
$stmt_num $connect->prepare("select count(*) from `shop` where `id` = ?");
            
$strow $connect->prepare("select * from `shop` where `id` = ?");

            if (
$adm_id == 1) {
                if (isset(
$_GET['del'])) {
                    
$stmt_num->execute(array($_GET['del']));
                    if (!
$stmt_num->fetchColumn()) {
                        
header('Location: /adm/shop');
                    } else {
                        
// платежи
                        
$stmt_p $connect->prepare("select count(*) from `purchase` where `status` != '1' and `pid` = ?");
                        
$stmt_p->execute(array($_GET['del']));
                        
// покупки
                        
$stmt_purch $connect->prepare("select count(*) from `purchase` where `pid` = ?");
                        
$stmt_purch->execute(array($_GET['del']));

                        if (!
$stmt_p->fetchColumn()) {

                            
// Файл
                            
$fileshop GlobFiles::findById($_GET['del'], GlobFiles::FileShop);

                            if (isset(
$_POST['cancel'])) {
                                
header('Location: /adm/shop');
                            }
                            elseif (isset(
$_POST['del'])) {

                                
$del_shop $connect->prepare("delete from `shop` where `id` = ?");
                                
$del_basket $connect->prepare("delete from `basket` where `pid` = ?");
                                
$del_dis $connect->prepare("delete from `discounts` where `pid` = ?");

                                if (
$del_shop->execute(array($_GET['del'])) &&
                                    
$del_basket->execute(array($_GET['del'])) &&
                                    
$del_dis->execute(array($_GET['del'])) &&
                                    
$del_downloads->execute(array($_GET['del'], 1)) &&
                                    
Comments::DelMess($_GET['del'], 2) &&
                                    (new 
Respect($_GET['del'], 1))->removeLikes()) {

                                    
/* Чистим мусор */

                                    
GlobFiles::DelAllById($_GET['del'], GlobFiles::FilesGlobFiles::MaskScreen);

                                    
// Удаляем файл
                                    
if (!$stmt_purch->fetchColumn() && $fileshop)
                                        
unlink($fileshop);

                                    
$icon GlobFiles::findById($_GET['del'], GlobFiles::FilesGlobFiles::MaskShopIcon);

                                    if (
$icon)
                                        
unlink($icon);

                                    
header('Location: /adm/shop');

                                } else {
                                    echo 
'<div class="menu">Произошла ошибка!</div>';
                                }
                            }
                            echo 
'<div class="menu">
                            <form action="" method="POST">
                            <input type="submit" name="del" value="Удалить товар ('
.intval($_GET['del']).')">
                            <input type="submit" name="cancel" value="Отмена">
                            </form></div>'
;
                        } else {
                            
header('Location: /adm/shop');
                        }
                    }
                }
            }

            if (isset(
$_GET['ban'])) {
                
$stmt_num->execute(array($_GET['ban']));
                if (!
$stmt_num->fetchColumn()) {
                    
header('Location: /adm/shop');
                } else {
                    
$strow->execute(array($_GET['ban']));
                    
$row $strow->fetch();
                    if (isset(
$_POST['cancel'])) {
                        
header('Location: /adm/shop');
                    }
                    elseif (isset(
$_POST['done']) || isset($_POST['block'])) {
                        
$status = isset($_POST['block']) ? 1;
                        
$message = !empty($_POST['message']) ? '[br]Примечание: '.$_POST['message'] : '';
                        
$stmt $connect->prepare("update `shop` set `time` = ?, `status` = ? where `id` = ?");
                        if (
$stmt->execute(array(time(), $status$_GET['ban']))) {
                            if (
$row['seller'] != $user['id'])
                                
notification('Ваш товар [url='.ROOT.'/shop/product/'.$row['id'].']'.$row['name'].'[/url] '.($status == '[color=green]одобрен[/color]' '[color=red]не одобрен[/color]').' для участия в продажах.'.$message$row['seller']);
                            
header('Location: /adm/shop');
                        } else {
                            echo 
'<div class="menu">Произошла ошибка!</div>';
                        }
                    }
                    echo 
'<div class="menu">
                    <form action="" method="POST">
                    ID: '
.intval($_GET['ban']).'<hr/>
                    Примечание:<br/><textarea name="message"></textarea><br/>
                    '
.($row['status'] != '<input type="submit" name="done" value="Одобрить">' '').
                      (
$row['status'] != '<input type="submit" name="block" value="Запретить продажу">' '').'
                    <input type="submit" name="cancel" value="Отмена">
                    </form></div>'
;
                }
            }

            
$keywords $search preg_replace("/[s,]+/""|"$search) : RS_ALL_CHARS;

            
$stmt_num $connect->prepare("select count(*) from `shop` where `text` rlike :keywords or `name` rlike :keywords or `seller` rlike :keywords");
            
$stmt_num->bindValue(':keywords'$keywords);
            
$stmt_num->execute();
            
$count_res $stmt_num->fetchColumn();

            if (
$count_res == 0) {
                echo 
'<div class="menu">NONE</div>';
            } else {

                
$page = new Pagination($count_res10);

                if (
$search) {

                    
$page->setLink('?search=' $search '&');

                    echo 
'<div class="menu">Найдено по запросу: '.$count_res.'</div>';

                }

                
$data $connect->prepare("select * from `shop` where `text` rlike :keywords or `name` rlike :keywords or `seller` rlike :keywords order by `status` desc, `id` desc limit :start, 10");
                
$data->bindValue(':keywords'$keywords);
                
$data->bindValue(':start'$page->startPDO::PARAM_INT);
                
$data->execute();
                
$sql $data->fetchAll();

                foreach (
$sql as $row) {

                    echo 
'<div class="menu">
                    <div class="forlink wa-bottom"><a href="/shop/product/'
.$row['id'].'" class="links"><img src="/img/product.png" alt="product">'.$row['name'].'</a></div>
                    ID: '
.$row['id'].'<br/>
                    Автор: '
.profileLink($row['seller']).'<br/>
                    Стоимость: '
.($row['free'] == 'бесплатно' rub($row['cena'])).'
                    '
.($row['status'] == '<div class="information">На модерации!</div>' : ($row['status'] == '<div class="forbidden">Товар не одобрен!</div>' '<div class="good">Товар одобрен!</div>')).'
                    <div class="butt2">
                    '
.($adm_id == '<a href="?del='.$row['id'].'">Удалить</a>' '').'
                    <a href="?ban='
.$row['id'].'">Модерация</a>
                    </div>
                    </div>'
;

                }

                
$page->navigation();

            }

    }

} else {
    
header('location: /');
}

require(
$_SERVER["DOCUMENT_ROOT"]."/inc/foot.php");
?>
Онлайн: 1
Реклама