Zikula_Core
[ class tree: Zikula_Core ] [ index: Zikula_Core ] [ all elements ]

Source for file legacy.php

Documentation is available at legacy.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2001, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: legacy.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_Core
  10.  * @subpackage Zikula_legacy
  11.  */
  12. global $pnconfig;
  13. $pnconfig['nukeurl'pnGetBaseURI();
  14. global $mainfile;
  15. $mainfile 1;
  16.  
  17.  
  18. /**
  19.  * Delete quotes in a string
  20. */
  21. function delQuotes($string)
  22. {
  23.     // No recursive function to add quote to an HTML tag if needed
  24.     // and delete duplicate spaces between attribs.
  25.     $tmp ""// string buffer
  26.     $result ""// result string
  27.     $i 0;
  28.     $attrib = -1// Are us in an HTML attrib ?   -1: no attrib   0: name of the attrib   1: value of the atrib
  29.     $quote 0// Is a string quote delimited opened ? 0=no, 1=yes
  30.     $len strlen($string);
  31.     while ($i $len{
  32.         switch ($string[$i]// What car is it in the buffer ?
  33.             case "\""// "       // a quote.
  34.                 if ($quote == 0{
  35.                     $quote 1;
  36.                 else {
  37.                     $quote 0;
  38.                     if (($attrib 0&& ($tmp != "")) {
  39.                         $result .= "=\"$tmp\"";
  40.                     }
  41.                     $tmp "";
  42.                     $attrib = -1;
  43.                 }
  44.                 break;
  45.             case "="// an equal - attrib delimiter
  46.                 if ($quote == 0// Is it found in a string ?
  47.                     $attrib 1;
  48.                     if ($tmp != ""{
  49.                         $result .= " $tmp";
  50.                     }
  51.                     $tmp "";
  52.                 else $tmp .= '=';
  53.                 break;
  54.             case " "// a blank ?
  55.                 if ($attrib 0// add it to the string, if one opened.
  56.                     $tmp .= $string[$i];
  57.                 }
  58.                 break;
  59.             default// Other
  60.                 if ($attrib 0// If we weren't in an attrib, set attrib to 0= 0;
  61.                 }
  62.                 $tmp .= $string[$i];
  63.                 break;
  64.         }
  65.         $i++;
  66.     }
  67.     if (($quote != 0&& ($tmp != "")) {
  68.         if ($attrib == 1{
  69.             $result .= "=";
  70.         }
  71.         /**
  72.          * If it is the value of an atrib, add the '='
  73.          */
  74.         $result .= "\"$tmp\"";
  75.         /**
  76.          * Add quote if needed (the reason of the function ;-)
  77.          */
  78.     }
  79.     return $result;
  80. }
  81.  
  82.  
  83. /**
  84.  * Fixes quoting on a string
  85.  *
  86.  * This function replaces all single single quotes with double single quotes
  87.  * (' becomes '') and all occurrences of \' with '.
  88.  *
  89.  * @param  $what string The string to be fixed
  90.  * @return string The fixed string
  91.  * @author ?
  92.  */
  93. function FixQuotes ($what "")
  94. {
  95.     $what ereg_replace("'""''"$what);
  96.     while (eregi("\\\\'"$what)) {
  97.         $what ereg_replace("\\\\'""'"$what);
  98.     }
  99.     return $what;
  100. }
  101.  
  102.  
  103. /**
  104.  * Checks allowed HTML in a string
  105.  */
  106. function check_html ($str$strip '')
  107. {
  108.     // The core of this code has been lifted from phpslash
  109.     // which is licenced under the GPL.
  110.     $AllowableHTML pnConfigGetVar('AllowableHTML');
  111.  
  112.     if ($strip == "nohtml"{
  113.         $AllowableHTML array('');
  114.     }
  115.     $str stripslashes($str);
  116.     $str eregi_replace("<[[:space:]]*([^>]*)[[:space:]]*>",
  117.         '<\\1>'$str);
  118.     // Delete all spaces from html tags .
  119.     $str eregi_replace("<a[^>]*href[[:space:]]*=[[:space:]]*\"?[[:space:]]*([^\" >]*)[[:space:]]*\"?[^>]*>",
  120.         '<a href="\\1">'$str)// "
  121.     // Delete all attribs from Anchor, except an href, double quoted.
  122.     $tmp "";
  123.     while (ereg("<(/?[[:alpha:]]*)[[:space:]]*([^>]*)>"$str$reg)) {
  124.         $i strpos($str$reg[0]);
  125.         $l strlen($reg[0]);
  126.         if ($reg[1][0== "/"{
  127.             $tag strtolower(substr($reg[1]1));
  128.         else {
  129.             $tag strtolower($reg[1]);
  130.         }
  131.         if (isset($AllowableHTML[$tag])) {
  132.             if ($a $AllowableHTML[$tag]{
  133.                 if ($reg[1][0== "/"{
  134.                     $tag "</$tag>";
  135.                 elseif (($a == 1|| ($reg[2== "")) {
  136.                     $tag "<$tag>";
  137.                 else {
  138.                     // Place here the double quote fix function.
  139.                     $attrb_list delQuotes($reg[2]);
  140.                     $tag "<$tag$attrb_list ">";
  141.                 // Attribs in tag allowed
  142.             }
  143.         else {
  144.             $tag "";
  145.         }
  146.         $tmp .= substr($str0$i$tag;
  147.         $str substr($str$i $l);
  148.     }
  149.     $str $tmp $str;
  150.     return $str;
  151.     pnShutDown();
  152.     // Squash PHP tags unconditionally
  153.     $str ereg_replace("<\?"""$str);
  154.     return $str;
  155. }
  156.  
  157.  
  158. /**
  159.  * Filter text through both censor and allowed HTML
  160.  */
  161. function filter_text($Message$strip "")
  162. {
  163.     global $EditedMessage;
  164.     check_words($Message);
  165.     $EditedMessage check_html($EditedMessage$strip);
  166.     return ($EditedMessage);
  167. }
  168.  
  169.  
  170. /**
  171.  * formatting stories
  172.  */
  173. function formatTimestamp($time)
  174. {
  175.     global $datetime;
  176.  
  177.     setlocale (LC_TIMEpnConfigGetVar('locale'));
  178.     // Below ereg commented out 07-08-2001:Alarion - less strict ereg thanks to "Joe"
  179.     // ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
  180.     ereg ("([0-9]+)-([0-9]+)-([0-9]+) ([0-9]+):([0-9]+):([0-9]+)"$time$datetime);
  181.     // 07-07-2001:Alarion - For the time being, I added an ereg_replace to strip out
  182.     // the timezone until I get a function in to replace the server timezone with the users timezone
  183.     $datetime strftime("" ereg_replace("%Z"""_DATESTRING""mktime($datetime[4]$datetime[5]$datetime[6]$datetime[2]$datetime[3]$datetime[1]));
  184.     $datetime ucfirst($datetime);
  185.     return($datetime);
  186. }
  187.  
  188.  
  189. /**
  190.  * include_once replacement
  191.  *
  192.  * Works basicly like include_once() (except not
  193.  * include() aware, I'm not sure what array name
  194.  * they use). Needed for older PHP4 installs.
  195.  *
  196.  * @param  $f string The file/path to include
  197.  * @return false if file was already included. true if first include
  198.  * @author Patrick Kellum <webmaster@ctarl-ctarl.com>
  199.  * @ignore
  200.  */
  201. if (!function_exists('pninclude_once')) {
  202.     function pninclude_once($f)
  203.     {
  204.         Loader::includeOnce($f);
  205.         return true;
  206.     }
  207. }
  208.  
  209.  
  210. /**
  211.  * Check string for censored words
  212.  */
  213. function check_words($message)
  214. {
  215.     global $EditedMessage;
  216.  
  217.     $EditedMessage DataUtil::censor($message);
  218.  
  219.     return ($EditedMessage);
  220. }
  221.  
  222.  
  223. /**
  224.  * cross site scripting check
  225.  */
  226. function csssafe($checkArg "op"$checkReferer true)
  227. {
  228.     return true;
  229. }
  230.  
  231.  
  232. /**
  233.  * Create basic text form
  234.  */
  235. function myTextForm($url $value $useTable false $extraname "postnuke")
  236. {
  237.     $form '<form action="'.$url.'" method="post">'."\n";
  238.     if ($useTable{
  239.         $form .= '<table border="0" width="100%" align="center"><tr><td>'."\n";
  240.     }
  241.     $form .= '<input type="submit" value="'.$value.'" class="pn-normal" style="text-align:center">';
  242.     $form .= '<input type="hidden" name="'.$extraname.'" value="'.$extraname.'"></form>'."\n";
  243.     if ($useTable{
  244.         $form .= '</td></tr></table>'."\n";
  245.     }
  246.     return $form;
  247. }
  248.  
  249.  
  250. /**
  251.  *  Error message due a ADODB SQL error and die
  252.  */
  253. function PN_DBMsgError($db='',$prg='',$line=0,$message='Error Accesing the Database')
  254. {
  255.  
  256.     /*
  257.     * simplied version of initial fix supplied by Neo
  258.     * original fix by markwest
  259.     */
  260.     $docroot getcwd();
  261.     $docroot str_replace'includes'""$docroot );
  262.  
  263.     $prg str_replace('\\''/'$prg);
  264.     $prgoutput str_replace($docroot'[webroot]'$prg);
  265.  
  266.     if (SecurityUtil::checkPermission("::"'::'ACCESS_ADMIN)) {
  267.         $lcmessage $message "<br>" .
  268.                      "Program: " $prgoutput " - " "Line N.: " $line "<br>" .
  269.                      "Database: " $db->database "<br> ";
  270.  
  271.         if ($db->ErrorNo()<>0{
  272.             $lcmessage .= "Error (" $db->ErrorNo(") : " $db->ErrorMsg("<br>";
  273.         }
  274.     else {
  275.         $lcmessage $message "<br>" ."Program: " $prgoutput " - " "Line N.: " $line "<br>";
  276.  
  277.         if ($db->ErrorNo()<>0{
  278.             $lcmessage .= "Error (" $db->ErrorNo(") : " $db->ErrorMsg("<br>";
  279.         }
  280.     }
  281.     pnShutDown($lcmessage);
  282. }
  283.  
  284.  
  285. /**
  286.  * Timezone information
  287.  */
  288. /* spliffster - moved to _module_vars '/PNConfig' 'timezone_info' */
  289. // fixed notice error [class007]
  290. $tzinfo pnModGetVar(PN_CONFIG_MODULE'timezone_info');

Documentation generated on Fri, 18 Jul 2008 21:47:33 +0200 by phpDocumentor 1.4.1