pat_path_wrapper.php
Upload User: feiyaoda
Upload Date: 2016-11-21
Package Size: 9556k
Code Size: 4k
Category:

WEB Mail

Development Platform:

PHP

  1. <?php
  2. /*
  3.  *  a basic wrapper for paths
  4.  *
  5.  *  note that keywords 
  6.  *
  7.  *
  8.  *
  9.  *
  10.  *
  11.  *
  12.  */
  13. class path_wrapper
  14. {
  15.    
  16.     var $delimiter_begin = '{';
  17.     
  18.     var $delimiter_end   = '}';
  19.     function create_date_wrapper_array($time)
  20.     {
  21.         if (0 == $time) $time = time();
  22.         
  23.         if ($time == $this->latest_date_export) return true;
  24.         
  25.         $this->latest_date_export = $time;
  26.         
  27.         $this->date_wrapper['da'] = date('a',$time); // "am" or "pm" 
  28.         $this->date_wrapper['dA'] = date('A',$time); // "AM" or "PM" 
  29.         $this->date_wrapper['dB'] = date('B',$time); // Swatch Internet time 
  30.         $this->date_wrapper['dd'] = date('d',$time); // day of the month, 2 digits with leading zeros; i.e. "01" to "31" 
  31.         $this->date_wrapper['dD'] = date('D',$time); // day of the week, textual, 3 letters; e.g. "Fri" 
  32.         $this->date_wrapper['dF'] = date('F',$time); // month, textual, long; e.g. "January" 
  33.         $this->date_wrapper['dg'] = date('g',$time); // hour, 12-hour format without leading zeros; i.e. "1" to "12" 
  34.         $this->date_wrapper['dG'] = date('G',$time); // hour, 24-hour format without leading zeros; i.e. "0" to "23" 
  35.         $this->date_wrapper['dh'] = date('h',$time); // hour, 12-hour format; i.e. "01" to "12" 
  36.         $this->date_wrapper['dH'] = date('H',$time); // hour, 24-hour format; i.e. "00" to "23" 
  37.         $this->date_wrapper['di'] = date('i',$time); // minutes; i.e. "00" to "59" 
  38.         $this->date_wrapper['dI'] = date('I',$time); // (capital i) - "1" if Daylight Savings Time, "0" otherwise. 
  39.         $this->date_wrapper['dj'] = date('j',$time); // day of the month without leading zeros; i.e. "1" to "31" 
  40.         $this->date_wrapper['dl'] = date('l',$time); // (lowercase 'L') - day of the week, textual, long; e.g. "Friday" 
  41.         $this->date_wrapper['dL'] = date('L',$time); // boolean for whether it is a leap year; i.e. "0" or "1" 
  42.         $this->date_wrapper['dm'] = date('m',$time); // month; i.e. "01" to "12" 
  43.         $this->date_wrapper['dM'] = date('M',$time); // month, textual, 3 letters; e.g. "Jan" 
  44.         $this->date_wrapper['dn'] = date('n',$time); // month without leading zeros; i.e. "1" to "12" 
  45.         $this->date_wrapper['dO'] = date('O',$time); // Difference to Greenwich time in hours; e.g. "+0200" 
  46.         $this->date_wrapper['dr'] = date('r',$time); // RFC 822 formatted date; e.g. "Thu, 21 Dec 2000 16:01:07 +0200" (added in PHP 4.0.4) 
  47.         $this->date_wrapper['ds'] = date('s',$time); // seconds; i.e. "00" to "59" 
  48.         $this->date_wrapper['dS'] = date('S',$time); // English ordinal suffix for the day of the month, 2 characters; i.e. "st", "nd", "rd" or "th" 
  49.         $this->date_wrapper['dt'] = date('t',$time); // number of days in the given month; i.e. "28" to "31" 
  50.         $this->date_wrapper['dT'] = date('T',$time); // Timezone setting of this machine; e.g. "EST" or "MDT" 
  51.         $this->date_wrapper['dU'] = date('U',$time); // seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) 
  52.         $this->date_wrapper['dw'] = date('w',$time); // day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday) 
  53.         $this->date_wrapper['dW'] = date('W',$time); // ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) 
  54.         $this->date_wrapper['dY'] = date('Y',$time); // year, 4 digits; e.g. "1999" 
  55.         $this->date_wrapper['dy'] = date('y',$time); // year, 2 digits; e.g. "99" 
  56.         $this->date_wrapper['dz'] = date('z',$time); // day of the year; i.e. "0" to "365" 
  57.         $this->date_wrapper['dZ'] = date('Z',$time); // timezone offset in seconds (i.e. "-43200" to "43200"). The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. 
  58.         
  59.         return true;
  60.     }
  61.     
  62.     function ($path2wrap,$wrappers,$specifictime=0)
  63.     {
  64.         $this->create_date_wrapper_array($specifictime);
  65.         
  66.         // we merge the two arrays we need to wrap
  67.         $_int_wrappers = array_merge($wrappers,$this->date_wrapper);
  68.         
  69.         // for each keyword in wrapper, we substitue it's value
  70.         foreach ($wrappers as $key => $value)
  71.         {
  72.             $str2search = $this->delimiter_begin.$key.$this->delimiter_end;
  73.             $path2wrap = str_replace ($str2search,$value,$path2wrap);
  74.         } 
  75.     }
  76. }