📄 general.php
字号:
<?php
/*
$Id: general.php,v 1.131 2002/07/14 11:47:28 project3000 Exp $
网络商店 - 吉鑫网络
http://www.chinaifc.com
Copyright (c) 2000,2001 网络商店
汗化版权所有吉鑫网络
*/
////
// Redirect to another page or site
function tep_redirect($url) {
global $logger;
header('Location: ' . $url);
if (STORE_PAGE_PARSE_TIME == 'true') {
if (!is_object($logger)) $logger = new logger;
$logger->timer_stop();
}
exit;
}
function tep_customers_name($customers_id) {
$customers = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . $customers_id . "'");
$customers_values = tep_db_fetch_array($customers);
return $customers_values['customers_firstname'] . ' ' . $customers_values['customers_lastname'];
}
function tep_get_path($current_category_id = '') {
global $cPath_array;
if ($current_category_id == '') {
$cPath_new = implode('_', $cPath_array);
} else {
if (sizeof($cPath_array) == 0) {
$cPath_new = $current_category_id;
} else {
$cPath_new = '';
$last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . $cPath_array[(sizeof($cPath_array)-1)] . "'");
$last_category = tep_db_fetch_array($last_category_query);
$current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . $current_category_id . "'");
$current_category = tep_db_fetch_array($current_category_query);
if ($last_category['parent_id'] == $current_category['parent_id']) {
for ($i=0; $i<(sizeof($cPath_array)-1); $i++) {
$cPath_new .= '_' . $cPath_array[$i];
}
} else {
for ($i=0; $i<sizeof($cPath_array); $i++) {
$cPath_new .= '_' . $cPath_array[$i];
}
}
$cPath_new .= '_' . $current_category_id;
if (substr($cPath_new, 0, 1) == '_') {
$cPath_new = substr($cPath_new, 1);
}
}
}
return 'cPath=' . $cPath_new;
}
function tep_get_all_get_params($exclude_array = '') {
global $HTTP_GET_VARS;
if ($exclude_array == '') $exclude_array = array();
$get_url = '';
reset($HTTP_GET_VARS);
while (list($key, $value) = each($HTTP_GET_VARS)) {
if (($key != tep_session_name()) && ($key != 'error') && (!tep_in_array($key, $exclude_array))) $get_url .= $key . '=' . $value . '&';
}
return $get_url;
}
function tep_date_long($raw_date) {
if (strlen($raw_date) == 19) {
$date_formated = strftime(DATE_FORMAT_SHORT, mktime(0,0,0,substr($raw_date, 5, 2),substr($raw_date, 8, 2),substr($raw_date, 0, 4)));
} elseif (strlen($raw_date) == 14) {
$date_formated = strftime(DATE_FORMAT_LONG, mktime(0,0,0,substr($raw_date, 4, 2),substr($raw_date, 6, 2),substr($raw_date, 0, 4)));
} else {
$date_formated = strftime(DATE_FORMAT_LONG, mktime(0,0,0,substr($raw_date, 4, 2),substr($raw_date, -2),substr($raw_date, 0, 4)));
}
return $date_formated;
}
////
// Output a raw date string in the selected locale date format
// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS
function tep_date_short($raw_date) {
if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;
$year = (int)substr($raw_date, 0, 4);
$month = (int)substr($raw_date, 5, 2);
$day = (int)substr($raw_date, 8, 2);
$hour = (int)substr($raw_date, 11, 2);
$minute = (int)substr($raw_date, 14, 2);
$second = (int)substr($raw_date, 17, 2);
return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
}
function tep_datetime_short($raw_datetime) {
if ( ($raw_datetime == '0000-00-00 00:00:00') || ($raw_datetime == '') ) return false;
$year = (int)substr($raw_datetime, 0, 4);
$month = (int)substr($raw_datetime, 5, 2);
$day = (int)substr($raw_datetime, 8, 2);
$hour = (int)substr($raw_datetime, 11, 2);
$minute = (int)substr($raw_datetime, 14, 2);
$second = (int)substr($raw_datetime, 17, 2);
return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
}
function tep_array_merge($array1, $array2, $array3 = '') {
if ($array3 == '') $array3 = array();
if (function_exists('array_merge')) {
$array_merged = array_merge($array1, $array2, $array3);
} else {
while (list($key, $val) = each($array1)) $array_merged[$key] = $val;
while (list($key, $val) = each($array2)) $array_merged[$key] = $val;
if (sizeof($array3) > 0) while (list($key, $val) = each($array3)) $array_merged[$key] = $val;
}
return (array) $array_merged;
}
function tep_in_array($lookup_value, $lookup_array) {
if (function_exists('in_array')) {
if (in_array($lookup_value, $lookup_array)) return true;
} else {
reset($lookup_array);
while (list($key, $value) = each($lookup_array)) {
if ($value == $lookup_value) return true;
}
}
return false;
}
function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) {
global $languages_id;
if (!is_array($category_tree_array)) $category_tree_array = array();
if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => '--Top--');
if ($include_itself) {
$category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . $languages_id . "' and cd.categories_id = '" . $parent_id . "'");
$category = tep_db_fetch_array($category_query);
$category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']);
}
$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' and c.parent_id = '" . $parent_id . "' order by c.sort_order, cd.categories_name");
while ($categories = tep_db_fetch_array($categories_query)) {
if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']);
$category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . ' ', $exclude, $category_tree_array);
}
return $category_tree_array;
}
function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') {
global $currencies, $languages_id;
if ($exclude == '') {
$exclude = array();
}
$select_string = '<select name="' . $name . '"';
if ($parameters) {
$select_string .= ' ' . $parameters;
}
$select_string .= '>';
$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' order by products_name");
while ($products = tep_db_fetch_array($products_query)) {
if (!tep_in_array($products['products_id'], $exclude)) {
$select_string .= '<option value="' . $products['products_id'] . '">' . $products['products_name'] . ' (' . $currencies->format($products['products_price']) . ')</option>';
}
}
$select_string .= '</select>';
return $select_string;
}
function tep_options_name($options_id) {
global $languages_id;
$options = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $options_id . "' and language_id = '" . $languages_id . "'");
$options_values = tep_db_fetch_array($options);
return $options_values['products_options_name'];
}
function tep_values_name($values_id) {
global $languages_id;
$values = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . $values_id . "' and language_id = '" . $languages_id . "'");
$values_values = tep_db_fetch_array($values);
return $values_values['products_options_values_name'];
}
function tep_info_image($image, $alt, $width = '', $height = '') {
if ( ($image) && (file_exists(DIR_FS_CATALOG_IMAGES . $image)) ) {
$image = tep_image(DIR_WS_CATALOG_IMAGES . $image, $alt, $width, $height);
} else {
$image = TEXT_IMAGE_NONEXISTENT;
}
return $image;
}
function tep_break_string($string, $len, $break_char = '-') {
$l = 0;
$output = '';
for ($i = 0; $i < strlen($string); $i++) {
$char = substr($string, $i, 1);
if ($char != ' ') {
$l++;
} else {
$l = 0;
}
if ($l > $len) {
$l = 1;
$output .= $break_char;
}
$output .= $char;
}
return $output;
}
function tep_get_country_name($country_id) {
$country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . $country_id . "'");
if (!tep_db_num_rows($country_query)) {
return $country_id;
} else {
$country = tep_db_fetch_array($country_query);
return $country['countries_name'];
}
}
function tep_get_zone_name($zone_id) {
$zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_id = '" . $zone_id . "'");
if (!tep_db_num_rows($zone_query)) {
return $zone_id;
} else {
$zone = tep_db_fetch_array($zone_query);
return $zone['zone_name'];
}
}
function tep_not_null($value) {
if (is_array($value)) {
if (sizeof($value) > 0) {
return true;
} else {
return false;
}
} else {
if (($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {
return true;
} else {
return false;
}
}
}
function tep_browser_detect($component) {
global $HTTP_USER_AGENT;
return stristr($HTTP_USER_AGENT, $component);
}
function tep_tax_classes_pull_down($parameters, $selected = '') {
$select_string = '<select ' . $parameters . '>';
$classes_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
while ($classes = tep_db_fetch_array($classes_query)) {
$select_string .= '<option value="' . $classes['tax_class_id'] . '"';
if ($selected == $classes['tax_class_id']) $select_string .= ' SELECTED';
$select_string .= '>' . $classes['tax_class_title'] . '</option>';
}
$select_string .= '</select>';
return $select_string;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -