Пример #1
0
 public function addcart()
 {
     $session = new Zend_Session_Namespace('shopcart');
     $id = Zend_Controller_Front::getInstance()->getRequest()->getParam('id');
     //$session->cart=$cart;
     if (isset($session->cart[$id])) {
         $qty = $cart[$id] + 1;
     } else {
         $qty = 1;
     }
     // var_dump($session->cart) ; exit;
     $cart[$id] = $qty;
     $base = new Zend_View();
     $link = $base->baseUrl();
     $url = $link . "/shoppingcart";
     chuyen_trang($url);
     exit;
 }
 function postingAction()
 {
     $captcha = new Zend_Captcha_Image();
     $vi = new Zend_View();
     $base = $vi->baseurl();
     $muser = new Admin_Model_Page();
     $paginator = Zend_Paginator::factory($muser->option_page());
     $paginator->setItemCountPerPage(10);
     $paginator->setPageRange(10);
     $currentPage = $this->_request->getParam('page', 1);
     $paginator->setCurrentPageNumber($currentPage);
     $this->view->books = $paginator;
     $system = new Admin_Model_Category();
     $menu = $system->option_menu();
     $this->view->bookss = $menu;
     $district = $system->option_dictrict();
     $this->view->bokk = $district;
     if (!$this->_request->isPost()) {
         $captcha->setTimeout('300')->setWordLen('4')->setHeight('60')->setWidth('320')->setImgDir(APPLICATION_PATH . '/../public_html/captcha/images/')->setImgUrl($base . '/captcha/images/')->setFont(APPLICATION_PATH . '/../public_html/font/AHGBold.ttf')->setFontSize(24);
         $captcha->generate();
         $this->view->captcha = $captcha->render($this->view);
         $this->view->captchaID = $captcha->getId();
         // Dua chuoi Captcha vao session
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captcha->getId());
         $captchaSession->word = $captcha->getWord();
     } else {
         $captchaID = $this->_request->captcha_id;
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaID);
         $captchaIterator = $captchaSession->getIterator();
         $captchaWord = $captchaIterator['word'];
         if ($this->_request->captcha == $captchaWord) {
             $this->view->purifier = Zend_Registry::get('purifier');
             $conf = HTMLPurifier_Config::createDefault();
             $purifier = new HTMLPurifier($conf);
             $content = $purifier->purify($this->_request->getParam('content'));
             $menu_id = $purifier->purify($this->_request->getParam('parent_id'));
             $title = $purifier->purify($this->_request->getParam('title'));
             $dis = $purifier->purify($this->_request->getParam('dis'));
             $key = $purifier->purify($this->_request->getParam('key'));
             $description = $purifier->purify($this->_request->getParam('description'));
             // $home = $purifier->purify($this->_request->getParam('home'));
             $upload = new Zend_File_Transfer();
             $images = $upload->addValidator('Extension', false, 'jpg,png,gif');
             //print_r($images, FALSE) ;
             $images = $upload->getFilename();
             $images = basename($images);
             $url = khongdau($title);
             $random_digit = rand(00, 99999);
             if (basename($images)) {
                 $img = $url . "-" . $random_digit . $images;
                 $filterRename = new Zend_Filter_File_Rename(array('target' => 'Upload/' . $img, 'overwrite' => false));
                 $upload->addFilter($filterRename);
                 if (!$upload->receive()) {
                     thongbao("Vui lòng nhập đúng định dạng hình ảnh");
                     trang_truoc();
                     return;
                 }
                 $upload->receive();
             } else {
                 $img == "no-img.png";
             }
             // $position = $purifier->purify($this->_request->getParam('position'));
             //  $active = $purifier->purify($this->_request->getParam('active'));
             $price = $purifier->purify($this->_request->getParam('price'));
             $state = $purifier->purify($this->_request->getParam('state'));
             $sales = $purifier->purify($this->_request->getParam('sales'));
             $made_in = $purifier->purify($this->_request->getParam('made_in'));
             //$members = $purifier->purify($this->_request->getParam('members'));
             $session = new Zend_Session_Namespace('identity');
             $members = $session->username;
             $dictrict_id = $purifier->purify($this->_request->getParam('dictrict_id'));
             //  $type = $purifier->purify($this->_request->getParam('type'));
             $add = new Admin_Model_Products();
             $add->insert_products($title, $description, $img, $content, $menu_id, $price, $state, $sales, $dis, $key, "", 1, 2, $made_in, $members, $dictrict_id, 1);
             thongbao("Chúc mừng {$members}, bạn đã đăng tin thành công");
             chuyen_trang($base . "/thanh-vien.html");
         } else {
             thongbao('Ban nhap sai chuoi Captcha');
             trang_truoc();
         }
         $this->_helper->viewRenderer->setNoRender();
         $mask = APPLICATION_PATH . "/../public_html/captcha/images/*.png";
         array_map("unlink", glob($mask));
     }
 }
Пример #3
0
        $khach_mua = "";
        for ($i = 0; $i < count($_SESSION['soluong_giohang']); $i++) {
            $id = $_SESSION['id_giohang'][$i];
            $sl = $_SESSION['soluong_giohang'][$i];
            if ($sl != 0) {
                $khach_mua = $khach_mua . "{$id}" . "___" . "{$sl}" . "______";
            }
            $mua_tang = mua_tang($id, $sl);
            $mua = "UPDATE `sanpham` SET `loai_gia` = '{$mua_tang}' WHERE `sanpham`.`id` ={$id};";
            mysql_query($mua);
        }
        $kd = $_SESSION[$ten_danh_dau . 'ky_danh__abc'];
        $khach_mua = substr($khach_mua, 0, -6);
        $them = "\n\t\t\t\tINSERT INTO `hoadon`\n\t\t\t\t(\n\t\t\t\t\t`id` ,\n\t\t\t\t\t`khach_mua` ,\n\t\t\t\t\t`ho_ten` ,\n\t\t\t\t\t`dia_chi` ,\n\t\t\t\t\t`email` ,\n\t\t\t\t\t`dien_thoai` ,\n\t\t\t\t\t`noi_dung`,\n\t\t\t\t\t`ky_danh`\n\t\t\t\t)\n\t\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\tNULL ,\n\t\t\t\t\t'{$khach_mua}',\n\t\t\t\t\t'{$ho_ten}',\n\t\t\t\t\t'{$dia_chi}',\n\t\t\t\t\t'{$email}',\n\t\t\t\t\t'{$dien_thoai}',\n\t\t\t\t\t'{$noi_dung}',\n\t\t\t\t\t'{$kd}'\n\t\t\t\t);\n\t\t\t";
        mysql_query($them);
        $tv = "select * from thong_tin_lh where id='2'";
        $tv_1 = mysql_query($tv);
        $tv_2 = mysql_fetch_array($tv_1);
        $email_lh = $tv_2['email'];
        $tinnhan = "\n\t\t\tTên  khách hàng : {$ho_ten} <br>\n\t\t\tEmail : {$email} <br>\n\t\t\tÐ?a ch? : {$dia_chi} <br>\n\t\t\tÐi?n tho?i : {$dien_thoai} <br>\n\t\t\t\n\t\t\tN?i dung : {$noi_dung} <br>";
        $to = $email_lh;
        $subject = "Mua hàng tr?c tuy?n";
        $message = $tinnhan;
        $headers = 'Content-type: text/html;charset=utf-8';
        mail($to, $subject, $message, $headers);
        unset($_SESSION['soluong_giohang']);
        unset($_SESSION['id_giohang']);
        thongbao("Thanks for shopping at our site! \\n Your bill was sent to us!");
        chuyen_trang("index.php");
    }
}
Пример #4
0
 function orderAction()
 {
     $yourCart = new Zend_Session_Namespace('cart');
     if ($this->_request->isPost()) {
         $itemProduct = $this->_arrParam['itemProduct'];
         if (count($itemProduct) > 0) {
             foreach ($itemProduct as $key => $val) {
                 if ($val == 0) {
                     unset($itemProduct[$key]);
                 }
             }
         }
         $yourCart->cart = $itemProduct;
     }
     //echo count ($yourCart->cart);
     $ssInfo = $yourCart->getIterator();
     //var_dump($ssInfo);
     $tblProduct = new Default_Model_Cart();
     $this->_arrParam['cart'] = $ssInfo['cart'];
     if (count($this->_arrParam['cart']) > 0) {
         $this->view->Items = $tblProduct->listcart($this->_arrParam);
         $this->view->cart = $ssInfo['cart'];
         $buy = "";
         foreach ($ssInfo['cart'] as $key => $val) {
             $item[] = $key;
             $demo[] = $val;
             //  echo $key;
             //  echo $val;
         }
         for ($i = 0; $i < count($ssInfo['cart']); $i++) {
             $id = $item[$i];
             $sl = $demo[$i];
             $buy = $buy . "{$id}" . "___" . "{$sl}" . "______";
         }
         $buy = substr($buy, 0, -6);
         // thanh toan
         $muser = new Default_Model_Cart();
         $captcha = new Zend_Captcha_Image();
         $vi = new Zend_View();
         $base = $vi->baseurl();
         if (!$this->_request->isPost()) {
             $captcha->setTimeout('300')->setWordLen('4')->setHeight('50')->setWidth('320')->setImgDir(APPLICATION_PATH . '/../public_html/captcha/images/')->setImgUrl($base . '/captcha/images/')->setFont(APPLICATION_PATH . '/../public_html/font/UTM-Avo.ttf');
             $captcha->generate();
             $this->view->captcha = $captcha->render($this->view);
             $this->view->captchaID = $captcha->getId();
             // Dua chuoi Captcha vao session
             $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captcha->getId());
             $captchaSession->word = $captcha->getWord();
         } else {
             $captchaID = $this->_request->captcha_id;
             $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaID);
             $captchaIterator = $captchaSession->getIterator();
             $captchaWord = $captchaIterator['word'];
             if ($this->_request->captcha == $captchaWord) {
                 $session = new Zend_Session_Namespace('identity');
                 $username = $session->username;
                 $this->view->purifier = Zend_Registry::get('purifier');
                 $conf = HTMLPurifier_Config::createDefault();
                 $purifier = new HTMLPurifier($conf);
                 $fullname = $purifier->purify($this->_request->getParam('fullname'));
                 $address = $purifier->purify($this->_request->getParam('address'));
                 $phone = $purifier->purify($this->_request->getParam('phone'));
                 $email = $purifier->purify($this->_request->getParam('email'));
                 $coment = $purifier->purify($this->_request->getParam('coment'));
                 $title = $purifier->purify($this->_request->getParam('title'));
                 $emaillh = "*****@*****.**";
                 $tinnhan = "\n\t\t\tHọ tên : {$fullname} <br>\n\t\t\tEmail : {$email}<br>\n\t\t\tĐịa chỉ : {$address}<br>\n\t\t\tĐiện thoại : {$phone}<br>\n\t\t\t\n\t\t\tNội dung : {$coment}<br>";
                 $to = $emaillh;
                 $subject = $title;
                 $message = $tinnhan;
                 $headers = 'Content-type: text/html;charset=utf-8';
                 mail($to, $subject, $message, $headers);
                 // Thiết lập SMTP Server
                 require 'ham/class.phpmailer.php';
                 require 'ham/class.pop3.php';
                 // nạp thư viện
                 $mailer = new PHPMailer();
                 // khởi tạo đối tượng
                 $mailer->IsSMTP();
                 // gọi class smtp để đăng nhập
                 $mailer->CharSet = "utf-8";
                 // bảng mã unicode
                 //Đăng nhập Gmail
                 $mailer->SMTPAuth = true;
                 // Đăng nhập
                 $mailer->SMTPSecure = "ssl";
                 // Giao thức SSL
                 $mailer->Host = "smtp.gmail.com";
                 // SMTP của GMAIL
                 $mailer->Port = 465;
                 // cổng SMTP
                 // Phải chỉnh sửa lại
                 $mailer->Username = "******";
                 // GMAIL username
                 $mailer->Password = "******";
                 // GMAIL password
                 $mailer->AddAddress("{$emaillh}", 'Recipient Name');
                 //email người nhận
                 // Chuẩn bị gửi thư nào
                 $mailer->FromName = "{$fullname}";
                 // tên người gửi
                 $mailer->From = "{$email}";
                 // mail người gửi
                 $mailer->Subject = "{$base}";
                 $mailer->IsHTML(true);
                 //Bật HTML không thích thì false
                 // Nội dung lá thư
                 $mailer->Body = "{$tinnhan}";
                 // Gửi email
                 if (!$mailer->Send()) {
                     // Gửi không được, đưa ra thông báo lỗi
                     echo "Không gửi được ";
                     echo "Lỗi: " . $mailer->ErrorInfo;
                 } else {
                     $muser->insert_order($address, $email, $phone, $coment, $username, $fullname, $buy);
                     Zend_Session::namespaceUnset('cart');
                     thongbao("Cảm ơn bạn đã liên hệ cho chúng tôi");
                     chuyen_trang($base);
                 }
             } else {
                 thongbao('Bạn nhập sai chuỗi Captcha');
                 trang_truoc();
             }
             $this->_helper->viewRenderer->setNoRender();
             $mask = APPLICATION_PATH . "/../public_html/captcha/images/*.png";
             array_map("unlink", glob($mask));
         }
     } else {
         //echo "Bạn chưa mua hàng";
     }
 }
Пример #5
0
 function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $info = $auth->getIdentity();
         $level = $info->group_name;
         // luu cookie
         $value = $info->username;
         setcookie("test", $value, time() + 3600);
         // doc cookie
         $test = $this->_request->getCookie('test');
         //        if($test == FALSE){
         //            $auth = Zend_Auth::getInstance();
         //	    $auth->clearIdentity();
         //            $vew=new Zend_View();
         //           $ct= $vew->baseurl('/login/index/login');
         //           chuyen_trang($ct);
         //            }
         $role = "";
         switch ($level) {
             case 1:
                 $role = "seller";
                 break;
             case 2:
                 $role = "user";
                 break;
             case 3:
                 $role = "amo";
                 break;
             default:
                 $role = "admin";
                 break;
         }
     } else {
         $role = '';
     }
     $acl = new Zend_Acl();
     // khai bao cac  nhom phan quyen
     $acl->addRole(new Zend_Acl_Role('amo'))->addRole(new Zend_Acl_Role('user'), 'amo')->addRole(new Zend_Acl_Role('seller'), 'user')->addRole(new Zend_Acl_Role('admin'));
     //Khai bao cac resource (News - blog -production
     $acl->add(new Zend_Acl_Resource('login:index'));
     $acl->add(new Zend_Acl_Resource('default', NULL));
     $acl->add(new Zend_Acl_Resource('default:index'), 'default');
     $acl->add(new Zend_Acl_Resource('default:register'), 'default');
     $acl->add(new Zend_Acl_Resource('default:error'), 'default');
     $acl->add(new Zend_Acl_Resource('default:page'), 'default');
     $acl->add(new Zend_Acl_Resource('default:product'), 'default');
     $acl->add(new Zend_Acl_Resource('error'));
     $acl->add(new Zend_Acl_Resource('error:error'), 'error');
     $acl->add(new Zend_Acl_Resource('admin'));
     $acl->add(new Zend_Acl_Resource('admin:index'), 'admin');
     $acl->add(new Zend_Acl_Resource('admin:link'), 'admin');
     $acl->add(new Zend_Acl_Resource('admin:page'), 'admin');
     $acl->add(new Zend_Acl_Resource('admin:product'), 'admin');
     $acl->add(new Zend_Acl_Resource('admin:side'), 'admin');
     $acl->add(new Zend_Acl_Resource('admin:support'), 'admin');
     $acl->add(new Zend_Acl_Resource('admin:user'), 'admin');
     //khai bao danh sach cac action ma nhom co quyen truy cap
     $acl->allow("amo", "login:index", null);
     $acl->allow("amo", "default", null);
     $acl->allow('amo', "admin:index", "index");
     $acl->deny('amo', "admin", NULL);
     $acl->allow("user", "admin", null);
     $acl->deny('user', "admin:user", null);
     $acl->deny('user', "admin:page", array('listpage', 'listpages'));
     //$acl->deny('user', "admin:user", null);
     $acl->deny('user', "admin:user", null);
     $acl->allow('admin', NULL, NULL);
     $module = $request->getModuleName();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     //$_pg=$acl->isAllowed($role,$module.':'.$controller,$action);
     if ($role != '') {
         if (!$acl->isAllowed($role, $module . ':' . $controller, $action)) {
             thongbao('Bạn ko có quyền truy cập vào modules này');
             $view = new Zend_View();
             $bse = $view->baseUrl();
             chuyen_trang($bse);
             //var_dump($ada);
         }
     }
 }
Пример #6
0
<?php

for ($i = 0; $i < count($_SESSION['id_giohang']); $i++) {
    // cap nhat gio hang
    $id = $_SESSION['id_giohang'][$i];
    if ($id == $_GET['id']) {
        $trung_lap = "co";
        $sl_cu = $_SESSION['soluong_giohang'][$i];
        $_SESSION['soluong_giohang'][$i] = $sl_cu + 1;
        break;
    }
}
$dem_giohang = count($_SESSION['id_giohang']);
if (count($_GET) != 0) {
    if ($trung_lap == "") {
        $_SESSION['id_giohang'][$dem_giohang] = $_GET['id'];
        $_SESSION['soluong_giohang'][$dem_giohang] = 1;
    }
}
chuyen_trang("?thamso=gio_hang");