html_output.php

来自「全新且完善的强大网上商店系统」· PHP 代码 · 共 190 行

PHP
190
字号
<?php
/*
  [SOOBIC!] includes/html_output.php 

	Version: 1.5
	Author: Soolan (soolan@qq.com)
	Copyright: soolan (www.soobic.com)
	Last Modified: 2005/4/27 10:00

*/
function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
		global $request_type, $session_started, $SID;
    if (!tep_not_null($page)) {
         die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>');
    }
    if ($connection == 'NONSSL') {
        $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
    } elseif ($connection == 'SSL') {
        if (ENABLE_SSL == true) {
           $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
        } else {
           $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
        }
    } else {
        die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b><br><br>');
    }
    if (tep_not_null($parameters)) {
        $link .= $page . '?' . tep_output_string($parameters);
        $separator = '&';
    } else {
        $link .= $page;
        $separator = '?';
    }
    while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
    if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
        if (tep_not_null($SID)) {
            $_sid = $SID;
        } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
            if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {
                $_sid = tep_session_name() . '=' . tep_session_id();
            }
        }
    }
    if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
        while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);
        $link = str_replace('?', '/', $link);
        $link = str_replace('&', '/', $link);
        $link = str_replace('=', '/', $link);
        $separator = '?';
    }
    if (isset($_sid)) {
        $link .= $separator . $_sid;
    }
    return $link;
}

function tep_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') {
    $selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
    if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"';
    if ( ($checked == true) || ( isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ( ($GLOBALS[$name] == 'on') || (isset($value) && (stripslashes($GLOBALS[$name]) == $value)) ) ) ) {
        $selection .= ' CHECKED';
    }
    if (tep_not_null($parameters)) $selection .= ' ' . $parameters;
    $selection .= '>';
    return $selection;
}

function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {
    $field = '<textarea name="' . tep_output_string($name) . '" wrap="' . tep_output_string($wrap) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"';
    if (tep_not_null($parameters)) $field .= ' ' . $parameters;
    $field .= '>';
    if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {
        $field .= stripslashes($GLOBALS[$name]);
    } elseif (tep_not_null($text)) {
        $field .= $text;
    }
    $field .= '</textarea>';
    return $field;
}

function tep_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) {
    $field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
    if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {
      $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';
    } elseif (tep_not_null($value)) {
      $field .= ' value="' . tep_output_string($value) . '"';
    }
    if (tep_not_null($parameters)) $field .= ' ' . $parameters;
    $field .= '>';
    return $field;
}

function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
   if ( empty($src) && (IMAGE_REQUIRED == 'false') ) {
       return false;
   }
   if(CONFIG_CREATE_SMAILL_IMAGE!='True'){
       $src=eregi_replace('small_','',$src);
   }else{
       if(!@file_exists($src)){
           $src=eregi_replace(strrchr($src,'.'),'.jpg',$src);
       }
	 }
   $image = '<img src="'.$src.'" border="0" alt="'.$alt.'"';
   if (tep_not_null($alt)) {
      $image .= ' title=" '.$alt.'"';
   }
   if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) {
      if ($image_size = @getimagesize($src)) {
         if (empty($width) && tep_not_null($height)) {
            $ratio = $height / $image_size[1];
            $width = $image_size[0] * $ratio;
         } elseif (tep_not_null($width) && empty($height)) {
            $ratio = $width / $image_size[0];
            $height = $image_size[1] * $ratio;
         } elseif (empty($width) && empty($height)) {
            $width = $image_size[0];
            $height = $image_size[1];
         }
      } elseif (IMAGE_REQUIRED == 'false') {
         return false;
      }
   }
   if (tep_not_null($width) && tep_not_null($height)) {
      $image.= ' width="'.$width.'" height="'.$height.'"';
   }
   if (tep_not_null($parameters)) $image .= ' ' . $parameters;
   $image .= '>';
   return $image;
}

function tep_image_submit($image, $alt = '', $parameters = '') {
    global $language;
    $image_submit = '<input type="image" src="' . (IMGDIR.'/'.$language.'/'.$image) . '" border="0" alt="' . ($alt) . '"';
    if (tep_not_null($alt)) $image_submit .= ' title=" ' . ($alt) . ' "';
    if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters;
    $image_submit .= '>';
    return $image_submit;
}

function tep_image_button($image, $alt = '', $parameters = '') {
    global $language;
    return tep_image(IMGDIR.'/'.$language.'/'.$image, $alt, '', '', $parameters);
}

function tep_hide_session_id() {
    global $session_started, $SID;
    if (($session_started == true) && tep_not_null($SID)) {
        return '<input type="hidden" name="'.tep_session_name().'" value="'.tep_session_id().'">';
    }
}

function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
    $field = '<select name="' . tep_output_string($name) . '"';
    if (!empty($parameters)) $field .= ' ' . $parameters;
    $field .= '>';
    if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);
    for ($i=0, $n=sizeof($values); $i<$n; $i++) {
         $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
         if ($default == $values[$i]['id']) {
             $field .= ' SELECTED';
         } 
         $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;')) . '</option>';
    }
    $field .= '</select>';
    if ($required == true) $field .= TEXT_FIELD_REQUIRED;
    return $field;
}

function tep_get_country_list($name, $selected = '', $parameters = '') {
    $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
    $countries = tep_get_countries();
    for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
      $countries_array[] = array('id' => $countries[$i]['id'], 'text' => $countries[$i]['text']);
    }
    return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
}

function navgation($title=NAVBAR_TITLE,$title_1=NAVBAR_TITLE_1,$title_2=NAVBAR_TITLE_2,$title_3=NAVBAR_TITLE_3,$title_4=NAVBAR_TITLE_4) {
   $title_s=(tep_not_null($title)&& $title!= 'NAVBAR_TITLE') ? '--'.$title : '';
   $title_s.=(tep_not_null($title_1)&& $title_1!= 'NAVBAR_TITLE_1') ? '--'.$title_1 : '';
   $title_s.=(tep_not_null($title_2)&& $title_2!= 'NAVBAR_TITLE_2') ? '--'.$title_2 : '';
   $title_s.=(tep_not_null($title_3)&& $title_3!= 'NAVBAR_TITLE_3') ? '--'.$title_3 : '';
   $title_s.=(tep_not_null($title_4)&& $title_4!= 'NAVBAR_TITLE_4') ? '--'.$title_4 : '';
	 return ($title_s);
}


?>

⌨️ 快捷键说明

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