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 )
*
*/
2020-12-19 11:12:53 -08:00
define ( 'e_ADMIN_HOME' , true ); // used by some admin shortcodes and class2.
2016-11-11 13:44:20 +01:00
2021-01-16 13:32:35 -08:00
require_once ( __DIR__ . '/../class2.php' );
2016-11-11 13:44:20 +01:00
if ( varset ( $_GET [ 'mode' ]) == 'customize' )
{
$adminPref = e107 :: getConfig () -> get ( 'adminpref' , 0 );
// If not Main Admin and "Apply dashboard preferences to all administrators"
// is checked in admin theme settings.
if ( ! getperms ( " 1 " ) && $adminPref == 1 )
{
e107 :: redirect ( 'admin' );
exit ;
}
}
2020-05-12 15:21:20 -07:00
// check that the bootstrap library path is up-to-date before the header is loaded.
2021-01-27 12:20:58 -08:00
/* if ( $info = e107 :: getLibrary () -> load ( 'bootstrap' ))
2020-05-12 15:21:20 -07:00
{
if ( $info [ 'path' ] !== '3' )
{
2020-05-12 15:21:20 -07:00
e107 :: getCache () -> clearAll ( 'library' );
2020-05-12 16:47:09 -07:00
e107 :: getCache () -> clearAll ( 'browser' );
2020-05-12 15:21:20 -07:00
}
2021-01-27 12:20:58 -08:00
} */
2016-11-11 13:44:20 +01:00
2021-01-24 10:44:30 -08:00
e107 :: getDebug () -> logTime ( '[admin.php: Loading admin_icons]' );
//include_once(e107::coreTemplatePath('admin_icons'));
e107 :: loadAdminIcons (); // Needs to be loaded before infopanel AND in boot.php
2013-03-20 23:50:30 -07:00
2020-12-31 16:14:43 -08:00
/* if ( vartrue ( $_GET [ 'iframe' ]) == 1 )
2012-05-17 09:19:44 +00:00
{
define ( 'e_IFRAME' , true );
2020-12-31 16:14:43 -08:00
} */
2012-05-17 09:19:44 +00:00
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' ;
}
2016-11-07 14:12:19 +01:00
if ( in_array ( $pref [ 'adminstyle' ], array ( 'infopanel' , 'flexpanel' )))
2012-12-04 00:14:43 -08:00
{
2016-11-07 14:12:19 +01:00
require_once ( e_ADMIN . 'includes/' . $pref [ 'adminstyle' ] . '.php' );
2016-11-04 10:40:45 +01:00
2016-11-07 14:12:19 +01:00
$_class = 'adminstyle_' . $pref [ 'adminstyle' ];
2013-02-07 15:22:00 +02:00
if ( class_exists ( $_class , false ))
{
2016-11-07 14:12:19 +01:00
$adp = new $_class ;
}
else
{
$adp = new adminstyle_infopanel ;
2013-02-07 15:22:00 +02:00
}
2012-12-04 00:14:43 -08:00
}
2019-04-11 12:28:14 -07:00
// DEBUG THE ADDON_UPDATED INFOPANEL
//e107::getCache()->clear('Infopanel_plugin', true);
//e107::getSession()->clear('addons-update-status');
//e107::getSession()->set('addons-update-checked',false); // set to recheck it.
2017-04-03 10:16:23 -07:00
2020-12-19 11:12:53 -08:00
2013-05-18 01:31:56 -07:00
2013-02-09 16:02:03 +02:00
require_once ( e_ADMIN . 'boot.php' );
2008-08-25 10:46:46 +00:00
require_once ( e_HANDLER . 'upload_handler.php' );
2021-01-16 13:32:35 -08:00
2017-04-03 10:16:23 -07:00
new admin_start ;
require_once ( e_ADMIN . 'auth.php' );
2013-02-26 21:27:36 -08:00
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( '(Start Admin Checks)' );
2017-04-03 10:16:23 -07:00
2006-12-02 04:36:16 +00:00
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( '(After Admin Checks)' );
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
{
2020-06-26 13:58:59 -07:00
2013-05-18 01:31:56 -07:00
private $incompat = array (
2018-01-23 11:41:07 -08:00
array ( 'banhelper' , 1.5 ),
array ( 'banhelper' , 1.7 ),
array ( 'slir_admin' , 1.0 ),
array ( 'facebook_like' , 0.7 ),
array ( 'unanswered' , 1.4 ),
array ( 'lightwindow' , '1.0b' ),
array ( 'aa_jquery' , 1.2 ),
array ( 'aa_jquery' , 1.4 ),
array ( 'who' , 1.0 ),
array ( 'ratings' , 4.2 ),
array ( 'lightbox' , 1.5 ),
array ( 'e107slider' , 0.1 ),
array ( 'forumthanks' , 0.5 ),
array ( 'eclassifieds' , 1.11 ),
array ( 'jshelpers' , '0.3b' ),
2019-02-22 15:11:19 -08:00
array ( 'akismet' , 7.0 ),
array ( 'newforumposts_main' , 1 ),
2020-05-06 13:33:01 -07:00
array ( 'fancybox' , '2.06b' ),
2013-05-18 01:31:56 -07:00
);
private $allowed_types = null ;
2015-08-24 17:39:28 -07:00
private $refresh = false ;
2017-01-04 18:14:15 -08:00
private $exit = false ;
2013-05-18 01:31:56 -07:00
2016-12-06 12:47:10 -08:00
private $deprecated = array ();
2020-05-05 15:11:49 -07:00
private $upgradeRequiredFirst = false ;
2016-12-06 12:47:10 -08:00
function __construct ()
{
2017-02-02 11:48:13 -08:00
if ( e_AJAX_REQUEST || ! getperms ( '0' ) || varset ( $_GET [ 'mode' ]) === 'customize' ) // don't display this tuff to regular admins only main admin.
2016-12-21 20:34:52 -08:00
{
return null ;
}
2020-05-05 15:11:49 -07:00
if ( ! e107 :: getDb () -> isTable ( 'admin_log' )) // Upgrade from v1.x to v2.x required.
{
$this -> upgradeRequiredFirst = true ;
}
2016-12-22 10:15:10 -08:00
// Files that can cause comflicts and problems.
2020-03-27 17:04:14 -05:00
$fileInspector = e107 :: getFileInspector ();
2021-01-02 01:07:10 +01:00
$this -> deprecated = $fileInspector :: getCachedDeprecatedFiles ();
2016-12-06 12:47:10 -08:00
2017-04-27 15:21:20 -07:00
$this -> checkCoreVersion ();
2016-12-06 11:17:20 -08:00
if ( ! empty ( $_POST [ 'delete-deprecated' ]))
{
$this -> deleteDeprecated ();
}
2017-04-23 16:24:43 -07:00
unset ( $_SESSION [ 'lancheck' ]);
2017-01-04 18:14:15 -08:00
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check Paths' );
2015-08-24 17:39:28 -07:00
$this -> checkPaths ();
2017-01-21 10:49:04 -08:00
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check Timezone' );
2015-08-24 17:39:28 -07:00
$this -> checkTimezone ();
2017-01-21 10:49:04 -08:00
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check Writable' );
2013-05-18 02:02:00 -07:00
$this -> checkWritable ();
2017-01-04 18:17:15 -08:00
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check Incompatible Plugins' );
2013-05-18 01:31:56 -07:00
$this -> checkIncompatiblePlugins ();
2017-01-04 18:17:15 -08:00
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check Filetypes' );
2019-02-03 09:51:16 -08:00
$this -> checkFileTypes ();
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check Suspect Files' );
2013-05-18 01:31:56 -07:00
$this -> checkSuspiciousFiles ();
2017-01-04 18:17:15 -08:00
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check Deprecated' );
2015-07-17 18:22:56 -07:00
$this -> checkDeprecated ();
2017-01-04 18:17:15 -08:00
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check HTMLArea' );
2017-01-04 18:17:15 -08:00
$this -> checkHtmlarea ();
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check Htaccess' );
2016-12-01 11:20:56 -08:00
$this -> checkHtaccess ();
2015-08-24 17:39:28 -07:00
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check Core Update' );
2017-01-04 18:17:15 -08:00
$this -> checkCoreUpdate ();
if ( $this -> exit === true )
{
return null ;
}
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check New Install' );
2017-01-04 18:17:15 -08:00
$this -> checkNewInstall ();
2020-05-02 15:35:30 -07:00
/* e107 :: getDebug () -> logTime ( 'Check Plugin Update' );
2017-01-04 18:17:15 -08:00
$this -> checkPluginUpdate ();
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check Theme Update' );
2017-01-04 18:17:15 -08:00
$this -> checkThemeUpdate ();
2017-02-02 11:48:13 -08:00
*/
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Check Password Encryption' );
2017-01-04 18:17:15 -08:00
$this -> checkPasswordEncryption ();
2020-05-03 17:43:50 +02:00
//Check if developer mode is enabled
$this -> checkDeveloperMode ();
2017-01-04 18:17:15 -08:00
2015-08-24 17:39:28 -07:00
if ( $this -> refresh == true )
{
2017-02-08 22:52:18 -08:00
e107 :: getRedirect () -> go ( e_REQUEST_SELF );
2015-08-24 17:39:28 -07:00
}
2021-01-27 12:20:58 -08:00
// delete half-completed user accounts. (previously called in header.php )
e107 :: getUserSession () -> deleteExpired ();
2013-04-22 03:29:10 -07:00
}
2017-01-30 07:52:25 -08:00
private function checkPaths ()
2015-08-24 17:39:28 -07:00
{
$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 );
2016-12-01 11:20:56 -08:00
$mes = e107 :: getMessage ();
2015-08-24 17:39:28 -07:00
foreach ( $create_dir as $dr )
{
if ( ! is_dir ( $dr ))
{
if ( mkdir ( $dr , 0755 ))
{
$this -> refresh = true ;
}
2016-12-01 11:20:56 -08:00
else
{
2017-06-06 08:12:39 +02:00
$message = e107 :: getParser () -> lanVars ( ADLAN_187 , $dr , true );
2017-06-05 09:14:14 +02:00
$mes -> addWarning ( $message );
2016-12-01 11:20:56 -08:00
}
2015-08-24 17:39:28 -07:00
}
}
}
2017-01-30 07:52:25 -08:00
private function checkTimezone ()
2015-08-24 17:39:28 -07:00
{
$mes = e107 :: getMessage ();
$timezone = e107 :: pref ( 'core' , 'timezone' );
if ( e107 :: getDate () -> isValidTimezone ( $timezone ) == false )
{
2017-06-06 08:12:39 +02:00
$message = e107 :: getParser () -> lanVars ( ADLAN_188 , $timezone );
2017-06-05 09:14:14 +02:00
$mes -> addWarning ( $message , 'default' , true );
2015-08-24 17:39:28 -07:00
e107 :: getConfig () -> set ( 'timezone' , 'UTC' ) -> save ( false , true , false );
$this -> refresh = true ;
}
}
2013-05-18 02:02:00 -07:00
2017-04-27 15:21:20 -07:00
private function checkCoreVersion ()
{
$e107info = array ();
require ( e_ADMIN . " ver.php " );
2021-01-05 10:04:26 -08:00
if ( ! empty ( $e107info [ 'e107_version' ]) && defined ( 'e_VERSION' ) && ( e_VERSION !== $e107info [ 'e107_version' ]))
2017-04-27 15:21:20 -07:00
{
e107 :: getConfig () -> set ( 'version' , $e107info [ 'e107_version' ]) -> save ( false , true , false );
// When version has changed, clear plugin/theme version cache.
e107 :: getPlug () -> clearCache ();
e107 :: getTheme () -> clearCache ();
e107 :: getDebug () -> log ( " Updating core version pref " );
}
}
2017-01-04 18:08:58 -08:00
private function checkCoreUpdate ()
{
// auto db update
if ( '0' != ADMINPERMS )
{
return null ;
}
2020-05-05 15:11:49 -07:00
if ( $this -> upgradeRequiredFirst )
{
$message = " <p><a class='btn btn-lg btn-primary alert-link' href='e107_update.php'> " . LAN_CONTINUE . " " . SEP . " </a></p> " ;
e107 :: getMessage () -> addInfo ( $message );
}
2017-11-15 17:51:46 -08:00
return null ;
2017-04-03 10:16:23 -07:00
2017-01-22 10:04:29 -08:00
$checked = e107 :: getSession () -> get ( 'core-update-checked' );
2017-01-27 15:21:17 -08:00
if ( ! deftrue ( 'e_DEBUG' ) && $checked === true && ! deftrue ( 'e_DEVELOPER' ))
2017-01-22 10:04:29 -08:00
{
2017-01-26 18:10:38 -08:00
e107 :: getMessage () -> addDebug ( " Skipping core update " );
2017-01-22 10:04:29 -08:00
return null ;
}
2017-01-04 18:08:58 -08:00
//$sc = e107::getScBatch('admin');
//echo $tp->parseTemplate('{ADMIN_COREUPDATE=alert}',true, $sc);
2017-01-22 10:04:29 -08:00
2017-01-04 18:08:58 -08:00
global $dont_check_update , $e107info ;
global $dbupdate , $dbupdatep , $e107cache ;
require_once ( e_ADMIN . 'update_routines.php' );
2017-01-04 18:14:15 -08:00
2017-01-22 10:04:29 -08:00
e107 :: getSession () -> set ( 'core-update-checked' , true );
2017-01-26 18:10:38 -08:00
e107 :: getMessage () -> addDebug ( " Checking for core updates " );
2017-01-22 10:04:29 -08:00
2017-04-03 10:16:23 -07:00
2017-01-04 18:14:15 -08:00
if ( update_check () === true )
{
2017-04-03 10:16:23 -07:00
$JS = <<< TMPO
$ ( function () {
$ ( '[data-toggle="popover"]' ) . popover ( 'show' );
$ ( '.popover' ) . on ( 'click' , function () {
$ ( '[data-toggle="popover"]' ) . popover ( 'hide' );
}
);
});
TMPO ;
e107 :: js ( 'footer-inline' , $JS );
e107 :: css ( 'inline' , '.hide.e-popover { display:block!important }' );
2017-01-04 18:14:15 -08:00
if ( e_DEBUG !== true )
{
$this -> exit = true ;
}
}
2017-01-04 18:08:58 -08:00
}
2017-02-02 11:48:13 -08:00
/*
* // Moved to admin_shortcodes.php
2017-01-04 18:08:58 -08:00
private function checkPluginUpdate ()
{
require_once ( e_HANDLER . 'e_marketplace.php' );
$mp = new e_marketplace (); // autodetect the best method
$versions = $mp -> getVersionList ( 'plugin' );
$plugins = e107 :: getPref ( 'plug_installed' );
if ( empty ( $plugins ))
{
return null ;
}
$tp = e107 :: getParser ();
foreach ( $plugins as $folder => $version )
{
if ( ! empty ( $versions [ $folder ][ 'version' ]) && version_compare ( $version , $versions [ $folder ][ 'version' ], '<' ))
{
2017-02-01 11:04:10 -08:00
$link = " <a rel='external' class='alert-link' href=' " . $versions [ $folder ][ 'url' ] . " '> " . $versions [ $folder ][ 'name' ] . " </a> " ;
2017-01-04 18:08:58 -08:00
$dl = $mp -> getDownloadModal ( 'plugin' , $versions [ $folder ]);
$caption = LAN_DOWNLOAD . " : " . $versions [ $folder ][ 'name' ] . " " . $versions [ $folder ][ 'version' ];
$lans = array ( 'x' => $link , 'y' => LAN_PLUGIN );
$message = $tp -> lanVars ( LAN_NEWER_VERSION_OF_X , $lans );
2017-02-01 11:04:10 -08:00
$message .= " <a href=' " . $dl . " ' class='e-modal alert-link' data-modal-caption= \" " . $caption . " \" title= \" " . LAN_DOWNLOAD . " \" > " . $tp -> toGlyph ( 'fa-arrow-circle-o-down' ) . " </a> " ;
2017-01-04 18:08:58 -08:00
e107 :: getMessage () -> addInfo ( $message );
2017-02-02 11:48:13 -08:00
2017-01-04 18:08:58 -08:00
}
}
2017-02-02 11:48:13 -08:00
} */
/*
* Moved to admin_shortcodes . php
2017-01-04 18:08:58 -08:00
private function checkThemeUpdate ()
{
require_once ( e_HANDLER . 'e_marketplace.php' );
$mp = new e_marketplace (); // autodetect the best method
$versions = $mp -> getVersionList ( 'theme' );
$themes = scandir ( e_THEME );
if ( empty ( $themes ))
{
return null ;
}
$tp = e107 :: getParser ();
$list = e107 :: getTheme () -> getThemeList ();
foreach ( $list as $data )
{
$folder = $data [ 'path' ];
$version = $data [ 'version' ];
if ( ! empty ( $versions [ $folder ][ 'version' ]) && version_compare ( $version , $versions [ $folder ][ 'version' ], '<' ))
{
2017-02-01 11:04:10 -08:00
$link = " <a rel='external' class='alert-link' href=' " . $versions [ $folder ][ 'url' ] . " '> " . $versions [ $folder ][ 'name' ] . " </a> " ;
2017-01-04 18:08:58 -08:00
$lans = array ( 'x' => $link , 'y' => LAN_THEME );
$dl = $mp -> getDownloadModal ( 'theme' , $versions [ $folder ]);
$caption = LAN_DOWNLOAD . " : " . $versions [ $folder ][ 'name' ] . " " . $versions [ $folder ][ 'version' ];
$message = $tp -> lanVars ( LAN_NEWER_VERSION_OF_X , $lans );
2017-02-01 11:04:10 -08:00
$message .= " <a href=' " . $dl . " ' class='e-modal alert-link' data-modal-caption= \" " . $caption . " \" title= \" " . LAN_DOWNLOAD . " \" > " . $tp -> toGlyph ( 'fa-arrow-circle-o-down' ) . " </a> " ;
2017-01-04 18:08:58 -08:00
e107 :: getMessage () -> addInfo ( $message );
e107 :: getMessage () -> addDebug ( " Local version: " . $version . " Remote version: " . $versions [ $folder ][ 'version' ]);
}
}
2017-02-02 11:48:13 -08:00
} */
2017-01-04 18:08:58 -08:00
2016-12-08 08:54:55 -08:00
/**
*
*/
2016-12-07 18:23:57 -08:00
private function checkNewInstall ()
{
2016-12-08 08:54:55 -08:00
$upgradeAlertFlag = e_CACHE . 'dismiss.upgrade.alert.txt' ;
if ( ! empty ( $_GET [ 'dismiss' ]) && $_GET [ 'dismiss' ] == 'upgrade' )
{
file_put_contents ( $upgradeAlertFlag , 'true' );
}
2016-12-07 18:23:57 -08:00
$pref = e107 :: getPref ( 'install_date' );
$v2ReleaseDate = strtotime ( 'August 27, 2015' );
$numDays = ( abs ( $pref - time ()) / 60 / 60 / 24 );
if ( $numDays < 3 ) // installed in the past 3 days.
{
2018-07-24 06:13:25 +02:00
$srch = array ( '[' , ']' );
2018-08-26 13:54:25 -07:00
$repl = array ( " <a href='http://e107help.org' target='_blank' rel='external'> " , " </a> " );
echo e107 :: getMessage () -> setTitle ( ADLAN_190 , E_MESSAGE_INFO ) -> addInfo ( " <p> " . str_replace ( $srch , $repl , ADLAN_192 ) . " </p> " ) -> render ();
2016-12-07 18:23:57 -08:00
}
2016-12-08 08:54:55 -08:00
elseif ( $pref < $v2ReleaseDate && ! file_exists ( $upgradeAlertFlag )) // installed prior to v2 release.
2016-12-07 18:23:57 -08:00
{
2018-07-24 06:13:25 +02:00
$srch = array ( '[' , ']' );
2018-08-26 13:54:25 -07:00
$repl = array ( " <a href='http://e107help.org' target='_blank' rel='external'> " , " </a> " );
2018-07-24 10:35:35 -07:00
$message = str_replace ( $srch , $repl , ADLAN_191 );
2018-07-22 16:02:03 +02:00
$message .= " <div class='text-right'><a class='btn btn-xs btn-primary ' href='admin.php?dismiss=upgrade'> " . LAN_DONT_SHOW_AGAIN . " </a></div> " ; //todo do it with class=e-ajax and data-dismiss='alert'
2018-07-24 10:35:35 -07:00
echo e107 :: getMessage () -> setTitle ( LAN_UPGRADING , E_MESSAGE_INFO ) -> addInfo ( $message ) -> render ();
2016-12-07 18:23:57 -08:00
}
e107 :: getMessage () -> setTitle ( null , E_MESSAGE_INFO );
}
2017-01-30 07:52:25 -08:00
private function checkWritable ()
2013-05-18 02:02:00 -07:00
{
$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
{
2018-07-24 06:13:25 +02:00
$message = str_replace ( " [x] " , e_MEDIA , ADLAN_193 );
2018-07-22 16:02:03 +02:00
$mes -> addWarning ( $message );
2013-05-18 02:02:00 -07:00
}
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
{
2018-07-24 06:13:25 +02:00
$message = str_replace ( " [x] " , e_SYSTEM , ADLAN_193 );
2018-07-22 16:02:03 +02:00
$mes -> addWarning ( $message );
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 ))
{
2018-07-24 06:13:25 +02:00
$message = str_replace ( " [x] " , e_IMAGE , ADLAN_194 );
2018-07-22 16:02:03 +02:00
$mes -> addWarning ( $message );
2016-03-21 14:22:49 -07:00
}
2013-05-18 02:02:00 -07:00
}
2013-05-18 01:31:56 -07:00
2017-01-30 07:52:25 -08:00
private function checkHtmlarea ()
2013-05-18 01:31:56 -07:00
{
$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
2017-01-30 07:52:25 -08:00
private function checkIncompatiblePlugins ()
2006-12-02 04:36:16 +00:00
{
2020-05-05 15:11:49 -07:00
if ( $this -> upgradeRequiredFirst )
{
return null ;
}
2013-05-18 01:31:56 -07:00
$mes = e107 :: getMessage ();
$installedPlugs = e107 :: getPref ( 'plug_installed' );
$inCompatText = " " ;
$incompatFolders = array_keys ( $this -> incompat );
2018-01-23 11:41:07 -08:00
foreach ( $this -> incompat as $data )
2006-12-02 04:36:16 +00:00
{
2018-01-23 11:41:07 -08:00
$folder = $data [ 0 ];
$version = $data [ 1 ];
if ( ! empty ( $installedPlugs [ $folder ]) && ( $version == $installedPlugs [ $folder ] || $version === '*' ))
2013-05-18 01:31:56 -07:00
{
2020-06-26 13:58:59 -07:00
$inCompatText .= " <li><a title=' " . LAN_UNINSTALL . " ' href=' " . e_ADMIN . " plugin.php?mode=installed&action=uninstall&path= " . $folder . " '> " . $folder . " v " . $installedPlugs [ $folder ] . " </a></li> " ;
2013-05-18 01:31:56 -07:00
}
2006-12-02 04:36:16 +00:00
}
2013-05-18 01:31:56 -07:00
if ( $inCompatText )
{
$text = " <ul> " . $inCompatText . " </ul> " ;
2020-06-26 13:58:59 -07:00
$mes -> addWarning ( ADLAN_189 . " <br /><br /> " . $text );
2013-05-18 01:31:56 -07:00
}
2006-12-02 04:36:16 +00:00
}
2015-07-17 18:22:56 -07:00
2017-01-30 07:52:25 -08:00
private function checkPasswordEncryption ()
2016-06-16 12:23:20 -07:00
{
2020-05-05 15:11:49 -07:00
if ( $this -> upgradeRequiredFirst )
{
return null ;
}
2016-06-16 12:23:20 -07:00
$us = e107 :: getUserSession ();
$mes = e107 :: getMessage ();
if ( $us -> passwordAPIExists () === true && $us -> getDefaultHashType () !== PASSWORD_E107_PHP && e107 :: pref ( 'core' , 'password_CHAP' ) == 0 )
{
2017-05-02 06:45:49 +02:00
$message = LAN_PASSWORD_WARNING ;
2016-06-16 12:23:20 -07:00
$srch = array ( '[' , ']' );
$repl = array ( " <a class='alert-link' href=' " . e_ADMIN . " prefs.php#nav-core-prefs-security'> " , " </a> " );
$mes -> addWarning ( str_replace ( $srch , $repl , $message ));
}
2016-03-21 14:22:49 -07:00
2016-06-16 12:23:20 -07:00
}
2016-03-21 14:22:49 -07:00
2020-05-03 17:43:50 +02:00
private function checkDeveloperMode ()
{
2020-05-04 21:22:13 +02:00
$pref = e107 :: getPref ();
$tp = e107 :: getParser ();
if ( $pref [ 'developer' ] && ( strpos ( e_SELF , 'localhost' ) === false ) && ( strpos ( e_SELF , '127.0.0.1' ) === false ))
2020-05-03 17:43:50 +02:00
{
2020-05-04 21:22:13 +02:00
e107 :: getMessage () -> addWarning ( $tp -> toHTML ( LAN_DEVELOPERMODE_CHECK , true ));
2020-05-03 17:43:50 +02:00
}
}
2016-03-21 14:22:49 -07:00
2020-05-04 21:22:13 +02:00
2016-12-01 11:20:56 -08:00
private function checkDependencies ()
{
}
2016-03-21 14:22:49 -07:00
2016-12-06 11:17:20 -08:00
private function checkDeprecated ()
2015-07-17 18:22:56 -07:00
{
2020-05-05 15:11:49 -07:00
if ( $this -> upgradeRequiredFirst )
{
return null ;
}
2015-07-17 18:22:56 -07:00
$found = array ();
2016-12-06 11:17:20 -08:00
foreach ( $this -> deprecated as $path )
2015-07-17 18:22:56 -07:00
{
if ( file_exists ( $path ))
{
2020-05-20 13:31:09 -07:00
$found [] = str_replace ( e_BASE , " " , $path );
2015-07-17 18:22:56 -07:00
}
}
if ( ! empty ( $found ))
{
2016-12-06 11:17:20 -08:00
$frm = e107 :: getForm ();
$text = $frm -> open ( 'deprecatedFiles' , 'post' );
2017-01-09 08:27:46 +01:00
$text .= ADLAN_186 ;
2015-07-17 18:22:56 -07:00
$text .= " <ul><li> " . implode ( " </li><li> " , $found ) . " </li></ul> " ;
2016-12-06 11:17:20 -08:00
$text .= $frm -> button ( 'delete-deprecated' , LAN_DELETE , 'delete' );
$text .= $frm -> close ();
2015-07-17 18:22:56 -07:00
e107 :: getMessage () -> addWarning ( $text );
}
}
2016-12-06 11:17:20 -08:00
private function deleteDeprecated ()
{
$mes = e107 :: getMessage ();
2020-05-20 13:31:09 -07:00
$error = 0 ;
2016-12-06 11:17:20 -08:00
foreach ( $this -> deprecated as $file )
{
if ( ! file_exists ( $file ))
{
continue ;
}
if ( @ unlink ( $file ))
{
2017-04-15 11:52:45 +02:00
$message = e107 :: getParser () -> lanVars ( LAN_UI_FILE_DELETED , array ( 'x' => $file ));
$mes -> addSuccess ( $message );
2016-12-06 11:17:20 -08:00
}
else
{
2017-04-15 11:52:45 +02:00
$message = e107 :: getParser () -> lanVars ( LAN_UI_FILE_DELETED_FAILED , array ( 'x' => $file ));
$mes -> addError ( $message );
2020-05-20 13:31:09 -07:00
$error ++ ;
2016-12-06 11:17:20 -08:00
}
}
2020-05-20 13:31:09 -07:00
$logFile = e_LOG . " fileinspector/deprecatedFiles.log " ;
if ( $error === 0 && file_exists ( $logFile ))
{
@ unlink ( $logFile );
}
2016-12-06 11:17:20 -08:00
}
2016-12-01 11:20:56 -08:00
2017-01-30 07:52:25 -08:00
private function checkHtaccess () // upgrade scenario
2016-12-01 11:20:56 -08:00
{
if ( ! file_exists ( e_BASE . " .htaccess " ) && file_exists ( e_BASE . " e107.htaccess " ))
{
if ( rename ( e_BASE . " e107.htaccess " , e_BASE . " .htaccess " ) === false )
{
e107 :: getMessage () -> addWarning ( " Please rename your <b>e107.htaccess</b> file to <b>.htaccess</b> " );
}
}
}
2013-05-18 01:31:56 -07:00
2017-01-30 07:52:25 -08:00
private 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 );
2017-01-13 10:34:44 -08:00
$mes -> addDebug ( " Setting default filetypes: " . implode ( ', ' , array_keys ( $this -> allowed_types )));
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
2008-12-30 15:56:12 +00:00
2017-01-30 07:52:25 -08:00
private 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 />";
2019-02-26 12:22:36 -08: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
2017-01-04 18:08:58 -08:00
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 = " " ;
2021-01-17 10:36:17 -08:00
while ( $td <= defset ( 'ADLINK_COLS' , 5 ))
2009-11-08 12:08:35 +00:00
{
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
2021-01-17 10:36:17 -08:00
if ( isset ( $adp ) && is_object ( $adp ))
2012-12-04 00:14:43 -08:00
{
2016-11-07 14:12:19 +01:00
$adp -> render ();
2012-12-04 00:14:43 -08:00
}
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 " );
2021-01-16 13:32:35 -08:00