Definition in file helpers.php.
Go to the source code of this file.
Functions | |
| email ($doc, $email) | |
| Makes the email robots unreadable. | |
| generate_password (&$passw, &$md5passw, $len=5) | |
| Generates simple random password. | |
| go_to ($relative_url) | |
| Redirects browser using 302 HTTP response code and Location header to some new page. | |
| html ($str) | |
| Shortcut for htmlspecialchars($str, ENT_QUOTES);. | |
| lg ($msg) | |
| Logs message into the log.txt file. | |
| link2aXML ($doc, $text) | |
| It recognises URLs which begins with http://, https:// or ftp:// and converts them into <a href=> elements. | |
| make_absolute_url ($relative_url) | |
| Tries to make absolute URL from relative one. | |
| nl2br_and_link2a_XML ($doc, $text) | |
| Combinates nl2brXML() and link2aXML(). | |
| nl2brXML ($doc, $text) | |
| This function is identical to nl2br except that it returns an array of DOMNode instances instead of plain HTML code (it also removes \n unlike original nl2br). | |
| starts_with ($what, $where) | |
| Java startsWith equivalent. | |
| url ($str) | |
| Shortcut for urlencode($str);. | |
| urlfile_exists ($url) | |
| Tests if given URL exists. | |
|
||||||||||||
|
Makes the email robots unreadable. Expects that there exists at.gif and dot.gif files.
Definition at line 93 of file helpers.php. References xml_convert_str2elem(). 00093 {
00094 // make some space around images
00095 $email = str_replace('@', ' @ ', str_replace('.', ' . ', $email));
00096 return xml_convert_str2elem($doc,
00097 xml_convert_str2elem($doc, $email, '@', new AtElementCreator),
00098 '.', new DotElementCreator);
00099 }
|
|
||||||||||||||||
|
Generates simple random password. It will consists only of letters a-z (to not be error-prone). Use this if user forgets its password.
Definition at line 210 of file helpers.php. 00210 {
00211 for ($i = 0; $i < $len; $i++):
00212 $passw .= chr(rand(97, 122));
00213 endfor;
00214 $md5passw = md5($passw);
00215 }
|
|
|
Redirects browser using 302 HTTP response code and Location header to some new page. Stops execution of the PHP script. Definition at line 184 of file helpers.php. 00184 {
00185 header("Location: http://" . make_absolute_url($relative_url));
00186 exit;
00187 }
|
|
|
Shortcut for htmlspecialchars($str, ENT_QUOTES);.
Definition at line 47 of file helpers.php. 00047 {
00048 return htmlspecialchars($str, ENT_QUOTES);
00049 }
|
|
|
Logs message into the log.txt file. Make sure that script has write access to the file. Definition at line 37 of file helpers.php. 00037 {
00038 $f = fopen('log.txt', 'a');
00039 fwrite($f, $msg . "\n");
00040 fclose($f);
00041 }
|
|
||||||||||||
|
It recognises URLs which begins with http://, https:// or ftp:// and converts them into <a href=> elements.
Definition at line 151 of file helpers.php. References xml_convert_regex2elem(). 00151 {
00152 return xml_convert_regex2elem($doc, $text, '#((?:http|https|ftp)://\S+)#i', new LinkElementCreator);
00153 }
|
|
|
Tries to make absolute URL from relative one.
Definition at line 167 of file helpers.php. 00167 {
00168 $dir = dirname($_SERVER['PHP_SELF']);
00169 if ($dir == '\\'):
00170 $dir = '';
00171 endif;
00172 if ($relative_url == '') $relative_url = 'index.php';
00173 if (strlen($dir) == 0 or $dir[strlen($dir) - 1] != '/'):
00174 $dir .= '/';
00175 endif;
00176 return $_SERVER['HTTP_HOST'] . $dir . $relative_url;
00177 }
|
|
||||||||||||
|
Combinates nl2brXML() and link2aXML().
Definition at line 158 of file helpers.php.
|
|
||||||||||||
|
This function is identical to nl2br except that it returns an array of DOMNode instances instead of plain HTML code (it also removes \n unlike original nl2br). You can use it like this -- PHP side: $doc = new DOMDocument(); ... $some_elem = $doc->createElement('someElem'); ... $coverted = nl2brXML($doc, $some_string); foreach($converted as $node): $some_elem->appendChild($node); endforeach; <xsl:copy-of select='someElem'/>
Definition at line 125 of file helpers.php. References xml_convert_str2elem(). 00125 {
00126 return xml_convert_str2elem($doc, $text, "\n", 'br');
00127 }
|
|
||||||||||||
|
Java startsWith equivalent.
Definition at line 196 of file helpers.php. Referenced by Servlet::get_referer(). 00196 {
00197 if (strpos($where, $what) === 0):
00198 return TRUE;
00199 endif;
00200 return FALSE;
00201 }
|
|
|
Shortcut for urlencode($str);.
Definition at line 54 of file helpers.php. Referenced by Servlet::show(). 00054 {
00055 return urlencode($str);
00056 }
|
|
|
Tests if given URL exists.
Definition at line 221 of file helpers.php. 00221 {
00222 $handle = @fopen($url, 'r');
00223 if (!$handle):
00224 return FALSE;
00225 endif;
00226 fclose($handle);
00227 return TRUE;
00228 }
|
1.4.2