Example #1
0
/**
 * @version $Id: footer.php 107 2008-07-22 17:27:12Z soeren $
 * @package eXtplorer
 * @copyright soeren 2007
 * @author The eXtplorer project (http://sourceforge.net/projects/extplorer)
 * @author The  The QuiX project (http://quixplorer.sourceforge.net)
 * 
 * @license
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 * 
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU General Public License Version 2 or later (the "GPL"), in
 * which case the provisions of the GPL are applicable instead of
 * those above. If you wish to allow use of your version of this file only
 * under the terms of the GPL and not to allow others to use
 * your version of this file under the MPL, indicate your decision by
 * deleting  the provisions above and replace  them with the notice and
 * other provisions required by the GPL.  If you do not delete
 * the provisions above, a recipient may use your version of this file
 * under either the MPL or the GPL."
 * 
 * Shows the About Box!
 */
function show_about()
{
    // footer for html-page
    echo "\n<div id=\"ext_footer\" style=\"text-align:center;\">\r\n\t<img src=\"" . _EXT_URL . "/images/MangosWeb_small.png\" align=\"middle\" alt=\"Mangosweb Enhanced Logo\" />\r\n\t<br />\r\n\t" . ext_Lang::msg('your_version') . ": <a href=\"" . $GLOBALS['ext_home'] . "\" target=\"_blank\">eXtplorer {$GLOBALS['ext_version']}</a>\r\n\t<br />\r\n (<a href=\"http://virtuemart.net/index2.php?option=com_versions&amp;catid=5&amp;myVersion=" . $GLOBALS['ext_version'] . "\" onclick=\"javascript:void window.open('http://virtuemart.net/index2.php?option=com_versions&catid=5&myVersion=" . $GLOBALS['ext_version'] . "', 'win2', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=580,directories=no,location=no'); return false;\" title=\"" . $GLOBALS["messages"]["check_version"] . "\">" . $GLOBALS["messages"]["check_version"] . "</a>)\r\n\t\r\n\t";
    if (function_exists("disk_free_space")) {
        $size = disk_free_space($GLOBALS['home_dir'] . $GLOBALS['separator']);
        $free = parse_file_size($size);
    } elseif (function_exists("diskfreespace")) {
        $size = diskfreespace($GLOBALS['home_dir'] . $GLOBALS['separator']);
        $free = parse_file_size($size);
    } else {
        $free = "?";
    }
    echo '<br />' . $GLOBALS["messages"]["miscfree"] . ": " . $free . " \n";
    if (extension_loaded("posix")) {
        $owner_info = '<br /><br />' . ext_Lang::msg('current_user') . ' ';
        if (ext_isFTPMode()) {
            $my_user_info = posix_getpwnam($_SESSION['ftp_login']);
            $my_group_info = posix_getgrgid($my_user_info['gid']);
        } else {
            $my_user_info = posix_getpwuid(posix_geteuid());
            $my_group_info = posix_getgrgid(posix_getegid());
        }
        $owner_info .= $my_user_info['name'] . ' (' . $my_user_info['uid'] . '), ' . $my_group_info['name'] . ' (' . $my_group_info['gid'] . ')';
        echo $owner_info;
    }
    echo "\r\n\t</div>";
}
Example #2
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'));
     }
 }
Example #3
0
 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'));
     }
 }
Example #4
0
function show_searchform($dir = '')
{
    ?>
{
     "height":400,
     "autoScroll":true,

     items: [
        new Ext.TabPanel({
        activeTab: 0,
        items: [{
            "title":"<?php 
    echo $GLOBALS["messages"]["searchlink"];
    ?>
",
            "height": "370",
            "autoScroll":true,
            "items":
                new Ext.DataView({
                "id": "dataview",
                 tpl: new Ext.XTemplate(
                    '<tpl for=".">',
                    '<div class="search-item">',
                        '<h3>',
                        '<a onclick="selectFile(\'{dir}\', \'{file}\');Ext.getCmp(\'dialog\').destroy();return false;" href="#" target="_blank">{s_dir}/{file}, {lastModified:date("M j, Y")}</a>',
                        '</h3>',
                    '</div></tpl>'
                ),
                 store: new Ext.data.Store({
                        proxy: new Ext.data.HttpProxy({
                            url: "<?php 
    echo $GLOBALS['script_name'];
    ?>
"
                        }),
                        reader: new Ext.data.JsonReader({
                            root: 'items',
                            totalProperty: 'totalCount',
                            id: 'file_id'
                        }, [
                            {name: 'fileId', mapping: 'file_id'},
                            {name: 'file', mapping: 'file'},
                            {name: 'dir', mapping: 'dir'},
                            {name: 's_dir', mapping: 's_dir'},
                            {name: 'lastModified', mapping: 'last_mtime', type: 'date', dateFormat: 'timestamp'}
                        ]),
                        baseParams: {
                            limit:20,
                            option: "com_extplorer",
                            action:"search",
                            dir: "<?php 
    echo $dir;
    ?>
",
                            content: '0',
                            subdir: '1'
                        }
                    }),
                 itemSelector: 'div.search-item'
            }),

         tbar: [
             'Search: ', ' ',
             new Ext.app.SearchField({
                 store: Ext.getCmp("dataview").store,
                 width:320,
                value: "*"
             })
         ],

         bbar: new Ext.PagingToolbar({
             store: Ext.getCmp("dataview").store,
             pageSize: 20,
             displayInfo: true,
             displayMsg: 'Results {0} - {1} of {2}',
             emptyMsg: "No files to display"
         })
    },
    {
        title: "Search Options",
        xtype:"form",
        layout: "form",
        "height": "350",
        items: [

            {
                id:'myGroup',
                xtype: 'checkboxgroup',
                fieldLabel: 'Extensive Search',
                itemCls: 'x-check-group-alt',
                // Put all controls in a single column with width 100%
                columns: 1,
                items: [
                {
                    boxLabel: 'Search within Subdirectories?', name: 'subdir',
                    checked: true,
                    tooltip: "<?php 
    echo ext_Lang::msg('miscsubdirs', true);
    ?>
?",
                    "listeners": {
                        "check": {
                            fn: function(box, checked) {
                                Ext.getCmp("dataview").store.baseParams.subdir = (checked ? '1' : '0');
                            }
                        }
                    }
                 }
                ]
            },{
                fieldLabel: "<?php 
    echo ext_Lang::msg('misccontent', true);
    ?>
",
                xtype: "textfield",
                width: 200,
                id: "contentfield",
                name: "content",
                "listeners": {
                    "change": {
                        fn: function(field, newValue) {
                            Ext.getCmp("dataview").store.baseParams.content = newValue;
                        }
                    }
                }

            },
            {
                xtype: "compositefield",
                items: [
                {
                    xtype: "checkbox",
                    fieldLabel: "Modification Date between",
                    "listeners": {
                    "check": {
                        fn: function(box, checked) {
                            if( checked ) {Ext.getCmp( "mdate_start" ).enable(); Ext.getCmp( "mdate_end" ).enable(); }
                            else {
								Ext.getCmp( "mdate_start" ).disable(); Ext.getCmp( "mdate_end" ).disable(); 	
								Ext.getCmp("dataview").store.baseParams.mdate_start = "";
								Ext.getCmp("dataview").store.baseParams.mdate_end = "";							
							}
                        }
                    }
                }
                },
                new Ext.form.DateField({
                    tooltip: 'Start',
                    name: 'mdate_start',
                    id: 'mdate_start',
                    "listeners": {
                        "change": {
                            fn: function(field, newValue) {
                                Ext.getCmp("dataview").store.baseParams.mdate_start = newValue;
                            }
                        }
                    },
                    width:90,
                    disabled: true
                }),
                new Ext.form.DateField({
                    tooltip: 'End',
                    name: 'mdate_end',
                    id: 'mdate_end',
                    disabled: true,
                    "listeners": {
                        "change": {
                            fn: function(field, newValue) {
                                Ext.getCmp("dataview").store.baseParams.mdate_end = newValue;
                            }
                        }
                    },
                    width:90
                })

                ]
            },
            {
                xtype: "compositefield",
                items: [
                {
                    xtype: "checkbox",
                    name: "age_enabled",
                    fieldLabel: "max. File Age",
                    "listeners": {
                        "check": {
                            fn: function(box, checked) {
                                if( checked ) {Ext.getCmp( "age_unit" ).enable(); Ext.getCmp( "age_value" ).enable(); }
								else {
									Ext.getCmp( "age_value" ).disable(); Ext.getCmp( "age_unit" ).disable(); 	
									Ext.getCmp("dataview").store.baseParams.age_value = "";
									Ext.getCmp("dataview").store.baseParams.age_unit = "";							
								}
                            }
                        }
                    }
                },
				{
					xtype: "textfield",
					name: "age_value",
					id: "age_value",
					value: 1,
					width: 40,
                    "listeners": {
                        "change": {
                            fn: function(field, newValue) {
                                Ext.getCmp("dataview").store.baseParams.age_value = newValue;
                            }
                        }
                    },
					disabled: true
				},
					new Ext.form.ComboBox({
						triggerAction: 'all',
						lazyRender:true,
						mode: 'local',
						disabled: true,
						name: "age_unit",
						id: "age_unit",
						value: "days",
                        "listeners": {
                            "change": {
                                fn: function(field, newValue) {
                                    Ext.getCmp("dataview").store.baseParams.age_unit = newValue;
                                }
                            }
                        },
						store: new Ext.data.ArrayStore({
							id: 0,
							fields: [
								'myId',
								'displayText'
							],
							data: [["minute", 'Minute(s)'], ["hours", 'Hour(s)'],
								["days", "Day(s)"], ["weeks", "Week(s)"], ["months", "Month(s)"], ["years", "Year(s)" ]
								]
						}),
						valueField: 'myId',
						displayField: 'displayText'
					})
                ]
            }

    ]
    }]
    })
    ]
}

<?php 
}
Example #5
0
/**
 * Lists all bookmarked directories in a dropdown list.
 *
 * @param string $dir
 */
function list_bookmarks($dir)
{
    $bookmarks = read_bookmarks();
    $bookmarks = array_flip($bookmarks);
    foreach ($bookmarks as $bookmark) {
        $len = strlen($bookmark);
        if ($len > 40) {
            $first_part = substr($bookmark, 0, 20);
            $last_part = substr($bookmark, -20);
            $bookmarks[$bookmark] = $first_part . '...' . $last_part;
        }
    }
    $html = $GLOBALS['messages']['quick_jump'] . ': ';
    if (!empty($dir[0]) && @$dir[0] == '/') {
        $dir = substr($dir, 1);
    }
    $html .= ext_selectList('favourites', $dir, $bookmarks, 1, '', 'onchange="chDir( this.options[this.options.selectedIndex].value);" style="max-width: 200px;"');
    $img_add = '<img src="' . _EXT_URL . '/images/_bookmark_add.png" border="0" alt="' . $GLOBALS['messages']['lbl_add_bookmark'] . '" align="absmiddle" />';
    $img_remove = '<img src="' . _EXT_URL . '/images/_remove.png" border="0" alt="' . $GLOBALS['messages']['lbl_remove_bookmark'] . '" align="absmiddle" />';
    $addlink = $removelink = '';
    if (!isset($bookmarks[$dir]) && $dir != '' && $dir != '/') {
        $addlink = '<a href="' . make_link('modify_bookmark', $dir) . '&task=add" onclick="' . 'Ext.Msg.prompt(\'' . ext_Lang::msg('lbl_add_bookmark', true) . '\', \'' . ext_Lang::msg('enter_alias_name', true) . ':\', ' . 'function(btn, text){ ' . 'if (btn == \'ok\') { ' . 'Ext.get(\'bookmark_container\').load({ ' . 'url: \'' . basename($GLOBALS['script_name']) . '\', ' . 'scripts: true, ' . 'params: { ' . 'action:\'modify_bookmark\', ' . 'task: \'add\', ' . 'requestType: \'xmlhttprequest\', ' . 'alias: text, ' . 'dir: \'' . $dir . '\', ' . 'option: \'com_extplorer\' ' . '} ' . '}); ' . '}' . '}); return false;" title="' . $GLOBALS['messages']['lbl_add_bookmark'] . '" >' . $img_add . '</a>';
    } elseif ($dir != '' && $dir != '/') {
        $removelink = '<a href="' . make_link('modify_bookmark', $dir) . '&task=remove" onclick="' . 'Ext.Msg.confirm(\'' . ext_Lang::msg('lbl_remove_bookmark', true) . '\',\'' . ext_Lang::msg('lbl_remove_bookmark', true) . '?\', ' . 'function(btn, text){ ' . 'if (btn == \'yes\') { ' . 'Ext.get(\'bookmark_container\').load({ ' . 'url: \'' . basename($GLOBALS['script_name']) . '\', ' . 'scripts: true, ' . 'params: { ' . 'action:\'modify_bookmark\', ' . 'task: \'remove\', ' . 'dir: \'' . $dir . '\', ' . 'option: \'com_extplorer\' ' . '} ' . '}); ' . '}' . '}); return false;" title="' . $GLOBALS['messages']['lbl_remove_bookmark'] . '">' . $img_remove . '</a>';
    }
    $html .= $addlink . '&nbsp;' . $removelink;
    return $html;
}
Example #6
0
		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() ) {
Example #7
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"]);
        }
        $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 
    }
Example #8
0
    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": "&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'
				}
			});
		}
	},{
		"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
		"handler": function() { Ext.getCmp("dialog").destroy(); }
	}]
}
	
		<?php 
    }
Example #9
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 
    }
Example #10
0
function ext_successBox($msg)
{
    return ext_scriptTag('', 'Ext.msgBoxSlider.msg( \'' . ext_Lang::msg('success', true) . '\', \'' . @mysql_escape_string($msg) . '\' );');
}
Example #11
0
 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);
     }
 }
Example #12
0
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 
}
Example #13
0
/**
 * 
 * Shows eXtplorer information
 */
function show_about()
{
    //$sess = print_r($_SESSION,true);
    //echo str_replace(array("\r", "\n"),array('',''),$sess);
    echo "\n<div id=\"ext_footer\" style=\"text-align:center;\">\n\t<img src=\"" . _EXT_URL . "/images/eXtplorer_logo.png\" align=\"middle\" alt=\"eXtplorer Logo\" />\n\t<br />\n\t" . ext_Lang::msg('your_version') . ": <a href=\"" . $GLOBALS['ext_home'] . "\" target=\"_blank\">eXtplorer {$GLOBALS['ext_version']}</a>\n\t<br />\n (<a href=\"http://extplorer.net/version_check?myVersion=" . $GLOBALS['ext_version'] . "\" onclick=\"javascript:void window.open('http://extplorer.net/version_check?myVersion=" . $GLOBALS['ext_version'] . "', 'win2', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=580,directories=no,location=no'); return false;\" title=\"" . $GLOBALS["messages"]["check_version"] . "\">" . $GLOBALS["messages"]["check_version"] . "</a>)\n\n\t";
    $size = disk_free_space($GLOBALS['home_dir'] . $GLOBALS['separator']);
    $free = parse_file_size($size);
    echo '<br />' . $GLOBALS["messages"]["miscfree"] . ": " . $free . " \n";
    if (extension_loaded("posix")) {
        $owner_info = '<br /><br />' . ext_Lang::msg('current_user') . ' ';
        if (ext_isFTPMode()) {
            $my_user_info = posix_getpwnam($_SESSION['ftp_login']);
            $my_group_info = posix_getgrgid($my_user_info['gid']);
        } else {
            $my_user_info = posix_getpwuid(posix_geteuid());
            $my_group_info = posix_getgrgid(posix_getegid());
        }
        $owner_info .= $my_user_info['name'] . ' (' . $my_user_info['uid'] . '), ' . $my_group_info['name'] . ' (' . $my_group_info['gid'] . ')';
        echo $owner_info;
    }
    echo "\n\t</div>";
}
Example #14
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") {
         $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;
     }
 }
Example #15
0
    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 
    }
Example #16
0
echo str_replace("'", "\\'", $dir);
?>
' );
							
	    				}
	    			}
		}
    });
	Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
	    expires: new Date(new Date().getTime()+(1000*60*60*24*7)) //7 days from now
	}));
		
    <?php 
if ($GLOBALS['require_login'] && $GLOBALS['mainframe']->getUserName() == 'admin' && ($GLOBALS['mainframe']->getPassword() == extEncodePassword('admin') || $GLOBALS['mainframe']->getPassword() == md5('admin'))) {
    // Urge User to change admin password!
    echo 'msgbox = Ext.Msg.alert(\'' . ext_Lang::msg('password_warning_title', true) . '\', \'' . ext_Lang::msg('password_warning_text', true) . '\',
    		function(btn) { if( btn == \'ok\' ) openActionDialog( null, \'admin\') }
    	);
    	msgbox.setIcon(Ext.MessageBox.WARNING);
		';
}
?>
    
}
if( typeof Ext == 'undefined' ) {
	document.location = '<?php 
echo basename($GLOBALS['script_name']);
?>
?option=com_extplorer&nofetchscript=1';
}
Example #17
0
/**
 * This function assembles an array (list) of files or directories in the directory specified by $dir
 * The result array is send using JSON
 *
 * @param string $dir
 * @param string $sendWhat Can be "files" or "dirs"
 */
function send_dircontents($dir, $sendWhat = 'files')
{
    // print table of files
    global $dir_up, $mainframe;
    // make file & dir tables, & get total filesize & number of items
    get_dircontents($dir, $dir_list, $file_list, $tot_file_size, $num_items);
    if ($sendWhat == 'files') {
        $list = $file_list;
    } elseif ($sendWhat == 'dirs') {
        $list = $dir_list;
    } else {
        $list = make_list($dir_list, $file_list);
    }
    $i = 0;
    $items['totalCount'] = count($list);
    $items['items'] = array();
    $dirlist = array();
    if ($sendWhat != 'dirs') {
        // Replaced array_splice, because it resets numeric indexes (like files or dirs with a numeric name)
        // Here we reduce the list to the range of $limit beginning at $start
        $a = 0;
        $output_array = array();
        foreach ($list as $key => $value) {
            if ($a >= $GLOBALS['start'] && $a - $GLOBALS['start'] < $GLOBALS['limit']) {
                $output_array[$key] = $value;
            }
            $a++;
        }
        $list = $output_array;
    }
    while (list($item, $info) = each($list)) {
        // link to dir / file
        if (is_array($info)) {
            $abs_item = $info;
            if (extension_loaded('posix')) {
                $user_info = posix_getpwnam($info['user']);
                $file_info['uid'] = $user_info['uid'];
                $file_info['gid'] = $user_info['gid'];
            }
        } else {
            $abs_item = get_abs_item(ext_TextEncoding::fromUTF8($dir), $item);
            $file_info = @stat($abs_item);
        }
        $is_dir = get_is_dir($abs_item);
        if ($GLOBALS['use_mb']) {
            if (ext_isFTPMode()) {
                $items['items'][$i]['name'] = $item;
            } else {
                if (mb_detect_encoding($item) == 'ASCII') {
                    $items['items'][$i]['name'] = ext_TextEncoding::toUTF8($item);
                } else {
                    $items['items'][$i]['name'] = ext_TextEncoding::toUTF8($item);
                }
            }
        } else {
            $items['items'][$i]['name'] = ext_isFTPMode() ? $item : ext_TextEncoding::toUTF8($item);
        }
        $items['items'][$i]['is_file'] = get_is_file($abs_item);
        $items['items'][$i]['is_archive'] = ext_isArchive($item) && !ext_isFTPMode();
        $items['items'][$i]['is_writable'] = $is_writable = @$GLOBALS['ext_File']->is_writable($abs_item);
        $items['items'][$i]['is_chmodable'] = $is_chmodable = @$GLOBALS['ext_File']->is_chmodable($abs_item);
        $items['items'][$i]['is_readable'] = $is_readable = @$GLOBALS['ext_File']->is_readable($abs_item);
        $items['items'][$i]['is_deletable'] = $is_deletable = @$GLOBALS['ext_File']->is_deletable($abs_item);
        $items['items'][$i]['is_editable'] = get_is_editable($abs_item);
        $items['items'][$i]['icon'] = _EXT_URL . "/images/" . get_mime_type($abs_item, "img");
        $items['items'][$i]['size'] = parse_file_size(get_file_size($abs_item));
        // type
        $items['items'][$i]['type'] = get_mime_type($abs_item, "type");
        // modified
        $items['items'][$i]['modified'] = parse_file_date(get_file_date($abs_item));
        // permissions
        $perms = get_file_perms($abs_item);
        if ($perms) {
            if (strlen($perms) > 3) {
                $perms = substr($perms, 2);
            }
            $items['items'][$i]['perms'] = $perms . ' (' . parse_file_perms($perms) . ')';
        } else {
            $items['items'][$i]['perms'] = ' (unknown) ';
        }
        $items['items'][$i]['perms'] = $perms . ' (' . parse_file_perms($perms) . ')';
        if (extension_loaded("posix")) {
            if ($file_info["uid"]) {
                $user_info = posix_getpwuid($file_info["uid"]);
                //$group_info = posix_getgrgid($file_info["gid"]);
                $items['items'][$i]['owner'] = $user_info["name"] . " (" . $file_info["uid"] . ")";
            } else {
                $items['items'][$i]['owner'] = " (unknown) ";
            }
        } else {
            $items['items'][$i]['owner'] = 'n/a';
        }
        if ($is_dir && $sendWhat != 'files') {
            $id = str_replace('/', $GLOBALS['separator'], $dir) . $GLOBALS['separator'] . $item;
            $id = str_replace($GLOBALS['separator'], '_RRR_', $id);
            $qtip = "<strong>" . ext_Lang::mime('dir', true) . "</strong><br /><strong>" . ext_Lang::msg('miscperms', true) . ":</strong> " . $perms . "<br />";
            $qtip .= '<strong>' . ext_Lang::msg('miscowner', true) . ':</strong> ' . $items['items'][$i]['owner'];
            if ($GLOBALS['use_mb']) {
                if (ext_isFTPMode()) {
                    $dirlist[] = array('text' => htmlspecialchars($item), 'id' => $id, 'qtip' => $qtip, 'is_writable' => $is_writable, 'is_chmodable' => $is_chmodable, 'is_readable' => $is_readable, 'is_deletable' => $is_deletable, 'cls' => 'folder');
                } else {
                    if (mb_detect_encoding($item) == 'ASCII') {
                        $dirlist[] = array('text' => htmlspecialchars(ext_TextEncoding::toUTF8($item)), 'id' => utf8_encode($id), 'qtip' => $qtip, 'is_writable' => $is_writable, 'is_chmodable' => $is_chmodable, 'is_readable' => $is_readable, 'is_deletable' => $is_deletable, 'cls' => 'folder');
                    } else {
                        $dirlist[] = array('text' => htmlspecialchars($item), 'id' => $id, 'qtip' => $qtip, 'is_writable' => $is_writable, 'is_chmodable' => $is_chmodable, 'is_readable' => $is_readable, 'is_deletable' => $is_deletable, 'cls' => 'folder');
                    }
                }
            } else {
                $dirlist[] = array('text' => htmlspecialchars(ext_isFTPMode() ? $item : ext_TextEncoding::toUTF8($item)), 'id' => ext_isFTPMode() ? $id : ext_TextEncoding::toUTF8($id), 'qtip' => $qtip, 'is_writable' => $is_writable, 'is_chmodable' => $is_chmodable, 'is_readable' => $is_readable, 'is_deletable' => $is_deletable, 'cls' => 'folder');
            }
        }
        if (!$is_dir && $sendWhat == 'files' || $sendWhat == 'both') {
            $i++;
        }
    }
    while (@ob_end_clean()) {
    }
    if ($sendWhat == 'dirs') {
        $result = $dirlist;
    } else {
        $result = $items;
    }
    $classname = class_exists('ext_Json') ? 'ext_Json' : 'Services_JSON';
    $json = new $classname();
    echo $json->encode($result);
    ext_exit();
}
Example #18
0
 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);
     }
 }
Example #19
0
    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 
    }
Example #20
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") {
            $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'
				}
			});
		}
	},{
		"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
		"handler": function() { Ext.getCmp("dialog").destroy(); } 
	}]
}
	
	<?php 
    }
Example #21
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"]);
        }
        $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 
    }
Example #22
0
function show_searchform($dir = '')
{
    ?>
{
     "title":"<?php 
    echo $GLOBALS["messages"]["searchlink"];
    ?>
",
     "height":300,
     "autoScroll":true,

     items: new Ext.DataView({
     	"id": "dataview",
         tpl: new Ext.XTemplate(
	        '<tpl for=".">',
	        '<div class="search-item">',
	            '<h3>',
	            '<a onclick="selectFile(\'{dir}\', \'{file}\');Ext.getCmp(\'dialog\').destroy();return false;" href="#" target="_blank">{s_dir}/{file}, {lastModified:date("M j, Y")}</a>',
	            '</h3>',
	        '</div></tpl>'
	    ),
         store: new Ext.data.Store({
		        proxy: new Ext.data.HttpProxy({
		            url: "<?php 
    echo $GLOBALS['script_name'];
    ?>
"
		        }),
		        reader: new Ext.data.JsonReader({
		            root: 'items',
		            totalProperty: 'totalCount',
		            id: 'file_id'
		        }, [			            
		            {name: 'fileId', mapping: 'file_id'},
		            {name: 'file', mapping: 'file'},
		            {name: 'dir', mapping: 'dir'},
		            {name: 's_dir', mapping: 's_dir'},
		            {name: 'lastModified', mapping: 'last_mtime', type: 'date', dateFormat: 'timestamp'}
		        ]),
		        baseParams: {
		        	limit:20, 
		        	option: "com_extplorer",
		        	action:"search",
		        	dir: "<?php 
    echo $dir;
    ?>
",
		        	content: '0',
	        		subdir: '1'
		        }
		    }),
         itemSelector: 'div.search-item'
     }),

     tbar: [
         'Search: ', ' ',
         new Ext.app.SearchField({
             store: Ext.getCmp("dataview").store,
             width:420
         }),' ',' ',' ',
         {	
         	"id": "searchsubdir",
			text: "Subdirs",
			tooltip: "<?php 
    echo ext_Lang::msg('miscsubdirs', true);
    ?>
?",
			name: "subdir",
			"listeners": {
				"toggle": {
					fn: function(btn, pressed) {
							Ext.getCmp("dataview").store.baseParams.subdir = (pressed ? '1' : '0');
					}
				}
			},
			 enableToggle: true,
			 pressed: true
		},' ',' ',' ',{
			
			"id": "searchcontent",
			text: "Content",
			tooltip: "<?php 
    echo ext_Lang::msg('misccontent', true);
    ?>
?",
			name: 'content',
			"listeners": {
				"toggle": {
					fn: function(btn, pressed) {
							Ext.getCmp("dataview").store.baseParams.content = (pressed ? '1' : '0');
							
					}
				}
			},
			 enableToggle: true,
			 pressed: false
		}
     ],

     bbar: new Ext.PagingToolbar({
         store: Ext.getCmp("dataview").store,
         pageSize: 20,
         displayInfo: true,
         displayMsg: 'Results {0} - {1} of {2}',
         emptyMsg: "No files to display"
     })
}

<?php 
}
Example #23
0
function system_info()
{
    $version = $GLOBALS['ext_version'];
    //$tab = extGetParam( $_REQUEST, 'tab', 'tab1' );
    $width = 400;
    // width of 100%
    ?>
	<br />
	<div id="sysinfo">
	<div id="system-page" class="x-tab" title="<?php 
    echo ext_Lang::msg('sisysteminfo');
    ?>
">
	
	<table class="adminform">
	<tr>
		<td valign="top" width="250" style="font-weight:bold;">
		Logged in as:
		</td>
		<td><?php 
    echo $_SESSION['s_user'];
    ?>
</td>
	<tr>
		<td valign="top" width="250" style="font-weight:bold;">
			<?php 
    echo ext_lang::msg('sibuilton');
    ?>
:
		</td>
		<td>
		<?php 
    echo php_uname();
    ?>
		</td>
	</tr>
	<tr>
		<td valign="top" style="font-weight:bold;">
			<?php 
    echo ext_lang::msg('siphpversion');
    ?>
:
		</td>
		<td>
		<?php 
    echo phpversion();
    ?>
		&nbsp;
		<?php 
    echo phpversion() >= '4.3' ? '' : $GLOBALS['messages']['siphpupdate'];
    ?>
		</td>
	</tr>
	<tr>
		<td style="font-weight:bold;">
			<?php 
    echo ext_lang::msg('siwebserver');
    ?>
:
		</td>
		<td>
		<?php 
    echo get_server_software();
    ?>
		</td>
	</tr>
	<tr>
		<td style="font-weight:bold;">
			<?php 
    echo ext_lang::msg('siwebsphpif');
    ?>
:
		</td>
		<td>
		<?php 
    echo php_sapi_name();
    ?>
		</td>
	</tr>
	<tr>
		<td style="font-weight:bold;">
			<?php 
    echo ext_lang::msg('simamboversion');
    ?>
:
		</td>
		<td>
		<?php 
    echo $version;
    ?>
		</td>
	</tr>
	<tr>
		<td style="font-weight:bold;">
			<?php 
    echo ext_lang::msg('siuseragent');
    ?>
:
		</td>
		<td>
		<?php 
    echo phpversion() <= "4.2.1" ? getenv("HTTP_USER_AGENT") : $_SERVER['HTTP_USER_AGENT'];
    ?>
		</td>
	</tr>
	<tr>
		<td valign="top" style="font-weight:bold;">
			<?php 
    echo ext_lang::msg('sirelevantsettings');
    ?>
:
		</td>
		<td>
			<table cellspacing="1" cellpadding="1" border="0">
			<tr>
				<td valign="top">
					<?php 
    echo ext_lang::msg('sisafemode');
    ?>
:
				</td>
				<td>
				<?php 
    echo get_php_setting('safe_mode', 0);
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
    echo ext_lang::msg('sibasedir');
    ?>
:
				</td>
				<td>
				<?php 
    echo ($ob = ini_get('open_basedir')) ? $ob : 'none';
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
    echo ext_lang::msg('sidisplayerrors');
    ?>
:
				</td>
				<td>
				<?php 
    echo get_php_setting('display_errors');
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
    echo ext_lang::msg('sishortopentags');
    ?>
:
				</td>
				<td>
				<?php 
    echo get_php_setting('short_open_tag');
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
    echo ext_lang::msg('sifileuploads');
    ?>
:
				</td>
				<td>
				<?php 
    echo get_php_setting('file_uploads');
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
    echo ext_lang::msg('simagicquotes');
    ?>
:
				</td>
				<td>
				<?php 
    echo get_php_setting('magic_quotes_gpc');
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
    echo ext_lang::msg('siregglobals');
    ?>
:
				</td>
				<td>
				<?php 
    echo get_php_setting('register_globals', 0);
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
    echo ext_lang::msg('sioutputbuf');
    ?>
:
				</td>
				<td>
				<?php 
    echo get_php_setting('output_buffering', 0);
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
    echo ext_lang::msg('sisesssavepath');
    ?>
:
				</td>
				<td>
				<?php 
    echo ($sp = ini_get('session.save_path')) ? $sp : 'none';
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
    echo ext_lang::msg('sisessautostart');
    ?>
:
				</td>
				<td>
				<?php 
    echo intval(ini_get('session.auto_start'));
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
    echo ext_lang::msg('sixmlenabled');
    ?>
:
				</td>
				<td>
					<?php 
    echo extension_loaded('xml') ? '<font style="color: green;">' . $GLOBALS['messages']['miscyesno'][0] . '</font>' : '<font style="color: red;">' . $GLOBALS['messages']['miscyesno'][1] . '</font>';
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
    echo ext_lang::msg('sizlibenabled');
    ?>
:
				</td>
				<td>
				<?php 
    echo extension_loaded('zlib') ? '<font style="color: green;">' . $GLOBALS['messages']['miscyesno'][0] . '</font>' : '<font style="color: red;">' . $GLOBALS['messages']['miscyesno'][1] . '</font>';
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
    echo ext_lang::msg('sidisabledfuncs');
    ?>
:
				</td>
				<td>
				<?php 
    echo ($df = ini_get('disable_functions')) ? $df : 'none';
    ?>
				</td>
			</tr>
			</table>
		</td>
	</tr>
	</table>
	</div>
	<div id="php-page" class="x-tab" title="<?php 
    echo ext_Lang::msg('siphpinfo');
    ?>
">
	<table class="adminform">
	<tr>
		<th colspan="2">
			<?php 
    echo ext_lang::msg('siphpinformation');
    ?>
:
		</th>
	</tr>
	<tr>
		<td>
		<?php 
    ob_start();
    phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES);
    $phpinfo = ob_get_contents();
    ob_end_clean();
    preg_match_all('#<body[^>]*>(.*)</body>#siU', $phpinfo, $output);
    $output = preg_replace('#<table#', '<table class="adminlist" align="center"', $output[1][0]);
    $output = preg_replace('#(\\w),(\\w)#', '\\1, \\2', $output);
    $output = preg_replace('#border="0" cellpadding="3" width="600"#', 'border="0" cellspacing="1" cellpadding="4" width="95%"', $output);
    $output = preg_replace('#<hr />#', '', $output);
    echo $output;
    ?>
		</td>
	</tr>
	</table>
	</div>
	</div>
	<script type="text/javascript">
<!--
var tabs = new Ext.TabPanel( "sysinfo" );
tabs.addTab( "system-page","<?php 
    echo ext_Lang::msg('sisysteminfo');
    ?>
" ); 
tabs.addTab( "php-page","<?php 
    echo ext_Lang::msg('siphpinfo');
    ?>
" ); 
tabs.activate( "system-page" );
//-->
</script>
	<?php 
}
Example #24
0
 static function mime($mime, $make_javascript_safe = false)
 {
     $str = ext_Lang::_get('mimes', $mime);
     if ($make_javascript_safe) {
         return ext_Lang::escape_for_javascript($str);
     } else {
         return $str;
     }
 }
Example #25
0
define("_EXT_PATH", realpath(dirname(__FILE__) . '/../../administrator/components/com_extplorer'));
define("_EXT_URL", $mosConfig_live_site . "/administrator/components/com_extplorer");
require _EXT_PATH . "/application.php";
require _EXT_PATH . "/libraries/File_Operations.php";
require _EXT_PATH . "/include/functions.php";
require _EXT_PATH . "/include/header.php";
require _EXT_PATH . "/include/result.class.php";
if (!class_exists('InputFilter')) {
    require_once _EXT_PATH . '/libraries/inputfilter.php';
}
$GLOBALS['ERROR'] = '';
$GLOBALS['__GET'] =& $_GET;
$GLOBALS['__POST'] =& $_POST;
$GLOBALS['__SERVER'] =& $_SERVER;
$GLOBALS['__FILES'] =& $_FILES;
$default_lang = !empty($GLOBALS['mosConfig_lang']) ? $GLOBALS['mosConfig_lang'] : ext_Lang::detect_lang();
echo $default_lang;
if (file_exists(_EXT_PATH . "/languages/{$default_lang}.php")) {
    require _EXT_PATH . "/languages/{$default_lang}.php";
} else {
    require _EXT_PATH . "/languages/english.php";
}
if (file_exists(_EXT_PATH . "/languages/" . $default_lang . "_mimes.php")) {
    require _EXT_PATH . "/languages/" . $default_lang . "_mimes.php";
} else {
    require _EXT_PATH . "/languages/english_mimes.php";
}
require _EXT_PATH . "/config/mimes.php";
// the filename of the QuiXplorer script: (you rarely need to change this)
if ($_SERVER['SERVER_PORT'] == 443) {
    $GLOBALS["script_name"] = "https://" . $GLOBALS['__SERVER']['HTTP_HOST'] . $GLOBALS['__SERVER']["PHP_SELF"];
Example #26
0
function show_userform($data = null)
{
    if ($data == null) {
        $data = array('', '', '', '', '', '', '');
    }
    ?>
	<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;"><?php 
    if (!empty($data[0])) {
        echo $GLOBALS["messages"]["actadmin"] . ": " . sprintf($GLOBALS["messages"]["miscedituser"], $data[0]);
    } else {
        echo $GLOBALS["messages"]["actadmin"] . ": " . $GLOBALS["messages"]["miscadduser"];
    }
    ?>
</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 yesno = new Ext.data.SimpleStore({
	    fields: ['yesno', 'Yes_No'],
	    data :  [
	        ['1', '<?php 
    echo ext_Lang::msg(array('miscyesno' => 0), true);
    ?>
'],
	        ['0', '<?php 
    echo ext_Lang::msg(array('miscyesno' => 1), true);
    ?>
']
	        ]
	});
	var permvalues = new Ext.data.SimpleStore({
		fields: ['value', 'text'],
		data: [
	
	<?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 ',';
        }
    }
    ?>
	]});
	var userform = new Ext.form.Form({
	    labelWidth: 125, // label settings here cascade unless overridden
	    url:'<?php 
    echo basename($GLOBALS['script_name']);
    ?>
'
	});

	
	userform.add(
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
    echo ext_Lang::msg('miscusername', true);
    ?>
',
	        name: 'nuser',
	        value: '<?php 
    echo @$data[0];
    ?>
',
	        width:175,
	        allowBlank:false
	    }),
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
    echo ext_Lang::msg('miscconfpass', true);
    ?>
',
	        name: 'pass1',
	        inputType: 'password',
	        width:175
	    }),
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
    echo ext_Lang::msg('miscconfnewpass', true);
    ?>
',
	        name: 'pass2',
	        inputType: 'password',
	        width:175
	    }),
	    <?php 
    if (!empty($data[0])) {
        ?>
		    new Ext.form.Checkbox({
		        fieldLabel: '<?php 
        echo ext_Lang::msg('miscchpass', true);
        ?>
',
		        name: 'chpass',
		        hiddenValue: 'true'
			}),
			<?php 
    }
    ?>
	    
	    new Ext.form.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
	    }),	    
	    new Ext.form.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
	    }),		
		new Ext.form.ComboBox({
			fieldLabel: '<?php 
    echo ext_Lang::msg('miscshowhidden', true);
    ?>
',
		    store: yesno,
		    displayField:'Yes_No',
		    valueField: 'yesno',
		    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
		}),
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
    echo ext_Lang::msg('mischidepattern', true);
    ?>
',
	        name: 'no_access',
	        value: '<?php 
    echo @$data[5];
    ?>
',
	        width:175,
	        allowBlank:true
	    }),
	
		new Ext.form.ComboBox({
			fieldLabel: '<?php 
    echo ext_Lang::msg('miscperms', true);
    ?>
',
		    store: permvalues,
		    valueField: 'value',
		    displayField:'text',
		    hiddenName: 'permissions',
		    disableKeyFilter: true,
		    value: '<?php 
    echo (int) @$data[6];
    ?>
',
		    editable: false,
		    triggerAction: 'all',
		    mode: 'local'
		}),
		new Ext.form.ComboBox({
			fieldLabel: '<?php 
    echo ext_Lang::msg('miscactive', true);
    ?>
',
		    store: yesno,
		    displayField:'Yes_No',
		    valueField: 'yesno',
		    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
		})
	);
	userform.addButton('<?php 
    echo ext_Lang::msg('btnsave', true);
    ?>
', function() {
		if( !check_pwd()) return;
		statusBarMessage( 'Please wait...', true );
	    userform.submit({
	        success: function(form, action) {	
	        	statusBarMessage( action.result.message, false, true );
				dialog_panel.load({ url: '<?php 
    echo make_link('admin', '');
    ?>
' });
	        },
	        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', 
	        		user: '******',
	        		action: 'admin', 
	        		action2: '<?php 
    echo @$data[0] ? 'edituser' : 'adduser';
    ?>
',
	        		confirm: 'true'
	        }
	    })
	});
	userform.addButton('<?php 
    echo ext_Lang::msg('btncancel', true);
    ?>
', 
		function() { 
			dialog_panel.load({ url: '<?php 
    echo make_link('admin', '');
    ?>
' });
		} 
	);
	userform.render('adminForm');
	</script>
	<?php 
}
Example #27
0
function login()
{
    global $auth, $authentication_type;
    if (!is_object($auth)) {
        return false;
    }
    if (!empty($GLOBALS['__POST']['username']) || !empty($_SESSION['credentials_' . $authentication_type])) {
        if (!empty($GLOBALS['__POST']['username'])) {
            $username = $GLOBALS['__POST']['username'];
            $password = $GLOBALS['__POST']['password'];
        } else {
            $username = $_SESSION['credentials_' . $authentication_type]['username'];
            $password = $_SESSION['credentials_' . $authentication_type]['password'];
        }
        $res = $auth->onAuthenticate(array('username' => $username, 'password' => $password));
        if (!PEAR::isError($res) && $res !== false) {
            if (@$GLOBALS['__POST']['action'] == 'login' && ext_isXHR()) {
                session_write_close();
                ext_Result::sendResult('login', true, ext_Lang::msg('actlogin_success'));
            }
            return true;
        } else {
            if ($authentication_type == 'extplorer') {
                // Second attempt to authenticate, since we've switched password hashing algorithm
                // now we fall back to md5 hashing.
                $password = md5((string) $GLOBALS['__POST']['password']);
                $res = $auth->onAuthenticate(array('username' => $username, 'password' => $password));
                if (!PEAR::isError($res) && $res !== false) {
                    if (@$GLOBALS['__POST']['action'] == 'login' && ext_isXHR()) {
                        session_write_close();
                        ext_Result::sendResult('login', true, ext_Lang::msg('actlogin_success'));
                    }
                    return true;
                }
            }
            if (ext_isXHR()) {
                $errmsg = PEAR::isError($res) ? $res->getMessage() : ext_Lang::msg('actlogin_failure');
                ext_Result::sendResult('login', false, $errmsg);
            }
            return false;
        }
    }
    if (ext_isXHR() && $GLOBALS['action'] != 'login') {
        echo '<script type="text/javascript>document.location="' . _EXT_URL . '/index.php";</script>';
        exit;
    }
    session_write_close();
    session_id(get_session_id());
    session_start();
    // Ask for Login
    $GLOBALS['mainframe']->setPageTitle(ext_Lang::msg('actlogin'));
    $GLOBALS['mainframe']->addcustomheadtag('
		<script type="text/javascript" src="scripts/extjs3/adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="scripts/extjs3/ext-all.js"></script>
		<script type="text/javascript" src="' . $GLOBALS['script_name'] . '?option=com_extplorer&amp;action=include_javascript&amp;file=functions.js"></script>
		<link rel="stylesheet" href="' . _EXT_URL . '/scripts/extjs3/resources/css/ext-all.css" />
		<link rel="stylesheet" href="scripts/extjs3/resources/css/xtheme-blue.css" />');
    ?>
		<div style="width: 400px;" id="formContainer">
			<div id="ext_logo" style="text-align:center;">
			<a href="http://extplorer.net" target="_blank">
				<img src="<?php 
    echo _EXT_URL;
    ?>
/images/eXtplorer-horizontal2.png" align="middle" alt="eXtplorer Logo" style="border:none;" />
			</a>
			</div>
			<noscript>
				<div style="width:400px;text-align:center;">
					<h1>eXtplorer Login</h1>
					<p style="color:red;">Oh, Javascript is disabled!</p>
					<p>Find out <a target="_blank" href="https://www.google.com/adsense/support/bin/answer.py?hl=en&answer=12654">how you can enable Javascript in your browser.</a>
					</p>
				</div>
			</noscript>
			<div id="adminForm"></div>
			
	</div>
	<script type="text/javascript">
Ext.onReady( function() {
	var simple = new Ext.FormPanel(<?php 
    $auth->onShowLoginForm();
    ?>
);
	
	Ext.get( 'formContainer').center();
	Ext.get( 'formContainer').setTop(100);
	simple.getForm().findField('username').focus();
	Ext.EventManager.onWindowResize( function() { Ext.get( 'formContainer').center();Ext.get( 'formContainer').setTop(100); } );
});
</script><?php 
    define('_LOGIN_REQUIRED', 1);
}
Example #28
0
    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 
        }
    }
Example #29
0
    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", "&nbsp;&nbsp;&nbsp;&nbsp;", htmlentities($content)));
            //$content2 = nl2br(str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;", 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 
    }
Example #30
0
    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 
    }