diff --git a/livesupport/src/modules/htmlUI/var/formmask/exchange.inc.php b/livesupport/src/modules/htmlUI/var/formmask/exchange.inc.php new file mode 100644 index 000000000..2fc06cc35 --- /dev/null +++ b/livesupport/src/modules/htmlUI/var/formmask/exchange.inc.php @@ -0,0 +1,94 @@ + array( + array( + 'element' => 'act', + 'type' => 'hidden', + 'constant' => 'BACKUP.schedule' + ), + array( + 'element' => 'mon', + 'type' => 'checkbox', + 'label' => 'Mon', + 'groupit' => true + ), + array( + 'element' => 'tue', + 'type' => 'checkbox', + 'label' => 'Tue', + 'groupit' => true + ), + array( + 'element' => 'wed', + 'type' => 'checkbox', + 'label' => 'Wed', + 'groupit' => true + ), + array( + 'element' => 'thu', + 'type' => 'checkbox', + 'label' => 'Thu', + 'groupit' => true + ), + array( + 'element' => 'fri', + 'type' => 'checkbox', + 'label' => 'Fri', + 'groupit' => true + ), + array( + 'element' => 'sat', + 'type' => 'checkbox', + 'label' => 'Sat', + 'groupit' => true + ), + array( + 'element' => 'sun', + 'type' => 'checkbox', + 'label' => 'Sun', + 'groupit' => true + ), + array( + 'group' => array('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'), + 'label' => 'Weeksdays' + ), + array( + 'element' => 'date', + 'type' => 'date', + 'label' => 'Month/Day', + 'options' => array( + 'format' => 'md', + 'addEmptyOption' => true, + 'emptyOptionValue' => '*', + 'emptyOptionText' => '*' + ) + ), + array( + 'element' => 'time', + 'type' => 'date', + 'label' => 'Hour/Minute', + 'options' => array( + 'format' => 'Hi', + ) + ), + array( + 'element' =>'cancel', + 'type' =>'button', + 'label' =>'Cancel', + 'attributes'=>array('onclick' => 'location.href="'.UI_BROWSER.'?act=BACKUP"'), + 'groupit' => TRUE + ), + array( + 'element' =>'Submit', + 'type' =>'submit', + 'label' =>'Submit', + 'groupit' => TRUE + ), + array( + 'group' => array('cancel', 'Submit'), + 'label' => ' ' + ), + ) +); +?> + \ No newline at end of file diff --git a/livesupport/src/modules/htmlUI/var/html/ui_browser.php b/livesupport/src/modules/htmlUI/var/html/ui_browser.php index d871dcb22..35a2963ee 100644 --- a/livesupport/src/modules/htmlUI/var/html/ui_browser.php +++ b/livesupport/src/modules/htmlUI/var/html/ui_browser.php @@ -171,6 +171,14 @@ if (is_array($_REQUEST['popup'])){ $uiBrowser->EXCHANGE->setFile($_REQUEST['file']); $Smarty->display('backup/fileBrowser.tpl'); break; + + case 'BACKUP.createBackupDownloadPopup': + $Smarty->display('backup/download.tpl'); + break; + + case 'BACKUP.createBackupDownloadNow': + $uiBrowser->EXCHANGE->createBackupDownload(); + break; } } die(); @@ -278,7 +286,8 @@ if ($uiBrowser->userid) { break; case "BACKUP": - case "RESTORE": + case "RESTORE": + case "BACKUP.schedule": $Smarty->assign('act', $_REQUEST['act']); break; diff --git a/livesupport/src/modules/htmlUI/var/html/ui_handler.php b/livesupport/src/modules/htmlUI/var/html/ui_handler.php index 6fc186250..f51197479 100644 --- a/livesupport/src/modules/htmlUI/var/html/ui_handler.php +++ b/livesupport/src/modules/htmlUI/var/html/ui_handler.php @@ -289,7 +289,7 @@ switch($_REQUEST['act']){ $uiHandler->SCHEDULER->setReload(); break; - case "EXCHANGE.createBackupOpen": + case "BACKUP.createBackupOpen": $uiHandler->EXCHANGE->createBackupOpen(); $uiHandler->redirUrl = UI_BROWSER.'?act=BACKUP'; break; diff --git a/livesupport/src/modules/htmlUI/var/templates/backup/backup.tpl b/livesupport/src/modules/htmlUI/var/templates/backup/backup.tpl index 9a11a4bb2..b971aff69 100644 --- a/livesupport/src/modules/htmlUI/var/templates/backup/backup.tpl +++ b/livesupport/src/modules/htmlUI/var/templates/backup/backup.tpl @@ -21,17 +21,20 @@ {/if} {if $EXCHANGE->checkTarget() === true} -

+

{/if} -

+

+ +

+ {else} {assign var='status' value=$EXCHANGE->createBackupCheck()} Backup status: {$status.status} {if $status.status === 'success'} -

+

{/if} {/if} diff --git a/livesupport/src/modules/htmlUI/var/templates/backup/download.tpl b/livesupport/src/modules/htmlUI/var/templates/backup/download.tpl new file mode 100644 index 000000000..4331c8b39 --- /dev/null +++ b/livesupport/src/modules/htmlUI/var/templates/backup/download.tpl @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/livesupport/src/modules/htmlUI/var/templates/backup/fileBrowser.tpl b/livesupport/src/modules/htmlUI/var/templates/backup/fileBrowser.tpl index 297389e30..1b7105784 100644 --- a/livesupport/src/modules/htmlUI/var/templates/backup/fileBrowser.tpl +++ b/livesupport/src/modules/htmlUI/var/templates/backup/fileBrowser.tpl @@ -7,9 +7,6 @@ if (window.scrollbars.visible == false) { location.reload(); } {/literal} -{if $EXCHANGE->errorMsg} - alert("{$EXCHANGE->errorMsg|escape:'quotes'}"); -{/if} @@ -17,31 +14,37 @@ if (window.scrollbars.visible == false) {
- - + + + + {assign var='currdir' value=$EXCHANGE->listFolder()} {foreach from=$currdir.subdirs item=entry key=name} - - - - + + + + + + {/foreach} {foreach from=$currdir.files item=entry key=name} - - - - + + + + + + {/foreach} @@ -52,5 +55,11 @@ if (window.scrollbars.visible == false) {

##File browser##

-
- ##Filename:##
- - -
-

##File browser##

+
+ ##Filename:##
+ + +
+
{$name}{if $entry.r}r{/if}{if $entry.w}w{/if}
{$name|truncate:50:"...":true}{$entry.u|truncate:10:'...':true}{$entry.g|truncate:10:'...':true}{if $entry.r}r{/if}{if $entry.w}w{/if} {if $entry.x}x{/if}
{$name}{if $entry.r}r{/if}{if $entry.w}w{/if}
{$name|truncate:50:"...":true}{$entry.u|truncate:10:'...':true}{$entry.g|truncate:10:'...':true}{if $entry.r}r{/if}{if $entry.w}w{/if} {if $entry.x}x{/if}
+ + \ No newline at end of file diff --git a/livesupport/src/modules/htmlUI/var/templates/backup/schedule.tpl b/livesupport/src/modules/htmlUI/var/templates/backup/schedule.tpl new file mode 100644 index 000000000..756c0853a --- /dev/null +++ b/livesupport/src/modules/htmlUI/var/templates/backup/schedule.tpl @@ -0,0 +1,11 @@ +
+ +
+

##Schedule backup##

+ +{assign var='dynform' value=$EXCHANGE->getScheduleBackupForm()} +{include file="sub/dynForm_plain.tpl"} + +
+
+ diff --git a/livesupport/src/modules/htmlUI/var/templates/masterpanel.tpl b/livesupport/src/modules/htmlUI/var/templates/masterpanel.tpl index e51466988..b4b065ce3 100644 --- a/livesupport/src/modules/htmlUI/var/templates/masterpanel.tpl +++ b/livesupport/src/modules/htmlUI/var/templates/masterpanel.tpl @@ -59,6 +59,10 @@ {include file="backup/backup.tpl"} {/if} + {if $act === 'BACKUP.schedule'} + {include file="backup/schedule.tpl"} + {/if} + {if $act === 'RESTORE'} {include file="backup/restore.tpl"} {/if} diff --git a/livesupport/src/modules/htmlUI/var/ui_base.inc.php b/livesupport/src/modules/htmlUI/var/ui_base.inc.php index 3338f8bb3..cb6e827d3 100644 --- a/livesupport/src/modules/htmlUI/var/ui_base.inc.php +++ b/livesupport/src/modules/htmlUI/var/ui_base.inc.php @@ -210,7 +210,7 @@ class uiBase if (!$v['groupit']) $form->addElement($elem[$v['element']]); } elseif ($v['type']=='checkbox' || $v['type']=='static') { - $elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']), $v['text'], $v['attributes']); + $elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']), tra($v['text']), $v['attributes']); if (!$v['groupit']) $form->addElement($elem[$v['element']]); } elseif (isset($v['type'])) { diff --git a/livesupport/src/modules/htmlUI/var/ui_exchange.class.php b/livesupport/src/modules/htmlUI/var/ui_exchange.class.php index 4059807ef..cdab5925f 100644 --- a/livesupport/src/modules/htmlUI/var/ui_exchange.class.php +++ b/livesupport/src/modules/htmlUI/var/ui_exchange.class.php @@ -13,6 +13,8 @@ class uiExchange $this->test = false; } + // GB wrapper emthods + function getBackupToken() { if ($this->test) return "12345"; @@ -66,6 +68,19 @@ class uiExchange return $res; } + // Download the backup + + function createBackupDownload() + { + $check = $this->createBackupCheck(); + + header('Content-Length: '.filesize($check['tmpfile'])); + header("Content-Transfer-Encoding: binary"); + header('Content-Disposition: attachment; filename="'.basename($check['tmpfile']).'"'); + + readfile($check['tmpfile']); + } + function createBackupClose() { $token = $token = $this->getBackupToken(); @@ -89,16 +104,39 @@ class uiExchange return $status; } + // backup schduler methods + function getScheduleBackupForm() + { + include 'formmask/exchange.inc.php'; + + $form = new HTML_QuickForm('BACKUP_Schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER); + $this->Base->_parseArr2Form($form, $mask['BACKUP.schedule']); + $renderer =& new HTML_QuickForm_Renderer_Array(true, true); + $form->accept($renderer); + + return $renderer->toArray(); + } + + + + // file browser methods function setFolder($subfolder) { $this->file = false; + $newfolder = realpath($this->folder.'/'.$subfolder); - if (!is_dir($this->folder.'/'.$subfolder)) { + if (!is_dir($newfolder)) { # F5 pressed return false; } - $this->folder = realpath($this->folder.'/'.$subfolder); + + if (!is_executable($newfolder)) { + $this->errorMsg = tra('$1: cd: permission denied', $newfolder); + return false; + } + + $this->folder = $newfolder; } function setFile($file) @@ -109,7 +147,7 @@ class uiExchange return true; } $this->file = false; - $this->errorMsg = tra('$1: Permission denied', $file); + $this->errorMsg = tra('$1: open: permission denied', $file); return false; } @@ -154,15 +192,20 @@ class uiExchange function listFolder() { + if (!is_readable($this->folder)) { + $this->errorMsg = tra('$1: ls: permission denied', $this->folder); + return array('subdirs' => array('..' => array()), 'files' => array()); + } + $d = dir($this->folder); while (false !== ($entry = $d->read())) { $loc = $this->folder.'/'.$entry; if (is_dir($loc)) { - $dirs[$entry] = $this->_getPerm($loc); + $dirs[$entry] = $this->_getFileProperty($loc); } else { - $files[$entry] = $this->_getPerm($loc); + $files[$entry] = $this->_getFileProperty($loc); } } @@ -173,12 +216,18 @@ class uiExchange return array('subdirs' => $dirs, 'files' => $files); } - function _getPerm($loc) + function _getFileProperty($loc) { + $uarr = posix_getpwuid(fileowner($loc)); + $user = $uarr['name']; + $grarr = posix_getgrgid(filegroup($loc)); + $group = $grarr['name']; return array( 'r' => is_readable($loc), 'w' => is_writable($loc), - 'x' => is_executable($loc), + 'x' => is_executable($loc), + 'u' => $user, + 'g' => $group, ); }