예제 #1
0
require_once 'bd_script.php';
// подключаем smarty
$smarty_dir = 'Smarty/';
require $smarty_dir . 'libs/Smarty.class.php';
$smarty = new Smarty();
$smarty->compile_check = TRUE;
$smarty->debugging = FALSE;
$smarty->template_dir = $smarty_dir . 'templates/';
$smarty->compile_dir = $smarty_dir . 'templates_c/';
$smarty->cache_dir = $smarty_dir . 'cache/';
$smarty->config_dir = $smarty_dir . 'configs/';
//передаем 'имя переменной' и 'значение'
$smarty->assign('title', 'Наше объявление');
$smarty->assign('citys', $citys);
$smarty->assign('categorys', $categorys);
connect_bd('localhost', 'root', '', 'main_bd');
if (isset($_POST['confirm_add'])) {
    // кнопка добавить
    if (is_numeric($_POST['id_r'])) {
        // если присутствует метка id_r то сохраняем редактируемое объявление
        edit_ads($_POST);
    } else {
        ads_ad($_POST);
        // иначе добавляем новое объявление
    }
    restart();
    // вызываем restart(); для очистки формы
} elseif (isset($_POST['clear_form']) || isset($_POST['back'])) {
    // кнопка очистить форму  вызывает restart();
    restart();
} elseif (isset($_POST['clear_base'])) {
예제 #2
0
 $result = mysql_query($sql);
 $categories = array();
 while ($row = mysql_fetch_assoc($result)) {
     array_push($categories, $row);
 }
 $sql = "SELECT * FROM bookmarks WHERE user = "******" ORDER BY position";
 $result = mysql_query($sql);
 $bookmarks = array();
 while ($row = mysql_fetch_assoc($result)) {
     array_push($bookmarks, $row);
 }
 mysql_close($connexion);
 //////////////////
 //////IMPORT
 //////////////////
 $connexion2 = connect_bd(SERVER_N, USER_N, PASSWORD_N, BASE_NAME_N);
 //user
 $idUser = $_POST['idUserNew'];
 $categoryConversion = array();
 foreach ($categories as $k => $v) {
     $name = addslashes(utf8_decode(html_entity_decode($v['nom'])));
     $sql = "INSERT INTO category (name, parent, user_id) VALUES ('" . $name . "', '" . $v['idParent'] . "','" . $idUser . "')";
     mysql_query($sql);
     $categoryConversion[$v['id']] = mysql_insert_id();
 }
 //bookmark
 $bookmarkConversion = array();
 $sql = "SELECT id FROM category WHERE name = '__default' AND user_id = " . $idUser . " LIMIT 1";
 $result = mysql_query($sql);
 $row = mysql_fetch_assoc($result);
 $idFav = $row['id'];
예제 #3
0
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
header("Content-Type: text/html; charset=utf-8");
$project_root = $_SERVER['DOCUMENT_ROOT'];
$smarty_dir = $project_root . '/Smarty/';
require_once "dz9-functions.php";
// подключаем файл с функциями
require_once "bd_script.php";
//подключаем файл со скриптами для БД
require_once "data_connection.php";
//подключаем файл для соединения с БД
connect_bd($ServerName, $UserName, $Password, $Database);
//соединяемся с БД
// подключаем smarty
$smarty_dir = 'Smarty/';
require $smarty_dir . 'libs/Smarty.class.php';
$smarty = new Smarty();
$smarty->compile_check = TRUE;
$smarty->debugging = FALSE;
$smarty->template_dir = $smarty_dir . 'templates/';
$smarty->compile_dir = $smarty_dir . 'templates_c/';
$smarty->cache_dir = $smarty_dir . 'cache/';
$smarty->config_dir = $smarty_dir . 'configs/';
//передаем 'имя переменной' и 'значение'
$smarty->assign('title', 'Наше объявление');
$smarty->assign('cities', get_cities());
$smarty->assign('category', get_category());
if (isset($_POST['confirm_add'])) {
    // кнопка добавить