Annotation of /mambo/branches/4.6/includes/mambofunc.php
Parent Directory
|
Revision Log
Revision 1756 - (view) (download)
| 1 : | elpie | 1756 | <?php |
| 2 : | /** | ||
| 3 : | * @package Mambo | ||
| 4 : | * @author Mambo Foundation Inc see README.php | ||
| 5 : | * @copyright (C) 2000 - 2009 Mambo Foundation Inc. | ||
| 6 : | * See COPYRIGHT.php for copyright notices and details. | ||
| 7 : | * @license GNU/GPL Version 2, see LICENSE.php | ||
| 8 : | * | ||
| 9 : | * Redistributions of files must retain the above copyright notice. | ||
| 10 : | * | ||
| 11 : | * Mambo is free software; you can redistribute it and/or | ||
| 12 : | * modify it under the terms of the GNU General Public License | ||
| 13 : | * as published by the Free Software Foundation; version 2 of the License. | ||
| 14 : | */ | ||
| 15 : | |||
| 16 : | /** | ||
| 17 : | * Sorts an Array of objects | ||
| 18 : | * sort_direction [1 = Ascending] [-1 = Descending] | ||
| 19 : | */ | ||
| 20 : | function SortArrayObjects( &$a, $k, $sort_direction=1 ) { | ||
| 21 : | $sorter =& new mosObjectSorter($a, $k, $sort_direction); | ||
| 22 : | } | ||
| 23 : | |||
| 24 : | /** | ||
| 25 : | * Sends mail to admin | ||
| 26 : | * Deprecated - not used in Mambo (code copied into weblinks.php) | ||
| 27 : | * Could do with a better facility that works out who to send it to as well | ||
| 28 : | * Note the "email" parameter was not used in the earlier version | ||
| 29 : | */ | ||
| 30 : | function mosSendAdminMail( $adminName, $adminEmail, $email, $type, $title, $author ) { | ||
| 31 : | $mosConfig_live_site = mamboCore::get('mosConfig_live_site'); | ||
| 32 : | $from = mamboCore::get('mosConfig_mailfrom'); | ||
| 33 : | $fromname = mamboCore::get('mosConfig_fromname'); | ||
| 34 : | $subject = sprintf(T_("User Submitted '%s'"), $type); | ||
| 35 : | $message = T_("Hello %s,\n\n | ||
| 36 : | A user submitted %s:\n[ %s ]\n | ||
| 37 : | has been just been submitted by user:\n[ %s ]\n\n | ||
| 38 : | for %\n\nPlease go to %s/administrator to view and approve this %s\n\n | ||
| 39 : | Please do not respond to this message as it is automatically generated and is for information purposes only."); | ||
| 40 : | $message = sprintf($message, $adminName ,$type, $title, $author, $mosConfig_live_site, $mosConfig_live_site, $type); | ||
| 41 : | require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpmailer/class.phpmailer.php'); | ||
| 42 : | $mail =& new mosMailer ($from, $fromname, $subject, $message); | ||
| 43 : | return $mail->mosMail($adminEmail); | ||
| 44 : | } | ||
| 45 : | |||
| 46 : | /* | ||
| 47 : | * Includes pathway file | ||
| 48 : | * Needed by templates | ||
| 49 : | */ | ||
| 50 : | function mosPathWay() { | ||
| 51 : | $pathway =& mosPathway::getInstance(); | ||
| 52 : | echo $pathway->makePathway(); | ||
| 53 : | } | ||
| 54 : | |||
| 55 : | /** | ||
| 56 : | * Displays a not authorised message | ||
| 57 : | * | ||
| 58 : | * If the user is not logged in then an addition message is displayed. | ||
| 59 : | */ | ||
| 60 : | function mosNotAuth() { | ||
| 61 : | global $my; | ||
| 62 : | |||
| 63 : | echo T_('You are not authorized to view this resource.'); | ||
| 64 : | if ($my->id < 1) { | ||
| 65 : | echo "<br />" . T_('You need to login.'); | ||
| 66 : | } | ||
| 67 : | } | ||
| 68 : | |||
| 69 : | /** | ||
| 70 : | * Replaces & with & for xhtml compliance | ||
| 71 : | * | ||
| 72 : | * Needed to handle unicode conflicts due to unicode conflicts | ||
| 73 : | * Deprecated - simply code the line below | ||
| 74 : | */ | ||
| 75 : | function ampReplace( $text ) { | ||
| 76 : | |||
| 77 : | $text = str_replace( '&#', '*-*', $text ); | ||
| 78 : | $text = str_replace( '&', '&', $text ); | ||
| 79 : | $text = str_replace( '*-*', '&#', $text ); | ||
| 80 : | |||
| 81 : | return $text; | ||
| 82 : | //return preg_replace('/(&)([^#]|$)/','&$2', $text); | ||
| 83 : | } | ||
| 84 : | |||
| 85 : | /** | ||
| 86 : | * Chmods files and directories recursively to given permissions. Available from 4.5.2 up. | ||
| 87 : | * @param path The starting file or directory (no trailing slash) | ||
| 88 : | * @param filemode Integer value to chmod files. NULL = dont chmod files. | ||
| 89 : | * @param dirmode Integer value to chmod directories. NULL = dont chmod directories. | ||
| 90 : | * @return TRUE=all succeeded FALSE=one or more chmods failed | ||
| 91 : | */ | ||
| 92 : | function mosChmodRecursive($path, $filemode=NULL, $dirmode=NULL) | ||
| 93 : | { | ||
| 94 : | $fileman =& mosFileManager::getInstance(); | ||
| 95 : | return $fileman->mosChmodRecursive($path, $filemode, $dirmode); | ||
| 96 : | } | ||
| 97 : | |||
| 98 : | /** | ||
| 99 : | * Chmods files and directories recursively to mos global permissions. Available from 4.5.2 up. | ||
| 100 : | * @param path The starting file or directory (no trailing slash) | ||
| 101 : | * @param filemode Integer value to chmod files. NULL = dont chmod files. | ||
| 102 : | * @param dirmode Integer value to chmod directories. NULL = dont chmod directories. | ||
| 103 : | * @return TRUE=all succeeded FALSE=one or more chmods failed | ||
| 104 : | */ | ||
| 105 : | function mosChmod($path) | ||
| 106 : | { | ||
| 107 : | $fileman =& mosFileManager::getInstance(); | ||
| 108 : | return $fileman->mosChmod($path); | ||
| 109 : | } // mosChmod | ||
| 110 : | |||
| 111 : | /** | ||
| 112 : | * Function to convert array to integer values | ||
| 113 : | * Deprecated - not used within Mambo | ||
| 114 : | */ | ||
| 115 : | function mosArrayToInts( &$array, $default=null ) { | ||
| 116 : | if (is_array( $array )) { | ||
| 117 : | $n = count( $array ); | ||
| 118 : | for ($i = 0; $i < $n; $i++) { | ||
| 119 : | $array[$i] = intval( $array[$i] ); | ||
| 120 : | } | ||
| 121 : | } else { | ||
| 122 : | if (is_null( $default )) { | ||
| 123 : | return array(); | ||
| 124 : | } else { | ||
| 125 : | return array( $default ); | ||
| 126 : | } | ||
| 127 : | } | ||
| 128 : | } | ||
| 129 : | |||
| 130 : | /** | ||
| 131 : | * Strip slashes from strings or arrays of strings | ||
| 132 : | * @param value the input string or array | ||
| 133 : | */ | ||
| 134 : | function mosStripslashes(&$value) | ||
| 135 : | { | ||
| 136 : | $database =& mamboDatabase::getInstance(); | ||
| 137 : | return $database->mosStripslashes($value); | ||
| 138 : | } | ||
| 139 : | |||
| 140 : | /** | ||
| 141 : | * Copy the named array content into the object as properties | ||
| 142 : | * only existing properties of object are filled. when undefined in hash, properties wont be deleted | ||
| 143 : | * @param array the input array | ||
| 144 : | * @param obj byref the object to fill of any class | ||
| 145 : | * @param string | ||
| 146 : | * @param boolean | ||
| 147 : | */ | ||
| 148 : | function mosBindArrayToObject( $array, &$obj, $ignore='', $prefix=NULL, $checkSlashes=true ) { | ||
| 149 : | $database =& mamboDatabase::getInstance(); | ||
| 150 : | return $database->mosBindArrayToOBject($array, $obj, $ignore='', $prefix=NULL, $checkSlashes=true); | ||
| 151 : | } | ||
| 152 : | |||
| 153 : | /** | ||
| 154 : | * Utility function to read the files in a directory | ||
| 155 : | * @param string The file system path | ||
| 156 : | * @param string A filter for the names | ||
| 157 : | * @param boolean Recurse search into sub-directories | ||
| 158 : | * @param boolean True if to prepend the full path to the file name | ||
| 159 : | */ | ||
| 160 : | function mosReadDirectory( $path, $filter='.', $recurse=false, $fullpath=false ) { | ||
| 161 : | if (@is_dir($path)) { | ||
| 162 : | $dir =& new mosDirectory($path); | ||
| 163 : | $arr =& $dir->listFiles ($filter, $type='both', $recurse, $fullpath); | ||
| 164 : | } | ||
| 165 : | else $arr = array(); | ||
| 166 : | return $arr; | ||
| 167 : | } | ||
| 168 : | |||
| 169 : | /** | ||
| 170 : | * Utility function redirect the browser location to another url | ||
| 171 : | * | ||
| 172 : | * Can optionally provide a message. | ||
| 173 : | * @param string The file system path | ||
| 174 : | * @param string A filter for the names | ||
| 175 : | */ | ||
| 176 : | function mosRedirect( $url, $msg='' ) { | ||
| 177 : | mamboCore::redirect($url, $msg); | ||
| 178 : | } | ||
| 179 : | |||
| 180 : | /** | ||
| 181 : | * Function to strip additional / or \ in a path name | ||
| 182 : | * @param string The path | ||
| 183 : | * @param boolean Add trailing slash | ||
| 184 : | */ | ||
| 185 : | function mosPathName($p_path,$p_addtrailingslash = true) { | ||
| 186 : | $fileman =& mosFileManager::getInstance(); | ||
| 187 : | return $fileman->mosPathName($p_path,$p_addtrailingslash); | ||
| 188 : | } | ||
| 189 : | |||
| 190 : | /** | ||
| 191 : | * Checks the user agent string against known browsers | ||
| 192 : | */ | ||
| 193 : | function mosGetBrowser( $agent ) { | ||
| 194 : | require( "includes/agent_browser.php" ); | ||
| 195 : | |||
| 196 : | if (preg_match( "/msie[\/\sa-z]*([\d\.]*)/i", $agent, $m ) | ||
| 197 : | && !preg_match( "/webtv/i", $agent ) | ||
| 198 : | && !preg_match( "/omniweb/i", $agent ) | ||
| 199 : | && !preg_match( "/opera/i", $agent )) { | ||
| 200 : | // IE | ||
| 201 : | return "MS Internet Explorer $m[1]"; | ||
| 202 : | } else if (preg_match( "/netscape.?\/([\d\.]*)/i", $agent, $m )) { | ||
| 203 : | // Netscape 6.x, 7.x ... | ||
| 204 : | return "Netscape $m[1]"; | ||
| 205 : | } else if ( preg_match( "/mozilla[\/\sa-z]*([\d\.]*)/i", $agent, $m ) | ||
| 206 : | && !preg_match( "/gecko/i", $agent ) | ||
| 207 : | && !preg_match( "/compatible/i", $agent ) | ||
| 208 : | && !preg_match( "/opera/i", $agent ) | ||
| 209 : | && !preg_match( "/galeon/i", $agent ) | ||
| 210 : | && !preg_match( "/safari/i", $agent )) { | ||
| 211 : | // Netscape 3.x, 4.x ... | ||
| 212 : | return "Netscape $m[2]"; | ||
| 213 : | } else { | ||
| 214 : | // Other | ||
| 215 : | $found = false; | ||
| 216 : | foreach ($browserSearchOrder as $key) { | ||
| 217 : | if (preg_match( "/$key.?\/([\d\.]*)/i", $agent, $m )) { | ||
| 218 : | $name = "$browsersAlias[$key] $m[1]"; | ||
| 219 : | return $name; | ||
| 220 : | break; | ||
| 221 : | } | ||
| 222 : | } | ||
| 223 : | } | ||
| 224 : | |||
| 225 : | return 'Unknown'; | ||
| 226 : | } | ||
| 227 : | |||
| 228 : | /** | ||
| 229 : | * Checks the user agent string against known operating systems | ||
| 230 : | */ | ||
| 231 : | function mosGetOS( $agent ) { | ||
| 232 : | require( "includes/agent_os.php" ); | ||
| 233 : | |||
| 234 : | foreach ($osSearchOrder as $key) { | ||
| 235 : | if (preg_match( "/$key/i", $agent )) { | ||
| 236 : | return $osAlias[$key]; | ||
| 237 : | break; | ||
| 238 : | } | ||
| 239 : | } | ||
| 240 : | |||
| 241 : | return 'Unknown'; | ||
| 242 : | } | ||
| 243 : | |||
| 244 : | /** | ||
| 245 : | * Makes a variable safe to display in forms | ||
| 246 : | * | ||
| 247 : | * Object parameters that are non-string, array, object or start with underscore | ||
| 248 : | * will be converted | ||
| 249 : | * @param object An object to be parsed | ||
| 250 : | * @param int The optional quote style for the htmlspecialchars function | ||
| 251 : | * @param string|array An optional single field name or array of field names not | ||
| 252 : | * to be parsed (eg, for a textarea) | ||
| 253 : | */ | ||
| 254 : | function mosMakeHtmlSafe( &$mixed, $quote_style=ENT_QUOTES, $exclude_keys='' ) { | ||
| 255 : | if (is_object( $mixed )) { | ||
| 256 : | foreach (get_object_vars( $mixed ) as $k => $v) { | ||
| 257 : | if (is_array( $v ) || is_object( $v ) || $v == NULL || substr( $k, 1, 1 ) == '_' ) { | ||
| 258 : | continue; | ||
| 259 : | } | ||
| 260 : | if (is_string( $exclude_keys ) && $k == $exclude_keys) { | ||
| 261 : | continue; | ||
| 262 : | } else if (is_array( $exclude_keys ) && in_array( $k, $exclude_keys )) { | ||
| 263 : | continue; | ||
| 264 : | } | ||
| 265 : | $mixed->$k = htmlspecialchars( $v, $quote_style ); | ||
| 266 : | } | ||
| 267 : | } | ||
| 268 : | } | ||
| 269 : | |||
| 270 : | /** | ||
| 271 : | * Checks whether a menu option is within the users access level | ||
| 272 : | * @param int Item id number | ||
| 273 : | * @param string The menu option | ||
| 274 : | * @param int The users group ID number | ||
| 275 : | * @param database A database connector object | ||
| 276 : | * @return boolean True if the visitor's group at least equal to the menu access | ||
| 277 : | */ | ||
| 278 : | function mosMenuCheck( $Itemid, $menu_option, $task, $gid ) { | ||
| 279 : | $menuhandler =& mosMenuHandler::getInstance(); | ||
| 280 : | return $menuhandler->menuCheck($Itemid, $menu_option, $task, $gid); | ||
| 281 : | } | ||
| 282 : | |||
| 283 : | /** | ||
| 284 : | * Returns formated date according to current local and adds time offset | ||
| 285 : | * @param string date in datetime format | ||
| 286 : | * @param string format optional format for strftime | ||
| 287 : | * @param offset time offset if different than global one | ||
| 288 : | * @returns formated date | ||
| 289 : | */ | ||
| 290 : | function mosFormatDate( $date, $format="", $offset="" ){ | ||
| 291 : | $core = mamboCore::getMamboCore(); | ||
| 292 : | if ( $format == '' ) { | ||
| 293 : | // %Y-%m-%d %H:%M:%S | ||
| 294 : | $format = $core->current_language->date_format; | ||
| 295 : | } | ||
| 296 : | |||
| 297 : | |||
| 298 : | if ( !$offset ) { | ||
| 299 : | $offset = $core->mosConfig_offset; | ||
| 300 : | } | ||
| 301 : | if ( $date && ereg( "([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $date, $regs ) ) { | ||
| 302 : | $date = mktime( $regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1] ); | ||
| 303 : | $date = $date > -1 ? $core->current_language->getDate($format, $date + ($offset*60*60)) : '-'; | ||
| 304 : | } | ||
| 305 : | return $date; | ||
| 306 : | } | ||
| 307 : | |||
| 308 : | /** | ||
| 309 : | * Returns current date according to current local and time offset | ||
| 310 : | * @param string format optional format for strftime | ||
| 311 : | * @returns current date | ||
| 312 : | */ | ||
| 313 : | function mosCurrentDate( $format="" ) { | ||
| 314 : | $core =& mamboCore::getMamboCore(); | ||
| 315 : | $offset = mamboCore::get('mosConfig_offset'); | ||
| 316 : | if ($format=="") { | ||
| 317 : | $format = $format = $core->current_language->date_format; | ||
| 318 : | } | ||
| 319 : | $date = $core->current_language->getDate($format, time() + ($offset*60*60)); | ||
| 320 : | return $date; | ||
| 321 : | } | ||
| 322 : | |||
| 323 : | /** | ||
| 324 : | * Utility function to provide ToolTips | ||
| 325 : | * @param string ToolTip text | ||
| 326 : | * @param string Box title | ||
| 327 : | * @returns HTML code for ToolTip | ||
| 328 : | */ | ||
| 329 : | function mosToolTip( $tooltip, $title='', $width='', $image='tooltip.png', $text='', $href='#' ) { | ||
| 330 : | global $mosConfig_live_site; | ||
| 331 : | |||
| 332 : | if ( $width ) { | ||
| 333 : | $width = ', WIDTH, \''.$width .'\''; | ||
| 334 : | } | ||
| 335 : | if ( $title ) { | ||
| 336 : | $title = ', CAPTION, \''.$title .'\''; | ||
| 337 : | } | ||
| 338 : | if ( !$text ) { | ||
| 339 : | $image = $mosConfig_live_site . '/includes/js/ThemeOffice/'. $image; | ||
| 340 : | $text = '<img src="'. $image .'" border="0" />'; | ||
| 341 : | } | ||
| 342 : | $style = 'style="text-decoration: none; color: #333;"'; | ||
| 343 : | if ( $href ) { | ||
| 344 : | $style = ''; | ||
| 345 : | } | ||
| 346 : | $tip = "<a href=\"". $href ."\" onMouseOver=\"return overlib('" . $tooltip . "'". $title .", BELOW, RIGHT". $width .");\" onmouseout=\"return nd();\" ". $style .">". $text ."</a>"; | ||
| 347 : | return $tip; | ||
| 348 : | } | ||
| 349 : | |||
| 350 : | /** | ||
| 351 : | * Utility function to provide Warning Icons | ||
| 352 : | * @param string Warning text | ||
| 353 : | * @param string Box title | ||
| 354 : | * @returns HTML code for Warning | ||
| 355 : | */ | ||
| 356 : | function mosWarning($warning, $title=null) { | ||
| 357 : | if (is_null($title)) $title = T_('Mambo Warning'); | ||
| 358 : | $mosConfig_live_site = mamboCore::get('mosConfig_live_site'); | ||
| 359 : | $tip = "<a href=\"#\" onMouseOver=\"return overlib('" . $warning . "', CAPTION, '$title', BELOW, RIGHT);\" onmouseout=\"return nd();\"><img src=\"" . $mosConfig_live_site . "/includes/js/ThemeOffice/warning.png\" border=\"0\" /></a>"; | ||
| 360 : | return $tip; | ||
| 361 : | } | ||
| 362 : | |||
| 363 : | function mosCreateGUID(){ | ||
| 364 : | srand((double)microtime()*1000000); | ||
| 365 : | $r = rand ; | ||
| 366 : | $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); | ||
| 367 : | $m = md5 ($u); | ||
| 368 : | return($m); | ||
| 369 : | } | ||
| 370 : | |||
| 371 : | function mosCompressID( $ID ){ | ||
| 372 : | return(Base64_encode(pack("H*",$ID))); | ||
| 373 : | } | ||
| 374 : | |||
| 375 : | function mosExpandID( $ID ) { | ||
| 376 : | return ( implode(unpack("H*",Base64_decode($ID)), '') ); | ||
| 377 : | } | ||
| 378 : | |||
| 379 : | /** | ||
| 380 : | * Mail function (uses phpMailer) | ||
| 381 : | * @param string From e-mail address | ||
| 382 : | * @param string From name | ||
| 383 : | * @param string/array Recipient e-mail address(es) | ||
| 384 : | * @param string E-mail subject | ||
| 385 : | * @param string Message body | ||
| 386 : | * @param boolean false = plain text, true = HTML | ||
| 387 : | * @param string/array CC e-mail address(es) | ||
| 388 : | * @param string/array BCC e-mail address(es) | ||
| 389 : | * @param string/array Attachment file name(s) | ||
| 390 : | * @param string/array Reply-to e-mail address | ||
| 391 : | * @param string/array Reply-to name | ||
| 392 : | */ | ||
| 393 : | function mosMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=NULL, $bcc=NULL, $attachment=NULL, $replyto=NULL, $replytoname=NULL ) { | ||
| 394 : | require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpmailer/class.phpmailer.php'); | ||
| 395 : | $mail =& new mosMailer ($from, $fromname, $subject, $body); | ||
| 396 : | $result = $mail->mosMail($recipient, $mode, $cc, $bcc, $attachment, $replyto, $replytoname); | ||
| 397 : | return $result; | ||
| 398 : | } // mosMail | ||
| 399 : | |||
| 400 : | /** | ||
| 401 : | * Create mail object | ||
| 402 : | * @return mail object | ||
| 403 : | */ | ||
| 404 : | function &mosCreateMail ($from, $fromname, $subject, $body) { | ||
| 405 : | require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpmailer/class.phpmailer.php'); | ||
| 406 : | $mail =& new mosMailer ($from, $fromname, $subject, $body); | ||
| 407 : | return $mail; | ||
| 408 : | } | ||
| 409 : | |||
| 410 : | /** | ||
| 411 : | * Random password generator | ||
| 412 : | * @return password | ||
| 413 : | */ | ||
| 414 : | function mosMakePassword() { | ||
| 415 : | require_once(mamboCore::get('mosConfig_absolute_path').'/includes/authenticator.php'); | ||
| 416 : | $authenticator =& mamboAuthenticator::getInstance(); | ||
| 417 : | return $authenticator->mosMakePassword(); | ||
| 418 : | } | ||
| 419 : | |||
| 420 : | if (!function_exists('html_entity_decode')) { | ||
| 421 : | /** | ||
| 422 : | * html_entity_decode function for backward compatability in PHP | ||
| 423 : | * @param string | ||
| 424 : | * @param string | ||
| 425 : | */ | ||
| 426 : | function html_entity_decode ($string, $opt = ENT_COMPAT) { | ||
| 427 : | |||
| 428 : | $trans_tbl = get_html_translation_table (HTML_ENTITIES); | ||
| 429 : | $trans_tbl = array_flip ($trans_tbl); | ||
| 430 : | |||
| 431 : | if ($opt & 1) { // Translating single quotes | ||
| 432 : | // Add single quote to translation table; | ||
| 433 : | // doesn't appear to be there by default | ||
| 434 : | $trans_tbl["'"] = "'"; | ||
| 435 : | } | ||
| 436 : | |||
| 437 : | if (!($opt & 2)) { // Not translating double quotes | ||
| 438 : | // Remove double quote from translation table | ||
| 439 : | unset($trans_tbl["""]); | ||
| 440 : | } | ||
| 441 : | |||
| 442 : | return strtr ($string, $trans_tbl); | ||
| 443 : | } | ||
| 444 : | } | ||
| 445 : | |||
| 446 : | /** | ||
| 447 : | * @param string | ||
| 448 : | * @return string | ||
| 449 : | * Deprecated - use the code within this function instead - not used in Mambo | ||
| 450 : | */ | ||
| 451 : | function mosParseParams( $txt ) { | ||
| 452 : | $pparser = new mosParameters($txt); | ||
| 453 : | return $pparser->getParams(); | ||
| 454 : | } | ||
| 455 : | |||
| 456 : | class mosEmpty { | ||
| 457 : | function def( $key, $value='' ) { | ||
| 458 : | return 1; | ||
| 459 : | } | ||
| 460 : | function get( $key, $default='' ) { | ||
| 461 : | return 1; | ||
| 462 : | } | ||
| 463 : | } | ||
| 464 : | |||
| 465 : | function mosIsRTL(){ | ||
| 466 : | $core = mamboCore::getMamboCore(); | ||
| 467 : | if ( $core->current_language->text_direction == "rtl" ){ | ||
| 468 : | return true; | ||
| 469 : | } else { | ||
| 470 : | return false; | ||
| 471 : | } | ||
| 472 : | } | ||
| 473 : | |||
| 474 : | /** | ||
| 475 : | * Utility path directory separator sanitizer | ||
| 476 : | * @param string the path to sanitize | ||
| 477 : | * @param boolean false = don't strip trailing slashes true = strip trailing slashes | ||
| 478 : | * @return sanitized path | ||
| 479 : | */ | ||
| 480 : | function mosPath($path, $stripTrailing=false) { | ||
| 481 : | if ($stripTrailing) $path = preg_replace("/[\/\\\\]+$/", "", $path); | ||
| 482 : | $ds = defined('DIRECTORY_SEPARATOR') ? DIRECTORY_SEPARATOR : '/'; | ||
| 483 : | $path = preg_replace("/[\/\\\\]+/",$ds,$path); | ||
| 484 : | return $path; | ||
| 485 : | } | ||
| 486 : | |||
| 487 : | /** | ||
| 488 : | * Replacement for session_start | ||
| 489 : | */ | ||
| 490 : | function mos_session_start() { | ||
| 491 : | if (!session_id()) session_start(); | ||
| 492 : | if (!isset($_SESSION['initiated'])) { | ||
| 493 : | session_regenerate_id(true); | ||
| 494 : | $_SESSION['initiated'] = true; | ||
| 495 : | } | ||
| 496 : | } | ||
| 497 : | |||
| 498 : | /** | ||
| 499 : | * Get a form hash | ||
| 500 : | */ | ||
| 501 : | function mosFormId($option='', $task='', $my='') { | ||
| 502 : | return mosMainframe::formId($option, $task, $my); | ||
| 503 : | } | ||
| 504 : | |||
| 505 : | /** | ||
| 506 : | * Check a form hash | ||
| 507 : | */ | ||
| 508 : | function mosValidFormId($option='', $task='', $my='') { | ||
| 509 : | return mosMainframe::validFormId($option, $task, $my); | ||
| 510 : | } | ||
| 511 : | |||
| 512 : | /** | ||
| 513 : | * Utility debugging shortcut | ||
| 514 : | * @param string echoed with a trailing <br /> tag | ||
| 515 : | */ | ||
| 516 : | function e($string) { | ||
| 517 : | echo "$string<br />"; | ||
| 518 : | } | ||
| 519 : | |||
| 520 : | /** | ||
| 521 : | * Utility debugging shortcut | ||
| 522 : | * @param list print_r(list) enclosed by <pre></pre> tags | ||
| 523 : | */ | ||
| 524 : | function pr($list) { | ||
| 525 : | echo "<pre>"; | ||
| 526 : | print_r($list); | ||
| 527 : | echo "</pre>"; | ||
| 528 : | } | ||
| 529 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

