[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path Zen Cart 源代码 html_output.php
while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
if (defined('SID') && zen_not_null(SID)) {
$sid = SID;
// } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL_ADMIN == 'true') ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
} elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == 'true') ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
if ($http_domain != $https_domain) {
$sid = zen_session_name() . '=' . zen_session_id();
}
}
}
// clean up the link before processing
while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);
while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);
if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);
/*
* The HTML image wrapper function for non-proportional images
* used when "proportional images" is turned off or if calling from a template directory
*/
function zen_image_OLD($src, $alt = '', $width = '', $height = '', $parameters = '') {
global $template_dir;
//auto replace with defined missing image
if ($src == DIR_WS_IMAGES and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
$src = DIR_WS_IMAGES . PRODUCTS_IMAGE_NO_IMAGE;
}
// if not in current template switch to template_default
if (!file_exists($src)) {
$src = str_replace(DIR_WS_TEMPLATES . $template_dir, DIR_WS_TEMPLATES . 'template_default', $src);
}
// alt is added to the img tag even if it is null to prevent browsers from outputting
// the image filename as default
$image = '<img src="' . zen_output_string($src) . '" alt="' . zen_output_string($alt) . '"';
if (zen_not_null($parameters)) $image .= ' ' . $parameters;
$image .= ' />';
return $image;
}
/*
* The HTML image wrapper function
*/
function zen_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
global $template_dir, $zco_notifier;
// soft clean the alt tag
$alt = zen_clean_html($alt);
// use old method on template images
if (strstr($src, 'includes/templates') or strstr($src, 'includes/languages') or PROPORTIONAL_IMAGES_STATUS == '0') {
return zen_image_OLD($src, $alt, $width, $height, $parameters);
}
//auto replace with defined missing image
if ($src == DIR_WS_IMAGES and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
$src = DIR_WS_IMAGES . PRODUCTS_IMAGE_NO_IMAGE;
}
// if not in current template switch to template_default
if (!file_exists($src)) {
$src = str_replace(DIR_WS_TEMPLATES . $template_dir, DIR_WS_TEMPLATES . 'template_default', $src);
}
// hook for handle_image() function such as Image Handler etc
if (function_exists('handle_image')) {
$newimg = handle_image($src, $alt, $width, $height, $parameters);
list($src, $alt, $width, $height, $parameters) = $newimg;
$zco_notifier->notify('NOTIFY_HANDLE_IMAGE', array($newimg));
}
// Convert width/height to int for proper validation.
// intval() used to support compatibility with plugins like image-handler
$width = empty($width) ? $width : intval($width);
$height = empty($height) ? $height : intval($height);
// alt is added to the img tag even if it is null to prevent browsers from outputting
// the image filename as default
$image = '<img src="' . zen_output_string($src) . '" alt="' . zen_output_string($alt) . '"';
if (zen_not_null($width) && zen_not_null($height) and file_exists($src)) {
// $image .= ' width="' . zen_output_string($width) . '" height="' . zen_output_string($height) . '"';
// proportional images
$image_size = @getimagesize($src);
// fix division by zero error
$ratio = ($image_size[0] != 0 ? $width / $image_size[0] : 1);
if ($image_size[1]*$ratio > $height) {
$ratio = $height / $image_size[1];
$width = $image_size[0] * $ratio;
} else {
$height = $image_size[1] * $ratio;
}
// only use proportional image when image is larger than proportional size
if ($image_size[0] < $width and $image_size[1] < $height) {
$image .= ' width="' . $image_size[0] . '" height="' . intval($image_size[1]) . '"';
} else {
$image .= ' width="' . round($width) . '" height="' . round($height) . '"';
}
} else {
// override on missing image to allow for proportional and required/not required
if (IMAGE_REQUIRED == 'false') {
return false;
} else if (substr($src, 0, 4) != 'http') {
$image .= ' width="' . intval(SMALL_IMAGE_WIDTH) . '" height="' . intval(SMALL_IMAGE_HEIGHT) . '"';
}
}
// inject rollover class if one is defined. NOTE: This could end up with 2 "class" elements if $parameters contains "class" already.
if (defined('IMAGE_ROLLOVER_CLASS') && IMAGE_ROLLOVER_CLASS != '') {
$parameters .= (zen_not_null($parameters) ? ' ' : '') . 'class="rollover"';
}
// add $parameters to the tag output
if (zen_not_null($parameters)) $image .= ' ' . $parameters;
$image .= ' />';
return $image;
}
/*
* The HTML form submit button wrapper function
* Outputs a "submit" button in the selected language
*/
function zen_image_submit($image, $alt = '', $parameters = '', $sec_class = '') {
global $template, $current_page_base, $zco_notifier;
if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes' && strlen($alt)<30) return zenCssButton($image, $alt, 'submit', $sec_class /*, $parameters = ''*/ );
$zco_notifier->notify('PAGE_OUTPUT_IMAGE_SUBMIT');
if (zen_not_null($parameters)) $image_submit .= ' ' . $parameters;
$image_submit .= ' />';
return $image_submit;
}
/*
* Output a function button in the selected language
*/
function zen_image_button($image, $alt = '', $parameters = '', $sec_class = '') {
global $template, $current_page_base, $zco_notifier;
// inject rollover class if one is defined. NOTE: This could end up with 2 "class" elements if $parameters contains "class" already.
if (defined('IMAGE_ROLLOVER_CLASS') && IMAGE_ROLLOVER_CLASS != '') {
$parameters .= (zen_not_null($parameters) ? ' ' : '') . 'class="rollover"';
}
/**
* generate CSS buttons in the current language
* concept from contributions by Seb Rouleau and paulm, subsequently adapted to Zen Cart
* note: any hard-coded buttons will not be able to use this function
**/
function zenCssButton($image = '', $text, $type, $sec_class = '', $parameters = '') {
// automatic width setting depending on the number of characters
$min_width = 80; // this is the minimum button width, change the value as you like
$character_width = 6.5; // change this value depending on font size!
// end settings
// added html_entity_decode function to prevent html special chars to be counted as multiple characters (like &)
$width = strlen(html_entity_decode($text)) * $character_width;
$width = (int)$width;
if ($width < $min_width) $width = $min_width;
$style = ' style="width: ' . $width . 'px;"';
// if no secondary class is set use the image name for the sec_class
if (empty($sec_class)) $sec_class = basename($image, '.gif');
if(!empty($sec_class))$sec_class = ' ' . $sec_class;
if(!empty($parameters))$parameters = ' ' . $parameters;
$mouse_out_class = 'cssButton' . $sec_class;
$mouse_over_class = 'cssButtonHover' . $sec_class . $sec_class . 'Hover';
// javascript to set different classes on mouseover and mouseout: enables hover effect on the buttons
// (pure css hovers on non link elements do work work in every browser)
$css_button_js .= 'onmouseover="this.className=\''. $mouse_over_class . '\'" onmouseout="this.className=\'' . $mouse_out_class . '\'"';
/*
* Output a separator either through whitespace, or with an image
*/
function zen_draw_separator($image = 'true', $width = '100%', $height = '1') {
// set default to use from template - zen_image will translate if not found in current template
if ($image == 'true') {
$image = DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_BLACK_SEPARATOR;
} else {
if (!strstr($image, DIR_WS_TEMPLATE_IMAGES)) {
$image = DIR_WS_TEMPLATE_IMAGES . $image;
}
}
return zen_image($image, '', $width, $height);
}
if (zen_not_null($parameters)) $field .= ' ' . $parameters;
$field .= ' />';
return $field;
}
/*
* Output a form file-field
*/
function zen_draw_file_field($name, $required = false) {
$field = zen_draw_input_field($name, '', ' size="50" ', 'file');
return $field;
}
/*
* Hide form elements while including session id info
* IMPORTANT: This should be used in every FORM that has an OnSubmit() function tied to it, to prevent unexpected logouts
*/
function zen_hide_session_id() {
global $session_started;
/*
* Output a form pull down menu
* Pulls values from a passed array, with the indicated option pre-selected
*/
function zen_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
$field = '<select name="' . zen_output_string($name) . '"';
if (zen_not_null($parameters)) $field .= ' ' . $parameters;
$field .= '>' . "\n";
if (empty($default) && isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) ) $default = stripslashes($GLOBALS[$name]);
if ($required == true) $field .= TEXT_FIELD_REQUIRED;
return $field;
}
/*
* Creates a pull-down list of countries
*/
function zen_get_country_list($name, $selected = '', $parameters = '') {
$countriesAtTopOfList = array();
$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$countries = zen_get_countries();
// Set some default entries at top of list:
if (STORE_COUNTRY != SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY) $countriesAtTopOfList[] = SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY;
$countriesAtTopOfList[] = STORE_COUNTRY;
// IF YOU WANT TO ADD MORE DEFAULTS TO THE TOP OF THIS LIST, SIMPLY ENTER THEIR NUMBERS HERE.
// Duplicate more lines as needed
// Example: Canada is 108, so use 108 as shown:
//$countriesAtTopOfList[] = 108;
//process array of top-of-list entries:
foreach ($countriesAtTopOfList as $key=>$val) {
$countries_array[] = array('id' => $val, 'text' => zen_get_country_name($val));
}
// now add anything not in the defaults list:
for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
$alreadyInList = FALSE;
foreach($countriesAtTopOfList as $key=>$val) {
if ($countries[$i]['countries_id'] == $val)
{
// If you don't want to exclude entries already at the top of the list, comment out this next line:
$alreadyInList = TRUE;
continue;
}
}
if (!$alreadyInList) $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
}
return zen_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
}
/*
* Assesses suitability for additional parameters such as rel=nofollow etc
*/
function zen_href_params($page = '', $parameters = '') {
global $current_page_base;
$addparms = '';
// if nofollow has already been set, ignore this function
if (stristr($parameters, 'nofollow')) return $parameters;
// if list of skippable pages has been set in meta_tags.php lang file (is by default), use that to add rel=nofollow params
if (defined('ROBOTS_PAGES_TO_SKIP') && in_array($page, explode(",", constant('ROBOTS_PAGES_TO_SKIP')))
|| $current_page_base=='down_for_maintenance') $addparms = 'rel="nofollow"';
return ($parameters == '' ? $addparms : $parameters . ' ' . $addparms);
}
?>