📄 general.php
字号:
function zen_get_country_name($country_id) {
global $db;
$country = $db->Execute("select countries_name
from " . TABLE_COUNTRIES . "
where countries_id = '" . (int)$country_id . "'");
if ($country->RecordCount() < 1) {
return $country_id;
} else {
return $country->fields['countries_name'];
}
}
function zen_get_country_name_cfg() {
global $db;
$country = $db->Execute("select countries_name
from " . TABLE_COUNTRIES . "
where countries_id = '" . (int)$country_id . "'");
if ($country->RecordCount() < 1) {
return $country_id;
} else {
return $country->fields['countries_name'];
}
}
function zen_get_zone_name($country_id, $zone_id, $default_zone) {
global $db;
$zone = $db->Execute("select zone_name
from " . TABLE_ZONES . "
where zone_country_id = '" . (int)$country_id . "'
and zone_id = '" . (int)$zone_id . "'");
if ($zone->RecordCount() > 0) {
return $zone->fields['zone_name'];
} else {
return $default_zone;
}
}
function zen_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 zen_browser_detect($component) {
return stristr($_SERVER['HTTP_USER_AGENT'], $component);
}
function zen_tax_classes_pull_down($parameters, $selected = '') {
global $db;
$select_string = '<select ' . $parameters . '>';
$classes = $db->Execute("select tax_class_id, tax_class_title
from " . TABLE_TAX_CLASS . "
order by tax_class_title");
while (!$classes->EOF) {
$select_string .= '<option value="' . $classes->fields['tax_class_id'] . '"';
if ($selected == $classes->fields['tax_class_id']) $select_string .= ' SELECTED';
$select_string .= '>' . $classes->fields['tax_class_title'] . '</option>';
$classes->MoveNext();
}
$select_string .= '</select>';
return $select_string;
}
function zen_geo_zones_pull_down($parameters, $selected = '') {
global $db;
$select_string = '<select ' . $parameters . '>';
$zones = $db->Execute("select geo_zone_id, geo_zone_name
from " . TABLE_GEO_ZONES . "
order by geo_zone_name");
while (!$zones->EOF) {
$select_string .= '<option value="' . $zones->fields['geo_zone_id'] . '"';
if ($selected == $zones->fields['geo_zone_id']) $select_string .= ' SELECTED';
$select_string .= '>' . $zones->fields['geo_zone_name'] . '</option>';
$zones->MoveNext();
}
$select_string .= '</select>';
return $select_string;
}
function zen_get_geo_zone_name($geo_zone_id) {
global $db;
$zones = $db->Execute("select geo_zone_name
from " . TABLE_GEO_ZONES . "
where geo_zone_id = '" . (int)$geo_zone_id . "'");
if ($zones->RecordCount() < 1) {
$geo_zone_name = $geo_zone_id;
} else {
$geo_zone_name = $zones->fields['geo_zone_name'];
}
return $geo_zone_name;
}
function zen_address_format($address_format_id, $address, $html, $boln, $eoln) {
global $db;
$address_format = $db->Execute("select address_format as format
from " . TABLE_ADDRESS_FORMAT . "
where address_format_id = '" . (int)$address_format_id . "'");
$company = zen_output_string_protected($address['company']);
if (isset($address['firstname']) && zen_not_null($address['firstname'])) {
$firstname = zen_output_string_protected($address['firstname']);
$lastname = zen_output_string_protected($address['lastname']);
} elseif (isset($address['name']) && zen_not_null($address['name'])) {
$firstname = zen_output_string_protected($address['name']);
$lastname = '';
} else {
$firstname = '';
$lastname = '';
}
$street = zen_output_string_protected($address['street_address']);
$suburb = zen_output_string_protected($address['suburb']);
$city = zen_output_string_protected($address['city']);
$state = zen_output_string_protected($address['state']);
if (isset($address['country_id']) && zen_not_null($address['country_id'])) {
$country = zen_get_country_name($address['country_id']);
if (isset($address['zone_id']) && zen_not_null($address['zone_id'])) {
$state = zen_get_zone_code($address['country_id'], $address['zone_id'], $state);
}
} elseif (isset($address['country']) && zen_not_null($address['country'])) {
$country = zen_output_string_protected($address['country']);
} else {
$country = '';
}
$postcode = zen_output_string_protected($address['postcode']);
$zip = $postcode;
if ($html) {
// HTML Mode
$HR = '<hr>';
$hr = '<hr>';
if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults
$CR = '<br>';
$cr = '<br>';
$eoln = $cr;
} else { // Use values supplied
$CR = $eoln . $boln;
$cr = $CR;
}
} else {
// Text Mode
$CR = $eoln;
$cr = $CR;
$HR = '----------------------------------------';
$hr = '----------------------------------------';
}
$statecomma = '';
$streets = $street;
if ($suburb != '') $streets = $street . $cr . $suburb;
if ($country == '') $country = zen_output_string_protected($address['country']);
if ($state != '') $statecomma = $state . ', ';
$fmt = $address_format->fields['format'];
eval("\$address = \"$fmt\";");
if ( (ACCOUNT_COMPANY == 'true') && (zen_not_null($company)) ) {
$address = $company . $cr . $address;
}
return $address;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//
// Function : zen_get_zone_code
//
// Arguments : country country code string
// zone state/province zone_id
// def_state default string if zone==0
//
// Return : state_prov_code state/province code
//
// Description : Function to retrieve the state/province code (as in FL for Florida etc)
//
////////////////////////////////////////////////////////////////////////////////////////////////
function zen_get_zone_code($country, $zone, $def_state) {
global $db;
$state_prov_values = $db->Execute("select zone_code
from " . TABLE_ZONES . "
where zone_country_id = '" . (int)$country . "'
and zone_id = '" . (int)$zone . "'");
if (!$state_prov_values->RecordCount() < 1) {
$state_prov_code = $def_state;
}
else {
$state_prov_code = $state_prov_values->fields['zone_code'];
}
return $state_prov_code;
}
function zen_get_uprid($prid, $params) {
$uprid = $prid;
if ( (is_array($params)) && (!strstr($prid, '{')) ) {
while (list($option, $value) = each($params)) {
$uprid = $uprid . '{' . $option . '}' . $value;
}
}
return $uprid;
}
function zen_get_prid($uprid) {
$pieces = explode('{', $uprid);
return $pieces[0];
}
function zen_get_languages() {
global $db;
$languages = $db->Execute("select languages_id, name, code, image, directory
from " . TABLE_LANGUAGES . " order by sort_order");
while (!$languages->EOF) {
$languages_array[] = array('id' => $languages->fields['languages_id'],
'name' => $languages->fields['name'],
'code' => $languages->fields['code'],
'image' => $languages->fields['image'],
'directory' => $languages->fields['directory']);
$languages->MoveNext();
}
return $languages_array;
}
function zen_get_category_name($category_id, $language_id) {
global $db;
$category = $db->Execute("select categories_name
from " . TABLE_CATEGORIES_DESCRIPTION . "
where categories_id = '" . (int)$category_id . "'
and language_id = '" . (int)$language_id . "'");
return $category->fields['categories_name'];
}
function zen_get_category_description($category_id, $language_id) {
global $db;
$category = $db->Execute("select categories_description
from " . TABLE_CATEGORIES_DESCRIPTION . "
where categories_id = '" . (int)$category_id . "'
and language_id = '" . (int)$language_id . "'");
return $category->fields['categories_description'];
}
function zen_get_orders_status_name($orders_status_id, $language_id = '') {
global $db;
if (!$language_id) $language_id = $_SESSION['languages_id'];
$orders_status = $db->Execute("select orders_status_name
from " . TABLE_ORDERS_STATUS . "
where orders_status_id = '" . (int)$orders_status_id . "'
and language_id = '" . (int)$language_id . "'");
return $orders_status->fields['orders_status_name'];
}
function zen_get_orders_status() {
global $db;
$orders_status_array = array();
$orders_status = $db->Execute("select orders_status_id, orders_status_name
from " . TABLE_ORDERS_STATUS . "
where language_id = '" . (int)$_SESSION['languages_id'] . "'
order by orders_status_id");
while (!$orders_status->EOF) {
$orders_status_array[] = array('id' => $orders_status->fields['orders_status_id'],
'text' => $orders_status->fields['orders_status_name']);
$orders_status->MoveNext();
}
return $orders_status_array;
}
function zen_get_products_name($product_id, $language_id = 0) {
global $db;
if ($language_id == 0) $language_id = $_SESSION['languages_id'];
$product = $db->Execute("select products_name
from " . TABLE_PRODUCTS_DESCRIPTION . "
where products_id = '" . (int)$product_id . "'
and language_id = '" . (int)$language_id . "'");
return $product->fields['products_name'];
}
function zen_get_products_description($product_id, $language_id) {
global $db;
$product = $db->Execute("select products_description
from " . TABLE_PRODUCTS_DESCRIPTION . "
where products_id = '" . (int)$product_id . "'
and language_id = '" . (int)$language_id . "'");
return $product->fields['products_description'];
}
function zen_get_products_url($product_id, $language_id) {
global $db;
$product = $db->Execute("select products_url
from " . TABLE_PRODUCTS_DESCRIPTION . "
where products_id = '" . (int)$product_id . "'
and language_id = '" . (int)$language_id . "'");
return $product->fields['products_url'];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -