Project

General

Profile

Revision 41

View differences:

tags/joomlaxplorer-1.6.1-released/joomlaxplorer.php
1
<?php
2
// ensure this file is being included by a parent file
3
if( !defined( '_JEXEC' ) && !defined( '_VALID_MOS' ) ) die( 'Restricted access' );
4
/**
5
 * @version $Id: $
6
 * @package joomlaXplorer
7
 * @copyright soeren 2007
8
 * @author The joomlaXplorer project (http://joomlacode.org/gf/project/joomlaxplorer/)
9
 * @author The  The QuiX project (http://quixplorer.sourceforge.net)
10
 * @license
11
 * The contents of this file are subject to the Mozilla Public License
12
 * Version 1.1 (the "License"); you may not use this file except in
13
 * compliance with the License. You may obtain a copy of the License at
14
 * http://www.mozilla.org/MPL/
15
 * 
16
 * Software distributed under the License is distributed on an "AS IS"
17
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
18
 * License for the specific language governing rights and limitations
19
 * under the License.
20
 * 
21
 * Alternatively, the contents of this file may be used under the terms
22
 * of the GNU General Public License Version 2 or later (the "GPL"), in
23
 * which case the provisions of the GPL are applicable instead of
24
 * those above. If you wish to allow use of your version of this file only
25
 * under the terms of the GPL and not to allow others to use
26
 * your version of this file under the MPL, indicate your decision by
27
 * deleting  the provisions above and replace  them with the notice and
28
 * other provisions required by the GPL.  If you do not delete
29
 * the provisions above, a recipient may use your version of this file
30
 * under either the MPL or the GPL."
31
 * 
32
*/
33

  
34
require( $mosConfig_absolute_path.'/components/com_joomlaxplorer/configuration.jx.php' );
35

  
36
if( !$frontend_enabled || empty( $subdir ) || $subdir == '/' || $subdir == '\\' ) {
37
	echo _NOT_EXIST;
38
	return;
39
}
40

  
41
$GLOBALS["home_dir"] = $mosConfig_absolute_path . $subdir;
42
// the url corresponding with the home directory: (no trailing '/')
43
$GLOBALS["home_url"] = $mosConfig_live_site.'/downloads';
44

  
45
require( $mosConfig_absolute_path.'/components/com_joomlaxplorer/joomlaxplorer.init.php');
46
include( $mosConfig_absolute_path.'/components/com_joomlaxplorer/joomlaxplorer.list.php');
47

  
48
if( !empty($GLOBALS['ERROR'])) {
49
	echo '<h2>'.$GLOBALS['ERROR'].'</h2>';
50
	return;
51
}
52

  
53
$database->setQuery( 'SELECT id, name FROM `#__menu` WHERE link LIKE \'%option=com_joomlaxplorer%\' ORDER BY `id` LIMIT 1');
54
$database->loadObject( $res );
55
if( is_object( $res )) {
56
	$name = $res->name;
57
}
58
else {
59
	$name = '';
60
}
61

  
62
if( $name || $dir ) {
63
	$mainframe->setPageTitle( $name.' - '.$dir );
64
}
65
$action = mosGetParam( $_REQUEST, 'action', 'list');
66
$item = mosGetParam( $_REQUEST, 'item', '');
67

  
68
// Here we allow *download* and *directory listing*, nothing more, nothing less
69
switch( $action ) {
70
	case 'download':
71
		require _QUIXPLORER_PATH . "/include/fun_down.php";
72
	  	@ob_end_clean(); // get rid of cached unwanted output
73
	  	download_item($dir, $item);
74
	  	ob_start(false); // prevent unwanted output
75
	  	exit;
76
	case 'list':
77
	default:
78
		list_dir($dir);
79
		break;
80
}
81

  
82
// A small nice footer. Remove if you don't want to give credit to the developer.
83
echo '<br style="clear:both;"/>
84
	<small>
85
	<a class="title" href="'.$GLOBALS['jx_home'].'" target="_blank">powered by joomlaXplorer</a>
86
	</small>
87
	';
88
	
89
?>
0 90

  
tags/joomlaxplorer-1.6.1-released/include/fun_archive.php
1
<?php
2
// ensure this file is being included by a parent file
3
if( !defined( '_JEXEC' ) && !defined( '_VALID_MOS' ) ) die( 'Restricted access' );
4
/**
5
 * @package joomlaXplorer
6
 * @copyright soeren 2007
7
 * @author The joomlaXplorer project (http://joomlacode.org/gf/project/joomlaxplorer/)
8
 * @author The  The QuiX project (http://quixplorer.sourceforge.net)
9
 * @license
10
 * @version $Id: $
11
 * The contents of this file are subject to the Mozilla Public License
12
 * Version 1.1 (the "License"); you may not use this file except in
13
 * compliance with the License. You may obtain a copy of the License at
14
 * http://www.mozilla.org/MPL/
15
 * 
16
 * Software distributed under the License is distributed on an "AS IS"
17
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
18
 * License for the specific language governing rights and limitations
19
 * under the License.
20
 * 
21
 * Alternatively, the contents of this file may be used under the terms
22
 * of the GNU General Public License Version 2 or later (the "GPL"), in
23
 * which case the provisions of the GPL are applicable instead of
24
 * those above. If you wish to allow use of your version of this file only
25
 * under the terms of the GPL and not to allow others to use
26
 * your version of this file under the MPL, indicate your decision by
27
 * deleting  the provisions above and replace  them with the notice and
28
 * other provisions required by the GPL.  If you do not delete
29
 * the provisions above, a recipient may use your version of this file
30
 * under either the MPL or the GPL."
31
 * 
32
*/
33

  
34
/**
35
 * Zip & TarGzip Functions
36
 */
37

  
38

  
39
function archive_items( $dir ) {
40
	global $mosConfig_absolute_path;
41
	if(($GLOBALS["permissions"]&01)!=01) show_error($GLOBALS["error_msg"]["accessfunc"]);
42
	if(!$GLOBALS["zip"] && !$GLOBALS["tgz"]) show_error($GLOBALS["error_msg"]["miscnofunc"]);
43
	
44
	$allowed_types = array( 'zip', 'tgz', 'tbz', 'tar' );
45
	$actionURL = str_replace("index2.php", "index3.php", make_link("arch",$dir,NULL));
46
	
47
	// If we have something to archive, let's do it now
48
	if(isset($GLOBALS['__POST']["name"])) {
49
		$saveToDir = $GLOBALS['__POST']['saveToDir'];
50
		if( !file_exists( get_abs_dir($saveToDir ) )) {
51
			echo jx_scriptTag('', '$(\'loadingindicator\').style.display=\'none\';');
52
			echo jx_alertBox('The Save-To Directory you have specified does not exist.');
53
			die('The Save-To Directory you have specified does not exist.');
54
		}
55
		if( !is_writable( get_abs_dir($saveToDir ) )) {
56
			echo jx_scriptTag('', '$(\'loadingindicator\').style.display=\'none\';');
57
			echo jx_alertBox('Please specify a writable directory to save the archive to.');
58
			die('Please specify a writable directory to save the archive to.');
59
		}
60
		require_once( _QUIXPLORER_PATH .'/libraries/Archive.php' );
61
		
62
		if( !in_array(strtolower( $GLOBALS['__POST']["type"] ), $allowed_types )) {
63
			echo('Unknown Archive Format: '.htmlspecialchars($GLOBALS['__POST']["type"]));
64
			jx_exit();
65
		}
66
		while( @ob_end_clean() );
67
		header('Status: 200 OK');
68
		echo '<?xml version="1.0" ?>'."\n";
69
		
70
		$files_per_step = 2500;
71
		
72
		$cnt=count($GLOBALS['__POST']["selitems"]);
73
		$abs_dir=get_abs_dir($dir);
74
		$name=basename(stripslashes($GLOBALS['__POST']["name"]));
75
		if($name=="") show_error($GLOBALS["error_msg"]["miscnoname"]);
76
		
77
		$download = mosGetParam( $_REQUEST, 'download', "n" );
78
		$startfrom = mosGetParam( $_REQUEST, 'startfrom', 0 );
79
		
80
		$archive_name = get_abs_item($saveToDir,$name);
81
		$fileinfo = pathinfo( $archive_name );
82
		if( empty( $fileinfo['extension'] )) {
83
			$archive_name .= ".".$GLOBALS['__POST']["type"];
84
			$fileinfo['extension'] = $GLOBALS['__POST']["type"];
85
		}
86
		foreach( $allowed_types as $ext ) {
87
			if( $GLOBALS['__POST']["type"] == $ext && @$fileinfo['extension'] != $ext ) {
88
				$archive_name .= ".".$ext;
89
			}
90
		}
91
		
92
		for($i=0;$i<$cnt;$i++) {
93
			
94
			$selitem=stripslashes($GLOBALS['__POST']["selitems"][$i]);
95
			
96
			if( is_dir( $abs_dir ."/". $selitem )) {
97
				$items = mosReadDirectory($abs_dir ."/".  $selitem, '.', true, true );
98
				foreach ( $items as $item ) {
99
					if( is_dir( $item ) || !is_readable( $item ) || $item == $archive_name ) continue;
100
					$v_list[] = $item;
101
				}
102
			}
103
			else {
104
				$v_list[] = $abs_dir ."/". $selitem;
105
			}
106
		}
107
		$cnt_filelist = count( $v_list );
108
		$remove_path = $GLOBALS["home_dir"];
109
		if( $dir ) {
110
			$remove_path .= $dir.$GLOBALS['separator'];
111
		}
112
		for( $i=$startfrom;$i < $cnt_filelist && $i < ($startfrom + $files_per_step); $i++ ) {
113
			
114
			$filelist[] = File_Archive::read( $v_list[$i], str_replace($remove_path, '', $v_list[$i] ) );
115

  
116
		}
117
		//echo '<strong>Starting from: '.$startfrom.'</strong><br />';
118
		//echo '<strong>Files to process: '.$cnt_filelist.'</strong><br />';
119
		//print_r( $filelist );exit;
120
		
121
		// Do some setup stuff
122
		ini_set('memory_limit', '128M');
123
		@set_time_limit( 0 );
124
		error_reporting( E_ERROR | E_PARSE );		
125
		
126
		$result = File_Archive::extract( $filelist, $archive_name );
127
		
128
		if( PEAR::isError( $result ) ) {
129
			echo $name.": Failed saving Archive File. Error: ".$result->getMessage();
130
			jx_exit();
131
		}
132
		
133
		if( $cnt_filelist > $startfrom+$files_per_step ) {
134
			echo "\n <script type=\"text/javascript\">document.archform.startfrom.value = '".( $startfrom + $files_per_step )."';</script>\n";
135
			echo '<script type="text/javascript"> doArchiving( \''.$actionURL.'\' );</script>';
136
			printf( $GLOBALS['messages']['processed_x_files'], $startfrom + $files_per_step, $cnt_filelist );
137
		}
138
		else {
139
			if( $GLOBALS['__POST']["type"] == 'tgz' || $GLOBALS['__POST']["type"] == 'tbz') {
140
				chmod( $archive_name, 0644 );
141
			}
142
		  	if( $download=="y" ) {
143
				echo '<script type="text/javascript">document.location=\''.make_link( 'download', dirname($archive_name), basename($archive_name) ).'\';</script>';
144
		  	}
145
		  	else {
146
		  		echo '<script type="text/javascript">document.location=\''.str_replace("index3.php", "index2.php", make_link("list",$dir,NULL)).'&mosmsg=The%20Archive%20File%20has%20been%20created\';</script>';
147
		  	}
148
		}
149
		jx_exit();
150
	}
151
	?>
152
	<script type="text/javascript" src="components/com_joomlaxplorer/scripts/functions.js"></script>
153
	<script type="text/javascript">
154
	function doArchiving( url ) {
155
		showLoadingIndicator( $('loadingindicator'), true );
156
		$('loadingindicator').style.display = '';
157
		
158
		var controller = new Ajax( url, { 	postBody: $('adminform'),
159
											evalScripts: true,
160
											update: 'statustext' 
161
											} 
162
								);
163
		controller.request();
164
		return false;
165
	}</script>
166
	<?php
167
	show_header($GLOBALS["messages"]["actarchive"]);
168
	?><br/>
169
	
170
	<form name="archform" method="post" action="<?php echo $actionURL ?>" onsubmit="return doArchiving(this.action);" id="adminform">
171
	
172
	<input type="hidden" name="no_html" value="1" />
173
	<input type="hidden" name="startfrom" value="0" />
174
	<?php
175
	$cnt=count($GLOBALS['__POST']["selitems"]);
176
	for($i=0;$i<$cnt;++$i) {
177
		echo '<input type="hidden" name="selitems[]" value="'.stripslashes($GLOBALS['__POST']["selitems"][$i]).'">';
178
	}
179
	
180
	?>
181
	<table class="adminform" style="width:600px;">
182
		<tr><td colspan="2" style="text-align:center;display:none;" id="loadingindicator"><strong><?php echo $GLOBALS['messages']['creating_archive'] ?></strong></td></tr>
183
		<tr><td colspan="2" style="font-weight:bold;text-align:center" id="statustext">&nbsp;</td></tr>
184
		<tr><td><?php echo $GLOBALS['messages']['archive_name'] ?>:</td>
185
			<td align="left">
186
				<input type="text" name="name" size="25" value="<?php echo ( $dir != '' ? basename($dir) : $GLOBALS['__POST']["selitems"][0] ) ?>" />
187
			</td>
188
		</tr>
189
		<tr><td><?php echo $GLOBALS["messages"]["typeheader"] ?>:</td>
190
			<td align="left">
191
				<select name="type">
192
				<?php
193
				if(extension_loaded("zlib")) {
194
				  echo '<option value="zip">Zip ('.$GLOBALS["messages"]['normal_compression'].')</option>'."\n";
195
				  echo '<option value="tgz">Tar/Gz ('.$GLOBALS["messages"]['good_compression'].')</option>'."\n";
196
				}
197
				if(extension_loaded("bz2")) {
198
					echo '<option value="tbz">Tar/Bzip2 ('.$GLOBALS["messages"]['best_compression'].')</option>'."\n";
199
				}
200
				echo '<option value="" disabled="disabled"> - - - - - - -</option>'."\n";
201
				echo '<option value="tar">Tar ('.$GLOBALS["messages"]['no_compression'].')</option>'."\n";
202
				?>
203
				</select>
204
			</td>
205
		</tr>
206
		<tr><td><?php echo $GLOBALS['messages']['archive_saveToDir'] ?>:</td>
207
			<td align="left">
208
				<input type="text" name="saveToDir" size="50" value="<?php echo $dir ?>" />
209
			</td>
210
		</tr>
211
		<tr><td><?php echo $GLOBALS["messages"]["downlink"] ?>?:</td>
212
			<td align="left">
213
				<input type="checkbox" checked="checked" name="download" value="y" />
214
			</td>
215
		</tr>
216
		<tr>
217
			<td colspan="2" style="text-align:center;">
218
				<input type="submit" value="<?php echo $GLOBALS["messages"]["btncreate"] ?>">
219
				<input type="button" value="<?php echo $GLOBALS["messages"]["btncancel"] ?>" onclick="javascript:location='<?php echo make_link("list",$dir,NULL) ?>';">
220
			</td>
221
		</tr>
222
		<tr><td colspan="2">&nbsp;</td></tr>
223
	</table>
224
	</form>
225
	<br/>
226
	<script type="text/javascript">if(document.archform) document.archform.name.focus();</script>
227
	<?php
228
}
229

  
230
function extract_item( $dir, $item ) {
231
  global $mosConfig_absolute_path;
232
  
233
  if( !jx_isArchive( $item )) {
234
	show_error($GLOBALS["error_msg"]["extract_noarchive"]);
235
  }
236
  else {
237
		$archive_name = realpath(get_abs_item($dir,$item));
238

  
239
		$file_info = pathinfo($archive_name);
240

  
241
		if( empty( $dir )) {
242
			$extract_dir = realpath($GLOBALS['home_dir']);
243
		}
244
		else {
245
			$extract_dir = realpath( $GLOBALS['home_dir']."/".$dir );
246
		}
247

  
248
		$ext = $file_info["extension"];
249

  
250
		require_once(_QUIXPLORER_PATH . "/libraries/Archive.php");
251
		$archive_name .= '/';
252
		$result = File_Archive::extract( $archive_name, $extract_dir );
253
		if( PEAR::isError( $result )) {
254
			show_error($GLOBALS["error_msg"]["extract_failure"]);
255
		}
256
	  }
257
  
258
	  mosRedirect( make_link("list", $dir, null), $GLOBALS['messages']['extract_success'] );
259
}
260
//------------------------------------------------------------------------------
261
?>
0 262

  
tags/joomlaxplorer-1.6.1-released/include/error.php
1
<?php
2
/** ensure this file is being included by a parent file */
3
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
4
/*------------------------------------------------------------------------------
5
     The contents of this file are subject to the Mozilla Public License
6
     Version 1.1 (the "License"); you may not use this file except in
7
     compliance with the License. You may obtain a copy of the License at
8
     http://www.mozilla.org/MPL/
9

  
10
     Software distributed under the License is distributed on an "AS IS"
11
     basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
12
     License for the specific language governing rights and limitations
13
     under the License.
14

  
15
     The Original Code is error.php, released on 2003-02-21.
16

  
17
     The Initial Developer of the Original Code is The QuiX project.
18

  
19
     Alternatively, the contents of this file may be used under the terms
20
     of the GNU General Public License Version 2 or later (the "GPL"), in
21
     which case the provisions of the GPL are applicable instead of
22
     those above. If you wish to allow use of your version of this file only
23
     under the terms of the GPL and not to allow others to use
24
     your version of this file under the MPL, indicate your decision by
25
     deleting  the provisions above and replace  them with the notice and
26
     other provisions required by the GPL.  If you do not delete
27
     the provisions above, a recipient may use your version of this file
28
     under either the MPL or the GPL."
29
------------------------------------------------------------------------------*/
30
/*------------------------------------------------------------------------------
31
Author: The QuiX project
32
	quix@free.fr
33
	http://www.quix.tk
34
	http://quixplorer.sourceforge.net
35
	
36
Comment:
37
	QuiXplorer Version 2.3
38
	Error Reporting File
39
	
40
	Have Fun...
41
------------------------------------------------------------------------------*/
42
//------------------------------------------------------------------------------
43
function add_message($message, $type='general') {
44
	$_SESSION['jx_message'][$type][] = $message;
45
}
46
function empty_messages() {
47
	$_SESSION['jx_message'] = array();
48
}
49
function count_messages() {
50
	$count = 0;
51
	if( empty( $_SESSION['jx_message'] )) {
52
		return 0;
53
	}
54
	foreach( $_SESSION['jx_message'] as $type ) {
55
		if( !empty( $type ) && is_array( $type )) {
56
			$count += sizeof( $type );
57
		}
58
	}
59
	return $count;
60
}
61
function add_error($error, $type='general') {
62
	$_SESSION['jx_error'][$type][] = $error;
63
}
64
function empty_errors() {
65
	$_SESSION['jx_error'] = array();
66
}
67
function count_errors() {
68
	$count = 0;
69
	
70
	if( empty( $_SESSION['jx_error'] )) {
71
		return 0;
72
	}
73
	foreach( $_SESSION['jx_error'] as $type ) {
74
		if( !empty( $type ) && is_array( $type )) {
75
			$count += sizeof( $type );
76
		}
77
	}
78
	return $count;
79
}
80
function show_error($error,$extra=NULL) {		// show error-message
81
	
82
	$msg = $error;
83
	if($extra != NULL) {
84
		$msg .= " - ".$extra;
85
	}
86
	add_error( $msg );
87
	
88
	if( empty( $_GET['error'] )) {
89
		session_write_close();
90
		mosRedirect( make_link("show_error", $GLOBALS["dir"]).'&error=1&extra='.urlencode( $extra ));
91
	}
92
	else {
93
		show_header($GLOBALS["error_msg"]["error"]);
94
		$errors = count_errors();
95
		$messages = count_messages();
96
		echo '<div class="quote">';
97
		if( $errors ) {
98
			echo '<a href="#errors">'. $errors.' '.$GLOBALS["error_msg"]["error"].'</a><br />';
99
		}
100
		if( $messages ) {
101
			echo '<a href="#messages">'.$messages .' '.$GLOBALS["error_msg"]["message"].'</a><br />';
102
		}
103
		echo "</div>\n";
104
		
105
		if( !empty( $_SESSION['jx_message'])) {
106
			echo "<a href=\"".str_replace('&dir=', '&ignore=', make_link("list", '' ))."\">[ "
107
					.$GLOBALS["error_msg"]["back"]." ]</a>";
108
					
109
			echo "<div class=\"jx_message\"><a name=\"messages\"></a>
110
					<h3>".$GLOBALS["error_msg"]["message"].":</strong>"."</h3>\n";
111
			
112
			foreach ( $_SESSION['jx_message'] as $msgtype ) {
113
				foreach ( $msgtype as $message ) {
114
					echo $message ."\n<br/>";
115
				}
116
				echo '<br /><hr /><br />';
117
			}
118
			empty_messages();
119
			
120
			if( !empty( $_REQUEST['extra'])) echo " - ".urldecode($_REQUEST['extra']);
121
			echo "</div>\n";
122
		}
123
		
124
		
125
		echo "<div class=\"jx_error\"><a name=\"errors\"></a>
126
				<h3>".$GLOBALS["error_msg"]["error"].":</strong>"."</h3>\n";
127
		
128
		foreach ( $_SESSION['jx_error'] as $errortype ) {
129
			foreach ( $errortype as $error ) {
130
				echo $error ."\n<br/>";
131
			}
132
			echo '<br /><hr /><br />';
133
		}
134
		empty_errors();
135
		
136
		echo "<a href=\"".str_replace('&dir=', '&ignore=', make_link("list", '' ))."\">".$GLOBALS["error_msg"]["back"]."</a>";
137
		if( !empty( $_REQUEST['extra'])) echo " - ".urldecode($_REQUEST['extra']);
138
		echo "</div>\n";
139
		
140
	}
141
}
142
//------------------------------------------------------------------------------
143
?>
0 144

  
tags/joomlaxplorer-1.6.1-released/include/fun_extra.php
1
<?php
2
// ensure this file is being included by a parent file
3
if( !defined( '_JEXEC' ) && !defined( '_VALID_MOS' ) ) die( 'Restricted access' );
4
/**
5
 * @version $Id: $
6
 * @package joomlaXplorer
7
 * @copyright soeren 2007
8
 * @author The joomlaXplorer project (http://joomlacode.org/gf/project/joomlaxplorer/)
9
 * @author The  The QuiX project (http://quixplorer.sourceforge.net)
10
 * 
11
 * @license
12
 * The contents of this file are subject to the Mozilla Public License
13
 * Version 1.1 (the "License"); you may not use this file except in
14
 * compliance with the License. You may obtain a copy of the License at
15
 * http://www.mozilla.org/MPL/
16
 * 
17
 * Software distributed under the License is distributed on an "AS IS"
18
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
19
 * License for the specific language governing rights and limitations
20
 * under the License.
21
 * 
22
 * Alternatively, the contents of this file may be used under the terms
23
 * of the GNU General Public License Version 2 or later (the "GPL"), in
24
 * which case the provisions of the GPL are applicable instead of
25
 * those above. If you wish to allow use of your version of this file only
26
 * under the terms of the GPL and not to allow others to use
27
 * your version of this file under the MPL, indicate your decision by
28
 * deleting  the provisions above and replace  them with the notice and
29
 * other provisions required by the GPL.  If you do not delete
30
 * the provisions above, a recipient may use your version of this file
31
 * under either the MPL or the GPL."
32
 * 
33
 */
34

  
35
/**
36
 * THESE ARE NUMEROUS HELPER FUNCTIONS FOR THE OTHER INCLUDE FILES
37
 */
38

  
39
$GLOBALS['isWindows'] = substr(PHP_OS, 0, 3) == 'WIN';
40

  
41
function make_link($_action,$_dir,$_item=NULL,$_order=NULL,$_srt=NULL,$languages=NULL) {
42
	// make link to next page
43
	if($_action=="" || $_action==NULL) $_action="list";
44
	//if($_dir=="") $_dir=NULL;
45
	if($_item=="") $_item=NULL;
46
	if($_order==NULL) $_order=$GLOBALS["order"];
47
	if($_srt==NULL) $_srt=$GLOBALS["srt"];
48
	if($languages==NULL) $languages=(isset($GLOBALS["lang"])?$GLOBALS["lang"]:NULL);
49
	
50
	$link=$GLOBALS["script_name"]."?option=com_joomlaxplorer&action=".$_action;
51
	$link.="&dir=".urlencode($_dir);
52
	if($_item!=NULL) $link.="&item=".urlencode($_item);
53
	if($_order!=NULL) $link.="&order=".$_order;
54
	if($_srt!=NULL) $link.="&srt=".$_srt;
55
	if($languages!=NULL) $link.="&lang=".$languages;
56
	
57
	return $link;
58
}
59
//------------------------------------------------------------------------------
60
function get_abs_dir($dir) {			// get absolute path
61
	if( jx_isFTPMode() ) {
62
		if( $dir != '' && $dir[0] != '/' ) {
63
			$dir = '/'.$dir;
64
		}
65
		return $dir;
66
	}
67
	$abs_dir=$GLOBALS["home_dir"];
68
	
69
	if($dir!="" && !stristr( $dir, $abs_dir )) $abs_dir.="/".$dir;
70
	elseif(stristr( $dir, $abs_dir )) $abs_dir = "/".$dir;
71
	/*else {
72
		$abs_dir = $dir;
73
	}*/
74
	$realpath = realpath($abs_dir);
75
	/*if( $realpath == '') {
76
		return $abs_dir;
77
	}
78
	else {
79
		return $realpath;
80
	}*/
81
	
82
	return $realpath;
83
}
84
//------------------------------------------------------------------------------
85
function get_abs_item($dir, $item) {		// get absolute file+path
86
	if( is_array( $item )) {
87
		// FTP Mode
88
		$abs_item = '/' . get_abs_dir($dir)."/".$item['name'];
89
		if( get_is_dir($item)) $abs_item.='/';
90
		return $abs_item; 
91
	}
92
	return get_abs_dir($dir)."/".$item;
93
}
94
/**
95
 * Returns the LS info array from an ftp directory listing
96
 *
97
 * @param unknown_type $dir
98
 * @param unknown_type $item
99
 * @return unknown
100
 */
101
function get_item_info( $dir, $item ) {
102
	$ls = getCachedFTPListing( $dir );
103
	foreach( $ls as $entry ) {
104
		if( $entry['name'] == $item ) {
105
			return $entry;
106
		}
107
	}
108
	if( $dir != '') {
109
		return $dir.'/'.$item;
110
	}
111
	return $item;
112
}
113
//------------------------------------------------------------------------------
114
function get_rel_item($dir,$item) {		// get file relative from home
115
	if($dir!="") return $dir."/".$item;
116
	else return $item;
117
}
118
//------------------------------------------------------------------------------
119
function get_is_file( $abs_item) {		// can this file be edited?
120
	if( jx_isFTPMode() && is_array( $abs_item )) {
121
		return empty($abs_item['is_dir']);
122
	} elseif( jx_isFTPMode() ) {
123
		$info = get_item_info( dirname($abs_item), basename($abs_item));
124
		return empty($info['is_dir']);
125
	}
126
	
127
	return @is_file($abs_item);
128
}
129
//------------------------------------------------------------------------------
130
function get_is_dir( $abs_item ) {		// is this a directory?
131
	if( jx_isFTPMode() && is_array( $abs_item )) {
132
		return !empty($abs_item['is_dir']);
133
	}
134
	elseif( jx_isFTPMode() ) {
135
		$info = get_item_info( dirname( $abs_item), basename( $abs_item ));
136
		return !empty($info['is_dir']);
137
	}
138
	return @is_dir( $abs_item );
139
}
140
//------------------------------------------------------------------------------
141
function parse_file_type( $abs_item ) {		// parsed file type (d / l / -)
142
	
143
	if(@get_is_dir($abs_item)) return "d";
144
	if(@is_link($abs_item)) return "l";
145
	return "-";
146
}
147
//------------------------------------------------------------------------------
148
function get_file_perms( $item) {		// file permissions
149
	if( jx_isFTPMode() ) {
150
		$perms = decoct( bindec( decode_ftp_rights($item['rights']) ) );
151
		return $perms;
152
	}
153
	return @decoct(@fileperms( $item ) & 0777);
154
}
155
//------------------------------------------------------------------------------
156
function parse_file_perms($mode) {		// parsed file permisions
157
	
158
	if(strlen($mode)<3) return "---------";
159
	$parsed_mode="";
160
	for($i=0;$i<3;$i++) {
161
		// read
162
		if(($mode{$i} & 04)) $parsed_mode .= "r";
163
		else $parsed_mode .= "-";
164
		// write
165
		if(($mode{$i} & 02)) $parsed_mode .= "w";
166
		else $parsed_mode .= "-";
167
		// execute
168
		if(($mode{$i} & 01)) $parsed_mode .= "x";
169
		else $parsed_mode .= "-";
170
	}
171
	return $parsed_mode;
172
}
173

  
174
function decode_ftp_rights( $rights) {
175
	$parsed_mode="";
176
	for($i=0;$i<9;$i++) {
177
		// read
178
		if( $rights[$i] != '-' ) {
179
			$parsed_mode .= '1';
180
		}
181
		else {
182
			$parsed_mode.= '0';
183
		}
184
	}
185
	
186
	return $parsed_mode;	
187
}
188
//------------------------------------------------------------------------------
189
function get_file_size( $abs_item) {		// file size
190
	return @$GLOBALS['jx_File']->filesize( $abs_item );
191
}
192
//------------------------------------------------------------------------------
193
function parse_file_size($size) {		// parsed file size
194
	if($size >= 1073741824) {
195
		$size = round($size / 1073741824 * 100) / 100 . " GB";
196
	} elseif($size >= 1048576) {
197
		$size = round($size / 1048576 * 100) / 100 . " MB";
198
	} elseif($size >= 1024) {
199
		$size = round($size / 1024 * 100) / 100 . " KB";
200
	} else $size = $size . " Bytes";
201
	if($size==0) $size="-";
202

  
203
	return $size;
204
}
205
//------------------------------------------------------------------------------
206
function get_file_date( $item) {		// file date
207
	return @$GLOBALS['jx_File']->filemtime( $item );
208
}
209
//------------------------------------------------------------------------------
210
function parse_file_date($date) {		// parsed file date
211
	return @date($GLOBALS["date_fmt"],$date);
212
}
213
//------------------------------------------------------------------------------
214
function get_is_image( $abs_item ) {		// is this file an image?
215
	if(!get_is_file($abs_item)) return false;
216
	if( isset($abs_item['name'])) {
217
		$abs_item = $abs_item['name'];
218
	}
219
	return @eregi($GLOBALS["images_ext"], $abs_item);
220
}
221
//-----------------------------------------------------------------------------
222
function get_is_editable( $abs_item ) {		// is this file editable?
223
	if(!get_is_file( $abs_item )) return false;
224
	if( is_array( $abs_item ) ) {
225
		 $abs_item = $abs_item['name'];
226
	}
227
	foreach($GLOBALS["editable_ext"] as $pat) if(@eregi($pat,$abs_item)) return true;
228
	
229
	return strpos( basename($abs_item), "." ) ? false : true;
230
	
231
}
232
//-----------------------------------------------------------------------------
233
function get_mime_type( $abs_item, $query) {	// get file's mimetype
234
	
235
	if(get_is_dir( $abs_item )) {			// directory
236
		$mime_type	= $GLOBALS["super_mimes"]["dir"][0];
237
		$image		= $GLOBALS["super_mimes"]["dir"][1];
238
		
239
		if($query=="img") return $image;
240
		else return $mime_type;
241
	}
242
	$extra = $GLOBALS['jx_File']->is_link( $abs_item ) ? ' ('.$GLOBALS['mimes']['symlink'].')' : '';
243
	if( jx_isFTPMode() && isset($abs_item['name']) ) {
244
		$abs_item=$abs_item['name'];
245
	}
246
				// mime_type
247
	foreach($GLOBALS["used_mime_types"] as $mime) {
248
		list($desc,$img,$ext)	= $mime;
249
		if(@eregi($ext,basename($abs_item) )) {
250
			$mime_type	= $desc;
251
			$image		= $img;
252
			if($query=="img") return $image;
253
			else return $mime_type . $extra;
254
		}
255
	}
256
	
257
	if((function_exists("is_executable") &&
258
		@is_executable( $abs_item )) ||
259
		@eregi($GLOBALS["super_mimes"]["exe"][2],$abs_item))		
260
	{						// executable
261
		$mime_type	= $GLOBALS["super_mimes"]["exe"][0];
262
		$image		= $GLOBALS["super_mimes"]["exe"][1];
263
	} else {					// unknown file
264
		$mime_type	= $GLOBALS["super_mimes"]["file"][0];
265
		$image		= $GLOBALS["super_mimes"]["file"][1];
266
	}
267
	
268
	if($query=="img") 
269
	  return $image;
270
	else 
271
	  return $mime_type . $extra;
272
}
273
//------------------------------------------------------------------------------
274
function get_show_item($dir, $item) {		// show this file?
275
	if( is_array( $item )) {
276
		$item = $item['name'];
277
	}
278
	if($item == "." || $item == ".." ||
279
		(substr($item,0,1)=="." && $GLOBALS["show_hidden"]==false)) return false;
280
		
281
	if($GLOBALS["no_access"]!="" && @eregi($GLOBALS["no_access"],$item)) return false;
282
	
283
	if($GLOBALS["show_hidden"]==false) {
284
		$dirs=explode("/",$dir);
285
		foreach($dirs as $i) if(substr($i,0,1)==".") return false;
286
	}
287
	
288
	return true;
289
}
290
//------------------------------------------------------------------------------
291
function get_dir_list( $dir='' ) {
292
	$files = mosReadDirectory( get_abs_dir( $dir), '.', false, true );
293
	$dirs =array();
294
	foreach( $files as $item) {
295
		$item = str_replace( '\\', '/', $item );
296
		if( get_is_dir($item)) {
297
			$index = str_replace( $GLOBALS['home_dir'].$GLOBALS['separator'], '', $item );
298
			$dirs[$index]= basename($index);
299
		}
300
	}
301
	return $dirs;
302
}
303
function get_dir_selects( $dir ) {
304
	$dirs = explode( "/", $dir );
305
	
306
	$subdirs = get_dir_list();
307
	if( empty($dirs[0]) ) array_shift($dirs);
308
	$dirsCopy = $dirs;
309
	$implode = '';
310
	$selectedDir = @$dirs[0];
311
	$dir_links = jx_selectList('dirselect1', $selectedDir, $subdirs, 1, '', 'onchange="theDir=this.options[this.selectedIndex].value;if(theDir!=\'jx_disabled\' ) chDir(theDir);"' );
312
	$i = 2;
313
	foreach( $dirs as $directory ) {
314
	  	if( $directory != "" ) {
315
			$implode .= $directory;
316
			$next = next($dirsCopy);
317
			$subdirs = get_dir_list( $implode );
318
			if( $next !== false ) {
319
				$selectedDir .= '/'.$next;
320
			} else {
321
				if( sizeof( $subdirs ) > 0) {
322
					$subdirs = array_merge(Array('jx_disabled' => '-'), $subdirs );
323
				}
324
			}
325
			$dir_links .= ' / ' .jx_selectList('dirselect'.$i++, $selectedDir, $subdirs, 1, '', 'onchange="theDir=this.options[this.selectedIndex].value;if(theDir!=\'jx_disabled\' ) chDir(theDir);"' );
326
			$implode .= '/';
327
	  	}
328
	}
329
	
330
	return $dir_links;
331
}
332
//------------------------------------------------------------------------------
333
function copy_dir($source,$dest) {		// copy dir
334
	$ok = true;
335
	
336
	if(!@mkdir($dest,0777)) return false;
337
	$itemlist = mosReadDirectory( $source, '.', true, true );
338
	if( empty( $itemlist )) return false;
339
	
340
	foreach( $itemlist as $file ) {
341
		if(($file==".." || $file==".")) continue;
342
		
343
		$new_dest = str_replace( $source, $dest, $file );
344
		if(@is_dir($file)) {
345
			@mkdir($new_dest,0777);
346
		} else {
347
			$ok=@copy($file,$new_dest);
348
		}
349
	}
350
	
351
	return $ok;
352
}
353

  
354
//------------------------------------------------------------------------------
355
function remove($item) {			// remove file / dir
356
	
357
	if( !is_link( $item )) {
358
		$item = realpath($item);
359
	}
360
	$ok = true;
361
	if( is_link($item) ||  is_file($item)) 
362
	  $ok =  unlink($item);
363
	elseif( is_dir($item)) {
364
		
365
		if(($handle= opendir($item))===false) 
366
		  show_error(basename($item).": ".$GLOBALS["error_msg"]["opendir"]);
367

  
368
		while(($file=readdir($handle))!==false) {
369
			if(($file==".." || $file==".")) continue;
370
			
371
			$new_item = $item."/".$file;
372
			if(!file_exists($new_item)) 
373
			  show_error(basename($item).": ".$GLOBALS["error_msg"]["readdir"]);
374
			//if(!get_show_item($item, $new_item)) continue;
375
			
376
			if( is_dir($new_item)) {
377
				$ok=remove($new_item);
378
			} else {
379
				$ok= unlink($new_item);
380
			}
381
		}
382
		
383
		closedir($handle);
384
		$ok=@rmdir($item);
385
	}
386
	return $ok;
387
}
388
function chmod_recursive($item, $mode) {			// chmod file / dir
389
	$ok = true;
390
	if(@is_link($item) || @is_file($item)) {
391
		$ok=@chmod( $item, $mode );
392
	}
393
	elseif(@is_dir($item)) {
394
		if(($handle=@opendir($item))===false) {
395
			
396
			add_error(basename($item).": ".$GLOBALS["error_msg"]["opendir"]);
397
			return false; 
398
		}
399

  
400
		while(($file=readdir($handle))!==false) {
401
			if(($file==".." || $file==".")) continue;
402
			
403
			$new_item = $item."/".$file;
404
			if(!@file_exists($new_item)) {
405
				add_error(basename($item).": ".$GLOBALS["error_msg"]["readdir"]);
406
				continue; 
407
			}
408
			//if(!get_show_item($item, $new_item)) continue;
409
			
410
			if(@is_dir($new_item)) {
411
				$ok=chmod_recursive($new_item, $mode);
412
				if($ok) add_message($GLOBALS['messages']['permchange'].' '.$new_item);
413
			} else {
414
				$ok=@chmod($new_item, $mode);
415
				if($ok) add_message($GLOBALS['messages']['permchange'].' '.$new_item);
416
			}
417
		}
418
		closedir($handle);
419
		if( is_dir( $item )) {
420
			$bin = decbin( $mode );
421
			// when we chmod a directory we must care for the permissions
422
			// to prevent that the directory becomes not readable (when the "execute bits" are removed)
423
			$bin = substr_replace( $bin, '1', 2, 1 ); // set 1st x bit to 1
424
			$bin = substr_replace( $bin, '1', 5, 1 );// set  2nd x bit to 1
425
			$bin = substr_replace( $bin, '1', 8, 1 );// set 3rd x bit to 1
426
			$mode = bindec( $bin ); 
427
		}
428
		$ok=@chmod( $item, $mode );
429
		if($ok) add_message($GLOBALS['messages']['permchange'].' '.$new_item);
430
	}
431
	return $ok;
432
}
433
//------------------------------------------------------------------------------
434
function get_max_file_size() {			// get php max_upload_file_size
435
	return calc_php_setting_bytes( ini_get("upload_max_filesize") );	
436
}
437
function get_max_upload_limit() {
438
	return calc_php_setting_bytes( ini_get('post_max_size'));
439
}
440

  
441
function calc_php_setting_bytes( $value ) {
442
	if(@eregi("G$",$value)) {
443
		$value = substr($value,0,-1);
444
		$value = round($value*1073741824);
445
	} elseif(@eregi("M$",$value)) {
446
		$value = substr($value,0,-1);
447
		$value = round($value*1048576);
448
	} elseif(@eregi("K$",$value)) {
449
		$value = substr($value,0,-1);
450
		$value = round($value*1024);
451
	}
452
	
453
	return $value;
454
}
455
//------------------------------------------------------------------------------
456
function down_home($abs_dir) {			// dir deeper than home?
457
	if( jx_isFTPMode() ) {
458
		return true;
459
	}
460
	$real_home = @realpath($GLOBALS["home_dir"]);
461
	$real_dir = @realpath($abs_dir);
462
	
463
	if($real_home===false || $real_dir===false) {
464
		if(@eregi("\\.\\.",$abs_dir)) return false;
465
	} else if(strcmp($real_home,@substr($real_dir,0,strlen($real_home)))) {
466
		return false;
467
	}
468
	return true;
469
}
470
//------------------------------------------------------------------------------
471
function id_browser() {
472
	$browser=$GLOBALS['__SERVER']['HTTP_USER_AGENT'];
473
	
474
	if(ereg('Opera(/| )([0-9].[0-9]{1,2})', $browser)) {
475
		return 'OPERA';
476
	} else if(ereg('MSIE ([0-9].[0-9]{1,2})', $browser)) {
477
		return 'IE';
478
	} else if(ereg('OmniWeb/([0-9].[0-9]{1,2})', $browser)) {
479
		return 'OMNIWEB';
480
	} else if(ereg('(Konqueror/)(.*)', $browser)) {
481
		return 'KONQUEROR';
482
	} else if(ereg('Mozilla/([0-9].[0-9]{1,2})', $browser)) {
483
		return 'MOZILLA';
484
	} else {
485
		return 'OTHER';
486
	}
487
}
488
function jx_isArchive( $file ) {
489
  
490
	$file_info = pathinfo($file);
491
	$ext = @$file_info["extension"];
492
	if( $ext == "tar" || $ext == "gz" || $ext == "tgz" || $ext == "zip" || $ext == "bzip2"  || $ext == "bz2" || $ext == "tbz") {
493
	  return true;
494
	}
495
	return false;
496
}
497
if( !extension_loaded('posix') ) {
498
	function posix_geteuid() {
499
		return false;
500
	}
501
	function posix_getpwnam() {
502
		
503
	}
504
}
505

  
506
//------------------------------------------------------------------------------
507
/**
508
 * Checks if the User Agent String identifies the browser as Internet Explorer
509
 *
510
 * @return boolean
511
 */
512
function jx_isIE() {
513
	return (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']));
514
}
515

  
516
if( !function_exists('mosToolTip')) {
517
	/**
518
	* Utility function to provide ToolTips
519
	* @param string ToolTip text
520
	* @param string Box title
521
	* @returns HTML code for ToolTip
522
	*/
523
	function mosToolTip( $tooltip, $title='', $width='', $image='tooltip.png', $text='', $href='#', $link=1 ) {
524
		global $mosConfig_live_site;
525
	
526
		if ( $width ) {
527
			$width = ', WIDTH, \''.$width .'\'';
528
		}
529
		if ( $title ) {
530
			$title = ', CAPTION, \''.$title .'\'';
531
		}
532
		if ( !$text ) {
533
			$image 	= $mosConfig_live_site . '/includes/js/ThemeOffice/'. $image;
534
			$text 	= '<img src="'. $image .'" border="0" />';
535
		}
536
		$style = 'style="text-decoration: none; color: #333;"';
537
		if ( $href ) {
538
			$style = '';
539
		}
540
		else{ $href = "#"; }
541
	
542
		if ( $link ) {
543
			$tip = "<a href=\"". $href ."\" onmouseover=\"return overlib('" . $tooltip . "'". $title .", BELOW, RIGHT". $width .");\" onmouseout=\"return nd();\" ". $style .">". $text ."</a>";
544
		} else {
545
			$tip = "<span onmouseover=\"return overlib('" . $tooltip . "'". $title .", BELOW, RIGHT". $width .");\" onmouseout=\"return nd();\" ". $style .">". $text ."</span>";
546
		}
547
	
548
		return $tip;
549
	}
550
}
551
/**
552
 * Prints an HTML dropdown box named $name using $arr to
553
 * load the drop down.  If $value is in $arr, then $value
554
 * will be the selected option in the dropdown.
555
 * @author gday
556
 * @author soeren
557
 * 
558
 * @param string $name The name of the select element
559
 * @param string $value The pre-selected value
560
 * @param array $arr The array containting $key and $val
561
 * @param int $size The size of the select element
562
 * @param string $multiple use "multiple=\"multiple\" to have a multiple choice select list
563
 * @param string $extra More attributes when needed
564
 * @return string HTML drop-down list
565
 */	
566
function jx_selectList($name, $value, $arr, $size=1, $multiple="", $extra="") {
567
	$html = '';
568
	if( !empty( $arr ) ) {
569
		$html = "<select class=\"inputbox\" name=\"$name\" id=\"$name\" size=\"$size\" $multiple $extra>\n";
570

  
571
		while (list($key, $val) = each($arr)) {
572
			$selected = "";
573
			if( is_array( $value )) {
574
				if( in_array( $key, $value )) {
575
					$selected = "selected=\"selected\"";
576
				}
577
			}
578
			else {
579
				if(strtolower($value) == strtolower($key) ) {
580
					$selected = "selected=\"selected\"";
581
				}
582
			}
583
			if( $val == '-') {
584
				//$selected .= ' disabled="disabled"';
585
				$val = '- - - - -';
586
			}
587
			$html .= "<option value=\"$key\" $selected>$val";
588
			$html .= "</option>\n";
589
		}
590

  
591
		$html .= "</select>\n";
592
	}
593
	return $html;
594
}
595
function jx_scriptTag( $src = '', $script = '') {
596
	if( $src!='') {
597
		return '<script type="text/javascript" src="'.$src.'"></script>';
598
	}
599
	if( $script != '') {
600
		return '<script type="text/javascript">'.$script.'</script>';
601
	}
602
}
603
function jx_alertBox( $msg ) {
604
	return jx_scriptTag('', 'alert( \''. @mysql_escape_string( $msg ) .'\' );' );
605
}
606
function jx_docLocation( $url ) {
607
	return jx_scriptTag('', 'document.location=\''. $url .'\';' );
608
}
609
function jx_isXHR() {
610
	return strtolower(mosGetParam($_SERVER,'HTTP_X_REQUESTED_WITH')) == 'xmlhttprequest'
611
		|| strtolower(mosGetParam($_POST,'requestType')) == 'xmlhttprequest';
612
}
613
function jx_exit() {
614
	global $mainframe;
615
	
616
	if( is_callable( array( $mainframe, 'close' ) ) ) {				
617
		$mainframe->close();
618
	} else {
619
		session_write_close();
620
		exit;
621
	}
622
}
623
/**
624
 * Raise the memory limit when it is lower than the needed value
625
 *
626
 * @param string $setLimit Example: 16M
627
 */
628
function jx_RaiseMemoryLimit( $setLimit ) {
629
	
630
	$memLimit = @ini_get('memory_limit');
631
	
632
	if( stristr( $memLimit, 'k') ) {
633
		$memLimit = str_replace( 'k', '', str_replace( 'K', '', $memLimit )) * 1024;
634
	}
635
	elseif( stristr( $memLimit, 'm') ) {
636
		$memLimit = str_replace( 'm', '', str_replace( 'M', '', $memLimit )) * 1024 * 1024;
637
	}
638
	
639
	if( stristr( $setLimit, 'k') ) {
640
		$setLimitB = str_replace( 'k', '', str_replace( 'K', '', $setLimit )) * 1024;
641
	}
642
	elseif( stristr( $setLimit, 'm') ) {
643
		$setLimitB = str_replace( 'm', '', str_replace( 'M', '', $setLimit )) * 1024 * 1024;
644
	}
645
	
646
	if( $memLimit < $setLimitB ) {
647
		@ini_set('memory_limit', $setLimit );
648
	}	
649
}
650
/**
651
 * Reads a file and sends them in chunks to the browser
652
 * This should overcome memory problems
653
 * http://www.php.net/manual/en/function.readfile.php#54295
654
 *
655
 * @since 1.4.1
656
 * @param string $filename
657
 * @param boolean $retbytes
658
 * @return mixed
659
 */
660
function readFileChunked($filename,$retbytes=true) {
661
	$chunksize = 1*(1024*1024); // how many bytes per chunk
662
	$buffer = '';
663
	$cnt =0;
664
	// $handle = fopen($filename, 'rb');
665
	$handle = fopen($filename, 'rb');
666
	if ($handle === false) {
667
		return false;
668
	}
669
	while (!feof($handle)) {
670
		$buffer = fread($handle, $chunksize);
671
		echo $buffer;
672
		sleep(1);
673
		ob_flush();
674
		flush();
675
		if ($retbytes) {
676
			$cnt += strlen($buffer);
677
		}
678
	}
679
	$status = fclose($handle);
680
	if ($retbytes && $status) {
681
		return $cnt; // return num. bytes delivered like readfile() does.
682
	}
683
	return $status;
684
}
685
//implements file_put_contents function for compartability with mambo on PHP < 4.3
686
if ( ! function_exists('file_put_contents') ) {
687
	function file_put_contents ( $filename, $filecont ){
688
		$handle = fopen( $filename, 'w' );
689
		if ( is_array($filecont) ) {
690
			$size = 0;
691
			foreach ( $filecont as $filestring ) {
692
				fwrite( $handle, $filestring );
693
				$size += strlen( $filestring );
694
			}
695
			fclose($handle);
696
			return $size;
697
		} else {
698
			fwrite( $handle, $filecont );
699
			fclose($handle);
700
			return strlen( $filecont );
701
		}
702
	}
703
}
704
if ( ! function_exists('scandir') ) {
705
function scandir($dir,$listDirectories=false, $skipDots=true) {
706
    $dirArray = array();
707
    if ($handle = opendir($dir)) {
708
        while (false !== ($file = readdir($handle))) {
709
            if (($file != "." && $file != "..") || $skipDots == true) {
710
                if($listDirectories == false) { if(is_dir($file)) { continue; } }
711
                array_push($dirArray,basename($file));
712
            }
713
        }
714
        closedir($handle);
715
    }
716
    return $dirArray;
717
}
718
}
719
?>
0 720

  
tags/joomlaxplorer-1.6.1-released/include/fun_up.php
1
<?php
2
/** ensure this file is being included by a parent file */
3
if( !defined( '_JEXEC' ) && !defined( '_VALID_MOS' ) ) die( 'Restricted access' );
4
/*------------------------------------------------------------------------------
5
     The contents of this file are subject to the Mozilla Public License
6
     Version 1.1 (the "License"); you may not use this file except in
7
     compliance with the License. You may obtain a copy of the License at
8
     http://www.mozilla.org/MPL/
9

  
10
     Software distributed under the License is distributed on an "AS IS"
11
     basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
12
     License for the specific language governing rights and limitations
13
     under the License.
14

  
15
     The Original Code is fun_up.php, released on 2003-03-31.
16

  
17
     The Initial Developer of the Original Code is The QuiX project.
18

  
19
     Alternatively, the contents of this file may be used under the terms
20
     of the GNU General Public License Version 2 or later (the "GPL"), in
21
     which case the provisions of the GPL are applicable instead of
22
     those above. If you wish to allow use of your version of this file only
23
     under the terms of the GPL and not to allow others to use
24
     your version of this file under the MPL, indicate your decision by
25
     deleting  the provisions above and replace  them with the notice and
26
     other provisions required by the GPL.  If you do not delete
27
     the provisions above, a recipient may use your version of this file
28
     under either the MPL or the GPL."
29
------------------------------------------------------------------------------*/
30
/*------------------------------------------------------------------------------
31
Author: The QuiX project
32
	quix@free.fr
33
	http://www.quix.tk
34
	http://quixplorer.sourceforge.net
35

  
36
Comment:
37
	QuiXplorer Version 2.3
38
	File-Upload Functions
39
	
40
	Have Fun...
41
------------------------------------------------------------------------------*/
42
//------------------------------------------------------------------------------
43
function upload_items($dir) {		// upload file
44
	if(($GLOBALS["permissions"]&01)!=01) show_error($GLOBALS["error_msg"]["accessfunc"]);
45
	
46
	// Execute
47
	if(isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"]=="true") {	
48
		$cnt=count($GLOBALS['__FILES']['userfile']['name']);
49
		$err=false;
50
		$err_avaliable=isset($GLOBALS['__FILES']['userfile']['error']);
51
	
52
		// upload files & check for errors
53
		for($i=0;$i<$cnt;$i++) {
54
			$errors[$i]=NULL;
55
			$tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i];
56
			$items[$i] = stripslashes($GLOBALS['__FILES']['userfile']['name'][$i]);
57
			if($err_avaliable) $up_err = $GLOBALS['__FILES']['userfile']['error'][$i];
58
			else $up_err=(file_exists($tmp)?0:4);
59
			$abs = get_abs_item($dir,$items[$i]);
60
		
61
			if($items[$i]=="" || $up_err==4) continue;
62
			if($up_err==1 || $up_err==2) {
63
				$errors[$i]=$GLOBALS["error_msg"]["miscfilesize"];
64
				$err=true;	continue;
65
			}
66
			if($up_err==3) {
67
				$errors[$i]=$GLOBALS["error_msg"]["miscfilepart"];
68
				$err=true;	continue;
69
			}
70
			if(!@is_uploaded_file($tmp)) {
71
				$errors[$i]=$GLOBALS["error_msg"]["uploadfile"];
72
				$err=true;	continue;
73
			}
74
			if(@file_exists($abs) && empty( $_REQUEST['overwrite_files'])) {
75
				$errors[$i]=$GLOBALS["error_msg"]["itemdoesexist"];
76
				$err=true;	continue;
77
			}
78
			
79
			// Upload
80
			$ok = @$GLOBALS['jx_File']->move_uploaded_file($tmp, $abs);
81
			
82
			if($ok===false || PEAR::isError( $ok )) {
83
				$errors[$i]=$GLOBALS["error_msg"]["uploadfile"];
84
				if( PEAR::isError( $ok ) ) $errors[$i].= ' ['.$ok->getMessage().']';
85
				$err=true;	continue;
86
			}
87
			else {
88
				$mode = jx_isFTPMode() ? 644 : 0644;
89
			  	@$GLOBALS['jx_File']->chmod( $abs, $mode );
90
			}
91
		}
92
		
93
		if($err) {			// there were errors
94
			$err_msg="";
95
			for($i=0;$i<$cnt;$i++) {
96
				if($errors[$i]==NULL) continue;
97
				$err_msg .= $items[$i]." : ".$errors[$i]."<BR>\n";
98
			}
99
			show_error($err_msg);
100
		}
101
		
102
		header("Location: ".make_link("list",$dir,NULL));
103
		return;
104
	}
105
	
106
	show_header($GLOBALS["messages"]["actupload"]);
107
	
108
	// List
109
	echo "<br /><form enctype=\"multipart/form-data\" action=\"".make_link("upload",$dir,NULL). "\" method=\"post\">
110
			<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"". get_max_file_size()."\" />
111
			<input type=\"hidden\" name=\"confirm\" value=\"true\" />
112
		<table style=\"width:60%;\" border=\"1\" class=\"adminform\">
113
			<tr><td class=\"quote\" colspan=\"2\">Maximum File Size = <strong>". ((get_max_file_size() / 1024) / 1024)." MB</strong><br />
114
				Maximum Upload Limit = <strong>". ((get_max_upload_limit() / 1024) / 1024)." MB</strong>
115
			</td></tr>
116
			";
117
	for($i=0;$i<10;$i++) {
118
		$class = $i % 2 ? 'row0' : 'row1';
119
		echo "<tr class=\"$class\"><td colspan=\"2\">";
120
		echo "<input name=\"userfile[]\" type=\"file\" size=\"50\" class=\"inputbox\" /></td></tr>\n";
121
	}
122
	echo "<tr><td colspan=\"2\">
123
				<input type=\"checkbox\" checked=\"checked\" value=\"1\" name=\"overwrite_files\" id=\"overwrite_files\" /><label for=\"overwrite_files\">".$GLOBALS["messages"]["overwrite_files"]. "</label>
124
			</td>
125
			</tr>
126
			<tr>
127
				<td width=\"40%\" style=\"text-align:right;\">
128
					<input type=\"submit\" value=\"".$GLOBALS["messages"]["btnupload"]. "\" class=\"button\" />&nbsp;&nbsp;&nbsp;&nbsp;
129
				</td>
130
				<td width=\"60%\" style=\"text-align:left;\">&nbsp;&nbsp;&nbsp;&nbsp;
131
					<input type=\"button\" value=\"".$GLOBALS["messages"]["btncancel"]."\" class=\"button\" onclick=\"javascript:location='".make_link("list",$dir,NULL)."';\" />
132
				</td>
133
			</tr>
134
		</table>
135
		</form><br />\n";
136
	
137
	return;
138
}
139
//------------------------------------------------------------------------------
140
?>
0 141

  
tags/joomlaxplorer-1.6.1-released/include/fun_edit.php
1
<?php
2
// ensure this file is being included by a parent file
3
if( !defined( '_JEXEC' ) && !defined( '_VALID_MOS' ) ) die( 'Restricted access' );
4
/**
5
 * @version $Id: $
6
 * @package joomlaXplorer
7
 * @copyright soeren 2007
8
 * @author The joomlaXplorer project (http://joomlacode.org/gf/project/joomlaxplorer/)
9
 * @author The  The QuiX project (http://quixplorer.sourceforge.net)
10
 * 
11
 * @license
12
 * The contents of this file are subject to the Mozilla Public License
13
 * Version 1.1 (the "License"); you may not use this file except in
14
 * compliance with the License. You may obtain a copy of the License at
15
 * http://www.mozilla.org/MPL/
16
 * 
17
 * Software distributed under the License is distributed on an "AS IS"
18
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
19
 * License for the specific language governing rights and limitations
20
 * under the License.
21
 * 
22
 * Alternatively, the contents of this file may be used under the terms
23
 * of the GNU General Public License Version 2 or later (the "GPL"), in
24
 * which case the provisions of the GPL are applicable instead of
25
 * those above. If you wish to allow use of your version of this file only
26
 * under the terms of the GPL and not to allow others to use
27
 * your version of this file under the MPL, indicate your decision by
28
 * deleting  the provisions above and replace  them with the notice and
29
 * other provisions required by the GPL.  If you do not delete
30
 * the provisions above, a recipient may use your version of this file
31
 * under either the MPL or the GPL."
32
 * 
33
 * 
34
 */
35
	
36
/**
37
 * File-Edit Functions
38
 *
39
 */
40
//------------------------------------------------------------------------------
41
function savefile($file_name) {			// save edited file
42
	if( get_magic_quotes_gpc() ) {
43
		$code = stripslashes($GLOBALS['__POST']["code"]);
44
	}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff