1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 21:27:25 +02:00

#318 - More work on theme upload - semi-functional now.

This commit is contained in:
Moc
2013-06-15 15:02:45 +02:00
parent 84b408073e
commit b4b35d25dd
2 changed files with 27 additions and 23 deletions

View File

@@ -329,6 +329,8 @@ class themeHandler
$ns = e107::getRender(); $ns = e107::getRender();
extract($_FILES); extract($_FILES);
//print_a($_FILES);
if(!is_writable(e_THEME)) if(!is_writable(e_THEME))
{ {
$mes->addInfo(TPVLAN_20); $mes->addInfo(TPVLAN_20);
@@ -336,25 +338,29 @@ class themeHandler
} }
else else
{ {
// FIXME - upload seems to unfunctional - needs further testing and fixing // FIXME - temporary fixes to upload process, check required.
require_once (e_HANDLER."upload_handler.php"); require_once (e_HANDLER."upload_handler.php");
$fileName = $file_userfile['name'][0]; // $_FILES['file_userfile']['name'][0] ? $fileName = $_FILES['file_userfile']['name'][0];
$fileSize = $file_userfile['size'][0]; $fileSize = $_FILES['file_userfile']['size'][0];
$fileType = $file_userfile['type'][0]; // type is returned as mime type (application/octet-stream) not as zip/rar $fileType = $_FILES['file_userfile']['type'][0]; // type is returned as mime type (application/octet-stream) not as zip/rar
if(strstr($file_userfile['type'][0], "gzip")) // There may be a better way to do this.. MIME may not be secure enough
{ // XXX - is there an e107 function for this?
$fileType = "tar"; $mime_zip = array("application/octet-stream", "application/zip", "multipart/x-zip");
} $mime_gzip = array("application/x-gzip", "multipart/x-gzip");
else // rar?
if(strstr($file_userfile['type'][0], "zip"))
if(in_array($fileType, $mime_zip))
{ {
$fileType = "zip"; $fileType = "zip";
} }
elseif(in_array($fileType, $mime_gzip))
{
$fileType = "gzip";
}
else else
{ {
$mes->addError(TPVLAN_17);
$mes->addError(TPVLAN_17);;
return FALSE; return FALSE;
} }
@@ -362,20 +368,18 @@ class themeHandler
{ {
$uploaded = file_upload(e_THEME); $uploaded = file_upload(e_THEME);
$archiveName = $uploaded[0]['name']; $archiveName = $uploaded[0]['name'];
if($fileType == "zip") if($fileType == "zip")
{ {
require_once (e_HANDLER."pclzip.lib.php"); require_once (e_HANDLER."pclzip.lib.php");
$archive = new PclZip(e_THEME.$archiveName); $archive = new PclZip(e_THEME.$archiveName);
$unarc = ($fileList = $archive->extract(PCLZIP_OPT_PATH, e_THEME, PCLZIP_OPT_SET_CHMOD, 0666)); $unarc = ($fileList = $archive->extract(PCLZIP_OPT_PATH, e_THEME, PCLZIP_OPT_SET_CHMOD, 0666)); // FIXME - detect folder structure similar to 'Find themes'
} }
else else
{ {
require_once (e_HANDLER."pcltar.lib.php"); require_once (e_HANDLER."pcltar.lib.php");
$unarc = ($fileList = PclTarExtract($archiveName, e_THEME)); $unarc = ($fileList = PclTarExtract($archiveName, e_THEME)); // FIXME - detect folder structure similar to 'Find themes'
} }
if(!$unarc) if(!$unarc)
@@ -389,13 +393,13 @@ class themeHandler
$error = TPVLAN_47.PclErrorString().", ".TPVLAN_48.intval(PclErrorCode()); $error = TPVLAN_47.PclErrorString().", ".TPVLAN_48.intval(PclErrorCode());
} }
$mes->add(TPVLAN_18." ".$archiveName." ".$error, E_MESSAGE_ERROR); $mes->addError(TPVLAN_18." ".$archiveName." ".$error);
// $ns->tablerender(TPVLAN_16, TPVLAN_18." ".$archiveName." ".$error); // $ns->tablerender(TPVLAN_16, TPVLAN_18." ".$archiveName." ".$error);
return FALSE; return FALSE;
} }
$folderName = substr($fileList[0]['stored_filename'], 0, (strpos($fileList[0]['stored_filename'], "/"))); $folderName = substr($fileList[0]['stored_filename'], 0, (strpos($fileList[0]['stored_filename'], "/")));
$mes->add(TPVLAN_19, E_MESSAGE_SUCCESS); $mes->addSuccess(TPVLAN_19);
if(varset($_POST['setUploadTheme'])) if(varset($_POST['setUploadTheme']))
{ {
@@ -407,7 +411,7 @@ class themeHandler
} }
else else
{ {
$mes->addError(TPVLAN_3); $mes->addError("Could not change site theme."); // TODO LAN
} }
} }

View File

@@ -9,14 +9,14 @@
define("TPVLAN_1", "You are looking at a preview of the <b>'".PREVIEWTHEMENAME."'</b> theme. It has not been set as the main theme for your site, it has been activated to provide a preview of how the theme looks.<br />To set this theme as your site theme, <a href='".e_ADMIN."theme.php?choose'>return to your theme manager</a> and select 'Set As Site Theme'.<br />To preview more themes please <a href='".e_ADMIN."theme.php'>click here</a>"); define("TPVLAN_1", "You are looking at a preview of the <b>'".PREVIEWTHEMENAME."'</b> theme. It has not been set as the main theme for your site, it has been activated to provide a preview of how the theme looks.<br />To set this theme as your site theme, <a href='".e_ADMIN."theme.php?choose'>return to your theme manager</a> and select 'Set As Site Theme'.<br />To preview more themes please <a href='".e_ADMIN."theme.php'>click here</a>");
define("TPVLAN_2", "Theme Preview"); define("TPVLAN_2", "Theme Preview");
define("TPVLAN_3", "Main site theme set to"); define("TPVLAN_3", "Site theme changed.");
define("TPVLAN_4", "Author"); define("TPVLAN_4", "Author");
define("TPVLAN_5", "Website"); define("TPVLAN_5", "Website");
define("TPVLAN_6", "Release date"); define("TPVLAN_6", "Release date");
define("TPVLAN_7", "Information"); define("TPVLAN_7", "Information");
define("TPVLAN_8", "Options"); define("TPVLAN_8", "Options");
define("TPVLAN_9", "Preview Theme"); define("TPVLAN_9", "Preview Theme");
define("TPVLAN_10", "Set As Site Theme"); define("TPVLAN_10", "Set as Site Theme");
define("TPVLAN_11", "Version"); define("TPVLAN_11", "Version");
define("TPVLAN_12", "No preview available"); define("TPVLAN_12", "No preview available");
@@ -26,7 +26,7 @@ define("TPVLAN_15", "The file could not be uploaded as the ".e_THEME." folder do
define("TPVLAN_16", "Admin Message"); define("TPVLAN_16", "Admin Message");
define("TPVLAN_17", "That file does not appear to be a valid .zip or .tar archive."); define("TPVLAN_17", "That file does not appear to be a valid .zip or .tar archive.");
define("TPVLAN_18", "An error has occurred, unable to un-archive the file"); define("TPVLAN_18", "An error has occurred, unable to un-archive the file");
define("TPVLAN_19", "Your theme has been uploaded and unzipped, please scroll down to see your theme in the list."); define("TPVLAN_19", "Your theme has been uploaded and unzipped.");
define("TPVLAN_20", "Auto theme upload and extraction is disabled as your themes folder does not have the correct permissions - please CHMOD your e107_themes folder to 777."); define("TPVLAN_20", "Auto theme upload and extraction is disabled as your themes folder does not have the correct permissions - please CHMOD your e107_themes folder to 777.");
define("TPVLAN_21", "This is the currently selected site theme"); define("TPVLAN_21", "This is the currently selected site theme");