function output($mode) { global $application; loadCoreFile('html_form.php'); $this->_prefix = _ml_strtolower($mode); $this->_Prefix = _ml_strtoupper($mode[0]) . _ml_substr($this->_prefix, 1); $this->_PREFIX = _ml_strtoupper($mode); $this->_messageResources =& Subscriptions::getMessageResources(); $this->_tmplFiller = new TmplFiller(dirname(dirname(__FILE__)) . '/templates_az/'); $this->initFormData(); $result = ''; //$action = modApiFunc('Request', 'getValueByKey', 'asc_action'); $action = @$this->POST['asc_action']; $has_errors = sizeof($this->ErrorsArray) > 0; $stage = modApiFunc('Request', 'getValueByKey', 'stage'); if (empty($stage)) { $result = $this->outputAskEmails(); } elseif ($stage == 'confirm') { $result = $this->outputAskConfirmation(); } elseif ($stage == 'finish') { // @ show errors if were modApiFunc("application", "closeChild_UpdateParent"); } return $result; }
/** * */ 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()); }
function updateDataInDB($data) { foreach ($data as $key => $val) { if (_ml_substr($key, 0, 3) == "hf_") { modApiFunc("Location", "updateState", $val, isset($data["ci_" . $val]) ? $data["ci_" . $val] : NULL, isset($data["cb_" . $val]) ? "true" : "false", isset($data["default_state"]) && $data["default_state"] == $val ? "true" : "false"); } } }
function onAction() { global $application; $eid = $_POST["entity_id"]; $pe = $_POST["parent_entity"]; unset($_POST["entity_id"], $_POST["parent_entity"]); $data = array("parent_entity" => $pe, "entity_id" => $eid, "option_name" => $_POST["NewOption"]["OptionName"], "display_name" => $_POST["NewOption"]["DisplayName"], "display_descr" => $_POST["NewOption"]["DisplayDescr"], "option_type" => $_POST["NewOption"]["OptionType"], "show_type" => $_POST["NewOption"]["ShowType"][$_POST["NewOption"]["OptionType"]]); if ($data["option_type"] == "SS") { $data["discard_avail"] = _ml_substr($_POST["NewOption"]["DiscardAvail"], 0, 1); if ($data["discard_avail"] == 'Y') { $data["discard_value"] = $_POST["NewOption"]["DiscardValue"]; } } if ($data["option_type"] == "UF") { $data["discard_avail"] = _ml_substr($_POST["NewOption"]["DiscardAvail"], 0, 1); } if ($data["option_type"] == "CI" and in_array($data["show_type"], array('CBSI', 'CBTA'))) { $data["checkbox_text"] = $_POST["NewOption"]["CheckBoxText"]; } if (!in_array($data["option_type"], array("CI", "UF"))) { $data["use_for_it"] = _ml_substr($_POST["NewOption"]["UseForIT"], 0, 1); } else { $data["use_for_it"] = 'N'; } $check_result = modApiFunc("Product_Options", "checkDataFor", "addOptionToEntity", $data); if ($pe == "product" and !modApiFunc("Catalog", "isCorrectProductId", $data["entity_id"])) { $check_result[] = "E_INVALID_PRODUCT_ID"; } if (!empty($check_result)) { modApiFunc("Session", "set", "Errors", $check_result); $request = new Request(); $request->setKey("parent_entity", $pe); $request->setKey("entity_id", $eid); $request->setView('PO_AddOption'); $application->redirect($request); } else { $add_result = modApiFunc("Product_Options", "addOptionToEntity", $data); if ($add_result == false) { modApiFunc("Session", "set", "SessionPost", $_POST); modApiFunc("Session", "set", "ResultMessage", "MSG_OPTION_NOT_ADDED"); $request = new Request(); $request->setKey("parent_entity", $pe); $request->setKey("entity_id", $eid); $request->setView('PO_AddOption'); $application->redirect($request); } else { modApiFunc("Session", "set", "ResultMessage", "MSG_OPTION_ADDED"); $request = new Request(); $request->setKey("option_id", $add_result); $request->setView('PO_EditOption'); $application->redirect($request); } } }
static function cut_uuid_suffix($text, $style) { // . CCInfo . // : getValidatedDataStructure PersonInfoVariantID, . $uuid_pattern = UUIDUtils::getRegexpPattern($style); $matches = array(); if (preg_match($uuid_pattern, $text, $matches)) { $text = _ml_substr($text, 0, _ml_strlen($text) - UUIDUtils::getLength($style)); } else { } return $text; }
/** * */ function outputBackupFilesList() { if (_ml_strtoupper(_ml_substr(PHP_OS, 0, 3)) === 'WIN') { $retval = modApiFunc('TmplFiller', 'fill', "tools/backup/", "item_win_os.tpl.html", array()); return $retval; } global $application; $retval = ""; $directory = $application->getAppIni('PATH_SYSTEM_DIR') . "backup/"; $n = 0; $backup_list = array(); if ($dir = dir($directory)) { while ($file = $dir->read()) { if (_ml_substr($file, _ml_strrpos($file, '.') + 1) == "abi") { $backup_file_name = _ml_substr($file, 0, _ml_strrpos($file, '.')); if (file_exists($directory . $backup_file_name . ".tar.gz")) { $backup_info = _parse_ini_file($directory . $backup_file_name . ".abi"); if (isset($backup_info["asc_version"]) && $backup_info["asc_version"] == PRODUCT_VERSION_NUMBER) { $request = new Request(); $request->setView('Downdoad'); $request->setKey('directory', 'backup'); $request->setKey('file', $backup_file_name . ".tar.gz"); $DownloadLink = $request->getURL(); $request = new Request(); $request->setView('AdminBackup'); $request->setAction('BackupDeleteAction'); $request->setKey('file', $backup_file_name); $DeleteFormAction = $request->getURL(); $this->_Template_Contents = array('BackupFileName' => $backup_file_name, 'DownloadLink' => $DownloadLink, 'InfoLink' => "", 'BackupFileDate' => modApiFunc("Localization", "timestamp_date_format", $backup_info['backup_date']) . " " . modApiFunc("Localization", "timestamp_time_format", $backup_info['backup_date']), 'BackupFileSize' => modApiFunc("Localization", "num_format", $backup_info['backup_file_size'] / 1024) . " Kb", 'N' => $n); $backup_list[] = $this->_Template_Contents; $n++; } } } } $dir->close(); } for ($i = sizeof($backup_list) - 1; $i >= 0; $i--) { $this->_Template_Contents = $backup_list[$i]; $application->registerAttributes($this->_Template_Contents); $retval .= modApiFunc('TmplFiller', 'fill', "tools/backup/", "item.tpl.html", array()); } if ($n == 0) { $retval .= modApiFunc('TmplFiller', 'fill', "tools/backup/", "item_na.tpl.html", array()); } $retval .= modApiFunc('TmplFiller', 'fill', "tools/backup/", "item_empty.tpl.html", array()); return $retval; }
function outputCategoriesPaths($cats) { $js_code = 'var categories_paths = new Array();' . "\n"; $last_parents_on_levels = array(); for ($i = 0; $i < count($cats); $i++) { $cat = $cats[$i]; $cpath = ''; if (isset($last_parents_on_levels[$cat['level'] - 1])) { $cpath = $last_parents_on_levels[$cat['level'] - 1]['path']; } $cpath .= '/' . $cat['name']; $last_parents_on_levels[$cat['level']] = array('id' => $cat['id'], 'path' => $cpath); $js_code .= 'categories_paths[' . $cat['id'] . '] = \'' . addslashes(_ml_substr($cpath, 1)) . '\';' . "\n"; } return $js_code; }
function prepareHtaccessCode($arr_err_code) { global $application; loadCoreFile('URI.class.php'); $uriObj = new URI($application->getAppIni('HTTP_URL')); $url_dir = $uriObj->getPart('dir') . (_ml_substr($uriObj->getPart('dir'), -1) != '/' ? '/' : ''); $hta_content = ERRDOC_BLOCK_IDENT_BEGIN . "\n"; /* ignore list htaccess code - starts */ $hta_content .= str_replace('%files_to_ignore%', FILES_TO_IGNORE, file_get_contents(dirname(__FILE__) . '/includes/errdoc_ignore_list_block_first_strings')); foreach ($arr_err_code as $error_code => $error_page) { $hta_content .= str_replace('%error_code%', $error_code, file_get_contents(dirname(__FILE__) . '/includes/errdoc_block_for_ignore_list')); } $hta_content .= file_get_contents(dirname(__FILE__) . '/includes/errdoc_ignore_list_block_last_strings'); /* ignore list htaccess code - ends */ foreach ($arr_err_code as $error_code => $error_page) { $hta_content .= str_replace(array('%error_code%', '%url_dir%', '%error_code_file%'), array($error_code, $url_dir, $error_page), file_get_contents(dirname(__FILE__) . '/includes/errdoc_block_for_all_files')); } $hta_content .= ERRDOC_BLOCK_IDENT_END; return $hta_content; }
function is_valid_credit_card_number($cc_number, $cc_type) { $cc_number = trim($cc_number); switch ($cc_type) { case "Visa": $valid = preg_match("/^4[0-9]{12}([0-9]{3})?\$/", $cc_number); if (!$valid) { return array('error_code_full' => 'CCNUM_ERR_002', 'error_code_short' => 'CCNUM_ERR_002'); } break; case "MasterCard": $valid = preg_match("/^5[1-5][0-9]{14}\$/", $cc_number); if (!$valid) { return array('error_code_full' => 'CCNUM_ERR_003', 'error_code_short' => 'CCNUM_ERR_003'); } break; case "Discover": $valid = preg_match("/^6011[0-9]{12}\$/", $cc_number); if (!$valid) { return array('error_code_full' => 'CCNUM_ERR_004', 'error_code_short' => 'CCNUM_ERR_004'); } break; case "Amex": $valid = preg_match("/^3[47][0-9]{13}\$/", $cc_number); if (!$valid) { return array('error_code_full' => 'CCNUM_ERR_005', 'error_code_short' => 'CCNUM_ERR_005'); } break; case "Maestro": $MaestroRules = array("490302,490309,18,1", "490335,490339,18,1", "491101,491102,16,1", "491174,491182,18,1", "493600,493699,19,1", "564182,564182,16,2", "633300,633300,16,0", "633301,633301,19,1", "633302,633349,16,0", "675900,675900,16,0", "675901,675901,19,1", "675902,675904,16,0", "675905,675905,19,1", "675906,675917,16,0", "675918,675918,19,1", "675919,675937,16,0", "675938,675940,18,1", "675941,675949,16,0", "675950,675962,19,1", "675963,675997,16,0", "675998,675998,19,1", "675999,675999,16,0"); $valid = $this->is_valid_debit_card_number($cc_number, $MaestroRules); if (!$valid) { return array('error_code_full' => 'CCNUM_ERR_007', 'error_code_short' => 'CCNUM_ERR_007'); } break; case "Solo": $SoloRules = array("633450,633453,16,0", "633454,633457,16,0", "633458,633460,16,0", "633461,633461,18,1", "633462,633472,16,0", "633473,633473,18,1", "633474,633475,16,0", "633476,633476,19,1", "633477,633477,16,0", "633478,633478,18,1", "633479,633480,16,0", "633481,633481,19,1", "633482,633489,16,0", "633490,633493,16,1", "633494,633494,18,1", "633495,633497,16,2", "633498,633498,19,1", "633499,633499,18,1", "676700,676700,16,0", "676701,676701,19,1", "676702,676702,16,0", "676703,676703,18,1", "676704,676704,16,0", "676705,676705,19,1", "676706,676707,16,2", "676708,676711,16,0", "676712,676715,16,0", "676716,676717,16,0", "676718,676718,19,1", "676719,676739,16,0", "676740,676740,18,1", "676741,676749,16,0", "676750,676762,19,1", "676763,676769,16,0", "676770,676770,19,1", "676771,676773,16,0", "676774,676774,18,1", "676775,676778,16,0", "676779,676779,18,1", "676780,676781,16,0", "676782,676782,18,1", "676783,676794,16,0", "676795,676795,18,1", "676796,676797,16,0", "676798,676798,19,1", "676799,676799,16,0"); $valid = $this->is_valid_debit_card_number($cc_number, $SoloRules); if (!$valid) { return array('error_code_full' => 'CCNUM_ERR_008', 'error_code_short' => 'CCNUM_ERR_008'); } break; default: $list = modApiFunc("Configuration", "getCreditCardSettings"); if (array_key_exists($cc_type, $list)) { // . // . return true; } else { return array('error_code_full' => 'CCTYPE_ERR_002', 'error_code_short' => 'CCTYPE_ERR_002'); } } $cc_number = _ml_strrev($cc_number); $numSum = 0; for ($i = 0; $i < _ml_strlen($cc_number); $i++) { $currentNum = _ml_substr($cc_number, $i, 1); // Double every second digit if ($i % 2 == 1) { $currentNum *= 2; } // Add digits of 2-digit numbers together if ($currentNum > 9) { $firstNum = $currentNum % 10; $secondNum = ($currentNum - $firstNum) / 10; $currentNum = $firstNum + $secondNum; } $numSum += $currentNum; } if (!($numSum % 10 == 0)) { return array('error_code_full' => 'CCNUM_ERR_006', 'error_code_short' => 'CCNUM_ERR_006'); } else { return true; } }
function getCZSiteHTTPSURL($SiteURL) { global $application; // - HTTPS AVACTIS' . // - HTTP AVACTIS' . // SiteURL . SiteHTTPSURL. $AZ_AVACTIS_ROOT_HTTP_URL = $application->getAppIni("HTTP_URL_CONFIG.PHP"); $AZ_AVACTIS_ROOT_HTTPS_URL = $application->getAppIni("HTTPS_URL"); $url_cz = parse_url($SiteURL); $url_core = parse_url($AZ_AVACTIS_ROOT_HTTP_URL); $p_cz = explode("/", $url_cz['path']); $p_core = explode("/", $url_core['path']); foreach ($p_cz as $i => $p) { if (isset($p_core[$i]) && $p_cz[$i] == $p_core[$i] && !isset($p_cz[$i - 1])) { unset($p_cz[$i]); unset($p_core[$i]); } } $Path_CZ = implode("/", $p_cz); $Path_Core = implode("/", $p_core); $cz_https_url = preg_replace("/" . addcslashes($Path_Core, "/") . "/i", "", $AZ_AVACTIS_ROOT_HTTPS_URL); $cz_https_url .= $Path_CZ; if (_ml_strcasecmp("https://", _ml_substr($AZ_AVACTIS_ROOT_HTTPS_URL, 0, _ml_strlen("https://"))) !== 0) { return NULL; } else { return $cz_https_url; } }
/** * @ 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 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 isFileFromDirectoryOrSubdirectories($dir_path, $file_path) { $d = realpath($dir_path); $f = realpath($file_path); return _ml_substr($f, 0, _ml_strlen($d)) == $d; }
function genThumbnail($product_id, $original_image_path, $thumb_side = null, $subfolder = '') { if (!function_exists('gd_info')) { return null; } $img_info = getimagesize($original_image_path); if (!(imagetypes() & $this->__imageTypeToBit($img_info[2]))) { return null; } $oimage = $this->getImageRes($original_image_path); if ($oimage == null) { return null; } $sets = $this->getSettings(); if ($thumb_side == null || intval($thumb_side) <= 0) { $thumb_side = $sets['THUMB_SIDE']; } else { $thum_side = intval($thumb_side); } list($dst_x, $dst_y) = $this->convertSizes($img_info[0], $img_info[1], $thumb_side); $dst_image = imagecreatetruecolor($dst_x, $dst_y); imagecolortransparent($dst_image, imagecolorallocatealpha($dst_image, 0, 0, 0, 127)); imagealphablending($dst_image, false); imagesavealpha($dst_image, true); imagecopyresampled($dst_image, $oimage, 0, 0, 0, 0, $dst_x, $dst_y, $img_info[0], $img_info[1]); global $application; $large_image_path_parts = pathinfo($original_image_path); $large_image_basename = $large_image_path_parts['basename']; $large_image_ext = $large_image_path_parts['extension']; $large_image_basename_without_ext = _ml_substr($large_image_basename, 0, -1 * _ml_strlen("." . $large_image_ext)); $thumb_basename = "thumb_" . $large_image_basename_without_ext . "." . $large_image_ext; $new_image_path = $application->getUploadImageName($thumb_basename, $subfolder); if ($large_image_ext == 'png' && imagepng($dst_image, $new_image_path)) { return $new_image_path; } if (imagejpeg($dst_image, $new_image_path, $application->getAppIni('JPEG_THUMBNAIL_QUALITY'))) { return $new_image_path; } else { return null; } }
/** * @ 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; }
function _fetch_data() { $raw = array(); for ($i = 0; $i < $this->_settings['bulk']; $i++) { $raw_line = $this->_fetch_line_as_array(); if ($raw_line == null) { break; } $raw[] = $raw_line; } if (empty($raw)) { return null; } // in data we will keep values for all languages separately // so $data is an array of arrays // Note: in action the records will be shown separately as well $data = array(); $label_types = array(); $label_names = array(); foreach ($raw as $raw_line) { // checking the label type and label name $label_type = @$raw_line[$this->_csv_headers['labeltype']]; $label_name = @$raw_line[$this->_csv_headers['labelname']]; // if label name is empty -> invalid record! if (!$label_name) { if (!isset($this->_info['total'])) { $this->_info['total'] = array(); } if (!isset($this->_info['total']['error'])) { $this->_info['total']['error'] = 0; } $this->_info['total']['error']++; // do nothing... continue; } // if the type is empty assume it is a custom label if (!$label_type) { $label_type = 'CZ'; if (_ml_substr($label_name, 0, 7) !== 'CUSTOM_') { $label_name = 'CUSTOM_' . $label_name; } $this->_warnings = getMsg('ML', 'ML_IMPORT_LABELS_EMPTY_TYPE_WARNING'); $this->_info['warning'] = $this->_warnings; } $label_types[] = $label_type; $label_names[] = $label_name; } // if empty $label_types -> do nothing... if (empty($label_types)) { return null; } // checking if label type exists // if it does not assume the record is invalid $meta_info = modApiFunc('Resources', 'getMetaByShortNames', $label_types); foreach ($label_types as $k => $label_type) { if (!isset($meta_info[$label_type])) { if (!isset($this->_info['total'])) { $this->_info['total'] = array(); } if (!isset($this->_info['total']['error'])) { $this->_info['total']['error'] = 0; } $this->_info['total']['error']++; unset($label_types[$k]); unset($label_names[$k]); } } // here we have valid label types // and valid label names since we assume a new label can be added // even for admin label types // so now we need to look through the languages and check the label // for each of them // getting the default language $def_lng = modApiFunc('MultiLang', 'getDefaultLanguage'); // firstly getting the map value for resource_labels table $ml_label = modApiFunc('MultiLang', 'mapMLField', 'resource_labels', 'res_text', 'Resources'); // secondly we get label ids for the labels $label_ids = modApiFunc('Resources', 'getMsgIDs', $label_types, $label_names); // thirdly we get translation for all languages $trns = array(); foreach ($this->_csv_headers as $header => $column) { // skipping missing languages and label keys if ($column < 0 || $header == 'labeltype' || $header == 'labelname' || $header == 'default' || $header == $def_lng) { continue; } $trns[$header] = modApiFunc('MultiLang', 'getLabelTranslationByIDs', array_values($label_ids), $header); } // looking through the data foreach ($raw as $raw_line) { $label_type = @$raw_line[$this->_csv_headers['labeltype']]; $label_name = @$raw_line[$this->_csv_headers['labelname']]; if (!$label_type) { $label_type = 'CZ'; if (_ml_substr($label_name, 0, 7) !== 'CUSTOM_') { $label_name = 'CUSTOM_' . $label_name; } } if (!in_array($label_type, $label_types) || !in_array($label_name, $label_names)) { continue; } // looking through the languages foreach ($this->_csv_headers as $header => $column) { // skipping missing languages and label keys if ($column < 0 || $header == 'labeltype' || $header == 'labelname') { continue; } // convert empty language if ($header == 'default') { $lng = ''; } else { $lng = $header; } // getting the label id $labelid = @$label_ids[$label_type . '_' . $label_name]['id']; if (!$labelid) { $labelid = 0; } $found = $labelid > 0; // checking if the label exists if ($lng != $def_lng) { $found = $found && isset($trns[$lng][$labelid]); // skipping empty values for non-found records // (if record is not found and its new value is empty // then actually we need to do nothing... if (!$raw_line[$column] && !$found) { continue; } // checking if found label will acually be updated if ($found && $raw_line[$column] == $trns[$lng][$labelid]) { continue; } } else { // checking if found label will acually be updated if ($found && $raw_line[$column] == $label_ids[$label_type . '_' . $label_name]['text']) { continue; } } // filling the _info array... // total... if (!isset($this->_info['total'])) { $this->_info['total'] = array(); } if ($found) { if (!isset($this->_info['total']['found'])) { $this->_info['total']['found'] = 0; } $this->_info['total']['found']++; } else { if (!isset($this->_info['total']['new'])) { $this->_info['total']['new'] = 0; } $this->_info['total']['new']++; } // language if (!isset($this->_info['language'])) { $this->_info['language'] = array(); } if (!isset($this->_info['language'][$header])) { $this->_info['language'][$header] = array(); } if ($found) { if (!isset($this->_info['language'][$header]['found'])) { $this->_info['language'][$header]['found'] = 0; } $this->_info['language'][$header]['found']++; } else { if (!isset($this->_info['language'][$header]['new'])) { $this->_info['language'][$header]['new'] = 0; } $this->_info['language'][$header]['new']++; } // label type if (!isset($this->_info['type'])) { $this->_info['type'] = array(); } // separating avactis and custom labels $_l_type = $label_type; if ($label_type == 'CZ' && _ml_substr($label_name, 0, 7) == 'CUSTOM_') { $_l_type = 'CZ_CUSTOM'; } if (!isset($this->_info['type'][$_l_type])) { $this->_info['type'][$_l_type] = array(); } if ($found) { if (!isset($this->_info['type'][$_l_type]['found'])) { $this->_info['type'][$_l_type]['found'] = 0; } $this->_info['type'][$_l_type]['found']++; } else { if (!isset($this->_info['type'][$_l_type]['new'])) { $this->_info['type'][$_l_type]['new'] = 0; } $this->_info['type'][$_l_type]['new']++; } // gathering the info $record = array('labelid' => $labelid, 'labeltype' => $label_type, 'labelname' => $label_name, 'lng' => $lng, 'found' => $found, 'value' => $raw_line[$column]); $data[] = $record; } } if (empty($data)) { return null; } return $data; }
/** * @ 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; }
function getSubscriptionKey() { /*global $application; $tables = Subscriptions::getTables(); $table = 'subscription_guest'; $columns = & $tables[$table]['columns'];*/ while (1) { $key = _ml_substr(md5(time() . mt_rand(1, 0x7fffffff)), 0, SUBSCRIPTION_KEY_SIZE); /*$query = new DB_Select($table); $query->addSelectField('subscription_key'); $query->WhereValue($columns['subscription_key'], DB_EQ, $key); $query->SelectLimit(0, 1); $result = $application->db->getDB_Result($query);*/ $result = execQuery("SUBSCR_GET_SUBSCRIPTION_EMAIL_BY_KEY", array("key" => $key, "limit" => "yes")); if (sizeof($result) == 0) { break; } } return $key; }
/** * Prepares data to output of possible mailing list. * * @return string - HTML code */ function outputSendSourceList($dirrection) { $retval = ""; $list = modApiFunc("Notifications", "getSendSourceList", $dirrection); $email_code_strlen = _ml_strlen($this->notificationInfo['Email_Code']); if ($this->notificationInfo['Email_Code'] == "EMAIL_ADMINISTRATOR") { $selected_key = "EMAIL_ADMINISTRATOR=" . $this->notificationInfo['Admin_ID']; } foreach ($list as $key => $address) { if ($dirrection == 'to') { if (!in_array($key, $this->usedSendToEmails)) { $retval .= "<option value='" . $key . "' >" . $address . "</option>"; } } else { if ($this->currentNotificationId == 'Add') { $retval .= "<option value='" . $key . "' >" . $address . "</option>"; } else { //"Edit" notification. if ($this->notificationInfo['Email_Code'] == "EMAIL_ADMINISTRATOR") { if ($key == $selected_key) { $retval .= "<option selected value='" . $key . "' >" . $address . "</option>"; } else { $retval .= "<option value='" . $key . "' >" . $address . "</option>"; } } else { if ($this->notificationInfo['Email_Code'] != "EMAIL_CUSTOM") { if (_ml_substr($key, 0, $email_code_strlen) == $this->notificationInfo['Email_Code']) { $retval .= "<option selected value='" . $key . "' >" . $address . "</option>"; } else { $retval .= "<option value='" . $key . "' >" . $address . "</option>"; } } else { $retval .= "<option value='" . $key . "' >" . $address . "</option>"; } } } } } return $retval; }
function getCategoryName() { if ($this->_Current_Category == null) { return null; } $value = $this->_Current_Category['name']; if (_ml_strlen($value) > 27) { $value = preg_replace('/^(\\S+)\\s.*\\s(\\S+)$/', '\\1 ... \\2', $value); if (_ml_strlen($value) > 27) { $value = _ml_substr($value, 0, 12) . '...'; } } return $value; }
/** * */ 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); } }
/** * Deletes tax rate by zip set. */ function onAction() { global $application; $SessionPost = array(); $SessionPost = $_POST; $Errors = array(); $Results = array(); $sets = modApiFunc("TaxRateByZip", "getSetsList"); if (isset($SessionPost["item_n"])) { $sid = $SessionPost["item_n"]; } else { // errors } if (isset($SessionPost["ViewState"]["FormSubmitValue"])) { switch ($SessionPost["ViewState"]["FormSubmitValue"]) { case "deleteSet": // check if set is used in tax rates if (modApiFunc("Taxes", "checkIfSetIsUsed", $sid)) { $Errors[] = str_replace("%1%", $sets[$sid], getMsg("TAX_ZIP", "SETS_LIST_CANNOT_DELETE_SET_IN_USE")); break; } else { modApiFunc("TaxRateByZip", "deleteSetFromDB", $sid); } break; case "checkRate": $sid = $SessionPost['CheckRate_sid']; $zip = $SessionPost['CheckRate_zip']; $Results[] = str_replace("%1%", $sets[$sid], getMsg("TAX_ZIP", "CHECK_RATES_GOT_ARCHIVE")); $Results[] = str_replace("%1%", prepareHTMLDisplay($zip), getMsg("TAX_ZIP", "CHECK_RATES_GOT_ZIP")); modApiFunc('Session', 'set', 'CheckRateByZip', array("sid" => $sid, "zip" => $zip)); $zip = preg_replace("/[^0-9]/", '', $zip); $len = _ml_strlen($zip); if ($len != 5 && $len != 9) { $Results[] = getMsg("TAX_ZIP", "CHECK_RATES_NOT_5_9_ZIP_ERROR"); break; } if ($len == 5) { $zip5 = intval($zip); $Results[] = str_replace("%1%", $zip5, getMsg("TAX_ZIP", "CHECK_RATES_GOT_ZIP5")); $Results[] = getMsg("TAX_ZIP", "CHECK_RATES_NO_ZIP4"); $rlt5 = modApiFunc("TaxRateByZip", "getTaxRateByZip5Strict", $sid, $zip5); $rlt5 = $rlt5 === FALSE ? 0.0 : $rlt5; $Results[] = str_replace("%1%", $rlt5, getMsg("TAX_ZIP", "CHECK_RATES_STRICT_RLT")); $rlt5i = modApiFunc("TaxRateByZip", "getTaxRateByZip5Interval", $sid, $zip5); $rlt5i = $rlt5i === FALSE ? 0.0 : $rlt5i; $Results[] = str_replace("%1%", $rlt5i, getMsg("TAX_ZIP", "CHECK_RATES_INTERVAL_RLT")); $rlt5m = modApiFunc("TaxRateByZip", "getTaxRateByZip5Mask", $sid, $zip5); $rlt5m = $rlt5m === FALSE ? 0.0 : $rlt5m; $Results[] = str_replace("%1%", $rlt5m, getMsg("TAX_ZIP", "CHECK_RATES_MASK_RLT")); } else { $zip5 = intval(_ml_substr($zip, 0, 5)); $zip4 = intval(_ml_substr($zip, 5, 4)); $Results[] = str_replace("%1%", $zip5, getMsg("TAX_ZIP", "CHECK_RATES_GOT_ZIP5")); $Results[] = str_replace("%1%", $zip4, getMsg("TAX_ZIP", "CHECK_RATES_GOT_ZIP4")); $rlt5 = modApiFunc("TaxRateByZip", "getTaxRateByZip9Strict", $sid, $zip5, $zip4); $rlt5 = $rlt5 === FALSE ? 0.0 : $rlt5; $Results[] = str_replace("%1%", $rlt5, getMsg("TAX_ZIP", "CHECK_RATES_STRICT_RLT")); $rlt5i = modApiFunc("TaxRateByZip", "getTaxRateByZip9Interval", $sid, $zip5, $zip4); $rlt5i = $rlt5i === FALSE ? 0.0 : $rlt5i; $Results[] = str_replace("%1%", $rlt5i, getMsg("TAX_ZIP", "CHECK_RATES_INTERVAL_RLT")); $rlt5m = modApiFunc("TaxRateByZip", "getTaxRateByZip9Mask", $sid, $zip5, $zip4); $rlt5m = $rlt5m === FALSE ? 0.0 : $rlt5m; $Results[] = str_replace("%1%", $rlt5m, getMsg("TAX_ZIP", "CHECK_RATES_MASK_RLT")); // if (!$rlt5 && !$rlt5i && !$rlt5m) // { // $Results[] = getMsg("TAX_ZIP", "CHECK_RATES_COULDNT_FIND_RATE_WITH_ZIP4"); // // $rlt5 = modApiFunc("TaxRateByZip", "getTaxRateByZip5Strict", $sid, $zip5); // $rlt5 = ($rlt5 === FALSE) ? 0.0 : $rlt5; // $Results[] = str_replace("%1%", $rlt5, getMsg("TAX_ZIP", "CHECK_RATES_STRICT_RLT")); // // $rlt5i = modApiFunc("TaxRateByZip", "getTaxRateByZip5Interval", $sid, $zip5); // $rlt5i = ($rlt5i === FALSE) ? 0.0 : $rlt5i; // $Results[] = str_replace("%1%", $rlt5i, getMsg("TAX_ZIP", "CHECK_RATES_INTERVAL_RLT")); // // $rlt5m = modApiFunc("TaxRateByZip", "getTaxRateByZip5Mask", $sid, $zip5); // $rlt5m = ($rlt5m === FALSE) ? 0.0 : $rlt5m; // $Results[] = str_replace("%1%", $rlt5m, getMsg("TAX_ZIP", "CHECK_RATES_MASK_RLT")); // } } if ($rlt5) { $Results[] = str_replace("%1%", $rlt5, getMsg("TAX_ZIP", "CHECK_RATES_STRICT_RLT_USED")); } else { if ($rlt5i) { $Results[] = str_replace("%1%", $rlt5i, getMsg("TAX_ZIP", "CHECK_RATES_INTERVAL_RLT_USED")); } else { if ($rlt5m) { $Results[] = str_replace("%1%", $rlt5m, getMsg("TAX_ZIP", "CHECK_RATES_MASK_RLT_USED")); } else { $Results[] = getMsg("TAX_ZIP", "CHECK_RATES_NO_RLT"); } } } break; default: _fatal(array("CODE" => "CORE_051"), __CLASS__, __FUNCTION__, $SessionPost["ViewState"]["FormSubmitValue"]); break; } } else { _fatal(array("CODE" => "CORE_051"), __CLASS__, __FUNCTION__, $SessionPost["ViewState"]["FormSubmitValue"]); } if (!empty($Errors)) { modApiFunc('Session', 'set', 'Errors', $Errors); } if (!empty($Results)) { modApiFunc('Session', 'set', 'Results', $Results); } // modApiFunc('Session', 'set', 'SessionPost', $SessionPost); $request = new Request(); $request->setView('TaxRateByZip_Sets'); $application->redirect($request); }
function __is_valid_string(&$string) { if (!is_string($string)) { return false; } if (_ml_strlen($string) > 256) { $string = _ml_substr($string, 0, 256); return true; } return true; }
/** * Prepares and returns necessary data, passed to the payment gateway. * * @ not all data is defined */ function getConfirmationData($orderId) { global $application; loadCoreFile('aal.class.php'); $request = new Request(); $request->setView(CURRENT_REQUEST_URL); $request->setAction("UpdatePaymentStatus"); $request->setKey("asc_oid", $orderId); $self_link = $request->getURL("", true); $currency_id = modApiFunc("Localization", "whichCurrencySendOrderToPaymentShippingGatewayIn", $orderId, $this->getUid()); $currency = modApiFunc("Localization", "getCurrencyCodeById", $currency_id); $ocntr = modApiFunc("Location", "getCountryCode", modApiFunc("Configuration", "getValue", SYSCONFIG_STORE_OWNER_COUNTRY)); $bn_code = "PentasoftCorp_Cart_WPS_" . $ocntr; $orderInfo = modApiFunc("Checkout", "getOrderInfo", $orderId, $currency_id); $discount = $this->export_PRICE_N_A(modApiFunc("Checkout", "getOrderPrice", "DiscountsSum", $currency_id)); $gc = $this->export_PRICE_N_A(modApiFunc("Checkout", "getOrderPrice", "TotalPrepaidByGC", $currency_id)); $amount = $this->export_PRICE_N_A(modApiFunc("Checkout", "getOrderPrice", "Subtotal", $currency_id) - $discount - $gc); if ($amount < 0) { $amount = 0; } $this->getSettings(); $confirmationData = array("FormMethod" => "POST", "DataFields" => array("cmd" => "_xclick", "rm" => "2", "business" => $this->Settings["MODULE_EMAIL"], "item_name" => modApiFunc("Configuration", "getValue", SYSCONFIG_STORE_OWNER_NAME), "amount" => number_format($amount, 2, '.', ''), "shipping" => number_format($this->export_PRICE_N_A(modApiFunc("Checkout", "getOrderPrice", "TotalShippingAndHandlingCost", $currency_id)), 2, '.', ''), "tax" => number_format($this->export_PRICE_N_A(modApiFunc("Checkout", "getOrderPrice", "NotIncludedTax", $currency_id)), 2, '.', ''), "currency_code" => $currency, "bn" => $bn_code, "return" => $self_link . "&status=return", "notify_url" => $self_link . "&status=notify", "cancel_return" => $self_link . "&status=cancel")); if ($this->Settings['MODULE_CART'] == 1 && $discount == 0) { $items = array(); $n = 1; foreach ($orderInfo["Products"] as $productInfo) { $items["item_name_" . $n] = prepareHTMLDisplay($productInfo["name"]); $items["amount_" . $n] = number_format($productInfo["SalePrice"], 2); $items["quantity_" . $n] = $productInfo["qty"]; foreach ($productInfo["options"] as $i => $option) { if ($i > 1) { $items["os1_" . $n] .= ", " . $option["option_name"] . ": " . $option["option_value"]; if (_ml_strlen($items["os1_" . $n]) >= 200) { $items["os1_" . $n] = _ml_substr($items["os1_" . $n], 0, 197) . "..."; } } else { $items["on" . $i . "_" . $n] = $option["option_name"]; $items["os" . $i . "_" . $n] = $option["option_value"]; } } $n++; } $confirmationData["DataFields"] = array_merge($confirmationData["DataFields"], $items); $confirmationData["DataFields"]["cmd"] = "_cart"; $confirmationData["DataFields"]["upload"] = "1"; $confirmationData["DataFields"]["handling_cart"] = $this->export_PRICE_N_A(modApiFunc("Checkout", "getOrderPrice", "TotalShippingAndHandlingCost", $currency_id)); $confirmationData["DataFields"]["tax_cart"] = $this->export_PRICE_N_A(modApiFunc("Checkout", "getOrderPrice", "NotIncludedTax", $currency_id)); unset($confirmationData["DataFields"]["shipping"]); unset($confirmationData["DataFields"]["tax"]); } if ($this->Settings['MODULE_BILLING_INFO'] == 1) { $billingInfo = new ArrayAccessLayer($orderInfo); $billingInfo->setAccessMask("Billing", "attr", AAL_CUSTOM_PARAM, "value"); if ($confirmationData["DataFields"]["cmd"] == "_xclick") { $confirmationData["DataFields"]["cmd"] = "_ext-enter"; $confirmationData["DataFields"]["redirect_cmd"] = "_xclick"; } $confirmationData["DataFields"]["first_name"] = $billingInfo->getByMask('Firstname'); $confirmationData["DataFields"]["last_name"] = $billingInfo->getByMask('Lastname'); $confirmationData["DataFields"]["address1"] = $billingInfo->getByMask('Streetline1'); $confirmationData["DataFields"]["address2"] = $billingInfo->getByMask('Streetline2'); $confirmationData["DataFields"]["city"] = $billingInfo->getByMask('City'); $confirmationData["DataFields"]["state"] = modApiFunc("Location", "getStateCodeByStateName", $billingInfo->getByMask('State')); if (!$confirmationData["DataFields"]["state"]) { $confirmationData["DataFields"]["state"] = $billingInfo->getByMask('State'); } $confirmationData["DataFields"]["zip"] = $billingInfo->getByMask('Postcode'); $confirmationData["DataFields"]["country"] = modApiFunc("Location", "getCountryCodeByCountryName", $billingInfo->getByMask('Country')); $confirmationData["DataFields"]["email"] = $billingInfo->getByMask('Email'); if ($billingInfo->getByMask('Phone')) { $phone = $billingInfo->getByMask('Phone'); $phone = preg_replace("/[^0-9]/", "", $phone); if (isset($confirmationData["DataFields"]["country"]) && $confirmationData["DataFields"]["country"] == "US") { if (_ml_strlen($phone) == 10) { $confirmationData["DataFields"]["night_phone_c"] = _ml_substr($phone, -4); $phone = _ml_substr($phone, 0, -4); $confirmationData["DataFields"]["night_phone_b"] = _ml_substr($phone, -3); $phone = _ml_substr($phone, 0, -3); $confirmationData["DataFields"]["night_phone_a"] = _ml_substr($phone, -3); } } } } if ($this->Settings['MODULE_ADDRESS_OVERRIDE'] == 1) { $shippingInfo = new ArrayAccessLayer($orderInfo); $shippingInfo->setAccessMask("Shipping", "attr", AAL_CUSTOM_PARAM, "value"); $confirmationData["DataFields"]["address_override"] = "1"; $confirmationData["DataFields"]["first_name"] = $shippingInfo->getByMask('Firstname'); $confirmationData["DataFields"]["last_name"] = $shippingInfo->getByMask('Lastname'); $confirmationData["DataFields"]["address1"] = $shippingInfo->getByMask('Streetline1'); $confirmationData["DataFields"]["address2"] = $shippingInfo->getByMask('Streetline2'); $confirmationData["DataFields"]["city"] = $shippingInfo->getByMask('City'); $confirmationData["DataFields"]["state"] = modApiFunc("Location", "getStateCodeByStateName", $shippingInfo->getByMask('State')); if (!$confirmationData["DataFields"]["state"]) { $confirmationData["DataFields"]["state"] = $shippingInfo->getByMask('State'); } $confirmationData["DataFields"]["zip"] = $shippingInfo->getByMask('Postcode'); $confirmationData["DataFields"]["country"] = modApiFunc("Location", "getCountryCodeByCountryName", $shippingInfo->getByMask('Country')); $confirmationData["DataFields"]["email"] = $shippingInfo->getByMask('Email'); if ($shippingInfo->getByMask('Phone')) { $phone = $shippingInfo->getByMask('Phone'); $phone = preg_replace("/[^0-9]/", "", $phone); if (isset($confirmationData["DataFields"]["country"]) && $confirmationData["DataFields"]["country"] == "US") { if (_ml_strlen($phone) == 10) { $confirmationData["DataFields"]["night_phone_c"] = _ml_substr($phone, -4); $phone = _ml_substr($phone, 0, -4); $confirmationData["DataFields"]["night_phone_b"] = _ml_substr($phone, -3); $phone = _ml_substr($phone, 0, -3); $confirmationData["DataFields"]["night_phone_a"] = _ml_substr($phone, -3); } } } } $confirmationData['FormAction'] = $this->Settings['MODULE_MODE'] == 1 ? PAYPAL_URL_TEST : PAYPAL_URL; //=========================== logging request ======================== $msgObj = $application->getInstance("MessageResources", "payment-module-paypal-messages", "AdminZone"); $title = $msgObj->getMessage("MODULE_PAYMENT_TIMELINE_HEADER_CONFIRMATION_DATA"); $title = str_replace('{ORDER_ID}', $orderId, $title); $this->addRequestLog("LOG_PM_INPUT", "Payment Module Logs", $title, prepareArrayDisplay($confirmationData)); //=========================== logging request ======================== return $confirmationData; }
/** * 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 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; }
/** * @ 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 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 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; }
/** * 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']); }