Exemplo n.º 1
0
 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'));
     }
 }
Exemplo n.º 2
0
 function execAction($dir)
 {
     if (($GLOBALS["permissions"] & 01) != 01) {
         ext_Result::sendResult('upload', false, $GLOBALS["error_msg"]["accessfunc"]);
     }
     $this->_downloadMethods = array(new CurlDownloader(), new WgetDownloader(), new FopenDownloader(), new FsockopenDownloader());
     //DEBUG ext_Result::sendResult('transfer', false, $dir );
     // Execute
     if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
         // CSRF Security Check
         if (!ext_checkToken($GLOBALS['__POST']["token"])) {
             ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
         }
         $cnt = count($GLOBALS['__POST']['userfile']);
         $err = false;
         foreach ($this->_downloadMethods as $method) {
             if ($method->isSupported()) {
                 $downloader =& $method;
                 break;
             }
         }
         // upload files & check for errors
         for ($i = 0; $i < $cnt; $i++) {
             $errors[$i] = NULL;
             $items[$i] = stripslashes(basename($GLOBALS['__POST']['userfile'][$i]));
             $abs = get_abs_item($dir, $items[$i]);
             if ($items[$i] == "") {
                 continue;
             }
             if (@file_exists($abs) && empty($_REQUEST['overwrite_files'])) {
                 $errors[$i] = $GLOBALS["error_msg"]["itemdoesexist"];
                 $err = true;
                 continue;
             }
             // Upload
             $ok = $downloader->download($GLOBALS['__POST']['userfile'][$i], $abs);
             if ($ok === true) {
                 $mode = ext_isFTPMode() ? 644 : 0644;
                 @$GLOBALS['ext_File']->chmod($abs, $mode);
             } else {
                 $errors[$i] = $ok;
                 $err = true;
                 continue;
             }
         }
         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('transfer', false, $err_msg);
         }
         ext_Result::sendResult('transfer', true, ext_Lang::msg('transfer_completed'));
         return;
     }
 }
Exemplo n.º 3
0
 function execAction($dir)
 {
     // delete files/dirs
     if (($GLOBALS["permissions"] & 01) != 01) {
         ext_Result::sendResult('delete', false, $GLOBALS["error_msg"]["accessfunc"]);
     }
     // CSRF Security Check
     if (!ext_checkToken($GLOBALS['__POST']["token"])) {
         ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
     }
     $cnt = count($GLOBALS['__POST']["selitems"]);
     $err = false;
     // delete files & check for errors
     for ($i = 0; $i < $cnt; ++$i) {
         $items[$i] = basename(stripslashes($GLOBALS['__POST']["selitems"][$i]));
         if (ext_isFTPMode()) {
             $abs = get_item_info($dir, $items[$i]);
         } else {
             $abs = get_abs_item($dir, $items[$i]);
         }
         if (!@$GLOBALS['ext_File']->file_exists($abs)) {
             $error[$i] = $GLOBALS["error_msg"]["itemexist"];
             $err = true;
             continue;
         }
         if (!get_show_item($dir, $items[$i])) {
             $error[$i] = $GLOBALS["error_msg"]["accessitem"];
             $err = true;
             continue;
         }
         // Delete
         if (ext_isFTPMode()) {
             $abs = str_replace('\\', '/', get_abs_item($dir, $abs));
         }
         $ok = $GLOBALS['ext_File']->remove($abs);
         if ($ok === false || PEAR::isError($ok)) {
             $error[$i] = $GLOBALS["error_msg"]["delitem"];
             if (PEAR::isError($ok)) {
                 $error[$i] .= ' [' . $ok->getMessage() . ']';
             }
             $err = true;
             continue;
         }
         $error[$i] = NULL;
     }
     if ($err) {
         // there were errors
         $err_msg = "";
         for ($i = 0; $i < $cnt; ++$i) {
             if ($error[$i] == NULL) {
                 continue;
             }
             $err_msg .= $items[$i] . " : " . $error[$i] . ".\n";
         }
         ext_Result::sendResult('delete', false, $err_msg);
     }
     ext_Result::sendResult('delete', true, $GLOBALS['messages']['success_delete_file']);
 }
Exemplo n.º 4
0
    function execAction($dir)
    {
        // make new directory or file
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('mkitem', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (extGetParam($_POST, 'confirm') == 'true') {
            // CSRF Security Check
            if (!ext_checkToken($GLOBALS['__POST']["token"])) {
                ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
            }
            $mkname = $GLOBALS['__POST']["mkname"];
            $mktype = $GLOBALS['__POST']["mktype"];
            $symlink_target = $GLOBALS['__POST']['symlink_target'];
            $mkname = basename(stripslashes($mkname));
            if ($mkname == "") {
                ext_Result::sendResult('mkitem', false, $GLOBALS["error_msg"]["miscnoname"]);
            }
            $new = get_abs_item($dir, $mkname);
            if (@$GLOBALS['ext_File']->file_exists($new)) {
                ext_Result::sendResult('mkitem', false, $mkname . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
            }
            $err = print_r($_POST, true);
            if ($mktype == "dir") {
                $ok = @$GLOBALS['ext_File']->mkdir($new, 0777);
                $err = $GLOBALS["error_msg"]["createdir"];
            } elseif ($mktype == 'file') {
                $ok = @$GLOBALS['ext_File']->mkfile($new);
                $err = $GLOBALS["error_msg"]["createfile"];
            } elseif ($mktype == 'symlink') {
                if (empty($symlink_target)) {
                    ext_Result::sendResult('mkitem', false, 'Please provide a valid <strong>target</strong> for the symbolic link.');
                }
                if (!file_exists($symlink_target) || !is_readable($symlink_target)) {
                    ext_Result::sendResult('mkitem', false, 'The file you wanted to make a symbolic link to does not exist or is not accessible by PHP.');
                }
                $ok = symlink($symlink_target, $new);
                $err = 'The symbolic link could not be created.';
            }
            if ($ok == false || PEAR::isError($ok)) {
                if (PEAR::isError($ok)) {
                    $err .= $ok->getMessage();
                }
                ext_Result::sendResult('mkitem', false, $err);
            }
            ext_Result::sendResult('mkitem', true, 'The item ' . $new . ' was created');
            return;
        }
        ?>
		{
		"xtype": "form",
		"id": "simpleform",
		"labelWidth": 125,
		"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
		"dialogtitle": "Create New File/Directory",
		"frame": true,
		"items": [{
			"xtype": "textfield",
			"fieldLabel": "<?php 
        echo ext_Lang::msg("nameheader", true);
        ?>
",
			"name": "mkname",
			"width":175,
			"allowBlank":false
			},{
			"xtype": "combo",
			"fieldLabel": "Type",
			"store": [["file", "<?php 
        echo ext_Lang::mime('file', true);
        ?>
"],
						["dir", "<?php 
        echo ext_Lang::mime('dir', true);
        ?>
"]
						<?php 
        if (!ext_isFTPMode() && !$GLOBALS['isWindows']) {
            ?>
						,["symlink", "<?php 
            echo ext_Lang::mime('symlink', true);
            ?>
"]
						<?php 
        }
        ?>
					],
			displayField:"type",
			valueField: "mktype",
			value: "file",
			hiddenName: "mktype",
			disableKeyFilter: true,
			editable: false,
			triggerAction: "all",
			mode: "local",
			allowBlank: false,
			selectOnFocus:true
		},{
			"xtype": "textfield",
			"fieldLabel": "<?php 
        echo ext_Lang::msg('symlink_target', true);
        ?>
",
			"name": "symlink_target",
			"width":175,
			"allowBlank":true
		}],
		"buttons": [{
			"text": "<?php 
        echo ext_Lang::msg('btncreate', true);
        ?>
", 
			"handler": function() {
				statusBarMessage( "Please wait...", true );
				Ext.getCmp("simpleform").getForm().submit({
					//reset: true,
					reset: false,
					success: function(form, action) {
						statusBarMessage( action.result.message, false, true );
						try{ 
							dirTree.getSelectionModel().getSelectedNode().reload(); 
						} catch(e) {}
						datastore.reload();
						Ext.getCmp("dialog").destroy();
					},
					failure: function(form, action) {
						if( !action.result ) return;
						Ext.Msg.alert("Error!", action.result.error);
						statusBarMessage( action.result.error, false, false );
					},
					scope: Ext.getCmp("simpleform"),
					// add some vars to the request, similar to hidden fields
					params: {option: "com_extplorer", 
							action: "mkitem", 
							dir: datastore.directory, 
							confirm: "true",
							token: "<?php 
        echo ext_getToken();
        ?>
"
					}
				})
			}
		},{
			"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
			"handler": function() { Ext.getCmp("dialog").destroy(); }
		}]
	}
	<?php 
    }
Exemplo n.º 5
0
    function execAction($dir, $item)
    {
        // change permissions
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('chmod', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        // CSRF Security Check
        if (!ext_checkToken($GLOBALS['__POST']["token"])) {
            ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
        }
        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": "&nbsp;"
		}]

	},{
		"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',
					token: "<?php 
        echo ext_getToken();
        ?>
"
				}
			});
		}
	},{
		"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
		"handler": function() { Ext.getCmp("dialog").destroy(); }
	}]
}
	
		<?php 
    }
Exemplo n.º 6
0
function removeuser($dir)
{
    // Remove User
    $user = stripslashes($GLOBALS['__POST']["user"]);
    if (!ext_checkToken($GLOBALS['__POST']["token"])) {
        ext_Result::sendResult('tokencheck', false, 'CSRF Token Check failed.');
    }
    if ($user == $GLOBALS['__SESSION']['credentials_extplorer']['username']) {
        ext_Result::sendResult('removeuser', false, $GLOBALS["error_msg"]["miscselfremove"]);
    }
    if (!ext_remove_user($user)) {
        ext_Result::sendResult('removeuser', false, $user . ": " . $GLOBALS["error_msg"]["deluser"]);
    }
    ext_Result::sendResult('removeuser', true, $user . " was successfully removed.");
}
Exemplo n.º 7
0
    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") {
            // CSRF Security Check
            if (!ext_checkToken($GLOBALS['__POST']["token"])) {
                ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
            }
            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 (@$GLOBALS['ext_File']->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",
                        "token": "<?php 
        echo ext_getToken();
        ?>
"
					}
				});
			}
		}, {
			"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',
                        "token": "<?php 
        echo ext_getToken();
        ?>
"
					}
				});
			}
		},{
			"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
			"handler": function() { Ext.getCmp("dialog").destroy(); }
		}]
	}]
}

	<?php 
    }
Exemplo n.º 8
0
/**
 * File/Directory Copy & Move Functions
 */
function ext_copy_move_items($dir)
{
    // copy/move file/dir
    $action = extGetParam($_REQUEST, 'action');
    if (($GLOBALS["permissions"] & 01) != 01) {
        ext_Result::sendResult($action, false, $GLOBALS["error_msg"]["accessfunc"]);
    }
    // CSRF Security Check
    if (!ext_checkToken($GLOBALS['__POST']["token"])) {
        ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
    }
    // Vars
    $first = extGetParam($GLOBALS['__POST'], 'first');
    if ($first == "y") {
        $new_dir = $dir;
    } else {
        $new_dir = extGetParam($GLOBALS['__POST'], "new_dir");
    }
    if ($new_dir == ".") {
        $new_dir = "";
    }
    $cnt = count($GLOBALS['__POST']["selitems"]);
    if (!$new_dir) {
        ext_copy_move_dialog($dir);
        return;
    }
    // DO COPY/MOVE
    // ALL OK?
    if (!@$GLOBALS['ext_File']->file_exists(dirname(get_abs_dir($new_dir)))) {
        ext_Result::sendResult($action, false, dirname(get_abs_dir($new_dir)) . ": " . $GLOBALS["error_msg"]["targetexist"]);
    }
    if (!get_show_item($new_dir, "")) {
        ext_Result::sendResult($action, false, $new_dir . ": " . $GLOBALS["error_msg"]["accesstarget"]);
    }
    if (!down_home(get_abs_dir($new_dir))) {
        ext_Result::sendResult($action, false, $new_dir . ": " . $GLOBALS["error_msg"]["targetabovehome"]);
    }
    // copy / move files
    $err = false;
    for ($i = 0; $i < $cnt; ++$i) {
        $tmp = basename(stripslashes($GLOBALS['__POST']["selitems"][$i]));
        $new = basename(stripslashes($GLOBALS['__POST']["selitems"][$i]));
        if (ext_isFTPMode()) {
            $abs_item = get_item_info($dir, $tmp);
            $abs_new_item = $new_dir . '/' . $new;
        } else {
            $abs_item = get_abs_item($dir, $tmp);
            $abs_new_item = get_abs_item($new_dir, $new);
        }
        $items[$i] = $tmp;
        // Check
        if ($new == "") {
            $error[$i] = $GLOBALS["error_msg"]["miscnoname"];
            $err = true;
            continue;
        }
        if (!@$GLOBALS['ext_File']->file_exists($abs_item)) {
            $error[$i] = $GLOBALS["error_msg"]["itemexist"];
            $err = true;
            continue;
        }
        if (!get_show_item($dir, $tmp)) {
            $error[$i] = $GLOBALS["error_msg"]["accessitem"];
            $err = true;
            continue;
        }
        if (@$GLOBALS['ext_File']->file_exists($abs_new_item)) {
            $error[$i] = $GLOBALS["error_msg"]["targetdoesexist"];
            $err = true;
            continue;
        }
        // Copy / Move
        if ($action == "copy") {
            if (@is_link(ext_TextEncoding::fromUTF8($abs_item)) || get_is_file(ext_TextEncoding::fromUTF8($abs_item))) {
                // check file-exists to avoid error with 0-size files (PHP 4.3.0)
                if (ext_isFTPMode()) {
                    $abs_item = '/' . $dir . '/' . $abs_item['name'];
                }
                $ok = @$GLOBALS['ext_File']->copy($abs_item, $abs_new_item);
                //||@file_exists($abs_new_item);
            } elseif (@get_is_dir(ext_TextEncoding::fromUTF8($abs_item))) {
                $ext_copy_dir = ext_isFTPMode() ? '/' . $dir . '/' . $abs_item['name'] . '/' : $abs_item;
                if (ext_isFTPMode()) {
                    $abs_new_item .= '/';
                }
                $ok = $GLOBALS['ext_File']->ext_copy_dir($ext_copy_dir, $abs_new_item);
            }
        } else {
            $ok = $GLOBALS['ext_File']->rename($abs_item, $abs_new_item);
        }
        if ($ok === false || PEAR::isError($ok)) {
            $error[$i] = $action == "copy" ? $GLOBALS["error_msg"]["copyitem"] : $GLOBALS["error_msg"]["moveitem"];
            if (PEAR::isError($ok)) {
                $error[$i] .= ' [' . $ok->getMessage() . ']';
            }
            $err = true;
            continue;
        }
        $error[$i] = NULL;
    }
    if ($err) {
        // there were errors
        $err_msg = "";
        for ($i = 0; $i < $cnt; ++$i) {
            if ($error[$i] == NULL) {
                continue;
            }
            $err_msg .= $items[$i] . " : " . $error[$i] . "\n";
        }
        ext_Result::sendResult($action, false, $err_msg);
    }
    ext_Result::sendResult($action, true, 'The File(s)/Directory(s) were successfully ' . ($action == 'copy' ? 'copied' : 'moved') . '.');
}
Exemplo n.º 9
0
/**
 * Adds a new bookmark to the bookmark ini file
 *
 * @param string $dir
 */
function ext_modify_bookmark($task, $dir)
{
    global $my, $user, $mainframe;
    $alias = substr(extGetParam($_REQUEST, 'alias'), 0, 150);
    // CSRF Security Check
    if (!ext_checkToken($GLOBALS['__POST']["token"])) {
        ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
    }
    $bookmarks = read_bookmarks();
    $bookmarkfile = _EXT_PATH . '/config/bookmarks_' . $GLOBALS['file_mode'] . '_';
    if (empty($my->id)) {
        if (class_exists('jfactory')) {
            $user = JFactory::getUser();
            $bookmarkfile .= $user->get('id') . '.php';
        } else {
            $bookmarkfile .= $mainframe->getUserName() . '.php';
        }
    } else {
        $bookmarkfile .= $my->id . '.php';
    }
    while (@ob_end_clean()) {
    }
    header("Status: 200 OK");
    switch ($task) {
        case 'add':
            if (in_array($dir, $bookmarks)) {
                echo ext_alertBox($GLOBALS['messages']['already_bookmarked']);
                exit;
            }
            //$alias = preg_replace('~[^\w-.\/\\\]~','', $alias ); // Make the alias ini-safe by removing all non-word characters
            $alias = strip_invalid_key_char($alias, "_");
            $bookmarks[$alias] = $dir;
            //we deal with the flippped array here
            $msg = ext_successBox($GLOBALS['messages']['bookmark_was_added']);
            break;
        case 'remove':
            if (!in_array($dir, $bookmarks)) {
                echo ext_alertBox($GLOBALS['messages']['not_a_bookmark']);
                exit;
            }
            $bookmarks = array_flip($bookmarks);
            unset($bookmarks[$dir]);
            $bookmarks = array_flip($bookmarks);
            $msg = ext_successBox($GLOBALS['messages']['bookmark_was_removed']);
    }
    $inifile = "; <?php if( !defined( '_JEXEC' ) && !defined( '_VALID_MOS' ) ) die( 'Restricted access' ); ?>\n";
    $inifile .= $GLOBALS['messages']['homelink'] . "=\n";
    foreach ($bookmarks as $alias => $directory) {
        //changed by pokemon
        if (empty($directory) || empty($alias)) {
            continue;
        }
        if ($directory[0] == $GLOBALS['separator']) {
            $directory = substr($directory, 1);
        }
        $inifile .= "{$alias}={$directory}\n";
    }
    if (!is_writable($bookmarkfile)) {
        echo ext_alertBox(sprintf($GLOBALS['messages']['bookmarkfile_not_writable'], $task, $bookmarkfile));
        exit;
    }
    file_put_contents($bookmarkfile, $inifile);
    echo $msg;
    echo ext_list_bookmarks($dir);
    exit;
}
Exemplo n.º 10
0
    function execAction($dir, $item)
    {
        // rename directory or file
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('rename', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
            // CSRF Security Check
            if (!ext_checkToken($GLOBALS['__POST']["token"])) {
                ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
            }
            $newitemname = $GLOBALS['__POST']["newitemname"];
            $newitemname = trim(basename(stripslashes($newitemname)));
            if ($newitemname == '') {
                ext_Result::sendResult('rename', false, $GLOBALS["error_msg"]["miscnoname"]);
            }
            if (!ext_isFTPMode()) {
                $abs_old = get_abs_item($dir, $item);
                $abs_new = get_abs_item($dir, $newitemname);
            } else {
                $abs_old = get_item_info($dir, $item);
                $abs_new = get_item_info($dir, $newitemname);
            }
            if (@$GLOBALS['ext_File']->file_exists($abs_new)) {
                ext_Result::sendResult('rename', false, ext_TextEncoding::toUTF8($newitemname) . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
            }
            $perms_old = $GLOBALS['ext_File']->fileperms($abs_old);
            $ok = $GLOBALS['ext_File']->rename(get_abs_item($dir, $item), get_abs_item($dir, $newitemname));
            if (ext_isFTPMode()) {
                $abs_new = get_item_info($dir, $newitemname);
            }
            $GLOBALS['ext_File']->chmod($abs_new, $perms_old);
            if ($ok === false || PEAR::isError($ok)) {
                ext_Result::sendResult('rename', false, 'Could not rename ' . $dir . '/' . $item . ' to ' . $newitemname);
            }
            $msg = sprintf($GLOBALS['messages']['success_rename_file'], $item, $newitemname);
            ext_Result::sendResult('rename', true, $msg);
        }
        $is_dir = get_is_dir(ext_isFTPMode() ? get_item_info($dir, $item) : get_abs_item($dir, $item));
        ?>
{
	"xtype": "form",
	"width": "350",
	"height": "150",
	"id": "simpleform",
	"labelWidth": 125,
	"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
	"dialogtitle": "<?php 
        echo $GLOBALS['messages']['rename_file'];
        ?>
",
	"frame": true,
	"items": [{
	
		"xtype": "textfield",
		"fieldLabel": "<?php 
        echo ext_Lang::msg('newname', true);
        ?>
",
		"name": "newitemname",
		"id": "newitemname",
		"value": "<?php 
        echo str_replace("'", "\\'", stripslashes($item));
        ?>
",
		"width":175,
		"allowBlank":false
		}
	],
	"listeners": { "afterrender": { 
						fn: function( form ) {
							form.findById("newitemname").focus(true);
						}
					}
	},
	"buttons": [{
		"text": "<?php 
        echo ext_Lang::msg('btnsave', true);
        ?>
", 
		"handler": function() {
			statusBarMessage( 'Please wait...', true );
			form = Ext.getCmp("simpleform").getForm();
			form.submit({
				//reset: true,
				reset: false,
				success: function(form, action) {
					<?php 
        if ($is_dir) {
            ?>
						if( dirTree.getSelectionModel().getSelectedNode() ) {
							parentDir = dirTree.getSelectionModel().getSelectedNode().parentNode;parentDir.reload();parentDir.select();
						}
					<?php 
        }
        ?>
					datastore.reload();
					statusBarMessage( action.result.message, false, true );
					Ext.getCmp("dialog").destroy();
				},
				failure: function(form, action) {
					if( !action.result ) return;
					Ext.MessageBox.alert('Error!', 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: 'rename', 
					dir: '<?php 
        echo stripslashes($dir);
        ?>
', 
					item: '<?php 
        echo stripslashes($item);
        ?>
', 
					confirm: 'true',
					token: "<?php 
        echo ext_getToken();
        ?>
"
				}
			});
		}
	},{
		"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
		"handler": function() { Ext.getCmp("dialog").destroy(); } 
	}]
}
	
	<?php 
    }
Exemplo n.º 11
0
    function execAction($dir, $item)
    {
        // edit file
        global $mainframe, $mosConfig_live_site;
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('edit', false, ext_Lang::err('accessfunc'));
        }
        $fname = ext_TextEncoding::fromUTF8(get_abs_item($dir, $item));
        if (!get_is_file($fname)) {
            ext_Result::sendResult('edit', false, ext_TextEncoding::toUTF8($item) . ": " . ext_Lang::err('fileexist'));
        }
        if (!get_show_item($dir, $item)) {
            ext_Result::sendResult('edit', false, $item . ": " . ext_Lang::err('accessfile'));
        }
        // CSRF Security Check
        if (!ext_checkToken($GLOBALS['__POST']["token"])) {
            ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
        }
        if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") {
            // Save / Save As
            $item = basename(stripslashes($GLOBALS['__POST']["fname"]));
            $fname2 = ext_TextEncoding::fromUTF8(get_abs_item($dir, $item));
            if (!isset($item) || $item == "") {
                ext_Result::sendResult('edit', false, ext_Lang::err('miscnoname'));
            }
            if ($fname != $fname2 && @$GLOBALS['ext_File']->file_exists($fname2)) {
                ext_Result::sendResult('edit', false, $item . ": " . ext_Lang::err('itemdoesexist'));
            }
            $this->savefile($fname2);
            $fname = $fname2;
            ext_Result::sendResult('edit', true, ext_Lang::msg('savefile') . ': ' . $item);
        }
        if (isset($GLOBALS['__POST']["doreopen"]) && $GLOBALS['__POST']["doreopen"] == "yes") {
            // File Reopen
            $extra = array();
            $content = $GLOBALS['ext_File']->file_get_contents($fname);
            if (get_magic_quotes_runtime()) {
                $content = stripslashes($content);
            }
            $langs = $GLOBALS["language"];
            if ($langs == "japanese") {
                $_encoding = $GLOBALS['__POST']["file_encoding"];
                if ($content) {
                    $content = mb_convert_encoding($content, "UTF-8", $_encoding);
                }
                $extra["file_encoding"] = $_encoding;
            }
            $extra["content"] = $content;
            ext_Result::sendResult('edit', true, ext_Lang::msg('reopenfile') . ': ' . $item, $extra);
        }
        // header
        $s_item = get_rel_item($dir, $item);
        if (strlen($s_item) > 50) {
            $s_item = "..." . substr($s_item, -47);
        }
        $id_hash = substr('f' . md5($s_item), 0, 10);
        $s_info = pathinfo($s_item);
        $s_extension = str_replace('.', '', $s_info['extension']);
        switch (strtolower($s_extension)) {
            case 'txt':
                $cp_lang = 'text';
                break;
            case 'cs':
                $cp_lang = 'csharp';
                break;
            case 'css':
                $cp_lang = 'css';
                break;
            case 'html':
            case 'htm':
            case 'xhtml':
                $cp_lang = 'html';
                break;
            case 'java':
                $cp_lang = 'java';
                break;
            case 'js':
                $cp_lang = 'js';
                break;
            case 'pl':
                $cp_lang = 'perl';
                break;
            case 'py':
                $cp_lang = 'python';
                break;
            case 'ruby':
                $cp_lang = 'ruby';
                break;
            case 'sql':
                $cp_lang = 'sql';
                break;
            case 'vb':
            case 'vbs':
                $cp_lang = 'vb';
                break;
            case 'php':
                $cp_lang = 'php';
                break;
            case 'xml':
                $cp_lang = 'xml';
                break;
            default:
                $cp_lang = '';
        }
        $content = $GLOBALS['ext_File']->file_get_contents($fname);
        if (get_magic_quotes_runtime()) {
            $content = stripslashes($content);
        }
        $cw = 250;
        $langs = $GLOBALS["language"];
        if ($langs == "japanese") {
            $cw = 200;
            if ($content) {
                $_encoding = strtoupper(mb_detect_encoding($content, array("ASCII", "ISO-2022-JP", "UTF-8", "EUCJP-WIN", "SJIS-WIN"), true));
                $content = mb_convert_encoding($content, "UTF-8", $_encoding);
                if ($_encoding == "SJIS-WIN") {
                    $_encoding_label = "SJIS";
                } elseif ($_encoding == "EUCJP-WIN") {
                    $_encoding_label = "EUC-JP";
                } elseif ($_encoding == "ISO-2022-JP") {
                    $_encoding_label = "JIS";
                } elseif ($_encoding == "ASCII") {
                    $_encoding_label = "UTF-8";
                } else {
                    $_encoding_label = $_encoding;
                }
            } else {
                $_encoding_label = "UTF-8";
            }
        }
        ?>
{
	"xtype": "form",
	"id": "<?php 
        echo $id_hash;
        ?>
",
	"labelWidth": "300",
	"autoScroll": "true", 
	"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
	"title": "<?php 
        echo strlen($s_item) > 50 ? substr(htmlentities($s_item, ENT_QUOTES), strlen($s_item) - 30, 30) : htmlentities($s_item, ENT_QUOTES);
        ?>
",
	"frame": "true",
	"closable": "true",
	"tbar": [{
 		"text": "<?php 
        echo ext_Lang::msg('btnsave', true);
        ?>
", 
		"handler": function() {
			statusBarMessage( '<?php 
        echo ext_Lang::msg('save_processing', true);
        ?>
', true );
			form = Ext.getCmp("<?php 
        echo $id_hash;
        ?>
").getForm();
			form.submit({
				waitMsg: 'Saving the File, please wait...',
				reset: false,
				success: function(form, action) {
					datastore.reload();
					statusBarMessage( action.result.message, false, true );
				},
				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,
				// add some vars to the request, similar to hidden fields
				params: {option: 'com_extplorer', 
						action: 'edit', 
						code: editAreaLoader.getValue("ext_codefield<?php 
        echo $id_hash;
        ?>
"),
						dir: '<?php 
        echo stripslashes($dir);
        ?>
', 
						item: '<?php 
        echo stripslashes($item);
        ?>
', 
						dosave: 'yes',
                        token: "<?php 
        echo ext_getToken();
        ?>
"
				}
			});
		},
        "cls":"x-btn-text-icon",
        "icon": "<?php 
        echo _EXT_URL;
        ?>
/images/_save.png"
    },{
		"text": "<?php 
        echo ext_Lang::msg('btnreopen', true);
        ?>
", 
		"handler": function() { 
			statusBarMessage( '<?php 
        echo ext_Lang::msg('reopen_processing', true);
        ?>
', true );
			form = Ext.getCmp("<?php 
        echo $id_hash;
        ?>
").getForm();
			form.submit({
				waitMsg: 'Processing Data, please wait...',
				reset: false,
				success: function(form, action) {
					statusBarMessage( action.result.message, false, true );
					editAreaLoader.setValue("ext_codefield<?php 
        echo $id_hash;
        ?>
", action.result.content);
				},
				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,
				// add some vars to the request, similar to hidden fields
				params: {
					option: 'com_extplorer', 
					action: 'edit', 
					dir: '<?php 
        echo stripslashes($dir);
        ?>
', 
					item: '<?php 
        echo stripslashes($item);
        ?>
', 
					doreopen: 'yes',
                    token: "<?php 
        echo ext_getToken();
        ?>
"
				}
			});
		},	
        "cls":"x-btn-text-icon",
        "icon": "<?php 
        echo _EXT_URL;
        ?>
/images/_reload.png"
    },
    {
    	"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
		"handler": function() { 
			Ext.getCmp("mainpanel").remove( Ext.getCmp("mainpanel").getActiveTab() );
		},
        "cls":"x-btn-text-icon",
        "icon": "<?php 
        echo _EXT_URL;
        ?>
/images/_cancel.png"
	}],	
	"items": [{
		"xtype": "displayfield",
		"value": "<?php 
        echo $GLOBALS["messages"]["actedit"] . ': ' . htmlentities($s_item, ENT_QUOTES);
        ?>
"
		},
		{
		"xtype": "textarea",
		"hideLabel": true,
		"name": "thecode",
		"id": "ext_codefield<?php 
        echo $id_hash;
        ?>
",
		"fieldClass": "x-form-field",
		"value": "<?php 
        echo str_replace(array("\r", "\n"), array('\\r', '\\n'), addslashes($content));
        ?>
",
		"width": "100%",
		"height": 500,
		"plugins": new Ext.ux.plugins.EditAreaEditor({
			"id" : "ext_codefield<?php 
        echo $id_hash;
        ?>
",	
			"syntax": "<?php 
        echo $cp_lang;
        ?>
",
			"start_highlight": true,
			"display": "later",
			"toolbar": "search, go_to_line, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, |, help" 
			<?php 
        if (array_key_exists($langs, $this->lang_tbl)) {
            ?>
				,"language": "<?php 
            echo $this->lang_tbl[$langs];
            ?>
"
				<?php 
        }
        ?>
		})
	},
	{
		
			"width": "<?php 
        echo $cw;
        ?>
", 
			"xtype": "textfield",
			"fieldLabel": "<?php 
        echo ext_Lang::msg('copyfile', true);
        ?>
",
			"name": "fname",
			"value": "<?php 
        echo addslashes($item);
        ?>
",
			"clear": "true"
			}
<?php 
        if ($langs == "japanese") {
            ?>
			,{
			 "width": "<?php 
            echo $cw;
            ?>
",  
			 "style":"margin-left:10px", 
			 "clear":"true",
			"xtype": "combo",
			"fieldLabel": "<?php 
            echo ext_Lang::msg('fileencoding', true);
            ?>
",
			"name": "file_encoding",
			"store": [
						["UTF-8", "UTF-8"],
						["SJIS-WIN", "SJIS"],
						["EUCJP-WIN", "EUC-JP"],
						["ISO-2022-JP","JIS"]
					],
			"value" : "<?php 
            echo $_encoding_label;
            ?>
",
			"typeAhead": "true",
			"mode": "local",
			"triggerAction": "all",
			"editable": "false",
			"forceSelection": "true"
			}
	
<?php 
        }
        ?>
		]

}
	
<?php 
    }
Exemplo n.º 12
0
    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"]);
        }
        // CSRF Security Check
        if (!ext_checkToken($GLOBALS['__POST']["token"])) {
            ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
        }
        $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', 'token' => ext_getToken(), '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, 'token' => ext_getToken(), '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 
    }