diff --git a/webtools/remora/app/config/bootstrap.php b/webtools/remora/app/config/bootstrap.php
index fb8253eabbc6..252122a9dde4 100644
--- a/webtools/remora/app/config/bootstrap.php
+++ b/webtools/remora/app/config/bootstrap.php
@@ -1,5 +1,5 @@
\ No newline at end of file
+?>
diff --git a/webtools/remora/app/controllers/addons_controller.php b/webtools/remora/app/controllers/addons_controller.php
index 5da62290f6a5..e1bc7d358ad6 100644
--- a/webtools/remora/app/controllers/addons_controller.php
+++ b/webtools/remora/app/controllers/addons_controller.php
@@ -9,7 +9,6 @@ class AddonsController extends AppController
*
*/
function index() {
- $this->layout = 'developers';
$this->set('addons', $this->Addon->findall());
}
@@ -18,8 +17,54 @@ class AddonsController extends AppController
* @param int $id
*/
function add($id = 0) {
+ $this->layout = 'developers';
+
if (isset($this->data['Addon']['add_step1'])) {
- $this->render('add_step2');
+ if ($this->data['Addon']['file']['error'] === 0) {
+ $uploadedFile = $this->data['Addon']['file']['tmp_name'];
+ $tempLocation = REPO_PATH.'/temp/'.$this->data['Addon']['file']['name'];
+
+ if (move_uploaded_file($uploadedFile, $tempLocation)) {
+ $uploadedFile = $tempLocation;
+ chmod($uploadedFile, 0644);
+ }
+ else {
+ $this->set('fileError', 'Could not move file');
+ $this->render('add_step1');
+ }
+
+ $manifestExists = false;
+
+ if ($zip = @zip_open($uploadedFile)) {
+ while ($zipEntry = zip_read($zip)) {
+ if (zip_entry_name($zipEntry) == 'install.rdf') {
+ $manifestExists = true;
+ if (zip_entry_open($zip, $zipEntry, 'r')) {
+ $manifestData = zip_entry_read($zipEntry, zip_entry_filesize($zipEntry));
+ zip_entry_close($zipEntry);
+ }
+ }
+ }
+ zip_close($zip);
+ }
+
+ if ($manifestExists === true) {
+
+ }
+
+ $this->render('add_step2');
+ }
+ else {
+ $this->Addon->invalidate('file');
+ $fileErrors = array('1' => 'Exceeds maximum upload size',
+ '2' => 'Exceeds maximum upload size',
+ '3' => 'Incomplete transfer',
+ '4' => 'No file uploaded'
+ );
+ $fileError = $fileErrors[$this->data['Addon']['file']['error']];
+ $this->set('fileError', $fileError);
+ $this->render('add_step1');
+ }
}
elseif (isset($this->data['Addon']['add_step2'])) {
$this->render('add_step3');
@@ -28,6 +73,7 @@ class AddonsController extends AppController
$this->render('add_step4');
}
else {
+ $this->set('fileError', '');
$this->render('add_step1');
}
}
diff --git a/webtools/remora/app/views/addons/add_step1.thtml b/webtools/remora/app/views/addons/add_step1.thtml
index 9d94ec020136..c2c318d1be07 100644
--- a/webtools/remora/app/views/addons/add_step1.thtml
+++ b/webtools/remora/app/views/addons/add_step1.thtml
@@ -1,5 +1,6 @@
-=$html->formTag('/addons/add/')?>
+=$html->formTag('/addons/add/', 'post', array('enctype'=>'multipart/form-data'))?>
=$html->hidden('Addon/add_step1')?>
-=$html->file('Addon/file')?>
-=$html->tagErrorMsg('Addon/file', 'Please upload your add-on file.')?>
+Max upload size: =ini_get('upload_max_filesize')?>
+Add-on File: =$html->file('Addon/file')?>
+=$html->tagErrorMsg('Addon/file', 'File error: '.$fileError)?>
=$html->submit()?>
diff --git a/webtools/remora/app/views/layouts/developers.thtml b/webtools/remora/app/views/layouts/developers.thtml
index f0384fb1a87b..019c877321b4 100644
--- a/webtools/remora/app/views/layouts/developers.thtml
+++ b/webtools/remora/app/views/layouts/developers.thtml
@@ -5,13 +5,13 @@