diff --git a/application/controllers/admin/templates.php b/application/controllers/admin/templates.php
index 5a0b87b4c38..a2a75df6738 100644
--- a/application/controllers/admin/templates.php
+++ b/application/controllers/admin/templates.php
@@ -33,7 +33,7 @@ function __construct()
{
parent::__construct();
}
-
+
/**
* templates::upload()
* function responsible to import a template archive.
@@ -42,22 +42,22 @@ function __construct()
function upload()
{
$clang = $this->limesurvey_lang;
-
+
self::_js_admin_includes(base_url().'scripts/admin/templates.js');
-
+
self::_getAdminHeader();
self::_initialise('default','welcome', 'startpage.pstpl',FALSE);
$lid = $this->input->post('lid');
$action = $this->input->post('action');
-
-
-
+
+
+
if ($action == 'templateupload')
{
$basedestdir = $this->config->item('publicdir')."/upload/surveys";
$importtemplateoutput = "
\n";
$importtemplateoutput .= "";
-
+
if ($this->config->item('demoModeOnly') === true)
{
$importtemplateoutput .= "
\n";
@@ -67,7 +67,7 @@ function upload()
show_error($importtemplateoutput);
return;
}
-
+
//require("classes/phpzip/phpzip.inc.php");
$this->load->library('admin/Phpzip');
//$the_full_file_path = $tempdir . "/" . $_FILES['the_file']['name'];
@@ -80,7 +80,7 @@ function upload()
$basedestdir = $this->config->item('usertemplaterootdir');
$newdir=str_replace('.','',self::_strip_ext(sanitize_paranoid_string($_FILES['the_file']['name'])));
$destdir=$basedestdir.'/'.$newdir.'/';
-
+
if (!is_writeable($basedestdir))
{
$importtemplateoutput .= "
\n";
@@ -90,7 +90,7 @@ function upload()
show_error($importtemplateoutput);
return;
}
-
+
if (!is_dir($destdir))
{
mkdir($destdir);
@@ -104,17 +104,17 @@ function upload()
show_error($importtemplateoutput);
return;
}
-
+
$aImportedFilesInfo=array();
$aErrorFilesInfo=array();
-
-
+
+
if (is_file($zipfile))
{
$importtemplateoutput .= "
\n";
$importtemplateoutput .= $clang->gT("File upload succeeded.")."
\n";
$importtemplateoutput .= $clang->gT("Reading file..")."
\n";
-
+
if ($z->extract($extractdir,$zipfile) != 'OK')
{
$importtemplateoutput .= "
\n";
@@ -124,10 +124,10 @@ function upload()
show_error($importtemplateoutput);
return;
}
-
+
$ErrorListHeader = "";
$ImportListHeader = "";
-
+
// now read tempdir and copy authorized files only
$dh = opendir($extractdir);
while($direntry = readdir($dh))
@@ -146,7 +146,7 @@ function upload()
"status" => $clang->gT("Copy failed")
);
unlink($extractdir."/".$direntry);
-
+
}
else
{
@@ -157,7 +157,7 @@ function upload()
unlink($extractdir."/".$direntry);
}
}
-
+
else
{ // Extension forbidden
$aErrorFilesInfo[]=Array(
@@ -169,14 +169,14 @@ function upload()
} // end if is_file
} // end if ! . or ..
} // end while read dir
-
-
+
+
//Delete the temporary file
unlink($zipfile);
closedir($dh);
//Delete temporary folder
rmdir($extractdir);
-
+
// display summary
$okfiles = 0;
$errfiles= 0;
@@ -196,7 +196,7 @@ function upload()
$importtemplateoutput .= "
\n";
show_error($importtemplateoutput);
return;
-
+
}
elseif (count($aErrorFilesInfo)>0 && count($aImportedFilesInfo)>0)
{
@@ -214,7 +214,7 @@ function upload()
$errfiles = count($aErrorFilesInfo);
$ErrorListHeader .= "
".$clang->gT("Error Files List").":
\n";
}
-
+
$importtemplateoutput .= "".$clang->gT("Imported template files for")." $lid
\n";
$importtemplateoutput .= "".$status."
\n";
$importtemplateoutput .= "".$clang->gT("Resources Import Summary")."
\n";
@@ -250,21 +250,21 @@ function upload()
}
$importtemplateoutput .= "\n";
$importtemplateoutput .= "\n";
-
+
$idata['display'] = $importtemplateoutput;
$this->load->view('survey_view',$idata);
-
+
}
else
{
-
+
$ZIPimportAction = " onclick='if (validatefilename(this.form,\"".$clang->gT('Please select a file to import!','js')."\")) {this.form.submit();}'";
if (!function_exists("zip_open"))
{
$ZIPimportAction = " onclick='alert(\"".$clang->gT("zip library not supported by PHP, Import ZIP Disabled","js")."\");'";
}
$templatesoutput= "\n";
-
+
$templatesoutput.= "\t