| 45 |
|
|
| 46 |
//require_once( $mosConfig_absolute_path . '/includes/gacl.class.php' ); |
//require_once( $mosConfig_absolute_path . '/includes/gacl.class.php' ); |
| 47 |
//require_once( $mosConfig_absolute_path . '/includes/gacl_api.class.php' ); |
//require_once( $mosConfig_absolute_path . '/includes/gacl_api.class.php' ); |
|
require_once( $mosConfig_absolute_path . '/includes/phpmailer/class.phpmailer.php' ); |
|
|
require_once( $mosConfig_absolute_path . '/includes/mamboxml.php' ); |
|
|
require_once( $mosConfig_absolute_path . '/includes/phpInputFilter/class.inputfilter.php' ); |
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 406 |
|
|
| 407 |
|
|
| 408 |
/** |
/** |
|
* Task routing class |
|
|
* @package Mambo |
|
|
* @abstract |
|
|
*/ |
|
|
class mosAbstractTasker { |
|
|
/** @var array An array of the class methods to call for a task */ |
|
|
var $taskMap = null; |
|
|
/** @var string The name of the default task */ |
|
|
var $defaultTask = null; |
|
|
/** @var string The name of the current task*/ |
|
|
var $task = null; |
|
|
/** @var array An array of the class methods*/ |
|
|
var $_methods = null; |
|
|
/** @var string A url to redirect to */ |
|
|
var $_redirect = null; |
|
|
/** @var string A message about the operation of the task */ |
|
|
var $_message = null; |
|
|
|
|
|
/** |
|
|
* Constructor |
|
|
*/ |
|
|
function mosAbstractTasker() { |
|
|
$taskMap = array(); |
|
|
$this->_methods = array(); |
|
|
foreach (get_class_methods( get_class( $this ) ) as $method) { |
|
|
$this->_methods[] = strtolower( $method ); |
|
|
} |
|
|
$this->_redirect = ''; |
|
|
$this->_message = ''; |
|
|
} |
|
|
/** |
|
|
* Set a URL to redirect the browser to |
|
|
* @param string A URL |
|
|
*/ |
|
|
function setRedirect( $url, $msg = null ) { |
|
|
$this->_redirect = $url; |
|
|
if ($msg !== null) { |
|
|
$this->_message = $msg; |
|
|
} |
|
|
} |
|
|
/** |
|
|
* Redirects the browser |
|
|
*/ |
|
|
function redirect() { |
|
|
if ($this->_redirect) { |
|
|
mosRedirect( $this->_redirect, $this->_message ); |
|
|
} |
|
|
} |
|
|
/** |
|
|
* Register (map) a task to a method in the class |
|
|
* @param string The task |
|
|
* @param string The name of the method in the derived class to perform for this task |
|
|
*/ |
|
|
function registerTask( $task, $method ) { |
|
|
if (in_array( strtolower( $method ), $this->_methods )) { |
|
|
$this->taskMap[$task] = $method; |
|
|
} else { |
|
|
$this->methodNotFound( $method ); |
|
|
} |
|
|
} |
|
|
/** |
|
|
* Register the default task to perfrom if a mapping is not found |
|
|
* @param string The name of the method in the derived class to perform if the task is not found |
|
|
*/ |
|
|
function registerDefaultTask( $method ) { |
|
|
$this->registerTask( '__default', $method ); |
|
|
} |
|
|
/** |
|
|
* Perform a task by triggering a method in the derived class |
|
|
* @param string The task to perform |
|
|
* @return mixed The value returned by the function |
|
|
*/ |
|
|
function performTask( $task ) { |
|
|
$this->task = $task; |
|
|
|
|
|
if (isset( $this->taskMap[$task] )) { |
|
|
return call_user_func( array( &$this, $this->taskMap[$task] ) ); |
|
|
} else if (isset( $this->taskMap['__default'] )) { |
|
|
return call_user_func( array( &$this, $this->taskMap['__default'] ) ); |
|
|
} else { |
|
|
return $this->taskNotFound( $task ); |
|
|
} |
|
|
} |
|
|
/** |
|
|
* Get the last task that was to be performed |
|
|
* @return string The task that was or is being performed |
|
|
*/ |
|
|
function getTask() { |
|
|
return $this->task; |
|
|
} |
|
|
/** |
|
|
* Basic method if the task is not found |
|
|
* @param string The task |
|
|
* @return null |
|
|
*/ |
|
|
function taskNotFound( $task ) { |
|
|
echo 'Task ' . $task . ' not found'; |
|
|
return null; |
|
|
} |
|
|
/** |
|
|
* Basic method if the registered method is not found |
|
|
* @param string The name of the method in the derived class |
|
|
* @return null |
|
|
*/ |
|
|
function methodNotFound( $name ) { |
|
|
echo 'Method ' . $name . ' not found'; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
| 409 |
* Component database table class |
* Component database table class |
| 410 |
* @package Mambo |
* @package Mambo |
| 411 |
*/ |
*/ |
| 764 |
|
|
| 765 |
// checks template image directory for image, if non found default are loaded |
// checks template image directory for image, if non found default are loaded |
| 766 |
if ( $params->get( 'icons' ) ) { |
if ( $params->get( 'icons' ) ) { |
| 767 |
$image = mosAdminMenus::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, _CMN_PRINT ); |
$mainframe = mosMainFrame::getInstance(); |
| 768 |
|
$image = $mainframe->ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, _CMN_PRINT ); |
| 769 |
} else { |
} else { |
| 770 |
$image = _ICON_SEP .' '. _CMN_PRINT. ' '. _ICON_SEP; |
$image = _ICON_SEP .' '. _CMN_PRINT. ' '. _ICON_SEP; |
| 771 |
} |
} |
| 1128 |
} |
} |
| 1129 |
|
|
| 1130 |
/** |
/** |
|
* Strip slashes from strings or arrays of strings |
|
|
* @param value the input string or array |
|
|
*/ |
|
|
function mosStripslashes(&$value) |
|
|
{ |
|
|
$ret = ''; |
|
|
if (is_string($value)) { |
|
|
$ret = stripslashes($value); |
|
|
} else { |
|
|
if (is_array($value)) { |
|
|
$ret = array(); |
|
|
while (list($key,$val) = each($value)) { |
|
|
$ret[$key] = mosStripslashes($val); |
|
|
} // while |
|
|
} else { |
|
|
$ret = $value; |
|
|
} // if |
|
|
} // if |
|
|
return $ret; |
|
|
} // mosStripSlashes |
|
|
|
|
|
/** |
|
|
* 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 |
|
|
* @param string |
|
|
* @param boolean |
|
|
*/ |
|
|
function mosBindArrayToObject( $array, &$obj, $ignore='', $prefix=NULL, $checkSlashes=true ) { |
|
|
$database = mamboDatabase::getInstance(); |
|
|
return $database->mosBindArrayToOBject($array, $obj, $ignore='', $prefix=NULL, $checkSlashes=true); |
|
|
} |
|
|
|
|
|
function checkIncludePath () { |
|
|
global $mosConfig_absolute_path; |
|
|
if (realpath($mosConfig_absolute_path) === false) die ('Global hack'); |
|
|
} |
|
|
|
|
|
/** |
|
|
* 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 = array(); |
|
|
if (!@is_dir( $path )) { |
|
|
return $arr; |
|
|
} |
|
|
$handle = opendir( $path ); |
|
|
|
|
|
while ($file = readdir($handle)) { |
|
|
$dir = mosPathName( $path.'/'.$file, false ); |
|
|
$isDir = is_dir( $dir ); |
|
|
if (($file <> ".") && ($file <> "..")) { |
|
|
if (preg_match( "/$filter/", $file )) { |
|
|
if ($fullpath) { |
|
|
$arr[] = trim( mosPathName( $path.'/'.$file, false ) ); |
|
|
} else { |
|
|
$arr[] = trim( $file ); |
|
|
} |
|
|
} |
|
|
if ($recurse && $isDir) { |
|
|
$arr2 = mosReadDirectory( $dir, $filter, $recurse, $fullpath ); |
|
|
$arr = array_merge( $arr, $arr2 ); |
|
|
} |
|
|
} |
|
|
} |
|
|
closedir($handle); |
|
|
asort($arr); |
|
|
return $arr; |
|
|
} |
|
|
|
|
|
/** |
|
|
* 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 mosRedirect( $url, $msg='' ) { |
|
|
mamboCore::redirect($url, $msg); |
|
|
} |
|
|
|
|
|
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; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Function to strip additional / or \ in a path name |
|
|
* @param string The path |
|
|
* @param boolean Add trailing slash |
|
|
*/ |
|
|
function mosPathName($p_path,$p_addtrailingslash = true) { |
|
|
$retval = ""; |
|
|
|
|
|
$isWin = (substr(PHP_OS, 0, 3) == 'WIN'); |
|
|
|
|
|
if ($isWin) { |
|
|
$retval = str_replace( '/', '\\', $p_path ); |
|
|
if ($p_addtrailingslash) { |
|
|
if (substr( $retval, -1 ) != '\\') { |
|
|
$retval .= '\\'; |
|
|
} |
|
|
} |
|
|
// Remove double \\ |
|
|
$retval = str_replace( '\\\\', '\\', $retval ); |
|
|
} else { |
|
|
$retval = str_replace( '\\', '/', $p_path ); |
|
|
if ($p_addtrailingslash) { |
|
|
if (substr( $retval, -1 ) != '/') { |
|
|
$retval .= '/'; |
|
|
} |
|
|
} |
|
|
// Remove double // |
|
|
$retval = str_replace('//','/',$retval); |
|
|
} |
|
|
|
|
|
return $retval; |
|
|
} |
|
|
|
|
|
/** |
|
| 1131 |
* Class mosMambot |
* Class mosMambot |
| 1132 |
* @package Mambo |
* @package Mambo |
| 1133 |
*/ |
*/ |
| 1228 |
} |
} |
| 1229 |
|
|
| 1230 |
|
|
| 1231 |
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; |
|
|
} |
|
| 1232 |
/** |
/** |
| 1233 |
* Checks the user agent string against known browsers |
* Tab Creation handler |
| 1234 |
|
* @package Mambo |
| 1235 |
|
* @author Phil Taylor |
| 1236 |
*/ |
*/ |
| 1237 |
function mosGetBrowser( $agent ) { |
class mosTabs { |
| 1238 |
require( "includes/agent_browser.php" ); |
/** @var int Use cookies */ |
| 1239 |
|
var $useCookies = 0; |
|
if (preg_match( "/msie[\/\sa-z]*([\d\.]*)/i", $agent, $m ) |
|
|
&& !preg_match( "/webtv/i", $agent ) |
|
|
&& !preg_match( "/omniweb/i", $agent ) |
|
|
&& !preg_match( "/opera/i", $agent )) { |
|
|
// IE |
|
|
return "MS Internet Explorer $m[1]"; |
|
|
} else if (preg_match( "/netscape.?\/([\d\.]*)/i", $agent, $m )) { |
|
|
// Netscape 6.x, 7.x ... |
|
|
return "Netscape $m[1]"; |
|
|
} else if ( preg_match( "/mozilla[\/\sa-z]*([\d\.]*)/i", $agent, $m ) |
|
|
&& !preg_match( "/gecko/i", $agent ) |
|
|
&& !preg_match( "/compatible/i", $agent ) |
|
|
&& !preg_match( "/opera/i", $agent ) |
|
|
&& !preg_match( "/galeon/i", $agent ) |
|
|
&& !preg_match( "/safari/i", $agent )) { |
|
|
// Netscape 3.x, 4.x ... |
|
|
return "Netscape $m[2]"; |
|
|
} else { |
|
|
// Other |
|
|
$found = false; |
|
|
foreach ($browserSearchOrder as $key) { |
|
|
if (preg_match( "/$key.?\/([\d\.]*)/i", $agent, $m )) { |
|
|
$name = "$browsersAlias[$key] $m[1]"; |
|
|
return $name; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return 'Unknown'; |
|
|
} |
|
| 1240 |
|
|
| 1241 |
/** |
/** |
| 1242 |
* Checks the user agent string against known operating systems |
* Constructor |
| 1243 |
|
* Includes files needed for displaying tabs and sets cookie options |
| 1244 |
|
* @param int useCookies, if set to 1 cookie will hold last used tab between page refreshes |
| 1245 |
*/ |
*/ |
| 1246 |
function mosGetOS( $agent ) { |
function mosTabs($useCookies) { |
| 1247 |
require( "includes/agent_os.php" ); |
global $mosConfig_live_site; |
| 1248 |
|
echo "<link id=\"luna-tab-style-sheet\" type=\"text/css\" rel=\"stylesheet\" href=\"" . $mosConfig_live_site. "/includes/js/tabs/tabpane.css\" />"; |
| 1249 |
foreach ($osSearchOrder as $key) { |
echo "<script type=\"text/javascript\" src=\"". $mosConfig_live_site . "/includes/js/tabs/tabpane.js\"></script>"; |
| 1250 |
if (preg_match( "/$key/i", $agent )) { |
$this->useCookies = $useCookies; |
|
return $osAlias[$key]; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
return 'Unknown'; |
|
| 1251 |
} |
} |
| 1252 |
|
|
| 1253 |
/** |
/** |
| 1254 |
* @param string SQL with ordering As value and 'name field' AS text |
* creates a tab pane and creates JS obj |
| 1255 |
* @param integer The length of the truncated headline |
* @param string The Tab Pane Name |
| 1256 |
*/ |
*/ |
| 1257 |
function mosGetOrderingList( $sql, $chop='30' ) { |
function startPane($id){ |
| 1258 |
global $database; |
echo "<div class=\"tab-page\" id=\"".$id."\">"; |
| 1259 |
|
echo "<script type=\"text/javascript\">\n"; |
| 1260 |
$order = array(); |
echo " var tabPane1 = new WebFXTabPane( document.getElementById( \"".$id."\" ), ".$this->useCookies." )\n"; |
| 1261 |
$database->setQuery( $sql ); |
echo "</script>\n"; |
|
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; |
|
| 1262 |
} |
} |
| 1263 |
|
|
| 1264 |
/** |
/** |
| 1265 |
* Makes a variable safe to display in forms |
* Ends Tab Pane |
|
* |
|
|
* Object parameters that are non-string, array, object or start with underscore |
|
|
* will be converted |
|
|
* @param object An object to be parsed |
|
|
* @param int The optional quote style for the htmlspecialchars function |
|
|
* @param string|array An optional single field name or array of field names not |
|
|
* to be parsed (eg, for a textarea) |
|
| 1266 |
*/ |
*/ |
| 1267 |
function mosMakeHtmlSafe( &$mixed, $quote_style=ENT_QUOTES, $exclude_keys='' ) { |
function endPane() { |
| 1268 |
if (is_object( $mixed )) { |
echo "</div>"; |
|
foreach (get_object_vars( $mixed ) as $k => $v) { |
|
|
if (is_array( $v ) || is_object( $v ) || $v == NULL || substr( $k, 1, 1 ) == '_' ) { |
|
|
continue; |
|
|
} |
|
|
if (is_string( $exclude_keys ) && $k == $exclude_keys) { |
|
|
continue; |
|
|
} else if (is_array( $exclude_keys ) && in_array( $k, $exclude_keys )) { |
|
|
continue; |
|
|
} |
|
|
$mixed->$k = htmlspecialchars( $v, $quote_style ); |
|
|
} |
|
|
} |
|
| 1269 |
} |
} |
| 1270 |
|
|
| 1271 |
/** |
/* |
| 1272 |
* Checks whether a menu option is within the users access level |
* Creates a tab with title text and starts that tabs page |
| 1273 |
* @param int Item id number |
* @param tabText - This is what is displayed on the tab |
| 1274 |
* @param string The menu option |
* @param paneid - This is the parent pane to build this tab on |
|
* @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 |
|
| 1275 |
*/ |
*/ |
| 1276 |
function mosMenuCheck( $Itemid, $menu_option, $task, $gid ) { |
function startTab( $tabText, $paneid ) { |
| 1277 |
$menuhandler = mosMenuHandler::getInstance(); |
echo "<div class=\"tab-page\" id=\"".$paneid."\">"; |
| 1278 |
return $menuhandler->menuCheck($Itemid, $menu_option, $task, $gid); |
echo "<h2 class=\"tab\">".$tabText."</h2>"; |
| 1279 |
|
echo "<script type=\"text/javascript\">\n"; |
| 1280 |
|
echo " tabPane1.addTabPage( document.getElementById( \"".$paneid."\" ) );"; |
| 1281 |
|
echo "</script>"; |
| 1282 |
} |
} |
| 1283 |
|
|
| 1284 |
/** |
/* |
| 1285 |
* Returns formated date according to current local and adds time offset |
* Ends a tab page |
|
* @param string date in datetime format |
|
|
* @param string format optional format for strftime |
|
|
* @param offset time offset if different than global one |
|
|
* @returns formated date |
|
| 1286 |
*/ |
*/ |
| 1287 |
function mosFormatDate( $date, $format="", $offset="" ){ |
function endTab() { |
| 1288 |
global $mosConfig_offset; |
echo "</div>"; |
|
if ( $format == '' ) { |
|
|
// %Y-%m-%d %H:%M:%S |
|
|
$format = _DATE_FORMAT_LC; |
|
|
} |
|
|
if ( $offset == '' ) { |
|
|
$offset = $mosConfig_offset; |
|
|
} |
|
|
if ( $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 ? strftime( $format, $date + ($offset*60*60) ) : '-'; |
|
| 1289 |
} |
} |
|
return $date; |
|
| 1290 |
} |
} |
| 1291 |
|
|
|
/** |
|
|
* Returns current date according to current local and time offset |
|
|
* @param string format optional format for strftime |
|
|
* @returns current date |
|
|
*/ |
|
|
function mosCurrentDate( $format="" ) { |
|
|
global $mosConfig_offset; |
|
|
if ($format=="") { |
|
|
$format = _DATE_FORMAT_LC; |
|
|
} |
|
|
$date = strftime( $format, time() + ($mosConfig_offset*60*60) ); |
|
|
return $date; |
|
|
} |
|
| 1292 |
|
|
| 1293 |
/** |
class mosCommonHTML { |
|
* 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; |
|
| 1294 |
|
|
| 1295 |
if ( $width ) { |
function ContentLegend( ) { |
| 1296 |
$width = ', WIDTH, \''.$width .'\''; |
?> |
| 1297 |
} |
<table cellspacing="0" cellpadding="4" border="0" align="center"> |
| 1298 |
if ( $title ) { |
<tr align="center"> |
| 1299 |
$title = ', CAPTION, \''.$title .'\''; |
<td> |
| 1300 |
} |
<img src="images/publish_y.png" width="12" height="12" border="0" alt="Pending" /> |
| 1301 |
if ( !$text ) { |
</td> |
| 1302 |
$image = $mosConfig_live_site . '/includes/js/ThemeOffice/'. $image; |
<td> |
| 1303 |
$text = '<img src="'. $image .'" border="0" />'; |
Published, but is <u>Pending</u> | |
| 1304 |
} |
</td> |
| 1305 |
$style = 'style="text-decoration: none; color: #333;"'; |
<td> |
| 1306 |
if ( $href ) { |
<img src="images/publish_g.png" width="12" height="12" border="0" alt="Visible" /> |
| 1307 |
$style = ''; |
</td> |
| 1308 |
} |
<td> |
| 1309 |
$tip = "<a href=\"". $href ."\" onMouseOver=\"return overlib('" . $tooltip . "'". $title .", BELOW, RIGHT". $width .");\" onmouseout=\"return nd();\" ". $style .">". $text ."</a>"; |
Published and is <u>Current</u> | |
| 1310 |
return $tip; |
</td> |
| 1311 |
|
<td> |
| 1312 |
|
<img src="images/publish_r.png" width="12" height="12" border="0" alt="Finished" /> |
| 1313 |
|
</td> |
| 1314 |
|
<td> |
| 1315 |
|
Published, but has <u>Expired</u> | |
| 1316 |
|
</td> |
| 1317 |
|
<td> |
| 1318 |
|
<img src="images/publish_x.png" width="12" height="12" border="0" alt="Finished" /> |
| 1319 |
|
</td> |
| 1320 |
|
<td> |
| 1321 |
|
Not Published |
| 1322 |
|
</td> |
| 1323 |
|
</tr> |
| 1324 |
|
<tr> |
| 1325 |
|
<td colspan="8" align="center"> |
| 1326 |
|
Click on icon to toggle state. |
| 1327 |
|
</td> |
| 1328 |
|
</tr> |
| 1329 |
|
</table> |
| 1330 |
|
<?php |
| 1331 |
} |
} |
| 1332 |
|
|
| 1333 |
/** |
function menuLinksContent( &$menus ) { |
| 1334 |
* Utility function to provide Warning Icons |
?> |
| 1335 |
* @param string Warning text |
<script language="javascript" type="text/javascript"> |
| 1336 |
* @param string Box title |
function go2( pressbutton, menu, id ) { |
| 1337 |
* @returns HTML code for Warning |
var form = document.adminForm; |
|
*/ |
|
|
function mosWarning($warning, $title='Mambo Warning') { |
|
|
global $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 $tip; |
|
|
} |
|
| 1338 |
|
|
| 1339 |
function mosCreateGUID(){ |
if (pressbutton == 'go2menu') { |
| 1340 |
srand((double)microtime()*1000000); |
form.menu.value = menu; |
| 1341 |
$r = rand ; |
submitform( pressbutton ); |
| 1342 |
$u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
return; |
|
$m = md5 ($u); |
|
|
return($m); |
|
| 1343 |
} |
} |
| 1344 |
|
|
| 1345 |
function mosCompressID( $ID ){ |
if (pressbutton == 'go2menuitem') { |
| 1346 |
return(Base64_encode(pack("H*",$ID))); |
form.menu.value = menu; |
| 1347 |
|
form.menuid.value = id; |
| 1348 |
|
submitform( pressbutton ); |
| 1349 |
|
return; |
| 1350 |
} |
} |
|
|
|
|
function mosExpandID( $ID ) { |
|
|
return ( implode(unpack("H*",Base64_decode($ID)), '') ); |
|
| 1351 |
} |
} |
| 1352 |
|
</script> |
| 1353 |
/** |
<?php |
| 1354 |
* Function to create a mail object for futher use (uses phpMailer) |
foreach( $menus as $menu ) { |
| 1355 |
* @param string From e-mail address |
?> |
| 1356 |
* @param string From name |
<tr> |
| 1357 |
* @param string E-mail subject |
<td colspan="2"> |
| 1358 |
* @param string Message body |
<hr /> |
| 1359 |
* @return object Mail object |
</td> |
| 1360 |
*/ |
</tr> |
| 1361 |
function mosCreateMail( $from='', $fromname='', $subject, $body ) { |
<tr> |
| 1362 |
global $mosConfig_absolute_path, $mosConfig_sendmail; |
<td width="90px" valign="top"> |
| 1363 |
global $mosConfig_smtpauth, $mosConfig_smtpuser; |
Menu |
| 1364 |
global $mosConfig_smtppass, $mosConfig_smtphost; |
</td> |
| 1365 |
global $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_mailer; |
<td> |
| 1366 |
|
<a href="javascript:go2( 'go2menu', '<?php echo $menu->menutype; ?>' );" title="Go to Menu"> |
| 1367 |
$mail = new mosPHPMailer(); |
<?php echo $menu->menutype; ?> |
| 1368 |
|
</a> |
| 1369 |
$mail->PluginDir = $mosConfig_absolute_path .'/includes/phpmailer/'; |
</td> |
| 1370 |
$mail->SetLanguage( 'en', $mosConfig_absolute_path . '/includes/phpmailer/language/' ); |
</tr> |
| 1371 |
$mail->CharSet = substr_replace(_ISO, '', 0, 8); |
<tr> |
| 1372 |
$mail->IsMail(); |
<td width="90px" valign="top"> |
| 1373 |
$mail->From = $from ? $from : $mosConfig_mailfrom; |
Link Name |
| 1374 |
$mail->FromName = $fromname ? $fromname : $mosConfig_fromname; |
</td> |
| 1375 |
$mail->Mailer = $mosConfig_mailer; |
<td> |
| 1376 |
|
<strong> |
| 1377 |
// Add smtp values if needed |
<a href="javascript:go2( 'go2menuitem', '<?php echo $menu->menutype; ?>', '<?php echo $menu->id; ?>' );" title="Go to Menu Item"> |
| 1378 |
if ( $mosConfig_mailer == 'smtp' ) { |
<?php echo $menu->name; ?> |
| 1379 |
$mail->SMTPAuth = $mosConfig_smtpauth; |
</a> |
| 1380 |
$mail->Username = $mosConfig_smtpuser; |
</strong> |
| 1381 |
$mail->Password = $mosConfig_smtppass; |
</td> |
| 1382 |
$mail->Host = $mosConfig_smtphost; |
</tr> |
| 1383 |
} else |
<tr> |
| 1384 |
|
<td width="90px" valign="top"> |
| 1385 |
// Set sendmail path |
State |
| 1386 |
if ( $mosConfig_mailer == 'sendmail' ) { |
</td> |
| 1387 |
if (isset($mosConfig_sendmail)) |
<td> |
| 1388 |
$mail->Sendmail = $mosConfig_sendmail; |
<?php |
| 1389 |
} // if |
switch ( $menu->published ) { |
| 1390 |
|
case -2: |
| 1391 |
$mail->Subject = $subject; |
echo '<font color="red">Trashed</font>'; |
| 1392 |
$mail->Body = $body; |
break; |
| 1393 |
|
case 0: |
| 1394 |
return $mail; |
echo 'UnPublished'; |
| 1395 |
} |
break; |
| 1396 |
|
case 1: |
| 1397 |
/** |
default: |
| 1398 |
* Mail function (uses phpMailer) |
echo '<font color="green">Published</font>'; |
| 1399 |
* @param string From e-mail address |
break; |
|
* @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 ) { |
|
|
global $mosConfig_debug; |
|
|
$mail = mosCreateMail( $from, $fromname, $subject, $body ); |
|
|
|
|
|
// activate HTML formatted emails |
|
|
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; |
|
|
} // mosMail |
|
|
|
|
|
/** |
|
|
* Random password generator |
|
|
* @return password |
|
|
*/ |
|
|
function mosMakePassword() { |
|
|
$salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
|
|
$len = strlen($salt); |
|
|
$makepass=""; |
|
|
mt_srand(10000000*(double)microtime()); |
|
|
for ($i = 0; $i < 8; $i++) |
|
|
$makepass .= $salt[mt_rand(0,$len - 1)]; |
|
|
return $makepass; |
|
|
} |
|
|
|
|
|
if (!function_exists('html_entity_decode')) { |
|
|
/** |
|
|
* html_entity_decode function for backward compatability in PHP |
|
|
* @param string |
|
|
* @param string |
|
|
*/ |
|
|
function html_entity_decode ($string, $opt = ENT_COMPAT) { |
|
|
|
|
|
$trans_tbl = get_html_translation_table (HTML_ENTITIES); |
|
|
$trans_tbl = array_flip ($trans_tbl); |
|
|
|
|
|
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); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
* Tab Creation handler |
|
|
* @package Mambo |
|
|
* @author Phil Taylor |
|
|
*/ |
|
|
class mosTabs { |
|
|
/** @var int Use cookies */ |
|
|
var $useCookies = 0; |
|
|
|
|
|
/** |
|
|
* Constructor |
|
|
* Includes files needed for displaying tabs and sets cookie options |
|
|
* @param int useCookies, if set to 1 cookie will hold last used tab between page refreshes |
|
|
*/ |
|
|
function mosTabs($useCookies) { |
|
|
global $mosConfig_live_site; |
|
|
echo "<link id=\"luna-tab-style-sheet\" type=\"text/css\" rel=\"stylesheet\" href=\"" . $mosConfig_live_site. "/includes/js/tabs/tabpane.css\" />"; |
|
|
echo "<script type=\"text/javascript\" src=\"". $mosConfig_live_site . "/includes/js/tabs/tabpane.js\"></script>"; |
|
|
$this->useCookies = $useCookies; |
|
|
} |
|
|
|
|
|
/** |
|
|
* creates a tab pane and creates JS obj |
|
|
* @param string The Tab Pane Name |
|
|
*/ |
|
|
function startPane($id){ |
|
|
echo "<div class=\"tab-page\" id=\"".$id."\">"; |
|
|
echo "<script type=\"text/javascript\">\n"; |
|
|
echo " var tabPane1 = new WebFXTabPane( document.getElementById( \"".$id."\" ), ".$this->useCookies." )\n"; |
|
|
echo "</script>\n"; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Ends Tab Pane |
|
|
*/ |
|
|
function endPane() { |
|
|
echo "</div>"; |
|
|
} |
|
|
|
|
|
/* |
|
|
* Creates a tab with title text and starts that tabs page |
|
|
* @param tabText - This is what is displayed on the tab |
|
|
* @param paneid - This is the parent pane to build this tab on |
|
|
*/ |
|
|
function startTab( $tabText, $paneid ) { |
|
|
echo "<div class=\"tab-page\" id=\"".$paneid."\">"; |
|
|
echo "<h2 class=\"tab\">".$tabText."</h2>"; |
|
|
echo "<script type=\"text/javascript\">\n"; |
|
|
echo " tabPane1.addTabPage( document.getElementById( \"".$paneid."\" ) );"; |
|
|
echo "</script>"; |
|
|
} |
|
|
|
|
|
/* |
|
|
* Ends a tab page |
|
|
*/ |
|
|
function endTab() { |
|
|
echo "</div>"; |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* Common HTML Output Files |
|
|
* @package Mambo |
|
|
*/ |
|
|
class mosAdminMenus { |
|
|
/** |
|
|
* build the select list for Menu Ordering |
|
|
*/ |
|
|
function Ordering( &$row, $id ) { |
|
|
global $database; |
|
|
|
|
|
if ( $id ) { |
|
|
$order = mosGetOrderingList( "SELECT ordering AS value, name AS text" |
|
|
. "\n FROM #__menu" |
|
|
. "\n WHERE menutype='". $row->menutype ."'" |
|
|
. "\n AND parent='". $row->parent ."'" |
|
|
. "\n AND published != '-2'" |
|
|
. "\n ORDER BY ordering" |
|
|
); |
|
|
$ordering = mosHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); |
|
|
} else { |
|
|
$ordering = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'. _CMN_NEW_ITEM_LAST; |
|
|
} |
|
|
return $ordering; |
|
|
} |
|
|
|
|
|
/** |
|
|
* build the select list for access level |
|
|
*/ |
|
|
function Access( &$row ) { |
|
|
global $database; |
|
|
|
|
|
$query = 'SELECT id AS value, name AS text FROM #__groups ORDER BY id'; |
|
|
$database->setQuery( $query ); |
|
|
$groups = $database->loadObjectList(); |
|
|
$access = mosHTML::selectList( $groups, 'access', 'class="inputbox" size="3"', 'value', 'text', intval( $row->access ) ); |
|
|
return $access; |
|
|
} |
|
|
|
|
|
/** |
|
|
* build the select list for parent item |
|
|
*/ |
|
|
function Parent( &$row ) { |
|
|
global $database; |
|
|
|
|
|
// get a list of the menu items |
|
|
$query = "SELECT m.*" |
|
|
. "\n FROM #__menu m" |
|
|
. "\n WHERE menutype='$row->menutype'" |
|
|
. "\n AND published <> -2" |
|
|
. "\n ORDER BY ordering" |
|
|
; |
|
|
$database->setQuery( $query ); |
|
|
$mitems = $database->loadObjectList(); |
|
|
|
|
|
// establish the hierarchy of the menu |
|
|
$children = array(); |
|
|
// first pass - collect children |
|
|
foreach ( $mitems as $v ) { |
|
|
$pt = $v->parent; |
|
|
$list = @$children[$pt] ? $children[$pt] : array(); |
|
|
array_push( $list, $v ); |
|
|
$children[$pt] = $list; |
|
|
} |
|
|
// second pass - get an indent list of the items |
|
|
$list = mosTreeRecurse( 0, '', array(), $children, 9999, 0, 0 ); |
|
|
|
|
|
// assemble menu items to the array |
|
|
$mitems = array(); |
|
|
$mitems[] = mosHTML::makeOption( '0', 'Top' ); |
|
|
$this_treename = ''; |
|
|
foreach ( $list as $item ) { |
|
|
if ( $this_treename ) { |
|
|
if ( $item->id != $row->id && strpos( $item->treename, $this_treename ) === false) { |
|
|
$mitems[] = mosHTML::makeOption( $item->id, $item->treename ); |
|
|
} |
|
|
} else { |
|
|
if ( $item->id != $row->id ) { |
|
|
$mitems[] = mosHTML::makeOption( $item->id, $item->treename ); |
|
|
} else { |
|
|
$this_treename = "$item->treename/"; |
|
|
} |
|
|
} |
|
|
} |
|
|
$parent = mosHTML::selectList( $mitems, 'parent', 'class="inputbox" size="1"', 'value', 'text', $row->parent ); |
|
|
return $parent; |
|
|
} |
|
|
|
|
|
/** |
|
|
* build a radio button option for published state |
|
|
*/ |
|
|
function Published( &$row ) { |
|
|
$published = mosHTML::yesnoRadioList( 'published', 'class="inputbox"', $row->published ); |
|
|
return $published; |
|
|
} |
|
|
|
|
|
/** |
|
|
* build the link/url of a menu item |
|
|
*/ |
|
|
function Link( &$row, $id, $link=NULL ) { |
|
|
if ( $id ) { |
|
|
if ( $link ) { |
|
|
$link = $row->link; |
|
|
} else { |
|
|
$link = $row->link .'&Itemid='. $row->id; |
|
|
} |
|
|
} else { |
|
|
$link = NULL; |
|
| 1400 |
} |
} |
| 1401 |
return $link; |
?> |
| 1402 |
|
</td> |
| 1403 |
|
</tr> |
| 1404 |
|
<?php |
| 1405 |
} |
} |
| 1406 |
|
?> |
| 1407 |
/** |
<input type="hidden" name="menu" value="" /> |
| 1408 |
* build the select list for target window |
<input type="hidden" name="menuid" value="" /> |
| 1409 |
*/ |
<?php |
|
function Target( &$row ) { |
|
|
$click[] = mosHTML::makeOption( '0', 'Parent Window With Browser Navigation' ); |
|
|
$click[] = mosHTML::makeOption( '1', 'New Window With Browser Navigation' ); |
|
|
$click[] = mosHTML::makeOption( '2', 'New Window Without Browser Navigation' ); |
|
|
$target = mosHTML::selectList( $click, 'browserNav', 'class="inputbox" size="4"', 'value', 'text', intval( $row->browserNav ) ); |
|
|
return $target; |
|
| 1410 |
} |
} |
| 1411 |
|
|
| 1412 |
/** |
function menuLinksSecCat( &$menus ) { |
| 1413 |
* build the multiple select list for Menu Links/Pages |
?> |
| 1414 |
*/ |
<script language="javascript" type="text/javascript"> |
| 1415 |
function MenuLinks( &$lookup, $all=NULL, $none=NULL ) { |
function go2( pressbutton, menu, id ) { |
| 1416 |
global $database; |
var form = document.adminForm; |
|
|
|
|
// get a list of the menu items |
|
|
$database->setQuery( "SELECT m.*" |
|
|
. "\n FROM #__menu m" |
|
|
. "\n WHERE type != 'separator'" |
|
|
. "\n AND link NOT LIKE '%tp:/%'" |
|
|
. "\n AND published = '1'" |
|
|
. "\n ORDER BY menutype, parent, ordering" |
|
|
); |
|
|
$mitems = $database->loadObjectList(); |
|
|
$mitems_temp = $mitems; |
|
| 1417 |
|
|
| 1418 |
// establish the hierarchy of the menu |
if (pressbutton == 'go2menu') { |
| 1419 |
$children = array(); |
form.menu.value = menu; |
| 1420 |
// first pass - collect children |
submitform( pressbutton ); |
| 1421 |
foreach ( $mitems as $v ) { |
return; |
|
$id = $v->id; |
|
|
$pt = $v->parent; |
|
|
$list = @$children[$pt] ? $children[$pt] : array(); |
|
|
array_push( $list, $v ); |
|
|
$children[$pt] = $list; |
|
| 1422 |
} |
} |
|
// second pass - get an indent list of the items |
|
|
$list = mosTreeRecurse( intval( $mitems[0]->parent ), '', array(), $children, 9999, 0, 0 ); |
|
| 1423 |
|
|
| 1424 |
// Code that adds menu name to Display of Page(s) |
if (pressbutton == 'go2menuitem') { |
| 1425 |
$text_count = "0"; |
form.menu.value = menu; |
| 1426 |
$mitems_spacer = $mitems_temp[0]->menutype; |
form.menuid.value = id; |
| 1427 |
foreach ($list as $list_a) { |
submitform( pressbutton ); |
| 1428 |
foreach ($mitems_temp as $mitems_a) { |
return; |
|
if ($mitems_a->id == $list_a->id) { |
|
|
// Code that inserts the blank line that seperates different menus |
|
|
if ($mitems_a->menutype <> $mitems_spacer) { |
|
|
$list_temp[] = mosHTML::makeOption( -999, '----' ); |
|
|
$mitems_spacer = $mitems_a->menutype; |
|
| 1429 |
} |
} |
|
$text = $mitems_a->menutype." | ".$list_a->treename; |
|
|
$list_temp[] = mosHTML::makeOption( $list_a->id, $text ); |
|
|
if ( strlen($text) > $text_count) { |
|
|
$text_count = strlen($text); |
|
| 1430 |
} |
} |
| 1431 |
|
</script> |
| 1432 |
|
<?php |
| 1433 |
|
foreach( $menus as $menu ) { |
| 1434 |
|
?> |
| 1435 |
|
<tr> |
| 1436 |
|
<td colspan="2"> |
| 1437 |
|
<hr/> |
| 1438 |
|
</td> |
| 1439 |
|
</tr> |
| 1440 |
|
<tr> |
| 1441 |
|
<td width="90px" valign="top"> |
| 1442 |
|
Menu |
| 1443 |
|
</td> |
| 1444 |
|
<td> |
| 1445 |
|
<a href="javascript:go2( 'go2menu', '<?php echo $menu->menutype; ?>' );" title="Go to Menu"> |
| 1446 |
|
<?php echo $menu->menutype; ?> |
| 1447 |
|
</a> |
| 1448 |
|
</td> |
| 1449 |
|
</tr> |
| 1450 |
|
<tr> |
| 1451 |
|
<td width="90px" valign="top"> |
| 1452 |
|
Type |
| 1453 |
|
</td> |
| 1454 |
|
<td> |
| 1455 |
|
<?php echo $menu->type; ?> |
| 1456 |
|
</td> |
| 1457 |
|
</tr> |
| 1458 |
|
<tr> |
| 1459 |
|
<td width="90px" valign="top"> |
| 1460 |
|
Item Name |
| 1461 |
|
</td> |
| 1462 |
|
<td> |
| 1463 |
|
<strong> |
| 1464 |
|
<a href="javascript:go2( 'go2menuitem', '<?php echo $menu->menutype; ?>', '<?php echo $menu->id; ?>' );" title="Go to Menu Item"> |
| 1465 |
|
<?php echo $menu->name; ?> |
| 1466 |
|
</a> |
| 1467 |
|
</strong> |
| 1468 |
|
</td> |
| 1469 |
|
</tr> |
| 1470 |
|
<tr> |
| 1471 |
|
<td width="90px" valign="top"> |
| 1472 |
|
State |
| 1473 |
|
</td> |
| 1474 |
|
<td> |
| 1475 |
|
<?php |
| 1476 |
|
switch ( $menu->published ) { |
| 1477 |
|
case -2: |
| 1478 |
|
echo '<font color="red">Trashed</font>'; |
| 1479 |
|
break; |
| 1480 |
|
case 0: |
| 1481 |
|
echo 'UnPublished'; |
| 1482 |
|
break; |
| 1483 |
|
case 1: |
| 1484 |
|
default: |
| 1485 |
|
echo '<font color="green">Published</font>'; |
| 1486 |
|
break; |
| 1487 |
} |
} |
| 1488 |
|
?> |
| 1489 |
|
</td> |
| 1490 |
|
</tr> |
| 1491 |
|
<?php |
| 1492 |
} |
} |
| 1493 |
|
?> |
| 1494 |
|
<input type="hidden" name="menu" value="" /> |
| 1495 |
|
<input type="hidden" name="menuid" value="" /> |
| 1496 |
|
<?php |
| 1497 |
} |
} |
|
$list = $list_temp; |
|
| 1498 |
|
|
| 1499 |
$mitems = array(); |
function checkedOut( &$row, $overlib=1 ) { |
| 1500 |
if ( $all ) { |
$hover = ''; |
| 1501 |
// prepare an array with 'all' as the first item |
if ( $overlib ) { |
| 1502 |
$mitems[] = mosHTML::makeOption( 0, 'All' ); |
$date = mosFormatDate( $row->checked_out_time, '%A, %d %B %Y' ); |
| 1503 |
// adds space, in select box which is not saved |
$time = mosFormatDate( $row->checked_out_time, '%H:%M' ); |
| 1504 |
$mitems[] = mosHTML::makeOption( -999, '----' ); |
$checked_out_text = '<table>'; |
| 1505 |
} |
$checked_out_text .= '<tr><td>'. $row->editor .'</td></tr>'; |
| 1506 |
if ( $none ) { |
$checked_out_text .= '<tr><td>'. $date .'</td></tr>'; |
| 1507 |
// prepare an array with 'all' as the first item |
$checked_out_text .= '<tr><td>'. $time .'</td></tr>'; |
| 1508 |
$mitems[] = mosHTML::makeOption( -999, 'None' ); |
$checked_out_text .= '</table>'; |
| 1509 |
// adds space, in select box which is not saved |
$hover = 'onMouseOver="return overlib(\''. $checked_out_text .'\', CAPTION, \'Checked Out\', BELOW, RIGHT);" onMouseOut="return nd();"'; |
|
$mitems[] = mosHTML::makeOption( -999, '----' ); |
|
|
} |
|
|
// append the rest of the menu items to the array |
|
|
foreach ($list as $item) { |
|
|
$mitems[] = mosHTML::makeOption( $item->value, $item->text ); |
|
|
} |
|
|
$pages = mosHTML::selectList( $mitems, 'selections[]', 'class="inputbox" size="26" multiple="multiple"', 'value', 'text', $lookup ); |
|
|
return $pages; |
|
| 1510 |
} |
} |
| 1511 |
|
$checked = '<img src="images/checked_out.png" '. $hover .'/>'; |
| 1512 |
|
|
| 1513 |
|
return $checked; |
|
/** |
|
|
* build the select list to choose a category |
|
|
*/ |
|
|
function Category( &$menu, $id, $javascript='' ) { |
|
|
global $database; |
|
|
|
|
|
$query = "SELECT c.id AS `value`, c.section AS `id`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" |
|
|
. "\n FROM #__sections AS s" |
|
|
. "\n INNER JOIN #__categories AS c ON c.section = s.id" |
|
|
. "\n WHERE s.scope = 'content'" |
|
|
. "\n ORDER BY s.name,c.name" |
|
|
; |
|
|
$database->setQuery( $query ); |
|
|
$rows = $database->loadObjectList(); |
|
|
$category = ''; |
|
|
if ( $id ) { |
|
|
foreach ( $rows as $row ) { |
|
|
if ( $row->value == $menu->componentid ) { |
|
|
$category = $row->text; |
|
|
} |
|
|
} |
|
|
$category .= '<input type="hidden" name="componentid" value="'. $menu->componentid .'" />'; |
|
|
$category .= '<input type="hidden" name="link" value="'. $menu->link .'" />'; |
|
|
} else { |
|
|
$category = mosHTML::selectList( $rows, 'componentid', 'class="inputbox" size="10"'. $javascript, 'value', 'text' ); |
|
|
$category .= '<input type="hidden" name="link" value="" />'; |
|
|
} |
|
|
return $category; |
|
| 1514 |
} |
} |
| 1515 |
|
|
| 1516 |
/** |
/* |
| 1517 |
* build the select list to choose a section |
* Loads all necessary files for JS Overlib tooltips |
| 1518 |
*/ |
*/ |
| 1519 |
function Section( &$menu, $id, $all=0 ) { |
function loadOverlib() { |
| 1520 |
global $database; |
global $mosConfig_live_site; |
| 1521 |
|
?> |
| 1522 |
$query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`" |
<script language="Javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_mini.js"></script> |
| 1523 |
. "\n FROM #__sections AS s" |
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div> |
| 1524 |
. "\n WHERE s.scope = 'content'" |
<?php |
|
. "\n ORDER BY s.name" |
|
|
; |
|
|
$database->setQuery( $query ); |
|
|
if ( $all ) { |
|
|
$rows[] = mosHTML::makeOption( 0, '- All Sections -' ); |
|
|
$rows = array_merge( $rows, $database->loadObjectList() ); |
|
|
} else { |
|
|
$rows = $database->loadObjectList(); |
|
| 1525 |
} |
} |
| 1526 |
|
|
|
if ( $id ) { |
|
|
foreach ( $rows as $row ) { |
|
|
if ( $row->value == $menu->componentid ) { |
|
|
$section = $row->text; |
|
|
} |
|
|
} |
|
|
$section .= '<input type="hidden" name="componentid" value="'. $menu->componentid .'" />'; |
|
|
$section .= '<input type="hidden" name="link" value="'. $menu->link .'" />'; |
|
|
} else { |
|
|
$section = mosHTML::selectList( $rows, 'componentid', 'class="inputbox" size="10"', 'value', 'text' ); |
|
|
$section .= '<input type="hidden" name="link" value="" />'; |
|
|
} |
|
|
return $section; |
|
|
} |
|
| 1527 |
|
|
| 1528 |
/** |
/* |
| 1529 |
* build the select list to choose a component |
* Loads all necessary files for JS Calendar |
| 1530 |
*/ |
*/ |
| 1531 |
function Component( &$menu, $id ) { |
function loadCalendar() { |
| 1532 |
global $database; |
global $mosConfig_live_site; |
| 1533 |
|
?> |
| 1534 |
$query = "SELECT c.id AS value, c.name AS text, c.link" |
<link rel="stylesheet" type="text/css" media="all" href="<?php echo $mosConfig_live_site;?>/includes/js/calendar/calendar-mos.css" title="green" /> |
| 1535 |
. "\n FROM #__components AS c" |
<!-- import the calendar script --> |
| 1536 |
. "\n WHERE c.link <> ''" |
<script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/calendar/calendar.js"></script> |
| 1537 |
. "\n ORDER BY c.name" |
<!-- import the language module --> |
| 1538 |
; |
<script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/calendar/lang/calendar-en.js"></script> |
| 1539 |
$database->setQuery( $query ); |
<?php |
|
$rows = $database->loadObjectList( ); |
|
|
if ( $id ) { |
|
|
// existing component, just show name |
|
|
foreach ( $rows as $row ) { |
|
|
if ( $row->value == $menu->componentid ) { |
|
|
$component = $row->text; |
|
|
} |
|
| 1540 |
} |
} |
| 1541 |
$component .= '<input type="hidden" name="componentid" value="'. $menu->componentid .'" />'; |
|
| 1542 |
|
function AccessProcessing( &$row, $i ) { |
| 1543 |
|
if ( !$row->access ) { |
| 1544 |
|
$color_access = 'style="color: green;"'; |
| 1545 |
|
$task_access = 'accessregistered'; |
| 1546 |
|
} else if ( $row->access == 1 ) { |
| 1547 |
|
$color_access = 'style="color: red;"'; |
| 1548 |
|
$task_access = 'accessspecial'; |
| 1549 |
} else { |
} else { |
| 1550 |
$component = mosHTML::selectList( $rows, 'componentid', 'class="inputbox" size="10"', 'value', 'text' ); |
$color_access = 'style="color: black;"'; |
| 1551 |
} |
$task_access = 'accesspublic'; |
|
return $component; |
|
| 1552 |
} |
} |
| 1553 |
|
|
| 1554 |
/** |
$href = ' |
| 1555 |
* build the select list to choose a component |
<a href="javascript: void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $task_access .'\')" '. $color_access .'> |
| 1556 |
*/ |
'. $row->groupname .' |
| 1557 |
function ComponentName( &$menu, $id ) { |
</a>' |
|
global $database; |
|
|
|
|
|
$query = "SELECT c.id AS value, c.name AS text, c.link" |
|
|
. "\n FROM #__components AS c" |
|
|
. "\n WHERE c.link <> ''" |
|
|
. "\n ORDER BY c.name" |
|
| 1558 |
; |
; |
|
$database->setQuery( $query ); |
|
|
$rows = $database->loadObjectList( ); |
|
|
|
|
|
$component = 'Component'; |
|
|
foreach ( $rows as $row ) { |
|
|
if ( $row->value == $menu->componentid ) { |
|
|
$component = $row->text; |
|
|
} |
|
|
} |
|
|
|
|
|
return $component; |
|
|
} |
|
|
|
|
|
/** |
|
|
* build the select list to choose an image |
|
|
*/ |
|
|
function Images( $name, &$active, $javascript=NULL, $directory=NULL ) { |
|
|
global $mosConfig_absolute_path; |
|
|
|
|
|
if ( !$javascript ) { |
|
|
$javascript = "onchange=\"javascript:if (document.forms[0].image.options[selectedIndex].value!='') {document.imagelib.src='../images/stories/' + document.forms[0].image.options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\""; |
|
|
} |
|
|
if ( !$directory ) { |
|
|
$directory = '/images/stories'; |
|
|
} |
|
|
|
|
|
$imageFiles = mosReadDirectory( $mosConfig_absolute_path . $directory ); |
|
|
$images = array( mosHTML::makeOption( '', '- Select Image -' ) ); |
|
|
foreach ( $imageFiles as $file ) { |
|
|
if ( eregi( "bmp|gif|jpg|png", $file ) ) { |
|
|
$images[] = mosHTML::makeOption( $file ); |
|
|
} |
|
|
} |
|
|
$images = mosHTML::selectList( $images, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); |
|
|
|
|
|
return $images; |
|
|
} |
|
|
|
|
|
/** |
|
|
* build the select list for Ordering of a specified Table |
|
|
*/ |
|
|
function SpecificOrdering( &$row, $id, $query, $neworder=0 ) { |
|
|
global $database; |
|
|
|
|
|
if ( $neworder ) { |
|
|
$text = _CMN_NEW_ITEM_FIRST; |
|
|
} else { |
|
|
$text = _CMN_NEW_ITEM_LAST; |
|
|
} |
|
| 1559 |
|
|
| 1560 |
if ( $id ) { |
return $href; |
|
$order = mosGetOrderingList( $query ); |
|
|
$ordering = mosHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); |
|
|
} else { |
|
|
$ordering = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'. $text; |
|
|
} |
|
|
return $ordering; |
|
| 1561 |
} |
} |
| 1562 |
|
|
| 1563 |
/** |
function CheckedOutProcessing( &$row, $i ) { |
| 1564 |
* Select list of active users |
global $my; |
|
*/ |
|
|
function UserSelect( $name, $active, $nouser=0, $javascript=NULL, $order='name' ) { |
|
|
global $database, $my; |
|
| 1565 |
|
|
| 1566 |
$query = "SELECT id AS value, name AS text" |
if ( $row->checked_out ) { |
| 1567 |
. "\n FROM #__users" |
$checked = mosCommonHTML::checkedOut( $row ); |
|
. "\n WHERE block = '0'" |
|
|
. "\n ORDER BY ". $order |
|
|
; |
|
|
$database->setQuery( $query ); |
|
|
if ( $nouser ) { |
|
|
$users[] = mosHTML::makeOption( '0', '- No User -' ); |
|
|
$users = array_merge( $users, $database->loadObjectList() ); |
|
| 1568 |
} else { |
} else { |
| 1569 |
$users = $database->loadObjectList(); |
$checked = mosHTML::idBox( $i, $row->id, ($row->checked_out && $row->checked_out != $my->id ) ); |
| 1570 |
} |
} |
| 1571 |
|
|
| 1572 |
$users = mosHTML::selectList( $users, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); |
return $checked; |
|
|
|
|
return $users; |
|
| 1573 |
} |
} |
| 1574 |
|
|
| 1575 |
/** |
function PublishedProcessing( &$row, $i ) { |
| 1576 |
* Select list of positions - generally used for location of images |
$img = $row->published ? 'publish_g.png' : 'publish_x.png'; |
| 1577 |
*/ |
$task = $row->published ? 'unpublish' : 'publish'; |
| 1578 |
function Positions( $name, $active=NULL, $javascript=NULL, $none=1, $center=1, $left=1, $right=1 ) { |
$alt = $row->published ? 'Published' : 'Unpublished'; |
| 1579 |
if ( $none ) { |
$action = $row->published ? 'Unpublish Item' : 'Publish item'; |
|
$pos[] = mosHTML::makeOption( '', _CMN_NONE ); |
|
|
} |
|
|
if ( $center ) { |
|
|
$pos[] = mosHTML::makeOption( 'center', _CMN_CENTER ); |
|
|
} |
|
|
if ( $left ) { |
|
|
$pos[] = mosHTML::makeOption( 'left', _CMN_LEFT ); |
|
|
} |
|
|
if ( $right ) { |
|
|
$pos[] = mosHTML::makeOption( 'right', _CMN_RIGHT ); |
|
|
} |
|
| 1580 |
|
|
| 1581 |
$positions = mosHTML::selectList( $pos, $name, 'class="inputbox" size="1"'. $javascript, 'value', 'text', $active ); |
$href = ' |
| 1582 |
|
<a href="javascript: void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $task .'\')" title="'. $action .'"> |
| 1583 |
|
<img src="images/'. $img .'" border="0" alt="'. $alt .'" /> |
| 1584 |
|
</a>' |
| 1585 |
|
; |
| 1586 |
|
|
| 1587 |
return $positions; |
return $href; |
| 1588 |
|
} |
| 1589 |
} |
} |
| 1590 |
|
|
| 1591 |
/** |
/** |
| 1592 |
* Select list of active categories for components |
* Sorts an Array of objects |
| 1593 |
*/ |
*/ |
| 1594 |
function ComponentCategory( $name, $section, $active=NULL, $javascript=NULL, $order='ordering', $size=1, $sel_cat=1 ) { |
function SortArrayObjects_cmp( &$a, &$b ) { |
| 1595 |
global $database; |
global $csort_cmp; |
| 1596 |
|
|
| 1597 |
$query = "SELECT id AS value, name AS text" |
if ( $a->$csort_cmp['key'] > $b->$csort_cmp['key'] ) { |
| 1598 |
. "\n FROM #__categories" |
return $csort_cmp['direction']; |
|
. "\n WHERE section = '". $section ."'" |
|
|
. "\n AND published = '1'" |
|
|
. "\n ORDER BY ". $order |
|
|
; |
|
|
$database->setQuery( $query ); |
|
|
if ( $sel_cat ) { |
|
|
$categories[] = mosHTML::makeOption( '0', _SEL_CATEGORY ); |
|
|
$categories = array_merge( $categories, $database->loadObjectList() ); |
|
|
} else { |
|
|
$categories = $database->loadObjectList(); |
|
| 1599 |
} |
} |
| 1600 |
|
|
| 1601 |
if ( count( $categories ) < 1 ) { |
if ( $a->$csort_cmp['key'] < $b->$csort_cmp['key'] ) { |
| 1602 |
mosRedirect( 'index2.php?option=com_categories§ion='. $section, 'You must create a category first.' ); |
return -1 * $csort_cmp['direction']; |
| 1603 |
} |
} |
| 1604 |
|
|
| 1605 |
$category = mosHTML::selectList( $categories, $name, 'class="inputbox" size="'. $size .'" '. $javascript, 'value', 'text', $active ); |
return 0; |
|
|
|
|
return $category; |
|
| 1606 |
} |
} |
| 1607 |
|
|
| 1608 |
/** |
/** |
| 1609 |
* Select list of active sections |
* Sorts an Array of objects |
| 1610 |
|
* sort_direction [1 = Ascending] [-1 = Descending] |
| 1611 |
*/ |
*/ |
| 1612 |
function SelectSection( $name, $active=NULL, $javascript=NULL, $order='ordering' ) { |
function SortArrayObjects( &$a, $k, $sort_direction=1 ) { |
| 1613 |
global $database; |
global $csort_cmp; |
| 1614 |
|
|
| 1615 |
$categories[] = mosHTML::makeOption( '0', _SEL_SECTION ); |
$csort_cmp = array( |
| 1616 |
$query = "SELECT id AS value, title AS text" |
'key' => $k, |
| 1617 |
. "\n FROM #__sections" |
'direction' => $sort_direction |
| 1618 |
. "\n WHERE published = '1'" |
); |
|
. "\n ORDER BY ". $order |
|
|
; |
|
|
$database->setQuery( $query ); |
|
|
$sections = array_merge( $categories, $database->loadObjectList() ); |
|
| 1619 |
|
|
| 1620 |
$category = mosHTML::selectList( $sections, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); |
usort( $a, 'SortArrayObjects_cmp' ); |
| 1621 |
|
|
| 1622 |
return $category; |
unset( $csort_cmp ); |
| 1623 |
} |
} |
| 1624 |
|
|
| 1625 |
/** |
/** |
| 1626 |
* Select list of menu items for a specific menu |
* Sends mail to admin |
| 1627 |
*/ |
*/ |
| 1628 |
function Links2Menu( $type, $and ) { |
function mosSendAdminMail( $adminName, $adminEmail, $email, $type, $title, $author ) { |
| 1629 |
global $database; |
global $mosConfig_live_site; |
|
|
|
|
$query = "SELECT *" |
|
|
. "\n FROM #__menu" |
|
|
. "\n WHERE type = '". $type ."'" |
|
|
. "\n AND published = '1'" |
|
|
. $and |
|
|
; |
|
|
$database->setQuery( $query ); |
|
|
$menus = $database->loadObjectList(); |
|
| 1630 |
|
|
| 1631 |
return $menus; |
$subject = _MAIL_SUB." '$type'"; |
| 1632 |
|
$message = _MAIL_MSG; |
| 1633 |
|
eval ("\$message = \"$message\";"); |
| 1634 |
|
mosMail($mosConfig_mailfrom, $mosConfig_fromname, $adminEmail, $subject, $message); |
| 1635 |
} |
} |
| 1636 |
|
|
| 1637 |
/** |
/* |
| 1638 |
* Select list of menus |
* Includes pathway file |
| 1639 |
*/ |
*/ |
| 1640 |
function MenuSelect( $name='menuselect', $javascript=NULL ) { |
function mosPathWay() { |
| 1641 |
global $database; |
require mamboCore::get('mosConfig_absolute_path').'/includes/pathway.php'; |
|
|
|
|
$query = "SELECT params" |
|
|
. "\n FROM #__modules" |
|
|
. "\n WHERE module = 'mod_mainmenu'" |
|
|
; |
|
|
$database->setQuery( $query ); |
|
|
$menus = $database->loadObjectList(); |
|
|
$total = count( $menus ); |
|
|
for( $i = 0; $i < $total; $i++ ) { |
|
|
$params = mosParseParams( $menus[$i]->params ); |
|
|
$menuselect[$i]->value = $params->menutype; |
|
|
$menuselect[$i]->text = $params->menutype; |
|
|
} |
|
|
// sort array of objects |
|
|
SortArrayObjects( $menuselect, 'text', 1 ); |
|
|
|
|
|
$menus = mosHTML::selectList( $menuselect, $name, 'class="inputbox" size="10" '. $javascript, 'value', 'text' ); |
|
|
|
|
|
return $menus; |
|
| 1642 |
} |
} |
| 1643 |
|
|
| 1644 |
/** |
/** |
| 1645 |
* Internal function to recursive scan the media manager directories |
* Displays a not authorised message |
| 1646 |
* @param string Path to scan |
* |
| 1647 |
* @param string root path of this folder |
* If the user is not logged in then an addition message is displayed. |
|
* @param array Value array of all existing folders |
|
|
* @param array Value array of all existing images |
|
| 1648 |
*/ |
*/ |
| 1649 |
function ReadImages( $imagePath, $folderPath, &$folders, &$images ) { |
function mosNotAuth() { |
| 1650 |
$imgFiles = mosReadDirectory( $imagePath ); |
global $my; |
|
|
|
|
foreach ($imgFiles as $file) { |
|
|
$ff_ = $folderPath . $file .'/'; |
|
|
$ff = $folderPath . $file; |
|
|
$i_f = $imagePath .'/'. $file; |
|
| 1651 |
|
|
| 1652 |
if ( is_dir( $i_f ) && $file <> 'CVS' ) { |
echo _NOT_AUTH; |
| 1653 |
$folders[] = mosHTML::makeOption( $ff_ ); |
if ($my->id < 1) { |
| 1654 |
mosAdminMenus::ReadImages( $i_f, $ff_, $folders, $images ); |
echo "<br />" . _DO_LOGIN; |
|
} else if ( eregi( "bmp|gif|jpg|png", $file ) && is_file( $i_f ) ) { |
|
|
// leading / we don't need |
|
|
$imageFile = substr( $ff, 1 ); |
|
|
$images[$folderPath][] = mosHTML::makeOption( $imageFile, $file ); |
|
|
} |
|
| 1655 |
} |
} |
| 1656 |
} |
} |
| 1657 |
|
|
| 1658 |
function GetImageFolders( &$folders, $path ) { |
/** |
| 1659 |
$javascript = "onchange=\"changeDynaList( 'imagefiles', folderimages, document.adminForm.folders.options[document.adminForm.folders.selectedIndex].value, 0, 0); previewImage( 'imagefiles', 'view_imagefiles', '$path/' );\""; |
* Replaces & with & for xhtml compliance |
| 1660 |
$getfolders = mosHTML::selectList( $folders, 'folders', 'class="inputbox" size="1" '. $javascript, 'value', 'text', '/' ); |
* |
| 1661 |
return $getfolders; |
* Needed to handle unicode conflicts due to unicode conflicts |
| 1662 |
} |
*/ |
| 1663 |
|
function ampReplace( $text ) { |
| 1664 |
|
$text = str_replace( '&#', '*-*', $text ); |
| 1665 |
|
$text = str_replace( '&', '&', $text ); |
| 1666 |
|
$text = str_replace( '*-*', '&#', $text ); |
| 1667 |
|
|
| 1668 |
function GetImages( &$images, $path ) { |
return $text; |
|
if ( !isset($images['/'] ) ) { |
|
|
$images['/'][] = mosHTML::makeOption( '' ); |
|
| 1669 |
} |
} |
| 1670 |
|
|
| 1671 |
//$javascript = "onchange=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\" onfocus=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\""; |
/** |
| 1672 |
$javascript = "onchange=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\""; |
* Prepares results from search for display |
| 1673 |
$getimages = mosHTML::selectList( $images['/'], 'imagefiles', 'class="inputbox" size="10" multiple="multiple" '. $javascript , 'value', 'text', null ); |
* @param string The source string |
| 1674 |
|
* @param int Number of chars to trim |
| 1675 |
return $getimages; |
* @param string The searchword to select around |
| 1676 |
|
* @return string |
| 1677 |
|
*/ |
| 1678 |
|
function mosPrepareSearchContent( $text, $length=200, $searchword ) { |
| 1679 |
|
// strips tags won't remove the actual jscript |
| 1680 |
|
$text = preg_replace( "'<script[^>]*>.*?</script>'si", "", $text ); |
| 1681 |
|
$text = preg_replace( '/{.+?}/', '', $text); |
| 1682 |
|
//$text = preg_replace( '/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is','\2', $text ); |
| 1683 |
|
return mosSmartSubstr( strip_tags( $text ), $length, $searchword ); |
| 1684 |
} |
} |
| 1685 |
|
|
| 1686 |
function GetSavedImages( &$row, $path ) { |
/** |
| 1687 |
$images2 = array(); |
* returns substring of characters around a searchword |
| 1688 |
foreach( $row->images as $file ) { |
* @param string The source string |
| 1689 |
$temp = explode( '|', $file ); |
* @param int Number of chars to return |
| 1690 |
if( strrchr($temp[0], '/') ) { |
* @param string The searchword to select around |
| 1691 |
$filename = substr( strrchr($temp[0], '/' ), 1 ); |
* @return string |
| 1692 |
|
*/ |
| 1693 |
|
function mosSmartSubstr($text, $length=200, $searchword) { |
| 1694 |
|
$wordpos = strpos(strtolower($text), strtolower($searchword)); |
| 1695 |
|
$halfside = intval($wordpos - $length/2 - strlen($searchword)); |
| 1696 |
|
if ($wordpos && $halfside > 0) { |
| 1697 |
|
return '...' . substr($text, $halfside, $length); |
| 1698 |
} else { |
} else { |
| 1699 |
$filename = $temp[0]; |
return substr( $text, 0, $length); |
| 1700 |
} |
} |
|
$images2[] = mosHTML::makeOption( $file, $filename ); |
|
| 1701 |
} |
} |
|
//$javascript = "onchange=\"previewImage( 'imagelist', 'view_imagelist', '$path/' ); showImageProps( '$path/' ); \" onfocus=\"previewImage( 'imagelist', 'view_imagelist', '$path/' )\""; |
|
|
$javascript = "onchange=\"previewImage( 'imagelist', 'view_imagelist', '$path/' ); showImageProps( '$path/' ); \""; |
|
|
$imagelist = mosHTML::selectList( $images2, 'imagelist', 'class="inputbox" size="10" '. $javascript, 'value', 'text' ); |
|
| 1702 |
|
|
| 1703 |
return $imagelist; |
/** |
| 1704 |
} |
* Chmods files and directories recursively to given permissions. Available from 4.5.2 up. |
| 1705 |
|
* @param path The starting file or directory (no trailing slash) |
| 1706 |
|
* @param filemode Integer value to chmod files. NULL = dont chmod files. |
| 1707 |
|
* @param dirmode Integer value to chmod directories. NULL = dont chmod directories. |
| 1708 |
|
* @return TRUE=all succeeded FALSE=one or more chmods failed |
| 1709 |
|
*/ |
| 1710 |
|
function mosChmodRecursive($path, $filemode=NULL, $dirmode=NULL) |
| 1711 |
|
{ |
| 1712 |
|
$ret = TRUE; |
| 1713 |
|
if (is_dir($path)) { |
| 1714 |
|
$dh = opendir($path); |
| 1715 |
|
while ($file = readdir($dh)) { |
| 1716 |
|
if ($file != '.' && $file != '..') { |
| 1717 |
|
$fullpath = $path.'/'.$file; |
| 1718 |
|
if (is_dir($fullpath)) { |
| 1719 |
|
if (!mosChmodRecursive($fullpath, $filemode, $dirmode)) |
| 1720 |
|
$ret = FALSE; |
| 1721 |
|
} else { |
| 1722 |
|
if (isset($filemode)) |
| 1723 |
|
if (!@chmod($fullpath, $filemode)) |
| 1724 |
|
$ret = FALSE; |
| 1725 |
|
} // if |
| 1726 |
|
} // if |
| 1727 |
|
} // while |
| 1728 |
|
closedir($dh); |
| 1729 |
|
if (isset($dirmode)) |
| 1730 |
|
if (!@chmod($path, $dirmode)) |
| 1731 |
|
$ret = FALSE; |
| 1732 |
|
} else { |
| 1733 |
|
if (isset($filemode)) |
| 1734 |
|
$ret = @chmod($path, $filemode); |
| 1735 |
|
} // if |
| 1736 |
|
return $ret; |
| 1737 |
|
} // mosChmodRecursive |
| 1738 |
|
|
| 1739 |
/** |
/** |
| 1740 |
* Checks to see if an image exists in the current templates image directory |
* Chmods files and directories recursively to mos global permissions. Available from 4.5.2 up. |
| 1741 |
* if it does it loads this image. Otherwise the default image is loaded. |
* @param path The starting file or directory (no trailing slash) |
| 1742 |
* Also can be used in conjunction with the menulist param to create the chosen image |
* @param filemode Integer value to chmod files. NULL = dont chmod files. |
| 1743 |
* load the default or use no image |
* @param dirmode Integer value to chmod directories. NULL = dont chmod directories. |
| 1744 |
|
* @return TRUE=all succeeded FALSE=one or more chmods failed |
| 1745 |
*/ |
*/ |
| 1746 |
function ImageCheck( $file, $directory='/images/M_images/', $param=NULL, $param_directory='/images/M_images/', $alt=NULL, $name='image', $type=1, $align='middle' ) { |
function mosChmod($path) |
| 1747 |
global $mosConfig_absolute_path, $mosConfig_live_site, $mainframe; |
{ |
| 1748 |
$cur_template = $mainframe->getTemplate(); |
global $mosConfig_fileperms, $mosConfig_dirperms; |
| 1749 |
|
$filemode = NULL; |
| 1750 |
|
if ($mosConfig_fileperms != '') |
| 1751 |
|
$filemode = octdec($mosConfig_fileperms); |
| 1752 |
|
$dirmode = NULL; |
| 1753 |
|
if ($mosConfig_dirperms != '') |
| 1754 |
|
$dirmode = octdec($mosConfig_dirperms); |
| 1755 |
|
if (isset($filemode) || isset($dirmode)) |
| 1756 |
|
return mosChmodRecursive($path, $filemode, $dirmode); |
| 1757 |
|
return TRUE; |
| 1758 |
|
} // mosChmod |
| 1759 |
|
|
| 1760 |
if ( $param ) { |
/** |
| 1761 |
$image = $mosConfig_live_site. $param_directory . $param; |
* Function to convert array to integer values |
| 1762 |
if ( $type ) { |
*/ |
| 1763 |
$image = '<img src="'. $image .'" align="'. $align .'" alt="'. $alt .'" name="'. $name .'" border="0" />'; |
function mosArrayToInts( &$array, $default=null ) { |
| 1764 |
|
if (is_array( $array )) { |
| 1765 |
|
$n = count( $array ); |
| 1766 |
|
for ($i = 0; $i < $n; $i++) { |
| 1767 |
|
$array[$i] = intval( $array[$i] ); |
| 1768 |
} |
} |
|
} else if ( $param == -1 ) { |
|
|
$image = ''; |
|
| 1769 |
} else { |
} else { |
| 1770 |
if ( file_exists( $mosConfig_absolute_path .'/templates/'. $cur_template .'/images/'. $file ) ) { |
if (is_null( $default )) { |
| 1771 |
$image = $mosConfig_live_site .'/templates/'. $cur_template .'/images/'. $file; |
return array(); |
| 1772 |
} else { |
} else { |
| 1773 |
// outputs only path to image |
return array( $default ); |
|
$image = $mosConfig_live_site. $directory . $file; |
|
|
} |
|
|
|
|
|
// outputs actual html <img> tag |
|
|
if ( $type ) { |
|
|
$image = '<img src="'. $image .'" alt="'. $alt .'" align="'. $align .'" name="'. $name .'" border="0" />'; |
|
| 1774 |
} |
} |
| 1775 |
} |
} |
|
|
|
|
return $image; |
|
| 1776 |
} |
} |
| 1777 |
|
|
| 1778 |
/** |
/** |
| 1779 |
* Checks to see if an image exists in the current templates image directory |
* Strip slashes from strings or arrays of strings |
| 1780 |
* if it does it loads this image. Otherwise the default image is loaded. |
* @param value the input string or array |
|
* Also can be used in conjunction with the menulist param to create the chosen image |
|
|
* load the default or use no image |
|
| 1781 |
*/ |
*/ |
| 1782 |
function ImageCheckAdmin( $file, $directory='/administrator/images/', $param=NULL, $param_directory='/administrator/images/', $alt=NULL, $name=NULL, $type=1, $align='middle' ) { |
function mosStripslashes(&$value) |
| 1783 |
global $mosConfig_absolute_path, $mosConfig_live_site, $mainframe; |
{ |
| 1784 |
$cur_template = $mainframe->getTemplate(); |
$ret = ''; |
| 1785 |
|
if (is_string($value)) { |
| 1786 |
if ( $param ) { |
$ret = stripslashes($value); |
|
$image = $mosConfig_live_site. $param_directory . $param; |
|
|
if ( $type ) { |
|
|
$image = '<img src="'. $image .'" align="'. $align .'" alt="'. $alt .'" name="'. $name .'" border="0" />'; |
|
|
} |
|
|
} else if ( $param == -1 ) { |
|
|
$image = ''; |
|
| 1787 |
} else { |
} else { |
| 1788 |
if ( file_exists( $mosConfig_absolute_path .'/administrator/templates/'. $cur_template .'/images/'. $file ) ) { |
if (is_array($value)) { |
| 1789 |
$image = $mosConfig_live_site .'/administrator/templates/'. $cur_template .'/images/'. $file; |
$ret = array(); |
| 1790 |
|
while (list($key,$val) = each($value)) { |
| 1791 |
|
$ret[$key] = mosStripslashes($val); |
| 1792 |
|
} // while |
| 1793 |
} else { |
} else { |
| 1794 |
$image = $mosConfig_live_site. $directory . $file; |
$ret = $value; |
| 1795 |
} |
} // if |
| 1796 |
|
} // if |
| 1797 |
|
return $ret; |
| 1798 |
|
} // mosStripSlashes |
| 1799 |
|
|
| 1800 |
// outputs actual html <img> tag |
/** |
| 1801 |
if ( $type ) { |
* Copy the named array content into the object as properties |
| 1802 |
$image = '<img src="'. $image .'" alt="'. $alt .'" align="'. $align .'" name="'. $name .'" border="0" />'; |
* only existing properties of object are filled. when undefined in hash, properties wont be deleted |
| 1803 |
} |
* @param array the input array |
| 1804 |
|
* @param obj byref the object to fill of any class |
| 1805 |
|
* @param string |
| 1806 |
|
* @param boolean |
| 1807 |
|
*/ |
| 1808 |
|
function mosBindArrayToObject( $array, &$obj, $ignore='', $prefix=NULL, $checkSlashes=true ) { |
| 1809 |
|
$database = mamboDatabase::getInstance(); |
| 1810 |
|
return $database->mosBindArrayToOBject($array, $obj, $ignore='', $prefix=NULL, $checkSlashes=true); |
| 1811 |
} |
} |
| 1812 |
|
|
| 1813 |
return $image; |
function checkIncludePath () { |
| 1814 |
|
global $mosConfig_absolute_path; |
| 1815 |
|
if (realpath($mosConfig_absolute_path) === false) die ('Global hack'); |
| 1816 |
} |
} |
| 1817 |
|
|
| 1818 |
function menutypes() { |
/** |
| 1819 |
global $database; |
* Utility function to read the files in a directory |
| 1820 |
|
* @param string The file system path |
| 1821 |
$query = "SELECT params" |
* @param string A filter for the names |
| 1822 |
. "\n FROM #__modules" |
* @param boolean Recurse search into sub-directories |
| 1823 |
. "\n WHERE module = 'mod_mainmenu'" |
* @param boolean True if to prepend the full path to the file name |
| 1824 |
. "\n ORDER BY title" |
*/ |
| 1825 |
; |
function mosReadDirectory( $path, $filter='.', $recurse=false, $fullpath=false ) { |
| 1826 |
$database->setQuery( $query ); |
$arr = array(); |
| 1827 |
$modMenus = $database->loadObjectList(); |
if (!@is_dir( $path )) { |
| 1828 |
|
return $arr; |
|
$query = "SELECT menutype" |
|
|
. "\n FROM #__menu" |
|
|
. "\n GROUP BY menutype" |
|
|
. "\n ORDER BY menutype" |
|
|
; |
|
|
$database->setQuery( $query ); |
|
|
$menuMenus = $database->loadObjectList(); |
|
|
|
|
|
$menuTypes = ''; |
|
|
foreach ( $modMenus as $modMenu ) { |
|
|
$check = 1; |
|
|
mosMakeHtmlSafe( $modMenu) ; |
|
|
$modParams = mosParseParams( $modMenu->params ); |
|
|
$menuType = @$modParams->menutype; |
|
|
if (!$menuType) { |
|
|
$menuType = 'mainmenu'; |
|
| 1829 |
} |
} |
| 1830 |
|
$handle = opendir( $path ); |
| 1831 |
|
|
| 1832 |
// stop duplicate menutype being shown |
while ($file = readdir($handle)) { |
| 1833 |
if ( !is_array( $menuTypes) ) { |
$dir = mosPathName( $path.'/'.$file, false ); |
| 1834 |
// handling to create initial entry into array |
$isDir = is_dir( $dir ); |
| 1835 |
$menuTypes[] = $menuType; |
if (($file <> ".") && ($file <> "..")) { |
| 1836 |
|
if (preg_match( "/$filter/", $file )) { |
| 1837 |
|
if ($fullpath) { |
| 1838 |
|
$arr[] = trim( mosPathName( $path.'/'.$file, false ) ); |
| 1839 |
} else { |
} else { |
| 1840 |
$check = 1; |
$arr[] = trim( $file ); |
|
foreach ( $menuTypes as $a ) { |
|
|
if ( $a == $menuType ) { |
|
|
$check = 0; |
|
|
} |
|
|
} |
|
|
if ( $check ) { |
|
|
$menuTypes[] = $menuType; |
|
| 1841 |
} |
} |
| 1842 |
} |
} |
| 1843 |
|
if ($recurse && $isDir) { |
| 1844 |
|
$arr2 = mosReadDirectory( $dir, $filter, $recurse, $fullpath ); |
| 1845 |
|
$arr = array_merge( $arr, $arr2 ); |
| 1846 |
} |
} |
|
// add menutypes from mos_menu |
|
|
foreach ( $menuMenus as $menuMenu ) { |
|
|
$check = 1; |
|
|
foreach ( $menuTypes as $a ) { |
|
|
if ( $a == $menuMenu->menutype ) { |
|
|
$check = 0; |
|
| 1847 |
} |
} |
| 1848 |
} |
} |
| 1849 |
if ( $check ) { |
closedir($handle); |
| 1850 |
$menuTypes[] = $menuMenu->menutype; |
asort($arr); |
| 1851 |
|
return $arr; |
| 1852 |
} |
} |
| 1853 |
|
|
| 1854 |
|
/** |
| 1855 |
|
* Utility function redirect the browser location to another url |
| 1856 |
|
* |
| 1857 |
|
* Can optionally provide a message. |
| 1858 |
|
* @param string The file system path |
| 1859 |
|
* @param string A filter for the names |
| 1860 |
|
*/ |
| 1861 |
|
function mosRedirect( $url, $msg='' ) { |
| 1862 |
|
mamboCore::redirect($url, $msg); |
| 1863 |
} |
} |
| 1864 |
|
|
| 1865 |
// sorts menutypes |
function mosTreeRecurse( $id, $indent, $list, &$children, $maxlevel=9999, $level=0, $type=1 ) { |
| 1866 |
asort( $menuTypes ); |
if (@$children[$id] && $level <= $maxlevel) { |
| 1867 |
|
foreach ($children[$id] as $v) { |
| 1868 |
|
$id = $v->id; |
| 1869 |
|
|
| 1870 |
return $menuTypes; |
if ( $type ) { |
| 1871 |
|
$pre = '<sup>L</sup> '; |
| 1872 |
|
$spacer = '. '; |
| 1873 |
|
} else { |
| 1874 |
|
$pre = '- '; |
| 1875 |
|
$spacer = ' '; |
| 1876 |
} |
} |
| 1877 |
|
|
| 1878 |
/* |
if ( $v->parent == 0 ) { |
| 1879 |
* loads files required for menu items |
$txt = $v->name; |
| 1880 |
*/ |
} else { |
| 1881 |
function menuItem( $item ) { |
$txt = $pre . $v->name; |
|
global $mosConfig_absolute_path; |
|
|
|
|
|
$path = $mosConfig_absolute_path .'/administrator/components/com_menus/'. $item .'/'; |
|
|
include_once( $path . $item .'.class.php' ); |
|
|
include_once( $path . $item .'.menu.html.php' ); |
|
| 1882 |
} |
} |
| 1883 |
|
$pt = $v->parent; |
| 1884 |
|
$list[$id] = $v; |
| 1885 |
|
$list[$id]->treename = "$indent$txt"; |
| 1886 |
|
$list[$id]->children = count( @$children[$id] ); |
| 1887 |
|
$list = mosTreeRecurse( $id, $indent . $spacer, $list, $children, $maxlevel, $level+1, $type ); |
| 1888 |
} |
} |
| 1889 |
|
} |
| 1890 |
|
return $list; |
|
class mosCommonHTML { |
|
|
|
|
|
function ContentLegend( ) { |
|
|
?> |
|
|
<table cellspacing="0" cellpadding="4" border="0" align="center"> |
|
|
<tr align="center"> |
|
|
<td> |
|
|
<img src="images/publish_y.png" width="12" height="12" border="0" alt="Pending" /> |
|
|
</td> |
|
|
<td> |
|
|
Published, but is <u>Pending</u> | |
|
|
</td> |
|
|
<td> |
|
|
<img src="images/publish_g.png" width="12" height="12" border="0" alt="Visible" /> |
|
|
</td> |
|
|
<td> |
|
|
Published and is <u>Current</u> | |
|
|
</td> |
|
|
<td> |
|
|
<img src="images/publish_r.png" width="12" height="12" border="0" alt="Finished" /> |
|
|
</td> |
|
|
<td> |
|
|
Published, but has <u>Expired</u> | |
|
|
</td> |
|
|
<td> |
|
|
<img src="images/publish_x.png" width="12" height="12" border="0" alt="Finished" /> |
|
|
</td> |
|
|
<td> |
|
|
Not Published |
|
|
</td> |
|
|
</tr> |
|
|
<tr> |
|
|
<td colspan="8" align="center"> |
|
|
Click on icon to toggle state. |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
<?php |
|
| 1891 |
} |
} |
| 1892 |
|
|
| 1893 |
function menuLinksContent( &$menus ) { |
/** |
| 1894 |
?> |
* Function to strip additional / or \ in a path name |
| 1895 |
<script language="javascript" type="text/javascript"> |
* @param string The path |
| 1896 |
function go2( pressbutton, menu, id ) { |
* @param boolean Add trailing slash |
| 1897 |
var form = document.adminForm; |
*/ |
| 1898 |
|
function mosPathName($p_path,$p_addtrailingslash = true) { |
| 1899 |
|
$retval = ""; |
| 1900 |
|
|
| 1901 |
if (pressbutton == 'go2menu') { |
$isWin = (substr(PHP_OS, 0, 3) == 'WIN'); |
|
form.menu.value = menu; |
|
|
submitform( pressbutton ); |
|
|
return; |
|
|
} |
|
| 1902 |
|
|
| 1903 |
if (pressbutton == 'go2menuitem') { |
if ($isWin) { |
| 1904 |
form.menu.value = menu; |
$retval = str_replace( '/', '\\', $p_path ); |
| 1905 |
form.menuid.value = id; |
if ($p_addtrailingslash) { |
| 1906 |
submitform( pressbutton ); |
if (substr( $retval, -1 ) != '\\') { |
| 1907 |
return; |
$retval .= '\\'; |
| 1908 |
} |
} |
| 1909 |
} |
} |
| 1910 |
</script> |
// Remove double \\ |
| 1911 |
<?php |
$retval = str_replace( '\\\\', '\\', $retval ); |
| 1912 |
foreach( $menus as $menu ) { |
} else { |
| 1913 |
?> |
$retval = str_replace( '\\', '/', $p_path ); |
| 1914 |
<tr> |
if ($p_addtrailingslash) { |
| 1915 |
<td colspan="2"> |
if (substr( $retval, -1 ) != '/') { |
| 1916 |
<hr /> |
$retval .= '/'; |
|
</td> |
|
|
</tr> |
|
|
<tr> |
|
|
<td width="90px" valign="top"> |
|
|
Menu |
|
|
</td> |
|
|
<td> |
|
|
<a href="javascript:go2( 'go2menu', '<?php echo $menu->menutype; ?>' );" title="Go to Menu"> |
|
|
<?php echo $menu->menutype; ?> |
|
|
</a> |
|
|
</td> |
|
|
</tr> |
|
|
<tr> |
|
|
<td width="90px" valign="top"> |
|
|
Link Name |
|
|
</td> |
|
|
<td> |
|
|
<strong> |
|
|
<a href="javascript:go2( 'go2menuitem', '<?php echo $menu->menutype; ?>', '<?php echo $menu->id; ?>' );" title="Go to Menu Item"> |
|
|
<?php echo $menu->name; ?> |
|
|
</a> |
|
|
</strong> |
|
|
</td> |
|
|
</tr> |
|
|
<tr> |
|
|
<td width="90px" valign="top"> |
|
|
State |
|
|
</td> |
|
|
<td> |
|
|
<?php |
|
|
switch ( $menu->published ) { |
|
|
case -2: |
|
|
echo '<font color="red">Trashed</font>'; |
|
|
break; |
|
|
case 0: |
|
|
echo 'UnPublished'; |
|
|
break; |
|
|
case 1: |
|
|
default: |
|
|
echo '<font color="green">Published</font>'; |
|
|
break; |
|
| 1917 |
} |
} |
|
?> |
|
|
</td> |
|
|
</tr> |
|
|
<?php |
|
| 1918 |
} |
} |
| 1919 |
?> |
// Remove double // |
| 1920 |
<input type="hidden" name="menu" value="" /> |
$retval = str_replace('//','/',$retval); |
|
<input type="hidden" name="menuid" value="" /> |
|
|
<?php |
|
| 1921 |
} |
} |
| 1922 |
|
|
| 1923 |
function menuLinksSecCat( &$menus ) { |
return $retval; |
|
?> |
|
|
<script language="javascript" type="text/javascript"> |
|
|
function go2( pressbutton, menu, id ) { |
|
|
var form = document.adminForm; |
|
|
|
|
|
if (pressbutton == 'go2menu') { |
|
|
form.menu.value = menu; |
|
|
submitform( pressbutton ); |
|
|
return; |
|
| 1924 |
} |
} |
| 1925 |
|
|
| 1926 |
if (pressbutton == 'go2menuitem') { |
function mosObjectToArray($p_obj) |
| 1927 |
form.menu.value = menu; |
{ |
| 1928 |
form.menuid.value = id; |
$retarray = null; |
| 1929 |
submitform( pressbutton ); |
if(is_object($p_obj)) |
| 1930 |
return; |
{ |
| 1931 |
|
$retarray = array(); |
| 1932 |
|
foreach (get_object_vars($p_obj) as $k => $v) |
| 1933 |
|
{ |
| 1934 |
|
if(is_object($v)) |
| 1935 |
|
$retarray[$k] = mosObjectToArray($v); |
| 1936 |
|
else |
| 1937 |
|
$retarray[$k] = $v; |
| 1938 |
} |
} |
| 1939 |
} |
} |
| 1940 |
</script> |
return $retarray; |
| 1941 |
<?php |
} |
| 1942 |
foreach( $menus as $menu ) { |
/** |
| 1943 |
?> |
* Checks the user agent string against known browsers |
| 1944 |
<tr> |
*/ |
| 1945 |
<td colspan="2"> |
function mosGetBrowser( $agent ) { |
| 1946 |
<hr/> |
require( "includes/agent_browser.php" ); |
| 1947 |
</td> |
|
| 1948 |
</tr> |
if (preg_match( "/msie[\/\sa-z]*([\d\.]*)/i", $agent, $m ) |
| 1949 |
<tr> |
&& !preg_match( "/webtv/i", $agent ) |
| 1950 |
<td width="90px" valign="top"> |
&& !preg_match( "/omniweb/i", $agent ) |
| 1951 |
Menu |
&& !preg_match( "/opera/i", $agent )) { |
| 1952 |
</td> |
// IE |
| 1953 |
<td> |
return "MS Internet Explorer $m[1]"; |
| 1954 |
<a href="javascript:go2( 'go2menu', '<?php echo $menu->menutype; ?>' );" title="Go to Menu"> |
} else if (preg_match( "/netscape.?\/([\d\.]*)/i", $agent, $m )) { |
| 1955 |
<?php echo $menu->menutype; ?> |
// Netscape 6.x, 7.x ... |
| 1956 |
</a> |
return "Netscape $m[1]"; |
| 1957 |
</td> |
} else if ( preg_match( "/mozilla[\/\sa-z]*([\d\.]*)/i", $agent, $m ) |
| 1958 |
</tr> |
&& !preg_match( "/gecko/i", $agent ) |
| 1959 |
<tr> |
&& !preg_match( "/compatible/i", $agent ) |
| 1960 |
<td width="90px" valign="top"> |
&& !preg_match( "/opera/i", $agent ) |
| 1961 |
Type |
&& !preg_match( "/galeon/i", $agent ) |
| 1962 |
</td> |
&& !preg_match( "/safari/i", $agent )) { |
| 1963 |
<td> |
// Netscape 3.x, 4.x ... |
| 1964 |
<?php echo $menu->type; ?> |
return "Netscape $m[2]"; |
| 1965 |
</td> |
} else { |
| 1966 |
</tr> |
// Other |
| 1967 |
<tr> |
$found = false; |
| 1968 |
<td width="90px" valign="top"> |
foreach ($browserSearchOrder as $key) { |
| 1969 |
Item Name |
if (preg_match( "/$key.?\/([\d\.]*)/i", $agent, $m )) { |
| 1970 |
</td> |
$name = "$browsersAlias[$key] $m[1]"; |
| 1971 |
<td> |
return $name; |
|
<strong> |
|
|
<a href="javascript:go2( 'go2menuitem', '<?php echo $menu->menutype; ?>', '<?php echo $menu->id; ?>' );" title="Go to Menu Item"> |
|
|
<?php echo $menu->name; ?> |
|
|
</a> |
|
|
</strong> |
|
|
</td> |
|
|
</tr> |
|
|
<tr> |
|
|
<td width="90px" valign="top"> |
|
|
State |
|
|
</td> |
|
|
<td> |
|
|
<?php |
|
|
switch ( $menu->published ) { |
|
|
case -2: |
|
|
echo '<font color="red">Trashed</font>'; |
|
|
break; |
|
|
case 0: |
|
|
echo 'UnPublished'; |
|
|
break; |
|
|
case 1: |
|
|
default: |
|
|
echo '<font color="green">Published</font>'; |
|
| 1972 |
break; |
break; |
| 1973 |
} |
} |
|
?> |
|
|
</td> |
|
|
</tr> |
|
|
<?php |
|
|
} |
|
|
?> |
|
|
<input type="hidden" name="menu" value="" /> |
|
|
<input type="hidden" name="menuid" value="" /> |
|
|
<?php |
|
| 1974 |
} |
} |
|
|
|
|
function checkedOut( &$row, $overlib=1 ) { |
|
|
$hover = ''; |
|
|
if ( $overlib ) { |
|
|
$date = mosFormatDate( $row->checked_out_time, '%A, %d %B %Y' ); |
|
|
$time = mosFormatDate( $row->checked_out_time, '%H:%M' ); |
|
|
$checked_out_text = '<table>'; |
|
|
$checked_out_text .= '<tr><td>'. $row->editor .'</td></tr>'; |
|
|
$checked_out_text .= '<tr><td>'. $date .'</td></tr>'; |
|
|
$checked_out_text .= '<tr><td>'. $time .'</td></tr>'; |
|
|
$checked_out_text .= '</table>'; |
|
|
$hover = 'onMouseOver="return overlib(\''. $checked_out_text .'\', CAPTION, \'Checked Out\', BELOW, RIGHT);" onMouseOut="return nd();"'; |
|
| 1975 |
} |
} |
|
$checked = '<img src="images/checked_out.png" '. $hover .'/>'; |
|
| 1976 |
|
|
| 1977 |
return $checked; |
return 'Unknown'; |
| 1978 |
} |
} |
| 1979 |
|
|
| 1980 |
/* |
/** |
| 1981 |
* Loads all necessary files for JS Overlib tooltips |
* Checks the user agent string against known operating systems |
| 1982 |
*/ |
*/ |
| 1983 |
function loadOverlib() { |
function mosGetOS( $agent ) { |
| 1984 |
global $mosConfig_live_site; |
require( "includes/agent_os.php" ); |
| 1985 |
?> |
|
| 1986 |
<script language="Javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_mini.js"></script> |
foreach ($osSearchOrder as $key) { |
| 1987 |
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div> |
if (preg_match( "/$key/i", $agent )) { |
| 1988 |
<?php |
return $osAlias[$key]; |
| 1989 |
|
break; |
| 1990 |
|
} |
| 1991 |
} |
} |
| 1992 |
|
|
| 1993 |
|
return 'Unknown'; |
| 1994 |
|
} |
| 1995 |
|
|
| 1996 |
/* |
/** |
| 1997 |
* Loads all necessary files for JS Calendar |
* @param string SQL with ordering As value and 'name field' AS text |
| 1998 |
|
* @param integer The length of the truncated headline |
| 1999 |
*/ |
*/ |
| 2000 |
function loadCalendar() { |
function mosGetOrderingList( $sql, $chop='30' ) { |
| 2001 |
global $mosConfig_live_site; |
global $database; |
|
?> |
|
|
<link rel="stylesheet" type="text/css" media="all" href="<?php echo $mosConfig_live_site;?>/includes/js/calendar/calendar-mos.css" title="green" /> |
|
|
<!-- import the calendar script --> |
|
|
<script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/calendar/calendar.js"></script> |
|
|
<!-- import the language module --> |
|
|
<script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/calendar/lang/calendar-en.js"></script> |
|
|
<?php |
|
|
} |
|
| 2002 |
|
|
| 2003 |
function AccessProcessing( &$row, $i ) { |
$order = array(); |
| 2004 |
if ( !$row->access ) { |
$database->setQuery( $sql ); |
| 2005 |
$color_access = 'style="color: green;"'; |
if (!($orders = $database->loadObjectList())) { |
| 2006 |
$task_access = 'accessregistered'; |
if ($database->getErrorNum()) { |
| 2007 |
} else if ( $row->access == 1 ) { |
echo $database->stderr(); |
| 2008 |
$color_access = 'style="color: red;"'; |
return false; |
|
$task_access = 'accessspecial'; |
|
| 2009 |
} else { |
} else { |
| 2010 |
$color_access = 'style="color: black;"'; |
$order[] = mosHTML::makeOption( 1, 'first' ); |
| 2011 |
$task_access = 'accesspublic'; |
return $order; |
| 2012 |
} |
} |
|
|
|
|
$href = ' |
|
|
<a href="javascript: void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $task_access .'\')" '. $color_access .'> |
|
|
'. $row->groupname .' |
|
|
</a>' |
|
|
; |
|
|
|
|
|
return $href; |
|
| 2013 |
} |
} |
| 2014 |
|
$order[] = mosHTML::makeOption( 0, '0 first' ); |
| 2015 |
|
for ($i=0, $n=count( $orders ); $i < $n; $i++) { |
| 2016 |
|
|
| 2017 |
function CheckedOutProcessing( &$row, $i ) { |
if (strlen($orders[$i]->text) > $chop) { |
| 2018 |
global $my; |
$text = substr($orders[$i]->text,0,$chop)."..."; |
|
|
|
|
if ( $row->checked_out ) { |
|
|
$checked = mosCommonHTML::checkedOut( $row ); |
|
| 2019 |
} else { |
} else { |
| 2020 |
$checked = mosHTML::idBox( $i, $row->id, ($row->checked_out && $row->checked_out != $my->id ) ); |
$text = $orders[$i]->text; |
| 2021 |
} |
} |
| 2022 |
|
|
| 2023 |
return $checked; |
$order[] = mosHTML::makeOption( $orders[$i]->value, $orders[$i]->value.' ('.$text.')' ); |
| 2024 |
} |
} |
| 2025 |
|
$order[] = mosHTML::makeOption( $orders[$i-1]->value+1, ($orders[$i-1]->value+1).' last' ); |
| 2026 |
|
|
| 2027 |
function PublishedProcessing( &$row, $i ) { |
return $order; |
| 2028 |
$img = $row->published ? 'publish_g.png' : 'publish_x.png'; |
} |
|
$task = $row->published ? 'unpublish' : 'publish'; |
|
|
$alt = $row->published ? 'Published' : 'Unpublished'; |
|
|
$action = $row->published ? 'Unpublish Item' : 'Publish item'; |
|
|
|
|
|
$href = ' |
|
|
<a href="javascript: void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $task .'\')" title="'. $action .'"> |
|
|
<img src="images/'. $img .'" border="0" alt="'. $alt .'" /> |
|
|
</a>' |
|
|
; |
|
| 2029 |
|
|
| 2030 |
return $href; |
/** |
| 2031 |
|
* Makes a variable safe to display in forms |
| 2032 |
|
* |
| 2033 |
|
* Object parameters that are non-string, array, object or start with underscore |
| 2034 |
|
* will be converted |
| 2035 |
|
* @param object An object to be parsed |
| 2036 |
|
* @param int The optional quote style for the htmlspecialchars function |
| 2037 |
|
* @param string|array An optional single field name or array of field names not |
| 2038 |
|
* to be parsed (eg, for a textarea) |
| 2039 |
|
*/ |
| 2040 |
|
function mosMakeHtmlSafe( &$mixed, $quote_style=ENT_QUOTES, $exclude_keys='' ) { |
| 2041 |
|
if (is_object( $mixed )) { |
| 2042 |
|
foreach (get_object_vars( $mixed ) as $k => $v) { |
| 2043 |
|
if (is_array( $v ) || is_object( $v ) || $v == NULL || substr( $k, 1, 1 ) == '_' ) { |
| 2044 |
|
continue; |
| 2045 |
|
} |
| 2046 |
|
if (is_string( $exclude_keys ) && $k == $exclude_keys) { |
| 2047 |
|
continue; |
| 2048 |
|
} else if (is_array( $exclude_keys ) && in_array( $k, $exclude_keys )) { |
| 2049 |
|
continue; |
| 2050 |
|
} |
| 2051 |
|
$mixed->$k = htmlspecialchars( $v, $quote_style ); |
| 2052 |
|
} |
| 2053 |
} |
} |
| 2054 |
} |
} |
| 2055 |
|
|
| 2056 |
/** |
/** |
| 2057 |
* Sorts an Array of objects |
* Checks whether a menu option is within the users access level |
| 2058 |
|
* @param int Item id number |
| 2059 |
|
* @param string The menu option |
| 2060 |
|
* @param int The users group ID number |
| 2061 |
|
* @param database A database connector object |
| 2062 |
|
* @return boolean True if the visitor's group at least equal to the menu access |
| 2063 |
*/ |
*/ |
| 2064 |
function SortArrayObjects_cmp( &$a, &$b ) { |
function mosMenuCheck( $Itemid, $menu_option, $task, $gid ) { |
| 2065 |
global $csort_cmp; |
$menuhandler = mosMenuHandler::getInstance(); |
| 2066 |
|
return $menuhandler->menuCheck($Itemid, $menu_option, $task, $gid); |
| 2067 |
|
} |
| 2068 |
|
|
| 2069 |
if ( $a->$csort_cmp['key'] > $b->$csort_cmp['key'] ) { |
/** |
| 2070 |
return $csort_cmp['direction']; |
* Returns formated date according to current local and adds time offset |
| 2071 |
|
* @param string date in datetime format |
| 2072 |
|
* @param string format optional format for strftime |
| 2073 |
|
* @param offset time offset if different than global one |
| 2074 |
|
* @returns formated date |
| 2075 |
|
*/ |
| 2076 |
|
function mosFormatDate( $date, $format="", $offset="" ){ |
| 2077 |
|
global $mosConfig_offset; |
| 2078 |
|
if ( $format == '' ) { |
| 2079 |
|
// %Y-%m-%d %H:%M:%S |
| 2080 |
|
$format = _DATE_FORMAT_LC; |
| 2081 |
|
} |
| 2082 |
|
if ( $offset == '' ) { |
| 2083 |
|
$offset = $mosConfig_offset; |
| 2084 |
|
} |
| 2085 |
|
if ( $date && ereg( "([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $date, $regs ) ) { |
| 2086 |
|
$date = mktime( $regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1] ); |
| 2087 |
|
$date = $date > -1 ? strftime( $format, $date + ($offset*60*60) ) : '-'; |
| 2088 |
|
} |
| 2089 |
|
return $date; |
| 2090 |
} |
} |
| 2091 |
|
|
| 2092 |
if ( $a->$csort_cmp['key'] < $b->$csort_cmp['key'] ) { |
/** |
| 2093 |
return -1 * $csort_cmp['direction']; |
* Returns current date according to current local and time offset |
| 2094 |
|
* @param string format optional format for strftime |
| 2095 |
|
* @returns current date |
| 2096 |
|
*/ |
| 2097 |
|
function mosCurrentDate( $format="" ) { |
| 2098 |
|
global $mosConfig_offset; |
| 2099 |
|
if ($format=="") { |
| 2100 |
|
$format = _DATE_FORMAT_LC; |
| 2101 |
|
} |
| 2102 |
|
$date = strftime( $format, time() + ($mosConfig_offset*60*60) ); |
| 2103 |
|
return $date; |
| 2104 |
} |
} |
| 2105 |
|
|
| 2106 |
return 0; |
/** |
| 2107 |
|
* Utility function to provide ToolTips |
| 2108 |
|
* @param string ToolTip text |
| 2109 |
|
* @param string Box title |
| 2110 |
|
* @returns HTML code for ToolTip |
| 2111 |
|
*/ |
| 2112 |
|
function mosToolTip( $tooltip, $title='', $width='', $image='tooltip.png', $text='', $href='#' ) { |
| 2113 |
|
global $mosConfig_live_site; |
| 2114 |
|
|
| 2115 |
|
if ( $width ) { |
| 2116 |
|
$width = ', WIDTH, \''.$width .'\''; |
| 2117 |
|
} |
| 2118 |
|
if ( $title ) { |
| 2119 |
|
$title = ', CAPTION, \''.$title .'\''; |
| 2120 |
|
} |
| 2121 |
|
if ( !$text ) { |
| 2122 |
|
$image = $mosConfig_live_site . '/includes/js/ThemeOffice/'. $image; |
| 2123 |
|
$text = '<img src="'. $image .'" border="0" />'; |
| 2124 |
|
} |
| 2125 |
|
$style = 'style="text-decoration: none; color: #333;"'; |
| 2126 |
|
if ( $href ) { |
| 2127 |
|
$style = ''; |
| 2128 |
|
} |
| 2129 |
|
$tip = "<a href=\"". $href ."\" onMouseOver=\"return overlib('" . $tooltip . "'". $title .", BELOW, RIGHT". $width .");\" onmouseout=\"return nd();\" ". $style .">". $text ."</a>"; |
| 2130 |
|
return $tip; |
| 2131 |
} |
} |
| 2132 |
|
|
| 2133 |
/** |
/** |
| 2134 |
* Sorts an Array of objects |
* Utility function to provide Warning Icons |
| 2135 |
* sort_direction [1 = Ascending] [-1 = Descending] |
* @param string Warning text |
| 2136 |
|
* @param string Box title |
| 2137 |
|
* @returns HTML code for Warning |
| 2138 |
*/ |
*/ |
| 2139 |
function SortArrayObjects( &$a, $k, $sort_direction=1 ) { |
function mosWarning($warning, $title='Mambo Warning') { |
| 2140 |
global $csort_cmp; |
global $mosConfig_live_site; |
| 2141 |
|
$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>"; |
| 2142 |
|
return $tip; |
| 2143 |
|
} |
| 2144 |
|
|
| 2145 |
$csort_cmp = array( |
function mosCreateGUID(){ |
| 2146 |
'key' => $k, |
srand((double)microtime()*1000000); |
| 2147 |
'direction' => $sort_direction |
$r = rand ; |
| 2148 |
); |
$u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
| 2149 |
|
$m = md5 ($u); |
| 2150 |
|
return($m); |
| 2151 |
|
} |
| 2152 |
|
|
| 2153 |
usort( $a, 'SortArrayObjects_cmp' ); |
function mosCompressID( $ID ){ |
| 2154 |
|
return(Base64_encode(pack("H*",$ID))); |
| 2155 |
|
} |
| 2156 |
|
|
| 2157 |
unset( $csort_cmp ); |
function mosExpandID( $ID ) { |
| 2158 |
|
return ( implode(unpack("H*",Base64_decode($ID)), '') ); |
| 2159 |
} |
} |
| 2160 |
|
|
| 2161 |
/** |
/** |
| 2162 |
* Sends mail to admin |
* Function to create a mail object for futher use (uses phpMailer) |
| 2163 |
|
* @param string From e-mail address |
| 2164 |
|
* @param string From name |
| 2165 |
|
* @param string E-mail subject |
| 2166 |
|
* @param string Message body |
| 2167 |
|
* @return object Mail object |
| 2168 |
*/ |
*/ |
| 2169 |
function mosSendAdminMail( $adminName, $adminEmail, $email, $type, $title, $author ) { |
function mosCreateMail( $from='', $fromname='', $subject, $body ) { |
| 2170 |
global $mosConfig_live_site; |
global $mosConfig_absolute_path, $mosConfig_sendmail; |
| 2171 |
|
global $mosConfig_smtpauth, $mosConfig_smtpuser; |
| 2172 |
|
global $mosConfig_smtppass, $mosConfig_smtphost; |
| 2173 |
|
global $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_mailer; |
| 2174 |
|
|
| 2175 |
$subject = _MAIL_SUB." '$type'"; |
$mail = new mosPHPMailer(); |
|
$message = _MAIL_MSG; |
|
|
eval ("\$message = \"$message\";"); |
|
|
mosMail($mosConfig_mailfrom, $mosConfig_fromname, $adminEmail, $subject, $message); |
|
|
} |
|
| 2176 |
|
|
| 2177 |
/* |
$mail->PluginDir = $mosConfig_absolute_path .'/includes/phpmailer/'; |
| 2178 |
* Includes pathway file |
$mail->SetLanguage( 'en', $mosConfig_absolute_path . '/includes/phpmailer/language/' ); |
| 2179 |
*/ |
$mail->CharSet = substr_replace(_ISO, '', 0, 8); |
| 2180 |
function mosPathWay() { |
$mail->IsMail(); |
| 2181 |
$Itemid = mosGetParam($_REQUEST,'Itemid',''); |
$mail->From = $from ? $from : $mosConfig_mailfrom; |
| 2182 |
require $GLOBALS['mosConfig_absolute_path'] . '/includes/pathway.php'; |
$mail->FromName = $fromname ? $fromname : $mosConfig_fromname; |
| 2183 |
} |
$mail->Mailer = $mosConfig_mailer; |
| 2184 |
|
|
| 2185 |
/** |
// Add smtp values if needed |
| 2186 |
* Displays a not authorised message |
if ( $mosConfig_mailer == 'smtp' ) { |
| 2187 |
* |
$mail->SMTPAuth = $mosConfig_smtpauth; |
| 2188 |
* If the user is not logged in then an addition message is displayed. |
$mail->Username = $mosConfig_smtpuser; |
| 2189 |
*/ |
$mail->Password = $mosConfig_smtppass; |
| 2190 |
function mosNotAuth() { |
$mail->Host = $mosConfig_smtphost; |
| 2191 |
global $my; |
} else |
| 2192 |
|
|
| 2193 |
echo _NOT_AUTH; |
// Set sendmail path |
| 2194 |
if ($my->id < 1) { |
if ( $mosConfig_mailer == 'sendmail' ) { |
| 2195 |
echo "<br />" . _DO_LOGIN; |
if (isset($mosConfig_sendmail)) |
| 2196 |
} |
$mail->Sendmail = $mosConfig_sendmail; |
| 2197 |
} |
} // if |
| 2198 |
|
|
| 2199 |
/** |
$mail->Subject = $subject; |
| 2200 |
* Replaces & with & for xhtml compliance |
$mail->Body = $body; |
|
* |
|
|
* Needed to handle unicode conflicts due to unicode conflicts |
|
|
*/ |
|
|
function ampReplace( $text ) { |
|
|
$text = str_replace( '&#', '*-*', $text ); |
|
|
$text = str_replace( '&', '&', $text ); |
|
|
$text = str_replace( '*-*', '&#', $text ); |
|
| 2201 |
|
|
| 2202 |
return $text; |
return $mail; |
| 2203 |
} |
} |
| 2204 |
|
|
| 2205 |
/** |
/** |
| 2206 |
* Prepares results from search for display |
* Mail function (uses phpMailer) |
| 2207 |
* @param string The source string |
* @param string From e-mail address |
| 2208 |
* @param int Number of chars to trim |
* @param string From name |
| 2209 |
* @param string The searchword to select around |
* @param string/array Recipient e-mail address(es) |
| 2210 |
* @return string |
* @param string E-mail subject |
| 2211 |
|
* @param string Message body |
| 2212 |
|
* @param boolean false = plain text, true = HTML |
| 2213 |
|
* @param string/array CC e-mail address(es) |
| 2214 |
|
* @param string/array BCC e-mail address(es) |
| 2215 |
|
* @param string/array Attachment file name(s) |
| 2216 |
|
* @param string/array Reply-to e-mail address |
| 2217 |
|
* @param string/array Reply-to name |
| 2218 |
*/ |
*/ |
| 2219 |
function mosPrepareSearchContent( $text, $length=200, $searchword ) { |
function mosMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=NULL, $bcc=NULL, $attachment=NULL, $replyto=NULL, $replytoname=NULL ) { |
| 2220 |
// strips tags won't remove the actual jscript |
global $mosConfig_debug; |
| 2221 |
$text = preg_replace( "'<script[^>]*>.*?</script>'si", "", $text ); |
$mail = mosCreateMail( $from, $fromname, $subject, $body ); |
| 2222 |
$text = preg_replace( '/{.+?}/', '', $text); |
|
| 2223 |
//$text = preg_replace( '/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is','\2', $text ); |
// activate HTML formatted emails |
| 2224 |
return mosSmartSubstr( strip_tags( $text ), $length, $searchword ); |
if ( $mode ) { |
| 2225 |
|
$mail->IsHTML(true); |
| 2226 |
} |
} |
| 2227 |
|
|
| 2228 |
/** |
if( is_array($recipient) ) { |
| 2229 |
* returns substring of characters around a searchword |
foreach ($recipient as $to) { |
| 2230 |
* @param string The source string |
$mail->AddAddress($to); |
| 2231 |
* @param int Number of chars to return |
} |
|
* @param string The searchword to select around |
|
|
* @return string |
|
|
*/ |
|
|
function mosSmartSubstr($text, $length=200, $searchword) { |
|
|
$wordpos = strpos(strtolower($text), strtolower($searchword)); |
|
|
$halfside = intval($wordpos - $length/2 - strlen($searchword)); |
|
|
if ($wordpos && $halfside > 0) { |
|
|
return '...' . substr($text, $halfside, $length); |
|
| 2232 |
} else { |
} else { |
| 2233 |
return substr( $text, 0, $length); |
$mail->AddAddress($recipient); |
| 2234 |
|
} |
| 2235 |
|
if (isset($cc)) { |
| 2236 |
|
if( is_array($cc) ) |
| 2237 |
|
foreach ($cc as $to) $mail->AddCC($to); |
| 2238 |
|
else |
| 2239 |
|
$mail->AddCC($cc); |
| 2240 |
} |
} |
| 2241 |
|
if (isset($bcc)) { |
| 2242 |
|
if( is_array($bcc) ) |
| 2243 |
|
foreach ($bcc as $to) $mail->AddBCC($to); |
| 2244 |
|
else |
| 2245 |
|
$mail->AddBCC($bcc); |
| 2246 |
} |
} |
| 2247 |
|
if ($attachment) { |
| 2248 |
/** |
if ( is_array($attachment) ) |
| 2249 |
* Chmods files and directories recursively to given permissions. Available from 4.5.2 up. |
foreach ($attachment as $fname) $mail->AddAttachment($fname); |
| 2250 |
* @param path The starting file or directory (no trailing slash) |
else |
| 2251 |
* @param filemode Integer value to chmod files. NULL = dont chmod files. |
$mail->AddAttachment($attachment); |
|
* @param dirmode Integer value to chmod directories. NULL = dont chmod directories. |
|
|
* @return TRUE=all succeeded FALSE=one or more chmods failed |
|
|
*/ |
|
|
function mosChmodRecursive($path, $filemode=NULL, $dirmode=NULL) |
|
|
{ |
|
|
$ret = TRUE; |
|
|
if (is_dir($path)) { |
|
|
$dh = opendir($path); |
|
|
while ($file = readdir($dh)) { |
|
|
if ($file != '.' && $file != '..') { |
|
|
$fullpath = $path.'/'.$file; |
|
|
if (is_dir($fullpath)) { |
|
|
if (!mosChmodRecursive($fullpath, $filemode, $dirmode)) |
|
|
$ret = FALSE; |
|
|
} else { |
|
|
if (isset($filemode)) |
|
|
if (!@chmod($fullpath, $filemode)) |
|
|
$ret = FALSE; |
|
|
} // if |
|
|
} // if |
|
|
} // while |
|
|
closedir($dh); |
|
|
if (isset($dirmode)) |
|
|
if (!@chmod($path, $dirmode)) |
|
|
$ret = FALSE; |
|
|
} else { |
|
|
if (isset($filemode)) |
|
|
$ret = @chmod($path, $filemode); |
|
| 2252 |
} // if |
} // if |
| 2253 |
return $ret; |
if ($replyto) { |
| 2254 |
} // mosChmodRecursive |
if ( is_array($replyto) ) { |
| 2255 |
|
reset($replytoname); |
| 2256 |
|
foreach ($replyto as $to) { |
| 2257 |
|
$toname = ((list($key, $value) = each($replytoname)) |
| 2258 |
|
? $value : ""); |
| 2259 |
|
$mail->AddReplyTo($to, $toname); |
| 2260 |
|
} |
| 2261 |
|
} else |
| 2262 |
|
$mail->AddReplyTo($replyto, $replytoname); |
| 2263 |
|
} |
| 2264 |
|
$mailssend = $mail->Send(); |
| 2265 |
|
|
| 2266 |
|
if( $mosConfig_debug ) { |
| 2267 |
|
//$mosDebug->message( "Mails send: $mailssend"); |
| 2268 |
|
} |
| 2269 |
|
if( $mail->error_count > 0 ) { |
| 2270 |
|
//$mosDebug->message( "The mail message $fromname <$from> about $subject to $recipient <b>failed</b><br /><pre>$body</pre>", false ); |
| 2271 |
|
//$mosDebug->message( "Mailer Error: " . $mail->ErrorInfo . "" ); |
| 2272 |
|
} |
| 2273 |
|
return $mailssend; |
| 2274 |
|
} // mosMail |
| 2275 |
|
|
| 2276 |
/** |
/** |
| 2277 |
* Chmods files and directories recursively to mos global permissions. Available from 4.5.2 up. |
* Random password generator |
| 2278 |
* @param path The starting file or directory (no trailing slash) |
* @return password |
|
* @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 |
|
| 2279 |
*/ |
*/ |
| 2280 |
function mosChmod($path) |
function mosMakePassword() { |
| 2281 |
{ |
$salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
| 2282 |
global $mosConfig_fileperms, $mosConfig_dirperms; |
$len = strlen($salt); |
| 2283 |
$filemode = NULL; |
$makepass=""; |
| 2284 |
if ($mosConfig_fileperms != '') |
mt_srand(10000000*(double)microtime()); |
| 2285 |
$filemode = octdec($mosConfig_fileperms); |
for ($i = 0; $i < 8; $i++) |
| 2286 |
$dirmode = NULL; |
$makepass .= $salt[mt_rand(0,$len - 1)]; |
| 2287 |
if ($mosConfig_dirperms != '') |
return $makepass; |
| 2288 |
$dirmode = octdec($mosConfig_dirperms); |
} |
|
if (isset($filemode) || isset($dirmode)) |
|
|
return mosChmodRecursive($path, $filemode, $dirmode); |
|
|
return TRUE; |
|
|
} // mosChmod |
|
| 2289 |
|
|
| 2290 |
|
if (!function_exists('html_entity_decode')) { |
| 2291 |
/** |
/** |
| 2292 |
* Function to convert array to integer values |
* html_entity_decode function for backward compatability in PHP |
| 2293 |
|
* @param string |
| 2294 |
|
* @param string |
| 2295 |
*/ |
*/ |
| 2296 |
function mosArrayToInts( &$array, $default=null ) { |
function html_entity_decode ($string, $opt = ENT_COMPAT) { |
| 2297 |
if (is_array( $array )) { |
|
| 2298 |
$n = count( $array ); |
$trans_tbl = get_html_translation_table (HTML_ENTITIES); |
| 2299 |
for ($i = 0; $i < $n; $i++) { |
$trans_tbl = array_flip ($trans_tbl); |
| 2300 |
$array[$i] = intval( $array[$i] ); |
|
| 2301 |
|
if ($opt & 1) { // Translating single quotes |
| 2302 |
|
// Add single quote to translation table; |
| 2303 |
|
// doesn't appear to be there by default |
| 2304 |
|
$trans_tbl["'"] = "'"; |
| 2305 |
} |
} |
| 2306 |
} else { |
|
| 2307 |
if (is_null( $default )) { |
if (!($opt & 2)) { // Not translating double quotes |
| 2308 |
return array(); |
// Remove double quote from translation table |
| 2309 |
} else { |
unset($trans_tbl["""]); |
|
return array( $default ); |
|
| 2310 |
} |
} |
| 2311 |
|
|
| 2312 |
|
return strtr ($string, $trans_tbl); |
| 2313 |
} |
} |
| 2314 |
} |
} |
| 2315 |
|
|