/** * */ function output() { global $application; ob_start(); phpinfo(1); $content = ob_get_contents(); ob_end_clean(); $flag = true; while ($flag) { $pos = _ml_strpos($content, "\n"); $line = _ml_substr($content, 0, $pos); $content = _ml_substr($content, $pos + 1); if (_ml_strpos($line, "System")) { $line = _ml_substr($line, 0, _ml_strrpos($line, "<")); $line = _ml_substr($line, 0, _ml_strrpos($line, "<")); $line = _ml_substr($line, _ml_strrpos($line, ">") + 1); $flag = false; } } $OS = $line; $request = new Request(); $request->setView('PHPInfo'); $link = $request->getURL(); global $db_link; $template_contents = array("ProductVersion" => PRODUCT_VERSION_NUMBER, "ProductVersionType" => PRODUCT_VERSION_TYPE, "ProductReleaseDate" => PRODUCT_VERSION_DATE, "CoreVersion" => CORE_VERSION, "ModulesList" => $this->outputModules(), "phpVersion" => PHP_VERSION, "MySQLVersion" => mysqli_get_server_info($db_link), "ServerOS" => $OS, "WebServerVersion" => $_SERVER["SERVER_SOFTWARE"], "PHPInfoLink" => $link); $this->_Template_Contents = $template_contents; $application->registerAttributes($this->_Template_Contents); return modApiFunc('TmplFiller', 'fill', "tools/server_info/", "container.tpl.html", array()); }
/** * Adds the table to the locked ones. * : check and describe return. See db_select.php * * @return alias of added or already existed record (?) * @param string $table_name table name * @param string $locking_mode locking mode * @param string $table_alias alias of the table name */ function addTableToLock($table_name, $locking_mode, $table_alias = '') { global $application; $table_prefix = $application->getAppIni('DB_TABLE_PREFIX'); if ($table_prefix != NULL) { if (_ml_strpos($table_name, $table_prefix) === false) { $table_name = $table_prefix . $table_name; } } foreach ($this->TablesToLock as $t_name => $t_info) { if ($t_info['alias'] == $table_name) { return $table_alias; } } //else : new table name is not a previously added -alias- //Check if table is already added if (!array_key_exists($table_name, $this->TablesToLock)) { foreach ($this->TablesToLock as $t_name => $t_info) { if ($t_info['alias'] == $table_alias && $table_alias != '') { user_error('Attempt to assign the same alias "' . $talbe_alias . '" to two different tables:"' . $t_name . '" and "' . $table_name . '".', E_USER_ERROR); } } //else : new table alias is not a previously added -table-alias- $this->TablesToLock[$table_name] = array("locking_mode" => $locking_mode, "alias" => $table_alias); } else { return $this->TablesToLock[$table_name]['alias']; } //: move this return to line "$this->TablesToLock[$table_name] = ..."? return $table_alias; }
/** * Outputs label information */ function outputLabelData($Label_Data, $lng) { global $application; $template_contents = array('LabelName' => _ml_substr($Label_Data['label'], 0, 7) != 'CUSTOM_' ? $Label_Data['sh_label'] : 'CUSTOM_', 'LabelZone' => $Label_Data['zone'], 'LabelType' => $Label_Data['module_name'], 'LabelUsage' => htmlspecialchars($Label_Data['usage']), 'LabelUsageText' => htmlspecialchars(_ml_substr($Label_Data['usage'], 0, _ml_strpos($Label_Data['usage'], '\'CUSTOM_') + 8)), 'LabelStatus' => $Label_Data['status'], 'Language' => $this->outputLanguage($lng), 'DefLanguage' => $this->outputDefaultLanguage(), 'CustomName' => $this->outputCustomNameField($Label_Data), 'LabelValue' => $this->outputLabelValue($Label_Data, $lng), 'LabelDefValue' => $this->outputLabelDefValue($Label_Data)); $this->_Template_Contents = $template_contents; $application->registerAttributes($this->_Template_Contents); return $this->mTmplFiller->fill('multilang/label_data/', 'label-data.tpl.html', array()); }
/** * */ function onAction() { global $application; CCacheFactory::clearAll(); modApiFunc("Tools", "clearBackupSession"); modApiFunc("Tools", "setDBStat", modApiFunc("Modules_Manager", "getTablesAndRecordsCount")); modApiFunc("Tools", "setCurrentBackupTable", 0); modApiFunc("Tools", "setCurrentBackupTableLimit", 0); modApiFunc("Tools", "setDBRecordsExported", 0); $request = $application->getInstance('Request'); $filename = $request->getValueByKey('BackupFile'); if ($filename) { modApiFunc("Tools", "setRestoreStatus", 'BACKUP'); modApiFunc("Tools", "setRestoreFile", $filename); $filename = modApiFunc("Tools", "getRestoreFile"); $full_filename = $application->getAppIni('PATH_BACKUP_DIR') . $filename . "/dump.sql"; $handle = @fopen($full_filename, "rb"); $backup_file_content = @fread($handle, 1024); @fclose($handle); $error = ""; $backup_info = @_parse_ini_file($application->getAppIni('PATH_BACKUP_DIR') . $filename . "/info/backup.ini"); if (!isset($backup_info["asc_version"]) || $backup_info["asc_version"] != PRODUCT_VERSION) { $error = "BCP_RESTORE_ERR_003"; } elseif (!$backup_file_content) { $error = "BCP_RESTORE_ERR_001"; } elseif (_ml_strpos($backup_file_content, "-- HASH: ") === false) { $error = "BCP_RESTORE_ERR_002"; } else { $hash = _byte_substr($backup_file_content, 9, 32); // $handle = fopen($full_filename, "rb"); $md5_temp = ''; // $begin = _byte_strpos($backup_file_content, "\n") + _byte_strlen("\n"); fseek($handle, $begin); while (!feof($handle)) { $contents = fread($handle, 1048576); $md5_temp .= md5($contents); } $counted_file_hash = md5($md5_temp); fclose($handle); // : if ($hash != $counted_file_hash) { $error = "BCP_RESTORE_ERR_002"; } } if ($error) { modApiFunc("Tools", "setRestoreError", $error); } else { modApiFunc("Tools", "setStringsCountInRestoreFile", $filename); } } modApiFunc("Tools", "saveState"); }
/** * Sets current product sort field from Request. * * Action: SetProductListSortField */ function onAction() { global $application; $request = $application->getInstance('Request'); // field , $field = $request->getValueByKey('field'); $direction = SORT_DIRECTION_ASC; if (_ml_strpos($field, ',') !== false) { $list = array_map('trim', explode(',', $field)); $field = @$list[0]; $direction = @$list[1]; } if ($field != NULL) { modApiFunc('CProductListFilter', 'changeCurrentSortField', $field, $direction); } }
function savePostedData($data) { if (!is_array($data)) { return; } foreach ($data as $k => $v) { $params = array(); if (in_array(@$v['status'], array('A', 'H', 'D'))) { $params['status'] = $v['status']; } if (in_array(@$v['availability'], array('A', 'R', 'C'))) { $params['availability'] = $v['availability']; } if (isset($v['parent_id']) && ($v['parent_id'] == 0 || _ml_strpos('/' . modApiFunc('CMS', 'getPagePath', $v['parent_id']), '/' . $k . '/') === false)) { $params['parent_id'] = $v['parent_id']; } if (!empty($params)) { $params['page_id'] = $k; execQuery('UPDATE_CMS_PAGE_DATA', $params); } } }
/** * * * Action: * * @ finish the functions on this page */ function onAction() { global $application; $request = $application->getInstance('Request'); $selected_admins = $request->getValueByKey('selected_admins'); // . - . // - Delete $removable_admins = array(); $unremovable_admins = array(); foreach ($selected_admins as $index => $admin_id) { if (!is_numeric($admin_id) || (int) $admin_id == 0) { continue; } else { $admin_id = (int) $admin_id; } $results_array = modApiFunc('EventsManager', 'processEvent', 'RemoveAdmin', $admin_id); $res_msg = ""; foreach ($results_array as $msg) { if ($msg !== NULL) { // - . . if (_ml_strpos($res_msg, $msg) === FALSE) { $res_msg .= $msg . "\n"; } } } if ($res_msg == "") { // - . $removable_admins[] = $admin_id; } else { // - . . $unremovable_admins[] = array("id" => $admin_id, "msg" => $res_msg); } } $res = array("removable_admins" => $removable_admins, "unremovable_admins" => $unremovable_admins); modApiFunc("Users", "setDeleteAdminMembersID", $res); }
function _find_header_columns($arr, $check = false) { // returns false if not an array if (!is_array($arr) || empty($arr)) { return false; } // building the array of fields $result = array('labeltype' => -1, 'labelname' => -1); // getting the active languages $lngs = modApiFunc('MultiLang', 'getLanguageList', false); if (!is_array($lngs) || empty($lngs)) { $lngs = array(0 => array('lng' => 'default', 'lng_name' => getMsg('ML', 'ML_DEFAULT'))); } // adding the languages to the list of fields foreach ($lngs as $v) { $result[$v['lng']] = -1; $lngs[$v['lng']] = $v; } // finding the column indexes in the $arr $found = array(); foreach ($result as $key => $value) { switch ($key) { case 'labeltype': case 'labelname': foreach ($arr as $k => $v) { if (in_array($k, $found)) { continue; } if (_ml_strpos(_ml_strtolower(str_replace(array(' ', '_', '(', ')'), '', $v)), $key) !== false) { $result[$key] = $k; $found[$k] = $k; break; } } break; default: foreach ($arr as $k => $v) { if (in_array($k, $found)) { continue; } if (_ml_strpos(_ml_strtolower(str_replace(array(' ', '_', '(', ')'), '', $v)), 'labelvalue') !== false) { if (_ml_strpos(' ' . _ml_strtolower(str_replace(array(' ', '_', '(', ')'), ' ', $v)) . ' ', ' ' . _ml_strtolower($key) . ' ') !== false || _ml_strpos(_ml_strtolower($v), _ml_strtolower($lngs[$key]['lng_name'])) !== false) { $result[$key] = $k; $found[$k] = $k; break; } } } break; } } if ($check) { if ($result['labeltype'] >= 0 && $result['labelname'] >= 0) { return true; } return false; } return $result; }
/** * @ describe the function ProductList->getTag. */ function getTag($tag) { global $application; $value = null; $CatID = modApiFunc('CProductListFilter', 'getCurrentCategoryId'); switch ($tag) { case 'CurrentCategoryPath': $value = str_replace("/", " >> ", $this->_cats_paths[modApiFunc('CProductListFilter', 'getCurrentCategoryId')]); break; case 'Local_CategoriesBrowser_GoTo': $cb_obj = new CategoriesBrowser(); $this->cb_params['category_path_prefix'] = getMsg('CTL', 'PRFX_TARGET_CATEGORY'); $this->cb_params['buttons'] = array('go' => array('label' => 'BTN_GO', 'callback' => 'OnGoButtonClick(%CID%);', 'default_state' => 'disabled', 'enable_condition' => 'category_selected'), 'cancel' => array('label' => 'BTN_CANCEL', 'callback' => 'hideBlock(\'categories_browser_goto\');', 'default_state' => 'enabled')); $value = $cb_obj->output($this->cb_params); break; case 'Local_CategoriesBrowser_MoveTo': $cb_obj = new CategoriesBrowser(); $this->cb_params['category_path_prefix'] = getMsg('CTL', 'PRFX_TARGET_CATEGORY'); $this->cb_params['buttons'] = array('move' => array('label' => 'BTN_MOVE_PRD', 'callback' => 'OnMoveButtonClick(%CID%);', 'default_state' => 'disabled', 'enable_condition' => 'category_selected'), 'cancel' => array('label' => 'BTN_CANCEL', 'callback' => 'hideBlock(\'categories_browser_moveto\');', 'default_state' => 'enabled')); $value = $cb_obj->output($this->cb_params); break; case 'Local_CategoriesBrowser_CopyTo': $cb_obj = new CategoriesBrowser(); $this->cb_params['category_path_prefix'] = getMsg('CTL', 'PRFX_TARGET_CATEGORY'); $this->cb_params['buttons'] = array('move' => array('label' => 'BTN_COPY_PRD', 'callback' => 'OnCopyButtonClick(%CID%);', 'default_state' => 'disabled', 'enable_condition' => 'category_selected'), 'cancel' => array('label' => 'BTN_CANCEL', 'callback' => 'hideBlock(\'categories_browser_copyto\');', 'default_state' => 'enabled')); $value = $cb_obj->output($this->cb_params); break; case 'ProductListSubcategories': $value = $this->getSubcategoriesList(); break; case 'Breadcrumb': $value = modApiFunc("Breadcrumb", "output", true, "ProductList"); break; case 'Items': $value = $this->getProductList(); break; case 'CategoryName': $categoryInfo = new CCategoryInfo($CatID); $value = $categoryInfo->getCategoryTagValue('name'); break; case 'PaginatorLine': $obj =& $application->getInstance($tag); $value = $obj->output($this->paginator_name, "ProductList"); break; # override the PaginatorRows tag behavior # override the PaginatorRows tag behavior case 'PaginatorRows': $obj =& $application->getInstance($tag); $value = $obj->output($this->paginator_name, 'ProductList'); break; case 'Add_Product_Link': $request = new Request(); // $request->setView ( 'SelectProductType' ); $request->setView('Catalog_AddProduct'); $request->setKey('category_id', $CatID); $value = $request->getURL(); break; case 'Move_Products_Link': $request = new Request(); $request->setView('MoveProducts'); $request->setAction('SetEditableProducts'); $value = $request->getURL(); break; case 'Copy_Products_Link': $request = new Request(); $request->setView('CopyProducts'); $request->setAction('SetEditableProducts'); $value = $request->getURL(); break; case 'Edit_Product_Link': $request = new Request(); $request->setView('Catalog_EditProduct'); $request->setAction('SetCurrentProduct'); $request->setKey('prod_id', ''); $value = $request->getURL(); break; case 'Delete_Products_Link': $request = new Request(); $request->setView('DeleteProducts'); $request->setAction('SetEditableProducts'); $value = $request->getURL(); break; case 'SortProdHref': $request = new Request(); $request->setView('SortProducts'); $value = $request->getURL(); break; case 'ProductsInCatTotal': $value = $this->ProdNumInCat; break; case 'AlertMessage': $MessageResources =& $application->getInstance('MessageResources'); $err_mes = new ActionMessage(array('PRDLST_006')); $value = $MessageResources->getMessage($err_mes); break; case 'SortAlertMessage': if ($this->ProdNumInCat == 0) { $MessageResources =& $application->getInstance('MessageResources'); $err_mes = new ActionMessage(array('PRDLST_007')); $value = $MessageResources->getMessage($err_mes); } elseif ($this->ProdNumInCat == 1) { $MessageResources =& $application->getInstance('MessageResources'); $err_mes = new ActionMessage(array('PRDLST_008')); $value = $MessageResources->getMessage($err_mes); } else { $value = ''; } break; case 'ProductsNumber': $value = $this->_Cat_Info->getCategoryTagValue('productsnumber_non_recursively'); break; case 'ProductsNumberRecursively': $value = $this->_Cat_Info->getCategoryTagValue('productsnumberrecursively') - $this->_Cat_Info->getCategoryTagValue('productsnumber'); break; case 'SubcategoriesNumber': $value = $this->_Cat_Info->getCategoryTagValue('subcategoriesnumber'); break; case 'From': $value = $this->From; break; case 'To': $value = $this->To; break; case 'CategoryStatistics': $value = $this->outputCategoryStatistics(); break; case 'CurrensySign': $value = modApiFunc("Localization", "getCurrencySign"); break; case 'ProductOfflineStatusReason': $prod_status_id = $this->_Current_Product->getProductTagValue('Available', PRODUCTINFO_NOT_LOCALIZED_DATA); $value = $prod_status_id == PRODUCT_STATUS_ONLINE ? getMsg('SYS', "PRODUCT_PARENT_STATUS_ONLINE") : ""; break; case 'ProductOfflineStatusColor': // Offline. // Online, , Offline - . $prod_status_id = $this->_Current_Product->getProductTagValue('Available', PRODUCTINFO_NOT_LOCALIZED_DATA); $value = $prod_status_id == PRODUCT_STATUS_ONLINE ? "rgb(175, 175, 175)" : "#FF0000"; break; case 'ProductCatsCount': $value = count($this->_Current_Product->getCategoriesIDs()); break; case 'ProductCatsList': $_ps = array(); $_cts = $this->_Current_Product->getCategoriesIDs(); foreach ($_cts as $cid) { $_ps[] = $this->_cats_paths[$cid]; } asort($_ps); $_ps = array_map("addslashes", array_map("_ml_htmlentities", $_ps)); $value = implode("<br>", $_ps); break; case 'ProductQuantityInStock': if ($this->_Current_Product->whichStockControlMethod() == PRODUCT_OPTIONS_INVENTORY_TRACKING) { $value = ""; $inv_qty = modApiFunc('Product_Options', 'getQuantityInStockByInventoryTable', 'product', $this->_Current_Product->getProductTagValue('ID')); if (Validator::isValidInt($inv_qty) == true) { $value = $inv_qty . ' ' . modApiFunc('Localization', 'getUnitTypeValue', 'item'); } } else { $value = $this->_Current_Product->getProductTagValue('QuantityInStock', PRODUCTINFO_NOT_LOCALIZED_DATA); if (Validator::isValidInt($value) == true) { $value = $this->_Current_Product->getProductTagValue('QuantityInStock', PRODUCTINFO_LOCALIZED_DATA); } } break; case 'HeaderData': if (empty($this->psf_filter)) { $value = modApiFunc('TmplFiller', 'fill', "catalog/prod_list/", "list-header-category-data.tpl.html", array()); } else { $value = modApiFunc('TmplFiller', 'fill', "catalog/prod_list/", "list-header-searchform-data.tpl.html", array()); } break; case 'SearchFilterData': $value = $this->getSearchFilterDataText(); break; case 'FooterData': if (empty($this->psf_filter)) { $value = modApiFunc('TmplFiller', 'fill', "catalog/prod_list/", "list-footer-category-data.tpl.html", array()); } else { $value = modApiFunc('TmplFiller', 'fill', "catalog/prod_list/", "list-footer-searchform-data.tpl.html", array()); } break; case 'IfSearchFormActive': $value = empty($this->psf_filter) ? '' : 'Y'; break; case 'ProductThumbnail': $value = modApiFunc('TmplFiller', 'fill', 'catalog/prod_list/', 'list_item_image.tpl.html', array()); break; case 'Local_NoImageSrc': $value = $application->getAppIni('URL_IMAGES_DIR') . 'noimage.png'; break; case 'Local_SelectCategoriesProducts': $categorylist = modApiFunc("Catalog", "getSubcategoriesFullListWithParent", 1, false); foreach ($categorylist as $val => $data) { $catvalid = $data["id"]; if ($data['level'] == 2) { $value = '<option value="' . $catvalid . '" ' . ($CatID == $catvalid ? 'selected' : '') . '> ' . $data["name"] . '</option>'; } else { $value = '<option value="' . $catvalid . '" ' . ($CatID == $catvalid ? 'selected' : '') . '>' . $data["name"] . '</option>'; } } break; default: if (_ml_strpos($tag, 'Local_SortBy') === 0) { $tag = _ml_substr($tag, _ml_strlen('Local_SortBy')); $value = $this->getSortLink($tag); break; } if (_ml_strpos($tag, 'Product') === 0) { $tag = _ml_substr($tag, _ml_strlen('Product')); } if (is_object($this->_Current_Product) && $this->_Current_Product->isTagExists($tag)) { $value = $this->_Current_Product->getProductTagValue($tag); } break; } return $value; }
/** * Outputs Forbidden Template * use case: customer is anonyous while posting a review * is available for signed-in customers */ function outputForbidden() { global $application; $return_url = modApiFunc('Request', 'selfURL'); if (_ml_strpos($return_url, '#') !== false) { $return_url = _ml_substr($return_url, _ml_strpos($return_url, '#')); } $return_url .= '#add_review_' . $this->_product_data['product_id']; $r = new Request(); $r->setView(CURRENT_REQUEST_URL); $r->setAction('sign_in_required'); $r->setKey('returnURL', urlencode($return_url)); $_tags = array('Local_SignInURL' => $r->getURL()); $this->_Template_Contents = $_tags; $application->registerAttributes($this->_Template_Contents); return $this->mTmplFiller->fill($this->_templates['forbidden']); }
/** * Action: AddCat. * * Adds a new category record to the DB, or saves current form state * parameters, like uploaded image names etc. * <p> Subactions are * <ul> * <li>"UploadImages"</li> * <li>"DeleteSmallImage"</li> * <li>"DeleteLargeImage"</li> * <li>"Save"</li> * </ul> * The main action is "Save". Any other subaction may occur 0 or any number * of times. Subactions change the "View State". */ function onAction() { global $application; $request = $application->getInstance('Request'); $SessionPost = array(); if (modApiFunc('Session', 'is_Set', 'SessionPost')) { _fatal(array("CODE" => "CORE_050"), __CLASS__, __FUNCTION__); } $SessionPost = $_POST; $this->initData($SessionPost); switch ($request->getValueByKey('FormSubmitValue')) { case "UploadImages": $this->uploadImages($SessionPost); break; case "DeleteSmallImage": $image = $SessionPost['ViewState']['SmallImage']; // if it was a temporary file, delete it from the general catalog. if (_ml_strpos(basename($image), 'tmp') === 0) { $images_dir = $application->getAppIni('PATH_IMAGES_DIR'); @unlink($images_dir . basename($image)); } // delete it from the user interface $SessionPost["ViewState"]["SmallImage"] = ""; break; case "DeleteLargeImage": $image = $SessionPost['ViewState']['LargeImage']; // if it was a temporary file, delete it from the general catalog. if (_ml_strpos(basename($image), 'tmp') === 0) { $images_dir = $application->getAppIni('PATH_IMAGES_DIR'); @unlink($images_dir . basename($image)); } // delete it from the user interface $SessionPost["ViewState"]["LargeImage"] = ""; break; case "UploadImagesAndSave": $nErrors = 0; $SessionPost["ViewState"]["ErrorsArray"] = array(); $this->uploadImages($SessionPost); loadCoreFile('html_form.php'); $HtmlForm1 = new HtmlForm(); $error_message_text = ""; if (!$this->isValidCatName($SessionPost["Subcategory"], $error_message_text)) { $nErrors++; $SessionPost["ViewState"]["ErrorsArray"]["Subcategory"] = new ActionMessage(array("ERR_AZ_CAT_ADDCAT_005")); //"ERR_AZ_CAT_ADDCAT_001"; // $SessionPost["Subcategory"] .= "<ERROR: Invalid input. See error list.>"; } if (!$this->isValidCatStatus($SessionPost["CategoryStatus"], $error_message_text)) { $nErrors++; $SessionPost["ViewState"]["ErrorsArray"]["CategoryStatus"] = new ActionMessage(array("ERR_AZ_CAT_ADDCAT_008")); $SessionPost["CategoryStatus"] = CATEGORY_STATUS_ONLINE; } if (!$this->isValidCatShowProductsRecursivelyStatus($SessionPost["CategoryShowProductsRecursivelyStatus"], $error_message_text)) { $nErrors++; $SessionPost["ViewState"]["ErrorsArray"]["CategoryShowProductsRecursivelyStatus"] = new ActionMessage(array("ERR_AZ_CAT_ADDCAT_009")); $SessionPost["CategoryShowProductsRecursivelyStatus"] = CATEGORY_DONOTSHOW_PRODUCTS_RECURSIVELY; } if (!$this->isValidImageDescription($SessionPost["ImageDescription"], $error_message_text)) { $nErrors++; $SessionPost["ViewState"]["ErrorsArray"]["ImageDescription"] = new ActionMessage(array("ERR_AZ_CAT_ADDCAT_006")); //"ERR_AZ_CAT_ADDCAT_001"; // $SessionPost["Subcategory"] .= "<ERROR: Invalid input. See error list.>"; } if (!$this->isValidPageTitle($SessionPost["PageTitle"], $error_message_text)) { $nErrors++; $SessionPost["ViewState"]["ErrorsArray"][] = $SessionPost["ViewState"]["ErrorsArray"]["PageTitle"] = new ActionMessage(array("ERR_AZ_CAT_ADDCAT_007")); // $SessionPost["ViewState"]["ErrorsArray"][] = "ERR_AZ_CAT_ADDCAT_002"; // $SessionPost["PageTitle"] .= "<ERROR: Invalid input. See error list.>"; } if (!$this->isValidMetaField($SessionPost["MetaKeywords"], $error_message_text)) { $nErrors++; $SessionPost["ViewState"]["ErrorsArray"]["MetaKeywords"] = new ActionMessage(array("ERR_AZ_CAT_ADDCAT_003")); //"ERR_AZ_CAT_ADDCAT_003"; } if (!$this->isValidMetaField($SessionPost["MetaDescription"], $error_message_text)) { $nErrors++; $SessionPost["ViewState"]["ErrorsArray"][] = $SessionPost["ViewState"]["ErrorsArray"]["MetaDescription"] = new ActionMessage(array("ERR_AZ_CAT_ADDCAT_004")); //"ERR_AZ_CAT_ADDCAT_004"; } $nErrors = sizeof($SessionPost["ViewState"]["ErrorsArray"]); if ($nErrors == 0) { unset($SessionPost["ViewState"]["ErrorsArray"]); $this->saveDataToDB($SessionPost); $SessionPost["ViewState"]["hasCloseScript"] = "true"; } break; default: _fatal(array("CODE" => "CORE_051"), __CLASS__, __FUNCTION__, $request->getValueByKey('FormSubmitValue')); } modApiFunc('Session', 'set', 'SessionPost', $SessionPost); // get view name by action name. $this->redirect(); }
function getDirectorySize($d = null) { global $application; if ($d == null) { $path = $application->getAppINI('PATH_CACHE_DIR'); } else { $path = $d; } $totalsize = 0; if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { $nextpath = $path . '/' . $file; if ($file != '.' && $file != '..' && !is_link($nextpath) && is_file($nextpath) && _ml_strpos($file, '_cache') === 0) { $totalsize += filesize($nextpath); } else { if ($file != '.' && $file != '..' && !is_link($nextpath) && is_dir($nextpath)) { $totalsize += $this->getDirectorySize($nextpath); } } } } closedir($handle); return $totalsize; }
/** * @ describe the function ViewCategory->getTag. */ function getTag($tag) { global $application; $value = null; $CatID = $this->_Current_Category->getCategoryTagValue('ID'); switch ($tag) { case 'Breadcrumb': $obj =& $application->getInstance('Breadcrumb'); $value = $obj->output(false); break; default: if (is_object($this->_Current_Category) && $this->_Current_Category->isTagExists($tag)) { $value = $this->_Current_Category->getCategoryTagValue($tag); } else { if (_ml_strpos($tag, 'Category') === 0) { $tag = _ml_substr($tag, _ml_strlen('Category')); if (is_object($this->_Current_Category) && $this->_Current_Category->isTagExists($tag)) { $value = $this->_Current_Category->getCategoryTagValue($tag); } } } break; } return $value; }
/** * Adds a Custoner (List Person) to this order. * It is used, for example, to save unregistered customers. * A separate record is not created in the table persons. * * @ * @param * @return */ function addOrderPerson($order_id) { global $application; $tables = $this->getTables(); $ptiv = $tables["person_to_info_variants"]['columns']; $opd = $tables["order_person_data"]['columns']; $data = $this->getPrerequisitesValidationResults(); $payment_module_id = modApiFunc("Checkout", "getChosenPaymentModuleIdCZ"); $required_cc_info_prerequisite_name = Checkout::getAdditionalPrerequisiteName("creditCardInfo", $payment_module_id); $required_bank_account_info_prerequisite_name = Checkout::getAdditionalPrerequisiteName("bankAccountInfo", $payment_module_id); loadCoreFile('db_multiple_insert.php'); $query = new DB_Multiple_Insert('order_person_data'); $query->setInsertFields(array('order_id', 'person_info_variant_id', 'person_attribute_id', 'order_person_data_name', 'order_person_data_value', 'order_person_data_description', 'order_person_data_b_encrypted', 'order_person_data_encrypted_secret_key', 'order_person_data_rsa_public_key_asc_format')); foreach ($data as $prerequisite_key => $info) { if (_ml_strpos($prerequisite_key, "Module") || $prerequisite_key == 'subscriptionTopics') { //"shippingModuleAndMethod","paymentModule" } else { if (_ml_strpos($prerequisite_key, "creditCardInfo") !== FALSE) { /** * Define, if this creditCardInfo instance matches * the selected payment module. * If it does, then write it to the DB. Make two instances: * 1. not encrypted obfuscaed one * 2. not obfuscated encrypted one. */ if ($prerequisite_key == $required_cc_info_prerequisite_name) { /* Ask the payment module, if it has to store Credit Card Info in the database, or it won't be used after creating the order. */ $mInfo = Checkout::getPaymentModuleInfo($payment_module_id); $mmObj =& $application->getInstance('Modules_Manager'); $mmObj->includeAPIFileOnce($mInfo["APIClassName"]); /* This condition can be checked only after loading */ if (is_callable(array($mInfo["APIClassName"], "storeCreditCardInfoInDB"))) { $b_storeCreditCardInfoInDB = call_user_func(array($mInfo["APIClassName"], 'storeCreditCardInfoInDB')); if ($b_storeCreditCardInfoInDB === true) { $symmetric_secret_key = modApiFunc("Crypto", "blowfish_gen_blowfish_key"); $rsa_public_key = modApiFunc("Payment_Module_Offline_CC", "getRSAPublicKeyInCryptRSAFormat"); $rsa_public_key_asc_format = modApiFunc("Payment_Module_Offline_CC", "getRSAPublicKeyInASCFormat"); $rsa_obj = new Crypt_RSA(); $encrypted_symmetric_secret_key = $rsa_obj->encrypt($symmetric_secret_key, $rsa_public_key); //Decrypt data in the session $this->decrypt_prerequisite_with_checkout_cz_blowfish_key($prerequisite_key); $decrypted_data = $this->getPrerequisitesValidationResults(); $info = $decrypted_data[$prerequisite_key]; //Encrypt data in the session $this->encrypt_prerequisite_with_checkout_cz_blowfish_key($prerequisite_key); $person_info_variant_id = $this->getPersonInfoVariantId($prerequisite_key, $info['variant_tag']); //Encrypt data in the session foreach ($info["validatedData"] as $attribute_key => $validatedData) { $attribute_id = $validatedData["id"]; $attribute_visible_name = $validatedData["attribute_visible_name"]; if ($attribute_key == "CreditCardType") { $cc_type_names = modApiFunc("Configuration", "getCreditCardSettings"); $attribute_value = $cc_type_names[$validatedData["value"]]["name"]; } else { $attribute_value = $validatedData["value"]; } $attribute_description = $validatedData["attribute_description"]; // add the not encrypted obfuscated value $b_encrypted = "0"; $i_arr = array('order_id' => $order_id, 'person_info_variant_id' => $person_info_variant_id, 'person_attribute_id' => $attribute_id, 'order_person_data_name' => $attribute_visible_name, 'order_person_data_value' => $this->get_public_view_of_secured_data($attribute_value, $attribute_id), 'order_person_data_description' => $attribute_description, 'order_person_data_b_encrypted' => $b_encrypted, 'order_person_data_encrypted_secret_key' => $encrypted_symmetric_secret_key, 'order_person_data_rsa_public_key_asc_format' => $rsa_public_key_asc_format); $query->addInsertValuesArray($i_arr); // add the not obfuscated encrypted value $i_arr['order_person_data_b_encrypted'] = "1"; $i_arr['order_person_data_value'] = base64_encode($this->encryptOrderPersonAttribute($attribute_value, $symmetric_secret_key)); $query->addInsertValuesArray($i_arr); } } } } } else { // , , // , , // . if (_ml_strpos($prerequisite_key, "bankAccountInfo") !== FALSE && $required_bank_account_info_prerequisite_name != $prerequisite_key) { //BankAccountInfo, } else { $person_info_variant_id = $this->getPersonInfoVariantId($prerequisite_key, $info['variant_tag']); // add to the table order_person_data foreach ($info["validatedData"] as $attribute_key => $validatedData) { if ($attribute_key == "Statemenu" || $attribute_key == "Statetext") { //An attribute "state" from the DB matches two attributes // state_menu and state_text in the session. They are mutually exclussive in meaning: // state_menu is the ID of the record about the state in the DB, i.e. // a number. sate_text is a state name, inputted manually by a customer. // It is inputted only if the customer selected a country, which has no // defined states in the DB. As for now (Dec 2005) in the DB // in the field "state" is saved only one of the values, which is not empty. // Either sate_menu, or state_text. if ($attribute_key == "Statetext") { continue; } if ($attribute_key == "Statemenu") { $state_menu_value = $info["validatedData"]["Statemenu"]["value"]; $state_text_value = $info["validatedData"]["Statetext"]["value"]; //FIMXE: check if both values are empty. $value = empty($state_menu_value) ? $state_text_value : $state_menu_value; //: analyze the conversion "1 atribute" <=> "2 attributes" for // "state". As for now(Dec 2005) data on DB-attribute "state" // is saved to the session-attribute "Statemenu" //Write a state name, but not the id //: depends on another attribute value: Country if (is_numeric($value)) { //: can validatedData contain a nested // structure with the same name validatedData? $states = modApiFunc("Location", "getStates", $info["validatedData"]["Country"]["value"]); $value = $states[$value]; } // add to the table order_person_data $i_arr = array('order_id' => $order_id, 'person_info_variant_id' => $person_info_variant_id, 'person_attribute_id' => $validatedData["id"], 'order_person_data_name' => $validatedData["attribute_visible_name"], 'order_person_data_value' => $value, 'order_person_data_description' => $validatedData["attribute_description"], 'order_person_data_b_encrypted' => "0", 'order_person_data_encrypted_secret_key' => "", 'order_person_data_rsa_public_key_asc_format' => ""); $query->addInsertValuesArray($i_arr); } } else { //Write a name for the country rather than the id if ($attribute_key == "Country") { $countries = modApiFunc("Location", "getCountries"); $value = empty($validatedData["value"]) ? "" : $countries[$validatedData["value"]]; } else { $value = $validatedData["value"]; } $i_arr = array('order_id' => $order_id, 'person_info_variant_id' => $person_info_variant_id, 'person_attribute_id' => $validatedData["id"], 'order_person_data_name' => $validatedData["attribute_visible_name"], 'order_person_data_value' => $value, 'order_person_data_description' => $validatedData["attribute_description"], 'order_person_data_b_encrypted' => "0", 'order_person_data_encrypted_secret_key' => "", 'order_person_data_rsa_public_key_asc_format' => ""); $query->addInsertValuesArray($i_arr); } } } } } } $application->db->PrepareSQL($query); return $application->db->DB_Exec(); }
/** * @ describe the function ProductList->getTag. */ function getTag($tag) { global $application; $value = null; $CatID = modApiFunc('CProductListFilter', 'getCurrentCategoryId'); $moveto_category_full_path = modApiFunc("Catalog", "getCategoryFullPath", modApiFunc("Catalog", "getMoveToCategoryID")); switch ($tag) { case 'HiddenArrayViewState': $value = $this->outputViewState(); break; case 'asc_action': $value = $this->outputAction(); break; case 'Items': $value = $this->outputSubcategoriesList(modApiFunc("Catalog", "getMoveToCategoryID")); break; case 'New_Path': $value = $this->outputLocationBreadcrumb($moveto_category_full_path, true); break; case 'New_Path_Breadcrumb': $value = $this->outputNewLocation($moveto_category_full_path); break; case 'Move_Href': $value = $this->outputMoveHref(); break; case 'Move_Object': $value = $this->outputMoveObject(); break; case 'Move_Subject': $value = $this->outputMoveSubject(); break; case 'Breadcrumb': $obj =& $application->getInstance('Breadcrumb'); $value = $obj->output(false); break; case 'Button': $value = $this->outputButton(); break; default: if (_ml_strpos($tag, 'Category') === 0) { $tag = _ml_substr($tag, _ml_strlen('Category')); } if ($this->_Current_Category->isTagExists($tag)) { $value = $this->_Current_Category->getCategoryTagValue($tag); } break; } return $value; }
/** * Function to get data. */ function &get_data() { $return = ''; $line = ''; $loops = 0; if (is_resource($this->connection)) { while ((_ml_strpos($return, CRLF) === FALSE or _ml_substr($line, 3, 1) !== ' ') and $loops < 100) { $line = fgets($this->connection, 512); $return .= $line; $loops++; } return $return; } else { return FALSE; } }
function getInputTypeActualValue($value) { if (_ml_strpos($value, 'PRDTYPE_VALUE_') === 0) { return getMsg('SYS', $value); } return $value; }
/** * stripos */ function _ml_stripos($haystack, $needle, $offset = 0) { global $application; if (!$application->multilang_core->_mb_enabled) { return stripos($haystack, $needle, $offset); } return _ml_strpos(_ml_strtolower($haystack), _ml_strtolower($needle), $offset); }
function getTag($tag) { global $application; $value = null; switch ($tag) { case 'Items': $value = $this->getModulesList(); break; case 'ShippingModulesList': $value = "Shipping Modules List"; break; /* case 'SubmitedCheckoutStoreBlocksListItemName': $value = "SubmitedCheckoutStoreBlocksList[shipping-method-list-input]"; break;*/ /* case 'SubmitedCheckoutStoreBlocksListItemName': $value = "SubmitedCheckoutStoreBlocksList[shipping-method-list-input]"; break;*/ case 'List_SelectedModules': $items = array(); $SelectedModules = modApiFunc("Checkout", "getSelectedModules", "shipping"); $new_selected_module_sort_order = 0; $modules = $this->getInstalledModulesListData(); foreach ($modules as $module) { $name = _ml_strtolower($module->name); $Shipping_group = modApiFunc("Checkout", "getShippingModuleGroup", $module); if ($Shipping_group != '') { $smInfo = modApiFunc($name, "getInfo"); //// INCORRECT method to get group name! Remove group name from id at all. //$groups_array = explode(',', $module->groups); if (array_key_exists($smInfo['GlobalUniqueShippingModuleID'], $SelectedModules)) { $ShippingModulesGroupsInfo = modApiFunc("Checkout", "getShippingModulesGroupsInfo"); //If sort id is not defined then assign the highest possible sort id to this item: 0, -1, -2 ... $sort_id = empty($SelectedModules[$smInfo["GlobalUniqueShippingModuleID"]]["sort_order"]) ? $new_selected_module_sort_order-- : $SelectedModules[$smInfo["GlobalUniqueShippingModuleID"]]["sort_order"]; $items[$sort_id] = "<option value=\"" . $smInfo['GlobalUniqueShippingModuleID'] . "\" id=\"" . $smInfo['GlobalUniqueShippingModuleID'] . "\">" . prepareHTMLDisplay($smInfo["Name"]) . "</option>"; } } } //Sort items by sort id and implode them. ksort($items, SORT_NUMERIC); $value = implode("", $items); break; case 'HiddenSelectedModules': //Hidden field to store selected ("Selected Shipping Modules") select state $value = ""; $SelectedModules = modApiFunc("Checkout", "getSelectedModules", "shipping"); $new_selected_module_sort_order = 0; $modules = $this->getInstalledModulesListData(); foreach ($modules as $module) { $name = _ml_strtolower($module->name); $Shipping_group = modApiFunc("Checkout", "getShippingModuleGroup", $module); if ($Shipping_group != '') { $smInfo = modApiFunc($name, "getInfo"); //// INCORRECT method to get group name! Remove group name from id at all. //$groups_array = explode(',', $module->groups); if (array_key_exists($smInfo['GlobalUniqueShippingModuleID'], $SelectedModules)) { $ShippingModulesGroupsInfo = modApiFunc("Checkout", "getShippingModulesGroupsInfo"); //If sort id is not defined then assign the highest possible sort id to this item: 0, -1, -2 ... $sort_id = empty($SelectedModules[$smInfo["GlobalUniqueShippingModuleID"]]["sort_order"]) ? $new_selected_module_sort_order-- : $SelectedModules[$smInfo["GlobalUniqueShippingModuleID"]]["sort_order"]; $value .= $value == "" ? $smInfo['GlobalUniqueShippingModuleID'] : "," . $smInfo['GlobalUniqueShippingModuleID']; } } } break; case 'SaveSelectedShippingModulesListHref': //// $request = new Request(); //// $request->setView ('CheckoutShippingModulesList'); $value = $application->getPagenameByViewname("StoreSettingsPage", -1, -1, 'AdminZone'); //////: should set action? //// $request->setAction('SaveSelectedShippingModulesList'); //// $value = modApiFunc('application', 'href', $request); break; case 'HiddenFieldAction': loadCoreFile('html_form.php'); $HtmlForm = new HtmlForm(); $value = $HtmlForm->genHiddenField('asc_action', 'SaveSelectedShippingModulesList'); break; case 'HiddenArrayViewState': break; case 'getShippingModuleInfoItemsJS': $value = ""; $modules = $this->getInstalledModulesListData(); foreach ($modules as $module) { $name = _ml_strtolower($module->name); $pmInfo = modApiFunc($name, "getInfo"); $Shipping_group = modApiFunc("Checkout", "getShippingModuleGroup", $module); if ($Shipping_group != '') { $ShippingModulesGroupsInfo = modApiFunc("Checkout", "getShippingModulesGroupsInfo"); $value .= "case '" . $pmInfo['GlobalUniqueShippingModuleID'] . "': switch(key){case 'ShippingModulesGroupID': value = '" . $Shipping_group . "'; break; case 'ShortName': value ='" . $pmInfo["Name"] . "'; break; case 'FullName': value ='" . $pmInfo["Name"] . "'; break;}; break;"; //e.g. ShippingModulesGroupID = OnlineCC // ShortName = Paypal // FullName = [Online CC]Paypal //Notice whitespace in "[Online CC]" } } break; case 'getShippingModuleGroupsItemsJS': $value = ""; $ShippingModulesGroupsInfo = modApiFunc("Checkout", "getShippingModulesGroupsInfo"); $bFirstItem = true; foreach ($ShippingModulesGroupsInfo as $ShippingModulesGroupInfo) { if ($bFirstItem) { $value .= "'" . $ShippingModulesGroupInfo['group_id'] . "'"; $bFirstItem = false; } else { $value .= ", '" . $ShippingModulesGroupInfo['group_id'] . "'"; } } break; case 'ShippingModulesLink': $request = new Request(); $request->setView(CURRENT_REQUEST_URL); $value = $request->getURL(); break; case 'ResultMessageRow': $value = $this->outputResultMessage(); break; case 'ResultMessage': $value = $this->_Template_Contents['ResultMessage']; break; default: $value = ""; $pos = _ml_strpos($tag, "_"); if ($pos != FALSE) { $prefix = _ml_substr($tag, 0, $pos); switch ($prefix) { case "ShippingModuleCheckGroupList": //Options for "Offline" "Online CC" "Online eCheck" and "Online Shipping" <select> control. $SelectedModules = modApiFunc("Checkout", "getSelectedModules", "shipping"); $group_name = _ml_substr($tag, _ml_strlen($prefix) + 1); $modules = $this->getInstalledModulesListData(array($group_name)); $free_shipping_sm_guid = modApiFunc('Shipping_Module_Free_Shipping', 'getUID'); foreach ($modules as $module) { $name = _ml_strtolower($module->name); $pmInfo = modApiFunc($name, "getInfo"); if ($pmInfo['GlobalUniqueShippingModuleID'] == $free_shipping_sm_guid) { continue; } $value .= "<ul id='isSelect' class='list-inline'><li style='list-style-type: none;'>"; if (array_key_exists($pmInfo['GlobalUniqueShippingModuleID'], $SelectedModules)) { $value .= "<label id='module-name'><input type='checkbox' class='checkbox-inline' name='sel_shipping' value='" . $pmInfo['GlobalUniqueShippingModuleID'] . "' id='chk_" . $pmInfo['GlobalUniqueShippingModuleID'] . "' style='margin: 0px 0px 2px;' checked>" . prepareHTMLDisplay($pmInfo["Name"]) . "</label></li></ul>"; } else { $value .= "<label id='module-name'><input type='checkbox' class='checkbox-inline' name='sel_shipping' value='" . $pmInfo['GlobalUniqueShippingModuleID'] . "' id='chk_" . $pmInfo['GlobalUniqueShippingModuleID'] . "' style='margin: 0px 0px 2px;'>" . prepareHTMLDisplay($pmInfo["Name"]) . "</label></li></ul>"; } } break; case "ShippingModuleGroupList": //Options for "Offline" "Online CC" "Online eCheck" and "Online Shipping" <select> control. $SelectedModules = modApiFunc("Checkout", "getSelectedModules", "shipping"); $group_name = _ml_substr($tag, _ml_strlen($prefix) + 1); $modules = $this->getInstalledModulesListData(array($group_name)); $free_shipping_sm_guid = modApiFunc('Shipping_Module_Free_Shipping', 'getUID'); foreach ($modules as $module) { $name = _ml_strtolower($module->name); $pmInfo = modApiFunc($name, "getInfo"); if ($pmInfo['GlobalUniqueShippingModuleID'] == $free_shipping_sm_guid) { continue; } if (!array_key_exists($pmInfo['GlobalUniqueShippingModuleID'], $SelectedModules)) { $value .= "<option value=\"" . $pmInfo['GlobalUniqueShippingModuleID'] . "\">" . prepareHTMLDisplay($pmInfo["Name"]) . "</option>"; } } break; case "HiddenAvailable": break; default: ////// can it be Current Module (Modules List Item) details? ////_fatal(__CLASS__ .'::'. __FUNCTION__. ': prefix = ' . $prefix); break; } } else { //Current Module (Modules List Item) details $value = getKeyIgnoreCase($tag, $this->_Current_Module); } break; } return $value; }
/** * DB_Table_Create class constructor. * * @return * @param array $tables array of meta description of the tables. * @ change error messages to error description from resource file */ function DB_Table_Create_Query($tables) { global $application; $table_prefix = $application->getAppIni('DB_TABLE_PREFIX'); foreach ($tables as $table_name => $table_properties) { $table_name = $table_prefix . $table_name; // if (DB_MySQL::DB_isTableExists($table_name)) // { // _fatal(array( "CODE" => "CORE_043"), $table_name); // } $this->QueryType = DBQUERY_TYPE_CREATE; $this->CreateTable = $table_name; $this->CreateFields = array(); $this->CreateKeys = array(); $this->CreateIndexes = array(); foreach ($table_properties['columns'] as $key => $field) { $this->addField($this->parseFieldName($field), $table_properties['types'][$key]); } if (isset($table_properties['primary']) && sizeof($table_properties['primary']) > 0) { $primary_key = array(); foreach ($table_properties['primary'] as $pk) { array_push($primary_key, $this->parseFieldName($table_properties['columns'][$pk])); } $this->addKey(implode(', ', $primary_key)); } if (isset($table_properties['indexes']) && sizeof($table_properties['indexes']) > 0) { foreach ($table_properties['indexes'] as $index_name => $field_names) { $field_names = str_replace(' ', '', $field_names); $fields = explode(',', $field_names); $index = array(); foreach ($fields as $field) { // , if (is_int($_pos = _ml_strpos($field, '('))) { $_len = _ml_substr($field, $_pos); $_field_without_len = _ml_substr($field, 0, $_pos); array_push($index, $this->parseFieldName($table_properties['columns'][$_field_without_len]) . $_len); } else { array_push($index, $this->parseFieldName($table_properties['columns'][$field])); } } $this->addIndex(implode(', ', $index), $index_name); } } } }
/** * */ function onAction() { global $application; $URL_correct = false; $request =& $application->getInstance('Request'); $HTTPSURL = $request->getValueByKey('HTTPSURL'); $SessionPost = array("URLS" => array("HTTPS_URL" => $HTTPSURL), "SECURE_SECTIONS" => array("AllAdminArea" => $request->getValueByKey('All') ? "true" : "", "SignIn_AdminMembers" => $request->getValueByKey('SignIn_AdminMembers') ? "true" : "", "Orders_Customers" => $request->getValueByKey('Orders_Customers') ? "true" : "", "Payment_Shipping" => $request->getValueByKey('Payment_Shipping') ? "true" : ""), "Message" => "", "FirstTimeSettings" => $request->getValueByKey('FirstTimeSettings')); if ($HTTPSURL) { $HTTPSURL = "https://" . $HTTPSURL; $parsedURL = @parse_url($HTTPSURL); if (isset($parsedURL["host"])) { if (isset($parsedURL["path"])) { $pos = _ml_strpos($parsedURL["path"], "/avactis-system"); if (!($pos === false)) { $parsedURL["path"] = _ml_substr($parsedURL["path"], 0, $pos + 1); } } $HTTPSURL = $parsedURL["host"]; $HTTPSURL .= isset($parsedURL["port"]) && $parsedURL["port"] != "" ? ":" . $parsedURL["port"] : ""; $HTTPSURL .= isset($parsedURL["path"]) && $parsedURL["path"] != "" ? $parsedURL["path"] : "/"; $HTTPSURL .= $HTTPSURL[_byte_strlen($HTTPSURL) - 1] != "/" ? "/" : ""; $SessionPost["URLS"]["HTTPS_URL"] = "https://" . $HTTPSURL; $URL_correct = $this->sendRequest("https://" . $HTTPSURL); /* if (!$URL_correct) { $HTTPSURL = $parsedURL["host"]; $HTTPSURL.= (isset($parsedURL["port"]) && $parsedURL["port"] != ""? ":".$parsedURL["port"]:""); $HTTPSURL.= "/".@parse_url($application->getAppIni('HTTP_URL'), PHP_URL_PATH); $HTTPSURL.= $HTTPSURL[_byte_strlen($HTTPSURL)-1] != "/"? "/":""; $URL_correct = $this->sendRequest("https://".$HTTPSURL); } */ if ($URL_correct || $request->getValueByKey('SSLAvailable') == "false") { $SessionPost["URLS"]["HTTPS_URL"] = "https://" . $HTTPSURL; #https_config.php file content $file_cotent = ";<?php exit(); >\n\n"; $file_cotent .= "[URLS]\n"; $file_cotent .= "HTTPS_URL = \"https://" . $HTTPSURL . "\"\n"; #if ($SessionPost["SECURE_SECTIONS"]["AllAdminArea"] == "true") #{ # $file_cotent.= "HTTP_URL = \"https://".$HTTPSURL."\"\n"; #} $file_cotent .= "\n[SECURE_SECTIONS]\n"; foreach ($SessionPost["SECURE_SECTIONS"] as $key => $val) { $file_cotent .= $key . " = " . $val . "\n"; } $file_name = $application->getAppIni("PATH_CONF_DIR") . "https_config.php"; $fp = @fopen($file_name, "w"); if ($fp) { @fwrite($fp, $file_cotent); @fclose($fp); if (!file_exists($file_name)) { #Can't create file $file_name $SessionPost["Message"] = "HTTPS_WRN_005"; } } else { #Can't write to the folder 'avactis-system' $SessionPost["Message"] = "HTTPS_WRN_004"; } } else { //Could't connect $SessionPost["Message"] = "HTTPS_WRN_003"; } } else { //Wrong URL syntax $SessionPost["Message"] = "HTTPS_WRN_002"; } } else { if ($SessionPost["FirstTimeSettings"] == "true") { //URL - isn't entered $SessionPost["Message"] = "HTTPS_WRN_001"; } elseif ($SessionPost["FirstTimeSettings"] == "false") { $SessionPost["Message"] = "HTTPS_WRN_006"; $SessionPost["FirstTimeSettings"] = ""; } else { $file_name = $application->getAppIni("PATH_CONF_DIR") . "https_config.php"; @unlink($file_name); if (file_exists($file_name)) { #Can't remove file $file_name $SessionPost["Message"] = "HTTPS_WRN_007"; } } } if ($SessionPost["Message"]) { modApiFunc('Session', 'set', 'SessionPost', $SessionPost); } else { // $SessionPost["hasCloseScript"] = "true"; modApiFunc('Session', 'set', 'SessionPost', $SessionPost); } if ($URL_correct) { // CZ : $layouts_from_bd = modApiFunc("Configuration", "getLayoutSettings"); foreach ($layouts_from_bd as $fname => $info) { $info =& $layouts_from_bd[$fname]; // , , : $k = 'layout_' . $info['id'] . '_res'; $res = $request->getValueByKey($k); if ($res === NULL) { $res = array(); } else { $res = explode('|', $res); } // Configuration : $sections = array_unique(array_values(modApiFunc("Configuration", "getLayoutSettingNameByCZLayoutSectionNameMap"))); foreach ($sections as $section) { if (in_array($section, $res)) { $info[$section] = DB_TRUE; } else { $info[$section] = DB_FALSE; } } unset($info); } modApiFunc("Session", "set", "ResultMessage", 'HTTPS_SETTINGS_SAVED'); modApiFunc("Configuration", "setLayoutSettings", $layouts_from_bd); $request = new Request(); $request->setView('HTTPSSettings'); $application->redirect($request); } }
/** * build apache mod_rewrite block for .htaccess file */ function genRewriteBlock($cz_layout_file_path) { global $application; $cz_layouts = array_keys(LayoutConfigurationManager::static_get_cz_layouts_list()); for ($i = 0; $i < count($cz_layouts); $i++) { $cz_layouts[$i] = $this->_prepareAbsFilePath($cz_layouts[$i]); } if (!in_array($cz_layout_file_path, $cz_layouts)) { return null; } $parsed_info = _parse_cz_layout_ini_file($cz_layout_file_path, true); # prepare info for categories pages $cats_info = array('by_id' => array(), 'as_sub' => array(), 'default' => ''); foreach ($parsed_info['ProductList'] as $layout_key => $rel_script_path) { // $layout_key = str_replace(' ', '', $layout_key); if (_ml_strtolower($layout_key) == 'default') { $cats_info['default'] = trim(_ml_strtolower($rel_script_path)); continue; } if (preg_match("/^categories\\s*\\{([0-9\\,\\+]+)\\}\$/i", trim(_ml_strtolower($layout_key)), $matches)) { $row_ids = array_map("trim", explode(",", $matches[1])); foreach ($row_ids as $row_id) { if (_ml_strpos($row_id, '+') === false) { $fine_id = intval($row_id); $cats_info['by_id'][trim(_ml_strtolower($rel_script_path))][] = $fine_id; } else { $fine_id = intval($row_id); $cats_info['as_sub'][trim(_ml_strtolower($rel_script_path))][] = $fine_id; } } } } $rw_strings = array(); # 1. , ID if (!empty($cats_info['by_id'])) { foreach ($cats_info['by_id'] as $rel_script_path => $ids_array) { $str = str_replace(array('%category_id%', '%page_number%', '%parent_cid%', '%query_cat_prefix%', '%seo_cat_prefix%'), array(implode('|', $ids_array), '[0-9]+', '', $this->queries_prefixes['category'], '.*'), $this->rewrite_scheme['category']); $rw_strings[] = 'RewriteRule ' . $str . ' ' . $rel_script_path . '?' . $this->queries_suffixes['category'] . ' [L]'; # . //$rw_strings[]='RewriteRule ^'.$this->queries_prefixes['category'].'/('.implode('|',$ids_array).')/([0-9])+/.*\.html '.$rel_script_path.'?'.$this->queries_suffixes['category'].' [L]'; } } # 2. ID+ if (!empty($cats_info['as_sub'])) { foreach ($cats_info['as_sub'] as $rel_script_path => $ids_array) { $str = str_replace(array('%category_id%', '%page_number%', '%parent_cid%', '%query_cat_prefix%', '%seo_cat_prefix%'), array('[0-9]+', '[0-9]+', '-' . (count($ids_array) > 1 ? '(' : '') . implode('|', $ids_array) . (count($ids_array) > 1 ? ')' : '') . '\\+', $this->queries_prefixes['category'], '.*'), $this->rewrite_scheme['category']); $rw_strings[] = 'RewriteRule ' . $str . ' ' . $rel_script_path . '?' . $this->queries_suffixes['category'] . ' [L]'; # . //$rw_strings[]='RewriteRule ^'.$this->queries_prefixes['category'].'/([0-9])+/([0-9])+/('.(implode('|',$ids_array)).'\+)/.*\.html '.$rel_script_path.'?'.$this->queries_suffixes['category'].' [L]'; } } # 3. $str = str_replace(array('%category_id%', '%page_number%', '%parent_cid%', '%query_cat_prefix%', '%seo_cat_prefix%'), array('[0-9]+', '[0-9]+', '', $this->queries_prefixes['category'], '.*'), $this->rewrite_scheme['category']); $rw_strings[] = 'RewriteRule ' . $str . ' ' . $cats_info['default'] . '?' . $this->queries_suffixes['category'] . ' [L]'; # . //$rw_strings[] = 'RewriteRule ^'.$this->queries_prefixes['category'].'/([0-9])+/([0-9])+/.*\.html '.$cats_info['default'].'?'.$this->queries_suffixes['category'].' [L]'; $prods_info = array('by_id' => array(), 'as_cat_child' => array('by_id' => array(), 'as_sub' => array()), 'default' => ''); foreach ($parsed_info['ProductInfo'] as $layout_key => $rel_script_path) { // $layout_key = str_replace(' ', '', $layout_key); if (_ml_strtolower($layout_key) == 'default') { $prods_info['default'] = trim(_ml_strtolower($rel_script_path)); continue; } if (preg_match("/products\\s*\\{([0-9\\,]+)\\}/i", $layout_key, $matches)) { $row_ids = array_map("trim", explode(",", $matches[1])); foreach ($row_ids as $row_id) { $fine_id = intval($row_id); $prods_info['by_id'][trim(_ml_strtolower($rel_script_path))][] = $fine_id; } continue; } if (preg_match("/categories\\s*\\{([0-9\\,\\+]+)\\}/i", $layout_key, $matches)) { $row_ids = array_map("trim", explode(",", $matches[1])); foreach ($row_ids as $row_id) { if (_ml_strpos($row_id, "+") === false) { $fine_id = intval($row_id); $prods_info['as_cat_child']['by_id'][trim(_ml_strtolower($rel_script_path))][] = $fine_id; } else { $fine_id = intval($row_id); $prods_info['as_cat_child']['as_sub'][trim(_ml_strtolower($rel_script_path))][] = $fine_id; } } } } # 1. ID if (!empty($prods_info['by_id'])) { foreach ($prods_info['by_id'] as $rel_script_path => $ids_array) { $str = str_replace(array('%product_id%', '%parent_cid%', '%query_prod_prefix%', '%seo_prod_prefix%'), array(implode('|', $ids_array), '', $this->queries_prefixes['product'], '.*'), $this->rewrite_scheme['product']); $rw_strings[] = 'RewriteRule ' . $str . ' ' . $rel_script_path . '?' . $this->queries_suffixes['product'] . ' [L]'; # . //$rw_strings[] = 'RewriteRule ^'.$this->queries_prefixes['product'].'/('.implode('|',$ids_array).')/.*\.html '.$rel_script_path.'?'.$this->queries_suffixes['product'].' [L]'; } } # 2. ID if (!empty($prods_info['as_cat_child']['by_id'])) { foreach ($prods_info['as_cat_child']['by_id'] as $rel_script_path => $ids_array) { $str = str_replace(array('%product_id%', '%parent_cid%', '%query_prod_prefix%', '%seo_prod_prefix%'), array('[0-9]+', '-' . (count($ids_array) > 1 ? '(' : '') . implode('|', $ids_array) . (count($ids_array) > 1 ? ')' : ''), $this->queries_prefixes['product'], '.*'), $this->rewrite_scheme['product']); $rw_strings[] = 'RewriteRule ' . $str . ' ' . $rel_script_path . '?' . $this->queries_suffixes['product'] . ' [L]'; # . //$rw_strings[] = 'RewriteRule ^'.$this->queries_prefixes['product'].'/([0-9]+)/('.implode('|',$ids_array).')/.*\.html '.$rel_script_path.'?'.$this->queries_suffixes['product'].' [L]'; } } # 3. ID+ if (!empty($prods_info['as_cat_child']['as_sub'])) { foreach ($prods_info['as_cat_child']['as_sub'] as $rel_script_path => $ids_array) { $str = str_replace(array('%product_id%', '%parent_cid%', '%query_prod_prefix%', '%seo_prod_prefix%'), array('[0-9]+', '-' . (count($ids_array) > 1 ? '(' : '') . implode('|', $ids_array) . (count($ids_array) > 1 ? ')' : '') . '\\+', $this->queries_prefixes['product'], '.*'), $this->rewrite_scheme['product']); $rw_strings[] = 'RewriteRule ' . $str . ' ' . $rel_script_path . '?' . $this->queries_suffixes['product'] . ' [L]'; # . //$rw_strings[] = 'RewriteRule ^'.$this->queries_prefixes['product'].'/([0-9]+)/('.implode('|',$ids_array).'\+)/.*\.html '.$rel_script_path.'?'.$this->queries_suffixes['product'].' [L]'; } } # 4. $str = str_replace(array('%product_id%', '%parent_cid%', '%query_prod_prefix%', '%seo_prod_prefix%'), array('[0-9]+', '', $this->queries_prefixes['product'], '.*'), $this->rewrite_scheme['product']); $rw_strings[] = 'RewriteRule ' . $str . ' ' . $prods_info['default'] . '?' . $this->queries_suffixes['product'] . ' [L]'; # . //$rw_strings[] = 'RewriteRule ^'.$this->queries_prefixes['product'].'/([0-9])+/.*\.html '.$prods_info['default'].'?'.$this->queries_suffixes['product'].' [L]'; $cms_info = array('by_id' => array(), 'as_sub' => array(), 'default' => ''); foreach ($parsed_info['CMSPage'] as $layout_key => $rel_script_path) { // $layout_key = str_replace(' ', '', $layout_key); if (_ml_strtolower($layout_key) == 'default') { $cms_info['default'] = trim(_ml_strtolower($rel_script_path)); continue; } if (preg_match("/cmspage\\s*\\{([0-9\\,]+)\\}/i", $layout_key, $matches)) { $row_ids = array_map("trim", explode(",", $matches[1])); foreach ($row_ids as $row_id) { $fine_id = intval($row_id); $cms_info['by_id'][trim(_ml_strtolower($rel_script_path))][] = $fine_id; } continue; } } # . ID if (!empty($cms_info['by_id'])) { foreach ($cms_info['by_id'] as $rel_script_path => $ids_array) { $str = str_replace(array('%page_id%', '%query_cms_prefix%', '%seo_cms_prefix%'), array(implode('|', $ids_array), $this->queries_prefixes['cmspage'], '.*'), $this->rewrite_scheme['cmspage']); $rw_strings[] = 'RewriteRule ' . $str . ' ' . $rel_script_path . '?' . $this->queries_suffixes['cmspage'] . ' [L]'; # . //$rw_strings[] = 'RewriteRule ^'.$this->queries_prefixes['product'].'/('.implode('|',$ids_array).')/.*\.html '.$rel_script_path.'?'.$this->queries_suffixes['product'].' [L]'; } } # 2. ID if (!empty($cms_info['as_cat_child']['by_id'])) { foreach ($cms_info['as_cat_child']['by_id'] as $rel_script_path => $ids_array) { $str = str_replace(array('%page_id%', '%query_cms_prefix%', '%seo_cms_prefix%'), array('[0-9]+', '-' . (count($ids_array) > 1 ? '(' : '') . implode('|', $ids_array) . (count($ids_array) > 1 ? ')' : ''), $this->queries_prefixes['cmspage'], '.*'), $this->rewrite_scheme['cmspage']); $rw_strings[] = 'RewriteRule ' . $str . ' ' . $rel_script_path . '?' . $this->queries_suffixes['cmspage'] . ' [L]'; # . //$rw_strings[] = 'RewriteRule ^'.$this->queries_prefixes['product'].'/([0-9]+)/('.implode('|',$ids_array).')/.*\.html '.$rel_script_path.'?'.$this->queries_suffixes['product'].' [L]'; } } # 3. ID+ if (!empty($cms_info['as_cat_child']['as_sub'])) { foreach ($cms_info['as_cat_child']['as_sub'] as $rel_script_path => $ids_array) { $str = str_replace(array('%page_id%', '%query_cms_prefix%', '%seo_cms_prefix%'), array('[0-9]+', '-' . (count($ids_array) > 1 ? '(' : '') . implode('|', $ids_array) . (count($ids_array) > 1 ? ')' : '') . '\\+', $this->queries_prefixes['cmspage'], '.*'), $this->rewrite_scheme['cmspage']); $rw_strings[] = 'RewriteRule ' . $str . ' ' . $rel_script_path . '?' . $this->queries_suffixes['cmspage'] . ' [L]'; # . //$rw_strings[] = 'RewriteRule ^'.$this->queries_prefixes['product'].'/([0-9]+)/('.implode('|',$ids_array).'\+)/.*\.html '.$rel_script_path.'?'.$this->queries_suffixes['product'].' [L]'; } } # 4. $str = str_replace(array('%page_id%', '%query_cms_prefix%', '%seo_cms_prefix%'), array('[0-9]+', $this->queries_prefixes['cmspage'], '.*'), $this->rewrite_scheme['cmspage']); $rw_strings[] = 'RewriteRule ' . $str . ' ' . $cms_info['default'] . '?' . $this->queries_suffixes['cmspage'] . ' [L]'; # . //$rw_strings[] = 'RewriteRule ^'.$this->queries_prefixes['product'].'/([0-9])+/.*\.html '.$prods_info['default'].'?'.$this->queries_suffixes['product'].' [L]'; loadCoreFile('URI.class.php'); $uriObj = new URI($parsed_info['Site']['SiteURL']); # Options +FollowSymLinks //if($application->getAppIni('MR_ADD_FSL_STRING') == 'YES') if ($this->settings['ADD_FSL_STRING'] == 'Y') { $fsl_string = 'Options +FollowSymLinks'; } else { $fsl_string = ''; } # $rw_first = str_replace(array('%http_site_url%', '%url_dir%', '%mr_fsl_string%'), array($parsed_info['Site']['SiteURL'], $uriObj->getPart('dir') . (_ml_substr($uriObj->getPart('dir'), -1) != '/' ? '/' : ''), $fsl_string), file_get_contents(dirname(__FILE__) . '/includes/rewrite_block_first_strings')); # $rw_scheme_block = str_replace(array('%category_prefix%', '%product_prefix%', '%cms_prefix%'), array($this->queries_prefixes['category'], $this->queries_prefixes['product'], $this->queries_prefixes['cmspage']), file_get_contents(dirname(__FILE__) . '/includes/rewrite_block_for_' . $this->settings['rewrite_scheme_name'])); # $rw_last = file_get_contents(dirname(__FILE__) . '/includes/rewrite_block_last_strings'); $rw_block = REWRITE_BLOCK_IDENT_BEGIN . "\n" . $rw_first . "\n" . $rw_scheme_block . "\n" . implode("\n", $rw_strings) . "\n" . $rw_last . "\n" . REWRITE_BLOCK_IDENT_END . "\n"; return $rw_block; }
function getTag($tag) { global $application; $value = null; //$CatID = $this->_Current_Category->getCategoryTagValue('ID'); switch ($tag) { case 'CategoryProducts': $value = $this->_Current_Category->getCategoryTagValue('productsnumber_non_recursively'); break; case 'CategoryProductsRec': $value = $this->_Current_Category->getCategoryTagValue('productsnumberrecursively_all_product_links'); break; case 'FeaturedProducts': $value = $this->outputFeaturedProducts(); break; case 'BestsellersProducts': $value = $this->outputBestsellersProducts(); break; default: if (is_object($this->_Current_Category) && $this->_Current_Category->isTagExists($tag)) { $value = $this->_Current_Category->getCategoryTagValue($tag); } else { if (_ml_strpos($tag, 'Category') === 0) { $tag = _ml_substr($tag, _ml_strlen('Category')); if (is_object($this->_Current_Category) && $this->_Current_Category->isTagExists($tag)) { $value = $this->_Current_Category->getCategoryTagValue($tag); } } } break; } return $value; }
function createXML($tagID, $parentXML = '') { // Creates XML string for a tag object // Specify parent XML to insert new string into parent XML $final = ''; // Get Reference to tag object $tag =& $this->xml_index[$tagID]; $name = $tag->name; $contents = $tag->contents; $attr_count = count($tag->attributes); $child_count = count($tag->tags); $empty_tag = $tag->contents == '' ? true : false; // Create intial tag if ($attr_count == 0) { // No attributes if ($empty_tag === true) { $final = "<{$name} />"; } else { $final = "<{$name}>{$contents}</{$name}>"; } } else { // Attributes present $attribs = ''; foreach ($tag->attributes as $key => $value) { $attribs .= ' ' . $key . "=\"{$value}\""; } if ($empty_tag === true) { $final = "<{$name}{$attribs} />"; } else { $final = "<{$name}{$attribs}>{$contents}</{$name}>"; } } // Search for children if ($child_count > 0) { foreach ($tag->tags as $childID) { $final = $this->createXML($childID, $final); } } if ($parentXML != '') { // Add tag XML to parent XML $stop1 = _ml_strrpos($parentXML, '</'); $stop2 = _ml_strrpos($parentXML, ' />'); if ($stop1 > $stop2) { // Parent already has children $begin_chunk = _ml_substr($parentXML, 0, $stop1); $end_chunk = _ml_substr($parentXML, $stop1, _ml_strlen($parentXML) - $stop1 + 1); $final = $begin_chunk . $final . $end_chunk; } elseif ($stop2 > $stop1) { // No previous children $spc = _ml_strpos($parentXML, ' ', 0); $parent_name = _ml_substr($parentXML, 1, $spc - 1); if ($spc != $stop2) { // Attributes present $parent_attribs = _ml_substr($parentXML, $spc, $stop2 - $spc); } else { // No attributes $parent_attribs = ''; } $final = "<{$parent_name}{$parent_attribs}>{$final}</{$parent_name}>"; } } return $final; }
/** * Adds fields to the SELECT query. * * @return * @param string $field_name table name * @param string $field_alias alias */ function addSelectField($field_name, $field_alias = '') { $pos = _ml_strpos($field_name, '('); if ($pos !== FALSE) { $field = _ml_substr($field_name, $pos + 1); } else { $field = $field_name; } $this->addSelectTableByField($field); if (!array_key_exists($field_name, $this->SelectFields)) { if ($field_alias != '' && in_array($field_alias, $this->SelectFields)) { user_error('This alias already exists', E_USER_ERROR); } else { $this->SelectFields[$field_name] = $field_alias; } } }
/** * */ function outputCCTypes() { global $application; $cc_types = modApiFunc("Configuration", "getCreditCardSettings", false); $retval = ""; $name_input_id = 1; foreach ($cc_types as $type) { $this->_CCType = array("id" => $type["id"], "name" => $type["name"], "name_input_id" => $name_input_id, "tag" => $type["tag"], "visible" => $type["visible"], "type" => _ml_substr($type["tag"], _ml_strlen("common_cc_type")) == "common_cc_type" ? "common" : $type["tag"], "StatusVisible" => $type["visible"] == DB_TRUE ? "SELECTED" : "", "StatusInvisible" => $type["visible"] == DB_TRUE ? "" : "SELECTED"); $name_input_id++; if (_ml_strpos($this->_CCType["tag"], "without_validation") === 0) { $this->_CCType["tag"] = getMsg('SYS', 'CREDIT_CARDS_TAG_COMMON_TYPE'); } $application->registerAttributes($this->_CCType); $retval .= $this->mTmplFiller->fill("configuration/credit_card_settings/", "credit_cards_list_item.tpl.html", array()); } return $retval; }
/** * @ describe the function ManageOrders->. */ function getTag($tag) { global $application; $value = null; switch ($tag) { case 'CountByStatus0': $value = modApiFunc('Checkout', 'getOrderCount', 0); break; case 'CountByStatus1': $value = modApiFunc('Checkout', 'getOrderCount', 1); break; case 'CountByStatus2': $value = modApiFunc('Checkout', 'getOrderCount', 2); break; case 'CountByStatus3': $value = modApiFunc('Checkout', 'getOrderCount', 3); break; case 'SearchStatusSelector': $this->_simple_selector['options'] = array(); $status_array = modApiFunc('Checkout', 'getOrderStatusList'); if (isset($this->_filter['status_id']) && $this->_filter['status_id'] != "") { $this->_simple_selector['selected'] = $this->_filter['status_id']; } foreach ($status_array as $status) { $sel = 0; if (isset($this->_filter['order_statuses']) && is_array($this->_filter['order_statuses']) && isset($this->_filter['order_statuses'][$status['id']])) { $sel = 1; } $this->_simple_selector['options'][] = array('value' => $status['id'], 'name' => $status['name'], 'selected' => $sel); } $value = $this->TemplateFiller->fill("checkout/orders/", "search-status-selector.tpl.html", array()); break; case 'SearchPaymentStatusSelector': $this->_simple_selector['options'] = array(); if (isset($this->_filter['payment_status_id']) && $this->_filter['payment_status_id'] != "") { $this->_simple_selector['selected'] = $this->_filter['payment_status_id']; } $status_array = modApiFunc('Checkout', 'getOrderPaymentStatusList'); foreach ($status_array as $status) { $sel = 0; if (isset($this->_filter['payment_statuses']) && is_array($this->_filter['payment_statuses']) && isset($this->_filter['payment_statuses'][$status['id']])) { $sel = 1; } $this->_simple_selector['options'][] = array('value' => $status['id'], 'name' => $status['name'], 'selected' => $sel); } $value = $this->TemplateFiller->fill("checkout/orders/", "search-payment-status-selector.tpl.html", array()); break; case 'SearchFromDaySelector': $this->_simple_selector['selected'] = $this->_filter['from_day']; $this->_simple_selector['options'] = array(); for ($i = 1; $i <= 31; $i++) { $num = sprintf("%02d", $i); $this->_simple_selector['options'][] = array('value' => $num, 'name' => $i); } $value = $this->TemplateFiller->fill("checkout/orders/", "search-from-day-selector.tpl.html", array()); break; case 'SearchFromMonthSelector': $this->_simple_selector['selected'] = $this->_filter['from_month']; $this->_simple_selector['options'] = array(); for ($i = 1; $i <= 12; $i++) { $num = sprintf("%02d", $i); $this->_simple_selector['options'][] = array('value' => $num, 'name' => $this->MessageResources->getMessage("GENERAL_MONTH_" . $num)); } $value = $this->TemplateFiller->fill("checkout/orders/", "search-from-month-selector.tpl.html", array()); break; case 'SearchFromYearSelector': $this->_simple_selector['selected'] = $this->_filter['from_year']; $this->_simple_selector['options'] = array(); $curr_year_4digits = date('Y'); $start_year = (int) modApiFunc('Settings', 'getParamValue', 'VISUAL_INTERFACE', 'SEARCH_START_YEAR'); $offset_to = modApiFunc('Settings', 'getParamValue', 'VISUAL_INTERFACE', 'SEARCH_YEAR_OFFSET'); for ($i = $start_year; $i <= $curr_year_4digits + $offset_to; $i++) { $this->_simple_selector['options'][] = array('value' => $i, 'name' => $i); } $value = $this->TemplateFiller->fill("checkout/orders/", "search-from-year-selector.tpl.html", array()); break; case 'SearchToDaySelector': if (empty($this->_filter['to_day']) == false) { $this->_simple_selector['selected'] = $this->_filter['to_day']; } else { $this->_simple_selector['selected'] = date("j"); } $this->_simple_selector['options'] = array(); for ($i = 1; $i <= 31; $i++) { $num = sprintf("%02d", $i); $this->_simple_selector['options'][] = array('value' => $num, 'name' => $i); } $value = $this->TemplateFiller->fill("checkout/orders/", "search-to-day-selector.tpl.html", array()); break; case 'SearchToMonthSelector': if (empty($this->_filter['to_month']) == false) { $this->_simple_selector['selected'] = $this->_filter['to_month']; } else { $this->_simple_selector['selected'] = date("m"); } $this->_simple_selector['options'] = array(); for ($i = 1; $i <= 12; $i++) { $num = sprintf("%02d", $i); $this->_simple_selector['options'][] = array('value' => $num, 'name' => $this->MessageResources->getMessage("GENERAL_MONTH_" . $num)); } $value = $this->TemplateFiller->fill("checkout/orders/", "search-to-month-selector.tpl.html", array()); break; case 'SearchToYearSelector': if (empty($this->_filter['to_year']) == false) { $this->_simple_selector['selected'] = $this->_filter['to_year']; } else { $this->_simple_selector['selected'] = date("Y"); } $this->_simple_selector['options'] = array(); $curr_year_4digits = date('Y'); $start_year = (int) modApiFunc('Settings', 'getParamValue', 'VISUAL_INTERFACE', 'SEARCH_START_YEAR'); $offset_to = modApiFunc('Settings', 'getParamValue', 'VISUAL_INTERFACE', 'SEARCH_YEAR_OFFSET'); for ($i = $start_year; $i <= $curr_year_4digits + $offset_to; $i++) { $this->_simple_selector['options'][] = array('value' => $i, 'name' => $i); } $value = $this->TemplateFiller->fill("checkout/orders/", "search-to-year-selector.tpl.html", array()); break; case 'SimpleSelectorOption': $selected = $this->_simple_selector['selected']; $value = ""; foreach ($this->_simple_selector['options'] as $option) { $sel = $option['value'] == $selected ? " selected" : ""; $value .= "<OPTION value=\"" . $option['value'] . "\"" . $sel . ">" . $option['name'] . "</OPTION>\n"; } break; case 'SimpleCheckBoxGroup_Orders': $selected = $this->_simple_selector['selected']; $value = ""; $items_per_col = 2; // number of items per column $idx = 0; $flag = 0; foreach ($this->_simple_selector['options'] as $option) { if ($idx % $items_per_col == 0) { $value .= "<TR>\n"; $flag = 0; } $sel = ""; $highlight = ""; if ($option['selected'] == 1) { $sel = "checked"; if ($this->_filter['search_by'] == "date") { $highlight = "style='color: black;'"; } } $name = "order_" . preg_replace("/ /", "", $option['name']); $value .= "<TD {$highlight}><INPUT class='form-control input-inline input-sm' id='" . $name . "' name='order_status[" . $option['value'] . "]' type='checkbox' " . $sel . "> " . $option['name'] . "</TD>\n"; if ($idx % $items_per_col == 0 && $flag == 1) { $value .= "</TR>\n"; $flag = 0; } $flag = 1; $idx++; } break; case 'SimpleCheckBoxGroup_Payments': $selected = $this->_simple_selector['selected']; $value = ""; $items_per_col = 1; // number of items per column $idx = 0; $flag = 0; foreach ($this->_simple_selector['options'] as $option) { if ($idx % $items_per_col == 0) { $value .= "<TR>\n"; $flag = 0; } $sel = ""; $highlight = ""; if ($option['selected'] == 1) { $sel = "checked"; if ($this->_filter['search_by'] == "date") { $highlight = "color: black;"; } } $name = "payment_" . preg_replace("/ /", "", $option['name']); $value .= "<TD style='margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" . $highlight . "'><INPUT class='form-control input-inline input-sm' id='" . $name . "' name='payment_status[" . $option['value'] . "]' type='checkbox' " . $sel . "> " . $option['name'] . "</TD>\n"; if ($idx % $items_per_col == 0 && $flag == 1) { $value .= "</TR>\n"; $flag = 0; } $flag = 1; $idx++; } break; case 'ResultCount': $from = modApiFunc("Paginator", "getCurrentPaginatorOffset") + 1; $to = modApiFunc("Paginator", "getCurrentPaginatorOffset") + modApiFunc("Paginator", "getPaginatorRowsPerPage", "Checkout_Orders"); $total = modApiFunc("Paginator", "getCurrentPaginatorTotalRows"); if ($to > $total) { $to = $total; } if ($total <= modApiFunc("Paginator", "getPaginatorRowsPerPage", "Checkout_Orders")) { $value = $this->MessageResources->getMessage(new ActionMessage(array("ORDERS_RESULTS_LESS_THEN_ROWS_PER_PAGE_FOUND", $total))); } else { $value = $this->MessageResources->getMessage(new ActionMessage(array("ORDERS_RESULTS_MORE_THEN_ROWS_PER_PAGE_FOUND", $from, $to, $total))); } break; case 'ResultDateRange': $count = count($this->_orders); if ($count == 0) { $value = ""; break; } elseif ($count == 1) { $orderInfo = $this->_fetched_orders[$this->_orders[0]]; $value = modApiFunc("Localization", "SQL_date_format", $orderInfo['order_date']); break; } $first_in_list_order_info = $this->_fetched_orders[$this->_orders[0]]; $last_in_list_order_info = $this->_fetched_orders[$this->_orders[$count - 1]]; $value = $value = modApiFunc("Localization", "SQL_date_format", $last_in_list_order_info['order_date']) . " - " . modApiFunc("Localization", "SQL_date_format", $first_in_list_order_info['order_date']); break; case 'ResultAmount': if (count($this->_orders) == 0) { $value = 0; break; } $amount = 0; $all_orders_are_in_main_currency = true; $main_store_currency = modApiFunc("Localization", "getCurrencyCodeById", modApiFunc("Localization", "getMainStoreCurrency")); foreach ($this->_orders as $order_id) { // order_total main_store_currency . // order' , default ( . . // main_store_currency ). // default currency main_store_currency, // , . order_total // . $order_default_currency = modApiFunc("Localization", "getOrderMainCurrency", $order_id, $this->_fetched_orders[$order_id]['order_currencies_list']); $order_total_in_order_default_currency = $this->_fetched_orders[$order_id]['price_total'][$order_default_currency]['order_total']; if ($order_default_currency == $main_store_currency) { //var_dump($order); $amount += $order_total_in_order_default_currency; } else { $all_orders_are_in_main_currency = false; $total = modApiFunc('Currency_Converter', 'convert', $order_total_in_order_default_currency, $order_default_currency, $main_store_currency); $amount += $total; } } $main_store_currency_id = modApiFunc("Localization", "getMainStoreCurrency"); modApiFunc("Localization", "pushDisplayCurrency", $main_store_currency_id, $main_store_currency_id); $value = modApiFunc("Localization", "currency_format", $amount); modApiFunc("Localization", "popDisplayCurrency"); if ($all_orders_are_in_main_currency == false) { $value = "~" . $value; } break; case 'ResultTaxTotal': break; case 'ResultFullTaxExempt': break; case 'ResultTaxTotalMinusFullTaxExempt': $tax_summary = $this->__getTaxSummary(); $value = $tax_summary[$tag]; break; case 'Items': $value = $this->getOrders(); break; case 'OrderStatusSelector': $value = '<select class="form-control input-sm input-small" name="status_id[' . $this->_order['IdInt'] . ']" onchange="onStatusChanged(' . $this->_order['IdInt'] . ')">'; if (!isset($this->OrderStatusList)) { $this->OrderStatusList = modApiFunc('Checkout', 'getOrderStatusList'); } foreach ($this->OrderStatusList as $status) { $value .= '<option value="' . $status['id'] . '" ' . ($status['id'] == $this->_order['StatusId'] ? " selected" : "") . '>' . $status['name'] . '</option>'; } $value .= '</select>'; break; case 'OrderIdLinkTitle': $value = $this->MessageResources->getMessage('ORDERS_RESULTS_ORDER_ID_LINK_TITLE'); break; case 'OrderCustomerNameLinkTitle': $value = $this->MessageResources->getMessage('ORDERS_RESULTS_ORDER_CUSTOMER_NAME_LINK_TITLE'); break; case 'OrderPaymentStatusSelector': $value = '<select class="form-control input-sm input-small" name="payment_status_id[' . $this->_order['IdInt'] . ']" onchange="onStatusChanged(' . $this->_order['IdInt'] . ')">\\n'; if (!isset($this->OrderPaymentStatusList)) { $this->OrderPaymentStatusList = modApiFunc('Checkout', 'getOrderPaymentStatusList'); } foreach ($this->OrderPaymentStatusList as $status) { $this->_payment_status = $status; $value .= '<option value="' . $status['id'] . '" ' . ($status['id'] == $this->_order['PaymentStatusId'] ? ' selected' : '') . '>' . $status['name'] . '</option>'; } $value .= '</select>'; break; case 'SearchOrders': $value = $this->TemplateFiller->fill("checkout/orders/", "search.tpl.html", array()); break; case 'SearchBy': if ($this->_filter['search_by'] == 'status') { $msg = ""; switch ($this->_filter['filter_status_id']) { case 0: $msg = $this->MessageResources->getMessage('ORDERS_SEARCH_ALL'); break; case 1: $msg = $this->MessageResources->getMessage('ORDERS_SEARCH_NEW_ORDERS'); break; case 2: $msg = $this->MessageResources->getMessage('ORDERS_SEARCH_IN_PROGRESS'); break; case 3: $msg = $this->MessageResources->getMessage('ORDERS_SEARCH_READY_TO_SHIP'); break; } $value = $msg; } elseif ($this->_filter['search_by'] == 'date') { $value = $this->MessageResources->getMessage('ORDERS_SEARCH_FILTER'); } elseif ($this->_filter['search_by'] == 'id') { $value = $this->MessageResources->getMessage('ORDERS_SEARCH_ORDER_ID'); } break; case 'SearchResults': if (count($this->_orders) == 0) { $value = modApiFunc('TmplFiller', 'fill', "checkout/orders/", "empty.tpl.html", array()); } else { $value = $this->TemplateFiller->fill("checkout/orders/", "results.tpl.html", array()); } break; case 'HighLightAll': if ($this->_filter['search_by'] == 'status' && $this->_filter['filter_status_id'] == 0) { $value = "color: blue;"; } break; case 'HighLightNewOrders': if ($this->_filter['search_by'] == 'status' && $this->_filter['filter_status_id'] == 1) { $value = "color: blue;"; } break; case 'HighLightInProgress': if ($this->_filter['search_by'] == 'status' && $this->_filter['filter_status_id'] == 2) { $value = "color: blue;"; } break; case 'HighLightReadyToShip': if ($this->_filter['search_by'] == 'status' && $this->_filter['filter_status_id'] == 3) { $value = "color: blue;"; } break; case 'HighLightDate': if ($this->_filter['search_by'] == 'date') { $value = "color: blue;"; } break; case 'HighLightDateOrderStatus': if ($this->_filter['search_by'] == 'date' && isset($this->_filter['order_statuses'])) { $value = "color: blue;"; } break; case 'HighLightDateOrderPaymentStatus': if ($this->_filter['search_by'] == 'date' && isset($this->_filter['payment_statuses'])) { $value = "color: blue;"; } break; case 'HighLightOrderId': if ($this->_filter['search_by'] == 'id') { $value = "color: blue;"; } break; case 'HighLightAffiliateId': if ($this->_filter['search_by'] == 'date' && !empty($this->_filter['affiliate_id'])) { $value = "style='color: blue;font-weight:bold;'"; } break; case 'SearchingOrderId': $value = ""; if ($this->_filter['search_by'] == 'id' && !empty($this->_filter['order_id'])) { $value = $this->_filter['order_id']; } break; case 'DeleteOrdersLink': $request = new Request(); $request->setView('DeleteOrders'); $request->setAction('SetOrdersForDeleteAction'); $value = $request->getURL(); break; case 'PaginatorLine': $obj =& $application->getInstance($tag); $value = $obj->output("Checkout_Orders", "Orders"); break; # PaginatorRows # PaginatorRows case 'PaginatorRows': $obj =& $application->getInstance($tag); $value = $obj->output("Checkout_Orders", 'Orders', 'PGNTR_ORD_ITEMS'); break; case 'ResultMessageRow': $value = $this->outputResultMessage(); break; case 'ResultMessage': $value = $this->_Template_Contents['ResultMessage']; break; case 'PackingSlipLink': $request = new Request(); $request->setView('OrderPackingSlip'); $request->setAction('SetCurrentOrder'); $request->setKey('order_id', $this->_order['IdInt']); // uncomment the following link to force printing // $request -> setKey('do_print', 'Y'); $value = $request->getURL(); break; case 'InvoiceLink': $request = new Request(); $request->setView('OrderInvoice'); $request->setAction('SetCurrentOrder'); $request->setKey('order_id', $this->_order['IdInt']); // uncomment the following link to force printing // $request -> setKey('do_print', 'Y'); $value = $request->getURL(); break; case 'AffiliateIDSearch': $v = isset($this->_filter['affiliate_id']) ? $this->_filter['affiliate_id'] : ""; $value = "<input type='text' name='affiliate_id' size='28' class='form-control form-filter input-sm' value='" . $v . "' />"; break; default: list($entity, $tag) = getTagName($tag); if ($entity == 'order') { if (_ml_strpos($tag, 'price') === 0) { $tag = _ml_strtolower(_ml_substr($tag, _ml_strlen('price'))); if ($tag == 'total') { $value = $this->_order['Total']; if ($this->_order['TotalInMainStoreCurrency'] !== NULL) { $value = $this->_order['TotalInMainStoreCurrency'] . ' (' . $value . ')'; } } elseif ($tag == 'subtotal') { $value = $this->_order['Subtotal']; } else { if ($tag == 'taxes') { $full_tax_exempt_orders = $this->__getFullTaxExemptOrders(); $code = $this->_fetched_orders[$this->_order['IdInt']]["order_currencies_list"]["CURRENCY_TYPE_MAIN_STORE_CURRENCY"]["currency_code"]; $value = $this->_fetched_orders[$this->_order['IdInt']]["price_total"][$code]["order_tax_total"]; $crcy_id = modApiFunc("Localization", "getCurrencyIdByCode", $code); modApiFunc("Localization", "pushDisplayCurrency", $crcy_id, $crcy_id); $value = modApiFunc("Localization", "currency_format", $value); $null_value = modApiFunc("Localization", "currency_format", "0.0000"); modApiFunc("Localization", "popDisplayCurrency"); if (array_key_exists($this->_order['IdInt'], $full_tax_exempt_orders)) { $value = $null_value . " (ex. {$value})"; } } else { $prices = getKeyIgnoreCase('price', $this->_order); $value = $prices[$tag]; } } } elseif (_ml_strpos($tag, 'customer') === 0) { $tag = _ml_strtolower(_ml_substr($tag, _ml_strlen('customer'))); switch ($tag) { case 'name': $value = $this->_order['PersonName']; break; case 'id': $value = $this->_order['PersonId']; break; case 'infoname': $value = $this->_order['PersonInfoName']; break; } } else { $value = getKeyIgnoreCase($tag, $this->_order); } } break; } return $value; }
function __getTablesOfQuery(&$query_obj) { $table_list_of_query = array(); // $table_list = $query_obj->getSelectTables(); foreach ($table_list as $table_name => $table_alias) { $table_list_of_query[] = $table_name; } // $table_list = $query_obj->getJoinTables(); foreach ($table_list as $table_info) { /* * getJoinTables . * . */ $table = $table_info['TABLE']; if (($pos = _ml_strpos($table, ' ')) !== false) { $table = _ml_substr($table, 0, $pos); } $table_list_of_query[] = $table; } // return array_unique(array_filter($table_list_of_query)); }
/** * @ describe the function OrderInfo->. */ function getTag($tag) { global $application; $value = null; switch ($tag) { case 'CustomerInfo': $value = $this->getCustomerInfo(); break; case 'BillingInfo': $value = $this->getBillingInfo(); break; case 'ShippingInfo': $value = $this->getShippingInfo(); break; case 'CreditCardInfo': $value = $this->getCreditCardInfo(); break; case 'Orders': $value = $this->getOrders(); break; case 'LastOrderId': $value = $this->_customer['ID']; break; case 'CHECKOUT_ORDER_INFO_REMOVE_ENCRYPTED_PERSON_INFO_MSG': case 'CHECKOUT_ORDER_INFO_REMOVE_ENCRYPTED_PERSON_INFO_CONFIRM_MSG': $value = $this->_msg[$tag]; break; default: list($entity, $tag) = getTagName($tag); if ($entity == 'group') { $value = getKeyIgnoreCase($tag, $this->_group); } elseif ($entity == 'attribute') { $value = getKeyIgnoreCase($tag, $this->_attr); } elseif ($entity == 'order') { if (_ml_strpos($tag, 'price') === 0) { $tag = _ml_strtolower(_ml_substr($tag, _ml_strlen('price'))); if ($tag == 'total') { $value = $this->_order['Total']; } elseif ($tag == 'subtotal') { $value = $this->_order['Subtotal']; } else { $prices = getKeyIgnoreCase('price', $this->_order); $value = getKeyIgnoreCase($tag, $prices); } } elseif (_ml_strpos($tag, 'customer') === 0) { $tag = _ml_strtolower(_ml_substr($tag, _ml_strlen('customer'))); $customer = getKeyIgnoreCase('customer', $this->_order); $value = $customer['attr'][$tag]['value']; } else { $value = getKeyIgnoreCase($tag, $this->_order); } } break; } return $value; }
/** * @ describe the function ProductList->getTag. */ function getTag($tag) { global $application; $value = ""; $CatID = $this->getCategoryID(); $full_path_arr = modApiFunc('Catalog', 'getCategoryFullPath', $CatID); loadCoreFile('html_form.php'); $HtmlForm = new HtmlForm(); switch ($tag) { case 'HiddenArrayViewState': $value = $this->outputViewState(); break; case 'asc_action': $value = $this->outputAction(); break; case 'Items': if ($CatID != NULL) { $value = $this->outputListItems($CatID); } break; case 'HiddenFieldAction': $value = $HtmlForm->genHiddenField('asc_action', $this->outputAction()); break; case 'HiddenFieldCatsId': $value = $HtmlForm->genHiddenField('CatsId', implode("|", $this->CatsId)); break; case 'HiddenFieldProdsId': $value = $HtmlForm->genHiddenField('ProdsId', implode("|", $this->ProdsId)); break; case 'Category_Path': $value = $this->outputLocationBreadcrumb($full_path_arr, false); break; case 'Delete_Warning': $value = $this->outputDeleteWarning(prepareHTMLDisplay($full_path_arr[sizeof($full_path_arr) - 1]['name'])); break; case 'DeleteCatHref': $value = $this->outputDeleteHref(); break; case 'Delete_Object': $value = $this->outputDeleteObject(); break; case 'Delete_Subject': $value = $this->outputDeleteSubject(); break; case 'Category_Full_Name': $value = $this->_Current_Category->getCategoryTagValue('Category_Full_Name'); break; case 'ProductDelMessage': $cats_ids = $this->_Current_Product->getCategoriesIDs(); if (count($cats_ids) == 1 || modApiFunc('Session', 'is_set', 'SearchProductFormFilter')) { $value = getMsg('CTL', 'MSG_REAL_PRODUCT_DEL'); } else { unset($cats_ids[array_search($CatID, $cats_ids)]); $strings = array(); foreach ($cats_ids as $cat_id) { $full_path = modApiFunc('Catalog', 'getCategoryFullPath', $cat_id); $names = array(); foreach ($full_path as $pci) { $names[] = $pci['name']; } $strings[] = implode("/", $names); } $value = getMsg('CTL', 'MSG_LINK_PRODUCT_DEL', implode("<br>", $strings)); } break; default: if (_ml_strpos($tag, 'Category') === 0) { $stag = _ml_substr($tag, _ml_strlen('Category')); if (is_object($this->_Current_Category) && $this->_Current_Category->isTagExists($tag)) { $value = $this->_Current_Category->getCategoryTagValue($tag); break; } } if (_ml_strpos($tag, 'Product') === 0) { $stag = _ml_substr($tag, _ml_strlen('Product')); if (is_object($this->_Current_Product) && $this->_Current_Product->isTagExists($stag)) { $value = $this->_Current_Product->getProductTagValue($stag); break; } } if (is_object($this->_Current_Category) && $this->_Current_Category->isTagExists($tag)) { $value = $this->_Current_Category->getCategoryTagValue($tag); } if (is_object($this->_Current_Product) && $this->_Current_Product->isTagExists($tag)) { $value = $this->_Current_Product->getProductTagValue($tag); } break; } return $value; }