function execAction($dir, $item) { if (!ext_isArchive($item)) { ext_Result::sendResult('archive', false, $item . ': ' . ext_Lang::err('extract_noarchive')); } else { // CSRF Security Check if (!ext_checkToken($GLOBALS['__POST']["token"])) { ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.'); } $archive_name = realpath(get_abs_item($dir, $item)); if (empty($dir)) { $extract_dir = realpath($GLOBALS['home_dir']); } else { $extract_dir = realpath($GLOBALS['home_dir'] . "/" . $dir); } require_once _EXT_PATH . '/libraries/Archive/archive.php'; $res = extArchive::extract($archive_name, $extract_dir); if (PEAR::isError($res)) { ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure') . ' - ' . $res->getMessage()); } if ($res === false) { ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure')); } else { ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success')); } ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success')); } }
function execAction($dir, $item) { if (!ext_isArchive($item)) { ext_Result::sendResult('archive', false, $item . ': ' . ext_Lang::err('extract_noarchive')); } else { $archive_name = realpath(get_abs_item($dir, $item)); if (empty($dir)) { $extract_dir = realpath($GLOBALS['home_dir']); } else { $extract_dir = realpath($GLOBALS['home_dir'] . "/" . $dir); } require_once _EXT_PATH . '/libraries/Archive/archive.php'; $res = extArchive::extract($archive_name, $extract_dir); if (PEAR::isError($res)) { ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure') . ' - ' . $res->getMessage()); } if ($res === false) { ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure')); } else { ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success')); } ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success')); } }
function onShowLoginForm($User, $Pass) { ?> { xtype: "form", <?php if (!ext_isXHR()) { ?> renderTo: "adminForm", <?php } ?> title: "<?php echo ext_Lang::msg('actlogin'); ?> ", id: "simpleform", labelWidth: 125, // label settings here cascade unless overridden url: "<?php echo basename($GLOBALS['script_name']); ?> ", frame: true, keys: { key: Ext.EventObject.ENTER, fn : function(){ if (simple.getForm().isValid()) { Ext.get( "statusBar").update( "Please wait..." ); Ext.getCmp("simpleform").getForm().submit({ reset: false, success: function(form, action) { location.reload() }, failure: function(form, action) { if( !action.result ) return; Ext.Msg.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error, function() { this.findField( 'password').setValue(''); this.findField( 'password').focus(); }, form ); Ext.get( 'statusBar').update( action.result.error ); }, scope: Ext.getCmp("simpleform").getForm(), params: { option: "com_extplorer", action: "login", type : "extplorer" } }); } else { return false; } } }, items: [{ xtype:"textfield", fieldLabel: "<?php echo ext_Lang::msg('miscusername', true); ?> ", name: "username", value: "<?php echo $User; ?> ", width:175, allowBlank:false },{ xtype:"textfield", fieldLabel: "<?php echo ext_Lang::msg('miscpassword', true); ?> ", name: "password", value: "<?php echo $Pass; ?> ", inputType: "password", width:175, allowBlank:false }, new Ext.form.ComboBox({ fieldLabel: "<?php echo ext_Lang::msg('misclang', true); ?> ", store: new Ext.data.SimpleStore({ fields: ['language', 'langname'], data : [ <?php $langs = get_languages(); $i = 0; $c = count($langs); foreach ($langs as $language => $name) { echo "['{$language}', '{$name}' ]"; if (++$i < $c) { echo ','; } } ?> ] }), displayField:"langname", valueField: "language", value: "<?php echo ext_Lang::detect_lang(); ?> ", hiddenName: "lang", disableKeyFilter: true, editable: false, triggerAction: "all", mode: "local", allowBlank: false, selectOnFocus:true }), { xtype: "displayfield", id: "statusBar" } ], buttons: [{ text: "<?php echo ext_Lang::msg('btnlogin', true); ?> ", type: "submit", handler: function() { Ext.get( "statusBar").update( "Please wait..." ); Ext.getCmp("simpleform").getForm().submit({ reset: false, success: function(form, action) { location.reload() }, failure: function(form, action) { if( !action.result ) return; Ext.Msg.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error, function() { this.findField( 'password').setValue(''); this.findField( 'password').focus(); }, form ); Ext.get( 'statusBar').update( action.result.error ); }, scope: Ext.getCmp("simpleform").getForm(), params: { option: "com_extplorer", action: "login", type : "extplorer" } }); } },<?php if (!ext_isXHR()) { ?> { text: '<?php echo ext_Lang::msg('btnreset', true); ?> ', handler: function() { simple.getForm().reset(); } } <?php } else { ?> { text: "<?php echo ext_Lang::msg('btncancel', true); ?> ", handler: function() { Ext.getCmp("dialog").destroy(); } } <?php } ?> ] } <?php }
function execAction() { $ftp_login = extGetParam($_POST, 'ftp_login_name', ''); $ftp_pass = extGetParam($_POST, 'ftp_login_pass', ''); global $dir, $mosConfig_live_site; if ($ftp_login != '' || $ftp_pass != '') { $ftp_host = extGetParam($_POST, 'ftp_hostname_port', 'localhost:21'); $url = @parse_url('ftp://' . $ftp_host); if (empty($url)) { ext_Result::sendResult('ftp_authentication', false, 'Unable to parse the specified Host Name. Please use a hostname in this format: hostname:21'); } $port = empty($url['port']) ? 21 : $url['port']; $ftp = new Net_FTP($url['host'], $port, 20); $res = $ftp->connect(); if (PEAR::isError($res)) { ext_Result::sendResult('ftp_authentication', false, $GLOBALS['messages']['ftp_connection_failed'] . ' (' . $url['host'] . ')'); } else { $res = $ftp->login($ftp_login, $ftp_pass); $ftp->disconnect(); if (PEAR::isError($res)) { ext_Result::sendResult('ftp_authentication', false, $GLOBALS['messages']['ftp_login_failed']); } $_SESSION['ftp_login'] = $ftp_login; $_SESSION['ftp_pass'] = $ftp_pass; $_SESSION['ftp_host'] = $ftp_host; $_SESSION['file_mode'] = 'ftp'; session_write_close(); ext_Result::sendResult('ftp_authentication', true, ext_Lang::msg('actlogin_success')); } } else { ?> <div style="width:auto;"> <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div> <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"> <h3 style="margin-bottom:5px;"><?php echo $GLOBALS["messages"]["ftp_header"]; ?> </h3> <strong><?php echo $GLOBALS["messages"]["ftp_login_lbl"]; ?> </strong><br /> <br /> <div id="adminForm"> </div> </div></div></div> <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div> </div> <script type="text/javascript"> var simple = new Ext.form.Form({ labelWidth: 175, // label settings here cascade unless overridden url:'<?php echo make_link("rename", $dir, $item); ?> ' }); simple.add( new Ext.form.TextField({ fieldLabel: '<?php echo ext_Lang::msg('ftp_login_name', true); ?> ', name: 'ftp_login_name', width:175, allowBlank:false }), new Ext.form.TextField({ fieldLabel: '<?php echo ext_Lang::msg('ftp_login_pass', true); ?> ', name: 'ftp_login_pass', inputType: 'password', width:175, allowBlank:false }), new Ext.form.TextField({ fieldLabel: '<?php echo ext_Lang::msg('ftp_hostname_port', true); ?> ', name: 'ftp_hostname_port', value: '<?php echo extGetParam($_SESSION, 'ftp_host', 'localhost:21'); ?> ', width:175, allowBlank:false }) ); simple.addButton({text: '<?php echo ext_Lang::msg('btnlogin', true); ?> ', type: 'submit' }, function() { statusBarMessage( '<?php echo ext_Lang::msg('ftp_login_check', true); ?> ', true ); simple.submit({ //reset: true, reset: false, success: function(form, action) { location.reload() }, failure: function(form, action) { if( !action.result ) return; Ext.MessageBox.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); statusBarMessage( action.result.error, false, false ); }, scope: simple, // add some vars to the request, similar to hidden fields params: {option: 'com_extplorer', action: 'ftp_authentication' } }); }); simple.addButton('<?php echo ext_Lang::msg('btncancel', true); ?> ', function() { dialog.destroy(); } ); simple.render('adminForm'); </script> <br/> <?php } }
function admin($admin, $dir) { // Change Password & Manage Users Form // Javascript functions: include _EXT_PATH . "/include/js_admin.php"; ?> <div style="width:auto;"> <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div> <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"> <h3 style="margin-bottom:5px;"><?php echo ext_Lang::msg('actadmin'); ?> </h3> <div id="adminForm"> <div id="passForm"></div> <div id="userList"></div> </div> </div></div></div> <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div> </div> <script type="text/javascript"> // Change Password var PassForm = new Ext.form.Form({ labelWidth: 125, // label settings here cascade unless overridden url:'<?php echo basename($GLOBALS['script_name']); ?> ' }); PassForm.add( new Ext.form.TextField({ fieldLabel: '<?php echo ext_Lang::msg('miscoldpass', true); ?> ', name: 'oldpwd', inputType: 'password', allowBlank:false }), new Ext.form.TextField({ fieldLabel: '<?php echo ext_Lang::msg('miscnewpass', true); ?> ', name: 'newpwd1', hiddenName: 'newpwd1', inputType: 'password', allowBlank:false }), new Ext.form.TextField({ fieldLabel: '<?php echo ext_Lang::msg('miscconfnewpass', true); ?> ', name: 'newpwd2', hiddenName: 'newpwd2', inputType: 'password', allowBlank:false }) ); PassForm.addButton('<?php echo ext_Lang::msg('btnchange', true); ?> ', function() { if( !check_pwd() ) return; statusBarMessage( 'Please wait...', true ); PassForm.submit({ //reset: true, reset: false, success: function(form, action) { statusBarMessage( action.result.message, false, true ); }, failure: function(form, action) { if( !action.result ) return; Ext.MessageBox.alert('Error!', action.result.error); statusBarMessage( action.result.error, false, true ); }, scope: PassForm, // add some vars to the request, similar to hidden fields params: { option: 'com_extplorer', action: 'admin', action2: 'chpwd' } }) }); PassForm.render('passForm'); PassForm.findField('oldpwd').focus(); <?php if ($admin) { ?> // Edit / Add / Remove User var UserForm = new Ext.form.Form({ labelWidth: 125, // label settings here cascade unless overridden url:'<?php echo basename($GLOBALS['script_name']); ?> ' }); UserForm.add( <?php $cnt = count($GLOBALS["users"]); for ($i = 0; $i < $cnt; ++$i) { // Username & Home dir: $user = $GLOBALS["users"][$i][0]; if (strlen($user) > 15) { $user = substr($user, 0, 12) . "..."; } $home = $GLOBALS["users"][$i][2]; if (strlen($home) > 30) { $home = substr($home, 0, 27) . "..."; } ?> new Ext.form.Radio( { name: 'nuser', inputValue: '<?php echo $GLOBALS["users"][$i][0]; ?> ', fieldLabel: '<?php echo $user; ?> ', boxLabel: '<?php echo '<strong>Homedir:</strong> ' . $home . '; ' . ($GLOBALS["users"][$i][4] ? $GLOBALS["messages"]["miscyesno"][2] : $GLOBALS["messages"]["miscyesno"][3]) . '; ' . $GLOBALS["users"][$i][6] . '; ' . ($GLOBALS["users"][$i][7] ? $GLOBALS["messages"]["miscyesno"][2] : $GLOBALS["messages"]["miscyesno"][3]); ?> ' }) <?php echo $i + 1 < $cnt ? ',' : ''; } ?> ); UserForm.addButton('<?php echo ext_Lang::msg('btnadd', true); ?> ', function() { dialog_panel.load({url: '<?php echo basename($GLOBALS['script_name']); ?> ', params: { option: 'com_extplorer', action: 'admin', action2: 'adduser' } }); }); UserForm.addButton('<?php echo ext_Lang::msg('btnedit', true); ?> ', function() { try { theUser = UserForm.findField(0).getGroupValue(); } catch(e) { Ext.Msg.alert( 'Error', '<?php echo ext_Lang::err('miscselitems', true); ?> ' ); return; } dialog_panel.load({url: '<?php echo basename($GLOBALS['script_name']); ?> ', params: { option: 'com_extplorer', action: 'admin', action2: 'edituser', nuser: theUser } }); }); UserForm.addButton('<?php echo ext_Lang::msg('btnremove', true); ?> ', function() { try { theUser = UserForm.findField(0).getGroupValue(); } catch(e) { Ext.Msg.alert( 'Error', '<?php echo ext_Lang::err('miscselitems', true); ?> ' ); return; } Ext.Msg.confirm( '', String.format( '<?php echo ext_Lang::err('miscdeluser', true); ?> ', theUser ), function( btn ) { if( btn != 'yes') return; statusBarMessage( 'Please wait...', true ); UserForm.submit({ success: function(form, action) { statusBarMessage( action.result.message, false, true ); }, failure: function(form, action) { if( !action.result ) return; Ext.MessageBox.alert('Error!', action.result.error); statusBarMessage( action.result.error, false, true ); }, scope: UserForm, // add some vars to the request, similar to hidden fields params: { option: 'com_extplorer', action: 'admin', action2: 'rmuser', user: theUser } }); }); }); UserForm.render('userList'); Ext.get('userList').createChild({ tag:'center', cn: { tag:'span', html: '<?php echo ext_Lang::msg('miscuseritems', true); ?> ', style:'margin-bottom:5px;' } }); <?php } ?> var tabs = new Ext.TabPanel("adminForm"); tabs.addTab("userList", '<?php echo ext_Lang::msg('actusers', true); ?> '); tabs.addTab("passForm", '<?php echo ext_Lang::msg('actchpwd', true); ?> '); <?php if ($_SESSION['s_user'] == 'admin' && $_SESSION['s_pass'] == extEncodePassword('admin')) { echo 'tabs.activate("passForm");'; } else { echo 'tabs.activate("userList");'; } ?> </script> <?php }
function execAction($dir, $item) { // change permissions if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('chmod', false, $GLOBALS["error_msg"]["accessfunc"]); } if (!empty($GLOBALS['__POST']["selitems"])) { $cnt = count($GLOBALS['__POST']["selitems"]); } else { $GLOBALS['__POST']["selitems"][] = $item; $cnt = 1; } if (!empty($GLOBALS['__POST']['do_recurse'])) { $do_recurse = true; } else { $do_recurse = false; } // Execute if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") { $bin = ''; for ($i = 0; $i < 3; $i++) { for ($j = 0; $j < 3; $j++) { $tmp = "r_" . $i . $j; if (!empty($GLOBALS['__POST'][$tmp])) { $bin .= '1'; } else { $bin .= '0'; } } } if ($bin == '0') { // Changing permissions to "none" is not allowed ext_Result::sendResult('chmod', false, $item . ": " . ext_Lang::err('chmod_none_not_allowed')); } $old_bin = $bin; for ($i = 0; $i < $cnt; ++$i) { if (ext_isFTPMode()) { $mode = decoct(bindec($bin)); } else { $mode = bindec($bin); } $item = $GLOBALS['__POST']["selitems"][$i]; if (ext_isFTPMode()) { $abs_item = get_item_info($dir, $item); } else { $abs_item = get_abs_item($dir, $item); } if (!$GLOBALS['ext_File']->file_exists($abs_item)) { ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]); } if (!get_show_item($dir, $item)) { ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]); } if ($do_recurse) { $ok = $GLOBALS['ext_File']->chmodRecursive($abs_item, $mode); } else { if (get_is_dir($abs_item)) { // when we chmod a directory we must care for the permissions // to prevent that the directory becomes not readable (when the "execute bits" are removed) $bin = substr_replace($bin, '1', 2, 1); // set 1st x bit to 1 $bin = substr_replace($bin, '1', 5, 1); // set 2nd x bit to 1 $bin = substr_replace($bin, '1', 8, 1); // set 3rd x bit to 1 if (ext_isFTPMode()) { $mode = decoct(bindec($bin)); } else { $mode = bindec($bin); } } //ext_Result::sendResult('chmod', false, $GLOBALS['FTPCONNECTION']->pwd()); $ok = @$GLOBALS['ext_File']->chmod($abs_item, $mode); } $bin = $old_bin; } if ($ok === false || PEAR::isError($ok)) { $msg = $item . ": " . $GLOBALS["error_msg"]["permchange"]; $msg .= PEAR::isError($ok) ? ' [' . $ok->getMessage() . ']' : ''; ext_Result::sendResult('chmod', false, $msg); } ext_Result::sendResult('chmod', true, ext_Lang::msg('permchange')); return; } if (ext_isFTPMode()) { $abs_item = get_item_info($dir, $GLOBALS['__POST']["selitems"][0]); } else { $abs_item = get_abs_item($dir, $GLOBALS['__POST']["selitems"][0]); $abs_item = utf8_decode($abs_item); } $mode = parse_file_perms(get_file_perms($abs_item)); if ($mode === false) { ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["permread"]); } $pos = "rwx"; $text = ""; for ($i = 0; $i < $cnt; ++$i) { $s_item = get_rel_item($dir, $GLOBALS['__POST']["selitems"][$i]); if (strlen($s_item) > 50) { $s_item = "..." . substr($s_item, -47); } $text .= $s_item . ($i + 1 < $cnt ? ', ' : ''); } ?> <div style="width:auto;"> <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div> <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"> <h3 style="margin-bottom:5px;"><?php echo ext_Lang::msg('actperms'); ?> </h3> <?php echo $text; ?> <div id="adminForm"> </div> </div></div></div> <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div> </div> <script type="text/javascript"> var form = new Ext.form.Form({ labelWidth: 125, // label settings here cascade unless overridden url:'<?php echo basename($GLOBALS['script_name']); ?> ' }); <?php // print table with current perms & checkboxes to change for ($i = 0; $i < 3; ++$i) { ?> form.column( {width:70, style:'margin-left:10px', clear:true} ); form.fieldset( {legend:'<?php echo ext_Lang::msg(array('miscchmod' => $i), true); ?> ', hideLabels:true}, <?php for ($j = 0; $j < 3; ++$j) { ?> new Ext.form.Checkbox({ boxLabel:'<?php echo $pos[$j]; ?> ', <?php if ($mode[3 * $i + $j] != "-") { echo 'checked:true,'; } ?> name:'<?php echo "r_" . $i . $j; ?> ' }) <?php if ($j < 2) { echo ','; } } ?> ); form.end(); <?php } ?> form.column( {width:400, style:'margin-left:10px', clear:true} ); form.add(new Ext.form.Checkbox({ fieldLabel:'<?php echo ext_Lang::msg('recurse_subdirs', true); ?> ', name:'do_recurse' })); form.end(); form.addButton('<?php echo ext_Lang::msg('btnsave', true); ?> ', function() { statusBarMessage( '<?php echo ext_Lang::msg('permissions_processing', true); ?> ', true ); form.submit({ //reset: true, reset: false, success: function(form, action) { statusBarMessage( action.result.message, false, true ); datastore.reload(); dialog.hide(); dialog.destroy(); }, failure: function(form, action) { statusBarMessage( action.result.error, false, false ); Ext.MessageBox.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); }, scope: form, // add some vars to the request, similar to hidden fields params: {option: 'com_extplorer', action: 'chmod', dir: '<?php echo stripslashes($GLOBALS['__POST']["dir"]); ?> ', 'selitems[]': ['<?php echo implode("','", $GLOBALS['__POST']["selitems"]); ?> '], confirm: 'true'} }); }); form.addButton('<?php echo ext_Lang::msg('btncancel', true); ?> ', function() { dialog.hide();dialog.destroy(); } ); form.render('adminForm'); </script> <?php }
function search_items($dir) { // search for item if (isset($GLOBALS['__POST']["searchitem"])) { $searchitem = stripslashes($GLOBALS['__POST']["searchitem"]); $subdir = !empty($GLOBALS['__POST']["subdir"]); $list = make_list($dir, $searchitem, $subdir); } else { $searchitem = NULL; $subdir = true; } if (!empty($searchitem)) { $msg = $GLOBALS["messages"]["actsearchresults"]; $msg .= ": (/" . get_rel_item($dir, $searchitem) . ")"; } else { $msg = $GLOBALS["messages"]["searchlink"]; } // Search Box $response = ' <div> <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div> <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"> <h3 style="margin-bottom:5px;">' . $msg . '</h3> <div id="adminForm"> </div> </div></div></div> <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div> </div> <script type="text/javascript"> var form = new Ext.form.Form({ labelWidth: 125, // label settings here cascade unless overridden url:\'' . basename($GLOBALS['script_name']) . '\' }); form.add( new Ext.form.TextField({ fieldLabel: \'' . ext_Lang::msg('nameheader', true) . '\', name: \'searchitem\', width:175, allowBlank:false }), new Ext.form.Checkbox({ fieldLabel: \'' . ext_Lang::msg('miscsubdirs', true) . '?\', name: \'subdir\', checked: true }) ); form.addButton({ text: "' . ext_Lang::msg('btnsearch', true) . '", type: "submit" }, function() { form.submit({ waitMsg: \'' . ext_Lang::msg('search_processing', true) . '\', //reset: true, reset: false, success: function(form, action) { dialog_panel.setContent( action.result.message, true ); }, failure: function(form, action) {Ext.MessageBox.alert(\'' . ext_Lang::err('error') . '!\', action.result.error);}, scope: form, // add some vars to the request, similar to hidden fields params: { option: \'com_extplorer\', action: \'search\', dir: \'' . $GLOBALS['__POST']["dir"] . '\' } }); }); form.addButton("' . ext_Lang::msg('btncancel', true) . '", function() { dialog.hide();dialog.destroy(); } ); form.render("adminForm"); </script>'; // Results if ($searchitem != NULL) { $response .= "<table width=\"95%\"><tr><td colspan=\"2\"><hr></td></tr>\n"; if (count($list) > 0) { // table header $response .= "<tr>\n<td width=\"42%\" class=\"header\"><b>" . $GLOBALS["messages"]["nameheader"]; $response .= "</b></td>\n<td width=\"58%\" class=\"header\"><b>" . $GLOBALS["messages"]["pathheader"]; $response .= "</b></td></tr>\n<tr><td colspan=\"2\"><hr></td></tr>\n"; // make & print table of found items $response .= get_result_table($list); $response .= "<tr><td colspan=\"2\"><hr></td></tr>\n<tr><td class=\"header\">" . count($list) . " "; $response .= $GLOBALS["messages"]["miscitems"] . ".</td><td class=\"header\"></td></tr>\n"; } else { $response .= "<tr><td>" . $GLOBALS["messages"]["miscnoresult"] . "</td></tr>"; } $response .= "<tr><td colspan=\"2\"><hr></td></tr></table>\n"; } if (empty($searchitem)) { echo $response; } else { while (@ob_end_clean()) { } ext_Result::sendResult('search', true, $response); } }
statusBar.setStatus({ text: '<?php echo ext_Lang::msg('success', true); ?> : ' + msg, iconCls: 'success', clear: true }); Ext.msgBoxSlider.msg('<?php echo ext_Lang::msg('success', true); ?> ', msg ); } else if( success != null ) { statusBar.setStatus({ text: '<?php echo ext_Lang::err('error', true); ?> : ' + msg, iconCls: 'error', clear: true }); } } function selectFile( dir, file ) { chDir( dir ); var conn = datastore.proxy.getConnection(); if( conn.isLoading() ) {
function savefile($file_name) { // save edited file if (get_magic_quotes_gpc()) { $code = stripslashes($GLOBALS['__POST']["code"]); } else { $code = $GLOBALS['__POST']["code"]; } $langs = $GLOBALS["language"]; if ($langs == "japanese") { $_encoding = $GLOBALS['__POST']["file_encoding"]; if ($_encoding != "UTF-8") { $code = mb_convert_encoding($code, $_encoding, "UTF-8"); } } $res = $GLOBALS['ext_File']->file_put_contents($file_name, $code); if ($res == false || PEAR::isError($res)) { $err = basename($file_name) . ": " . ext_Lang::err('savefile'); if (PEAR::isError($res)) { $err .= $res->getMessage(); } ext_Result::sendResult('edit', false, $err); } }
function execAction($dir) { if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('archive', false, $GLOBALS["error_msg"]["accessfunc"]); } if (!$GLOBALS["zip"] && !$GLOBALS["tgz"]) { ext_Result::sendResult('archive', false, $GLOBALS["error_msg"]["miscnofunc"]); } $allowed_types = array('zip', 'tgz', 'tbz', 'tar'); // If we have something to archive, let's do it now if (extGetParam($_POST, 'confirm') == 'true') { $saveToDir = utf8_decode($GLOBALS['__POST']['saveToDir']); if (!file_exists(get_abs_dir($saveToDir))) { ext_Result::sendResult('archive', false, ext_Lang::err('archive_dir_notexists')); } if (!is_writable(get_abs_dir($saveToDir))) { ext_Result::sendResult('archive', false, ext_Lang::err('archive_dir_unwritable')); } require_once _EXT_PATH . '/libraries/Archive/archive.php'; if (!in_array(strtolower($GLOBALS['__POST']["type"]), $allowed_types)) { ext_Result::sendResult('archive', false, ext_Lang::err('extract_unknowntype') . ': ' . htmlspecialchars($GLOBALS['__POST']["type"])); } // This controls how many files are processed per Step (it's split up into steps to prevent time-outs) $files_per_step = 2000; $cnt = count($GLOBALS['__POST']["selitems"]); $abs_dir = get_abs_dir($dir); $name = basename(stripslashes($GLOBALS['__POST']["name"])); if ($name == "") { ext_Result::sendResult('archive', false, $GLOBALS["error_msg"]["miscnoname"]); } $startfrom = extGetParam($_REQUEST, 'startfrom', 0); $dir_contents_cache_name = 'ext_' . md5(implode(null, $GLOBALS['__POST']["selitems"])); $dir_contents_cache_file = _EXT_FTPTMP_PATH . '/' . $dir_contents_cache_name . '.txt'; $archive_name = get_abs_item($saveToDir, $name); $fileinfo = pathinfo($archive_name); if (empty($fileinfo['extension'])) { $archive_name .= "." . $GLOBALS['__POST']["type"]; $fileinfo['extension'] = $GLOBALS['__POST']["type"]; foreach ($allowed_types as $ext) { if ($GLOBALS['__POST']["type"] == $ext && @$fileinfo['extension'] != $ext) { $archive_name .= "." . $ext; } } } if ($startfrom == 0) { for ($i = 0; $i < $cnt; $i++) { $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]); if ($selitem == 'ext_root') { $selitem = ''; } if (is_dir(utf8_decode($abs_dir . "/" . $selitem))) { $items = extReadDirectory(utf8_decode($abs_dir . "/" . $selitem), '.', true, true); foreach ($items as $item) { if (is_dir($item) || !is_readable($item) || $item == $archive_name) { continue; } $v_list[] = str_replace('\\', '/', $item); } } else { $v_list[] = utf8_decode(str_replace('\\', '/', $abs_dir . "/" . $selitem)); } } if (count($v_list) > $files_per_step) { if (file_put_contents($dir_contents_cache_file, implode("\n", $v_list)) == false) { ext_Result::sendResult('archive', false, 'Failed to create a temporary list of the directory contents'); } } } else { $file_list_string = file_get_contents($dir_contents_cache_file); if (empty($file_list_string)) { ext_Result::sendResult('archive', false, 'Failed to retrieve the temporary list of the directory contents'); } $v_list = explode("\n", $file_list_string); } $cnt_filelist = count($v_list); // Now we go to the right range of files and "slice" the array $v_list = array_slice($v_list, $startfrom, $files_per_step - 1); $remove_path = $GLOBALS["home_dir"]; if ($dir) { $remove_path .= $dir; } $debug = 'Starting from: ' . $startfrom . "\n"; $debug .= 'Files to process: ' . $cnt_filelist . "\n"; $debug .= implode("\n", $v_list); //file_put_contents( 'log.txt', $debug, FILE_APPEND ); // Do some setup stuff ini_set('memory_limit', '128M'); @set_time_limit(0); error_reporting(E_ERROR | E_PARSE); $result = extArchive::create($archive_name, $v_list, $GLOBALS['__POST']["type"], '', $remove_path); if (PEAR::isError($result)) { ext_Result::sendResult('archive', false, $name . ': ' . ext_Lang::err('archive_creation_failed') . ' (' . $result->getMessage() . $archive_name . ')'); } $json = new ext_Json(); if ($cnt_filelist > $startfrom + $files_per_step) { $response = array('startfrom' => $startfrom + $files_per_step, 'totalitems' => $cnt_filelist, 'success' => true, 'action' => 'archive', 'message' => sprintf(ext_Lang::msg('processed_x_files'), $startfrom + $files_per_step, $cnt_filelist)); } else { @unlink($dir_contents_cache_file); if ($GLOBALS['__POST']["type"] == 'tgz' || $GLOBALS['__POST']["type"] == 'tbz') { chmod($archive_name, 0644); } $response = array('action' => 'archive', 'success' => true, 'message' => ext_Lang::msg('archive_created'), 'newlocation' => make_link('download', $dir, basename($archive_name))); } echo $json->encode($response); ext_exit(); } ?> <div style="width:auto;"> <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div> <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"> <h3 style="margin-bottom:5px;"><?php echo $GLOBALS["messages"]["actarchive"]; ?> </h3> <div id="adminForm"></div> </div></div></div> <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div> </div> <script type="text/javascript"> var comprTypes = new Ext.data.SimpleStore({ fields: ['type', 'typename'], data : [ ['zip', 'Zip (<?php echo ext_Lang::msg('normal_compression', true); ?> )'], ['tgz', 'Tar/Gz (<?php echo ext_Lang::msg('good_compression', true); ?> )'], <?php if (extension_loaded("bz2")) { echo "['tbz', 'Tar/Bzip2 (" . ext_Lang::msg('best_compression', true) . ")'],"; } ?> ['tar', 'Tar (<?php echo ext_Lang::msg('no_compression', true); ?> )'] ] }); var form = new Ext.form.Form({ labelWidth: 125, // label settings here cascade unless overridden url:'<?php echo basename($GLOBALS['script_name']); ?> ' }); var combo = new Ext.form.ComboBox({ fieldLabel: '<?php echo ext_Lang::msg('typeheader', true); ?> ', store: comprTypes, displayField:'typename', valueField: 'type', name: 'type', value: 'zip', triggerAction: 'all', hiddenName: 'type', disableKeyFilter: true, editable: false, mode: 'local', allowBlank: false, selectOnFocus:true, width: 200 }); form.add( new Ext.form.TextField({ fieldLabel: '<?php echo ext_Lang::msg('archive_name', true); ?> ', name: 'name', width: 200 }), combo, new Ext.form.TextField({ fieldLabel: '<?php echo ext_Lang::msg('archive_saveToDir', true); ?> ', name: 'saveToDir', value: '<?php echo str_replace("'", "\\'", $dir); ?> ', width: 200 }), new Ext.form.Checkbox({ fieldLabel: '<?php echo ext_Lang::msg('downlink', true); ?> ?', name: 'download', checked: true }) ); combo.on('select', function(o, record ) { var nameField = form.findField('name').getValue(); if( nameField.indexOf( '.' ) > 0 ) { form.findField('name').setValue( nameField.substring( 0, nameField.indexOf('.')+1 ) + record.get('type') ); } else { form.findField('name').setValue( nameField + '.'+ record.get('type')); } }); form.addButton({text: '<?php echo ext_Lang::msg('btncreate', true); ?> ', type: 'submit' }, function() { formSubmit(0) }); form.addButton('<?php echo ext_Lang::msg('btncancel', true); ?> ', function() { dialog.hide();dialog.destroy(); } ); form.render('adminForm'); function formSubmit( startfrom, msg ) { if( startfrom == 0 ) { Ext.MessageBox.show({ title: 'Please wait', msg: msg ? msg : '<?php echo ext_Lang::msg('creating_archive', true); ?> ', progressText: 'Initializing...', width:300, progress:true, closable:false, }); } form.submit({ reset: false, success: function(form, action) { if( !action.result ) return; if( action.result.startfrom > 0 ) { formSubmit( action.result.startfrom, action.result.message ); i = action.result.startfrom/action.result.totalitems; Ext.MessageBox.updateProgress(i, action.result.startfrom + " of "+action.result.totalitems + " (" + Math.round(100*i)+'% completed)'); return } else { if( form.findField('download').getValue() ) { datastore.reload(); location.href = action.result.newlocation; dialog.hide(); dialog.destroy(); } else { Ext.MessageBox.alert('<?php echo ext_Lang::msg('success', true); ?> !', action.result.message); datastore.reload(); dialog.hide(); dialog.destroy(); } return; } }, failure: function(form, action) { if( action.result ) { Ext.MessageBox.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); } }, scope: form, // add some vars to the request, similar to hidden fields params: {option: 'com_extplorer', action: 'archive', dir: '<?php echo stripslashes($GLOBALS['__POST']["dir"]); ?> ', 'selitems[]': [ '<?php echo implode("','", $GLOBALS['__POST']["selitems"]); ?> ' ], startfrom: startfrom, confirm: 'true'} }); } </script> <?php }
die('Restricted access'); } ?> <script type="text/javascript"> //<!-- function check_pwd() { if(PassForm.findField('newpwd1').getValue() != PassForm.findField('newpwd2').getValue() ) { alert("<?php echo ext_Lang::msg('miscnopassmatch', true); ?> "); return false; } if(PassForm.findField('oldpwd').getValue() ==PassForm.findField('newpwd1').getValue()) { alert("<?php echo ext_Lang::err('miscnopassdiff', true); ?> "); return false; } return true; } // Edit / Delete function Edit() { document.userform.action2.value = "edituser"; document.userform.submit(); }
function execAction($dir) { if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('upload', false, ext_Lang::err('accessfunc')); } // Execute if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") { if (isset($GLOBALS['__FILES']['Filedata'])) { // Re-Map the flash-uploaded file with the name "Filedata" to the "userfile" array $GLOBALS['__FILES']['userfile'] = array('name' => array($GLOBALS['__FILES']['Filedata']['name']), 'tmp_name' => array($GLOBALS['__FILES']['Filedata']['tmp_name']), 'size' => array($GLOBALS['__FILES']['Filedata']['size']), 'type' => array($GLOBALS['__FILES']['Filedata']['type']), 'error' => array($GLOBALS['__FILES']['Filedata']['error'])); } $cnt = count($GLOBALS['__FILES']['userfile']['name']); $err = false; $err_available = isset($GLOBALS['__FILES']['userfile']['error']); // upload files & check for errors for ($i = 0; $i < $cnt; $i++) { $errors[$i] = NULL; $tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i]; $items[$i] = stripslashes($GLOBALS['__FILES']['userfile']['name'][$i]); if ($err_available) { $up_err = $GLOBALS['__FILES']['userfile']['error'][$i]; } else { $up_err = file_exists($tmp) ? 0 : 4; } $abs = get_abs_item($dir, $items[$i]); if ($items[$i] == "" || $up_err == 4) { continue; } if ($up_err == 1 || $up_err == 2) { $errors[$i] = ext_lang::err('miscfilesize'); $err = true; continue; } if ($up_err == 3) { $errors[$i] = ext_lang::err('miscfilepart'); $err = true; continue; } if (!@is_uploaded_file($tmp)) { $errors[$i] = ext_lang::err('uploadfile'); $err = true; continue; } if (@file_exists($abs) && empty($_REQUEST['overwrite_files'])) { $errors[$i] = ext_lang::err('itemdoesexist'); $err = true; continue; } // Upload $ok = @$GLOBALS['ext_File']->move_uploaded_file($tmp, $abs); if ($ok === false || PEAR::isError($ok)) { $errors[$i] = ext_lang::err('uploadfile'); if (PEAR::isError($ok)) { $errors[$i] .= ' [' . $ok->getMessage() . ']'; } $err = true; continue; } else { if (!ext_isFTPMode()) { @$GLOBALS['ext_File']->chmod($abs, 0644); } } } if ($err) { // there were errors $err_msg = ""; for ($i = 0; $i < $cnt; $i++) { if ($errors[$i] == NULL) { continue; } $err_msg .= $items[$i] . " : " . $errors[$i] . "\n"; } ext_Result::sendResult('upload', false, $err_msg); } ext_Result::sendResult('upload', true, ext_Lang::msg('upload_completed')); return; } ?> { "xtype": "tabpanel", "stateId": "upload_tabpanel", "activeTab": "uploadform", "dialogtitle": "<?php echo ext_Lang::msg('actupload'); ?> ", "stateful": "true", "stateEvents": ["tabchange"], "getState": function() { return { activeTab:this.items.indexOf(this.getActiveTab()) }; }, "listeners": { "resize": { "fn": function(panel) { panel.items.each( function(item) { item.setHeight(500);return true } ); } } }, "items": [ { "xtype": "swfuploadpanel", "title": "<?php echo Ext_Lang::msg('flashupload'); ?> ", "height": "300", "id": "swfuploader", viewConfig: { forceFit: true }, "listeners": { "allUploadsComplete": { "fn": function(panel) { datastore.reload(); panel.destroy(); Ext.getCmp("dialog").destroy(); statusBarMessage('<?php echo ext_Lang::msg('upload_completed', true); ?> ', false ); } } }, // Uploader Params "upload_url": "<?php echo _EXT_URL . '/uploadhandler.php'; ?> ", "post_params": { "<?php echo session_name(); ?> ": "<?php echo session_id(); ?> ", "<?php echo get_cfg_var('session.name'); ?> ": "<?php echo session_id(); ?> ", "session_name": "<?php echo session_name(); ?> ", "user_agent": "<?php echo addslashes($_SERVER['HTTP_USER_AGENT']); ?> ", "option": "com_extplorer", "action": "upload", "dir": datastore.directory, "requestType": "xmlhttprequest", "confirm": "true" }, <?php if ($_SERVER['SERVER_NAME'] == 'localhost') { echo '"debug": "true",'; } ?> "flash_url": "<?php echo _EXT_URL; ?> /scripts/extjs3-ext/ux.swfupload/swfupload.swf", "prevent_swf_caching": "false", "file_size_limit": "<?php echo get_max_file_size(); ?> B", // Custom Params "single_file_select": false, // Set to true if you only want to select one file from the FileDialog. "confirm_delete": false, // This will prompt for removing files from queue. "remove_completed": false // Remove file from grid after uploaded. }, { "xtype": "form", "autoScroll": "true", "autoHeight": "true", "id": "uploadform", "fileUpload": true, "labelWidth": 125, "url":"<?php echo basename($GLOBALS['script_name']); ?> ", "title": "<?php echo ext_Lang::msg('standardupload'); ?> ", "tooltip": "<?php echo ext_Lang::msg('max_file_size') . ' = <strong>' . get_max_file_size() / 1024 / 1024 . ' MB<\\/strong><br \\/>' . ext_Lang::msg('max_post_size') . ' = <strong>' . get_max_upload_limit() / 1024 / 1024 . ' MB<\\/strong><br \\/>'; ?> ", "frame": true, "items": [ { "xtype": "displayfield", "value": "<?php echo ext_Lang::msg('max_file_size') . ' = <strong>' . get_max_file_size() / 1024 / 1024 . ' MB<\\/strong><br \\/>' . ext_Lang::msg('max_post_size') . ' = <strong>' . get_max_upload_limit() / 1024 / 1024 . ' MB<\\/strong><br \\/>'; ?> " }, <?php for ($i = 0; $i < 7; $i++) { echo '{ "xtype": "fileuploadfield", "fieldLabel": "' . ext_Lang::msg('file', true) . ' ' . ($i + 1) . '", "id": "userfile' . $i . '", "name": "userfile[' . $i . ']", "width":275, "buttonOnly": false },'; } ?> { "xtype": "checkbox", "fieldLabel": "<?php echo ext_Lang::msg('overwrite_files', true); ?> ", "name": "overwrite_files", "checked": true }], "buttons": [{ "text": "<?php echo ext_Lang::msg('btnsave', true); ?> ", "handler": function() { statusBarMessage( '<?php echo ext_Lang::msg('upload_processing', true); ?> ', true ); form = Ext.getCmp("uploadform").getForm(); form.submit({ //reset: true, reset: false, success: function(form, action) { datastore.reload(); statusBarMessage( action.result.message, false, true ); Ext.getCmp("dialog").destroy(); }, failure: function(form, action) { if( !action.result ) return; Ext.MessageBox.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); statusBarMessage( action.result.error, false, false ); }, "scope": form, // add some vars to the request, similar to hidden fields "params": { "option": "com_extplorer", "action": "upload", "dir": datastore.directory, "requestType": "xmlhttprequest", "confirm": "true" } }); } }, { "text": "<?php echo ext_Lang::msg('btncancel', true); ?> ", "handler": function() { Ext.getCmp("dialog").destroy(); } }] }, { "xtype": "form", "id": "transferform", "url":"<?php echo basename($GLOBALS['script_name']); ?> ", "hidden": "true", "title": "<?php echo ext_Lang::msg('acttransfer'); ?> ", "autoHeight": "true", "labelWidth": 225, "frame": true, "items": [ <?php for ($i = 0; $i < 7; $i++) { echo '{ "xtype": "textfield", "fieldLabel": "' . ext_Lang::msg('url_to_file', true) . '", "name": "userfile[' . $i . ']", "width":275 },'; } ?> { "xtype": "checkbox", "fieldLabel": "<?php echo ext_Lang::msg('overwrite_files', true); ?> ", "name": "overwrite_files", "checked": true } ], "buttons": [{ "text": "<?php echo ext_Lang::msg('btnsave', true); ?> ", "handler": function() { statusBarMessage( '<?php echo ext_Lang::msg('transfer_processing', true); ?> ', true ); transfer = Ext.getCmp("transferform").getForm(); transfer.submit({ //reset: true, reset: false, success: function(form, action) { datastore.reload(); statusBarMessage( action.result.message, false, true ); Ext.getCmp("dialog").destroy(); }, failure: function(form, action) { if( !action.result ) return; Ext.MessageBox.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); statusBarMessage( action.result.error, false, false ); }, scope: transfer, // add some vars to the request, similar to hidden fields params: { "option": "com_extplorer", "action": "transfer", "dir": datastore.directory, "confirm": 'true' } }); } },{ "text": "<?php echo ext_Lang::msg('btncancel', true); ?> ", "handler": function() { Ext.getCmp("dialog").destroy(); } }] }] } <?php }
function execAction($dir, $item) { global $mosConfig_absolute_path; if (!ext_isArchive($item)) { ext_Result::sendResult('archive', false, ext_Lang::err('extract_noarchive')); } else { $archive_name = realpath(get_abs_item($dir, $item)); $file_info = pathinfo($archive_name); if (empty($dir)) { $extract_dir = realpath($GLOBALS['home_dir']); } else { $extract_dir = realpath($GLOBALS['home_dir'] . "/" . $dir); } $ext = $file_info["extension"]; switch ($ext) { case "zip": require_once _EXT_PATH . "/libraries/Zip.php"; $extract_dir = str_replace('\\', '/', $extract_dir); $zip = new Archive_Zip($archive_name); $res = $zip->extract(array('add_path' => $extract_dir)); if ($res == 0) { ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure') . ' (' . $zip->errorInfo(true) . ')'); } else { ext_Result::sendResult('extract', false, ext_Lang::msg('extract_success')); } break; case "gz": // a // a case "bz": // lot // lot case "bz2": // of // of case "bzip2": // fallthroughs, // fallthroughs, case "tbz": // don't // don't case "tar": // wonder require_once _EXT_PATH . "/libraries/Tar.php"; $archive = new Archive_Tar($archive_name); if ($archive->extract($extract_dir)) { ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success')); } else { ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure')); } break; default: ext_Result::sendResult('extract', false, ext_Lang::err('extract_unknowntype')); break; } /* require_once (_EXT_PATH . "/libraries/Archive/archive.php") ; $result = extArchive::extract( $archive_name, $extract_dir ) ; if( PEAR::isError( $result ) ) { ext_Result::sendResult( 'extract', false, ext_Lang::err( 'extract_failure' ) . ': ' . $result->getMessage() ) ; } */ ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success')); } }
function execAction() { $ftp_login = extGetParam($_POST, 'ftp_login_name', ''); $ftp_pass = extGetParam($_POST, 'ftp_login_pass', ''); global $dir, $mosConfig_live_site; if ($ftp_login != '' || $ftp_pass != '') { $ftp_host = extGetParam($_POST, 'ftp_hostname_port', 'localhost:21'); $url = @parse_url('ftp://' . $ftp_host); if (empty($url)) { ext_Result::sendResult('ftp_authentication', false, 'Unable to parse the specified Host Name. Please use a hostname in this format: hostname:21'); } $port = empty($url['port']) ? 21 : $url['port']; $ftp = new Net_FTP($url['host'], $port, 20); $res = $ftp->connect(); if (PEAR::isError($res)) { ext_Result::sendResult('ftp_authentication', false, $GLOBALS['messages']['ftp_connection_failed'] . ' (' . $url['host'] . ')'); } else { $res = $ftp->login($ftp_login, $ftp_pass); $ftp->disconnect(); if (PEAR::isError($res)) { ext_Result::sendResult('ftp_authentication', false, $GLOBALS['messages']['ftp_login_failed']); } $_SESSION['ftp_login'] = $ftp_login; $_SESSION['ftp_pass'] = $ftp_pass; $_SESSION['ftp_host'] = $ftp_host; $_SESSION['file_mode'] = 'ftp'; session_write_close(); ext_Result::sendResult('ftp_authentication', true, ext_Lang::msg('actlogin_success')); } } else { ?> { "xtype": "form", "id": "simpleform", "labelWidth": 125, "url":"<?php echo basename($GLOBALS['script_name']); ?> ", "dialogtitle": "<?php echo $GLOBALS["messages"]["ftp_header"]; ?> ", "title": "<?php echo $GLOBALS["messages"]["ftp_login_lbl"]; ?> ", "frame": true, "keys": { "key": Ext.EventObject.ENTER, "fn" : function(){ if (Ext.getCmp("simpleform").getForm().isValid()) { statusBarMessage( '<?php echo ext_Lang::msg('ftp_login_check', true); ?> ', true ); Ext.getCmp("simpleform").getForm().submit({ "reset": false, "success": function(form, action) { location.reload() }, "failure": function(form, action) { if( !action.result ) return; Ext.Msg.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); statusBarMessage( action.result.error, false, false ); }, "scope": Ext.getCmp("simpleform").getForm(), "params": { "option": "com_extplorer", "action": "ftp_authentication" } }); } else { return false; } } }, "items": [{ "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('ftp_login_name', true); ?> ", "name": "ftp_login_name", "width":175, "allowBlank":false },{ "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('ftp_login_pass', true); ?> ", "name": "ftp_login_pass", "inputType": "password", "width":175, "allowBlank":false },{ "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('ftp_hostname_port', true); ?> ", "name": "ftp_hostname_port", "value": "<?php echo extGetParam($_SESSION, 'ftp_host', 'localhost:21'); ?> ", "width":175, "allowBlank":false }], "buttons": [{ "text": "<?php echo ext_Lang::msg('btnlogin', true); ?> ", "type": "submit", "handler": function() { statusBarMessage( '<?php echo ext_Lang::msg('ftp_login_check', true); ?> ', true ); Ext.getCmp("simpleform").getForm().submit({ "reset": false, "success": function(form, action) { location.reload() }, "failure": function(form, action) { if( !action.result ) return; Ext.Msg.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); statusBarMessage( action.result.error, false, false ); }, "scope": Ext.getCmp("simpleform").getForm(), "params": { "option": "com_extplorer", "action": "ftp_authentication" } }); } },{ "text": "<?php echo ext_Lang::msg('btncancel', true); ?> ", "handler": function() { Ext.getCmp("dialog").destroy(); } }] } <?php } }
<?php /** ensure this file is being included by a parent file */ if (!defined('_JEXEC') && !defined('_VALID_MOS')) { die('Restricted access'); } ?> <script type="text/javascript"> //<!-- function check_pwd() { if(userform.findField('nuser').getValue()=="" || userform.findField('home_dir').getValue()=="") { Ext.Msg.alert('Status', "<?php echo ext_Lang::err('miscfieldmissed', true); ?> "); return false; } if(userform.findField('pass1').getValue() != userform.findField('pass2').getValue()) { Ext.Msg.alert('Status', "<?php echo ext_Lang::err('miscnopassmatch', true); ?> "); return false; } return true; } // --> </script>
function savefile($file_name) { // save edited file if (get_magic_quotes_gpc()) { $code = stripslashes($GLOBALS['__POST']["code"]); } else { $code = $GLOBALS['__POST']["code"]; } $res = $GLOBALS['ext_File']->file_put_contents($file_name, $code); if ($res == false || PEAR::isError($res)) { $err = basename($file_name) . ": " . ext_Lang::err('savefile'); if (PEAR::isError($res)) { $err .= $res->getMessage(); } ext_Result::sendResult('edit', false, $err); } }
function execAction($dir) { if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('archive', false, $GLOBALS["error_msg"]["accessfunc"]); } if (!$GLOBALS["zip"] && !$GLOBALS["tgz"]) { ext_Result::sendResult('archive', false, $GLOBALS["error_msg"]["miscnofunc"]); } $allowed_types = array('zip', 'tgz', 'tbz', 'tar'); // If we have something to archive, let's do it now if (extGetParam($_POST, 'confirm') == 'true') { $saveToDir = utf8_decode($GLOBALS['__POST']['saveToDir']); if (!file_exists(get_abs_dir($saveToDir))) { ext_Result::sendResult('archive', false, ext_Lang::err('archive_dir_notexists')); } if (!is_writable(get_abs_dir($saveToDir))) { ext_Result::sendResult('archive', false, ext_Lang::err('archive_dir_unwritable')); } require_once _EXT_PATH . '/libraries/Archive/archive.php'; if (!in_array(strtolower($GLOBALS['__POST']["type"]), $allowed_types)) { ext_Result::sendResult('archive', false, ext_Lang::err('extract_unknowntype') . ': ' . htmlspecialchars($GLOBALS['__POST']["type"])); } // This controls how many files are processed per Step (it's split up into steps to prevent time-outs) $files_per_step = 2000; $cnt = count($GLOBALS['__POST']["selitems"]); $abs_dir = get_abs_dir($dir); $name = basename(stripslashes($GLOBALS['__POST']["name"])); if ($name == "") { ext_Result::sendResult('archive', false, $GLOBALS["error_msg"]["miscnoname"]); } $startfrom = extGetParam($_REQUEST, 'startfrom', 0); $dir_contents_cache_name = 'ext_' . md5(implode(null, $GLOBALS['__POST']["selitems"])); $dir_contents_cache_file = _EXT_FTPTMP_PATH . '/' . $dir_contents_cache_name . '.txt'; $archive_name = get_abs_item($saveToDir, $name); $fileinfo = pathinfo($archive_name); if (empty($fileinfo['extension'])) { $archive_name .= "." . $GLOBALS['__POST']["type"]; $fileinfo['extension'] = $GLOBALS['__POST']["type"]; foreach ($allowed_types as $ext) { if ($GLOBALS['__POST']["type"] == $ext && @$fileinfo['extension'] != $ext) { $archive_name .= "." . $ext; } } } if ($startfrom == 0) { for ($i = 0; $i < $cnt; $i++) { $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]); if ($selitem == 'ext_root') { $selitem = ''; } if (is_dir(utf8_decode($abs_dir . "/" . $selitem))) { $items = extReadDirectory(utf8_decode($abs_dir . "/" . $selitem), '.', true, true); foreach ($items as $item) { if (is_dir($item) || !is_readable($item) || $item == $archive_name) { continue; } $v_list[] = str_replace('\\', '/', $item); } } else { $v_list[] = utf8_decode(str_replace('\\', '/', $abs_dir . "/" . $selitem)); } } if (count($v_list) > $files_per_step) { if (file_put_contents($dir_contents_cache_file, implode("\n", $v_list)) == false) { ext_Result::sendResult('archive', false, 'Failed to create a temporary list of the directory contents'); } } } else { $file_list_string = file_get_contents($dir_contents_cache_file); if (empty($file_list_string)) { ext_Result::sendResult('archive', false, 'Failed to retrieve the temporary list of the directory contents'); } $v_list = explode("\n", $file_list_string); } $cnt_filelist = count($v_list); // Now we go to the right range of files and "slice" the array $v_list = array_slice($v_list, $startfrom, $files_per_step - 1); $remove_path = $GLOBALS["home_dir"]; if ($dir) { $remove_path .= $dir; } $remove_path = str_replace('\\', '/', realpath($remove_path)) . '/'; $debug = 'Starting from: ' . $startfrom . "\n"; $debug .= 'Files to process: ' . $cnt_filelist . "\n"; $debug .= implode("\n", $v_list); //file_put_contents( 'log.txt', $debug, FILE_APPEND ); // Do some setup stuff ini_set('memory_limit', '128M'); @set_time_limit(0); //error_reporting( E_ERROR | E_PARSE ); $result = extArchive::create($archive_name, $v_list, $GLOBALS['__POST']["type"], '', $remove_path); if (PEAR::isError($result)) { ext_Result::sendResult('archive', false, $name . ': ' . ext_Lang::err('archive_creation_failed') . ' (' . $result->getMessage() . $archive_name . ')'); } $classname = class_exists('ext_Json') ? 'ext_Json' : 'Services_JSON'; $json = new $classname(); if ($cnt_filelist > $startfrom + $files_per_step) { $response = array('startfrom' => $startfrom + $files_per_step, 'totalitems' => $cnt_filelist, 'success' => true, 'action' => 'archive', 'message' => sprintf(ext_Lang::msg('processed_x_files'), $startfrom + $files_per_step, $cnt_filelist)); } else { @unlink($dir_contents_cache_file); if ($GLOBALS['__POST']["type"] == 'tgz' || $GLOBALS['__POST']["type"] == 'tbz') { chmod($archive_name, 0644); } $response = array('action' => 'archive', 'success' => true, 'message' => ext_Lang::msg('archive_created'), 'newlocation' => ext_make_link('download', $dir, basename($archive_name))); } echo $json->encode($response); ext_exit(); } $default_archive_type = 'zip'; ?> { "xtype": "form", "id": "simpleform", "height": "200", "width": "350", "labelWidth": 125, "url":"<?php echo basename($GLOBALS['script_name']); ?> ", "dialogtitle": "<?php echo $GLOBALS["messages"]["actarchive"]; ?> ", "frame": true, "items": [{ "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('archive_name', true); ?> ", "name": "name", "value": "<?php echo $GLOBALS['item'] . '.' . $default_archive_type; ?> ", "width": "200" }, { "xtype": "combo", "fieldLabel": "<?php echo ext_Lang::msg('typeheader', true); ?> ", "store": [ ['zip', 'Zip (<?php echo ext_Lang::msg('normal_compression', true); ?> )'], ['tgz', 'Tar/Gz (<?php echo ext_Lang::msg('good_compression', true); ?> )'], <?php if (extension_loaded("bz2")) { echo "['tbz', 'Tar/Bzip2 (" . ext_Lang::msg('best_compression', true) . ")'],"; } ?> ['tar', 'Tar (<?php echo ext_Lang::msg('no_compression', true); ?> )'] ], "displayField":"typename", "valueField": "type", "name": "type", "value": "<?php echo $default_archive_type; ?> ", "triggerAction": "all", "hiddenName": "type", "disableKeyFilter": "true", "editable": "false", "mode": "local", "allowBlank": "false", "selectOnFocus":"true", "width": "200", "listeners": { "select": { fn: function(o, record ) { form = Ext.getCmp("simpleform").getForm(); var nameField = form.findField("name").getValue(); if( nameField.indexOf( '.' ) > 0 ) { form.findField('name').setValue( nameField.substring( 0, nameField.indexOf('.')+1 ) + o.getValue() ); } else { form.findField('name').setValue( nameField + '.'+ o.getValue()); } } } } }, { "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('archive_saveToDir', true); ?> ", "name": "saveToDir", "value": "<?php echo str_replace("'", "\\'", $dir); ?> ", "width": "200" },{ "xtype": "checkbox", "fieldLabel": "<?php echo ext_Lang::msg('downlink', true); ?> ?", "name": "download", "checked": "true" } ], "buttons": [{ "text": "<?php echo ext_Lang::msg('btncreate', true); ?> ", "type": "submit", "handler": function() { Ext.ux.OnDemandLoad.load( "<?php echo $GLOBALS['script_name']; ?> ?option=com_extplorer&action=include_javascript&file=archive.js", function(options) { submitArchiveForm(0) } ); } },{ "text": "<?php echo ext_Lang::msg('btncancel', true); ?> ", "handler": function() { Ext.getCmp("dialog").destroy() } }] } <?php }
function onShowLoginForm() { ?> { xtype: "form", <?php if (!ext_isXHR()) { ?> renderTo: "adminForm", <?php } ?> id: "simpleform", labelWidth: 125, url:"<?php echo basename($GLOBALS['script_name']); ?> ", dialogtitle: "<?php echo ext_Lang::msg('ftp_header'); ?> ", title: "<?php echo ext_Lang::msg('ftp_login_lbl'); ?> ", frame: true, keys: { key: Ext.EventObject.ENTER, fn : function(){ if (Ext.getCmp("simpleform").getForm().isValid()) { Ext.get( 'statusBar').update( '<?php echo ext_Lang::msg('ftp_login_check', true); ?> ' ); Ext.getCmp("simpleform").getForm().submit({ reset: false, success: function(form, action) { location.reload() }, failure: function(form, action) { if( !action.result ) return; Ext.Msg.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); Ext.get( 'statusBar').update( action.result.error ); }, scope: Ext.getCmp("simpleform").getForm(), params: { option: "com_extplorer", action: "login", type: "ftp", file_mode: "ftp" } }); } else { return false; } } }, items: [{ xtype: "textfield", fieldLabel: "<?php echo ext_Lang::msg('ftp_login_name', true); ?> ", name: "username", width:175, allowBlank:false },{ xtype: "textfield", fieldLabel: "<?php echo ext_Lang::msg('ftp_login_pass', true); ?> ", name: "password", inputType: "password", width:175, allowBlank:false },{ xtype: "combo", fieldLabel: "<?php echo ext_Lang::msg('ftp_hostname_port', true); ?> ", hiddenName: "ftp_host", triggerAction: "all", value: "<?php echo extGetParam($_SESSION, 'ftp_host'); ?> ", store: ["<?php echo implode('","', $GLOBALS['ext_conf']['remote_hosts_allowed']); ?> "], width:175, editable: false, forceSelection: true, allowBlank:false }, { xtype: "displayfield", id: "statusBar" }], buttons: [{ text: "<?php echo ext_Lang::msg('btnlogin', true); ?> ", type: "submit", handler: function() { Ext.get( 'statusBar').update( '<?php echo ext_Lang::msg('ftp_login_check', true); ?> ' ); Ext.getCmp("simpleform").getForm().submit({ reset: false, success: function(form, action) { location.reload() }, failure: function(form, action) { if( !action.result ) return; Ext.Msg.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); Ext.get( 'statusBar').update( action.result.error ); }, scope: Ext.getCmp("simpleform").getForm(), params: { option: "com_extplorer", action: "login", type: "ftp", file_mode: "ftp" } }); } }, <?php if (!ext_isXHR()) { ?> { text: '<?php echo ext_Lang::msg('btnreset', true); ?> ', handler: function() { simple.getForm().reset(); } } <?php } else { ?> { text: "<?php echo ext_Lang::msg('btncancel', true); ?> ", handler: function() { Ext.getCmp("dialog").destroy(); } } <?php } ?> ] } <?php }
function execAction($dir, $item) { // change permissions if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('chmod', false, $GLOBALS["error_msg"]["accessfunc"]); } if (!empty($GLOBALS['__POST']["selitems"])) { $cnt = count($GLOBALS['__POST']["selitems"]); } else { $GLOBALS['__POST']["selitems"][] = $item; $cnt = 1; } if (!empty($GLOBALS['__POST']['do_recurse'])) { $do_recurse = true; } else { $do_recurse = false; } // Execute if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") { $bin = ''; for ($i = 0; $i < 3; $i++) { for ($j = 0; $j < 3; $j++) { $tmp = "r_" . $i . $j; if (!empty($GLOBALS['__POST'][$tmp])) { $bin .= '1'; } else { $bin .= '0'; } } } if ($bin == '0') { // Changing permissions to "none" is not allowed ext_Result::sendResult('chmod', false, $item . ": " . ext_Lang::err('chmod_none_not_allowed')); } $old_bin = $bin; for ($i = 0; $i < $cnt; ++$i) { if (ext_isFTPMode()) { $mode = decoct(bindec($bin)); } else { $mode = bindec($bin); } $item = $GLOBALS['__POST']["selitems"][$i]; if (ext_isFTPMode()) { $abs_item = get_item_info($dir, $item); } else { $abs_item = get_abs_item($dir, $item); } if (!$GLOBALS['ext_File']->file_exists($abs_item)) { ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]); } if (!get_show_item($dir, $item)) { ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]); } if ($do_recurse) { $ok = $GLOBALS['ext_File']->chmodRecursive($abs_item, $mode); } else { if (get_is_dir($abs_item)) { // when we chmod a directory we must care for the permissions // to prevent that the directory becomes not readable (when the "execute bits" are removed) $bin = substr_replace($bin, '1', 2, 1); // set 1st x bit to 1 $bin = substr_replace($bin, '1', 5, 1); // set 2nd x bit to 1 $bin = substr_replace($bin, '1', 8, 1); // set 3rd x bit to 1 if (ext_isFTPMode()) { $mode = decoct(bindec($bin)); } else { $mode = bindec($bin); } } //ext_Result::sendResult('chmod', false, $GLOBALS['FTPCONNECTION']->pwd()); $ok = @$GLOBALS['ext_File']->chmod($abs_item, $mode); } $bin = $old_bin; } if ($ok === false || PEAR::isError($ok)) { $msg = $item . ": " . $GLOBALS["error_msg"]["permchange"]; $msg .= PEAR::isError($ok) ? ' [' . $ok->getMessage() . ']' : ''; ext_Result::sendResult('chmod', false, $msg); } ext_Result::sendResult('chmod', true, ext_Lang::msg('permchange')); return; } if (ext_isFTPMode()) { $abs_item = get_item_info($dir, $GLOBALS['__POST']["selitems"][0]); } else { $abs_item = get_abs_item($dir, $GLOBALS['__POST']["selitems"][0]); $abs_item = utf8_decode($abs_item); } $mode = parse_file_perms(get_file_perms($abs_item)); if ($mode === false) { ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["permread"]); } $pos = "rwx"; $text = ""; for ($i = 0; $i < $cnt; ++$i) { $s_item = get_rel_item($dir, $GLOBALS['__POST']["selitems"][$i]); if (strlen($s_item) > 50) { $s_item = "..." . substr($s_item, -47); } $text .= $s_item . ($i + 1 < $cnt ? ', ' : ''); } ?> { "xtype": "form", "id": "simpleform", "width": "300", "labelWidth": 125, "url":"<?php echo basename($GLOBALS['script_name']); ?> ", "dialogtitle": "<?php echo ext_Lang::msg('actperms'); ?> ", "title" : "<?php echo $text; ?> ", "frame": true, "items": [{ "layout": "column", "items": [{ <?php // print table with current perms & checkboxes to change for ($i = 0; $i < 3; ++$i) { ?> "width":80, "title":"<?php echo ext_Lang::msg(array('miscchmod' => $i), true); ?> ", "items": [{ <?php for ($j = 0; $j < 3; ++$j) { ?> "xtype": "checkbox", "boxLabel":"<?php echo $pos[$j]; ?> ", <?php if ($mode[3 * $i + $j] != "-") { echo '"checked":true,'; } ?> "name":"<?php echo "r_" . $i . $j; ?> " } <?php if ($j < 2) { echo ',{'; } } ?> ] } <?php if ($i < 2) { echo ',{'; } } ?> ,{ "width":400, "style":"margin-left:10px", "clear":true, "html": " " }] },{ "xtype": "checkbox", "fieldLabel":"<?php echo ext_Lang::msg('recurse_subdirs', true); ?> ", "name":"do_recurse" }], "buttons": [{ "text": "<?php echo ext_Lang::msg('btnsave', true); ?> ", "handler": function() { statusBarMessage( '<?php echo ext_Lang::msg('permissions_processing', true); ?> ', true ); form = Ext.getCmp("simpleform").getForm(); form.submit({ //reset: true, reset: false, success: function(form, action) { statusBarMessage( action.result.message, false, true ); datastore.reload(); Ext.getCmp("dialog").destroy(); }, failure: function(form, action) { statusBarMessage( action.result.error, false, false ); Ext.Msg.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); }, scope: form, params: { "option": "com_extplorer", "action": "chmod", "dir": "<?php echo stripslashes($GLOBALS['__POST']["dir"]); ?> ", "selitems[]": ['<?php echo implode("','", $GLOBALS['__POST']["selitems"]); ?> '], confirm: 'true' } }); } },{ "text": "<?php echo ext_Lang::msg('btncancel', true); ?> ", "handler": function() { Ext.getCmp("dialog").destroy(); } }] } <?php }
function show_userform($data = null) { if ($data == null) { $data = array('', '', '', '', '', '', ''); } $formname = @$data[0] ? 'frmedituser' : 'frmadduser'; ?> { "xtype": "form", "id" : "<?php echo $formname; ?> ", "renderTo": Ext.getCmp("dialog_tabpanel").getEl(), "hidden": true, "closable":true, "autoHeight": "true", "labelWidth": 125, "url":"<?php echo basename($GLOBALS['script_name']); ?> ", "title": "<?php if (!empty($data[0])) { printf($GLOBALS["messages"]["miscedituser"], $data[0]); } else { echo $GLOBALS["messages"]["miscadduser"]; } ?> " , items: [{ "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('miscusername', true); ?> ", "name": "nuser", "value": "<?php echo @$data[0]; ?> ", "width":175, "allowBlank":false },{ "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('miscconfpass', true); ?> ", "name": "pass1", "inputType": "password", "width":175 }, { "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('miscconfnewpass', true); ?> ", "name": "pass2", "inputType": "password", "width":175 }, <?php if (!empty($data[0])) { ?> { "xtype": "checkbox", "fieldLabel": "<?php echo ext_Lang::msg('miscchpass', true); ?> ", "name": "chpass", "hiddenValue": "true" }, <?php } ?> { "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('mischomedir', true); ?> ", "name": "home_dir", "value": "<?php echo !empty($data[2]) ? $data[2] : $_SERVER['DOCUMENT_ROOT']; ?> ", "width":175, "allowBlank":false }, { "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('mischomeurl', true); ?> ", "name": "home_url", "value": "<?php echo !empty($data[3]) ? $data[3] : $GLOBALS["home_url"]; ?> ", "width":175, "allowBlank":false },{ "xtype": "combo", "fieldLabel": "<?php echo ext_Lang::msg('miscshowhidden', true); ?> ", "store": [ ["1", "<?php echo ext_Lang::msg(array('miscyesno' => 0), true); ?> "], ["0", "<?php echo ext_Lang::msg(array('miscyesno' => 1), true); ?> "] ], "hiddenName": "show_hidden", "disableKeyFilter": true, "value": "<?php echo !empty($data[4]) ? $data[4] : (int) $data[4]; ?> ", "editable": false, "triggerAction": "all", "mode": "local", "allowBlank": false, "selectOnFocus":true }, { "xtype": "textfield", "fieldLabel": "<?php echo ext_Lang::msg('mischidepattern', true); ?> ", "name": "no_access", "value": "<?php echo @$data[5]; ?> ", "width":175, "allowBlank":true }, { "xtype": "combo", "fieldLabel": "<?php echo ext_Lang::msg('miscperms', true); ?> ", "store": [<?php $permvalues = array(0, 1, 2, 3, 7); $permcount = count($GLOBALS["messages"]["miscpermnames"]); for ($i = 0; $i < $permcount; ++$i) { if ($permvalues[$i] == 7) { $index = 4; } else { $index = $i; } echo '["' . $permvalues[$i] . '", "' . ext_lang::msg(array('miscpermnames' => $index)) . '" ]' . "\n"; if ($i + 1 < $permcount) { echo ','; } } ?> ], "hiddenName": "permissions", "disableKeyFilter": true, "value": "<?php echo (int) @$data[6]; ?> ", "editable": false, "triggerAction": "all", "mode": "local" }, { "xtype": "combo", "fieldLabel": "<?php echo ext_Lang::msg('miscactive', true); ?> ", "store": [ ["1", "<?php echo ext_Lang::msg(array('miscyesno' => 0), true); ?> "], ["0", "<?php echo ext_Lang::msg(array('miscyesno' => 1), true); ?> "] ], "hiddenName": "active", "disableKeyFilter": true, "value": "<?php echo !empty($data[7]) ? $data[7] : 0; ?> ", "disabled": <?php echo !empty($self) ? 'true' : 'false'; ?> , "editable": false, "triggerAction": "all", "mode": "local", "allowBlank": false, "selectOnFocus":true } ], "buttons": [ { "text": "<?php echo ext_Lang::msg('btnsave', true); ?> ", "handler": function() { userform = Ext.getCmp("<?php echo $formname; ?> ").getForm(); if(userform.findField('nuser').getValue()=="" || userform.findField('home_dir').getValue()=="") { Ext.Msg.alert('Status', "<?php echo ext_Lang::err('miscfieldmissed', true); ?> "); return false; } if( userform.findField('chpass') ) { if(userform.findField('chpass').getValue() && userform.findField('pass1').getValue() != userform.findField('pass2').getValue()) { Ext.Msg.alert('Status', "<?php echo ext_Lang::err('miscnopassmatch', true); ?> "); return false; } } statusBarMessage( 'Please wait...', true ); userform.submit({ "success": function(form, action) { statusBarMessage( action.result.message, false, true ); Ext.getCmp("dialog_tabpanel").remove("<?php echo $formname; ?> "); }, "failure": function(form, action) { if( !action.result ) return; Ext.Msg.alert('Error!', action.result.error); statusBarMessage( action.result.error, false, true ); }, "scope": userform, // add some vars to the request, similar to hidden fields "params": {option: 'com_extplorer', user: "******", "action": 'admin', "action2": "<?php echo @$data[0] ? 'edituser' : 'adduser'; ?> ", "confirm": "true" } }) } },{ "text": "<?php echo ext_Lang::msg('btncancel', true); ?> ", "handler": function() { Ext.getCmp("dialog_tabpanel").remove("<?php echo $formname; ?> "); } }] } <?php }
function execAction($dir, $item) { if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('diff', false, ext_Lang::err('accessfunc')); } $fname = get_abs_item($dir, $item); if (!get_is_file(utf8_decode($fname))) { ext_Result::sendResult('diff', false, $item . ": " . ext_Lang::err('fileexist')); } if (!get_show_item($dir, $item)) { ext_Result::sendResult('diff', false, $item . ": " . ext_Lang::err('accessfile')); } $cnt = 0; if (!empty($GLOBALS['__POST']["selitems"])) { $cnt = count($GLOBALS['__POST']["selitems"]); } $item2 = extGetParam($_POST, 'item2'); if ($item2 !== null) { $fname2 = get_abs_item('', utf8_decode($item2)); } elseif ($cnt >= 2) { $item2 = $GLOBALS['__POST']["selitems"][1]; $fname2 = get_abs_item($dir, $item2); } if ($item2 !== null) { if (!get_is_file($fname2)) { ext_Result::sendResult('diff', false, $item2 . ": " . ext_Lang::err('fileexist')); } if (!get_show_item('', $item2)) { ext_Result::sendResult('diff', false, $item2 . ": " . ext_Lang::err('accessfile')); } } elseif (empty($cnt) && extGetParam($_POST, 'confirm') == 'true') { ext_Result::sendResult('diff', false, 'Please select a second file to diff to'); } if ($item2 || $cnt >= 2) { // Show File In TextArea $content = $GLOBALS['ext_File']->file_get_contents($fname); $content2 = $GLOBALS['ext_File']->file_get_contents($fname2); //$content = nl2br(str_replace("\t", " ", htmlentities($content))); //$content2 = nl2br(str_replace("\t", " ", htmlentities($content2))); $diff = $this->inline_diff($content, $content2); if (empty($diff)) { ext_Result::sendResult('diff', true, 'Both Files are identical'); } $diff = utf8_encode(nl2br($diff)); echo '{ "xtype": "panel", "dialogtitle": "Diff Result", "html": "' . str_replace(array("\n", "\r"), array('', ''), $diff) . '" }'; exit; } ?> { "xtype": "form", "id": "simpleform", "width": "700", "labelWidth": 125, "url":"<?php echo basename($GLOBALS['script_name']); ?> ", "dialogtitle": "Diff <?php echo htmlentities($item); if ($item2) { echo ' and ' . htmlentities($item2); } ?> ", "title": "Diff", "items": [{ xtype: "textfield", fieldLabel: 'File to Compare', name: 'item2', value: "<?php echo $dir; ?> /", width:175, allowBlank:false }], buttons: [{ "text": "<?php echo ext_Lang::msg('btndiff', true); ?> ", "handler": function() { statusBarMessage( 'Please wait...', true ); form = Ext.getCmp("simpleform").getForm(); form.submit({ //reset: true, reset: false, success: function(form, action) { Ext.getCmp("dialog").setContent( action.result.message, true ); }, failure: function(form, action) { if( !action.result ) return; Ext.MessageBox.alert('Error!', action.result.error); statusBarMessage( action.result.error, false, true ); }, scope: form, // add some vars to the request, similar to hidden fields params: { "option": "com_extplorer", "action": "diff", "dir": "<?php echo stripslashes($GLOBALS['__POST']["dir"]); ?> ", "item": "<?php echo $item; ?> ", "selitems[]": ['<?php echo implode("','", $GLOBALS['__POST']["selitems"]); ?> '], confirm: 'true' } }); } },{ "text": "<?php echo ext_Lang::msg('btncancel', true); ?> ", "handler": function() { Ext.getCmp("dialog").destroy(); } }] } <?php }
function execAction($dir) { if (($GLOBALS["permissions"] & 01) != 01) { ext_Result::sendResult('upload', false, $GLOBALS["error_msg"]["accessfunc"]); } // Execute if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") { $cnt = count($GLOBALS['__FILES']['userfile']['name']); $err = false; $err_available = isset($GLOBALS['__FILES']['userfile']['error']); // upload files & check for errors for ($i = 0; $i < $cnt; $i++) { $errors[$i] = NULL; $tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i]; $items[$i] = stripslashes($GLOBALS['__FILES']['userfile']['name'][$i]); if ($err_available) { $up_err = $GLOBALS['__FILES']['userfile']['error'][$i]; } else { $up_err = file_exists($tmp) ? 0 : 4; } $abs = get_abs_item($dir, $items[$i]); if ($items[$i] == "" || $up_err == 4) { continue; } if ($up_err == 1 || $up_err == 2) { $errors[$i] = $GLOBALS["error_msg"]["miscfilesize"]; $err = true; continue; } if ($up_err == 3) { $errors[$i] = $GLOBALS["error_msg"]["miscfilepart"]; $err = true; continue; } if (!@is_uploaded_file($tmp)) { $errors[$i] = $GLOBALS["error_msg"]["uploadfile"]; $err = true; continue; } if (@file_exists($abs) && empty($_REQUEST['overwrite_files'])) { $errors[$i] = $GLOBALS["error_msg"]["itemdoesexist"]; $err = true; continue; } // Upload $ok = @$GLOBALS['ext_File']->move_uploaded_file($tmp, $abs); if ($ok === false || PEAR::isError($ok)) { $errors[$i] = $GLOBALS["error_msg"]["uploadfile"]; if (PEAR::isError($ok)) { $errors[$i] .= ' [' . $ok->getMessage() . ']'; } $err = true; continue; } else { if (!ext_isFTPMode()) { @$GLOBALS['ext_File']->chmod($abs, 0644); } } } if ($err) { // there were errors $err_msg = ""; for ($i = 0; $i < $cnt; $i++) { if ($errors[$i] == NULL) { continue; } $err_msg .= $items[$i] . " : " . $errors[$i] . "\n"; } ext_Result::sendResult('upload', false, $err_msg); } ext_Result::sendResult('upload', true, ext_Lang::msg('upload_completed')); return; } ?> <div style="width:auto;"> <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div> <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"> <h3 style="margin-bottom:5px;"><?php echo ext_Lang::msg('actupload'); ?> </h3> <?php echo '<br /> ' . ext_Lang::msg('max_file_size') . ' = <strong>' . get_max_file_size() / 1024 / 1024 . ' MB</strong><br /> ' . ext_Lang::msg('max_post_size') . ' = <strong>' . get_max_upload_limit() / 1024 / 1024 . ' MB</strong><br />'; ?> <div id="adminForm"> <div id="uploadForm"></div> <div id="transferForm"><h4><?php echo ext_Lang::msg('acttransfer'); ?> </h4></div> </div> </div></div></div> <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div> </div> <script type="text/javascript"> var simple = new Ext.form.Form({ labelWidth: 125, // label settings here cascade unless overridden url:'<?php echo basename($GLOBALS['script_name']); ?> ', fileUpload: true }); simple.add( <?php for ($i = 0; $i < 7; $i++) { echo "new Ext.form.TextField({\n\t\t fieldLabel: '" . ext_Lang::msg('file', true) . ' ' . ($i + 1) . "',\n\t\t name: 'userfile[{$i}]',\n\t\t width:275,\n\t\t inputType: 'file'\n\t\t }),"; } ?> new Ext.form.Checkbox({ fieldLabel: '<?php echo ext_Lang::msg('overwrite_files', true); ?> ', name: 'overwrite_files', checked: true }) ); simple.addButton('<?php echo ext_Lang::msg('btnsave', true); ?> ', function() { statusBarMessage( '<?php echo ext_Lang::msg('upload_processing', true); ?> ', true ); simple.submit({ //reset: true, reset: false, success: function(form, action) { datastore.reload(); statusBarMessage( action.result.message, false, true ); dialog.destroy(); }, failure: function(form, action) { if( !action.result ) return; Ext.MessageBox.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); statusBarMessage( action.result.error, false, false ); }, scope: simple, // add some vars to the request, similar to hidden fields params: {option: 'com_extplorer', action: 'upload', dir: datastore.directory, requestType: 'xmlhttprequest', confirm: 'true'} }); }); simple.addButton('<?php echo ext_Lang::msg('btncancel', true); ?> ', function() { dialog.destroy(); } ); simple.render('uploadForm'); var transfer = new Ext.form.Form({ labelWidth: 125, // label settings here cascade unless overridden url:'<?php echo basename($GLOBALS['script_name']); ?> ' }); transfer.add( <?php for ($i = 0; $i < 7; $i++) { echo "new Ext.form.TextField({\n\t\t fieldLabel: '" . ext_Lang::msg('url_to_file', true) . "',\n\t\t name: 'userfile[{$i}]',\n\t\t width:275\n\t\t }),"; } ?> new Ext.form.Checkbox({ fieldLabel: '<?php echo ext_Lang::msg('overwrite_files', true); ?> ', name: 'overwrite_files', checked: true }) ); transfer.addButton('<?php echo ext_Lang::msg('btnsave', true); ?> ', function() { statusBarMessage( '<?php echo ext_Lang::msg('transfer_processing', true); ?> ', true ); transfer.submit({ //reset: true, reset: false, success: function(form, action) { datastore.reload(); statusBarMessage( action.result.message, false, true ); dialog.destroy(); }, failure: function(form, action) { if( !action.result ) return; Ext.MessageBox.alert('<?php echo ext_Lang::err('error', true); ?> ', action.result.error); statusBarMessage( action.result.error, false, false ); }, scope: transfer, // add some vars to the request, similar to hidden fields params: {option: 'com_extplorer', action: 'transfer', dir: datastore.directory, confirm: 'true' } }); }); transfer.addButton('<?php echo ext_Lang::msg('btncancel', true); ?> ', function() { dialog.destroy(); } ); transfer.render('transferForm'); var tabs = new Ext.TabPanel("adminForm"); tabs.addTab("uploadForm", '<?php echo ext_Lang::msg('actupload', true); ?> '); tabs.addTab("transferForm", '<?php echo ext_Lang::msg('acttransfer', true); ?> '); tabs.activate('uploadForm'); </script> <?php }