1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-12 18:46:20 +02:00

Added filetypes.xml info in Admin-> Preferences -> File Uploads to remove confusion with file upload limits. Theme upload should be working correctly now.

This commit is contained in:
Cameron
2015-02-10 23:13:53 -08:00
parent 540922d25c
commit 00696d92d3
7 changed files with 137 additions and 21 deletions

View File

@ -51,7 +51,7 @@ $security_risks = array(
if(ini_get($risk)) if(ini_get($risk))
{ {
$srch = '<tr><td class="forumheader2">'.$risk.'</td><td class="forumheader3">'; $srch = '<tr><td class="forumheader2">'.$risk.'</td><td class="forumheader3">';
$repl = '<tr><td class="forumheader2">'.$risk.'</td><td title="'.$tp->toAttribute($diz).'" class="forumheader3" style="background-color:red">'; $repl = '<tr><td class="forumheader2">'.$risk.'</td><td title="'.$tp->toAttribute($diz).'" class="forumheader3 alert alert-danger">';
$phpinfo = str_replace($srch,$repl,$phpinfo); $phpinfo = str_replace($srch,$repl,$phpinfo);
$mes->addWarning("<b>".$risk."</b>: ".$diz); $mes->addWarning("<b>".$risk."</b>: ".$diz);
} }

View File

@ -816,7 +816,7 @@ class pluginManager{
if(empty($data[0]['error'])) if(empty($data[0]['error']))
{ {
if($fl->unzipArchive($data[0]['name'],'plugin') === true) if($fl->unzipArchive($data[0]['name'],'plugin'))
{ {
$mes->addSuccess(EPL_ADLAN_43); $mes->addSuccess(EPL_ADLAN_43);
} }

View File

@ -2281,10 +2281,34 @@ $text .= "
// File Uploads // File Uploads
include_lan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_upload.php"); include_lan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_upload.php");
require_once(e_HANDLER."upload_handler.php");
$text .= " $text .= "
<fieldset class='e-hideme' id='core-prefs-uploads'> <fieldset class='e-hideme' id='core-prefs-uploads'>
<legend>File Uploading</legend> <legend>File Uploading</legend>";
$upload_max_filesize = ini_get('upload_max_filesize');
$post_max_size = ini_get('post_max_size');
$maxINI = min($upload_max_filesize,$post_max_size);
if($maxINI < $pref['upload_maxfilesize'])
{
$text .= "<div class='alert-block alert alert-danger'>";
$text .= "The maximum upload size imposed by your php.ini settings is: ".$maxINI."</div>";
$pref['upload_maxfilesize'] = $maxINI;
}
$text .= "
<table class='table adminform'> <table class='table adminform'>
<colgroup> <colgroup>
<col class='col-label' /> <col class='col-label' />
@ -2307,7 +2331,7 @@ $text .= "
<td>". <td>".
$frm->text('upload_maxfilesize', $pref['upload_maxfilesize'], 10) $frm->text('upload_maxfilesize', $pref['upload_maxfilesize'], 10)
." ."
<div class='field-help'>".UPLLAN_34." (upload_max_filesize = ".ini_get('upload_max_filesize').", post_max_size = ".ini_get('post_max_size')." )</div> <div class='field-help'>".UPLLAN_34."</div>
</td> </td>
</tr> </tr>
@ -2317,9 +2341,41 @@ $text .= "
<div class='field-help'>".UPLLAN_38."</div> <div class='field-help'>".UPLLAN_38."</div>
</td> </td>
</tr> </tr>
<tr><td>Filetype upload limits</td>
<td>
<table class='table table-striped table-bordered'>
<tr><th>".LAN_TYPE."</th><th>".UPLLAN_33."</th>
";
$fl = e107::getFile();
$data = $fl->getFiletypeLimits();
foreach($data as $k=>$v)
{
$text .= "<tr><td>".$k."</td>
<td>".$fl->file_size_encode($v)."</td>
</tr>";
}
// $text .= print_a($data,true);
$text .= "</table>
<div>** For security reasons these values may only be changed manually in the following file: <b>".str_replace("../",'',e_SYSTEM).e_READ_FILETYPES."</b></div>
</td>
</tbody> </tbody>
</table> </table>
".pref_submit('uploads')." ".pref_submit('uploads');
$text .= "
</fieldset>"; </fieldset>";

View File

@ -177,6 +177,7 @@ else
if($mode == 'download' && !empty($_GET['src'])) if($mode == 'download' && !empty($_GET['src']))
{ {
define('e_IFRAME', true); define('e_IFRAME', true);
@ -210,10 +211,9 @@ elseif(vartrue($_POST['selectadmin']))
if(vartrue($_POST['upload'])) if(vartrue($_POST['upload']))
{ {
$mode = "choose"; $mode = "upload";
} }
elseif(vartrue($_POST['selectmain']) || varset($_POST['setUploadTheme']))
if(vartrue($_POST['selectmain']) || varset($_POST['setUploadTheme']))
{ {
$mode = "main"; $mode = "main";
} }

View File

@ -1042,6 +1042,7 @@ class e_file
* Unzip Plugin or Theme zip file and move to plugin or theme folder. * Unzip Plugin or Theme zip file and move to plugin or theme folder.
* @param string $localfile - filename located in e_TEMP * @param string $localfile - filename located in e_TEMP
* @param string $type - addon type, either 'plugin' or 'theme', (possibly 'language' in future). * @param string $type - addon type, either 'plugin' or 'theme', (possibly 'language' in future).
* @return string unzipped folder name on success or false.
*/ */
public function unzipArchive($localfile, $type) public function unzipArchive($localfile, $type)
{ {
@ -1094,13 +1095,28 @@ class e_file
//$status = "Done"; // ADMIN_TRUE_ICON; //$status = "Done"; // ADMIN_TRUE_ICON;
@unlink(e_TEMP.$localfile); @unlink(e_TEMP.$localfile);
return true; return $dir;
} }
return false; return false;
} }
/**
* Get an array of permitted filetypes according to a set hierarchy.
* If a specific file name given, that's used. Otherwise the default hierarchy is used
*
* @param string $file_mask - comma-separated list of allowed file types
* @param string $filename - optional override file name - defaults ignored
*
* @return array of filetypes
*/
function getFiletypeLimits($file_mask = false, $filename = '') // Wrapper only for now.
{
require_once(e_HANDLER."upload_handler.php");
$limits = get_filetypes($file_mask, $filename);
ksort($limits);
return $limits;
}
} }

View File

@ -65,13 +65,28 @@ class themeHandler
$this->fl = e107::getFile(); $this->fl = e107::getFile();
if(!empty($_POST['upload']))
if(isset($_POST['upload']))
{ {
$this->themeUpload(); $unzippedTheme = $this->themeUpload();
} }
if(vartrue($_POST['installContent'])) if(!empty($_POST['setUploadTheme']) && !empty($unzippedTheme))
{
$themeArray = $this->getThemes();
$this->id = $themeArray[$unzippedTheme]['id'];
if($this->setTheme())
{
$mes->addSuccess(TPVLAN_3);
}
else
{
$mes->addError("Could not change site theme."); // TODO LAN
}
}
if(!empty($_POST['installContent']))
{ {
$this->installContent($_POST['installContent']); $this->installContent($_POST['installContent']);
} }
@ -319,15 +334,33 @@ class themeHandler
$mes = e107::getMessage(); $mes = e107::getMessage();
$ns = e107::getRender(); $ns = e107::getRender();
extract($_FILES); // extract($_FILES);
//print_a($_FILES); //print_a($_FILES);
if(!is_writable(e_THEME)) if(!is_writable(e_TEMP))
{ {
$mes->addInfo(TPVLAN_20); $mes->addInfo(TPVLAN_20);
return FALSE; return FALSE;
} }
else
$fl = e107::getFile();
$mp = $this->getMarketplace();
$status = $fl->getUploaded(e_TEMP);
if(!empty($status[0]['error']))
{
$mes->addError($status[0]['message']);
return;
}
$mes->addSuccess($status[0]['message']);
return $fl->unzipArchive($status[0]['name'],'theme');
// else
/*
{ {
// FIXME - temporary fixes to upload process, check required. // FIXME - temporary fixes to upload process, check required.
// Probably in need of a rewrite to use process_uploaded_files(); // Probably in need of a rewrite to use process_uploaded_files();
@ -410,6 +443,8 @@ class themeHandler
@unlink(e_THEME.$archiveName); @unlink(e_THEME.$archiveName);
} }
} }
*
*/
} }
@ -754,7 +789,7 @@ class themeHandler
</tr> </tr>
</table> </table>
<div class='buttons-bar center'>".$frm->admin_button('upload', TPVLAN_14, 'submit')."</div> <div class='buttons-bar center'>".$frm->admin_button('upload', 1, 'submit', LAN_UPLOAD)."</div>
</form> </form>
"; ";
} }

View File

@ -33,7 +33,7 @@ if (!defined('e107_INIT'))
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_upload_handler.php'); include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_upload_handler.php');
//define("UH_DEBUG",TRUE); //define("UH_DEBUG",TRUE);
define("UH_DEBUG", FALSE);
//FIXME need another name //FIXME need another name
// define('e_UPLOAD_TEMP_DIR', e_MEDIA.'temp/'); // define('e_UPLOAD_TEMP_DIR', e_MEDIA.'temp/');
@ -120,6 +120,15 @@ function process_uploaded_files($uploaddir, $fileinfo = FALSE, $options = NULL)
$ul_temp_dir = e_UPLOAD_TEMP_DIR; $ul_temp_dir = e_UPLOAD_TEMP_DIR;
} }
if(E107_DEBUG_LEVEL > 0)
{
define("UH_DEBUG", true);
}
else
{
define("UH_DEBUG", false);
}
if (UH_DEBUG) if (UH_DEBUG)
{ {
e107::getLog()->e_log_event(10, debug_backtrace(), "DEBUG", "Upload Handler test", "Process uploads to {$uploaddir}, fileinfo ".$fileinfo, FALSE, LOG_TO_ROLLING); e107::getLog()->e_log_event(10, debug_backtrace(), "DEBUG", "Upload Handler test", "Process uploads to {$uploaddir}, fileinfo ".$fileinfo, FALSE, LOG_TO_ROLLING);