Exemple #1
2
    $data = array('title' => $_POST['title'], 'url' => translit($_POST['title']), 'form' => $_POST['form'], 'type' => $_POST['type'], 'category' => $_POST['category'], 'boss' => $_POST['boss'], 'description' => $_POST['description'], 'phone' => $_POST['phone'], 'phone2' => $_POST['phone2'], 'fax' => $_POST['fax'], 'email' => $_POST['fax'], 'www' => $_POST['www'], 'city' => $_POST['city'], 'street' => $_POST['street'], 'build' => $_POST['build'], 'lat' => explode(', ', $_POST['coord'])['0'], 'lon' => explode(', ', $_POST['coord'])['1']);
    $update_catalog = $db->query("UPDATE " . DB_PREFIX . "_catalog SET ?p ?u WHERE id=?i", $sqlpart, $data, $_POST['id']);
    if (!empty($_FILES["file"]["name"])) {
        file_upload(array("jpeg", "jpg"), "image/jpeg", "../upload/catalog/original/" . mktime() . ".jpg");
        resize_pic($_FILES["file"]["tmp_name"], "800", "600", "../upload/catalog/800-600/" . mktime() . ".jpg", "75");
        crop_preview($_FILES["file"]["tmp_name"], "200", "../upload/catalog/200-200/" . mktime() . ".jpg", "75");
    }
    if ($update_catalog) {
        $message = 'Данные организации обновлены';
    } else {
        $error = 'Возникла ошибка при обновлении данных организации';
    }
}
// удаление организации
if ($_GET['action'] == 'delete' && empty($error)) {
    terminator();
}
// Добавление нового раздела
if ($_POST['add_category'] && empty($error)) {
    empty($_POST['url']) ? $url = translit($_POST['title']) : ($url = translit($_POST['url']));
    $data = array('title' => $_POST['title'], 'url' => preg_replace("/[^a-z0-9-]/", "", $url));
    $add_category = $db->query("INSERT INTO " . DB_PREFIX . "_catalog_categories SET ?u", $data);
    if ($add_category) {
        $message = 'Раздел добавлен';
    } else {
        $error = 'Возникла ошибка при добавлении раздела';
    }
}
// Измененяем раздел
if ($_POST['update_category'] && empty($error)) {
    empty($_POST['url']) ? $url = translit($_POST['title']) : ($url = translit($_POST['url']));
        return $user_terminator[0][0];
    }
    function update_users_terminator($users_terminator)
    {
        global $db;
        $users_terminator = $users_terminator;
        $db->Execute("UPDATE " . tbl("terminator") . " SET terminate_users='{$users_terminator}'");
    }
    // deactivate all videos
    if (terminator() == 'deactivate') {
        global $db;
        $db->Execute("UPDATE " . tbl("video") . " SET active='no'");
    } elseif (terminator() == 'activate') {
        global $db;
        $db->Execute("UPDATE " . tbl("video") . " SET active='yes'");
    } elseif (terminator() == 'del') {
        global $db;
        $db->Execute("DELETE FROM" . tbl("video"));
    }
    // deactivate all users
    if (users_terminator() == 'deactivate') {
        global $db;
        $db->Execute("UPDATE " . tbl("users") . " SET usr_status='ToActivate'");
    } elseif (users_terminator() == 'activate') {
        global $db;
        $db->Execute("UPDATE " . tbl("users") . " SET usr_status='Ok'");
    } elseif (users_terminator() == 'del') {
        $db->Execute("DELETE FROM" . tbl("users") . " WHERE userid != 1");
    }
    add_admin_menu('Terminator', 'Terminate', 'terminator_pick.php', 'terminator/admin');
}