[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[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

Zen Cart 源代码 html_output.php




下载文件

文件名: html_output.php
文件类型: PHP文件
文件大小: 23.38 KiB
MD5: f1ff6bd50236b52a87a5761b4d09bbd4

html_output.php - 关闭高亮
  1. <?php
  2. /**
  3.  * html_output.php
  4.  * HTML-generating functions used throughout the core
  5.  *
  6.  * @package functions
  7.  * @copyright Copyright 2003-2014 Zen Cart Development Team
  8.  * @copyright Portions Copyright 2003 osCommerce
  9.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  10.  * @version GIT: $Id: Author: DrByte  Sat Apr 19 13:30:33 2014 -0400 Modified in v1.5.3 $
  11.  */
  12.  
  13. // Ultimate SEO URLs
  14. // The HTML href link wrapper function
  15.   function zen_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true, $static = false, $use_dir_ws_catalog = true) {
  16.     global $seo_urls;
  17.  
  18.     $href_link = null;
  19.     if(isset($seo_urls)) {
  20.       $href_link = $seo_urls->href_link($page, $parameters, $connection, $add_session_id, $static, $use_dir_ws_catalog);
  21.     }
  22.  
  23.     if($href_link === null) {
  24.         $href_link = original_zen_href_link($page, $parameters, $connection, $add_session_id, $search_engine_safe, $static, $use_dir_ws_catalog);
  25.     }
  26.  
  27.     return $href_link;
  28.   }
  29.  
  30. /*
  31.  * The HTML href link wrapper function
  32.  */
  33.   function original_zen_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true, $static = false, $use_dir_ws_catalog = true) {
  34.     global $request_type, $session_started, $http_domain, $https_domain;
  35.  
  36.     if (!zen_not_null($page)) {
  37.       die('</td></tr></table></td></tr></table><br /><br /><strong class="note">Error!<br /><br />Unable to determine the page link!</strong><br /><br /><!--' . $page . '<br />' . $parameters . ' -->');
  38.     }
  39.  
  40.     if ($connection == 'NONSSL') {
  41.       $link = HTTP_SERVER;
  42.     } elseif ($connection == 'SSL') {
  43.       if (ENABLE_SSL == 'true') {
  44.         $link = HTTPS_SERVER ;
  45.       } else {
  46.         $link = HTTP_SERVER;
  47.       }
  48.     } else {
  49.       die('</td></tr></table></td></tr></table><br /><br /><strong class="note">Error!<br /><br />Unable to determine connection method on a link!<br /><br />Known methods: NONSSL SSL</strong><br /><br />');
  50.     }
  51.  
  52.     if ($use_dir_ws_catalog) {
  53.       if ($connection == 'SSL' && ENABLE_SSL == 'true') {
  54.         $link .= DIR_WS_HTTPS_CATALOG;
  55.       } else {
  56.         $link .= DIR_WS_CATALOG;
  57.       }
  58.     }
  59.  
  60.     if (!$static) {
  61.       if (zen_not_null($parameters)) {
  62.         $link .= 'index.php?main_page='. $page . "&" . zen_output_string($parameters);
  63.       } else {
  64.         $link .= 'index.php?main_page=' . $page;
  65.       }
  66.     } else {
  67.       if (zen_not_null($parameters)) {
  68.         $link .= $page . "?" . zen_output_string($parameters);
  69.       } else {
  70.         $link .= $page;
  71.       }
  72.     }
  73.  
  74.     $separator = '&';
  75.  
  76.     while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
  77. // Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
  78.     if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
  79.       if (defined('SID') && zen_not_null(constant('SID'))) {
  80.         $sid = constant('SID');
  81. //      } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL_ADMIN == 'true') ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
  82.       } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == 'true') ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
  83.         if ($http_domain != $https_domain) {
  84.           $sid = zen_session_name() . '=' . zen_session_id();
  85.         }
  86.       }
  87.     }
  88.  
  89. // clean up the link before processing
  90.     while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);
  91.     while (strstr($link, '&amp;&amp;')) $link = str_replace('&amp;&amp;', '&amp;', $link);
  92.  
  93.     if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
  94.       while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);
  95.  
  96.       $link = str_replace('&amp;', '/', $link);
  97.       $link = str_replace('?', '/', $link);
  98.       $link = str_replace('&', '/', $link);
  99.       $link = str_replace('=', '/', $link);
  100.  
  101.       $separator = '?';
  102.     }
  103.  
  104.     if (isset($sid)) {
  105.       $link .= $separator . zen_output_string($sid);
  106.     }
  107.  
  108. // clean up the link after processing
  109.     while (strstr($link, '&amp;&amp;')) $link = str_replace('&amp;&amp;', '&amp;', $link);
  110.  
  111.     $link = preg_replace('/&/', '&amp;', $link);
  112.     return $link;
  113.   }
  114.  
  115.  
  116. /*
  117.  * The HTML image wrapper function for non-proportional images
  118.  * used when "proportional images" is turned off or if calling from a template directory
  119.  */
  120.   function zen_image_OLD($src, $alt = '', $width = '', $height = '', $parameters = '') {
  121.     global $template_dir;
  122.  
  123. //auto replace with defined missing image
  124.     if ($src == DIR_WS_IMAGES and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
  125.       $src = DIR_WS_IMAGES . PRODUCTS_IMAGE_NO_IMAGE;
  126.     }
  127.  
  128.     if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
  129.       return false;
  130.     }
  131.  
  132.     // if not in current template switch to template_default
  133.     if (!file_exists($src)) {
  134.       $src = str_replace(DIR_WS_TEMPLATES . $template_dir, DIR_WS_TEMPLATES . 'template_default', $src);
  135.     }
  136.  
  137. // alt is added to the img tag even if it is null to prevent browsers from outputting
  138. // the image filename as default
  139.     $image = '<img src="' . zen_output_string($src) . '" alt="' . zen_output_string($alt) . '"';
  140.  
  141.     if (zen_not_null($alt)) {
  142.       $image .= ' title=" ' . zen_output_string($alt) . ' "';
  143.     }
  144.  
  145.     if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) {
  146.       if ($image_size = @getimagesize($src)) {
  147.         if (empty($width) && zen_not_null($height)) {
  148.           $ratio = $height / $image_size[1];
  149.           $width = $image_size[0] * $ratio;
  150.         } elseif (zen_not_null($width) && empty($height)) {
  151.           $ratio = $width / $image_size[0];
  152.           $height = $image_size[1] * $ratio;
  153.         } elseif (empty($width) && empty($height)) {
  154.           $width = $image_size[0];
  155.           $height = $image_size[1];
  156.         }
  157.       } elseif (IMAGE_REQUIRED == 'false') {
  158.         return false;
  159.       }
  160.     }
  161.  
  162.     if (zen_not_null($width) && zen_not_null($height)) {
  163.       $image .= ' width="' . zen_output_string($width) . '" height="' . zen_output_string($height) . '"';
  164.     }
  165.  
  166.     if (zen_not_null($parameters)) $image .= ' ' . $parameters;
  167.  
  168.     $image .= ' />';
  169.  
  170.     return $image;
  171.   }
  172.  
  173.  
  174. /*
  175.  * The HTML image wrapper function
  176.  */
  177.   function zen_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
  178.     global $template_dir, $zco_notifier;
  179.  
  180.     // soft clean the alt tag
  181.     $alt = zen_clean_html($alt);
  182.  
  183.     // use old method on template images
  184.     if (strstr($src, 'includes/templates') or strstr($src, 'includes/languages') or PROPORTIONAL_IMAGES_STATUS == '0') {
  185.       return zen_image_OLD($src, $alt, $width, $height, $parameters);
  186.     }
  187.  
  188. //auto replace with defined missing image
  189.     if ($src == DIR_WS_IMAGES and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
  190.       $src = DIR_WS_IMAGES . PRODUCTS_IMAGE_NO_IMAGE;
  191.     }
  192.  
  193.     if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
  194.       return false;
  195.     }
  196.  
  197.     // if not in current template switch to template_default
  198.     if (!file_exists($src)) {
  199.       $src = str_replace(DIR_WS_TEMPLATES . $template_dir, DIR_WS_TEMPLATES . 'template_default', $src);
  200.     }
  201.  
  202.     // hook for handle_image() function such as Image Handler etc
  203.     if (function_exists('handle_image')) {
  204.       $newimg = handle_image($src, $alt, $width, $height, $parameters);
  205.       list($src, $alt, $width, $height, $parameters) = $newimg;
  206.       $zco_notifier->notify('NOTIFY_HANDLE_IMAGE', array($newimg));
  207.     }
  208.  
  209.     // Convert width/height to int for proper validation.
  210.     // intval() used to support compatibility with plugins like image-handler
  211.     $width = empty($width) ? $width : intval($width);
  212.     $height = empty($height) ? $height : intval($height);
  213.  
  214. // alt is added to the img tag even if it is null to prevent browsers from outputting
  215. // the image filename as default
  216.     $image = '<img src="' . zen_output_string($src) . '" alt="' . zen_output_string($alt) . '"';
  217.  
  218.     if (zen_not_null($alt)) {
  219.       $image .= ' title=" ' . zen_output_string($alt) . ' "';
  220.     }
  221.  
  222.     if ( ((CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height))) ) {
  223.       if ($image_size = @getimagesize($src)) {
  224.         if (empty($width) && zen_not_null($height)) {
  225.           $ratio = $height / $image_size[1];
  226.           $width = $image_size[0] * $ratio;
  227.         } elseif (zen_not_null($width) && empty($height)) {
  228.           $ratio = $width / $image_size[0];
  229.           $height = $image_size[1] * $ratio;
  230.         } elseif (empty($width) && empty($height)) {
  231.           $width = $image_size[0];
  232.           $height = $image_size[1];
  233.         }
  234.       } elseif (IMAGE_REQUIRED == 'false') {
  235.         return false;
  236.       }
  237.     }
  238.  
  239.  
  240.     if (zen_not_null($width) && zen_not_null($height) and file_exists($src)) {
  241. //      $image .= ' width="' . zen_output_string($width) . '" height="' . zen_output_string($height) . '"';
  242. // proportional images
  243.       $image_size = @getimagesize($src);
  244.       // fix division by zero error
  245.       $ratio = ($image_size[0] != 0 ? $width / $image_size[0] : 1);
  246.       if ($image_size[1]*$ratio > $height) {
  247.         $ratio = $height / $image_size[1];
  248.         $width = $image_size[0] * $ratio;
  249.       } else {
  250.         $height = $image_size[1] * $ratio;
  251.       }
  252. // only use proportional image when image is larger than proportional size
  253.       if ($image_size[0] < $width and $image_size[1] < $height) {
  254.         $image .= ' width="' . $image_size[0] . '" height="' . intval($image_size[1]) . '"';
  255.       } else {
  256.         $image .= ' width="' . round($width) . '" height="' . round($height) . '"';
  257.       }
  258.     } else {
  259.        // override on missing image to allow for proportional and required/not required
  260.       if (IMAGE_REQUIRED == 'false') {
  261.         return false;
  262.       } else if (substr($src, 0, 4) != 'http') {
  263.         $image .= ' width="' . intval(SMALL_IMAGE_WIDTH) . '" height="' . intval(SMALL_IMAGE_HEIGHT) . '"';
  264.       }
  265.     }
  266.  
  267.     // inject rollover class if one is defined. NOTE: This could end up with 2 "class" elements if $parameters contains "class" already.
  268.     if (defined('IMAGE_ROLLOVER_CLASS') && IMAGE_ROLLOVER_CLASS != '') {
  269.       $parameters .= (zen_not_null($parameters) ? ' ' : '') . 'class="rollover"';
  270.     }
  271.     // add $parameters to the tag output
  272.     if (zen_not_null($parameters)) $image .= ' ' . $parameters;
  273.  
  274.     $image .= ' />';
  275.  
  276.     return $image;
  277.   }
  278.  
  279. /*
  280.  * The HTML form submit button wrapper function
  281.  * Outputs a "submit" button in the selected language
  282.  */
  283.   function zen_image_submit($image, $alt = '', $parameters = '', $sec_class = '') {
  284.     global $template, $current_page_base, $zco_notifier;
  285.     if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes' && strlen($alt)<30) return zenCssButton($image, $alt, 'submit', $sec_class, $parameters);
  286.     $zco_notifier->notify('PAGE_OUTPUT_IMAGE_SUBMIT');
  287.  
  288.     $image_submit = '<input type="image" src="' . zen_output_string($template->get_template_dir($image, DIR_WS_TEMPLATE, $current_page_base, 'buttons/' . $_SESSION['language'] . '/') . $image) . '" alt="' . zen_output_string($alt) . '"';
  289.  
  290.     if (zen_not_null($alt)) $image_submit .= ' title=" ' . zen_output_string($alt) . ' "';
  291.  
  292.     if (zen_not_null($parameters)) $image_submit .= ' ' . $parameters;
  293.  
  294.     $image_submit .= ' />';
  295.  
  296.     return $image_submit;
  297.   }
  298.  
  299. /*
  300.  * Output a function button in the selected language
  301.  */
  302.   function zen_image_button($image, $alt = '', $parameters = '', $sec_class = '') {
  303.     global $template, $current_page_base, $zco_notifier;
  304.  
  305.     // inject rollover class if one is defined. NOTE: This could end up with 2 "class" elements if $parameters contains "class" already.
  306.     if (defined('IMAGE_ROLLOVER_CLASS') && IMAGE_ROLLOVER_CLASS != '') {
  307.       $parameters .= (zen_not_null($parameters) ? ' ' : '') . 'class="rollover"';
  308.     }
  309.  
  310.     $zco_notifier->notify('PAGE_OUTPUT_IMAGE_BUTTON');
  311.     if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes') return zenCssButton($image, $alt, 'button', $sec_class, $parameters);
  312.     return zen_image($template->get_template_dir($image, DIR_WS_TEMPLATE, $current_page_base, 'buttons/' . $_SESSION['language'] . '/') . $image, $alt, '', '', $parameters);
  313.   }
  314.  
  315.  
  316. /**
  317.  * generate CSS buttons in the current language
  318.  * concept from contributions by Seb Rouleau and paulm, subsequently adapted to Zen Cart
  319.  * note: any hard-coded buttons will not be able to use this function
  320. **/
  321.   function zenCssButton($image = '', $text, $type, $sec_class = '', $parameters = '') {
  322.    global $css_button_text, $css_button_opts, $template, $current_page_base, $language;
  323.  
  324.    $button_name = basename($image, '.gif');
  325.  
  326.     // if no secondary class is set use the image name for the sec_class
  327.     if (empty($sec_class)) $sec_class = $button_name;
  328.     if(!empty($sec_class)) $sec_class = ' ' . $sec_class;
  329.     if(!empty($parameters))$parameters = ' ' . $parameters;
  330.     $mouse_out_class  = 'cssButton ' . (($type == 'submit') ? 'submit_button button ' : 'normal_button button ') . $sec_class;
  331.     $mouse_over_class = 'cssButtonHover ' . (($type == 'button') ? 'normal_button button ' : '') . $sec_class . $sec_class . 'Hover';
  332.     // javascript to set different classes on mouseover and mouseout: enables hover effect on the buttons
  333.     // (pure css hovers on non link elements do work work in every browser)
  334.     $css_button_js .=  'onmouseover="this.className=\''. $mouse_over_class . '\'" onmouseout="this.className=\'' . $mouse_out_class . '\'"';
  335.  
  336.     if (CSS_BUTTON_POPUPS_IS_ARRAY == 'true') {
  337.       $popuptext = (!empty($css_button_text[$button_name])) ? $css_button_text[$button_name] : ($button_name . CSSBUTTONS_CATALOG_POPUPS_SHOW_BUTTON_NAMES_TEXT);
  338.       $tooltip = ' title="' . $popuptext . '"';
  339.     } else {
  340.       $tooltip = '';
  341.     }
  342.     $css_button = '';
  343.  
  344.     if ($type == 'submit'){
  345.       // form input button
  346.       if ($parameters != '') {
  347.         // If the input parameters include a "name" attribute, need to emulate an <input type="image" /> return value by adding a _x to the name parameter (creds to paulm)
  348.         if (preg_match('/name="([a-zA-Z0-9\-_]+)"/', $parameters, $matches)) {
  349.           $parameters = str_replace('name="' . $matches[1], 'name="' . $matches[1] . '_x', $parameters);
  350.         }
  351.         // If the input parameters include a "value" attribute, remove it since that attribute will be set to the input text string.
  352.         if (preg_match('/(value="[a-zA-Z0=9\-_]+")/', $parameters, $matches)) {
  353.           $parameters = str_replace($matches[1], '', $parameters);
  354.         }
  355.       }
  356.  
  357.       $css_button = '<input class="' . $mouse_out_class . '" ' . $css_button_js . ' type="submit" value="' . $text . '"' . $tooltip . $parameters . ' />';
  358.     }
  359.  
  360.     if ($type=='button'){
  361.       // link button
  362.       $css_button = '<span class="' . $mouse_out_class . '" ' . $css_button_js . $tooltip . $parameters . '>&nbsp;' . $text . '&nbsp;</span>';
  363.     }
  364.     return $css_button;
  365.   }
  366.  
  367.  
  368. /*
  369.  *  Output a separator either through whitespace, or with an image
  370.  */
  371.   function zen_draw_separator($image = 'true', $width = '100%', $height = '1') {
  372.  
  373.     // set default to use from template - zen_image will translate if not found in current template
  374.     if ($image == 'true') {
  375.       $image = DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_BLACK_SEPARATOR;
  376.     } else {
  377.       if (!strstr($image, DIR_WS_TEMPLATE_IMAGES)) {
  378.         $image = DIR_WS_TEMPLATE_IMAGES . $image;
  379.       }
  380.     }
  381.     return zen_image($image, '', $width, $height);
  382.   }
  383.  
  384. /*
  385.  *  Output a form
  386.  */
  387.   function zen_draw_form($name, $action, $method = 'post', $parameters = '') {
  388.     $form = '<form name="' . zen_output_string($name) . '" action="' . zen_output_string($action) . '" method="' . zen_output_string($method) . '"';
  389.  
  390.     if (zen_not_null($parameters)) $form .= ' ' . $parameters;
  391.  
  392.     $form .= '>';
  393.     if (strtolower($method) == 'post') $form .= '<input type="hidden" name="securityToken" value="' . $_SESSION['securityToken'] . '" />';
  394.     return $form;
  395.   }
  396.  
  397. /*
  398.  *  Output a form input field
  399.  */
  400.   function zen_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) {
  401.     $field = '<input type="' . zen_output_string($type) . '" name="' . zen_sanitize_string(zen_output_string($name)) . '"';
  402.     if ( (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) && ($reinsert_value == true) ) {
  403.       $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
  404.     } elseif (zen_not_null($value)) {
  405.       $field .= ' value="' . zen_output_string($value) . '"';
  406.     }
  407.  
  408.     if (zen_not_null($parameters)) $field .= ' ' . $parameters;
  409.  
  410.     $field .= ' />';
  411.  
  412.     return $field;
  413.   }
  414.  
  415. /*
  416.  *  Output a form password field
  417.  */
  418.   function zen_draw_password_field($name, $value = '', $parameters = 'maxlength="40"') {
  419.     return zen_draw_input_field($name, $value, $parameters, 'password', true);
  420.   }
  421.  
  422. /*
  423.  *  Output a selection field - alias function for zen_draw_checkbox_field() and zen_draw_radio_field()
  424.  */
  425.   function zen_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') {
  426.     $selection = '<input type="' . zen_output_string($type) . '" name="' . zen_output_string($name) . '"';
  427.  
  428.     if (zen_not_null($value)) $selection .= ' value="' . zen_output_string($value) . '"';
  429.  
  430.     if ( ($checked == true) || ( isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ( ($GLOBALS[$name] == 'on') || (isset($value) && (stripslashes($GLOBALS[$name]) == $value)) ) ) ) {
  431.       $selection .= ' checked="checked"';
  432.     }
  433.  
  434.     if (zen_not_null($parameters)) $selection .= ' ' . $parameters;
  435.  
  436.     $selection .= ' />';
  437.  
  438.     return $selection;
  439.   }
  440.  
  441. /*
  442.  *  Output a form checkbox field
  443.  */
  444.   function zen_draw_checkbox_field($name, $value = '', $checked = false, $parameters = '') {
  445.     return zen_draw_selection_field($name, 'checkbox', $value, $checked, $parameters);
  446.   }
  447.  
  448. /*
  449.  * Output a form radio field
  450.  */
  451.   function zen_draw_radio_field($name, $value = '', $checked = false, $parameters = '') {
  452.     return zen_draw_selection_field($name, 'radio', $value, $checked, $parameters);
  453.   }
  454.  
  455. /*
  456.  *  Output a form textarea field
  457.  */
  458.   function zen_draw_textarea_field($name, $width, $height, $text = '~*~*#', $parameters = '', $reinsert_value = true) {
  459.     $field = '<textarea name="' . zen_output_string($name) . '" cols="' . zen_output_string($width) . '" rows="' . zen_output_string($height) . '"';
  460.  
  461.     if (zen_not_null($parameters)) $field .= ' ' . $parameters;
  462.  
  463.     $field .= '>';
  464.  
  465.     if ($text == '~*~*#' && (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) && ($reinsert_value == true) ) {
  466.       $field .= stripslashes($GLOBALS[$name]);
  467.     } elseif ($text != '~*~*#' && zen_not_null($text)) {
  468.       $field .= $text;
  469.     }
  470.  
  471.     $field .= '</textarea>';
  472.  
  473.     return $field;
  474.   }
  475.  
  476. /*
  477.  *  Output a form hidden field
  478.  */
  479.   function zen_draw_hidden_field($name, $value = '', $parameters = '') {
  480.     $field = '<input type="hidden" name="' . zen_sanitize_string(zen_output_string($name)) . '"';
  481.  
  482.     if (zen_not_null($value)) {
  483.       $field .= ' value="' . zen_output_string($value) . '"';
  484.     } elseif (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) {
  485.       $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
  486.     }
  487.  
  488.     if (zen_not_null($parameters)) $field .= ' ' . $parameters;
  489.  
  490.     $field .= ' />';
  491.  
  492.     return $field;
  493.   }
  494.  
  495. /*
  496.  * Output a form file-field
  497.  */
  498.   function zen_draw_file_field($name, $required = false) {
  499.     $field = zen_draw_input_field($name, '', ' size="50" ', 'file');
  500.  
  501.     return $field;
  502.   }
  503.  
  504.  
  505. /*
  506.  *  Hide form elements while including session id info
  507.  *  IMPORTANT: This should be used in every FORM that has an OnSubmit() function tied to it, to prevent unexpected logouts
  508.  */
  509.   function zen_hide_session_id() {
  510.     global $session_started;
  511.  
  512.     if ( ($session_started == true) && defined('SID') && zen_not_null(SID) ) {
  513.       return zen_draw_hidden_field(zen_session_name(), zen_session_id());
  514.     }
  515.   }
  516.  
  517. /*
  518.  *  Output a form pull down menu
  519.  *  Pulls values from a passed array, with the indicated option pre-selected
  520.  */
  521.   function zen_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
  522.     $field = '<select name="' . zen_output_string($name) . '"';
  523.  
  524.     if (zen_not_null($parameters)) $field .= ' ' . $parameters;
  525.  
  526.     $field .= '>' . "\n";
  527.  
  528.     if (empty($default) && isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) ) $default = stripslashes($GLOBALS[$name]);
  529.  
  530.     for ($i=0, $n=sizeof($values); $i<$n; $i++) {
  531.       $field .= '  <option value="' . zen_output_string($values[$i]['id']) . '"';
  532.       if ($default == $values[$i]['id']) {
  533.         $field .= ' selected="selected"';
  534.       }
  535.  
  536.       $field .= '>' . zen_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;')) . '</option>' . "\n";
  537.     }
  538.     $field .= '</select>' . "\n";
  539.  
  540.     if ($required == true) $field .= TEXT_FIELD_REQUIRED;
  541.  
  542.     return $field;
  543.   }
  544.  
  545. /*
  546.  * Creates a pull-down list of countries
  547.  */
  548.   function zen_get_country_list($name, $selected = '', $parameters = '') {
  549.     $countriesAtTopOfList = array();
  550.     $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
  551.     $countries = zen_get_countries();
  552.  
  553.     // Set some default entries at top of list:
  554.     if (STORE_COUNTRY != SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY) $countriesAtTopOfList[] = SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY;
  555.     $countriesAtTopOfList[] = STORE_COUNTRY;
  556.     // IF YOU WANT TO ADD MORE DEFAULTS TO THE TOP OF THIS LIST, SIMPLY ENTER THEIR NUMBERS HERE.
  557.     // Duplicate more lines as needed
  558.     // Example: Canada is 108, so use 108 as shown:
  559.     //$countriesAtTopOfList[] = 108;
  560.  
  561.     //process array of top-of-list entries:
  562.     foreach ($countriesAtTopOfList as $key=>$val) {
  563.       $countries_array[] = array('id' => $val, 'text' => zen_get_country_name($val));
  564.     }
  565.     // now add anything not in the defaults list:
  566.     for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
  567.       $alreadyInList = FALSE;
  568.       foreach($countriesAtTopOfList as $key=>$val) {
  569.         if ($countries[$i]['countries_id'] == $val)
  570.         {
  571.           // If you don't want to exclude entries already at the top of the list, comment out this next line:
  572.           $alreadyInList = TRUE;
  573.           continue;
  574.         }
  575.       }
  576.       if (!$alreadyInList) $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
  577.     }
  578.  
  579.     return zen_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
  580.   }
  581. /*
  582.  * Assesses suitability for additional parameters such as rel=nofollow etc
  583.  */
  584.   function zen_href_params($page = '', $parameters = '') {
  585.     global $current_page_base;
  586.     $addparms = '';
  587.     // if nofollow has already been set, ignore this function
  588.     if (stristr($parameters, 'nofollow')) return $parameters;
  589.     // if list of skippable pages has been set in meta_tags.php lang file (is by default), use that to add rel=nofollow params
  590.     if (defined('ROBOTS_PAGES_TO_SKIP') && in_array($page, explode(",", constant('ROBOTS_PAGES_TO_SKIP')))
  591.         || $current_page_base=='down_for_maintenance') $addparms = 'rel="nofollow"';
  592.     return ($parameters == '' ? $addparms : $parameters . ' ' . $addparms);
  593.   }
  594. ?>