| 269 |
mamboCore::redirect($url, $msg); |
mamboCore::redirect($url, $msg); |
| 270 |
} |
} |
| 271 |
|
|
|
function mosTreeRecurse( $id, $indent, $list, &$children, $maxlevel=9999, $level=0, $type=1 ) { |
|
|
if (@$children[$id] && $level <= $maxlevel) { |
|
|
foreach ($children[$id] as $v) { |
|
|
$id = $v->id; |
|
|
|
|
|
if ( $type ) { |
|
|
$pre = '<sup>L</sup> '; |
|
|
$spacer = '. '; |
|
|
} else { |
|
|
$pre = '- '; |
|
|
$spacer = ' '; |
|
|
} |
|
|
|
|
|
if ( $v->parent == 0 ) { |
|
|
$txt = $v->name; |
|
|
} else { |
|
|
$txt = $pre . $v->name; |
|
|
} |
|
|
$pt = $v->parent; |
|
|
$list[$id] = $v; |
|
|
$list[$id]->treename = "$indent$txt"; |
|
|
$list[$id]->children = count( @$children[$id] ); |
|
|
$list = mosTreeRecurse( $id, $indent . $spacer, $list, $children, $maxlevel, $level+1, $type ); |
|
|
} |
|
|
} |
|
|
return $list; |
|
|
} |
|
|
|
|
| 272 |
/** |
/** |
| 273 |
* Function to strip additional / or \ in a path name |
* Function to strip additional / or \ in a path name |
| 274 |
* @param string The path |
* @param string The path |
| 302 |
return $retval; |
return $retval; |
| 303 |
} |
} |
| 304 |
|
|
|
function mosObjectToArray($p_obj) |
|
|
{ |
|
|
$retarray = null; |
|
|
if(is_object($p_obj)) |
|
|
{ |
|
|
$retarray = array(); |
|
|
foreach (get_object_vars($p_obj) as $k => $v) |
|
|
{ |
|
|
if(is_object($v)) |
|
|
$retarray[$k] = mosObjectToArray($v); |
|
|
else |
|
|
$retarray[$k] = $v; |
|
|
} |
|
|
} |
|
|
return $retarray; |
|
|
} |
|
| 305 |
/** |
/** |
| 306 |
* Checks the user agent string against known browsers |
* Checks the user agent string against known browsers |
| 307 |
*/ |
*/ |
| 357 |
} |
} |
| 358 |
|
|
| 359 |
/** |
/** |
|
* @param string SQL with ordering As value and 'name field' AS text |
|
|
* @param integer The length of the truncated headline |
|
|
*/ |
|
|
function mosGetOrderingList( $sql, $chop='30' ) { |
|
|
global $database; |
|
|
|
|
|
$order = array(); |
|
|
$database->setQuery( $sql ); |
|
|
if (!($orders = $database->loadObjectList())) { |
|
|
if ($database->getErrorNum()) { |
|
|
echo $database->stderr(); |
|
|
return false; |
|
|
} else { |
|
|
$order[] = mosHTML::makeOption( 1, 'first' ); |
|
|
return $order; |
|
|
} |
|
|
} |
|
|
$order[] = mosHTML::makeOption( 0, '0 first' ); |
|
|
for ($i=0, $n=count( $orders ); $i < $n; $i++) { |
|
|
|
|
|
if (strlen($orders[$i]->text) > $chop) { |
|
|
$text = substr($orders[$i]->text,0,$chop)."..."; |
|
|
} else { |
|
|
$text = $orders[$i]->text; |
|
|
} |
|
|
|
|
|
$order[] = mosHTML::makeOption( $orders[$i]->value, $orders[$i]->value.' ('.$text.')' ); |
|
|
} |
|
|
$order[] = mosHTML::makeOption( $orders[$i-1]->value+1, ($orders[$i-1]->value+1).' last' ); |
|
|
|
|
|
return $order; |
|
|
} |
|
|
|
|
|
/** |
|
| 360 |
* Makes a variable safe to display in forms |
* Makes a variable safe to display in forms |
| 361 |
* |
* |
| 362 |
* Object parameters that are non-string, array, object or start with underscore |
* Object parameters that are non-string, array, object or start with underscore |
| 488 |
} |
} |
| 489 |
|
|
| 490 |
/** |
/** |
|
* Function to create a mail object for futher use (uses phpMailer) |
|
|
* @param string From e-mail address |
|
|
* @param string From name |
|
|
* @param string E-mail subject |
|
|
* @param string Message body |
|
|
* @return object Mail object |
|
|
*/ |
|
|
function mosCreateMail( $from='', $fromname='', $subject, $body ) { |
|
|
global $mosConfig_absolute_path, $mosConfig_sendmail; |
|
|
global $mosConfig_smtpauth, $mosConfig_smtpuser; |
|
|
global $mosConfig_smtppass, $mosConfig_smtphost; |
|
|
global $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_mailer; |
|
|
|
|
|
$mail = new mosPHPMailer(); |
|
|
|
|
|
$mail->PluginDir = $mosConfig_absolute_path .'/includes/phpmailer/'; |
|
|
$mail->SetLanguage( 'en', $mosConfig_absolute_path . '/includes/phpmailer/language/' ); |
|
|
$mail->CharSet = substr_replace(_ISO, '', 0, 8); |
|
|
$mail->IsMail(); |
|
|
$mail->From = $from ? $from : $mosConfig_mailfrom; |
|
|
$mail->FromName = $fromname ? $fromname : $mosConfig_fromname; |
|
|
$mail->Mailer = $mosConfig_mailer; |
|
|
|
|
|
// Add smtp values if needed |
|
|
if ( $mosConfig_mailer == 'smtp' ) { |
|
|
$mail->SMTPAuth = $mosConfig_smtpauth; |
|
|
$mail->Username = $mosConfig_smtpuser; |
|
|
$mail->Password = $mosConfig_smtppass; |
|
|
$mail->Host = $mosConfig_smtphost; |
|
|
} else |
|
|
|
|
|
// Set sendmail path |
|
|
if ( $mosConfig_mailer == 'sendmail' ) { |
|
|
if (isset($mosConfig_sendmail)) |
|
|
$mail->Sendmail = $mosConfig_sendmail; |
|
|
} // if |
|
|
|
|
|
$mail->Subject = $subject; |
|
|
$mail->Body = $body; |
|
|
|
|
|
return $mail; |
|
|
} |
|
|
|
|
|
/** |
|
| 491 |
* Mail function (uses phpMailer) |
* Mail function (uses phpMailer) |
| 492 |
* @param string From e-mail address |
* @param string From e-mail address |
| 493 |
* @param string From name |
* @param string From name |
| 502 |
* @param string/array Reply-to name |
* @param string/array Reply-to name |
| 503 |
*/ |
*/ |
| 504 |
function mosMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=NULL, $bcc=NULL, $attachment=NULL, $replyto=NULL, $replytoname=NULL ) { |
function mosMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=NULL, $bcc=NULL, $attachment=NULL, $replyto=NULL, $replytoname=NULL ) { |
| 505 |
global $mosConfig_debug; |
require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpmailer/class.phpmailer.php'); |
| 506 |
$mail = mosCreateMail( $from, $fromname, $subject, $body ); |
$mail =& new mosMailer ($from, $fromname, $subject, $body); |
| 507 |
|
$result = $mail->mosMail($recipient, $mode, $cc, $bcc, $attachment, $replyto, $replytoname); |
| 508 |
// activate HTML formatted emails |
return $result; |
|
if ( $mode ) { |
|
|
$mail->IsHTML(true); |
|
|
} |
|
|
|
|
|
if( is_array($recipient) ) { |
|
|
foreach ($recipient as $to) { |
|
|
$mail->AddAddress($to); |
|
|
} |
|
|
} else { |
|
|
$mail->AddAddress($recipient); |
|
|
} |
|
|
if (isset($cc)) { |
|
|
if( is_array($cc) ) |
|
|
foreach ($cc as $to) $mail->AddCC($to); |
|
|
else |
|
|
$mail->AddCC($cc); |
|
|
} |
|
|
if (isset($bcc)) { |
|
|
if( is_array($bcc) ) |
|
|
foreach ($bcc as $to) $mail->AddBCC($to); |
|
|
else |
|
|
$mail->AddBCC($bcc); |
|
|
} |
|
|
if ($attachment) { |
|
|
if ( is_array($attachment) ) |
|
|
foreach ($attachment as $fname) $mail->AddAttachment($fname); |
|
|
else |
|
|
$mail->AddAttachment($attachment); |
|
|
} // if |
|
|
if ($replyto) { |
|
|
if ( is_array($replyto) ) { |
|
|
reset($replytoname); |
|
|
foreach ($replyto as $to) { |
|
|
$toname = ((list($key, $value) = each($replytoname)) |
|
|
? $value : ""); |
|
|
$mail->AddReplyTo($to, $toname); |
|
|
} |
|
|
} else |
|
|
$mail->AddReplyTo($replyto, $replytoname); |
|
|
} |
|
|
$mailssend = $mail->Send(); |
|
|
|
|
|
if( $mosConfig_debug ) { |
|
|
//$mosDebug->message( "Mails send: $mailssend"); |
|
|
} |
|
|
if( $mail->error_count > 0 ) { |
|
|
//$mosDebug->message( "The mail message $fromname <$from> about $subject to $recipient <b>failed</b><br /><pre>$body</pre>", false ); |
|
|
//$mosDebug->message( "Mailer Error: " . $mail->ErrorInfo . "" ); |
|
|
} |
|
|
return $mailssend; |
|
| 509 |
} // mosMail |
} // mosMail |
| 510 |
|
|
| 511 |
/** |
/** |