/[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.15 by ravilov, Tue Oct 2 16:18:09 2001 UTC revision 1.18 by ravilov, Fri Oct 12 09:22:02 2001 UTC
# Line 45  Line 45 
45                  return $str;                  return $str;
46          }          }
47    
48          function MyEscape($str, $full = true) {          function MyEscape($str, $full = false) {
49                    if ($full) {
50                            $str = str_replace("&", "&", $str);
51                            $str = str_replace("<", "&lt;", $str);
52                            $str = str_replace(">", "&gt;", $str);
53                    }
54                  $allowed = array("", "A", "B", "I", "U", "UL", "OL", "LI", "TABLE", "TR", "TH", "TD", "HR", "SUP", "SUB");                  $allowed = array("", "A", "B", "I", "U", "UL", "OL", "LI", "TABLE", "TR", "TH", "TD", "HR", "SUP", "SUB");
55                  $str = preg_replace('/(^[       ]+|[    ]+$)/m', '', $str);                  $str = preg_replace('/(^[       ]+|[    ]+$)/m', '', $str);
56                  $str = preg_replace('/(\<\/?\s*(\w+)\\b[^\>]*\>)/e', 'array_search(MyUpper("\2"),'.                  $str = preg_replace('/(\<\/?\s*(\w+)\\b[^\>]*\>)/e', 'array_search(MyUpper("\2"),'.
57                          '\$allowed,false)?"\1":HTMLSpecialChars("\1")', $str);                          '\$allowed,false)?"\1":HTMLSpecialChars("\1")', $str);
58                  $str = preg_replace('/(\<\s*A\b)/i', '\\1 target=_blank class=more', $str);                  if (!$full) {
59                  $str = preg_replace('/(\<\s*TABLE\b)/i', '\\1 class=normal', $str);                          $str = preg_replace('/(\<\s*TABLE\b)/i', '\\1 class=normal', $str);
60                  $str = preg_replace('/(class=[^         ]+)( class=[^   ]+)+/', '\\1', $str);                          $str = preg_replace('/(\<\s*A\b)/i', '\\1 class=underlined target=_blank', $str);
61                            $str = preg_replace('/(class=[^         ]+)( class=[^   ]+)+/', '\\1', $str);
62                            $str = preg_replace('/(class=[^         ]+ target=_blank)( class=[^     ]+ target=_blank)+/', '\\1', $str);
63                    }
64                  $str = my_replace($str, "<TABLE", "/TABLE>");                  $str = my_replace($str, "<TABLE", "/TABLE>");
65                  $str = my_replace($str, "<UL", "/UL>", true);                  $str = my_replace($str, "<UL", "/UL>", true);
66                  $str = my_replace($str, "<OL", "/OL>");                  $str = my_replace($str, "<OL", "/OL>");
# Line 98  Line 106 
106                  # If a number, don't touch it                  # If a number, don't touch it
107                  if (strcmp(intval($str)."", $str."") == 0) return $str;                  if (strcmp(intval($str)."", $str."") == 0) return $str;
108    
109                  # Replace "``" and "''" with """ (normal ASCII double quote)                  # Replace "``", "''", "<<" and ">>" with """ (normal ASCII double quote)
110                  $str = str_replace("“", '"', $str);                  $str = str_replace("“", '"', $str);
111                  $str = str_replace("”", '"', $str);                  $str = str_replace("”", '"', $str);
112                    $str = str_replace("¨", '"', $str);
113                    $str = str_replace("¯", '"', $str);
114                  # Replace "-" with "-"                  # Replace "-" with "-"
115                  $str = str_replace("—", '-', $str);                  $str = str_replace("—", '-', $str);
116                  # Replace character references ("&...;" and "&#...;") with its value                  # Replace character references ("&...;" and "&#...;") with its value
# Line 144  Line 154 
154                  return $str;                  return $str;
155          }          }
156    
157            function LinkIt($str) {
158                    $allowed = "ABCČčĘęDŠšEFGHIJKLMNOPQRS©¹TUVWXYZ®¾0123456789-_.";
159                    $idx = 0;
160                    while (true) {
161                            $idx = strpos($str, "@", $idx);
162                            if ($idx === false) break;
163                            $idx1 = $idx - 1;
164                            $idx2 = $idx + 1;
165                            while ($idx1 > 0 && stristr($allowed, $str[$idx1 - 1])) $idx1--;
166                            while ($idx2 < strlen($str) - 1 && stristr($allowed, $str[$idx2])) $idx2++;
167                            $str1 = substr($str, 0, $idx1);
168                            $str2 = substr($str, $idx1, $idx2 - $idx1);
169                            $str3 = substr($str, $idx2, strlen($idx2));
170                            $str4 = '<A HREF="mailto:'.$str2.'" CLASS="underlined">'.$str2.'</A>';
171                            $str = $str1.$str4.$str3;
172                            $idx = $idx1 + strlen($str4);
173                    }
174                    return $str;
175            }
176  ?>  ?>

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.26