[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文件
文件大小: 22.73 KiB
MD5: f299f5b05ff60778ee44c8a06198633d

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