⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 general.php

📁 每个RFC 3261信息头有一个相应的存取标识. 但是,许多信息头拥有同样的形式。 例如。To和From的信息头都是由显示名和一个URI组成。 To和From信息头用来管理与处理NameAddr实例的
💻 PHP
📖 第 1 页 / 共 4 页
字号:
<?php/*  $Id: general.php,v 1.160 2003/07/12 08:32:47 hpdl Exp $  osCommerce, Open Source E-Commerce Solutions  http://www.oscommerce.com  Copyright (c) 2003 osCommerce  Released under the GNU General Public License*/////// 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;  }////// Parse the data used in the html tags to ensure the tags will not break  function tep_parse_input_field_data($data, $parse) {    return strtr(trim($data), $parse);  }  function tep_output_string($string, $translate = false, $protected = false) {    if ($protected == true) {      return htmlspecialchars($string);    } else {      if ($translate == false) {        return tep_parse_input_field_data($string, array('"' => '&quot;'));      } else {        return tep_parse_input_field_data($string, $translate);      }    }  }  function tep_output_string_protected($string) {    return tep_output_string($string, false, true);  }  function tep_sanitize_string($string) {    $string = ereg_replace(' +', ' ', $string);    return preg_replace("/[<>]/", '_', $string);  }  function tep_customers_name($customers_id) {    $customers = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$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 = '" . (int)$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 = '" . (int)$current_category_id . "'");        $current_category = tep_db_fetch_array($current_category_query);        if ($last_category['parent_id'] == $current_category['parent_id']) {          for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) {            $cPath_new .= '_' . $cPath_array[$i];          }        } else {          for ($i = 0, $n = sizeof($cPath_array); $i < $n; $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') && (!in_array($key, $exclude_array))) $get_url .= $key . '=' . $value . '&';    }    return $get_url;  }  function tep_date_long($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 strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year));  }////// 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// NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers  function tep_date_short($raw_date) {    if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;    $year = 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);    if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {      return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));    } else {      return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));    }  }  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_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' => TEXT_TOP);    if ($include_itself) {      $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$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 = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$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 . '&nbsp;&nbsp;&nbsp;', $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 = '" . (int)$languages_id . "' order by products_name");    while ($products = tep_db_fetch_array($products_query)) {      if (!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 = '" . (int)$options_id . "' and language_id = '" . (int)$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 = '" . (int)$values_id . "' and language_id = '" . (int)$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 (tep_not_null($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, $n=strlen($string); $i<$n; $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 = '" . (int)$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($country_id, $zone_id, $default_zone) {    $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");    if (tep_db_num_rows($zone_query)) {      $zone = tep_db_fetch_array($zone_query);      return $zone['zone_name'];    } else {      return $default_zone;    }  }  function tep_not_null($value) {    if (is_array($value)) {      if (sizeof($value) > 0) {        return true;      } else {        return false;      }    } else {      if ( (is_string($value) || is_int($value)) && ($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;  }  function tep_geo_zones_pull_down($parameters, $selected = '') {    $select_string = '<select ' . $parameters . '>';    $zones_query = tep_db_query("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " order by geo_zone_name");    while ($zones = tep_db_fetch_array($zones_query)) {      $select_string .= '<option value="' . $zones['geo_zone_id'] . '"';      if ($selected == $zones['geo_zone_id']) $select_string .= ' SELECTED';      $select_string .= '>' . $zones['geo_zone_name'] . '</option>';    }    $select_string .= '</select>';    return $select_string;  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -