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

📄 general.php

📁 asterisk 計費模塊
💻 PHP
📖 第 1 页 / 共 3 页
字号:
    $category_query = tep_db_query("select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int)$products_id . "' and p.products_status = '1' and p.products_id = p2c.products_id limit 1");    if (tep_db_num_rows($category_query)) {      $category = tep_db_fetch_array($category_query);      $categories = array();      tep_get_parent_categories($categories, $category['categories_id']);      $categories = array_reverse($categories);      $cPath = implode('_', $categories);      if (tep_not_null($cPath)) $cPath .= '_';      $cPath .= $category['categories_id'];    }    return $cPath;  }////// Return a product ID with attributes  function tep_get_uprid($prid, $params) {    if (is_numeric($prid)) {      $uprid = $prid;      if (is_array($params) && (sizeof($params) > 0)) {        $attributes_check = true;        $attributes_ids = '';        reset($params);        while (list($option, $value) = each($params)) {          if (is_numeric($option) && is_numeric($value)) {            $attributes_ids .= '{' . (int)$option . '}' . (int)$value;          } else {            $attributes_check = false;            break;          }        }        if ($attributes_check == true) {          $uprid .= $attributes_ids;        }      }    } else {      $uprid = tep_get_prid($prid);      if (is_numeric($uprid)) {        if (strpos($prid, '{') !== false) {          $attributes_check = true;          $attributes_ids = '';// strpos()+1 to remove up to and including the first { which would create an empty array element in explode()          $attributes = explode('{', substr($prid, strpos($prid, '{')+1));          for ($i=0, $n=sizeof($attributes); $i<$n; $i++) {            $pair = explode('}', $attributes[$i]);            if (is_numeric($pair[0]) && is_numeric($pair[1])) {              $attributes_ids .= '{' . (int)$pair[0] . '}' . (int)$pair[1];            } else {              $attributes_check = false;              break;            }          }          if ($attributes_check == true) {            $uprid .= $attributes_ids;          }        }      } else {        return false;      }    }    return $uprid;  }////// Return a product ID from a product ID with attributes  function tep_get_prid($uprid) {    $pieces = explode('{', $uprid);    if (is_numeric($pieces[0])) {      return $pieces[0];    } else {      return false;    }  }////// Return a customer greeting  function tep_customer_greeting() {    global $customer_id, $customer_first_name;    if (tep_session_is_registered('customer_first_name') && tep_session_is_registered('customer_id')) {      $greeting_string = sprintf(TEXT_GREETING_PERSONAL, tep_output_string_protected($customer_first_name), tep_href_link(FILENAME_PRODUCTS_NEW));    } else {      $greeting_string = sprintf(TEXT_GREETING_GUEST, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));    }    return $greeting_string;  }//////! Send email (text/html) using MIME// This is the central mail function. The SMTP Server should be configured// correct in php.ini// Parameters:// $to_name           The name of the recipient, e.g. "Jan Wildeboer"// $to_email_address  The eMail address of the recipient,//                    e.g. jan.wildeboer@gmx.de// $email_subject     The subject of the eMail// $email_text        The text of the eMail, may contain HTML entities// $from_email_name   The name of the sender, e.g. Shop Administration// $from_email_adress The eMail address of the sender,//                    e.g. info@mytepshop.com  function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) {    if (SEND_EMAILS != 'true') return false;    // Instantiate a new mail object    $message = new email(array('X-Mailer: osCommerce Mailer'));    // Build the text version    $text = strip_tags($email_text);    if (EMAIL_USE_HTML == 'true') {      $message->add_html($email_text, $text);    } else {      $message->add_text($text);    }    // Send message    $message->build_message();    $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);  }////// Check if product has attributes  function tep_has_product_attributes($products_id) {    $attributes_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "'");    $attributes = tep_db_fetch_array($attributes_query);    if ($attributes['count'] > 0) {      return true;    } else {      return false;    }  }////// Get the number of times a word/character is present in a string  function tep_word_count($string, $needle) {    $temp_array = split($needle, $string);    return sizeof($temp_array);  }  function tep_count_modules($modules = '') {    $count = 0;    if (empty($modules)) return $count;    $modules_array = split(';', $modules);    for ($i=0, $n=sizeof($modules_array); $i<$n; $i++) {      $class = substr($modules_array[$i], 0, strrpos($modules_array[$i], '.'));      if (is_object($GLOBALS[$class])) {        if ($GLOBALS[$class]->enabled) {          $count++;        }      }    }    return $count;  }  function tep_count_payment_modules() {    return tep_count_modules(MODULE_PAYMENT_INSTALLED);  }  function tep_count_shipping_modules() {    return tep_count_modules(MODULE_SHIPPING_INSTALLED);  }  function tep_create_random_value($length, $type = 'mixed') {    if ( ($type != 'mixed') && ($type != 'chars') && ($type != 'digits')) return false;    $rand_value = '';    while (strlen($rand_value) < $length) {      if ($type == 'digits') {        $char = tep_rand(0,9);      } else {        $char = chr(tep_rand(0,255));      }      if ($type == 'mixed') {        if (eregi('^[a-z0-9]$', $char)) $rand_value .= $char;      } elseif ($type == 'chars') {        if (eregi('^[a-z]$', $char)) $rand_value .= $char;      } elseif ($type == 'digits') {        if (ereg('^[0-9]$', $char)) $rand_value .= $char;      }    }    return $rand_value;  }  function tep_array_to_string($array, $exclude = '', $equals = '=', $separator = '&') {    if (!is_array($exclude)) $exclude = array();    $get_string = '';    if (sizeof($array) > 0) {      while (list($key, $value) = each($array)) {        if ( (!in_array($key, $exclude)) && ($key != 'x') && ($key != 'y') ) {          $get_string .= $key . $equals . $value . $separator;        }      }      $remove_chars = strlen($separator);      $get_string = substr($get_string, 0, -$remove_chars);    }    return $get_string;  }  function tep_not_null($value) {    if (is_array($value)) {      if (sizeof($value) > 0) {        return true;      } else {        return false;      }    } else {      if (($value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) {        return true;      } else {        return false;      }    }  }////// Output the tax percentage with optional padded decimals  function tep_display_tax_value($value, $padding = TAX_DECIMAL_PLACES) {    if (strpos($value, '.')) {      $loop = true;      while ($loop) {        if (substr($value, -1) == '0') {          $value = substr($value, 0, -1);        } else {          $loop = false;          if (substr($value, -1) == '.') {            $value = substr($value, 0, -1);          }        }      }    }    if ($padding > 0) {      if ($decimal_pos = strpos($value, '.')) {        $decimals = strlen(substr($value, ($decimal_pos+1)));        for ($i=$decimals; $i<$padding; $i++) {          $value .= '0';        }      } else {        $value .= '.';        for ($i=0; $i<$padding; $i++) {          $value .= '0';        }      }    }    return $value;  }////// Checks to see if the currency code exists as a currency// TABLES: currencies  function tep_currency_exists($code) {    $code = tep_db_prepare_input($code);    $currency_code = tep_db_query("select currencies_id from " . TABLE_CURRENCIES . " where code = '" . tep_db_input($code) . "'");    if (tep_db_num_rows($currency_code)) {      return $code;    } else {      return false;    }  }  function tep_string_to_int($string) {    return (int)$string;  }////// Parse and secure the cPath parameter values  function tep_parse_category_path($cPath) {// make sure the category IDs are integers    $cPath_array = array_map('tep_string_to_int', explode('_', $cPath));// make sure no duplicate category IDs exist which could lock the server in a loop    $tmp_array = array();    $n = sizeof($cPath_array);    for ($i=0; $i<$n; $i++) {      if (!in_array($cPath_array[$i], $tmp_array)) {        $tmp_array[] = $cPath_array[$i];      }    }    return $tmp_array;  }////// Return a random value  function tep_rand($min = null, $max = null) {    static $seeded;    if (!isset($seeded)) {      mt_srand((double)microtime()*1000000);      $seeded = true;    }    if (isset($min) && isset($max)) {      if ($min >= $max) {        return $min;      } else {        return mt_rand($min, $max);      }    } else {      return mt_rand();    }  }  function tep_setcookie($name, $value = '', $expire = 0, $path = '/', $domain = '', $secure = 0) {    setcookie($name, $value, $expire, $path, (tep_not_null($domain) ? $domain : ''), $secure);  }  function tep_get_ip_address() {    if (isset($_SERVER)) {      if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];      } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {        $ip = $_SERVER['HTTP_CLIENT_IP'];      } else {        $ip = $_SERVER['REMOTE_ADDR'];      }    } else {      if (getenv('HTTP_X_FORWARDED_FOR')) {        $ip = getenv('HTTP_X_FORWARDED_FOR');      } elseif (getenv('HTTP_CLIENT_IP')) {        $ip = getenv('HTTP_CLIENT_IP');      } else {        $ip = getenv('REMOTE_ADDR');      }    }    return $ip;  }  function tep_count_customer_orders($id = '', $check_session = true) {    global $customer_id;    if (is_numeric($id) == false) {      if (tep_session_is_registered('customer_id')) {        $id = $customer_id;      } else {        return 0;      }    }    if ($check_session == true) {      if ( (tep_session_is_registered('customer_id') == false) || ($id != $customer_id) ) {        return 0;      }    }    $orders_check_query = tep_db_query("select count(*) as total from " . TABLE_ORDERS . " where customers_id = '" . (int)$id . "'");    $orders_check = tep_db_fetch_array($orders_check_query);    return $orders_check['total'];  }  function tep_count_customer_address_book_entries($id = '', $check_session = true) {    global $customer_id;    if (is_numeric($id) == false) {      if (tep_session_is_registered('customer_id')) {        $id = $customer_id;      } else {        return 0;      }    }    if ($check_session == true) {      if ( (tep_session_is_registered('customer_id') == false) || ($id != $customer_id) ) {        return 0;      }    }    $addresses_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$id . "'");    $addresses = tep_db_fetch_array($addresses_query);    return $addresses['total'];  }// nl2br() prior PHP 4.2.0 did not convert linefeeds on all OSs (it only converted \n)  function tep_convert_linefeeds($from, $to, $string) {    if ((PHP_VERSION < "4.0.5") && is_array($from)) {      return ereg_replace('(' . implode('|', $from) . ')', $to, $string);    } else {      return str_replace($from, $to, $string);    }  }  function tep_db_prepare_input($string) {    if (is_string($string)) {      return trim(stripslashes($string));    } elseif (is_array($string)) {      reset($string);      while (list($key, $value) = each($string)) {        $string[$key] = tep_db_prepare_input($value);      }      return $string;    } else {      return $string;    }  }   ////// Alias function for Store configuration values in the Administration Tool  function tep_cfg_select_option($select_array, $key_value, $key = '') {    $string = '';    for ($i=0, $n=sizeof($select_array); $i<$n; $i++) {      $name = ((tep_not_null($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;  }?>

⌨️ 快捷键说明

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