Changeset 42 for trunk/lib/Utilities.inc.php
- Timestamp:
- Dec 18, 2005 12:16:03 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Utilities.inc.php
r41 r42 64 64 65 65 /** 66 * Returns text with appropriate html translations. 66 * Returns text with appropriate html translations. 67 67 * 68 68 * @param string $txt Text to clean. 69 * @param bool $preserve_html If set to true, oTxt will not translage <, >, ", or ' 69 * @param bool $preserve_html If set to true, oTxt will not translage <, >, ", or ' 70 70 * characters into HTML entities. This allows HTML to pass 71 71 * through unmunged. … … 85 85 $search['retain_left_angle'] = '/</'; 86 86 $replace['retain_left_angle'] = '<'; 87 87 88 88 $search['retain_right_angle'] = '/>/'; 89 89 $replace['retain_right_angle'] = '>'; 90 90 91 91 $search['retain_single_quote'] = '/'/'; 92 92 $replace['retain_single_quote'] = "'"; 93 93 94 94 $search['retain_double_quote'] = '/"/'; 95 95 $replace['retain_double_quote'] = '"'; … … 104 104 105 105 /** 106 * Returns text with stylistic modifications. 106 * Returns text with stylistic modifications. 107 107 * 108 108 * @param string $txt Text to clean. … … 125 125 $search['single_quotes'] = '/(^|[^\w=])(?:\'|'|‘)([^\']+?)(?:\'|'|’)([^\w]|$)/'; 126 126 $replace['single_quotes'] = '\\1‘\\2’\\3'; 127 127 128 128 // em--dashes become em—dashes 129 129 $search['em_dash'] = '/(\s*[^!<-])--([^>-]\s*)/'; … … 133 133 } 134 134 135 135 136 136 /** 137 137 * Generates a hexadecibal html color based on provided word. … … 159 159 } 160 160 break; 161 161 162 162 case 1 : 163 163 default : … … 219 219 $units = array('B', 'KB', 'MB', 'GB', 'TB'); 220 220 $ii = count($units) - 1; 221 221 222 222 // Max unit 223 223 $unit = array_search((string) $unit, $units); … … 225 225 $unit = $ii; 226 226 } 227 227 228 228 // Loop 229 229 $i = 0; … … 232 232 $i++; 233 233 } 234 234 235 235 return sprintf($format, $size, $units[$i]); 236 236 } … … 264 264 * @param mixed $var The variable that is being set. 265 265 * @param mixed $default What to set it to if $val is not currently set. 266 * @return mixed The resulting value of $var. 266 * @return mixed The resulting value of $var. 267 267 */ 268 268 function setDefault(&$var, $default='') … … 307 307 */ 308 308 function urlEncodeArray($data, $prefix='', $_return=true) { 309 309 310 310 // Data is stored in static variable. 311 311 static $args; 312 312 313 313 if (is_array($data)) { 314 314 foreach ($data as $key => $val) { … … 323 323 $args[$prefix] = urlencode($data); 324 324 } 325 325 326 326 if ($_return) { 327 327 // This is not a recursive execution. All recursion is complete. … … 343 343 */ 344 344 function urlEncodeArrayToString($data, $prefix='') { 345 345 346 346 $array_args = urlEncodeArray($data, $prefix); 347 347 $url_args = ''; … … 378 378 * Prints the word "checked" if a variable is set, and optionally matches 379 379 * the desired value, otherwise prints nothing, 380 * used for printing the word "checked" in a checkbox form input. 380 * used for printing the word "checked" in a checkbox form input. 381 381 * 382 382 * @param mixed $var the variable to compare … … 404 404 * prints the word "selected" if a variable is set, and optionally matches 405 405 * the desired value, otherwise prints nothing, 406 * otherwise prints nothing, used for printing the word "checked" in a 407 * select form input 406 * otherwise prints nothing, used for printing the word "checked" in a 407 * select form input 408 408 * 409 409 * @param mixed $var the variable to compare … … 450 450 * 451 451 * @param array $date String date to convert. 452 * @param array $format Date format to pass to date(). 452 * @param array $format Date format to pass to date(). 453 453 * Default produces MySQL datetime: 0000-00-00 00:00:00. 454 454 * @return string SQL-safe date. … … 462 462 $sql_date = date($format, strtotime($date)); 463 463 } 464 464 465 465 return $sql_date; 466 466 } … … 477 477 { 478 478 static $magic_quotes_gpc; 479 479 480 480 if (!isset($magic_quotes_gpc)) { 481 481 $magic_quotes_gpc = get_magic_quotes_gpc(); 482 482 } 483 483 484 484 if ($magic_quotes_gpc) { 485 485 if (!is_array($var)) { … … 562 562 App::logMsg(sprintf('Adding signature to empty string.', null), LOG_NOTICE, __FILE__, __LINE__); 563 563 } 564 564 565 565 if (!isset($seed_key)) { 566 566 $seed_key = App::getParam('signing_key'); … … 606 606 /** 607 607 * Sends empty output to the browser and flushes the php buffer so the client 608 * will see data before the page is finished processing. 608 * will see data before the page is finished processing. 609 609 */ 610 610 function flushBuffer() { … … 682 682 { 683 683 static $urls = array(); 684 684 685 685 if (!isset($urls[$url])) { 686 686 if (!preg_match('|\w{1,}\.\w{2,5}/|', $url)) { … … 695 695 696 696 /** 697 * Takes a URL and returns it without the query or anchor portion 697 * Takes a URL and returns it without the query or anchor portion 698 698 * 699 699 * @param string $url any kind of URI … … 706 706 707 707 /** 708 * Returns the remote IP address, taking into consideration proxy servers. 708 * Returns the remote IP address, taking into consideration proxy servers. 709 709 * 710 710 * @param bool $dolookup If true we resolve to IP to a host name, … … 740 740 $networks = array($networks); 741 741 } 742 742 743 743 $ip_binary = sprintf('%032b', ip2long($ip)); 744 744 foreach ($networks as $network) { … … 758 758 } 759 759 } 760 760 761 761 return false; 762 762 } 763 763 764 764 /** 765 * Returns a fully qualified URL to the current script, including the query. 765 * Returns a fully qualified URL to the current script, including the query. 766 766 * 767 767 * @return string a full url to the current script … … 796 796 /** 797 797 * Translates text 798 * 798 * 799 799 * @access public 800 800 * @param string $text the text to be translated … … 804 804 return $text; 805 805 } 806 806 807 807 /** 808 808 * Translates text 809 * 809 * 810 810 * @access public 811 811 * @param string $text the text to be translated … … 815 815 return $text; 816 816 } 817 817 818 818 /** 819 819 * Translates text by domain 820 * 820 * 821 821 * @access public 822 822 * @param string $domain the language to translate the text into … … 827 827 return $text; 828 828 } 829 829 830 830 /** 831 831 * Translates text by domain and category 832 * 832 * 833 833 * @access public 834 834 * @param string $domain the language to translate the text into … … 840 840 return $text; 841 841 } 842 842 843 843 /** 844 844 * Binds the text domain 845 * 845 * 846 846 * @access public 847 847 * @param string $domain the language to translate the text into 848 * @param string 848 * @param string 849 849 * @return string translated text 850 850 */ … … 852 852 return $domain; 853 853 } 854 854 855 855 /** 856 856 * Sets the text domain 857 * 857 * 858 858 * @access public 859 859 * @param string $domain the language to translate the text into
Note: See TracChangeset
for help on using the changeset viewer.