Source for file mambofunc.php
Documentation is available at mambofunc.php
* @copyright Refer to copyright.php
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @author Mambo Foundation Inc see README.php
* Sorts an Array of objects
* sort_direction [1 = Ascending] [-1 = Descending]
* Deprecated - not used in Mambo (code copied into weblinks.php)
* Could do with a better facility that works out who to send it to as well
* Note the "email" parameter was not used in the earlier version
function mosSendAdminMail( $adminName, $adminEmail, $email, $type, $title, $author ) {
$mosConfig_live_site =
mamboCore::get('mosConfig_live_site');
$subject =
sprintf(T_("User Submitted '%s'"), $type);
$message =
T_("Hello %s,\n\n
A user submitted %s:\n[ %s ]\n
has been just been submitted by user:\n[ %s ]\n\n
for %\n\nPlease go to %s/administrator to view and approve this %s\n\n
Please do not respond to this message as it is automatically generated and is for information purposes only.");
$message =
sprintf($message, $adminName ,$type, $title, $author, $mosConfig_live_site, $mosConfig_live_site, $type);
require_once(mamboCore::get('mosConfig_absolute_path').
'/includes/phpmailer/class.phpmailer.php');
$mail =
& new mosMailer ($from, $fromname, $subject, $message);
return $mail->mosMail($adminEmail);
echo
$pathway->makePathway();
* Displays a not authorised message
* If the user is not logged in then an addition message is displayed.
echo
T_('You are not authorized to view this resource.');
echo
"<br />" .
T_('You need to login.');
* Replaces & with & for xhtml compliance
* Needed to handle unicode conflicts due to unicode conflicts
* Deprecated - simply code the line below
//return preg_replace('/(&)([^#]|$)/','&$2', $text);
* Chmods files and directories recursively to given permissions. Available from 4.5.2 up.
* @param path The starting file or directory (no trailing slash)
* @param filemode Integer value to chmod files. NULL = dont chmod files.
* @param dirmode Integer value to chmod directories. NULL = dont chmod directories.
* @return TRUE=all succeeded FALSE=one or more chmods failed
* Chmods files and directories recursively to mos global permissions. Available from 4.5.2 up.
* @param path The starting file or directory (no trailing slash)
* @param filemode Integer value to chmod files. NULL = dont chmod files.
* @param dirmode Integer value to chmod directories. NULL = dont chmod directories.
* @return TRUE=all succeeded FALSE=one or more chmods failed
* Function to convert array to integer values
* Deprecated - not used within Mambo
for ($i =
0; $i <
$n; $i++
) {
$array[$i] =
intval( $array[$i] );
return array( $default );
* Strip slashes from strings or arrays of strings
* @param value the input string or array
* Copy the named array content into the object as properties
* only existing properties of object are filled. when undefined in hash, properties wont be deleted
* @param array the input array
* @param obj byref the object to fill of any class
return $database->mosBindArrayToOBject($array, $obj, $ignore=
'', $prefix=
NULL, $checkSlashes=
true);
* Utility function to read the files in a directory
* @param string The file system path
* @param string A filter for the names
* @param boolean Recurse search into sub-directories
* @param boolean True if to prepend the full path to the file name
function mosReadDirectory( $path, $filter=
'.', $recurse=
false, $fullpath=
false ) {
$arr =
& $dir->listFiles ($filter, $type=
'both', $recurse, $fullpath);
* Utility function redirect the browser location to another url
* Can optionally provide a message.
* @param string The file system path
* @param string A filter for the names
* Function to strip additional / or \ in a path name
* @param boolean Add trailing slash
function mosPathName($p_path,$p_addtrailingslash =
true) {
return $fileman->mosPathName($p_path,$p_addtrailingslash);
* Checks the user agent string against known browsers
require
( "includes/agent_browser.php" );
if (preg_match( "/msie[\/\sa-z]*([\d\.]*)/i", $agent, $m )
return "MS Internet Explorer $m[1]";
} else if (preg_match( "/netscape.?\/([\d\.]*)/i", $agent, $m )) {
} else if ( preg_match( "/mozilla[\/\sa-z]*([\d\.]*)/i", $agent, $m )
foreach ($browserSearchOrder as $key) {
if (preg_match( "/$key.?\/([\d\.]*)/i", $agent, $m )) {
$name =
"$browsersAlias[$key] $m[1]";
* Checks the user agent string against known operating systems
require
( "includes/agent_os.php" );
foreach ($osSearchOrder as $key) {
* Makes a variable safe to display in forms
* Object parameters that are non-string, array, object or start with underscore
* @param object An object to be parsed
* @param int The optional quote style for the htmlspecialchars function
* @param string|arrayAn optional single field name or array of field names not
* to be parsed (eg, for a textarea)
function mosMakeHtmlSafe( &$mixed, $quote_style=
ENT_QUOTES, $exclude_keys=
'' ) {
if (is_string( $exclude_keys ) &&
$k ==
$exclude_keys) {
* Checks whether a menu option is within the users access level
* @param int Item id number
* @param string The menu option
* @param int The users group ID number
* @param database A database connector object
* @return boolean True if the visitor's group at least equal to the menu access
function mosMenuCheck( $Itemid, $menu_option, $task, $gid ) {
return $menuhandler->menuCheck($Itemid, $menu_option, $task, $gid);
* Returns formated date according to current local and adds time offset
* @param string date in datetime format
* @param string format optional format for strftime
* @param offset time offset if different than global one
function mosFormatDate( $date, $format=
"", $offset=
"", $jalali =
1 ){
$offset =
$core->mosConfig_offset;
if ( $farsi &&
$date &&
ereg( "([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $date, $regs ) ) {
$date =
mktime( $regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1] );
$date =
$date > -
1 ?
jdate( $format, $date +
($offset*
60*
60),$faint ) :
'-';
$date =
$date > -
1 ?
$core->current_language->getDate($format, $date +
($offset*
60*
60)) :
'-';
} else if ( !$farsi &&
$date &&
ereg( "([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $date, $regs ) ) {
$date =
mktime( $regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1] );
$date =
$date > -
1 ?
$core->current_language->getDate($format, $date +
($offset*
60*
60)) :
'-';
* Returns current date according to current local and time offset
* @param string format optional format for strftime
$format =
$format =
$core->current_language->date_format;
$date =
$core->current_language->getDate($format, time() +
($offset*
60*
60));
* Utility function to provide ToolTips
* @param string ToolTip text
* @param string Box title
* @returns HTML code for ToolTip
function mosToolTip( $tooltip, $title=
'', $width=
'', $image=
'tooltip.png', $text=
'', $href=
'#' ) {
global $mosConfig_live_site;
$width =
', WIDTH, \''.
$width .
'\'';
$title =
', CAPTION, \''.
$title .
'\'';
$image =
$mosConfig_live_site .
'/includes/js/ThemeOffice/'.
$image;
$text =
'<img src="'.
$image .
'" border="0" />';
$style =
'style="text-decoration: none; color: #333;"';
$tip =
"<a href=\"".
$href .
"\" onMouseOver=\"return overlib('" .
$tooltip .
"'".
$title .
", BELOW, RIGHT".
$width .
");\" onmouseout=\"return nd();\" ".
$style .
">".
$text .
"</a>";
* Utility function to provide Warning Icons
* @param string Warning text
* @param string Box title
* @returns HTML code for Warning
if (is_null($title)) $title =
T_('Mambo Warning');
$mosConfig_live_site =
mamboCore::get('mosConfig_live_site');
$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>";
return(Base64_encode(pack("H*",$ID)));
* Mail function (uses phpMailer)
* @param string From e-mail address
* @param string From name
* @param string/array Recipient e-mail address(es)
* @param string E-mail subject
* @param string Message body
* @param boolean false = plain text, true = HTML
* @param string/array CC e-mail address(es)
* @param string/array BCC e-mail address(es)
* @param string/array Attachment file name(s)
* @param string/array Reply-to e-mail address
* @param string/array Reply-to name
function mosMail($from, $fromname, $recipient, $subject, $body, $mode=
0, $cc=
NULL, $bcc=
NULL, $attachment=
NULL, $replyto=
NULL, $replytoname=
NULL ) {
require_once(mamboCore::get('mosConfig_absolute_path').
'/includes/phpmailer/class.phpmailer.php');
$mail =
& new mosMailer ($from, $fromname, $subject, $body);
$result =
$mail->mosMail($recipient, $mode, $cc, $bcc, $attachment, $replyto, $replytoname);
require_once(mamboCore::get('mosConfig_absolute_path').
'/includes/phpmailer/class.phpmailer.php');
$mail =
& new mosMailer ($from, $fromname, $subject, $body);
* Random password generator
require_once(mamboCore::get('mosConfig_absolute_path').
'/includes/authenticator.php');
* html_entity_decode function for backward compatability in PHP
if ($opt & 1) { // Translating single quotes
// Add single quote to translation table;
// doesn't appear to be there by default
$trans_tbl["'"] =
"'";
if (!($opt & 2)) { // Not translating double quotes
// Remove double quote from translation table
unset
($trans_tbl["""]);
return strtr ($string, $trans_tbl);
* Deprecated - use the code within this function instead - not used in Mambo
return $pparser->getParams();
function def( $key, $value=
'' ) {
function get( $key, $default=
'' ) {
if ( $core->current_language->text_direction ==
"rtl" ){
Documentation generated on Mon, 05 May 2008 16:21:00 +0400 by phpDocumentor 1.4.0