本文整理汇总了PHP中SafeMySQL::query方法的典型用法代码示例。如果您正苦于以下问题:PHP SafeMySQL::query方法的具体用法?PHP SafeMySQL::query怎么用?PHP SafeMySQL::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SafeMySQL
的用法示例。
在下文中一共展示了SafeMySQL::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
function delete()
{
$pid = isset($_POST['id']) ? $_POST['id'] : '0';
$configuration = new Config();
$database = new SafeMySQL(array('user' => $configuration->db->username, 'pass' => $configuration->db->password, 'db' => $configuration->db->database, 'charset' => $configuration->db->charset));
$sql = "DELETE FROM students WHERE id=?i";
$action = $database->query($sql, $pid);
if (@$action) {
$response = new Response();
$response->setContent(200);
$response->send();
}
}
示例2: array
<?php
require '../php/main/db_connect.php';
require 'mm/parser.php';
$arr = array();
if (isset($user_id, $category)) {
$string_object = new SafeMySQL();
$writer = new Writer();
$y = $string_object->getRow("SELECT d_id, other_id, pioneer_id,meter FROM users_dialogs WHERE d_id=?i AND pioneer_id=?i OR d_id=?i AND other_id=?i LIMIT 1", $category, $user_id, $category, $user_id);
if ($y['meter'] !== $user_id) {
$string_object->query('UPDATE users_dialogs SET meter=0 WHERE d_id=?i', $id_page);
}
if ($y['d_id']) {
$dg = $string_object->getAll("SELECT m.text, m.date, m.mes_id, i.avatar, i.category, i.nickname FROM users_messages m, users_information i WHERE m.d_id=?i AND i.user_id = m.user_id ORDER BY m.mes_id DESC LIMIT 10", $y['d_id']);
$avatar = $string_object->getOne('SELECT avatar FROM users_information WHERE user_id=?i', $user_id);
$avatar = file_exists('../upload_image/avatars/pre_150px/' . $avatar . '.jpg') ? $avatar : 'default';
//Если диалогов нет
if ($dg) {
$i = 0;
foreach ($dg as $array) {
$avatar_other = file_exists('../upload_image/avatars/pre_150px/' . $array['avatar'] . '.jpg') ? $array['avatar'] : 'default';
$res = array('n0' => $y['d_id'], 'n1' => $array['mes_id'], 'n2' => $avatar_other, 'n3' => $array['nickname'], 'n4' => $array['date'], 'n5' => $writer->main($array['text'], 1));
if (!$i) {
$res = array('head' => '<nav id="content_menu">
<a href="mm=dialogs" class="new_local"><p>ДИАЛОГИ</p></a>
</nav>
<section id="message_input">
<div id="message_input_center">
<div id="user" style="background: #000 no-repeat center url(upload_image/avatars/pre_150px/' . $avatar . '.jpg);">
</div>
<div id="text" contenteditable="true"></div>
示例3: SafeMySQL
<?php
require_once '../../php/main/db_connect.php';
if ($user_id) {
$r = new SafeMySQL();
date_default_timezone_set('Europe/London');
$date = date('Y-m-d H:i:s');
$r->query("UPDATE users_online SET online='offline' WHERE user_id=?i LIMIT 1", $user_id);
$r->query("UPDATE users_online SET date=?s WHERE user_id=?i LIMIT 1", $date, $user_id);
setcookie('RememberMe', $password, time() + 3600 * 24 * 365, '/');
setcookie('email', $email, time() + 3600 * 24 * 365, '/');
unset($_SESSION['password'], $_SESSION['email']);
print 'success';
} else {
print 'error';
}
示例4: SafeMySQL
<?php
ini_set('display_errors', 1);
include 'mysql.php';
$db = new SafeMySQL();
$posts = json_decode(file_get_contents('https://api.vk.com/method/wall.get?owner_id=-99252033&count=30&filter=owner'));
print_r($posts);
for ($i = 1; $i < 25; $i++) {
if ($i == 1) {
$toBase['is_pinned'] = 1;
} else {
$toBase['is_pinned'] = 0;
}
$toBase['text'] = substr($posts->response[$i]->text, 0, strpos($posts->response[$i]->text, ' ', 240));
$toBase['img'] = $posts->response[$i]->attachment->photo->src_big;
$toBase['link'] = 'wall-99252033_' . $posts->response[$i]->id;
$toBase['reposts_count'] = $posts->response[$i]->reposts->count;
$test = trim($toBase['text']);
if (empty($test) or $posts->response[$i]->post_type == 'copy') {
continue;
} else {
//если закреплённый пост не пуст(нет бана) удаляем старый
if ($i == 1) {
$db->query("DELETE FROM posts WHERE is_pinned = '1'");
}
}
$is = $db->getRow("SELECT * FROM posts WHERE text = ?s OR img = ?s", $toBase['text'], $toBase['img']);
if (!$is) {
$db->query("INSERT INTO posts SET ?u", $toBase);
}
}
示例5: fclose
fclose($fop);
$message = 'Настройки обновлены';
} else {
$error = 'Возникла ошибка при обновлении настроек';
}
}
// Добавление организации
if ($_POST['add']) {
$filename = mktime() . '.jpg';
$data = array('title' => $_POST['title'], 'url' => translit($_POST['title']), 'form' => $_POST['form'], 'type' => $_POST['type'], 'category' => $_POST['category'], 'boss' => $_POST['boss'], 'description' => $_POST['description'], 'file' => $filename, 'phone' => $_POST['phone'], 'phone2' => $_POST['phone2'], 'fax' => $_POST['fax'], 'email' => $_POST['email'], 'www' => $_POST['www'], 'city' => $_POST['city'], 'street' => $_POST['street'], 'build' => $_POST['build'], 'lat' => explode(', ', $_POST['coord'])['0'], 'lon' => explode(', ', $_POST['coord'])['1']);
if (!empty($_FILES["file"]["name"])) {
file_upload(array("jpeg", "jpg"), "image/jpeg", "../upload/catalog/original/" . $filename);
resize_pic($_FILES["file"]["tmp_name"], "800", "600", "../upload/catalog/800-600/" . $filename);
crop_preview($_FILES["file"]["tmp_name"], "200", "../upload/catalog/200-200/" . $filename);
}
$add_catalog = $db->query("INSERT INTO " . DB_PREFIX . "_catalog SET ?u", $data);
if ($add_catalog && $_FILES["file"]["error"] == 0) {
$message = 'Организация добавлена';
} else {
$error = 'Возникла ошибка при добавлении организации';
}
}
// Изменение организации
if ($_POST['update']) {
$filename = mktime() . '.jpg';
$sqlpart = '';
if (!empty($_FILES["file"]["name"])) {
$sqlpart = $db->parse(" file='" . $filename . "',");
}
$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']);
示例6: demo
demo (Ajar tree)</a>] [<a href="dbtree_visual_demo.php?mode=branch">Visual demo (Branch)</a>]
<?php
require_once '../safemysql.class.php';
require_once '../DbTree.class.php';
require_once '../DbTreeExt.class.php';
// Data base connect
$dsn['user'] = 'root';
$dsn['pass'] = '';
$dsn['host'] = 'localhost';
$dsn['db'] = 'sesmikcms';
$dsn['charset'] = 'utf8';
$dsn['errmode'] = 'exception';
define('DEBUG_MODE', false);
$db = new SafeMySQL($dsn);
$sql = 'SET NAMES utf8';
$db->query($sql);
$tree_params = array('table' => 'test_sections', 'id' => 'section_id', 'left' => 'section_left', 'right' => 'section_right', 'level' => 'section_level');
$dbtree = new DbTreeExt($tree_params, $db);
/* ------------------------ MOVE ------------------------ */
/* ------------------------ MOVE 2 ------------------------ */
// Method 2: Assigns a node with all its children to another parent.
if (!empty($_GET['action']) && 'move_2' == $_GET['action']) {
// Move node ($_GET['section_id']) and its children to new parent ($_POST['section2_id'])
$dbtree->MoveAll((int) $_GET['section_id'], (int) $_POST['section2_id']);
header('Location:dbtree_demo.php');
exit;
}
/* ------------------------ MOVE 1 ------------------------ */
// Method 1: Swapping nodes within the same level and limits of one parent with all its children.
if (!empty($_GET['action']) && 'move_1' == $_GET['action']) {
// Change node ($_GET['section_id']) position and all its childrens to
示例7: registr
public function registr()
{
if ($_POST['login']) {
$login = $_POST['login'];
}
if ($_POST['name']) {
$name = $_POST['name'];
}
if ($_POST['password']) {
$password = $_POST['password'];
}
if ($_POST['password2']) {
$password2 = $_POST['password2'];
}
$img = new ImgInspector();
if (!empty($_FILES['avatar']['name'])) {
$tmp_name = $_FILES['avatar']['tmp_name'];
$avatar = $_FILES['avatar']['name'];
} else {
$avatar = "";
}
$login = trim($login);
$name = trim($name);
$password = trim($password);
$password2 = trim($password2);
//Проверка введенных данных
if ($this->checkUser($login)) {
$content['message'] = "Пользователь с таким именем уже существует.";
$content['redirect'] = "Пожалуйста, вернитесь <a href='javascript:history.back(1)'>назад</a> и повторите попытку.";
$content['class'] = "logintake";
} elseif (!preg_match("/^[a-zA-Z0-9_]{4,16}\$/", $login)) {
$content['message'] = "Поле <b>Логин</b> должно состоять только из букв латинского алфавита, цифр, нижнего подчеркивания, быть не короче 4 и не длиннее 16 символов.";
$content['redirect'] = "Пожалуйста, вернитесь <a href='javascript:history.back(1)'>назад</a> и повторите попытку.";
$content['class'] = "login";
} elseif (empty($login)) {
$content['message'] = "Поле <b>Логин</b> обязательно для заполнения.";
$content['redirect'] = "Пожалуйста, вернитесь <a href='javascript:history.back(1)'>назад</a> и повторите попытку.";
$content['class'] = "login";
} elseif (empty($name)) {
$content['message'] = "Поле <b>Имя</b> обязательно для заполнения.";
$content['redirect'] = "Пожалуйста, вернитесь <a href='javascript:history.back(1)'>назад</a> и повторите попытку.";
$content['class'] = "name";
} elseif (!preg_match("/^[A-Za-zА-Яа-я]+/", $name)) {
$content['message'] = "Поле <b>Имя</b> должно состоять только из латинских букв и кирилицы, быть не короче 5 и не длиннее 50 символов <br> <em>Например: Иван Васильевич</em>.";
$content['redirect'] = "Пожалуйста, вернитесь <a href='javascript:history.back(1)'>назад</a> и повторите попытку.";
$content['class'] = "name";
} elseif (empty($password)) {
$content['message'] = "Поле <b>Пароль</b> обязательно для заполнения.";
$content['redirect'] = "Пожалуйста, вернитесь <a href='javascript:history.back(1)'>назад</a> и повторите попытку.";
$content['class'] = "password";
} elseif (empty($password2)) {
$content['message'] = "Пожалуйста введите <b>Пароль</b> дважды.";
$content['redirect'] = "Пожалуйста, вернитесь <a href='javascript:history.back(1)'>назад</a> и повторите попытку.";
$content['class'] = "password2";
} elseif ($password != $password2) {
$content['message'] = "<b>Пароли</b> не совпадают.";
$content['redirect'] = "Пожалуйста, вернитесь <a href='javascript:history.back(1)'>назад</a> и повторите попытку.";
$content['class'] = "password2";
} elseif ($img->check_ext($avatar)) {
$content['message'] = "Неверный формат файла. Доступные форматы: *.jpg, *.png ";
$content['redirect'] = "Пожалуйста, вернитесь <a href='javascript:history.back(1)'>назад</a> и повторите попытку.";
$content['class'] = "error-ext";
} else {
if (!empty($avatar)) {
$img->move_to_tmp($tmp_name, $avatar, TMP_PATH);
$img->load(TMP_PATH . $avatar);
$img->resize(80, 80);
$img->save(IMG_PATH . $avatar);
$img->delete_to_tmp($avatar, TMP_PATH);
}
$password = md5(md5($password));
$code = $this->generateCode(10);
setcookie("user_hash", $code, time() + 3600);
$db = new SafeMySQL();
$data = array('login' => $login, 'name' => $name, 'password' => $password, 'avatar' => $avatar, 'user_hash' => $code);
$sql = "INSERT INTO users SET ?u";
$db->query($sql, $data);
$content['message'] = "Поздравляем, вы успешно зарегистрированы.";
$content['redirect'] = "Теперь вы можете <a class='btn btn-success' href='/user'>Bойти в свой кабинет <i class='fa fa-sign-in'></i></a> ";
$content['class'] = "final";
}
$this->view('check', $content);
}
示例8: SafeMySQL
include MLS_ROOT . "/lib/users.class.php";
include MLS_ROOT . "/lib/presets.class.php";
include MLS_ROOT . "/lib/options.class.php";
$db = new SafeMySQL(array('host' => $set->db_host, 'user' => $set->db_user, 'pass' => $set->db_pass, 'db' => $set->db_name));
if (!($db_set = $db->getRow("SELECT * FROM `" . MLS_PREFIX . "settings` LIMIT 1"))) {
// if we have no data in db we need to run the install.php
header("Location: install.php");
exit;
}
// we grab the settings and we merge them into $set
$set = (object) array_merge((array) $set, (array) $db_set);
$presets = new presets();
$user = new User($db);
$options = new Options();
// we check for cookies to autologin
if (!$user->islg() && isset($_COOKIE['user']) && isset($_COOKIE['pass'])) {
if ($usr = $db->getRow("SELECT `userid` FROM `" . MLS_PREFIX . "users` WHERE `username` = ?s AND `password` = ?s", $_COOKIE['user'], $_COOKIE['pass'])) {
$_SESSION['user'] = $usr->userid;
$user = new User($db);
}
} else {
$time = time();
if (!isset($_SESSION['last_log'])) {
$_SESSION['last_log'] = 0;
}
if ($_SESSION['last_log'] < $time - 60 * 2) {
// we update the db if more then 2 minutes passed since the last update
$db->query("UPDATE `" . MLS_PREFIX . "users` SET `lastactive` = '" . $time . "' WHERE `userid`='" . $user->data->userid . "'");
$_SESSION['last_log'] = $time;
}
}
示例9: users
exit;
}
//Данных нет, отлично, ищем в таблице регистрации
if ($x['password'] == $_SESSION['registration_password'] && $x['email'] == $_SESSION['registration_email']) {
//Создаем транзакцию, чтобы данные попали во все нужны таблицы
$load = $o->transactionQuery();
mysqli_autocommit($load, false);
$t1 = mysqli_query($load, $o->parse("INSERT INTO users (email,password) VALUES (?s,?s)", $x['email'], $x['password']));
mysqli_query($load, $o->parse("SET @lastID := LAST_INSERT_ID();"));
$t2 = mysqli_query($load, $o->parse("INSERT INTO users_information (user_id,nickname,category) VALUES (@lastID,?s,?s)", $x['nickname'], $x['category']));
$t3 = mysqli_query($load, $o->parse("INSERT INTO users_online (user_id,online) VALUES (@lastID,'offline')"));
if ($t1 && $t2 && $t3) {
mysqli_commit($load);
$res = array('head' => '<div id="none"><p>Вы зарегистрированы! Теперь можно попробовать войти на сайт.</p></div>');
array_push($arr, $res);
$o->query("DELETE FROM users_registration WHERE key_reg=?s", $category);
unset($_SESSION['registration_email'], $_SESSION['registration_password'], $key_reg);
} else {
mysqli_rollback($load);
$res = array('head' => '<div id="material_null">
<p>Что-то пошло не так.</p>
</div>');
array_push($arr, $res);
}
mysqli_close($load);
} else {
$res = array('head' => '<div id="material_null">
<p>Данные не сошлись.</p>
</div>');
array_push($arr, $res);
}
示例10: SafeMySQL
<?php
require_once '../../php/main/SafeMySQL.php';
$string_object = new SafeMySQL();
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
$password = md5(filter_input(INPUT_POST, 'password'));
if (isset($email, $password)) {
$login_query = $string_object->getOne("SELECT user_id FROM users WHERE email=?s AND password=?s LIMIT 1", $email, $password);
if ($login_query) {
setcookie('RememberMe', $password, time() + 3600 * 24 * 365, '/');
setcookie('email', $email, time() + 3600 * 24 * 365, '/');
$string_object->query("UPDATE users_online SET online='online' WHERE user_id=?i", $login_query['user_id']);
print 'success';
} else {
print 'Вы не зарегитрированы.';
}
} else {
print 'Вы не заполнили нужные формы.';
}
示例11: int
EEE;
// add the data to the file
if (!file_put_contents('inc/settings.php', $data)) {
$page->error = "There is an error with inc/settings.php make sure it is writable.";
}
$sqls[] = "\n CREATE TABLE IF NOT EXISTS `" . $prefix . "banned` (\n `userid` int(11) NOT NULL,\n `until` int(11) NOT NULL,\n `by` int(11) NOT NULL,\n `reason` varchar(255) NOT NULL,\n UNIQUE KEY `userid` (`userid`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$sqls[] = "\n CREATE TABLE IF NOT EXISTS `" . $prefix . "groups` (\n `groupid` int(11) NOT NULL AUTO_INCREMENT,\n `name` varchar(255) NOT NULL,\n `type` int(11) NOT NULL,\n `priority` int(11) NOT NULL,\n `color` varchar(50) NOT NULL,\n `canban` int(11) NOT NULL,\n `canhideavt` int(11) NOT NULL,\n `canedit` int(11) NOT NULL,\n PRIMARY KEY (`groupid`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n";
$sqls[] = "\n INSERT INTO `" . $prefix . "groups` (`groupid`, `name`, `type`, `priority`, `color`, `canban`, `canhideavt`, `canedit`) VALUES\n(1, 'Guest', 0, 1, '', 0, 0, 0),\n(2, 'Member', 1, 1, '#08c', 0, 0, 0),\n(3, 'Moderator', 2, 1, 'green', 1, 1, 0),\n(4, 'Administrator', 3, 1, '#F0A02D', 1, 1, 1);";
$sqls[] = "\n CREATE TABLE IF NOT EXISTS `" . $prefix . "privacy` (\n `userid` int(11) NOT NULL,\n `email` int(11) NOT NULL,\n UNIQUE KEY `userid` (`userid`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$sqls[] = "\n INSERT INTO `" . $prefix . "privacy` (`userid`, `email`) VALUES (1, 0);";
$sqls[] = "\n CREATE TABLE IF NOT EXISTS `" . $prefix . "settings` (\n `site_name` varchar(255) NOT NULL DEFAULT 'Demo Site',\n `url` varchar(300) NOT NULL,\n `admin_email` varchar(255) NOT NULL,\n `max_ban_period` int(11) NOT NULL DEFAULT '10',\n `register` int(11) NOT NULL DEFAULT '1',\n `email_validation` int(11) NOT NULL DEFAULT '0',\n `captcha` int(11) NOT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$sqls[] = $db->parse("\n INSERT INTO `" . $prefix . "settings` (`site_name`, `url`, `admin_email`, `max_ban_period`, `register`, `email_validation`, `captcha`) VALUES\n(?s, ?s, 'nor.reply@gmail.com', 10, 1, 0, 1);", $_POST['sitename'], $_POST['siteurl']);
$sqls[] = "\n CREATE TABLE IF NOT EXISTS `" . $prefix . "users` (\n `userid` int(11) NOT NULL AUTO_INCREMENT,\n `username` varchar(50) NOT NULL,\n `display_name` varchar(255) NOT NULL,\n `password` varchar(50) NOT NULL,\n `email` varchar(255) NOT NULL,\n `key` varchar(50) NOT NULL,\n `validated` varchar(100) NOT NULL,\n `groupid` int(11) NOT NULL DEFAULT '2',\n `lastactive` int(11) NOT NULL,\n `showavt` int(11) NOT NULL DEFAULT '1',\n `banned` int(11) NOT NULL,\n `regtime` int(11) NOT NULL,\n PRIMARY KEY (`userid`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
$sqls[] = "\n INSERT INTO `" . $prefix . "users` (`userid`, `username`, `display_name`, `password`, `email`, `key`, `validated`, `groupid`, `lastactive`, `showavt`, `banned`, `regtime`) VALUES\n(1, 'admin', 'Admin', '7110eda4d09e062aa5e4a390b0a572ac0d2c0220', 'admin@gmail.com', '', '1', 4, " . time() . ", 1, 0, " . time() . ");";
foreach ($sqls as $sql) {
if (!isset($page->error) && !$db->query("?p", $sql)) {
$page->error = "There was a problem while executing <code>{$sql}</code>";
}
}
if (!isset($page->error)) {
$page->success = "The installation was successful ! Thank you for using master loging system and we hope you enjo it ! Have fun ! <br/><br/>\n <a class='btn btn-success' href='./index.php'>Start exploring</a>\n <br/><br/>\n\n <h3>USER: admin <br/> PASSWORD: 1234</h3>";
}
}
?>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
示例12: SafeMySQL
<?php
require '../../php/main/db_connect.php';
$dialog = filter_input(INPUT_GET, 'dialog', FILTER_VALIDATE_INT);
if ($user_id) {
//Кол-во новых сообщений
$o = new SafeMySQL();
if ($dialog) {
$mm = $o->getOne('SELECT COUNT(meter) FROM users_dialogs WHERE meter=other_id AND pioneer_id=?i AND d_id <>?i OR meter=pioneer_id AND other_id=?i AND d_id <>?i', $user_id, $dialog, $user_id, $dialog);
$query_dialog = $o->query('UPDATE users_dialogs SET meter=0 WHERE d_id=?i AND meter<>?i LIMIT 1', $dialog, $user_id);
} else {
$mm = $o->getOne('SELECT COUNT(meter) FROM users_dialogs WHERE meter=other_id AND pioneer_id=?i OR meter=pioneer_id AND other_id=?i', $user_id, $user_id);
}
if ($mm) {
print $mm;
}
}
示例13: SafeMySQL
check_install();
// проверяем, установлена ли cms
$db = new SafeMySQL(array('user' => DB_LOGIN, 'pass' => DB_PASSWORD, 'db' => DB_NAME, 'charset' => 'utf8'));
$rows = get_subcategories($_POST['category_list']);
foreach ($rows as $rows2) {
echo '<option value="' . $rows2['id'] . '">' . $rows2['title'] . '</option>';
}
exit;
}
defined('CAFE') or die(header('Location: /'));
check_error();
// Добавление новой записи
if (isset($_POST['add']) && empty($error)) {
empty($_POST['url']) ? $url = translit($_POST['title']) : ($url = translit($_POST['url']));
$data = array('date' => timestamp($_POST['date']), 'login' => $_SESSION['login'], 'status' => $_POST['status'], 'title' => $_POST['title'], 'text' => $_POST['text'], 'type' => $_POST['type'], 'category' => $_POST['category'], 'keywords' => $_POST['keywords'], 'description' => $_POST['description'], 'url' => preg_replace("/[^a-z0-9-]/", "", $url), 'preview' => $_POST['preview'], 'source' => $_POST['source']);
$add_post = $db->query("INSERT " . DB_PREFIX . "_posts SET ?u", $data);
if ($add_post) {
$message = 'Запись добавлена';
} else {
$error = 'Возникла ошибка при сохранении записи';
}
}
// Измененяем содержимое записи
if ($_POST['update'] && empty($error)) {
empty($_POST['url']) ? $url = translit($_POST['title']) : ($url = translit($_POST['url']));
$data = array('date' => timestamp($_POST['date']), 'login' => $_POST['login'], 'status' => $_POST['status'], 'title' => $_POST['title'], 'text' => $_POST['text'], 'type' => $_POST['type'], 'category' => $_POST['category'], 'keywords' => $_POST['keywords'], 'description' => $_POST['description'], 'url' => preg_replace("/[^a-z0-9-]/", "", $url), 'preview' => $_POST['preview'], 'source' => $_POST['source']);
$update_post = $db->query("UPDATE " . DB_PREFIX . "_posts SET ?u WHERE id=?i", $data, $_POST['id']);
if ($update_post) {
$message = 'Содержимое записи обновлено';
} else {
$error = 'Возникла ошибка при обновлении содержимого записи';
示例14: uniqid
if ($x) {
print 'Извините пожайлуста, но такой email уже зарегистрирован.';
exit;
}
$x = $string_object->getOne("SELECT in_id FROM users_information WHERE nickname=?s", $login);
if ($x) {
print 'Извините пожайлуста, но такой никнейм уже зарегистрирован.';
exit;
}
$x = $string_object->getOne("SELECT nickname FROM users_registration WHERE nickname=?s", $login);
if ($x) {
print 'Просим прощения, но такой никнейм уже пытается зарегистрироваться.';
exit;
}
$x = $string_object->getOne("SELECT email FROM users_registration WHERE email=?s", $email);
if ($x) {
print 'Просим прощения, но кто-то уже регистрируется с таким E-mail.';
exit;
}
$_SESSION['registration_email'] = $email;
$_SESSION['registration_password'] = $password;
$key_reg = uniqid(rand(1, 1000) . '_');
$x = $string_object->query("INSERT INTO users_registration (key_reg, password, email, nickname, category, rules) VALUES (?s, ?s, ?s, ?s, ?s, ?s)", $key_reg, $password, $email, $login, $category, $rules);
if ($x) {
$text = 'Для окончания регистрации пройдите по ссылке: http://subscribeonme.ru/rn=' . $key_reg;
mail($email, 'Pulsar. Подтверждение регистрации на сайте', $text);
print 'success';
}
} else {
print 'Нам неудобно вас разочаровывать, но формат данных некоректен.';
}
示例15: demo
[<a href="dbtree.php">Manage demo</a>] [<a href="dbtree.php?mode=map">Visual demo (Map)</a>] [<a href="dbtree.php?mode=ajar">Visual demo (Ajar)</a>] [<a href="dbtree.php?mode=branch">Visual demo (Branch)</a>]
<?php
require_once 'classes/safemysql.class.php';
require_once 'classes/DbTree.class.php';
require_once 'classes/DbTreeExt.class.php';
// Data base connect
$dsn['user'] = 'root';
$dsn['pass'] = '';
$dsn['host'] = 'localhost';
$dsn['db'] = 'test';
$dsn['charset'] = 'utf8';
$dsn['errmode'] = 'exception';
define('DEBUG_MODE', false);
$db = new SafeMySQL($dsn);
$sql = 'SET NAMES utf8';
$db->query($sql);
$tree_params = array('table' => 'test_sections', 'id' => 'section_id', 'left' => 'section_left', 'right' => 'section_right', 'level' => 'section_level');
$dbtree = new DbTreeExt($tree_params, $db);
/* ------------------------ NAVIGATOR ------------------------ */
$navigator = 'You are here: ';
if (!empty($_GET['section_id'])) {
$parents = $dbtree->Parents((int) $_GET['section_id'], array('section_id', 'section_name'));
foreach ($parents as $item) {
if (@$_GET['section_id'] != $item['section_id']) {
$navigator .= '<a href="dbtree.php?mode=' . $_GET['mode'] . '§ion_id=' . $item['section_id'] . '">' . $item['section_name'] . '</a> > ';
} else {
$navigator .= '<strong>' . $item['section_name'] . '</strong>';
}
}
}
/* ------------------------ BRANCH ------------------------ */