public function action_profiler() { $profiler = Session::get('profiler'); if (empty($profiler) === false) { Session::Delete('profiler'); } else { Session::Set('profiler', true); } Response::Redirect_Back(); }
$session->SetId($sess_id); $session->SetActive($sess_active); $session->SetName($date->GetDate()); $session->SetIp($sess_ip); $session->SetUser($sess_user_id); if ($session->Update()) { $message = $screen_module_name . " alterado com sucesso."; } else { $message = "Problemas na operação."; } } if ($action == 4) { $session = new Session(); $session->SetDatabase($database); $session->SetId($sess_id); if ($session->Delete()) { $date = new Date(); $message = $screen_module_name . " excluído com sucesso."; $sess_id = ""; $sess_active = ""; $sess_date = $date->GetNowFull(); $sess_ip = ""; $sess_user_id = ""; } else { $message = "Problemas na operação."; } } } ?> <html>
| Create the database file and insert the default sittengs | |-------------------------------------------------------------------------- */ $dbFile = ABSPATH . '/database/' . Config::Get('db/dbname') . '.db'; if (!file_exists($dbFile)) { Session::Put("setup", true); Redirect::To("install"); die; } /* |-------------------------------------------------------------------------- | Check If there an admin |-------------------------------------------------------------------------- | */ if (file_exists($dbFile)) { try { if (DB::GetInstance()->queryGet("SELECT id FROM users where roles = 1 ")->count() == 0) { Session::Put("setup", true); Redirect::To("install"); die; } } catch (Exception $ex) { session_destroy(); die("Some database table(s) is missing Please delete the database file an reinstall the application."); } } // Everything is okay Session::Delete("setup"); Options::CheckSiteUrl();
if (crypt($pas, "mc05wBF&IТПШРnw4ton*R +-*/ ☺") != $user["Password"]) { $log->Write(basename(__FILE__, ".php"), "Неверная авторизация"); die("Логин или пароль не верен!"); } } $sessionid = Session::GenId($user["id"]); setcookie("session", $sessionid, time() + 900); } else { // For Users with mail $p = $db->QueryOne("select Password from `TemporaryPasswords` where UserId='" . $user["id"] . "' order by DateTime desc"); if ($p["Password"] != $pas) { $log->Write(basename(__FILE__, ".php"), "Неверная авторизация"); die($p["Password"] . "-" . $pas . " Логин или пароль не верен!"); } else { $sessionid = Session::GenId($user["id"]); setcookie("session", $sessionid, time() + 900); Session::DeletePasswords($login); } } die("ok"); break; case "logout": $log->Write(basename(__FILE__, ".php"), "Выход"); Session::Delete($cookie); setcookie('session', null, -1); die("ok"); break; default: echo "Action not found"; break; }
#------------------------------------------------------------------------------- /** @author Великодный В.В. (Joonte Ltd.) */ /******************************************************************************/ /******************************************************************************/ eval(COMP_INIT); /******************************************************************************/ /******************************************************************************/ if (Is_Error(System_Load('modules/Authorisation.mod', 'classes/Session.class.php'))) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $Session = new Session((string) @$_COOKIE['SessionID']); #------------------------------------------------------------------------------- if (Is_Error($Session->Delete())) { return ERROR | @Trigger_Error(400); } #------------------------------------------------------------------------------- if (!SetCookie('SessionID', 'closed', Time(), '/')) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $Event = array('UserID' => $GLOBALS['__USER']['ID'], 'Text' => 'Пользователь вышел из системы'); #------------------------------------------------------------------------------- $Event = Comp_Load('Events/EventInsert', $Event); if (!$Event) { return ERROR | @Trigger_Error(500); } #-------------------------------------------------------------------------------
function do_signout() { global $ttH; $output = array('ok' => 1); Session::Delete('user_cur'); Session::Delete('ordering_address'); Session::Delete('promotion_code'); Session::Delete('gift_voucher'); return json_encode($output); }
function do_main() { global $ttH; /*if($ttH->site_func->check_user_login() != 1) { $link_method = $ttH->site->get_link ('product',$ttH->setting['product']['ordering_friendly_link'],$ttH->setting['product']['ordering_address_link']); $ttH->html->redirect_rel($link_method); }*/ $ordering_payment = Session::get('ordering_payment', array()); /*print_arr($ordering_payment); die();*/ if (!is_array($ordering_payment) || !count($ordering_payment) > 0) { $ttH->html->redirect_rel($ttH->site->get_link('home')); } $arr_pro = $ttH->load_data->data_table('product', 'item_id', 'item_id,picture,price_buy,price_s,price_l,title,friendly_link', " is_show=1 \r\r\n\t\t\tand lang='" . $ttH->conf['lang_cur'] . "' \r\r\n\t\t\tand find_in_set(item_id,'" . @implode(',', $ordering_payment['arr_cart_list_pro']) . "')>0 \r\r\n\t\t\torder by show_order desc, date_create asc"); $sql = "select * \r\r\n\t\t\t\t\t\tfrom product_order \r\r\n\t\t\t\t\t\twhere order_code='" . $ordering_payment['order_code'] . "' "; //echo $sql; $result = $ttH->db->query($sql); if ($order_info = $ttH->db->fetch_row($result)) { $arr_order_shipping = $ttH->load_data->data_table('order_shipping', 'shipping_id', 'shipping_id,title,content', "shipping_id='" . $order_info['shipping'] . "' and lang='" . $ttH->conf['lang_cur'] . "' order by show_order desc, date_create desc"); $order_shipping = isset($arr_order_shipping[$order_info['shipping']]) ? $arr_order_shipping[$order_info['shipping']] : array(); $arr_order_method = $ttH->load_data->data_table('order_method', 'method_id', 'method_id,name_action,title', "is_show=1 and lang='" . $ttH->conf['lang_cur'] . "' and method_id='" . $order_info['method'] . "' order by show_order desc, date_create desc"); $order_method = isset($arr_order_method[$order_info['method']]) ? $arr_order_method[$order_info['method']] : array(); //Cập nhật trạng thái cho thanh toán online if (isset($order_method['name_action']) && $order_method['name_action'] != '') { $file = $ttH->conf['rootpath'] . 'modules' . DS . 'product' . DS . 'payment_method' . DS . $order_method['name_action'] . DS . 'payment.php'; if (file_exists($file)) { require_once $file; $payment = new Payment(); //Kiểm tra tính hợp lệ của link if ($payment->verifyResponseUrl($ttH->get) == TRUE) { //Kiểm tra tính hợp lệ của đơn hàng if ($order_info['order_code'] == $ttH->get['order_id']) { $col_up = array(); //Cập nhật thành trạng thái đã thanh toán $col_up["is_status"] = 2; $ttH->db->do_update("product_order", $col_up, " order_id='" . $order_info['order_id'] . "'"); } } } } //End $arr_cart = array(); $sql_cart = "select * \r\r\n\t\t\t\t\t\t\tfrom product_order_detail\r\r\n\t\t\t\t\t\t\twhere order_id='" . $order_info['order_id'] . "' "; //echo $sql_cart; $result_cart = $ttH->db->query($sql_cart); while ($row_cart = $ttH->db->fetch_row($result_cart)) { $arr_cart[$row_cart['detail_id']] = $row_cart; } $mail_arr_key = array('{list_cart}', '{o_full_name}', '{o_email}', '{o_phone}', '{o_address}', '{d_full_name}', '{d_email}', '{d_phone}', '{d_address}', '{shipping}', '{method}', '{request_more}', '{order_code}', '{date_create}'); $mail_arr_value = array($this->do_cart($order_info, $arr_cart, $arr_pro), $order_info["o_full_name"], $order_info["o_email"], $order_info["o_phone"], $order_info["o_address"], $order_info["d_full_name"], $order_info["d_email"], $order_info["d_phone"], $order_info["d_address"], isset($arr_order_shipping[$order_info['shipping']]) ? $arr_order_shipping[$order_info['shipping']]['title'] : '', isset($arr_order_method[$order_info['method']]) ? $arr_order_method[$order_info['method']]['title'] : '', $order_info["request_more"], $order_info["order_code"], $ttH->func->get_date_format($order_info["date_create"])); //send to admin $ttH->func->send_mail_temp('admin-ordering-complete', $ttH->conf['email'], $ttH->conf['email'], $mail_arr_key, $mail_arr_value); //send to customer $ttH->func->send_mail_temp('ordering-complete', $order_info['o_email'], $ttH->conf['email'], $mail_arr_key, $mail_arr_value); Session::Delete('ordering_payment'); } $data = array(); $data['link_action'] = $ttH->site->get_link('product', $ttH->setting['product']['ordering_friendly_link'], $ttH->setting['product']['ordering_complete_link']); $data['content'] = $ttH->site->get_banner('content'); $data['link_buy_more'] = $ttH->site->get_link('product'); $ttH->temp_act->assign('data', $data); $ttH->temp_act->parse("ordering_complete"); $output = $ttH->temp_act->text("ordering_complete"); return $output; }
function do_main() { global $ttH; /*if($ttH->site_func->check_user_login() != 1) { $link_method = $ttH->site->get_link ('product',$ttH->setting['product']['ordering_friendly_link'],$ttH->setting['product']['ordering_address_link']); $ttH->html->redirect_rel($link_method); }*/ if (isset($ttH->is_popup)) { $link_cart = $ttH->site_func->get_link_popup('product', 'cart'); $ordering_address_link = $ttH->site_func->get_link_popup('product', 'ordering_address'); $ordering_method_link = $ttH->site_func->get_link_popup('product', 'ordering_method'); $ordering_complete_link = $ttH->site_func->get_link_popup('product', 'ordering_complete'); } else { $link_cart = $ttH->site->get_link('product', $ttH->setting['product']['ordering_friendly_link'], $ttH->setting['product']['ordering_cart_link']); $ordering_address_link = $ttH->site->get_link('product', $ttH->setting['product']['ordering_friendly_link'], $ttH->setting['product']['ordering_address_link']); $ordering_method_link = $ttH->site->get_link('product', $ttH->setting['product']['ordering_friendly_link'], $ttH->setting['product']['ordering_method_link']); $ordering_complete_link = $ttH->site->get_link('product', $ttH->setting['product']['ordering_friendly_link'], $ttH->setting['product']['ordering_complete_link']); } $err = ''; //Get cart $arr_cart = Session::get('cart_pro', array()); $arr_cart_list_pro = Session::get('cart_list_pro'); $ordering_address = Session::Get('ordering_address', array()); if (count($ordering_address) == 0) { $link_go = $ordering_address_link; $ttH->html->redirect_rel($link_go); } if (!is_array($arr_cart) || !count($arr_cart) > 0) { $ttH->html->redirect_rel($link_cart); } //load order_method $order_shipping = $ttH->load_data->data_table('order_shipping', 'shipping_id', 'shipping_id,price,title,content', "is_show=1 and lang='" . $ttH->conf['lang_cur'] . "' order by show_order desc, date_create desc", array(), array('editor' => 'content')); $order_method = $ttH->load_data->data_table('order_method', 'method_id', '*', "is_show=1 and lang='" . $ttH->conf['lang_cur'] . "' order by show_order desc, date_create desc", array(), array('editor' => 'content')); if (isset($ttH->post['do_submit'])) { if (isset($ttH->post['shipping']) && isset($ttH->post['method'])) { $ordering_address['shipping'] = isset($ttH->post["shipping"]) && array_key_exists($ttH->post["shipping"], $order_shipping) ? $ttH->post["shipping"] : ''; $ordering_address['shipping_price'] = isset($order_shipping[$ordering_address['shipping']]['price']) ? $order_shipping[$ordering_address['shipping']]['price'] : 0; $ordering_address['method'] = isset($ttH->post["method"]) && array_key_exists($ttH->post["method"], $order_method) ? $ttH->post["method"] : ''; $ordering_address['request_more'] = isset($ttH->post["request_more"]) ? $ttH->post["request_more"] : ''; $ordering_address = Session::Set('ordering_address', $ordering_address); } else { //$arr_color = $ttH->load_data->data_table ('product_color', 'color_id', 'color_id,color,title', " is_show=1 and lang='".$ttH->conf['lang_cur']."' order by show_order desc, date_create desc"); //$arr_size = $ttH->load_data->data_table ('product_size', 'size_id', 'size_id,title', " is_show=1 and lang='".$ttH->conf['lang_cur']."' order by show_order desc, date_create desc"); $arr_pro = $ttH->load_data->data_table('product', 'item_id', 'item_id,picture,price_buy,title,friendly_link ', " is_show=1 and lang='" . $ttH->conf['lang_cur'] . "' and find_in_set(item_id,'" . @implode(',', $arr_cart_list_pro) . "')>0 order by show_order desc, date_create asc"); $col = array(); $arr_k = array('full_name', 'email', 'phone', 'address'); foreach ($arr_k as $k) { $col['o_' . $k] = isset($ordering_address['o_' . $k]) ? $ordering_address['o_' . $k] : ''; $col['d_' . $k] = isset($ordering_address['d_' . $k]) ? $ordering_address['d_' . $k] : ''; } if (empty($err)) { //promotion $err_promotion = ''; $promotion_percent = 0; $promotion_code = Session::get('promotion_code'); if (!empty($promotion_code)) { $sql = "select * \r\r\n\t\t\t\t\t\t\t\t\t\tfrom promotion \r\r\n\t\t\t\t\t\t\t\t\t\twhere is_show=1 \r\r\n\t\t\t\t\t\t\t\t\t\tand percent>0 \r\r\n\t\t\t\t\t\t\t\t\t\tand percent<100 \r\r\n\t\t\t\t\t\t\t\t\t\tand promotion_id='" . $promotion_code . "'"; //echo $sql; $result = $ttH->db->query($sql); if ($row_promotion = $ttH->db->fetch_row($result)) { if (!empty($row_promotion['order_id'])) { $err_promotion = $ttH->lang['product']['err_promotion_order']; Session::set('promotion_code', ''); $ttH->html->alert($err_promotion, $link_cart); } elseif (time() > $row_promotion['date_end']) { $err_promotion = $ttH->lang['product']['err_promotion_date_end']; Session::set('promotion_code', ''); $ttH->html->alert($err_promotion, $link_cart); } else { $promotion_percent = $row_promotion['percent']; } } else { Session::set('promotion_code', ''); } } $promotion_code = Session::get('promotion_code'); //End promotion //voucher $err_voucher = ''; $voucher_amount_has = 0; $gift_voucher = Session::get('gift_voucher'); if (!empty($gift_voucher)) { $sql = "select * \r\r\n\t\t\t\t\t\t\t\t\t\tfrom voucher \r\r\n\t\t\t\t\t\t\t\t\t\twhere is_show=1 \r\r\n\t\t\t\t\t\t\t\t\t\tand voucher_id='" . $gift_voucher . "'"; //echo $sql; $result = $ttH->db->query($sql); if ($row_voucher = $ttH->db->fetch_row($result)) { if ($row_voucher['amount'] <= $row_voucher['amount_use']) { $err_voucher = $ttH->lang['product']['err_gift_voucher_no_amount']; Session::set('gift_voucher', ''); $ttH->html->alert($err_voucher, $link_cart); } elseif (time() > $row_voucher['date_end']) { $err_voucher = $ttH->lang['product']['err_gift_voucher_date_end']; Session::set('gift_voucher', ''); $ttH->html->alert($err_voucher, $link_cart); } else { $voucher_amount_has = $row_voucher['amount'] - $row_voucher['amount_use']; } } else { Session::set('gift_voucher', ''); } } $gift_voucher = Session::get('gift_voucher'); //End voucher $col['shipping'] = isset($ordering_address['shipping']) && array_key_exists($ordering_address['shipping'], $order_shipping) ? $ordering_address['shipping'] : ''; $col['shipping_price'] = isset($order_shipping[$col['shipping']]['price']) ? $order_shipping[$col['shipping']]['price'] : 0; $col['method'] = isset($ordering_address['method']) && array_key_exists($ordering_address['method'], $order_method) ? $ordering_address['method'] : ''; $col["request_more"] = isset($ordering_address["request_more"]) ? $ordering_address["request_more"] : ''; $col["user_id"] = isset($ttH->data['user_cur']["user_id"]) ? $ttH->data['user_cur']["user_id"] : 0; $col["show_order"] = 0; $col["is_status"] = 1; $col["is_show"] = 1; $col["date_create"] = time(); $col["date_update"] = time(); /*print_arr($arr_cart); print_arr($col); die();*/ $ok = $ttH->db->do_insert("product_order", $col); //echo $ttH->db->debug(); if ($ok) { $order_id = $ttH->db->insertid(); $order_info = $col; $total_order = 0; if (is_array($arr_cart) && count($arr_cart) > 0) { foreach ($arr_cart as $cart_id => $row) { $row_pro = $arr_pro[$row['item_id']]; $col = array(); $col['order_id'] = $order_id; $col['type'] = 'product'; $col['type_id'] = isset($row_pro['item_id']) ? $row_pro['item_id'] : ''; $col['picture'] = isset($row_pro['picture']) ? $row_pro['picture'] : ''; $col['title'] = isset($row_pro['title']) ? $row_pro['title'] : ''; $col['price_buy'] = isset($row_pro['price_buy']) ? $row_pro['price_buy'] : 0; $col['quantity'] = isset($row['quantity']) ? $row['quantity'] : 0; $col['color_id'] = isset($row['color']) ? $row['color'] : 0; $col['size_id'] = isset($row['size']) ? $row['size'] : 0; $col['code_pic'] = isset($row['code_pic']) ? $row['code_pic'] : 0; $ttH->db->do_insert("product_order_detail", $col); $total_order += $col['price_buy'] * $col['quantity']; } } $total_payment = $total_order; //promotion_percent if ($promotion_percent > 0 && $promotion_percent < 100) { $total_payment = (100 - $promotion_percent) / 100 * $total_payment; } //end //shipping_price if ($order_info['shipping_price'] > 0) { $total_payment += $order_info['shipping_price']; } //End //voucher_amount $voucher_amount_has_use = $voucher_amount_has; if ($voucher_amount_has > $total_payment) { $voucher_amount_has_use = $total_payment; $total_payment = 0; } else { $total_payment -= $voucher_amount_has; } //end //update promotion $ttH->db->query("update promotion \r\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tset order_id='" . $order_id . "', \r\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdate_update=" . time() . " \r\r\n\t\t\t\t\t\t\t\t\t\t\t\t\twhere promotion_id='" . $promotion_code . "' "); //end //update voucher $ttH->db->query("update voucher \r\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tset amount_use=(amount_use+" . $voucher_amount_has_use . "), \r\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdate_update=" . time() . " \r\r\n\t\t\t\t\t\t\t\t\t\t\t\t\twhere voucher_id='" . $gift_voucher . "' "); //end //update product_order $col_up = array(); $col_up["order_code"] = $order_id . $ttH->func->random_str(5, 'u'); $col_up["total_order"] = $total_order; $col_up["promotion_id"] = $promotion_code; $col_up["promotion_percent"] = $promotion_percent; $col_up["voucher_id"] = $gift_voucher; $col_up["voucher_amount"] = $voucher_amount_has_use; $col_up["total_payment"] = $total_payment; $ttH->db->do_update("product_order", $col_up, " order_id='" . $order_id . "'"); $order_info = array_merge($order_info, $col_up); //end //write log $col_log = array(); $col_log["voucher_id"] = $gift_voucher; $col_log["order_code"] = $col_up["order_code"]; $col_log["amount_type"] = 'buy_product'; $col_log["amount"] = $voucher_amount_has_use; $col_log["amount_has"] = $voucher_amount_has - $voucher_amount_has_use; $col_log["date_create"] = time(); $ttH->db->do_insert("voucher_history", $col_log); //end //$order_method_info = $order_method[$order_info['method']]; $arr_cart = Session::set('ordering_payment', array('order_code' => $order_info['order_code'], 'method' => $order_info['method'], 'total_order' => $order_info['total_order'], 'total_payment' => $order_info['total_payment'], 'arr_cart_list_pro' => $arr_cart_list_pro, 'token' => $ttH->func->random_str(10))); Session::Delete('cart_pro'); Session::Delete('cart_list_pro'); Session::Delete('ordering_address'); Session::Delete('promotion_code'); Session::Delete('gift_voucher'); if (isset($order_method[$order_info['method']])) { $order_method_info = $order_method[$order_info['method']]; $file = $ttH->conf['rootpath'] . 'modules' . DS . 'product' . DS . 'payment_method' . DS . $order_method_info['name_action'] . DS . 'payment.php'; if (file_exists($file)) { require_once $file; $payment = new Payment(); $link_go = $payment->createRequestUrl($order_info['order_code'], $ttH->conf['email'], $order_info['total_payment'], '', '', '', $ttH->site->get_link('product', $ttH->setting['product']['ordering_friendly_link'], $ttH->setting['product']['ordering_complete_link']) . '/?order_id=' . $order_info['order_code'] . '&token_web=' . $arr_cart['token'], $ttH->site->get_link('product', $ttH->setting['product']['ordering_friendly_link'], $ttH->setting['product']['ordering_complete_link']) . '/?is_action=cancel', $ttH->site->get_link('home'), $order_info['o_full_name'], $order_info['o_email'], $order_info['o_phone'], $order_info['o_address']); $ttH->html->redirect_rel($link_go); } $link_go = $ordering_complete_link; $ttH->html->redirect_rel($link_go); } $link_go = $ordering_complete_link; $ttH->html->redirect_rel($link_go); } //End if ok } //End if err } //End else } //End if submit $output = ''; $data = $ordering_address; $data['content'] = $this->do_cart(); $data['content'] .= $this->do_address(); $data['shipping'] = isset($ordering_address['shipping']) && array_key_exists($ordering_address['shipping'], $order_shipping) ? $ordering_address['shipping'] : ''; $data['method'] = isset($ordering_address['method']) && array_key_exists($ordering_address['method'], $order_method) ? $ordering_address['method'] : ''; $data['request_more'] = isset($ordering_address['request_more']) ? $ordering_address['request_more'] : ''; if (!empty($data['shipping']) && !isset($ttH->get['change'])) { $data_tmp = $order_shipping[$ordering_address['shipping']]; if (isset($ttH->is_popup)) { $data_tmp['link_edit'] = $ordering_method_link . '&change=1'; } else { $data_tmp['link_edit'] = $ordering_method_link . '/?change=1'; } $data_tmp['price'] = $ttH->func->get_price_format($data_tmp['price'], 0); $ttH->temp_act->assign('data', $data_tmp); $ttH->temp_act->parse("ordering_method_shipping_statistic"); $data['content'] .= $ttH->temp_act->text("ordering_method_shipping_statistic"); } else { $data['content'] .= $this->do_shipping($data['shipping']); } if (!empty($data['method']) && !isset($ttH->get['change'])) { $data_tmp = $order_method[$ordering_address['method']]; if (isset($ttH->is_popup)) { $data_tmp['link_edit'] = $ordering_method_link . '&change=1'; } else { $data_tmp['link_edit'] = $ordering_method_link . '/?change=1'; } $ttH->temp_act->assign('data', $data_tmp); $ttH->temp_act->parse("ordering_method_method_statistic"); $data['content'] .= $ttH->temp_act->text("ordering_method_method_statistic"); } else { $data['content'] .= $this->do_method($data['method']); } if (!empty($data['request_more']) && !isset($ttH->get['change'])) { if (isset($ttH->is_popup)) { $link_edit = $ordering_method_link . '&change=1'; } else { $link_edit = $ordering_method_link . '/?change=1'; } $ttH->temp_act->assign('link_edit', $link_edit); $ttH->temp_act->assign('data', $data); $ttH->temp_act->parse("ordering_method.request_more_text"); } else { $ttH->temp_act->assign('data', $data); $ttH->temp_act->parse("ordering_method.request_more"); } $data['link_action'] = $ordering_method_link; $data['link_buy_more'] = $ttH->site->get_link('product'); $ttH->temp_act->assign('data', $data); $ttH->temp_act->parse("ordering_method"); $output .= $ttH->temp_act->text("ordering_method"); return $output; }
public function action_logout() { Auth::logout(); Session::Delete(); \Response::redirect('home'); }
function do_ordering_complete() { global $ttH; $ttH->func->load_language($this->modules); $ttH->temp_act = new XTemplate($ttH->path_html . $this->modules . DS . "popup.tpl"); $ttH->temp_act->assign('CONF', $ttH->conf); $ttH->temp_act->assign('LANG', $ttH->lang); $ttH->temp_act->assign('DIR_IMAGE', $ttH->dir_images); $ttH->func->include_css($ttH->dir_css . $this->modules . '/ordering.css'); $ttH->func->include_js($ttH->dir_js . 'jquery_plugins/jquery.validate.js'); $ttH->func->include_js($ttH->dir_skin . 'js/global/temp.js'); $ttH->func->include_js($ttH->dir_skin . 'js/location/location.js'); $ttH->func->include_js($ttH->dir_skin . 'js/user/user.js'); $ttH->func->include_js($ttH->dir_skin . 'js/' . $this->modules . '/ordering.js'); require_once $ttH->conf["rootpath"] . DS . "modules/" . $this->modules . "/seo_url_short.php"; require_once $ttH->conf["rootpath"] . DS . "modules/" . $this->modules . "/" . $this->modules . "_func.php"; $ordering_payment = Session::get('ordering_payment', array()); /*print_arr($ordering_payment); die();*/ if (!is_array($ordering_payment) || !count($ordering_payment) > 0) { $ttH->html->redirect_rel($ttH->site->get_link('home')); } $arr_pro = $ttH->load_data->data_table('product', 'item_id', 'item_id,picture,price_buy,title,friendly_link', " is_show=1 \n\t\t\tand lang='" . $ttH->conf['lang_cur'] . "' \n\t\t\tand find_in_set(item_id,'" . @implode(',', $ordering_payment['arr_cart_list_pro']) . "')>0 \n\t\t\torder by show_order desc, date_create asc"); $sql = "select * \n\t\t\t\t\t\tfrom product_order \n\t\t\t\t\t\twhere order_code='" . $ordering_payment['order_code'] . "' "; //echo $sql; $result = $ttH->db->query($sql); if ($order_info = $ttH->db->fetch_row($result)) { $arr_order_shipping = $ttH->load_data->data_table('order_shipping', 'shipping_id', 'shipping_id,title,content', "shipping_id='" . $order_info['shipping'] . "' and lang='" . $ttH->conf['lang_cur'] . "' order by show_order desc, date_create desc"); $order_shipping = isset($arr_order_shipping[$order_info['shipping']]) ? $arr_order_shipping[$order_info['shipping']] : array(); $arr_order_method = $ttH->load_data->data_table('order_method', 'method_id', 'method_id,name_action,title', "is_show=1 and lang='" . $ttH->conf['lang_cur'] . "' and method_id='" . $order_info['method'] . "' order by show_order desc, date_create desc"); $order_method = isset($arr_order_method[$order_info['method']]) ? $arr_order_method[$order_info['method']] : array(); //Cập nhật trạng thái cho thanh toán online if (isset($order_method['name_action']) && $order_method['name_action'] != '') { $file = $ttH->conf['rootpath'] . 'modules' . DS . 'product' . DS . 'payment_method' . DS . $order_method['name_action'] . DS . 'payment.php'; if (file_exists($file)) { require_once $file; $payment = new Payment(); //Kiểm tra tính hợp lệ của link if ($payment->verifyResponseUrl($ttH->get) == TRUE) { //Kiểm tra tính hợp lệ của đơn hàng if ($order_info['order_code'] == $ttH->get['order_id']) { $col_up = array(); //Cập nhật thành trạng thái đã thanh toán $col_up["is_status"] = 2; $ttH->db->do_update("product_order", $col_up, " order_id='" . $order_info['order_id'] . "'"); } } } } //End $arr_cart = array(); $sql_cart = "select * \n\t\t\t\t\t\t\tfrom product_order_detail \n\t\t\t\t\t\t\twhere order_id='" . $order_info['order_id'] . "' "; //echo $sql_cart; $result_cart = $ttH->db->query($sql_cart); while ($row_cart = $ttH->db->fetch_row($result_cart)) { $arr_cart[$row_cart['detail_id']] = $row_cart; } $mail_arr_key = array('{list_cart}', '{o_full_name}', '{o_email}', '{o_phone}', '{o_full_address}', '{d_full_name}', '{d_email}', '{d_phone}', '{d_full_address}', '{shipping}', '{method}', '{request_more}', '{order_code}', '{date_create}'); $mail_arr_value = array($this->_cart_mail($order_info, $arr_cart, $arr_pro), $order_info["o_full_name"], $order_info["o_email"], $order_info["o_phone"], $ttH->func->full_address($order_info, 'o_'), $order_info["d_full_name"], $order_info["d_email"], $order_info["d_phone"], $ttH->func->full_address($order_info, 'd_'), isset($arr_order_shipping[$order_info['shipping']]) ? $arr_order_shipping[$order_info['shipping']]['title'] : '', isset($arr_order_method[$order_info['method']]) ? $arr_order_method[$order_info['method']]['title'] : '', $order_info["request_more"], $order_info["order_code"], $ttH->func->get_date_format($order_info["date_create"])); //send to admin $ttH->func->send_mail_temp('admin-ordering-complete', $ttH->conf['email'], $ttH->conf['email'], $mail_arr_key, $mail_arr_value); //send to customer $ttH->func->send_mail_temp('ordering-complete', $order_info['o_email'], $ttH->conf['email'], $mail_arr_key, $mail_arr_value); Session::Delete('ordering_payment'); } $data = array(); $data['content'] = $ttH->site->get_banner('ordering-complete'); $ttH->temp_act->assign('data', $data); $ttH->temp_act->parse("ordering_complete"); $output = $ttH->temp_act->text("ordering_complete"); return $output; }
public function Logout() { if (isset($_COOKIE[Token::COOKIE])) { Token::Delete($_COOKIE[Token::COOKIE]); } Session::Delete($this); static::$is_member = null; static::$is_staff = null; static::$is_admin = null; }
function do_cart() { global $ttH; //$arr_cart = $ttH->cookie->get_cookie ('cart'); $arr_cart = Session::get('cart_pro', array()); $arr_cart_list_pro = Session::get('cart_list_pro'); Session::Delete('ordering_address'); $arr_color = $ttH->load_data->data_table('product_color', 'color_id', 'color_id,color,title', "\tlang='" . $ttH->conf['lang_cur'] . "' order by show_order desc, date_create desc"); $arr_size = $ttH->load_data->data_table('product_size', 'size_id', 'size_id,title', "\tlang='" . $ttH->conf['lang_cur'] . "' order by show_order desc, date_create desc"); $err = ''; if (isset($ttH->post['item_id'])) { $item_id = $ttH->post['item_id'] > 0 ? $ttH->post['item_id'] : 0; $color = isset($ttH->post['color']) ? $ttH->post['color'] : 0; $size = isset($ttH->post['size']) ? $ttH->post['size'] : 0; //$code_pic = (isset($ttH->post['code_pic'])) ? $ttH->post['code_pic'] : 0; if (isset($ttH->post['combine'])) { $combine = explode('_', $ttH->post['combine']); $color = isset($combine[0]) && $combine[0] > 0 ? $combine[0] : 0; $size = isset($combine[1]) && $combine[1] > 0 ? $combine[1] : 0; } $quantity = isset($ttH->post['quantity']) && $ttH->post['quantity'] > 0 ? $ttH->post['quantity'] : 1; if ($item_id > 0) { $cart_id = md5($item_id . '_c' . $color . '_s' . $size); //$cart_id = md5($item_id.'_c'.$color.'_cp'.$code_pic); $arr_tmp = array('item_id' => $item_id, 'color' => $color, 'size' => $size, 'quantity' => $quantity); $check_quantity = isset($arr_cart[$cart_id]['quantity']) ? $arr_cart[$cart_id]['quantity'] + $quantity : $quantity; $num_max = $ttH->site_func->check_in_stock(array('type_id' => $item_id), array('size_id' => $size)); if ($num_max < $check_quantity) { if ($size > 0) { $err = $ttH->html->html_alert(str_replace(array('{item}', '{num_has}', '{size}'), array('{product_' . $item_id . '}', $num_max, $arr_size[$size]['title']), $ttH->lang['global']['err_in_stock_size']), 'warning'); } else { $err = $ttH->html->html_alert(str_replace(array('{item}', '{num_has}'), array('{product_' . $item_id . '}', $num_max), $ttH->lang['global']['err_in_stock']), 'warning'); } $quantity = 0; if (isset($arr_cart[$cart_id])) { $arr_cart[$cart_id]['quantity'] = $arr_tmp['quantity']; } else { $arr_tmp['quantity'] = $num_max; } } $arr_cart_list_pro[$item_id] = $item_id; if (isset($arr_cart[$cart_id])) { $arr_cart[$cart_id]['quantity'] += $quantity; } else { $arr_cart[$cart_id] = $arr_tmp; } $arr_cart = Session::set('cart_pro', $arr_cart); $arr_cart_list_pro = Session::set('cart_list_pro', $arr_cart_list_pro); } } /*print_arr($arr_cart); print_arr($arr_cart_list_pro); print_arr($gift_voucher); print_arr($ttH->post);*/ //die('aaa'); $arr_pro = array(); $sql = "select item_id,picture,price_buy,title,friendly_link \r\r\n\t\t\t\t\t\tfrom product \r\r\n\t\t\t\t\t\twhere is_show=1 \r\r\n\t\t\t\t\t\tand find_in_set(item_id,'" . @implode(',', $arr_cart_list_pro) . "')>0 \r\r\n\t\t\t\t\t\torder by show_order desc, date_create asc"; //echo $sql; $result = $ttH->db->query($sql); $html_row = ""; while ($row = $ttH->db->fetch_row($result)) { $arr_pro[$row['item_id']] = $row; if (isset($ttH->post['item_id']) && $ttH->post['item_id'] == $row['item_id'] && !empty($err)) { $err = str_replace('{product_' . $ttH->post['item_id'] . '}', $row['title'], $err); } } $data = array(); $data['cart_total'] = 0; if (is_array($arr_cart) && count($arr_cart > 0)) { foreach ($arr_cart as $cart_id => $row) { $row_pro = isset($row['item_id']) ? $arr_pro[$row['item_id']] : array(); $row['cart_id'] = $cart_id; $row['pic_w'] = 50; $row['pic_h'] = 50; $row['picture'] = isset($row_pro['picture']) ? $row_pro['picture'] : ''; $row["picture"] = $ttH->func->get_src_mod($row["picture"], $row['pic_w'], $row['pic_h'], 1, 0, array('fix_max' => 1)); $row['price_buy'] = isset($row_pro['price_buy']) ? $row_pro['price_buy'] : 0; $row['title'] = isset($row_pro['title']) ? $row_pro['title'] : ''; $row['quantity'] = isset($row['quantity']) ? $row['quantity'] : 0; $row['total'] = $row['quantity'] * $row['price_buy']; $data['cart_total'] += $row['total']; $row['color'] = isset($row['color']) && array_key_exists($row['color'], $arr_color) ? $row['color'] : 0; $color = isset($arr_color[$row['color']]['color']) ? '<div><span class="color" style="background:' . $arr_color[$row['color']]['color'] . ';"> </span></div>' : ''; $row['color'] = isset($arr_color[$row['color']]['title']) ? $color . $arr_color[$row['color']]['title'] : ''; $row['size'] = isset($row['size']) && array_key_exists($row['size'], $arr_size) ? $row['size'] : 0; $row['size'] = isset($arr_size[$row['size']]['title']) ? $arr_size[$row['size']]['title'] : ''; /*$row['code_pic'] = (isset($row['code_pic']) && array_key_exists($row['code_pic'], $arr_code_pic)) ? $row['code_pic'] : 0; $code_pic = (isset($arr_code_pic[$row['code_pic']]['code_pic'])) ? '<div><span class="code_pic" style="background:'.$arr_code_pic[$row['code_pic']]['code_pic'].';"> </span></div>' : ''; $row['code_pic'] = (isset($arr_code_pic[$row['code_pic']]['title'])) ? $code_pic.$arr_code_pic[$row['code_pic']]['title'] : '';*/ $row['price_buy_text'] = $ttH->func->get_price_format($row['price_buy']); $row['quantity_text'] = list_quantity('quantity[]', $row['quantity'], ' for="' . $cart_id . '" class="quantity"'); $row['total'] = $ttH->func->get_price_format($row['total']); $ttH->temp_act->assign('row', $row); $ttH->temp_act->parse("table_cart.row_item"); } } else { $ttH->temp_act->assign('row', array('mess' => $ttH->lang['product']['no_have_item'])); $ttH->temp_act->parse("table_cart.row_empty"); } //promotion $err_promotion = ''; $promotion_percent = 0; $promotion_code = isset($ttH->post['promotional_code']) ? $ttH->post['promotional_code'] : Session::get('promotion_code'); if ($data['cart_total'] >= $ttH->setting['voucher']['min_cart_promotion']) { if (!empty($promotion_code)) { $sql = "select * \r\r\n\t\t\t\t\t\t\t\tfrom promotion \r\r\n\t\t\t\t\t\t\t\twhere is_show=1 \r\r\n\t\t\t\t\t\t\t\tand percent>0 \r\r\n\t\t\t\t\t\t\t\tand percent<100 \r\r\n\t\t\t\t\t\t\t\tand promotion_id='" . $promotion_code . "'"; //echo $sql; $result = $ttH->db->query($sql); if ($row_promotion = $ttH->db->fetch_row($result)) { if (!empty($row_promotion['order_id'])) { $err_promotion = $ttH->lang['product']['err_promotion_order']; } elseif (time() > $row_promotion['date_end']) { $err_promotion = $ttH->lang['product']['err_promotion_date_end']; } else { $promotion_percent = $row_promotion['percent']; $gift_promotion = Session::set('promotion_code', $row_promotion['promotion_id']); } } else { Session::set('promotion_code', ''); } } $promotion_code = Session::get('promotion_code'); } elseif (!empty($promotion_code)) { $err_promotion = str_replace('{min_cart}', $ttH->func->get_price_format($ttH->setting['voucher']['min_cart_promotion'], 0), $ttH->lang['global']['err_promotion_min_cart']); Session::set('promotion_code', ''); } //End promotion //voucher $err_voucher = ''; $voucher_amount_has = 0; $gift_voucher = isset($ttH->post['gift_voucher']) ? $ttH->post['gift_voucher'] : Session::get('gift_voucher'); if (!empty($gift_voucher)) { $sql = "select * \r\r\n\t\t\t\t\t\t\tfrom voucher \r\r\n\t\t\t\t\t\t\twhere is_show=1 \r\r\n\t\t\t\t\t\t\tand voucher_id='" . $gift_voucher . "'"; //echo $sql; $result = $ttH->db->query($sql); if ($row_voucher = $ttH->db->fetch_row($result)) { if ($row_voucher['amount'] <= $row_voucher['amount_use']) { $err_voucher = $ttH->lang['product']['err_gift_voucher_no_amount']; } elseif (time() > $row_voucher['date_end']) { $err_voucher = $ttH->lang['product']['err_gift_voucher_date_end']; } else { $voucher_amount_has = $row_voucher['amount'] - $row_voucher['amount_use']; $gift_voucher = Session::set('gift_voucher', $row_voucher['voucher_id']); } } else { Session::set('gift_voucher', ''); } } $gift_voucher = Session::get('gift_voucher'); //End voucher $data['cart_payment'] = $data['cart_total']; if ($promotion_percent > 0 && $promotion_percent < 100) { $data['cart_payment'] = (100 - $promotion_percent) / 100 * $data['cart_payment']; } $voucher_amount_has_out = $voucher_amount_has; if ($voucher_amount_has > $data['cart_payment']) { $voucher_amount_has_out = $data['cart_payment']; $data['cart_payment'] = 0; } else { $data['cart_payment'] -= $voucher_amount_has; } $data['cart_total'] = $ttH->func->get_price_format($data['cart_total'], 0); $data['min_cart_promotion'] = $ttH->setting['voucher']['min_cart_promotion']; $data['promotion_percent'] = $promotion_percent; $data['voucher_amount'] = $voucher_amount_has; $data['voucher_amount_out'] = $ttH->func->get_price_format($voucher_amount_has_out, 0); $data['cart_payment'] = $ttH->func->get_price_format($data['cart_payment'], 0); if (isset($ttH->is_popup)) { $data['link_action'] = $ttH->site_func->get_link_popup($this->modules, $this->action); $data['link_ordering_address'] = $ttH->site_func->get_link_popup($this->modules, 'ordering_address'); $data['link_buy_more'] = '#'; } else { $data['link_action'] = $ttH->site->get_link($this->modules, $ttH->setting[$this->modules]['ordering_friendly_link'], $ttH->setting[$this->modules]['ordering_cart_link']); $data['link_ordering_address'] = $ttH->site->get_link($this->modules, $ttH->setting[$this->modules]['ordering_friendly_link'], $ttH->setting[$this->modules]['ordering_address_link']); $data['link_buy_more'] = $ttH->site->get_link($this->modules); } $data['err'] = $err; $data['err_promotion'] = !empty($err_promotion) ? '<div class="error">' . $err_promotion . '</div>' : ''; $data['err_voucher'] = !empty($err_voucher) ? '<div class="error">' . $err_voucher . '</div>' : ''; $ttH->temp_act->assign('data', $data); $ttH->temp_act->parse("table_cart"); return $ttH->temp_act->text("table_cart"); }
if ($_REQUEST['user'] == 'login') { if (trim($_REQUEST['username']) != '' && trim($_REQUEST['password']) != '') { if ($database->Query("SELECT COUNT(*) FROM user WHERE username='******'username']}';")) { if ($database->Query("SELECT COUNT(*) FROM user WHERE username='******'username']}' AND password='******'password']}';")) { $error = NULL; $user = $database->Query("SELECT * FROM user WHERE username='******'username']}' AND password='******'password']}' LIMIT 1;"); $level = $database->Query("SELECT * FROM user_level WHERE level_id='{$user['level_id']}' LIMIT 1;"); $text = _LOGIN_TITLE . '<strong>' . $user['fullname'] . '</strong> | ' . _LOGIN_LEVEL . $level['level']; $timeCookie = 0; if ($user['level_id'] == 4) { $timeCookie = 0; } $session->setCookie('USER', $user['user_id'], $timeCookie); $session->setCookie('LEVEL', $user['level_id'], $timeCookie); } else { $error .= _LOGIN_ERROR_PASSWORD; } } else { $error .= _LOGIN_ERROR_USERNAME; } } else { $error .= _LOGIN_ERROR_NULL; } echo json_encode(array('error' => $error, 'text' => $text)); } elseif ($_REQUEST['user'] == 'logout') { $session->Delete('USER'); $session->Delete('LEVEL'); echo json_encode(array('')); } elseif ($_REQUEST['user'] == 'register') { echo json_encode(array('')); }
echo _INPUT_LOGIN; ?> " maxlength="20" /></div> <div align="right"><input type="submit" id="login" name="login_submit" value="<?php echo _INPUT_SUBMIT; ?> " disabled="disabled" /></div></form> </td> </tr> <tr> <td colspan="2" valign="top"> <div align="center" style="background-color:#3c3c3c; height:30px; margin:3px; padding:7px 10px 0 5px; color:#E00; font-weight:bold" id="error_massage"> <?php if ($control->Value('LOGIN_VAILD')) { echo _SUBMIT_TIMEUP; $control->Delete('LOGIN_VAILD'); } ?> </div> </td> </tr> </table> </td> </tr> <tr><td id="module_below"></td></tr></table></div> <br /><p><hr width="80%" /><center><?php echo _SITE_FOOTER; ?> </center></p><br /> </td> </tr>
// Test access token if (!$fb->IsATValid($accessToken)) { logs::Save($scheduled->id, lang('INVALID_ACCESS_TOKEN')); } else { // Send post and get the result $result = (object) $fb->Post($groups[$scheduled->next_target], $params, $postType, $accessToken); // Save log if (isset($result->status)) { if (isset($result->id)) { logs::Save($scheduled->id, "<a href='https://www.facebook.com/" . $result->id . "' target='_blank'><span class='glyphicon glyphicon-ok'></span> " . lang('VIEW_POST') . " </a>"); } else { if ($groups[$scheduled->next_target] == "me") { logs::Save($scheduled->id, "Your timeline - " . $result->message); } else { logs::Save($scheduled->id, $result->message . " <a href='https://www.facebook.com/groups/" . $groups[$scheduled->next_target] . "' target='_blank'><span class='glyphicon glyphicon-eye-open'></span> " . lang('VISIT_GROUP') . " </a>"); } } } else { logs::Save($scheduled->id, lang('UNKNOWN_ERROR')); } } // Access token is valid } // The post is ready } // There is a post must be posted } } // Delete the session Session::Delete('scheduleInProcess');