/[health_html]/inc/global.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /inc/global.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by ravilov, Mon Aug 27 09:17:40 2001 UTC revision 1.9 by ravilov, Fri Sep 7 12:55:13 2001 UTC
# Line 1  Line 1 
1  <?php  <?php
2            function MyUpper($str) {
3                    return strtr(strtoupper($str), "¹ðèæ¾", "©ÐÈÆ®");
4            }
5    
6            function MyLower($str) {
7                    return strtr(strtolower($str), "©ÐÈÆ®", "¹ðèæ¾");
8            }
9    
10            function Letters() { return "ABCÈÆDÐEFGHIJKLMNOPQRS©TUVWXYZ®"; }
11    
12            function Slova($alpha_only = false) {
13                    $sl = preg_split('//', Letters());
14                    array_pop($sl); // The final element is empty.
15                    if (!$alpha_only) array_unshift($sl, "@");
16                    return $sl;
17            }
18    
19            function MyCompare($a, $b) {
20                    $slova = Letters();
21                    $weights = "\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32";
22                    return strcasecmp(strtr(MyUpper($a), $slova, $weights),
23                            strtr(MyUpper($b), $slova, $weights));
24            }
25    
26          function MyEscape($str) {          function MyEscape($str) {
27                  $allowed = array("", "B", "I", "U", "UL", "OL", "LI");                  return $str;
28                  $str = preg_replace("/(\<\/?\s*(\w+)>[^\>]*\>)/e",                  $allowed = array("", "A", "B", "I", "U", "UL", "OL", "LI");
29                          "array_search(strtoupper('\\2'),\$allowed,false)?'\\1':HTMLSpecialChars('\\1')",                  $str = preg_replace("/(^\\s+|\\s+$)/", "", $str);
30                          $str);                  $str = preg_replace("/(\\<\\/?\\s*(\\w+)\\b[^\\>]*\\>)/e", "array_search(MyUpper('\\2'),".
31                  $str = preg_replace("/(^\s+|\s+$)/", "", $str);                          "\$allowed,false)?'\\1':HTMLSpecialChars('\\1')", $str);
32                    $str = preg_replace("/(\\<\\s*[aA]\\b)/", '\\1 target=_blank class=more', $str);
33                  $str = ereg_replace("\"", "&quot;", $str);                  $str = ereg_replace("\"", "&quot;", $str);
34                  return $str;                  return $str;
35          }          }
36          function ParseNewline($str) {  
37            function ParseNewline($str, $paragraphs = false) {
38                  if (!$str) return $str;                  if (!$str) return $str;
39                  $str = preg_replace('/\s*(\r\n\r\n|\n\r\n\r|\n\n|\r\r)/m', '</p> <p class="ptext">', $str);                  if ($paragraphs) $str = preg_replace('/\s*(\r\n\r\n|\n\r\n\r|\n\n|\r\r)/m', ' </p><p class="ptext">', $str);
40                  $str = preg_replace('/\s*(\r\n|\n\r|\r|\n)/m', '<br>', $str);                  $str = ereg_replace("[ \t]*(\r\n?|\n\r?)", '<br>', $str);
41                  return $str;                  return $str;
42          }          }
43          function MyQuote($str) {  
                 global $dbh;  
                 if (!$dbh) return "'$str'";  
                 return $dbh->quote($str);  
         }  
         function MyMove($src, $dest) {  
                 $cmd = "mv -f '".EscapeShellCmd($src)."' '".EscapeShellCmd($dest)."'";  
                 return exec($cmd);  
         }  
         function MyDelete($src) {  
                 @unlink($src);  
         }  
44          function error($msg) {          function error($msg) {
45                  if (is_array($msg)) $msg = implode(" ", $msg);                  if (is_array($msg)) $msg = implode(" ", $msg);
46                  echo "<BR>\n<FONT COLOR=\"#FF0000\">[".HTMLSpecialChars($msg).                  echo "<BR>\n<FONT COLOR=\"#FF0000\">[".HTMLSpecialChars($msg)."]</FONT><BR>\n";
                         "]</FONT><BR>\n";  
47          }          }
48          function PicSize($pic) {  
49                  global $syspicdir;          function convert_html($str) {
50                  $ret = array(0, 0);                  $entities = array(
51                  if ($pic) {                          "nbsp" => " ", "#160" => " ",   # nbsp
52                          @$size = GetImageSize($syspicdir."/".$pic);                          "amp" => " ", "#38" => " ",     # amp
53                          $ret = array($size[0], $size[1]);                          "quot" => "\"", "#34" => "\"",  # quot
54                  }                          "lt" => "<", "#60" => "<",      # lt
55                  return $ret;                          "gt" => ">", "#62" => ">",      # gt
56                            "Scaron" => "©", "#352" => "©",
57                            "scaron" => "¹", "#353" => "¹",
58                            "Ccaron" => "È", "#268" => "È", "#268" => "È",
59                            "ccaron" => "è", "#232" => "è", "#269" => "è",
60                            "Cgrave" => "Æ", "#262" => "Æ", "#" => "Æ",
61                            "cgrave" => "æ", "#230" => "æ", "#263" => "æ",
62                            "???" => "Ð", "#272" => "Ð", "#" => "Ð",
63                            "???" => "ð", "#273" => "ð",
64                            "Zcaron" => "®", "#381" => "®",
65                            "zcaron" => "¾", "#382" => "¾",
66                    );
67                    $t = intval($str);
68                    # Skip if not a scalar
69                    if (!is_scalar($str)) return $str;
70                    # If a number, don't touch it
71                    if (strcmp(intval($str), $str) == 0) return $str;
72                    # Replace "<BR>" with "\n"
73                    $str = preg_replace("/\<BR\>/m", "\n", $str);
74                    # Replace "<...>\n" with "<...>"
75                    $str = preg_replace("/(\<[^\/][^\>]*\>)\s*(\r\n?|\n\r?)\s*/m", '$1', $str);
76                    # Replace "\n</...>" with "</...>\n"
77                    $str = preg_replace("/\s*(\r\n?|\n\r?)\s*(\<\/[^\>]+\>)/m", '$2$1', $str);
78                    # Remove "<HEAD>"/"</HEAD>", and anything in between.
79                    $str = preg_replace("/\<\s*HEAD[^\>]*\>.*\<\/\s*HEAD\s*\>(\r\n?|\n\r?)*/ims", '', $str);
80                    # Remove all "<HTML>", "<HEAD>", "<BODY>", "<FONT>", "<P>" and "BR" tags, along with their pairs
81                    $str = preg_replace("/\<\/?\s*(HTML|HEAD|BODY|FONT|P|BR)[^\>]*\>/im", '', $str);
82                    # Replace "\n<LI>" or "<LI>\n" with "<LI>"
83                    $str = preg_replace("/(\s*(\r\n?|\n\r?))*(\<\/\s*LI\s*\>)(\s*(\r\n?|\n\r?))*/m", '$3', $str);
84                    # Replace "<UL>\n" or "<OL>\n" with "<UL>" or "<OL>", respectively
85                    $str = preg_replace("/(\<\s*(UL|OL)\s*\>)(\s*(\r\n?|\n\r?))+/m", '$1', $str);
86                    # Replace "\n</UL>" or "\n</OL>" with "</UL>" or "</OL>", respectively
87                    $str = preg_replace("/(\s*(\r\n?|\n\r?))+(\<\/\s*(UL|OL)\s*\>)/m", '$3', $str);
88                    # Replace "``" and "''" with """ (a single double quote)
89                    $str = str_replace("“", '"', $str);
90                    $str = str_replace("”", '"', $str);
91                    # Replace "-" with "-"
92                    $str = str_replace("—", '-', $str);
93                    # Replace character references ("&...;" and "&#...;") with its value
94                    $str = preg_replace("/\&([^;]+);/em", '$entities["$1"]?$entities["$1"]:"?"', $str);
95                    # Remove all whitespace at beginning or ending of a line
96                    $str = preg_replace("/(^\s+|\s+$)/", '', $str);
97                    # Convert Win1250 to ISO8859-2
98                    $str = strtr($str, "ŠÐÈÆŽšðèæž", "©ÐÈÆ®¹ðèæ¾");
99                    return $str;
100          }          }
         $isEdit = stristr($PHP_SELF, "/edit/") ? true : false;  
         $isMed = false; /* */  
101  ?>  ?>

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.26