📄 general.php
字号:
}
return $zones_array;
}
function tep_prepare_country_zones_pull_down($country_id = '') {
// preset the width of the drop-down for Netscape
$pre = '';
if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) {
for ($i=0; $i<45; $i++) $pre .= ' ';
}
$zones = tep_get_country_zones($country_id);
if (sizeof($zones) > 0) {
$zones_select = array(array('id' => '', 'text' => PLEASE_SELECT));
$zones = tep_array_merge($zones_select, $zones);
} else {
$zones = array(array('id' => '', 'text' => TYPE_BELOW));
// create dummy options for Netscape to preset the height of the drop-down
if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) {
for ($i=0; $i<9; $i++) {
$zones[] = array('id' => '', 'text' => $pre);
}
}
}
return $zones;
}
////
// Alias function for Store configuration values in the Administration Tool
function tep_cfg_pull_down_country_list($country_id) {
return tep_draw_pull_down_menu('configuration_value', tep_get_countries(), $country_id);
}
function tep_cfg_pull_down_zone_list($zone_id) {
return tep_draw_pull_down_menu('configuration_value', tep_get_country_zones(STORE_COUNTRY), $zone_id);
}
function tep_cfg_pull_down_tax_classes($tax_class_id, $key = '') {
$name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');
$tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
$tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
while ($tax_class = tep_db_fetch_array($tax_class_query)) {
$tax_class_array[] = array('id' => $tax_class['tax_class_id'],
'text' => $tax_class['tax_class_title']);
}
return tep_draw_pull_down_menu($name, $tax_class_array, $tax_class_id);
}
////
// Function to read in text area in admin
function tep_cfg_textarea($text) {
return tep_draw_textarea_field('configuration_value', false, 35, 5, $text);
}
////
// Sets the status of a banner
function tep_set_banner_status($banners_id, $status) {
if ($status == '1') {
return tep_db_query("update " . TABLE_BANNERS . " set status = '1', expires_impressions = NULL, expires_date = NULL, date_status_change = NULL where banners_id = '" . $banners_id . "'");
} elseif ($status == '0') {
return tep_db_query("update " . TABLE_BANNERS . " set status = '0', date_status_change = now() where banners_id = '" . $banners_id . "'");
} else {
return -1;
}
}
////
// Sets the status of a product
function tep_set_product_status($products_id, $status) {
if ($status == '1') {
return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '1', products_last_modified = now() where products_id = '" . $products_id . "'");
} elseif ($status == '0') {
return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0', products_last_modified = now() where products_id = '" . $products_id . "'");
} else {
return -1;
}
}
////
// Sets the status of a product on special
function tep_set_specials_status($specials_id, $status) {
if ($status == '1') {
return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . $specials_id . "'");
} elseif ($status == '0') {
return tep_db_query("update " . TABLE_SPECIALS . " set status = '0', date_status_change = now() where specials_id = '" . $specials_id . "'");
} else {
return -1;
}
}
////
// Sets timeout for the current script.
// Cant be used in safe mode.
function tep_set_time_limit($limit) {
if (!get_cfg_var('safe_mode')) {
set_time_limit(180);
}
}
////
// Alias function for Store configuration values in the Administration Tool
function tep_cfg_select_option($select_array, $key_value, $key = '') {
for ($i=0; $i<sizeof($select_array); $i++) {
$name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');
$string .= '<br><input type="radio" name="' . $name . '" value="' . $select_array[$i] . '"';
if ($key_value == $select_array[$i]) $string .= ' CHECKED';
$string .= '> ' . $select_array[$i];
}
return $string;
}
////
// Alias function for module configuration keys
function tep_mod_select_option($select_array, $key_name, $key_value) {
reset($select_array);
while (list($key, $value) = each($select_array)) {
if (is_int($key)) $key = $value;
$string .= '<br><input type="radio" name="configuration[' . $key_name . ']" value="' . $key . '"';
if ($key_value == $key) $string .= ' CHECKED';
$string .= '> ' . $value;
}
return $string;
}
////
// Retreive server information
function tep_get_system_information() {
global $HTTP_SERVER_VARS;
$db_query = tep_db_query("select now() as datetime");
$db = tep_db_fetch_array($db_query);
list($system, $host, $kernel) = preg_split('/[\s,]+/', @exec('uname -a'), 5);
return array('date' => tep_datetime_short(date('Y-m-d H:i:s')),
'system' => $system,
'kernel' => $kernel,
'host' => $host,
'ip' => gethostbyname($host),
'uptime' => @exec('uptime'),
'http_server' => $HTTP_SERVER_VARS['SERVER_SOFTWARE'],
'php' => phpversion(),
'zend' => (function_exists('zend_version') ? zend_version() : ''),
'db_server' => DB_SERVER,
'db_ip' => gethostbyname(DB_SERVER),
'db_version' => 'MySQL ' . (function_exists('mysql_get_server_info') ? mysql_get_server_info() : ''),
'db_date' => tep_datetime_short($db['datetime']));
}
////
// Check if a file has been truely uploaded
function tep_is_uploaded_file($filename) {
if (function_exists('is_uploaded_file')) {
return is_uploaded_file($filename);
} else {
if (!$tmp_file = get_cfg_var('upload_tmp_dir')) {
$tmp_file = dirname(tempnam('', ''));
}
$tmp_file .= '/' . basename($filename);
// User might have trailing slash in php.ini
return (ereg_replace('/+', '/', $tmp_file) == $filename);
}
}
function tep_array_shift(&$array) {
if (function_exists('array_shift')) {
return array_shift($array);
} else {
$i = 0;
$shifted_array = array();
reset($array);
while (list($key, $value) = each($array)) {
if ($i > 0) {
$shifted_array[$key] = $value;
} else {
$return = $array[$key];
}
$i++;
}
$array = $shifted_array;
return $return;
}
}
function tep_array_reverse($array) {
if (function_exists('array_reverse')) {
return array_reverse($array);
} else {
$reversed_array = array();
for ($i=sizeof($array)-1; $i>=0; $i--) {
$reversed_array[] = $array[$i];
}
return $reversed_array;
}
}
function tep_generate_category_path($id, $from = 'category', $categories_array = '', $index = 0) {
global $languages_id;
if (!is_array($categories_array)) $categories_array = array();
if ($from == 'product') {
$categories_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $id . "'");
while ($categories = tep_db_fetch_array($categories_query)) {
if ($categories['categories_id'] == '0') {
$categories_array[$index][] = array('id' => '0', 'text' => 'Top');
} else {
$category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . $categories['categories_id'] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "'");
$category = tep_db_fetch_array($category_query);
$categories_array[$index][] = array('id' => $categories['categories_id'], 'text' => $category['categories_name']);
if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);
$categories_array[$index] = tep_array_reverse($categories_array[$index]);
}
$index++;
}
} elseif ($from == 'category') {
$category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . $id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "'");
$category = tep_db_fetch_array($category_query);
$categories_array[$index][] = array('id' => $id, 'text' => $category['categories_name']);
if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);
}
return $categories_array;
}
function tep_output_generated_category_path($id, $from = 'category') {
$calculated_category_path_string = '';
$calculated_category_path = tep_generate_category_path($id, $from);
for ($i=0; $i<sizeof($calculated_category_path); $i++) {
for ($j=0; $j<sizeof($calculated_category_path[$i]); $j++) {
$calculated_category_path_string .= $calculated_category_path[$i][$j]['text'] . ' > ';
}
$calculated_category_path_string = substr($calculated_category_path_string, 0, -16) . '<br>';
}
$calculated_category_path_string = substr($calculated_category_path_string, 0, -4);
if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = 'Top';
return $calculated_category_path_string;
}
function tep_remove_category($category_id) {
$category_image_query = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . tep_db_input($category_id) . "'");
$category_image = tep_db_fetch_array($category_image_query);
if (file_exists(DIR_FS_CATALOG_IMAGES . $category_image['categories_image'])) {
@unlink(DIR_FS_CATALOG_IMAGES . $category_image['categories_image']);
}
tep_db_query("delete from " . TABLE_CATEGORIES . " where categories_id = '" . tep_db_input($category_id) . "'");
tep_db_query("delete from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . tep_db_input($category_id) . "'");
tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . tep_db_input($category_id) . "'");
if (USE_CACHE == 'true') {
tep_reset_cache_block('categories');
tep_reset_cache_block('also_purchased');
}
}
function tep_remove_product($product_id) {
$product_image_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . tep_db_input($product_id) . "'");
$product_image = tep_db_fetch_array($product_image_query);
if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image['products_image'])) {
@unlink(DIR_FS_CATALOG_IMAGES . $product_image['products_image']);
}
tep_db_query("delete from " . TABLE_SPECIALS . " where products_id = '" . tep_db_input($product_id) . "'");
tep_db_query("delete from " . TABLE_PRODUCTS . " where products_id = '" . tep_db_input($product_id) . "'");
tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . tep_db_input($product_id) . "'");
tep_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . tep_db_input($product_id) . "'");
tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . tep_db_input($product_id) . "'");
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where products_id = '" . tep_db_input($product_id) . "'");
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where products_id = '" . tep_db_input($product_id) . "'");
$product_reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where products_id = '" . tep_db_input($product_id) . "'");
while ($product_reviews = tep_db_fetch_array($product_reviews_query)) {
tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . $product_reviews['reviews_id'] . "'");
}
tep_db_query("delete from " . TABLE_REVIEWS . " where products_id = '" . tep_db_input($product_id) . "'");
if (USE_CACHE == 'true') {
tep_reset_cache_block('categories');
tep_reset_cache_block('also_purchased');
}
}
function tep_remove_order($order_id, $restock = false) {
if ($restock == 'on') {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -