1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-07 07:06:30 +02:00

Increased session to 24 hours (prevent being logged-out every hour).

Recursive chmod added to Database Tools for correcting folder and file perms.
This commit is contained in:
CaMer0n
2012-08-05 10:06:01 +00:00
parent a739be4176
commit c7c9bfe517
3 changed files with 98 additions and 5 deletions

View File

@@ -124,11 +124,11 @@ class system_tools
'importForm' => array('diz'=>DBLAN_59, 'label'=> DBLAN_59),
'exportForm' => array('diz'=>DBLAN_58, 'label'=> DBLAN_58),
'sc_override_scan' => array('diz'=>DBLAN_55, 'label'=> DBLAN_56),
'convert_to_utf8' => array('diz'=>'Convert Database to UTF-8','label'=>'Convert DB to UTF-8')
'convert_to_utf8' => array('diz'=>'Convert Database to UTF-8','label'=>'Convert DB to UTF-8'),
'correct_perms' => array('diz'=>'Correct File and Directory perms','label'=>'Correct Perms')
);
//TODO Merge db_verify.php into db.php
if(isset($_POST['delplug']))
{
@@ -202,6 +202,12 @@ class system_tools
$this->perform_utf8_convert();
return;
}
if(varset($_GET['mode'])=='correct_perms')
{
$this->correct_perms();
return;
}
if(!vartrue($_GET['mode']) && !isset($_POST['db_execute']))
{
@@ -212,6 +218,39 @@ class system_tools
}
/**
* Correct Folder and File permissions.
*/
function correct_perms()
{
$mes = e107::getMessage();
$fl = e107::getFile();
ob_start();
$fl->chmod(e_BASE);
$fl->chmod(e_BASE."cron.php",0755);
$errors = ob_get_clean();
if($errors !='')
{
$mes->addError($errors);
}
else
{
$mes->addSuccess("Folder and File permissions have been updated");
}
e107::getRender()->tablerender("Correcting File and Directory Permissions", $mes->render());
}
private function convertUTF8Form()
{
$emessage = e107::getMessage();

View File

@@ -491,5 +491,59 @@ class e_file
return round($size/$tb, 2)." ".CORE_LAN_TB;
}
}
/** Recursive Chmod function.
* @param string path to folder
* @param string perms for files
* @param string perms for directories
* @example chmod_R('mydir', 0644, 0755);
*/
function chmod($path, $filemode=0644, $dirmode=0755)
{
if (is_dir($path) )
{
if (!chmod($path, $dirmode))
{
$dirmode_str=decoct($dirmode);
print "Failed applying filemode '$dirmode_str' on directory '$path'\n";
print " `-> the directory '$path' will be skipped from recursive chmod\n";
return;
}
$dh = opendir($path);
while (($file = readdir($dh)) !== false)
{
if($file != '.' && $file != '..') // skip self and parent pointing directories
{
$fullpath = $path.'/'.$file;
$this->chmod($fullpath, $filemode,$dirmode);
}
}
closedir($dh);
}
else
{
if (is_link($path))
{
print "link '$path' is skipped\n";
return;
}
if (!chmod($path, $filemode))
{
$filemode_str=decoct($filemode);
print "Failed applying filemode '$filemode_str' on file '$path'\n";
return;
}
}
}
}

View File

@@ -142,7 +142,7 @@ class e_session
* @var array
*/
protected $_options = array(
'lifetime' => 3600, // 1 hour
'lifetime' => 3600 , // 1 hour
'path' => '',
'domain' => '',
'secure' => false,
@@ -203,7 +203,7 @@ class e_session
{
$config['SavePath'] = e107::getPref('session_save_path', false); // FIXME - new pref
$config['SaveMethod'] = e107::getPref('session_save_method', 'files'); // FIXME - new pref
$options['lifetime'] = (integer) e107::getPref('session_lifetime', 3600); // FIXME - new pref
$options['lifetime'] = (integer) e107::getPref('session_lifetime', 86400); // FIXME - new pref
$options['path'] = e107::getPref('session_cookie_path', ''); // FIXME - new pref
$options['secure'] = e107::getPref('ssl_enabled', false); // FIXME - new pref
}