/** * Order validation */ function _order_validate_select_payment() { module('shop')->_order_validate_delivery(); if (!$_POST["pay_type"] || !isset(module('shop')->_pay_types[$_POST["pay_type"]])) { _re("Wrong payment type"); } }
/** * Order step */ function _order_step_start($FORCE_DISPLAY_FORM = false) { module('shop')->_basket_save(); $basket_contents = module('shop')->_basket_api()->get_all(); $products_ids = []; foreach ((array) $basket_contents as $_item_id => $_info) { if ($_info["product_id"]) { $products_ids[$_info["product_id"]] = $_info["product_id"]; } } if (!empty($products_ids)) { $products_infos = db()->query_fetch_all("SELECT * FROM " . db('shop_products') . " WHERE id IN(" . implode(",", $products_ids) . ") AND active='1'"); $products_atts = module('shop')->_products_get_attributes($products_ids); $group_prices = module('shop')->_get_group_prices($products_ids); } $total_price = 0; foreach ((array) $products_infos as $_info) { $_product_id = $_info["id"]; $_info["_group_price"] = $group_prices[$_product_id][module('shop')->USER_GROUP]; $quantity = $basket_contents[$_info["id"]]["quantity"]; $price = module('shop')->_product_get_price($_info); $dynamic_atts = []; foreach ((array) $products_atts[$_product_id] as $_attr_id => $_attr_info) { if ($basket_contents[$_product_id]["atts"][$_attr_info["name"]] == $_attr_info["value"]) { $dynamic_atts[$_attr_id] = "- " . $_attr_info["name"] . " " . $_attr_info["value"]; $price += $_attr_info["price"]; } } $URL_PRODUCT_ID = module('shop')->_product_id_url($_info); $products[$_info["id"]] = ["name" => _prepare_html($_info["name"]), "price" => module('shop')->_format_price($price), "currency" => _prepare_html(module('shop')->CURRENCY), "quantity" => intval($quantity), "details_link" => process_url("./?object=shop&action=product_details&id=" . $URL_PRODUCT_ID), "dynamic_atts" => !empty($dynamic_atts) ? implode("\n<br />", $dynamic_atts) : "", "cat_name" => _prepare_html(module('shop')->_shop_cats[$_info["cat_id"]]), "cat_url" => process_url("./?object=shop&action=products_show&id=" . module('shop')->_shop_cats_all[$_info["cat_id"]]['url'])]; $total_price += $price * $quantity; } $replace = ["products" => $products, "total_price" => module('shop')->_format_price($total_price), "currency" => _prepare_html(module('shop')->CURRENCY), "back_link" => "./?object=shop&action=basket", "next_link" => "./?object=shop&action=order&id=delivery", "cats_block" => module('shop')->_categories_show()]; return tpl()->parse("shop/order_start", $replace); }
function _products_get_attributes($products_ids = []) { if (is_numeric($products_ids)) { $return_single_id = $products_ids; $products_ids = [$products_ids]; } if (empty($products_ids)) { return []; } $fields_info = main()->get_data("shop_product_attributes_info"); $Q = db()->query("SELECT * FROM " . db('shop_product_attributes_values') . " WHERE category_id=1 AND object_id IN (" . implode(",", $products_ids) . ")"); while ($A = db()->fetch_assoc($Q)) { $_product_id = $A["object_id"]; $A["value"] = strlen($A["value"]) ? unserialize($A["value"]) : []; $A["add_value"] = strlen($A["add_value"]) ? unserialize($A["add_value"]) : []; foreach ((array) $A["value"] as $_attr_id => $_dummy) { $_price = $A["add_value"][$_attr_id]; $_item_id = $A["field_id"] . "_" . $_attr_id; $_field_info = $fields_info[module("shop")->ATTRIBUTES_CAT_ID][$A["field_id"]]; $_field_info["value_list"] = strlen($_field_info["value_list"]) ? unserialize($_field_info["value_list"]) : []; $data[$_product_id][$_item_id] = ["id" => $_item_id, "price" => $_price, "name" => $_field_info["name"], "value" => $_field_info["value_list"][$_attr_id], "product_id" => $_product_id]; } } if ($return_single_id) { return $data[$return_single_id]; } return $data; }
/** * Order step */ function _order_step_do_payment($FORCE_DISPLAY_FORM = false) { $basket_contents = module('shop')->_basket_api()->get_all(); if (module('shop')->FORCE_PAY_METHOD) { $_POST["pay_type"] = module('shop')->FORCE_PAY_METHOD; } // Show previous form if needed if (common()->_error_exists() || empty($_POST)) { return module('shop')->_order_step_select_payment(); } $ORDER_ID = intval($_POST["order_id"] ? $_POST["order_id"] : module('shop')->_CUR_ORDER_ID); if (empty($ORDER_ID)) { _re("Missing order ID"); } // Get order info $order_info = db()->query_fetch("SELECT * FROM " . db('shop_orders') . " WHERE id=" . intval($ORDER_ID) . " AND user_id=" . intval(main()->USER_ID) . " AND status='pending'"); if (empty($order_info["id"])) { _re("Missing order record"); } // Payment by courier, skip next step if (!common()->_error_exists() && $_POST["pay_type"] == 1 or $_POST["pay_type"] == 3 or $_POST["pay_type"] == 4) { module('shop')->_basket_api()->clean(); return js_redirect("./?object=shop&action=" . $_GET["action"] . "&id=finish&page=" . intval($ORDER_ID)); } // Authorize.net payment type if ($_POST["pay_type"] == 2) { module('shop')->_basket_api()->clean(); return module('shop')->_order_pay_authorize_net($order_info); } }
/** */ function edit() { $replace = _class('admin_methods')->edit($this->_table); $data = []; if ($replace['linked_data']) { $data = main()->get_data($replace['linked_data']); } elseif ($replace['linked_table']) { $q = db()->query('SELECT id, name FROM `' . db($replace['linked_table']) . '` ORDER BY name ASC'); while ($a = db()->fetch_assoc($q)) { $data[$a['id']] = $a['name']; } } elseif ($replace['linked_method']) { list($module, $method) = explode('.', trim($replace['linked_method'])); $module_obj = module($module); if (method_exists($module_obj, $method)) { $data = $module_obj->{$method}(); } } $form = form($replace); $form->info('name'); if ($data) { $form->select_box('value', $data); } else { $form->text('value'); } $form->textarea('desc'); $form->save_and_back(); return $form; }
function product_details() { if (!$_GET["id"]) { return is_redirect("./?object=shop"); } // Get products from database if (is_numeric($_GET["id"])) { $add_sql = "id= '" . intval($_GET["id"]); } else { $add_sql = "url='" . _es($_GET['id']); } $sql = "SELECT * FROM " . db('shop_products') . " WHERE active='1' AND " . $add_sql . "'"; $product_info = db()->query_fetch($sql); // Required for comments module("shop")->_comments_params["object_id"] = $product_info["id"]; module("shop")->_comments_params["objects_ids"] = $product_info["id"]; $N = module("shop")->_get_num_comments(); $N = $N[$product_info["id"]]; if ($N == "") { $N = 0; } $dirs = sprintf("%06s", $product_info["id"]); $dir2 = substr($dirs, -3, 3); $dir1 = substr($dirs, -6, 3); $mpath = $dir1 . "/" . $dir2 . "/"; $group_prices = module("shop")->_get_group_prices($product_info["id"]); $product_info["_group_price"] = $group_prices[module("shop")->USER_GROUP]; module("shop")->_product_info = $product_info; $atts = module("shop")->_products_get_attributes($product_info["id"]); $thumb_path = $product_info["url"] . "_" . $product_info["id"] . "_" . $product_info["image"] . module("shop")->THUMB_SUFFIX . ".jpg"; $img_path = $product_info["url"] . "_" . $product_info["id"] . "_" . $product_info["image"] . module("shop")->FULL_IMG_SUFFIX . ".jpg"; if ($product_info["image"] == 0) { $image = ""; } else { $image_files = _class('dir')->scan_dir(module("shop")->products_img_dir . $mpath, true, "/" . $product_info["url"] . "_" . $product_info["id"] . ".+?_small\\.jpg" . "/"); $reg = "/" . $product_info["url"] . "_" . $product_info["id"] . "_(?P<content>[\\d]+)_small\\.jpg/"; foreach ((array) $image_files as $filepath) { preg_match($reg, $filepath, $rezult); $i = $rezult["content"]; if ($i != $product_info["image"]) { $thumb_temp = module("shop")->products_img_webdir . $mpath . $product_info["url"] . "_" . $product_info["id"] . "_" . $i . module("shop")->THUMB_SUFFIX . ".jpg"; $img_temp = module("shop")->products_img_webdir . $mpath . $product_info["url"] . "_" . $product_info["id"] . "_" . $i . module("shop")->FULL_IMG_SUFFIX . ".jpg"; $replace2 = ["thumb_path" => $thumb_temp, "img_path" => $img_temp, "name" => $product_info["url"]]; $image .= tpl()->parse("shop/image_items", $replace2); } } } $URL_PRODUCT_ID = module("shop")->_product_id_url($product_info); $sql_man = "SELECT * FROM " . db('shop_manufacturers') . " WHERE id = " . $product_info["manufacturer_id"]; $manufacturer = db()->query_fetch($sql_man); if (module("shop")->SHOW_products_similar_by_price == true) { $products_similar_by_price = module("shop")->products_similar_by_price($product_info["price"], $product_info["id"]); } if (module("shop")->products_similar_by_basket == true) { $products_similar_by_basket = module("shop")->products_similar_by_basket($product_info["id"]); } $replace = ["name" => _prepare_html($product_info["name"]), "model" => _prepare_html($product_info["model"]), "desc" => $product_info["description"], "manufacturer" => _prepare_html(module("shop")->_manufacturer[$product_info["manufacturer_id"]]["name"]), "url_manufacturer" => process_url("./?object=shop&action=products_show&id=" . module("shop")->_manufacturer[$product_info["manufacturer_id"]]["url"]), "date" => _format_date($product_info["add_date"], "long"), "price" => module("shop")->_format_price(module("shop")->_product_get_price($product_info)), "currency" => _prepare_html(module("shop")->CURRENCY), "thumb_path" => file_exists(module("shop")->products_img_dir . $mpath . $img_path) ? module("shop")->products_img_webdir . $mpath . $img_path : "", "img_path" => file_exists(module("shop")->products_img_dir . $mpath . $img_path) ? module("shop")->products_img_webdir . $mpath . $img_path : "", "image" => $image, "basket_add_url" => $product_info["external_url"] ? $product_info["external_url"] : process_url("./?object=shop&action=basket_add&id=" . $URL_PRODUCT_ID), "external_url" => intval((bool) $product_info["external_url"]), "back_url" => process_url("./?object=shop"), "show_basket_url" => process_url("./?object=shop&action=basket"), "dynamic_atts" => module("shop")->_get_select_attributes($atts), "cats_block" => module("shop")->_categories_show(), "cat_name" => _prepare_html(module("shop")->_shop_cats[$product_info["cat_id"]]), "cat_url" => process_url("./?object=shop&action=product_details&id=" . module("shop")->_shop_cats_all[$product_info["cat_id"]]['url']), 'comments' => module("shop")->_view_comments(), "N" => $N, "products_similar_by_price" => $products_similar_by_price, "products_similar_by_basket" => $products_similar_by_basket, "product_related" => module("shop")->products_related($product_info["id"])]; db()->query("UPDATE " . db('shop_products') . " SET viewed = viewed+1 , last_viewed_date = " . time() . " WHERE " . $add_sql . "'"); return tpl()->parse("shop/details", $replace); }
/** */ function add_comment($params = []) { if ($_POST['submit'] == 'Preview') { return module('preview')->_display_preview(['text' => $_POST['text']]); } return module('comments')->_add((array) $this->_comments_params + (array) $params); }
function _get_select_attributes($atts = []) { if (empty($atts)) { return []; } // Group by attribute name $_atts_by_name = []; foreach ((array) $atts as $_info) { $_atts_products_ids[$_info["name"]] = $_info["product_id"]; $_price_text = " (" . ($_info["price"] < 0 ? "-" : "+") . module("shop")->_format_price(abs($_info["price"])) . ")"; $_atts_by_name[$_info["name"]][$_info["value"]] = $_info["value"] . ($_info["price"] ? $_price_text : ""); } $result = []; foreach ((array) $_atts_by_name as $_name => $_info) { $_product_id = $_atts_products_ids[$_name]; $_box = ""; $_box_name = "atts[" . intval($_product_id) . "][" . $_name . "]"; if (count($_info) > 1) { $_box = common()->select_box($_box_name, $_info, $selected, false, 2, "", false); } else { $_box = current($_info) . "\n<input type=\"hidden\" name=\"" . $_box_name . "\" value=\"" . _prepare_html(current($_info)) . "\" />"; } $result[$_name] = ["name" => _prepare_html($_name), "box" => $_box]; } return $result; }
/** * Order step */ function _order_step_delivery($FORCE_DISPLAY_FORM = false) { // Validate previous form if (main()->is_post() && !$FORCE_DISPLAY_FORM) { module('shop')->_order_validate_delivery(); // Display next form if we have no errors if (!common()->_error_exists()) { return module('shop')->_order_step_select_payment(true); } } if (main()->USER_ID) { $order_info = module('shop')->_user_info; } // Fill fields foreach ((array) module('shop')->_b_fields as $_field) { $replace[$_field] = _prepare_html(isset($_POST[$_field]) ? $_POST[$_field] : module('shop')->_user_info[substr($_field, 2)]); } // Fill shipping from billing foreach ((array) module('shop')->_s_fields as $_field) { if (module('shop')->_user_info["shipping_same"] && !isset($_POST[$_field])) { $s_field = "b_" . substr($_field, 2); $replace[$_field] = _prepare_html(isset($_POST[$s_field]) ? $_POST[$s_field] : module('shop')->_user_info[$s_field]); } else { $replace[$_field] = _prepare_html(isset($_POST[$_field]) ? $_POST[$_field] : module('shop')->_user_info[$_field]); } } $force_ship_type = module('shop')->FORCE_GROUP_SHIP[module('shop')->USER_GROUP]; $SELF_METHOD_ID = substr(__FUNCTION__, strlen("_order_step_")); $replace = my_array_merge((array) $replace, ["form_action" => "./?object=shop&action=" . $_GET["action"] . "&id=" . $SELF_METHOD_ID, "error_message" => _e(), "ship_type_box" => module('shop')->_box("ship_type", $force_ship_type ? $force_ship_type : $_POST["ship_type"]), "back_link" => "./?object=shop&action=order", "cats_block" => module('shop')->_categories_show()]); return tpl()->parse("shop/order_delivery", $replace); }
function _manufacturer_show() { // Prepare manufacturer $replace = ["brand" => module("shop")->_manufacturer, "manufacturer_box" => common()->select_box("manufacturer", module("shop")->_man_for_select, $_SESSION['man_id'], false, 2), "url_manufacturer" => process_url("./?object=shop&action=products_show")]; unset($_SESSION["man_id"]); return tpl()->parse("shop/manufacturer", $replace); }
function command_parse() { global $DB, $Core, $Parse, $Security, $Base, $Style; if (!$Security->allowed()) { return; } $include = implode("/", module()); if (file_exists("module/{$include}/main.php")) { $dir = ""; foreach (module() as $module) { $dir .= "{$module}/"; $shared = "module/{$dir}shared.php"; if (file_exists($shared)) { include $shared; } } require_once "module/{$include}/main.php"; if (function_exists(command())) { eval(command() . "();"); } if (file_exists("module/{$include}/.content/" . func() . ".php")) { if (!get('ajax') && !get('xml')) { require_once "module/{$include}/.content/" . func() . ".php"; } } } else { $Base = new Base(); $Base->title("Invalid Module"); $Base->Header(); $Base->Footer(); } }
function products_similar_by_price($price, $id) { $price_min = floor($price - $price * 10 / 100); $price_max = ceil($price + $price * 10 / 100); $sql1 = "SELECT category_id FROM " . db('shop_product_to_category') . " WHERE product_id = " . $id . ""; $cat_id = db()->query($sql1); while ($A = db()->fetch_assoc($cat_id)) { $cats_id .= $A["category_id"] . ","; } $cats_id = rtrim($cats_id, ","); $sql2 = "SELECT product_id FROM " . db('shop_product_to_category') . " WHERE category_id IN ( " . $cats_id . ")"; $prod = db()->query($sql2); while ($A = db()->fetch_assoc($prod)) { $prods .= $A["product_id"] . ","; } $prods = rtrim($prods, ","); $sql = "SELECT * FROM " . db('shop_products') . " WHERE price > " . $price_min . " AND price < " . $price_max . " AND id != " . $id . " AND id IN(" . $prods . ")"; $product = db()->query_fetch_all($sql); foreach ((array) $product as $k => $product_info) { $thumb_path = $product_info["url"] . "_" . $product_info["id"] . "_1" . module("shop")->THUMB_SUFFIX . ".jpg"; $URL_PRODUCT_ID = module("shop")->_product_id_url($product_info); $items[$product_info["id"]] = ["name" => _prepare_html($product_info["name"]), "price" => module("shop")->_format_price(module("shop")->_product_get_price($product_info)), "currency" => _prepare_html(module("shop")->CURRENCY), "image" => file_exists(module("shop")->products_img_dir . $thumb_path) ? module("shop")->products_img_webdir . $thumb_path : "", "link" => $product_info["external_url"] ? $product_info["external_url"] : process_url("./?object=shop&action=product_details&id=" . $URL_PRODUCT_ID), "special" => ""]; } $replace = ["items" => $items, "title" => "Similar price"]; return tpl()->parse("shop/products_similar_by_price", $replace); }
/** * basket_main */ function basket_main() { $products_ids = []; $basket_contents = module('shop')->_basket_api()->get_all(); foreach ((array) $basket_contents as $_item_id => $_info) { if ($_info["product_id"]) { $products_ids[$_info["product_id"]] = $_info["product_id"]; } } if (!empty($products_ids)) { $products_infos = db()->query_fetch_all("SELECT * FROM " . db('shop_products') . " WHERE active='1' AND id IN(" . implode(",", $products_ids) . ")"); $products_atts = module('shop')->_products_get_attributes($products_ids); $group_prices = module('shop')->_get_group_prices($products_ids); } $total_price = 0; foreach ((array) $products_infos as $_info) { $_product_id = $_info["id"]; $_info["_group_price"] = $group_prices[$_product_id][module('shop')->USER_GROUP]; $quantity2 = $basket_contents[$_info["id"]]["quantity"]; $price = module('shop')->_product_get_price($_info); $dynamic_atts = []; foreach ((array) $products_atts[$_product_id] as $_attr_id => $_attr_info) { if ($basket_contents[$_product_id]["atts"][$_attr_info["name"]] == $_attr_info["value"]) { $dynamic_atts[$_attr_id] = "- " . $_attr_info["name"] . " " . $_attr_info["value"]; $price += $_attr_info["price"]; } } $total_price += $price * $quantity2; $quantity += intval($quantity2); } $replace = ["total_price" => module('shop')->_format_price($total_price), "currency" => _prepare_html(module('shop')->CURRENCY), "quantity" => $quantity, "order_link" => "./?object=shop&action=basket", "basket_link" => "./?object=shop&action=basket"]; return tpl()->parse("shop/basket_main", $replace); }
function pics_browser() { if (isset($_GET['active']) && $_GET['active'] == 1) { $active = ' AND p.active = \'1\' '; } elseif (isset($_GET['active']) && $_GET['active'] == 0) { $active = ' AND p.active = \'\' '; } else { $active = ''; } if (main()->is_post()) { foreach ($_POST['delete'] as $k => $v) { list($id, $product_id) = explode("_", $k); module('manage_shop')->_product_image_delete($id, $product_id); } } $cats_list = _class('_shop_categories', 'modules/shop/')->recursive_get_child_ids(62521); $sql = "SELECT `i`.`product_id`,`i`.`id` FROM `" . db('shop_products') . "` AS `p`, `" . db('shop_product_images') . "` AS `i` WHERE `p`.`id`=`i`.`product_id` AND `p`.`cat_id` IN ('" . implode("','", $cats_list) . "')" . $active; list($add_sql, $pages, $total_records, $page_current, $pages_total, $pages_limited) = common()->divide_pages($sql); $R = db()->query($sql . $add_sql); $items = []; while ($A = db()->fetch_assoc($R)) { $_cls_products = _class('_shop_products', 'modules/shop/'); $image = $_cls_products->_product_image($A['product_id'], true); $items[] = ['id' => $A['product_id'], 'image_id' => $A['id'], 'image' => $image['big']]; } $replace = ['items' => $items, 'total' => $total_records, 'pages' => $pages]; $tpl_name = 'manage_shop/pics_browser'; return tpl()->parse($tpl_name, $replace); }
protected function execute(InputInterface $input, OutputInterface $output) { init_yf(); if (!defined('PROJECT_PATH') || !strlen(constant('PROJECT_PATH'))) { $output->writeln('Error: not inside a project'); return false; } foreach ((array) main()->get_data('locale_langs') as $lang => $linfo) { echo '== ' . $lang . ' ==' . PHP_EOL; list($tr_vars) = module('locale_editor')->_get_vars_from_files($lang); if (!$tr_vars) { continue; } $fname = './langs_exported_' . $lang . '.csv'; $data = []; $data['__'] = '"key";"val"'; foreach ((array) $tr_vars as $k => $v) { $k = trim($k); $v = trim($v); if (!strlen($k)) { continue; } $data[$k] = '"' . str_replace('"', '\\\\"', str_replace('_', ' ', $k)) . '";"' . str_replace('"', '\\\\"', str_replace('_', ' ', $v)) . '"'; } ksort($data); file_put_contents($fname, implode(PHP_EOL, $data)); passthru('ls -l ' . escapeshellarg($fname)); } }
public function edit() { $id = intval($_GET['id']); $this->alert_str($id, 'int'); $this->view()->assign(module('content')->common_info($id, true)); $this->show(); }
function _init() { $payment_api =& $this->payment_api; $manage_lib =& $this->manage_payment_lib; $provider_name =& $this->provider_name; $provider_class =& $this->provider_class; // class $payment_api = _class('payment_api'); $manage_payment_lib = module('manage_payment_lib'); // provider $provider_class = $payment_api->provider_class(['provider_name' => $provider_name]); // property $object =& $this->object; $action =& $this->action; $id =& $this->id; $filter_name =& $this->filter_name; $filter =& $this->filter; $url =& $this->url; // setup property $object = $_GET['object']; $action = $_GET['action']; $id = $_GET['id']; $filter_name = $object . '__' . $action; $filter = $_SESSION[$filter_name]; // url $url = ['list' => url_admin(['is_full_url' => true, 'object' => $object, 'action' => 'show']), 'authorize' => url_admin(['is_full_url' => true, 'object' => $object, 'action' => 'authorize']), 'request_interkassa' => url_admin(['object' => $object, 'action' => 'request_interkassa', 'operation_id' => '%operation_id'])]; }
function _init() { $shop = module('shop'); $shop->_shop_cats = _class('cats')->_get_items_names('shop_cats'); $shop->_shop_cats_all = _class('cats')->_get_items_array('shop_cats'); $shop->_shop_cats_for_select = _class('cats')->_prepare_for_box('shop_cats'); $sql_man = 'SELECT * FROM ' . db('shop_manufacturers') . ' ORDER BY name ASC'; $shop->_manufacturer = db()->query_fetch_all($sql_man); $shop->_man_for_select['none'] = '--NONE--'; foreach ((array) $shop->_manufacturer as $k => $v) { $shop->_man_for_select[$v['url']] = $v['name']; } $shop->_man_id = 'none'; $shop->products_img_dir = INCLUDE_PATH . SITE_UPLOADS_DIR . $shop->PROD_IMG_DIR; $shop->products_img_webdir = WEB_PATH . SITE_UPLOADS_DIR . $shop->PROD_IMG_DIR; if (!file_exists($shop->products_img_dir)) { _mkdir_m($shop->products_img_dir); } $shop->_boxes = ['ship_type' => 'select_box("ship_type", $shop->_ship_types_names, $selected, false, 2, "", false)', 'pay_type' => 'radio_box("pay_type", $shop->_pay_types, $selected, 1, 2, "", false)']; $shop->_ship_types_names = []; foreach ((array) $shop->_ship_types as $_id => $_info) { $_price_text = ' (' . ($_info['price'] < 0 ? '-' : '+') . $shop->_format_price(abs($_info['price'])) . ')'; $shop->_ship_types_names[$_id] = $_info['name'] . ($_info['price'] ? $_price_text : ''); } // Override pay type for group $force_group_pay_type = $shop->FORCE_GROUP_PAY[main()->USER_GROUP]; if ($force_group_pay_type) { $shop->FORCE_PAY_METHOD = $force_group_pay_type; } }
protected function execute(InputInterface $input, OutputInterface $output) { if (info()->installMode()) { die('Opis Colibri is not installed' . PHP_EOL); } $output->getFormatter()->setStyle('b-error', new OutputFormatterStyle('white', 'red', array('bold'))); $output->getFormatter()->setStyle('warning', new OutputFormatterStyle('yellow')); $output->getFormatter()->setStyle('b-warning', new OutputFormatterStyle('yellow', null, array('bold'))); $output->getFormatter()->setStyle('b-info', new OutputFormatterStyle('green', null, array('bold'))); $modules = $input->getArgument('module'); foreach ($modules as $moduleName) { $module = module($moduleName); if (!$module->exists()) { $output->writeln('<error>Module <b-error>' . $moduleName . '</b-error> doesn\'t exist.</error>'); continue; } if (!$module->isInstalled()) { $output->writeln('<warning>Module <b-warning>' . $moduleName . '</b-warning> is already uninstaled.</warning>'); continue; } if ($module->isHidden()) { $output->writeln('<error>Module <b-error>' . $moduleName . '</b-error> is hidden and can\'t be uninstalled.'); continue; } if ($module->uninstall()) { $output->writeln('<info>Module <b-info>' . $moduleName . '</b-info> was uninstalled.</info>'); } else { $output->writeln('<error>Module <b-error>' . $moduleName . '</b-error> could not be uninstalled.</error>'); } } }
function basket_add() { $product = db()->query_fetch("SELECT id FROM " . db('shop_products') . " WHERE active = '1' AND " . (is_numeric($_GET["id"]) ? "id=" . intval($_GET["id"]) : "url='" . _es($_GET['id']) . "'")); if (!empty($product)) { $_GET['id'] = $product['id']; } $atts = module('shop')->_products_get_attributes($product["id"]); if ($_GET["id"]) { $_GET["id"] = intval($_GET["id"]); $_POST["quantity"][$_GET["id"]] = 1; } if (!empty($atts) && empty($_POST["atts"])) { module('shop')->_basket_is_processed = true; return js_redirect("./?object=shop&action=product_details&id=" . $_GET["id"]); } if (!empty($_POST["quantity"]) && !module('shop')->_basket_is_processed) { foreach ((array) $_POST["quantity"] as $_product_id => $_quantity) { $_product_id = intval($_product_id); $_old_quantity = (int) module('shop')->_basket_api()->get($_product_id, 'quantity'); $_quantity = intval($_quantity) + intval($_old_quantity); if ($_product_id && $_quantity) { module('shop')->_basket_api()->set($_product_id, ["product_id" => $_product_id, "quantity" => $_quantity, "atts" => $_POST["atts"][$_product_id]]); } } // Prevent double processing module('shop')->_basket_is_processed = true; } return js_redirect("./?object=shop"); }
function products_similar_by_basket($id) { $sql_order_id = "SELECT order_id FROM " . db('shop_order_items') . " WHERE product_id = " . $id; $orders = db()->query($sql_order_id); while ($A = db()->fetch_assoc($orders)) { $order_id .= $A["order_id"] . ","; } $order_id = rtrim($order_id, ","); if (!empty($order_id)) { $sql_product_id = "SELECT product_id FROM " . db('shop_order_items') . " WHERE order_id IN ( " . $order_id . ") AND product_id != " . $id; $products = db()->query($sql_product_id); while ($A = db()->fetch_assoc($products)) { $product_id .= $A["product_id"] . ","; } $product_id = rtrim($product_id, ","); } if (!empty($product_id)) { $sql = "SELECT * FROM " . db('shop_products') . " WHERE id in ( " . $product_id . ")"; $product = db()->query_fetch_all($sql); foreach ((array) $product as $k => $product_info) { $thumb_path = $product_info["url"] . "_" . $product_info["id"] . "_1" . module("shop")->THUMB_SUFFIX . ".jpg"; $URL_PRODUCT_ID = module("shop")->_product_id_url($product_info); $items[$product_info["id"]] = ["name" => _prepare_html($product_info["name"]), "price" => module("shop")->_format_price(module("shop")->_product_get_price($product_info)), "currency" => _prepare_html(module("shop")->CURRENCY), "image" => file_exists(module("shop")->products_img_dir . $thumb_path) ? module("shop")->products_img_webdir . $thumb_path : "", "link" => $product_info["external_url"] ? $product_info["external_url"] : process_url("./?object=shop&action=product_details&id=" . $URL_PRODUCT_ID), "special" => ""]; } } $replace = ["items" => $items, "title" => "Those who purchased this product also buy"]; return tpl()->parse("shop/products_similar_by_price", $replace); }
public function getCover() { if ($this->cover()) { return asset('assets/info/' . module('Info')->cover()); } return 'http://placehold.it/1280x720'; }
function orders() { if (!main()->USER_ID) { if (main()->is_post()) { module('shop')->order_validate_data(); // Display next form if we have no errors if (!common()->_error_exists()) { return module('shop')->order_view(true); } } $items[] = ["order_id" => $_POST["order_id"], "email" => $_POST["email"], "form_action" => "./?object=shop&action=orders", "back_link" => "./?object=shop"]; } else { $sql = "SELECT * FROM " . db('shop_orders') . " WHERE user_id=" . intval(main()->USER_ID); //$filter_sql = $this->PARENT_OBJ->USE_FILTER ? $this->PARENT_OBJ->_create_filter_sql() : ""; $sql .= strlen($filter_sql) ? " WHERE 1=1 " . $filter_sql : " ORDER BY date DESC "; list($add_sql, $pages, $total) = common()->divide_pages($sql); $orders_info = db()->query_fetch_all($sql . $add_sql); if (!empty($orders_info)) { foreach ((array) $orders_info as $v) { $user_ids[] = $v["user_id"]; } $user_infos = user($user_ids); } foreach ((array) $orders_info as $v) { if ($v["status"] == "pending" or $v["status"] == "pending payment") { $del = "./?object=shop&action=order_delete&id=" . $v["id"]; } else { $del = ""; } $items[] = ["order_id" => $v["id"], "date" => _format_date($v["date"], "long"), "sum" => module('shop')->_format_price($v["total_sum"]), "user_link" => _profile_link($v["user_id"]), "user_name" => _display_name($user_infos[$v["user_id"]]), "status" => $v["status"], "delete_url" => $del, "view_url" => "./?object=shop&action=order_view&id=" . $v["id"]]; } } $replace = ["error_message" => _e(), "items" => (array) $items, "pages" => $pages, "total" => intval($total), "filter" => module('shop')->USE_FILTER ? module('shop')->_show_filter() : ""]; return tpl()->parse("shop/order_show", $replace); }
/** * Order validation */ function _order_validate_delivery() { $_POST['exp_date'] = $_POST['exp_date_mm'] . $_POST['exp_date_yy']; $force_ship_type = module('shop')->FORCE_GROUP_SHIP[module('shop')->USER_GROUP]; if ($force_ship_type) { $_POST["ship_type"] = $force_ship_type; } if (!strlen($_POST["ship_type"]) || !isset(module('shop')->_ship_types[$_POST["ship_type"]])) { _re("Shipping type required"); } foreach ((array) module('shop')->_b_fields as $_field) { if (!strlen($_POST[$_field]) && in_array($_field, module('shop')->_required_fields)) { _re(t(str_replace("b_", "Billing ", $_field)) . " " . t("is required")); } } if ($_POST["email"] != "" && !common()->email_verify($_POST["email"])) { _re("email not valid."); } /* foreach ((array)module('shop')->_s_fields as $_field) { if (!strlen($_POST[$_field]) && in_array($_field, module('shop')->_required_fields)) { _re(t(str_replace("s_", "Shipping ", $_field))." ".t("is required")); } } if (!common()->email_verify($_POST["s_email"])) { _re("Shipping email not valid."); } */ }
function test() { $time_start = microtime(true); require_once YF_PATH . 'libs/phpmailer/PHPMailerAutoload.php'; $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = module('test')->SMTP_OPTIONS['smtp_host']; $mail->SMTPAuth = true; $mail->Username = module('test')->SMTP_OPTIONS['smtp_user_name']; $mail->Password = module('test')->SMTP_OPTIONS['smtp_password']; if (module('test')->SMTP_OPTIONS['smtp_secure']) { $mail->SMTPSecure = module('test')->SMTP_OPTIONS['smtp_secure']; } $mail->From = module('test')->TEST_MAIL['email_from']; if (module('test')->TEST_MAIL['name_from']) { $mail->FromName = module('test')->TEST_MAIL['name_from']; } $mail->AddAddress(module('test')->TEST_MAIL['email_to'], module('test')->TEST_MAIL['name_to']); $mail->IsHTML(true); $mail->Subject = module('test')->TEST_MAIL['subject']; $mail->Body = module('test')->TEST_MAIL['html']; $mail->AltBody = module('test')->TEST_MAIL['text']; $result = $mail->Send(); $error_message .= $mail->ErrorInfo; $body .= $result ? '<b style="color:green;">Send successful</b>' : '<b style="color:red;">Send failed</b>'; $body .= !$result ? '<br /><b>Reason:</b><br /> ' . $error_message . implode('<br />\\n', (array) main()->_all_core_error_msgs) . '<br />' : ''; $body .= '<br />Spent time: ' . common()->_format_time_value(microtime(true) - $time_start) . ' sec.<br />'; return $body; }
function _box($name = "", $selected = "") { if (empty($name) || empty(module("shop")->_boxes[$name])) { return false; } else { return eval("return common()->" . module("shop")->_boxes[$name] . ";"); } }
public function register() { $user = module("UserManagement"); $inputs = \Input::only('email', 'password'); $inputs['password'] = \Hash::make($inputs['password']); $user->db()->insert($inputs); return \Redirect::route("home"); }
function _format_price($price = 0) { $price = number_format($price, 2, '.', ' '); if (module("shop")->CURRENCY == "\$") { return module("shop")->CURRENCY . " " . $price; } else { return $price . " " . module("shop")->CURRENCY; } }
function debug() { print "<strong>query string:</strong> {$_SERVER['QUERY_STRING']}\n\n"; print "<strong>module:</strong> " . implode("-", module()) . "\n"; print "<strong>function:</strong> " . func() . "\n"; print "<strong>method:</strong> " . method() . "\n\n"; print "<strong>include:</strong> /module/" . implode("/", module()) . "/main.php\n\n"; print "<strong>run:</strong> " . command() . "\n\n"; }
/** * Order step */ function _order_step_finish($FORCE_DISPLAY_FORM = false) { module('shop')->_basket_api()->clean(); if (isset($_GET["page"])) { $_GET["id"] = intval($_GET["page"]); unset($_GET["page"]); } $_GET["id"] = intval($_GET["id"]); if ($_GET["id"]) { $order_info = db()->query_fetch("SELECT * FROM " . db('shop_orders') . " WHERE id=" . intval($_GET["id"]) . " AND user_id=" . intval(main()->USER_ID)); } if (empty($order_info)) { return _e("No such order"); } $products_ids = []; $Q = db()->query("SELECT * FROM " . db('shop_order_items') . " WHERE `order_id`=" . intval($order_info["id"])); while ($_info = db()->fetch_assoc($Q)) { if ($_info["product_id"]) { $products_ids[$_info["product_id"]] = $_info["product_id"]; } $order_items[$_info["product_id"]] = $_info; } if (!empty($products_ids)) { $products_infos = db()->query_fetch_all("SELECT * FROM " . db('shop_products') . " WHERE id IN(" . implode(",", $products_ids) . ") AND active='1'"); $products_atts = module('shop')->_products_get_attributes($products_ids); } foreach ((array) $order_items as $_info) { $_product_id = $_info["product_id"]; $_product = $products_infos[$_product_id]; $price = $_info["sum"]; $dynamic_atts = []; if (strlen($_info["attributes"]) > 3) { foreach ((array) unserialize($_info["attributes"]) as $_attr_id) { $_attr_info = $products_atts[$_info["product_id"]][$_attr_id]; $dynamic_atts[$_attr_id] = "- " . $_attr_info["name"] . " " . $_attr_info["value"]; $price += $_attr_info["price"]; } } $URL_PRODUCT_ID = module('shop')->_product_id_url($_product); $products[$_info["product_id"]] = ["name" => _prepare_html($_product["name"]), "price" => module('shop')->_format_price($price), "sum" => module('shop')->_format_price($_info["sum"]), "currency" => _prepare_html(module('shop')->CURRENCY), "quantity" => intval($_info["quantity"]), "details_link" => process_url("./?object=shop&action=product_details&id=" . $URL_PRODUCT_ID), "dynamic_atts" => !empty($dynamic_atts) ? implode("\n<br />", $dynamic_atts) : "", "cat_name" => _prepare_html(module('shop')->_shop_cats[$_product["cat_id"]]), "cat_url" => process_url("./?object=shop&action=products_show&id=" . module('shop')->_shop_cats_all[$_product["cat_id"]]['url'])]; $total_price += $price * $quantity; } $total_price = $order_info["total_sum"]; if (main()->USER_ID) { $order_info = my_array_merge(module('shop')->_user_info, $order_info); } else { $order_info["email"] = $order_info["email"]; $order_info["phone"] = $order_info["phone"]; } $order_info = my_array_merge(module('shop')->COMPANY_INFO, $order_info); $replace2 = my_array_merge($order_info, ["id" => $_GET["id"], "products" => $products, "ship_cost" => module('shop')->_format_price(0), "total_cost" => module('shop')->_format_price($total_price), "password" => ""]); // Prepare email template $message = tpl()->parse("shop/invoice_email", $replace2); common()->quick_send_mail($order_info["email"], "invoice #" . $_GET["id"], $message); $replace = my_array_merge($replace2, ["error_message" => _e(), "products" => $products, "ship_price" => module('shop')->_format_price(module('shop')->_ship_types_names[$order_info["ship_type"]]), "total_price" => module('shop')->_format_price($total_price), "order_no" => str_pad($order_info["id"], 8, "0", STR_PAD_LEFT), "hash" => _prepare_html($order_info["hash"]), "back_link" => "./?object=shop&action=show", "cats_block" => module('shop')->_categories_show()]); return tpl()->parse("shop/order_finish", $replace); }