Example #1
0
 private function handle($col)
 {
     $globalDAO = new GlobalDAO(DataSource::getInstance());
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $content = trim(remove_slashes($_POST['content']));
         if ($globalDAO->update($col, $content)) {
             $message = array('type' => 'info', 'value' => 'Lưu thành công.');
         } else {
             $message = array('type' => 'error', 'value' => 'Có lỗi xảy ra!');
         }
         $this->registry->template->message = $message;
         $this->registry->template->content = $content;
         $tmp = $globalDAO->select($col);
         $this->registry->template->content_backup = $tmp;
     } else {
         if ($_SERVER['REQUEST_METHOD'] == 'GET') {
             $tmp = $globalDAO->select($col);
             $this->registry->template->content = $tmp;
             $this->registry->template->content_backup = $tmp;
         }
     }
     if ($col == 'about') {
         $s = '“Giới thiệu”';
     } else {
         if ($col == 'contact') {
             $s = '“Liên hệ”';
         }
     }
     $this->registry->template->tile_title = 'Soạn thảo trang ' . $s;
     $this->registry->template->tile_content = 'admin/compose.php';
     $this->registry->template->show('admin/layout/admin.php');
 }
Example #2
0
 public function insert()
 {
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         echo '0';
         return;
     }
     $name = remove_slashes($_POST['name']);
     $catDAO = new CatDAO(DataSource::getInstance());
     $last_id = $catDAO->insert($name);
     echo $last_id;
 }
Example #3
0
 public function index()
 {
     echo 'zzzzzzzzzzz 1';
     if ($this->findGroupId() > 0) {
         header('Location: ' . __SITE_CONTEXT . 'admin/dashboard/');
         return;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $username = remove_slashes($_POST['username']);
         $password = remove_slashes($_POST['password']);
         $memberDAO = new MemberDAO(DataSource::getInstance());
         $group_id = $memberDAO->checkLogin($username, $password);
         if ($group_id == 0) {
             // login failed
             $message = 'Sai username hoặc password!';
             $this->registry->template->message = $message;
             $this->registry->template->username = $username;
         } else {
             $_SESSION['member'] = array('group_id' => $group_id);
             header('Location: ' . __SITE_CONTEXT . 'admin/dashboard/');
             return;
         }
     }
     $categoryDAO = new CatDAO(DataSource::getInstance());
     $categories_list = $categoryDAO->findByAll_Navigation();
     $promoDAO = new PromoDAO(DataSource::getInstance());
     $this->registry->template->promo_seo_url_newest = $promoDAO->findNewestSeoUrl();
     $cart = getCart();
     $this->registry->template->categories_list = $categories_list;
     $this->registry->template->cart = $cart;
     $this->registry->template->tile_title = 'Login';
     $this->registry->template->body_class = 'page-template';
     $this->registry->template->tile_content = 'login.php';
     $this->registry->template->tile_footer = 'footer.php';
     $this->registry->template->show('layout/user.php');
 }
Example #4
0
/** Create SQL condition from query string
* @param string
* @param array
* @return string
*/
function where_check($val, $fields = array())
{
    parse_str($val, $check);
    remove_slashes(array(&$check));
    return where($check, $fields);
}
Example #5
0
 public function updatePost()
 {
     $id = (int) $_POST['id'];
     $code = trim(remove_slashes($_POST['code']));
     $brand_id = (int) $_POST['brand_id'];
     $category_id = (int) $_POST['category_id'];
     $price_fonds = trim(remove_slashes($_POST['price_fonds']));
     $price_sell = trim(remove_slashes($_POST['price_sell']));
     $description = trim(remove_slashes($_POST['description']));
     $pics = trim(remove_slashes($_POST['pics']));
     $seo_url = trim(remove_slashes($_POST['seo_url']));
     $this->registry->template->product = array('id' => $id, 'code' => htmlspecialchars($code), 'category_id' => $category_id, 'brand_id' => $brand_id, 'price_fonds' => htmlspecialchars($price_fonds), 'price_sell' => htmlspecialchars($price_sell), 'description' => htmlspecialchars($description), 'pics' => $pics, 'seo_url' => htmlspecialchars($seo_url));
     $messageStr = '';
     $productDAO = new ProductDAO(DataSource::getInstance());
     if (!isset($code) || strlen($code) == 0) {
         $messageStr .= 'Mã sản phẩm: không được bỏ trống.<br />';
     } else {
         if ($productDAO->isExistedCode_Except($code, $id)) {
             $messageStr .= 'Mã sản phẩm: đã tồn tại.<br />';
         }
     }
     if (!isset($price_fonds) || strlen($price_fonds) == 0) {
         $messageStr .= 'Giá vốn: không được bỏ trống.<br />';
     } else {
         if ((int) $price_fonds <= 0) {
             $messageStr .= 'Giá vốn: phải là số nguyên dương.<br />';
         } else {
             $price_fonds_int = (int) $price_fonds;
         }
     }
     if (!isset($price_sell) || strlen($price_sell) == 0) {
         $messageStr .= 'Giá bán: không được bỏ trống.<br />';
     } else {
         if ((int) $price_sell <= 0) {
             $messageStr .= 'Giá bán: phải là số nguyên dương.<br />';
         } else {
             $price_sell_int = (int) $price_sell;
         }
     }
     if (isset($price_fonds_int) && isset($price_sell_int)) {
         if ($price_fonds_int > $price_sell_int) {
             $messageStr .= 'Giá bán: không được thấp hơn giá vốn.<br />';
         }
     }
     if (strlen($seo_url) == 0) {
         $messageStr .= 'SEO URL: không được bỏ trống.<br />';
     } else {
         if (!check_seo_url($seo_url)) {
             $messageStr .= 'SEO URL: không hợp lệ.<br />';
         } else {
             if ($productDAO->isExistedSeoUrl_Except($seo_url, $id)) {
                 $messageStr .= 'SEO URL: đã tồn tại.<br />';
             }
         }
     }
     $messageStr = trim($messageStr);
     if ($messageStr != '') {
         $this->registry->template->message = array('type' => 'error', 'value' => $messageStr);
     } else {
         $result = $productDAO->update($id, $code, $brand_id, $category_id, $price_fonds, $price_sell, $description, $pics, $seo_url);
         if ($result) {
             $this->registry->template->message = array('type' => 'info', 'value' => 'Lưu thành công!');
         } else {
             $this->registry->template->message = array('type' => 'error', 'value' => 'Có lỗi xảy ra.');
         }
     }
     $tmp = $productDAO->findById($id);
     $this->registry->template->product_backup = $tmp;
     if (!$tmp) {
         $this->registry->template->message = array('type' => 'error_not_found', 'value' => 'Không tồn tại sản phẩm này!');
     }
 }
Example #6
0
session_cache_limiter("");
// to allow restarting session and to not send Cache-Control: no-store
if (!defined("SID")) {
    session_name("adminer_sid");
    // use specific session name to get own namespace
    $params = array(0, preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]), "", $HTTPS);
    if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
        $params[] = true;
        // HttpOnly
    }
    call_user_func_array('session_set_cookie_params', $params);
    // ini_set() may be disabled
    session_start();
}
// disable magic quotes to be able to use database escaping function
remove_slashes(array(&$_GET, &$_POST, &$_COOKIE), $filter);
if (get_magic_quotes_runtime()) {
    set_magic_quotes_runtime(false);
}
@set_time_limit(0);
// @ - can be disabled
@ini_set("zend.ze1_compatibility_mode", false);
// @ - deprecated
@ini_set("precision", 20);
// @ - can be disabled
include "../adminer/include/lang.inc.php";
include "../adminer/lang/{$LANG}.inc.php";
include "../adminer/include/pdo.inc.php";
include "../adminer/include/driver.inc.php";
include "../adminer/drivers/sqlite.inc.php";
include "../adminer/drivers/pgsql.inc.php";
Example #7
0
<?php

if (!defined('ROOT')) {
    exit('Access denied!');
}
#PHP版本要大于5.1
if (version_compare(PHP_VERSION, '5.1.0', '<')) {
    exit('PHP_VERSION>5.1.0');
}
define('DEBUG', TRUE);
define('FILEPATH', 'upload/');
#程序运行模式
error_reporting(DEBUG ? E_ALL : 0);
#设置时间区域
date_default_timezone_set('PRC');
#魔法引用如果开启就先移除斜杠
@set_magic_quotes_runtime(0);
if (@get_magic_quotes_gpc()) {
    $_POST = remove_slashes($_POST);
}
require_once ROOT . '/function.php';
$do = isset($_REQUEST['do']) ? trim($_REQUEST['do']) : '';
header("content-type:text/html;charset=utf-8");
Example #8
0
                if ($count < $rowcount) {
                    echo ", ";
                }
                $count++;
            }
        } elseif ($rowcount >= 4) {
            echo "Various";
        }
        echo "<br /><a href='kb_view_article.php?id={$kbarticle->docid}' class='info'>{$kbarticle->title}";
        $asql = "SELECT LEFT(content,400) FROM `{$dbKBContent}` WHERE docid='{$kbarticle->docid}' ORDER BY id ASC LIMIT 1";
        $aresult = mysql_query($asql);
        if (mysql_error()) {
            trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING);
        }
        list($content) = mysql_fetch_row($aresult);
        $content = strip_tags(remove_slashes($content));
        echo "<span>{$content}</span>";
        echo "</a>";
        echo "</td>";
        echo "<td>" . ldate($CONFIG['dateformat_date'], mysql2date($kbarticle->published)) . "</td>";
        echo "<td>" . $kbarticle->author . "</td>";
        echo "<td>{$kbarticle->keywords}</td>";
        echo "</tr>\n";
        if ($shade == 'shade1') {
            $shade = 'shade2';
        } else {
            $shade = 'shade1';
        }
    }
    echo "</table>\n";
} else {
Example #9
0
 private function updatePost()
 {
     $id = (int) $_POST['id'];
     $full_name = trim(remove_slashes($_POST['full_name']));
     $address = trim(remove_slashes($_POST['address']));
     $email = trim(remove_slashes($_POST['email']));
     $birthday = trim(remove_slashes($_POST['birthday']));
     $city_id = (int) $_POST['city_id'];
     $note = trim(remove_slashes($_POST['note']));
     $phone = trim(remove_slashes($_POST['phone']));
     $this->registry->template->customer = array('id' => $id, 'full_name' => htmlspecialchars($full_name), 'address' => htmlspecialchars($address), 'email' => htmlspecialchars($email), 'birthday' => htmlspecialchars($birthday), 'city_id' => $city_id, 'note' => htmlspecialchars($note), 'phone' => htmlspecialchars($phone));
     $messageStr = '';
     if (!isset($full_name) || strlen($full_name) == 0) {
         $messageStr .= 'Họ và tên: không được bỏ trống.<br />';
     }
     if (isset($email) && strlen($email) > 0) {
         if (!valid_email($email)) {
             $messageStr .= 'Email: không hợp lệ.<br />';
         }
     }
     if (isset($birthday) && strlen($birthday) > 0) {
         if (!valid_date_vn($birthday)) {
             $messageStr .= 'Ngày sinh: không hợp lệ.<br />';
         }
     }
     $messageStr = trim($messageStr);
     $customerDAO = new CustomerDAO(DataSource::getInstance());
     if ($messageStr != '') {
         $this->registry->template->message = array('type' => 'error', 'value' => $messageStr);
     } else {
         $result = $customerDAO->update($id, $full_name, convert_date_to_us($birthday), $address, $email, $city_id, $note, $phone);
         if ($result) {
             $this->registry->template->message = array('type' => 'info', 'value' => 'Lưu thành công!');
         } else {
             $this->registry->template->message = array('type' => 'error', 'value' => 'Có lỗi xảy ra.');
         }
     }
     $tmp = $customerDAO->findById($id);
     $this->registry->template->customer_backup = $tmp;
     if (!$tmp) {
         $this->registry->template->message = array('type' => 'error_not_found', 'value' => 'Không tồn tại khách hàng này!');
     }
 }
Example #10
0
 public function deleteBatch()
 {
     $strBatch = remove_slashes($_POST['str_batch']);
     $cartDAO = new CartDAO(DataSource::getInstance());
     $cartDAO->deleteBatch($strBatch);
     echo '1';
 }
Example #11
0
 private function insertPost()
 {
     $seo_url = trim(remove_slashes($_POST['seo_url']));
     $subject = trim(remove_slashes($_POST['subject']));
     $promo_date = trim(remove_slashes($_POST['promo_date']));
     $content = trim(remove_slashes($_POST['content']));
     $this->registry->template->promo = array('seo_url' => htmlspecialchars($seo_url), 'subject' => htmlspecialchars($subject), 'promo_date' => htmlspecialchars($promo_date), 'content' => $content);
     $promoDAO = new PromoDAO(DataSource::getInstance());
     $message = '';
     if (strlen($seo_url) == 0) {
         $message .= 'SEO URL: không được bỏ trống.<br />';
     } else {
         if (!check_seo_url($seo_url)) {
             $message .= 'SEO URL: không hợp lệ.<br />';
         } else {
             if ($promoDAO->isExistedSeoUrl($seo_url)) {
                 $message .= 'SEO URL: đã tồn tại.<br />';
             }
         }
     }
     if (strlen($subject) == 0) {
         $message .= 'Chủ đề: không được bỏ trống.<br />';
     }
     if (strlen($promo_date) == 0) {
         $message .= 'Ngày tạo: không được bỏ trống.<br />';
     } else {
         if (!valid_date_vn($promo_date)) {
             $message .= 'Ngày tạo: không hợp lệ.<br />';
         }
     }
     if (strlen($content) == 0) {
         $message .= 'Nội dung chương trình: không được bỏ trống.<br />';
     }
     if (strlen($message) != 0) {
         $this->registry->template->message = array('type' => 'error', 'value' => $message);
     } else {
         $last_id = $promoDAO->insert($seo_url, $subject, convert_date_to_us($promo_date), $content);
         if ($last_id > -1) {
             $this->registry->template->message = array('type' => 'info', 'value' => 'Đã thêm chương trình khuyến mãi thành công. ' . ' <a href="' . __SITE_CONTEXT . 'admin/promo/update?id=' . $last_id . '">[Sửa]</a>');
             $this->registry->template->promo = array('promo_date' => get_cur_date('/'));
         } else {
             $this->registry->template->message = array('type' => 'error', 'value' => 'Có lỗi xảy ra.');
         }
     }
 }