0) { error_reporting( $_Config_error_reporting ); } #Connect to MySQL & Create Object //$local_backup_path = $_Config_absolute_path.'/administrator/backups'; //$media_path = $_Config_absolute_path.'/media/'; //$image_path = $_Config_absolute_path.'/images/stories'; //$image_size = 100; //require_once( $_Config_absolute_path . "/includes/version.php" ); require_once( $_Config_absolute_path . "/includes/connMySQL.class.php" ); //require_once( $_Config_absolute_path . "/includes/gacl.class.php" ); //require_once( $_Config_absolute_path . "/includes/gacl_api.class.php" ); //require_once( $_Config_absolute_path . "/includes/phpmailer/class.phpmailer.php" ); //require_once( $_Config_absolute_path . "/includes/mamboxml.php" ); if (sizeof($_POST) > 0) $_FORM = $_POST; else if (sizeof($_GET) > 0) $_FORM = $_GET; else $_FORM = array(""); /** * Utility function to return a value from a named array or a specified default */ define( "_MOS_NOTRIM", 0x0001 ); define( "_MOS_ALLOWHTML", 0x0002 ); function mosGetParam( &$arr, $name, $def=null, $mask=0 ) { $return = null; if (isset( $arr[$name] )) { if (is_string( $arr[$name] )) { if (!($mask&_MOS_NOTRIM)) { $arr[$name] = trim( $arr[$name] ); } if (!($mask&_MOS_ALLOWHTML)) { $arr[$name] = strip_tags( $arr[$name] ); } if (!get_magic_quotes_gpc()) { $arr[$name] = addslashes( $arr[$name] ); } } return $arr[$name]; } else { return $def; } } /** * 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 ) { if (!is_array( $array ) || !is_object( $obj )) { return (false); } if ($prefix) { foreach (get_object_vars($obj) as $k => $v) { if (strpos( $ignore, $k) === false) { if (isset($array[$prefix . $k ])) { $obj->$k = ($checkSlashes && get_magic_quotes_gpc()) ? mosStripslashes( $array[$k] ) : $array[$k]; } } } } else { foreach (get_object_vars($obj) as $k => $v) { if (strpos( $ignore, $k) === false) { if (isset($array[$k])) { $obj->$k = ($checkSlashes && get_magic_quotes_gpc()) ? mosStripslashes( $array[$k] ) : $array[$k]; } } } } return true; } /** * Utility function to read the files in a directory * @param string The file system path * @param string A filter for the names * @param boolean Recurse search into sub-directories * @param boolean True if to prepend the full path to the file name */ function mosReadDirectory( $path, $filter='.', $recurse=false, $fullpath=false ) { $arr = 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='' ) { if (trim( $msg )) { if (strpos( $url, '?' )) { $url .= '&mosmsg=' . urlencode( $msg ); } else { $url .= '?mosmsg=' . urlencode( $msg ); } } if (headers_sent()) { echo "\n"; } else { header( "Location: $url" ); //header ("Refresh: 0 url=$url"); } exit(); } 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 = 'L '; $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; } 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; } /** * Checks the user agent string against known browsers */ function mosGetBrowser( $agent ) { require( "library/agent_browser.php" ); 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'; } /** * Checks the user agent string against known operating systems */ function mosGetOS( $agent ) { require( "library/agent_os.php" ); foreach ($osSearchOrder as $key) { if (preg_match( "/$key/i", $agent )) { return $osAlias[$key]; break; } } return 'Unknown'; } /** * @param string SQL with ordering As value and 'name field' AS text * @param integer The length of the truncated headline */ function mosGetOrderingList( $sql, $chop='30' ) { global $database; $order = array(); $database->setQuery( $sql ); if (!($orders = $database->loadObjectList())) { if ($database->getErrorNum()) { echo $database->stderr(); return false; } else { $order[] = mosHTML::makeOption( 1, 'first' ); return $order; } } $order[] = mosHTML::makeOption( 0, '0 first' ); for ($i=0, $n=count( $orders ); $i < $n; $i++) { if (strlen($orders[$i]->text) > $chop) { $text = substr($orders[$i]->text,0,$chop)."..."; } else { $text = $orders[$i]->text; } $order[] = mosHTML::makeOption( $orders[$i]->value, $orders[$i]->value.' ('.$text.')' ); } $order[] = mosHTML::makeOption( $orders[$i-1]->value+1, ($orders[$i-1]->value+1).' last' ); return $order; } /** * Makes a variable safe to display in forms * * 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) */ function mosMakeHtmlSafe( &$mixed, $quote_style=ENT_QUOTES, $exclude_keys='' ) { if (is_object( $mixed )) { 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 ); } } } function mosCreateGUID(){ srand((double)microtime()*1000000); $r = rand ; $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); $m = md5 ($u); return($m); } function mosCompressID( $ID ){ return(Base64_encode(pack("H*",$ID))); } function mosExpandID( $ID ) { return ( implode(unpack("H*",Base64_decode($ID)), '') ); } /** * Random password generator * @return password */ function mosMakePassword( $digit=8 ) { $salt = "abcdefhijkmnpqrstuwxyzABCDEFGHJKLMNPQRSTUWXY1345678"; $len = strlen($salt); $makepass=""; mt_srand(10000000*(double)microtime()); for ($i = 0; $i < $digit; $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); } } /** * Utility class for all HTML drawing classes * @package Mambo */ class mosHTML { function makeOption( $value, $text='' ) { $obj = new stdClass; $obj->value = $value; $obj->text = trim( $text ) ? $text : $value; return $obj; } function writableCell( $folder ) { echo ''; echo '' . $folder . '/'; echo ''; echo is_writable( "../$folder" ) ? 'Writeable' : 'Unwriteable' . ''; echo ''; } /** * Generates an HTML select list * @param array An array of objects * @param string The value of the HTML name attribute * @param string Additional HTML attributes for the "; for ($i=0, $n=count( $arr ); $i < $n; $i++ ) { $k = $arr[$i]->$key; $t = $arr[$i]->$text; $id = @$arr[$i]->id; $extra = ''; $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; if (is_array( $selected )) { foreach ($selected as $obj) { $k2 = $obj->$key; if ($k == $k2) { $extra .= " selected=\"selected\""; break; } } } else { $extra .= ($k == $selected ? " selected=\"selected\"" : ''); } $html .= "\n\t"; } $html .= "\n\n"; return $html; } /** * Writes a select list of integers * @param int The start integer * @param int The end integer * @param int The increment * @param string The value of the HTML name attribute * @param string Additional HTML attributes for the tag * @param mixed The key that is selected * @returns string HTML for the select list values */ function monthSelectList( $tag_name, $tag_attribs, $selected ) { $arr = array( mosHTML::makeOption( '01', _JAN ), mosHTML::makeOption( '02', _FEB ), mosHTML::makeOption( '03', _MAR ), mosHTML::makeOption( '04', _APR ), mosHTML::makeOption( '05', _MAY ), mosHTML::makeOption( '06', _JUN ), mosHTML::makeOption( '07', _JUL ), mosHTML::makeOption( '08', _AUG ), mosHTML::makeOption( '09', _SEP ), mosHTML::makeOption( '10', _OCT ), mosHTML::makeOption( '11', _NOV ), mosHTML::makeOption( '12', _DEC ) ); return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', $selected ); } /** * Generates an HTML select list from a tree based query list * @param array Source array with id and parent fields * @param array The id of the current list item * @param array Target array. May be an empty array. * @param array An array of objects * @param string The value of the HTML name attribute * @param string Additional HTML attributes for the tag * @param mixed The key that is selected * @returns string HTML for the select list values */ function yesnoSelectList( $tag_name, $tag_attribs, $selected, $yes=_CMN_YES, $no=_CMN_NO ) { $arr = array( mosHTML::makeOption( '0', $no ), mosHTML::makeOption( '1', $yes ), ); return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', $selected ); } /** * Generates an HTML radio list * @param array An array of objects * @param string The value of the HTML name attribute * @param string Additional HTML attributes for the " . $t; } $html .= "\n"; return $html; } /** * Writes a yes/no radio list * @param string The value of the HTML name attribute * @param string Additional HTML attributes for the '; } } function sortIcon( $base_href, $field, $state='none' ) { global $mosConfig_live_site; $alts = array( 'none' => _CMN_SORT_NONE, 'asc' => _CMN_SORT_ASC, 'desc' => _CMN_SORT_DESC, ); $next_state = 'asc'; if ($state == 'asc') { $next_state = 'desc'; } else if ($state == 'desc') { $next_state = 'none'; } $html = "" . "\"{$alts[$next_state]}\"" . ""; return $html; } /** * Writes Close Button */ function CloseButton ( &$params, $hide_js=NULL ) { // displays close button in Pop-up window if ( $params->get( 'popup' ) && !$hide_js ) { ?>
get( 'back_button' ) && !$params->get( 'popup' ) && !$hide_js) { ?>
]*>.*?'si", '', $text ); $text = preg_replace( '/]*>([^<]+)<\/a>/is', '\2 (\1)', $text ); $text = preg_replace( '//', '', $text ); $text = preg_replace( '/{.+?}/', '', $text ); $text = preg_replace( '/ /', ' ', $text ); $text = preg_replace( '/&/', ' ', $text ); $text = preg_replace( '/"/', ' ', $text ); $text = strip_tags( $text ); $text = htmlspecialchars( $text ); return $text; } /** * Writes Print icon */ function PrintIcon( &$row, &$params, $hide_js, $link, $status=NULL ) { global $mosConfig_live_site, $mosConfig_absolute_path, $cur_template, $Itemid; if ( $params->get( 'print' ) && !$hide_js ) { // use default settings if none declared if ( !$status ) { $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no'; } // checks template image directory for image, if non found default are loaded if ( $params->get( 'icons' ) ) { $image = mosAdminMenus::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, _CMN_PRINT ); } else { $image = _ICON_SEP .' '. _CMN_PRINT. ' '. _ICON_SEP; } if ( $params->get( 'popup' ) && !$hide_js ) { // Print Preview button - used when viewing page ?> "; $replacement .= "\n\n"; $replacement .= ""; $replacement .= ""; return $replacement; } function encoding_converter( $text ) { // replace vowels with character encoding $text = str_replace( 'a', 'a', $text ); $text = str_replace( 'e', 'e', $text ); $text = str_replace( 'i', 'i', $text ); $text = str_replace( 'o', 'o', $text ); $text = str_replace( 'u', 'u', $text ); return $text; } } /* // define class connMySQL // Utility mosGetParam mosStripslashes mosBindArrayToObject mosReadDirectory mosRedirect mosTreeRecurse mosPathName mosObjectToArray mosGetBrowser mosGetOS mosGetOrderingList mosMakeHtmlSafe mosMenuCheck mosToolTip mosWarning mosCreateGUID mosCompressID mosExpandID initGzip doGzip mosMakePassword html_entity_decode 709 : class mosHTML */ ?>