Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Saturday, November 14, 2026

Diff for Metafox/lib/phpWebFileManager/functions.inc.php between version 1.1 and 1.2

version 1.1, 2005/06/05 12:15:15 version 1.2, 2005/10/01 23:59:39
Line 7 
Line 7 
  * ____________________________________________________________   * ____________________________________________________________
  *   *
  * Developed by Ondrej Jombik <nepto@platon.sk>   * Developed by Ondrej Jombik <nepto@platon.sk>
  * Copyright (c) 2001-2003 Platon SDG, http://platon.sk/   * Copyright (c) 2001-2005 Platon Group, http://platon.sk/
  * All rights reserved.   * All rights reserved.
  *   *
  * See README file for more information about this software.   * See README file for more information about this software.
Line 17 
Line 17 
  * http://platon.sk/projects/phpWebFileManager/   * http://platon.sk/projects/phpWebFileManager/
  */   */
   
 /* $Platon: phpWebFileManager/functions.inc.php,v 1.3 2003/11/20 14:07:26 nepto Exp $ */  /* $Platon: phpWebFileManager/functions.inc.php,v 1.8 2005/10/01 17:17:34 nepto Exp $ */
   
 /* Functions in this file was extracted created from Platon class.  /* Functions in this file was extracted created from Platon class.
   
    Class Platon is part of Platon SDG PHP framework and can be accessible via     Class Platon is part of Platon SDG PHP framework and can be accessible via
    phpPlatonLib project. */     phpPlatonLib project. */
   
Line 33 
Line 33 
  */   */
 function fm_get_cgi_var($name, $default_value = null) /* {{{ */  function fm_get_cgi_var($name, $default_value = null) /* {{{ */
 {  {
         global $HTTP_GET_VARS;      static $magic_quotes_gpc = null;
         $var = @$HTTP_GET_VARS[$name];      if ($magic_quotes_gpc === null) {
         if (! isset($var)) {          $magic_quotes_gpc = get_magic_quotes_gpc();
                 global $HTTP_POST_VARS;      }
                 $var = @$HTTP_POST_VARS[$name];      $var = @$_GET[$name];
         }      if (! isset($var)) {
         if (isset($var)) {          $var = @$_POST[$name];
                 if (is_array($var)) {      }
                         foreach (array_keys($var) as $key) {      if (isset($var)) {
                                 $var[$key] = stripslashes($var[$key]);          if ($magic_quotes_gpc) {
                         }              if (is_array($var)) {
                 } else {                  foreach (array_keys($var) as $key) {
                         $var = stripslashes($var);                      $var[$key] = stripslashes($var[$key]);
                 }                  }
         } else {              } else {
                 $var = @$default_value;                  $var = stripslashes($var);
         }              }
         return $var;          }
       } else {
           $var = @$default_value;
       }
       return $var;
 } /* }}} */  } /* }}} */
   
 /**  /**
  * Returns original variables HTML code for use in forms or links.   * Returns original variables HTML code for use in forms or links.
  *   *
  * @param   mixed   $origvars       string or array of original varaibles   * @param   mixed   $origvars  string or array of original variables;
  * @param   string  $method         type of method ("POST" or "GET")   *                             if string values should be rawurlencoded();
  * @param   mixed   $default_value  default value of variables   *                             if array values should not be encoded
  *                                  if null, empty values will be skipped   * @param   string  $method    type of method ("POST" or "GET")
  * @return                          get HTML code of original varaibles   * @param   mixed   $default   default value of variables
    *                             if null, empty values will be skipped
    * @return                     get HTML code of original variables
  */   */
 function fm_get_origvars_html($origvars, $method = 'POST', $default_value = '') /* {{{ */  function fm_get_origvars_html($origvars, $method = 'POST', $default = '') /* {{{ */
 {  {
         $ret    = '';      $ret    = '';
         $method = strtoupper($method);      $method = strtoupper($method);
         if ($method == 'POST') {      if ($method == 'POST') {
                 if (! is_array($origvars)) {          if (! is_array($origvars)) {
             $new_origvars = array();              $new_origvars = array();
                         foreach (explode('&', $origvars) as $param) {              foreach (explode('&', $origvars) as $param) {
                                 $parts = explode('=', $param, 2);                  $parts = explode('=', $param, 2);
                                 if (! isset($parts[1])) {                  if (! isset($parts[1])) {
                                         $parts[1] = $default_value;                      $parts[1] = $default;
                                 }                  }
                                 if (strlen($parts[0]) <= 0) {                  if (strlen($parts[0]) <= 0) {
                                         continue;                      continue;
                                 }                  }
                                 $new_origvars[$parts[0]] = $parts[1];                  $new_origvars[$parts[0]] = $parts[1];
                         }              }
             $origvars =& $new_origvars;              $origvars =& $new_origvars;
                 }          }
                 foreach ($origvars as $key => $val) {          foreach ($origvars as $key => $val) {
                         if (strlen($val) <= 0 && $default_value === null) {              if (strlen($val) <= 0 && $default === null) {
                                 continue;                  continue;
                         }              }
                         $key = rawurldecode($key);              $key = rawurldecode($key);
                         $val = rawurldecode($val);              $val = rawurldecode($val);
                         $ret .= '<input type="hidden" name="';              $ret .= '<input type="hidden" name="';
                         $ret .= htmlspecialchars($key).'"';              $ret .= htmlspecialchars($key).'"';
                         $ret .= ' value="'.htmlspecialchars($val).'"';              $ret .= ' value="'.htmlspecialchars($val).'"';
                         $ret .= " />\n";              $ret .= " />\n";
                 }          }
         } else if (! strncmp('GET', $method, 3)) {      } else if (! strncmp('GET', $method, 3)) {
                 if (! is_array($origvars)) {          if (! is_array($origvars)) {
                         $ret .= $origvars;              $ret .= $origvars;
                 } else {          } else {
                         foreach ($origvars as $key => $val) {              foreach ($origvars as $key => $val) {
                                 if (strlen($val) <= 0 && $default_value === null) {                  if (strlen($val) <= 0 && $default === null) {
                                         continue;                      continue;
                                 }                  }
                                 $ret == '' || $ret .= '&amp;';                  $ret == '' || $ret .= '&amp;';
                                 $ret .= htmlspecialchars(rawurlencode($key));                  $ret .= htmlspecialchars(rawurlencode($key));
                                 $ret .= '=';                  $ret .= '=';
                                 $ret .= htmlspecialchars(rawurlencode($val));                  $ret .= htmlspecialchars(rawurlencode($val));
                         }              }
                 }          }
                 if ($method[strlen($method) - 1] == '+') {          if ($method[strlen($method) - 1] == '+') {
                         $ret = "?$ret";              $ret = "?$ret";
                 }          }
         } else {      } else {
                 trigger_error('Unsupported Platon::get_origvars_html() method: '          trigger_error('Unsupported Platon::get_origvars_html() method: '
                                 .$method, E_USER_ERROR);                  .$method, E_USER_ERROR);
         }      }
         return $ret;      return $ret;
 } /* }}} */  } /* }}} */
   
 /**  /**
Line 126  function fm_get_origvars_html($origvars,
Line 132  function fm_get_origvars_html($origvars,
  */   */
 function fm_append_slash($string, $char = '/') /* {{{ */  function fm_append_slash($string, $char = '/') /* {{{ */
 {  {
         if (! is_string($string) || ! is_string($char)) {      if (! is_string($string) || ! is_string($char)) {
                 return false;          return false;
         }      }
         if (strlen($string) > 0) {      if (strlen($string) > 0) {
                 if ($string[strlen($string) - 1] != $char[0])          if ($string[strlen($string) - 1] != $char[0])
                         $string .= $char[0];              $string .= $char[0];
         }      }
         return $string;      return $string;
 } /* }}} */  } /* }}} */
   
 /**  /**
Line 145  function fm_append_slash($string, $char
Line 151  function fm_append_slash($string, $char
  */   */
 function fm_get_path_without_scriptname($url) /* {{{ */  function fm_get_path_without_scriptname($url) /* {{{ */
 {  {
         $path = is_array($url) ? $url['path'] : $url;      $path = is_array($url) ? $url['path'] : $url;
         $path = preg_replace('/http[s]?:\/\/[^\/]+/', '', $path);      $path = preg_replace('/http[s]?:\/\/[^\/]+/', '', $path);
         $path = preg_replace('/\?.*/', '', $path);      $path = preg_replace('/\?.*/', '', $path);
         $path = preg_replace('/[^\/]+\z/', '', $path);      $path = preg_replace('/[^\/]+\z/', '', $path);
         return $path;      return $path;
 } /* }}} */  } /* }}} */
   
 /**  /**
Line 163  function fm_get_path_without_scriptname(
Line 169  function fm_get_path_without_scriptname(
  */   */
 function fm_glue_url($url) /* {{{ */  function fm_glue_url($url) /* {{{ */
 {  {
         if (! is_array($url))      if (! is_array($url))
                 return false;          return false;
         // scheme      // scheme
         $uri = empty($url['scheme']) ? '' : $url['scheme'] . '://';      $uri = empty($url['scheme']) ? '' : $url['scheme'] . '://';
         // user and pass      // user and pass
         if (! empty($url['user'])) {      if (! empty($url['user'])) {
                 $uri .= $url['user'].':'.$url['pass'].'@';          $uri .= $url['user'].':'.$url['pass'].'@';
         }      }
         // host      // host
         $uri .= $url['host'];      $uri .= $url['host'];
         // port      // port
         $port = empty($url['port']) ? '' : ':'.$url['port'];      $port = empty($url['port']) ? '' : ':'.$url['port'];
         $uri .= $port;      $uri .= $port;
         // path      // path
         $uri .= $url['path'];      $uri .= $url['path'];
         // fragment or query      // fragment or query
         if (isset($url['fragment'])) {      if (isset($url['fragment'])) {
                 $uri .= '#' . $url['fragment'];          $uri .= '#' . $url['fragment'];
         }      }
         elseif (isset($url['query'])) {      elseif (isset($url['query'])) {
                 $uri .= '?' . $url['query'];          $uri .= '?' . $url['query'];
         }      }
         return $uri;      return $uri;
 } /* }}} */  } /* }}} */
   
 /* vim: set expandtab tabstop=4 shiftwidth=4:  /* vim: set expandtab tabstop=4 shiftwidth=4:

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top