diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php
index 500d14dbe..b38c6583b 100644
--- a/e107_handlers/theme_handler.php
+++ b/e107_handlers/theme_handler.php
@@ -329,6 +329,8 @@ class themeHandler
$ns = e107::getRender();
extract($_FILES);
+ //print_a($_FILES);
+
if(!is_writable(e_THEME))
{
$mes->addInfo(TPVLAN_20);
@@ -336,46 +338,48 @@ class themeHandler
}
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");
- $fileName = $file_userfile['name'][0]; // $_FILES['file_userfile']['name'][0] ?
- $fileSize = $file_userfile['size'][0];
- $fileType = $file_userfile['type'][0]; // type is returned as mime type (application/octet-stream) not as zip/rar
+ $fileName = $_FILES['file_userfile']['name'][0];
+ $fileSize = $_FILES['file_userfile']['size'][0];
+ $fileType = $_FILES['file_userfile']['type'][0]; // type is returned as mime type (application/octet-stream) not as zip/rar
+
+ // There may be a better way to do this.. MIME may not be secure enough
+ // XXX - is there an e107 function for this?
+ $mime_zip = array("application/octet-stream", "application/zip", "multipart/x-zip");
+ $mime_gzip = array("application/x-gzip", "multipart/x-gzip");
+ // rar?
- if(strstr($file_userfile['type'][0], "gzip"))
- {
- $fileType = "tar";
- }
- else
- if(strstr($file_userfile['type'][0], "zip"))
+ if(in_array($fileType, $mime_zip))
{
$fileType = "zip";
}
+ elseif(in_array($fileType, $mime_gzip))
+ {
+ $fileType = "gzip";
+ }
else
{
-
- $mes->addError(TPVLAN_17);;
+ $mes->addError(TPVLAN_17);
return FALSE;
}
if($fileSize)
{
- $uploaded = file_upload(e_THEME);
-
+ $uploaded = file_upload(e_THEME);
$archiveName = $uploaded[0]['name'];
-
if($fileType == "zip")
{
require_once (e_HANDLER."pclzip.lib.php");
$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
{
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)
@@ -389,13 +393,13 @@ class themeHandler
$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);
return FALSE;
}
$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']))
{
@@ -407,7 +411,7 @@ class themeHandler
}
else
{
- $mes->addError(TPVLAN_3);
+ $mes->addError("Could not change site theme."); // TODO LAN
}
}
diff --git a/e107_languages/English/admin/lan_theme.php b/e107_languages/English/admin/lan_theme.php
index 9b8596a36..69bf89a2d 100644
--- a/e107_languages/English/admin/lan_theme.php
+++ b/e107_languages/English/admin/lan_theme.php
@@ -9,14 +9,14 @@
define("TPVLAN_1", "You are looking at a preview of the '".PREVIEWTHEMENAME."' 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.
To set this theme as your site theme, return to your theme manager and select 'Set As Site Theme'.
To preview more themes please click here");
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_5", "Website");
define("TPVLAN_6", "Release date");
define("TPVLAN_7", "Information");
define("TPVLAN_8", "Options");
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_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_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_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_21", "This is the currently selected site theme");