2006-12-02 04:36:16 +00:00
< ? php
/*
2009-11-17 10:35:34 +00:00
* e107 website system
*
2009-11-18 01:06:08 +00:00
* Copyright ( C ) 2008 - 2009 e107 Inc ( e107 . org )
2009-11-17 10:35:34 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
*
*
* $Source : / cvs_backup / e107_0 . 8 / e107_admin / admin . php , v $
2010-02-10 18:18:01 +00:00
* $Revision $
* $Date $
* $Author $
2009-11-17 10:35:34 +00:00
*/
2006-12-02 04:36:16 +00:00
require_once ( '../class2.php' );
2013-03-20 23:50:30 -07:00
include_once ( e107 :: coreTemplatePath ( 'admin_icons' )); // Needs to be loaded before infopanel AND in boot.php
2012-12-06 14:53:58 -08:00
if ( vartrue ( $_GET [ 'iframe' ]) == 1 )
2012-05-17 09:19:44 +00:00
{
define ( 'e_IFRAME' , true );
}
2016-01-13 01:31:12 -08:00
2006-12-02 04:36:16 +00:00
$e_sub_cat = 'main' ;
2012-12-04 00:14:43 -08:00
2013-02-26 21:27:36 -08:00
if ( varset ( $pref [ 'adminstyle' ]) == 'cascade' || varset ( $pref [ 'adminstyle' ]) == 'beginner' ) // Deprecated Admin-include.
{
$pref [ 'adminstyle' ] = 'infopanel' ;
}
2013-02-07 15:22:00 +02:00
if ( strpos ( $pref [ 'adminstyle' ], 'infopanel' ) === 0 )
2012-12-04 00:14:43 -08:00
{
require_once ( e_ADMIN . 'includes/' . $pref [ 'adminstyle' ] . '.php' );
2013-02-07 15:22:00 +02:00
$_class = 'adminstyle_' . $pref [ 'adminstyle' ];
if ( class_exists ( $_class , false ))
{
$adp = new $_class ;
}
else $adp = new adminstyle_infopanel ;
2012-12-04 00:14:43 -08:00
}
2013-05-18 01:31:56 -07:00
2013-02-09 16:02:03 +02:00
require_once ( e_ADMIN . 'boot.php' );
require_once ( e_ADMIN . 'auth.php' );
2008-08-25 10:46:46 +00:00
require_once ( e_HANDLER . 'upload_handler.php' );
2013-02-26 21:27:36 -08:00
2008-08-25 10:46:46 +00:00
2013-05-18 01:31:56 -07:00
new admin_start ;
2006-12-02 04:36:16 +00:00
2013-05-18 01:31:56 -07:00
$mes = e107 :: getMessage ();
2013-04-22 03:29:10 -07:00
2013-05-18 01:31:56 -07:00
if ( ! isset ( $pref [ 'adminstyle' ])) $pref [ 'adminstyle' ] = 'infopanel' ; // Shouldn't be needed - but just in case
2013-04-22 03:29:10 -07:00
2013-05-18 01:31:56 -07:00
class admin_start
2013-04-22 03:29:10 -07:00
{
2013-05-18 01:31:56 -07:00
private $incompat = array (
'banhelper' => 1.7 ,
'slir_admin' => 1.0 ,
'facebook_like' => 0.7 ,
'unanswered' => 1.4 ,
'lightwindow' => '1.0b' ,
'aa_jquery' => 1.2 ,
2016-02-17 16:51:25 +01:00
'aa_jquery' => 1.4 ,
2013-05-18 01:31:56 -07:00
'who' => 1.0 ,
2013-05-29 16:16:17 +02:00
'ratings' => 4.2 ,
2014-09-07 16:34:17 +02:00
'lightbox' => 1.5 ,
2016-03-03 15:44:35 -08:00
'e107slider' => 0.1 ,
'forumthanks' => 0.5
2013-05-18 01:31:56 -07:00
);
private $allowed_types = null ;
2015-08-24 17:39:28 -07:00
private $refresh = false ;
2013-05-18 01:31:56 -07:00
function __construct ()
2013-04-22 03:29:10 -07:00
{
2015-08-24 17:39:28 -07:00
$this -> checkPaths ();
$this -> checkTimezone ();
2013-05-18 02:02:00 -07:00
$this -> checkWritable ();
2013-05-18 01:31:56 -07:00
$this -> checkHtmlarea ();
$this -> checkIncompatiblePlugins ();
$this -> checkFileTypes ();
$this -> checkSuspiciousFiles ();
2015-07-17 18:22:56 -07:00
$this -> checkDeprecated ();
2015-08-24 17:39:28 -07:00
if ( $this -> refresh == true )
{
e107 :: getRedirect () -> go ( e_SELF );
}
2013-04-22 03:29:10 -07:00
}
2015-08-24 17:39:28 -07:00
function checkPaths ()
{
$create_dir = array ( e_MEDIA , e_SYSTEM , e_CACHE , e_CACHE_CONTENT , e_CACHE_IMAGE , e_CACHE_DB , e_LOG , e_BACKUP , e_CACHE_URL , e_TEMP , e_IMPORT );
$refresh = false ;
foreach ( $create_dir as $dr )
{
if ( ! is_dir ( $dr ))
{
if ( mkdir ( $dr , 0755 ))
{
$this -> refresh = true ;
}
}
}
}
function checkTimezone ()
{
$mes = e107 :: getMessage ();
$timezone = e107 :: pref ( 'core' , 'timezone' );
if ( e107 :: getDate () -> isValidTimezone ( $timezone ) == false )
{
$mes -> addWarning ( " Your timezone setting ( " . $timezone . " ) is invalid. It has been reset to UTC. To Modify, please go to Admin -> Preferences -> Date Display Options. " , 'default' , true );
e107 :: getConfig () -> set ( 'timezone' , 'UTC' ) -> save ( false , true , false );
$this -> refresh = true ;
}
}
2013-05-18 02:02:00 -07:00
function checkWritable ()
{
$mes = e107 :: getMessage ();
2013-10-31 17:51:12 -07:00
if ( deftrue ( 'e_MEDIA' ) && is_dir ( e_MEDIA ) && ! is_writable ( e_MEDIA ))
2013-05-18 02:02:00 -07:00
{
$mes -> addWarning ( " The folder " . e_MEDIA . " is not writable. Please correct before proceeding. " );
}
2013-10-31 17:51:12 -07:00
if ( deftrue ( 'e_SYSTEM' ) && is_dir ( e_SYSTEM ) && ! is_writable ( e_SYSTEM ))
2013-05-18 02:02:00 -07:00
{
$mes -> addWarning ( " The folder " . e_SYSTEM . " is not writable. Please correct before proceeding. " );
2016-03-21 14:22:49 -07:00
}
$files = e107 :: getFile () -> scandir ( e_IMAGE . " avatars " , 'jpg,gif,png,jpeg' );
if ( is_dir ( e_IMAGE . " avatars " ) && ! is_writable ( e_IMAGE . " avatars " ) && ! empty ( $files ))
{
$mes -> addWarning ( " Legacy avatars folder detected. Please make sure " . e_IMAGE . " avatars/ is writable. Please correct before proceeding. " );
}
2013-05-18 02:02:00 -07:00
}
2013-05-18 01:31:56 -07:00
function checkHtmlarea ()
{
$mes = e107 :: getMessage ();
if ( is_dir ( e_ADMIN . 'htmlarea' ) || is_dir ( e_HANDLER . 'htmlarea' ))
{
2016-03-21 14:22:49 -07:00
$mes -> addWarning ( e_HANDLER_ABS . " htmlarea/<br /> " . e_ADMIN_ABS . " htmlarea/ " );
2013-05-18 01:31:56 -07:00
}
}
2013-04-22 03:29:10 -07:00
2013-05-18 01:31:56 -07:00
function checkIncompatiblePlugins ()
2006-12-02 04:36:16 +00:00
{
2013-05-18 01:31:56 -07:00
$mes = e107 :: getMessage ();
$installedPlugs = e107 :: getPref ( 'plug_installed' );
$inCompatText = " " ;
$incompatFolders = array_keys ( $this -> incompat );
foreach ( $this -> incompat as $folder => $version )
2006-12-02 04:36:16 +00:00
{
2013-05-18 01:31:56 -07:00
if ( vartrue ( $installedPlugs [ $folder ]) && $version == $installedPlugs [ $folder ])
{
$inCompatText .= " <li> " . $folder . " v " . $installedPlugs [ $folder ] . " </li> " ;
}
2006-12-02 04:36:16 +00:00
}
2013-05-18 01:31:56 -07:00
if ( $inCompatText )
{
$text = " <ul> " . $inCompatText . " </ul> " ;
2015-07-13 19:09:30 -07:00
$mes -> addWarning ( " The following plugins are not compatible with this version of e107 and should be uninstalled: " . $text . " <a class='btn btn-default' href=' " . e_ADMIN . " plugin.php'>uninstall</a> " );
2013-05-18 01:31:56 -07:00
}
2006-12-02 04:36:16 +00:00
}
2015-07-17 18:22:56 -07:00
2016-03-21 14:22:49 -07:00
2015-07-17 18:22:56 -07:00
function checkDeprecated ()
{
$deprecated = array (
e_ADMIN . " ad_links.php " ,
2015-08-24 17:39:28 -07:00
e_PLUGIN . " tinymce4/e_meta.php " ,
e_THEME . " bootstrap3/css/bootstrap_dark.css " ,
2015-07-17 18:22:56 -07:00
e_PLUGIN . " search_menu/languages/English.php " ,
e_LANGUAGEDIR . " English/lan_parser_functions.php " ,
e_HANDLER . " np_class.php " ,
e_CORE . " shortcodes/single/user_extended.sc " ,
2016-01-12 17:11:06 -08:00
e_ADMIN . " download.php " ,
2016-02-11 11:21:03 -08:00
e_PLUGIN . " banner/config.php " ,
e_PLUGIN . " forum/newforumposts_menu_config.php " ,
2016-02-12 12:58:44 -08:00
e_PLUGIN . " forum/e_latest.php " ,
e_PLUGIN . " forum/e_status.php "
2016-02-11 11:21:03 -08:00
2015-07-17 18:22:56 -07:00
);
$found = array ();
foreach ( $deprecated as $path )
{
if ( file_exists ( $path ))
{
$found [] = $path ;
}
}
if ( ! empty ( $found ))
{
$text = " The following old files can be safely deleted from your system: " ;
$text .= " <ul><li> " . implode ( " </li><li> " , $found ) . " </li></ul> " ;
e107 :: getMessage () -> addWarning ( $text );
}
}
2013-05-18 01:31:56 -07:00
function checkFileTypes ()
2006-12-02 04:36:16 +00:00
{
2013-05-18 01:31:56 -07:00
$mes = e107 :: getMessage ();
$this -> allowed_types = get_filetypes (); // Get allowed types according to filetypes.xml or filetypes.php
if ( count ( $this -> allowed_types ) == 0 )
{
2016-03-21 14:22:49 -07:00
$this -> allowed_types = array ( 'zip' => 1 , 'gz' => 1 , 'jpg' => 1 , 'png' => 1 , 'gif' => 1 , 'pdf' => 1 );
2013-05-18 01:31:56 -07:00
$mes -> addInfo ( " Setting default filetypes: " . implode ( ', ' , array_keys ( $this -> allowed_types )));
}
2006-12-02 04:36:16 +00:00
}
2013-05-18 01:31:56 -07:00
2006-12-02 04:36:16 +00:00
2008-12-30 15:56:12 +00:00
2013-05-18 01:31:56 -07:00
function checkSuspiciousFiles ()
2008-08-25 10:46:46 +00:00
{
2013-05-18 01:31:56 -07:00
$mes = e107 :: getMessage ();
$public = array ( e_UPLOAD , e_AVATAR_UPLOAD );
2015-07-16 14:29:19 -07:00
$tp = e107 :: getParser ();
2013-05-18 01:31:56 -07:00
$exceptions = array ( " . " , " .. " , " / " , " CVS " , " avatars " , " Thumbs.db " , " .ftpquota " , " .htaccess " , " php.ini " , " .cvsignore " , 'e107.htaccess' );
//TODO use $file-class to grab list and perform this check.
foreach ( $public as $dir )
2008-08-25 10:46:46 +00:00
{
2013-05-18 01:31:56 -07:00
if ( is_dir ( $dir ))
2008-08-25 10:46:46 +00:00
{
2013-05-18 01:31:56 -07:00
if ( $dh = opendir ( $dir ))
2008-08-25 10:46:46 +00:00
{
2013-05-18 01:31:56 -07:00
while (( $file = readdir ( $dh )) !== false )
2008-08-25 10:46:46 +00:00
{
2013-05-18 01:31:56 -07:00
if ( is_dir ( $dir . " / " . $file ) == FALSE && ! in_array ( $file , $exceptions ))
2008-08-25 10:46:46 +00:00
{
2013-05-18 01:31:56 -07:00
$fext = substr ( strrchr ( $file , " . " ), 1 );
if ( ! array_key_exists ( strtolower ( $fext ), $this -> allowed_types ) )
2008-08-25 10:46:46 +00:00
{
2013-05-18 01:31:56 -07:00
if ( $file == 'index.html' || $file == " null.txt " )
{
if ( filesize ( $dir . '/' . $file ))
{
$potential [] = str_replace ( '../' , '' , $dir ) . '/' . $file ;
}
}
else
{
$potential [] = str_replace ( '../' , '' , $dir ) . '/' . $file ;
}
2006-12-02 04:36:16 +00:00
}
2008-12-30 15:56:12 +00:00
}
2006-12-02 04:36:16 +00:00
}
2013-05-18 01:31:56 -07:00
closedir ( $dh );
2006-12-02 04:36:16 +00:00
}
}
}
2013-05-18 01:31:56 -07:00
if ( isset ( $potential ))
{
//$text = ADLAN_ERR_3."<br /><br />";
2015-07-16 14:29:19 -07:00
$mes -> addWarning ( $tp -> toHtml ( ADLAN_ERR_3 , true ));
2013-05-18 01:31:56 -07:00
$text = '<ul>' ;
foreach ( $potential as $p_file )
{
$text .= '<li>' . $p_file . '</li>' ;
}
$mes -> addWarning ( $text );
//$ns -> tablerender(ADLAN_ERR_1, $text);
}
2006-12-02 04:36:16 +00:00
}
2013-05-18 01:31:56 -07:00
2006-12-02 04:36:16 +00:00
}
2013-05-18 01:31:56 -07:00
2006-12-02 04:36:16 +00:00
// ---------------------------------------------------------
2013-05-20 04:50:11 -07:00
2006-12-02 04:36:16 +00:00
// auto db update
2008-12-30 15:56:12 +00:00
if ( '0' == ADMINPERMS )
2008-08-25 10:46:46 +00:00
{
2013-05-31 18:52:46 -07:00
$sc = e107 :: getScBatch ( 'admin' );
echo $tp -> parseTemplate ( '{ADMIN_COREUPDATE=alert}' , true , $sc );
2013-05-20 04:50:11 -07:00
2006-12-02 04:36:16 +00:00
require_once ( e_ADMIN . 'update_routines.php' );
update_check ();
}
2013-05-12 04:51:06 -07:00
2006-12-02 04:36:16 +00:00
// end auto db update
2008-08-25 10:46:46 +00:00
/*
2008-12-30 15:56:12 +00:00
if ( e_QUERY == 'purge' && getperms ( '0' ))
2008-08-25 10:46:46 +00:00
{
2006-12-02 04:36:16 +00:00
$admin_log -> purge_log_events ( false );
}
2008-08-25 10:46:46 +00:00
*/
2006-12-02 04:36:16 +00:00
$td = 1 ;
2012-12-08 00:36:34 -08:00
2008-08-25 10:46:46 +00:00
2012-12-03 02:21:51 -08:00
// DEPRECATED
2008-12-30 15:56:12 +00:00
function render_links ( $link , $title , $description , $perms , $icon = FALSE , $mode = FALSE )
2008-08-25 10:46:46 +00:00
{
2012-12-03 02:21:51 -08:00
return e107 :: getNav () -> renderAdminButton ( $link , $title , $description , $perms , $icon , $mode );
2006-12-02 04:36:16 +00:00
}
2008-08-25 10:46:46 +00:00
2012-12-05 21:30:17 -08:00
function render_clean () // still used by classis, tabbed etc.
2008-08-25 10:46:46 +00:00
{
2006-12-02 04:36:16 +00:00
global $td ;
2009-11-08 12:08:35 +00:00
$text = " " ;
while ( $td <= ADLINK_COLS )
{
2006-12-02 04:36:16 +00:00
$text .= " <td class='td' style='width:20%;'></td> " ;
$td ++ ;
}
$text .= " </tr> " ;
$td = 1 ;
return $text ;
}
2008-12-04 20:17:54 +00:00
2009-07-04 13:36:15 +00:00
2012-12-04 00:14:43 -08:00
if ( is_object ( $adp ))
{
$adp -> render ();
}
else
{
require_once ( e_ADMIN . 'includes/' . $pref [ 'adminstyle' ] . '.php' );
}
2009-07-04 13:36:15 +00:00
2006-12-02 04:36:16 +00:00
2008-08-25 10:46:46 +00:00
2008-12-30 15:56:12 +00:00
function admin_info ()
2008-08-25 10:46:46 +00:00
{
2006-12-02 04:36:16 +00:00
global $tp ;
$width = ( getperms ( '0' )) ? " 33% " : " 50% " ;
$ADMIN_INFO_TEMPLATE = "
< div style = 'text-align:center' >
< table style = 'width: 100%; border-collapse:collapse; border-spacing:0px;' >
< tr >
< td style = 'width: ".$width."; vertical-align: top' >
{ ADMIN_STATUS }
</ td >
< td style = 'width:".$width."; vertical-align: top' >
{ ADMIN_LATEST }
</ td > " ;
if ( getperms ( '0' ))
{
$ADMIN_INFO_TEMPLATE .= "
< td style = 'width:".$width."; vertical-align: top' > { ADMIN_LOG } </ td > " ;
}
$ADMIN_INFO_TEMPLATE .= "
</ tr ></ table ></ div > " ;
return $tp -> parseTemplate ( $ADMIN_INFO_TEMPLATE );
}
2008-12-30 15:56:12 +00:00
function status_request ()
2008-08-25 10:46:46 +00:00
{
2006-12-02 04:36:16 +00:00
global $pref ;
2009-07-04 03:08:03 +00:00
if ( $pref [ 'adminstyle' ] == 'classis' || $pref [ 'adminstyle' ] == 'cascade' || $pref [ 'adminstyle' ] == 'beginner' || $pref [ 'adminstyle' ] == 'tabbed' ) {
2006-12-02 04:36:16 +00:00
return TRUE ;
} else {
return FALSE ;
}
}
2008-08-25 10:46:46 +00:00
2008-12-30 15:56:12 +00:00
function latest_request ()
2008-08-25 10:46:46 +00:00
{
2006-12-02 04:36:16 +00:00
global $pref ;
2009-07-04 03:08:03 +00:00
if ( $pref [ 'adminstyle' ] == 'classis' || $pref [ 'adminstyle' ] == 'cascade' || $pref [ 'adminstyle' ] == 'beginner' || $pref [ 'adminstyle' ] == 'tabbed' ) {
2006-12-02 04:36:16 +00:00
return TRUE ;
} else {
return FALSE ;
}
}
2008-12-30 15:56:12 +00:00
function log_request ()
2008-08-25 10:46:46 +00:00
{
2006-12-02 04:36:16 +00:00
global $pref ;
2009-07-04 03:08:03 +00:00
if ( $pref [ 'adminstyle' ] == 'classis' || $pref [ 'adminstyle' ] == 'cascade' || $pref [ 'adminstyle' ] == 'beginner' || $pref [ 'adminstyle' ] == 'tabbed' ) {
2006-12-02 04:36:16 +00:00
return TRUE ;
} else {
return FALSE ;
}
}
2012-12-03 01:40:47 -08:00
// getPlugLinks() - moved to sitelinks_class.php : pluginLinks();
2008-08-25 10:46:46 +00:00
2006-12-02 04:36:16 +00:00
require_once ( " footer.php " );
2013-05-18 01:31:56 -07:00
?>