Project

General

Profile

Revision 13

View differences:

trunk/.include/fun_extra.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 fun_extra.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
	(Extra) Functions
39
	
40
	Have Fun...
41
------------------------------------------------------------------------------*/
42
//------------------------------------------------------------------------------
43
// THESE ARE NUMEROUS HELPER FUNCTIONS FOR THE OTHER INCLUDE FILES
44
//------------------------------------------------------------------------------
45

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

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

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

  
210
	return $size;
211
}
212
//------------------------------------------------------------------------------
213
function get_file_date( $item) {		// file date
214
	return @$GLOBALS['jx_File']->filemtime( $item );
215
}
216
//------------------------------------------------------------------------------
217
function parse_file_date($date) {		// parsed file date
218
	return @date($GLOBALS["date_fmt"],$date);
219
}
220
//------------------------------------------------------------------------------
221
function get_is_image( $abs_item ) {		// is this file an image?
222
	if(!get_is_file($abs_item)) return false;
223
	if( isset($abs_item['name'])) {
224
		$abs_item = $abs_item['name'];
225
	}
226
	return @eregi($GLOBALS["images_ext"], $abs_item);
227
}
228
//-----------------------------------------------------------------------------
229
function get_is_editable( $abs_item ) {		// is this file editable?
230
	if(!get_is_file( $abs_item )) return false;
231
	if( is_array( $abs_item ) ) {
232
		 $abs_item = $abs_item['name'];
233
	}
234
	foreach($GLOBALS["editable_ext"] as $pat) if(@eregi($pat,$abs_item)) return true;
235
	
236
	return strpos( basename($abs_item), "." ) ? false : true;
237
	
238
}
239
//-----------------------------------------------------------------------------
240
function get_mime_type( $abs_item, $query) {	// get file's mimetype
241
	
242
	if(get_is_dir( $abs_item )) {			// directory
243
		$mime_type	= $GLOBALS["super_mimes"]["dir"][0];
244
		$image		= $GLOBALS["super_mimes"]["dir"][1];
245
		
246
		if($query=="img") return $image;
247
		else return $mime_type;
248
	}
249
	$extra = $GLOBALS['jx_File']->is_link( $abs_item ) ? ' ('.$GLOBALS['mimes']['symlink'].')' : '';
250
	if( jx_isFTPMode() && isset($abs_item['name']) ) {
251
		$abs_item=$abs_item['name'];
252
	}
253
				// mime_type
254
	foreach($GLOBALS["used_mime_types"] as $mime) {
255
		list($desc,$img,$ext)	= $mime;
256
		if(@eregi($ext,basename($abs_item) )) {
257
			$mime_type	= $desc;
258
			$image		= $img;
259
			if($query=="img") return $image;
260
			else return $mime_type . $extra;
261
		}
262
	}
263
	
264
	if((function_exists("is_executable") &&
265
		@is_executable( $abs_item )) ||
266
		@eregi($GLOBALS["super_mimes"]["exe"][2],$abs_item))		
267
	{						// executable
268
		$mime_type	= $GLOBALS["super_mimes"]["exe"][0];
269
		$image		= $GLOBALS["super_mimes"]["exe"][1];
270
	} else {					// unknown file
271
		$mime_type	= $GLOBALS["super_mimes"]["file"][0];
272
		$image		= $GLOBALS["super_mimes"]["file"][1];
273
	}
274
	
275
	if($query=="img") 
276
	  return $image;
277
	else 
278
	  return $mime_type . $extra;
279
}
280
//------------------------------------------------------------------------------
281
function get_show_item($dir, $item) {		// show this file?
282
	if( is_array( $item )) {
283
		$item = $item['name'];
284
	}
285
	if($item == "." || $item == ".." ||
286
		(substr($item,0,1)=="." && $GLOBALS["show_hidden"]==false)) return false;
287
		
288
	if($GLOBALS["no_access"]!="" && @eregi($GLOBALS["no_access"],$item)) return false;
289
	
290
	if($GLOBALS["show_hidden"]==false) {
291
		$dirs=explode("/",$dir);
292
		foreach($dirs as $i) if(substr($i,0,1)==".") return false;
293
	}
294
	
295
	return true;
296
}
297
//------------------------------------------------------------------------------
298
function copy_dir($source,$dest) {		// copy dir
299
	$ok = true;
300
	
301
	if(!@mkdir($dest,0777)) return false;
302
	if(($handle=@opendir($source))===false) 
303
	  show_error(basename($source).": ".$GLOBALS["error_msg"]["opendir"]);
304
	
305
	while(($file=readdir($handle))!==false) {
306
		if(($file==".." || $file==".")) continue;
307
		
308
		$new_source = $source."/".$file;
309
		$new_dest = $dest."/".$file;
310
		if(@is_dir($new_source)) {
311
			$ok=copy_dir($new_source,$new_dest);
312
		} else {
313
			$ok=@copy($new_source,$new_dest);
314
		}
315
	}
316
	closedir($handle);
317
	return $ok;
318
}
319
//------------------------------------------------------------------------------
320
function remove($item) {			// remove file / dir
321
	
322
	if( !is_link( $item )) {
323
		$item = realpath($item);
324
	}
325
	$ok = true;
326
	if( is_link($item) ||  is_file($item)) 
327
	  $ok =  unlink($item);
328
	elseif( is_dir($item)) {
329
		
330
		if(($handle= opendir($item))===false) 
331
		  show_error(basename($item).": ".$GLOBALS["error_msg"]["opendir"]);
332

  
333
		while(($file=readdir($handle))!==false) {
334
			if(($file==".." || $file==".")) continue;
335
			
336
			$new_item = $item."/".$file;
337
			if(!file_exists($new_item)) 
338
			  show_error(basename($item).": ".$GLOBALS["error_msg"]["readdir"]);
339
			//if(!get_show_item($item, $new_item)) continue;
340
			
341
			if( is_dir($new_item)) {
342
				$ok=remove($new_item);
343
			} else {
344
				$ok= unlink($new_item);
345
			}
346
		}
347
		
348
		closedir($handle);
349
		$ok=@rmdir($item);
350
	}
351
	return $ok;
352
}
353
function chmod_recursive($item, $mode) {			// chmod file / dir
354
	$ok = true;
355
	if(@is_link($item) || @is_file($item)) {
356
		$ok=@chmod( $item, $mode );
357
	}
358
	elseif(@is_dir($item)) {
359
		if(($handle=@opendir($item))===false) {
360
			
361
			add_error(basename($item).": ".$GLOBALS["error_msg"]["opendir"]);
362
			return false; 
363
		}
364

  
365
		while(($file=readdir($handle))!==false) {
366
			if(($file==".." || $file==".")) continue;
367
			
368
			$new_item = $item."/".$file;
369
			if(!@file_exists($new_item)) {
370
				add_error(basename($item).": ".$GLOBALS["error_msg"]["readdir"]);
371
				continue; 
372
			}
373
			//if(!get_show_item($item, $new_item)) continue;
374
			
375
			if(@is_dir($new_item)) {
376
				$ok=chmod_recursive($new_item, $mode);
377
				if($ok) add_message($GLOBALS['messages']['permchange'].' '.$new_item);
378
			} else {
379
				$ok=@chmod($new_item, $mode);
380
				if($ok) add_message($GLOBALS['messages']['permchange'].' '.$new_item);
381
			}
382
		}
383
		closedir($handle);
384
		if( is_dir( $item )) {
385
			$bin = decbin( $mode );
386
			// when we chmod a directory we must care for the permissions
387
			// to prevent that the directory becomes not readable (when the "execute bits" are removed)
388
			$bin = substr_replace( $bin, '1', 2, 1 ); // set 1st x bit to 1
389
			$bin = substr_replace( $bin, '1', 5, 1 );// set  2nd x bit to 1
390
			$bin = substr_replace( $bin, '1', 8, 1 );// set 3rd x bit to 1
391
			$mode = bindec( $bin ); 
392
		}
393
		$ok=@chmod( $item, $mode );
394
		if($ok) add_message($GLOBALS['messages']['permchange'].' '.$new_item);
395
	}
396
	return $ok;
397
}
398
//------------------------------------------------------------------------------
399
function get_max_file_size() {			// get php max_upload_file_size
400
	return calc_php_setting_bytes( ini_get("upload_max_filesize") );	
401
}
402
function get_max_upload_limit() {
403
	return calc_php_setting_bytes( ini_get('post_max_size'));
404
}
405

  
406
function calc_php_setting_bytes( $value ) {
407
	if(@eregi("G$",$value)) {
408
		$value = substr($value,0,-1);
409
		$value = round($value*1073741824);
410
	} elseif(@eregi("M$",$value)) {
411
		$value = substr($value,0,-1);
412
		$value = round($value*1048576);
413
	} elseif(@eregi("K$",$value)) {
414
		$value = substr($value,0,-1);
415
		$value = round($value*1024);
416
	}
417
	
418
	return $value;
419
}
420
//------------------------------------------------------------------------------
421
function down_home($abs_dir) {			// dir deeper than home?
422
	if( jx_isFTPMode() ) {
423
		return true;
424
	}
425
	$real_home = @realpath($GLOBALS["home_dir"]);
426
	$real_dir = @realpath($abs_dir);
427
	
428
	if($real_home===false || $real_dir===false) {
429
		if(@eregi("\\.\\.",$abs_dir)) return false;
430
	} else if(strcmp($real_home,@substr($real_dir,0,strlen($real_home)))) {
431
		return false;
432
	}
433
	return true;
434
}
435
//------------------------------------------------------------------------------
436
function id_browser() {
437
	$browser=$GLOBALS['__SERVER']['HTTP_USER_AGENT'];
438
	
439
	if(ereg('Opera(/| )([0-9].[0-9]{1,2})', $browser)) {
440
		return 'OPERA';
441
	} else if(ereg('MSIE ([0-9].[0-9]{1,2})', $browser)) {
442
		return 'IE';
443
	} else if(ereg('OmniWeb/([0-9].[0-9]{1,2})', $browser)) {
444
		return 'OMNIWEB';
445
	} else if(ereg('(Konqueror/)(.*)', $browser)) {
446
		return 'KONQUEROR';
447
	} else if(ereg('Mozilla/([0-9].[0-9]{1,2})', $browser)) {
448
		return 'MOZILLA';
449
	} else {
450
		return 'OTHER';
451
	}
452
}
453
function jx_isArchive( $file ) {
454
  
455
	$file_info = pathinfo($file);
456
	$ext = @$file_info["extension"];
457
	if( $ext == "tar" || $ext == "gz" || $ext == "tgz" || $ext == "zip" || $ext == "bzip2"  || $ext == "bz2" || $ext == "tbz") {
458
	  return true;
459
	}
460
	return false;
461
}
462
if( !extension_loaded('posix') ) {
463
	function posix_geteuid() {
464
		return false;
465
	}
466
	function posix_getpwnam() {
467
		
468
	}
469
}
470

  
471
//------------------------------------------------------------------------------
472
/**
473
 * Checks if the User Agent String identifies the browser as Internet Explorer
474
 *
475
 * @return boolean
476
 */
477
function jx_isIE() {
478
	return (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']));
479
}
480

  
481
if( !function_exists('mosToolTip')) {
482
	/**
483
	* Utility function to provide ToolTips
484
	* @param string ToolTip text
485
	* @param string Box title
486
	* @returns HTML code for ToolTip
487
	*/
488
	function mosToolTip( $tooltip, $title='', $width='', $image='tooltip.png', $text='', $href='#', $link=1 ) {
489
		global $mosConfig_live_site;
490
	
491
		if ( $width ) {
492
			$width = ', WIDTH, \''.$width .'\'';
493
		}
494
		if ( $title ) {
495
			$title = ', CAPTION, \''.$title .'\'';
496
		}
497
		if ( !$text ) {
498
			$image 	= $mosConfig_live_site . '/includes/js/ThemeOffice/'. $image;
499
			$text 	= '<img src="'. $image .'" border="0" />';
500
		}
501
		$style = 'style="text-decoration: none; color: #333;"';
502
		if ( $href ) {
503
			$style = '';
504
		}
505
		else{ $href = "#"; }
506
	
507
		if ( $link ) {
508
			$tip = "<a href=\"". $href ."\" onmouseover=\"return overlib('" . $tooltip . "'". $title .", BELOW, RIGHT". $width .");\" onmouseout=\"return nd();\" ". $style .">". $text ."</a>";
509
		} else {
510
			$tip = "<span onmouseover=\"return overlib('" . $tooltip . "'". $title .", BELOW, RIGHT". $width .");\" onmouseout=\"return nd();\" ". $style .">". $text ."</span>";
511
		}
512
	
513
		return $tip;
514
	}
515
}
516
/**
517
 * Prints an HTML dropdown box named $name using $arr to
518
 * load the drop down.  If $value is in $arr, then $value
519
 * will be the selected option in the dropdown.
520
 * @author gday
521
 * @author soeren
522
 * 
523
 * @param string $name The name of the select element
524
 * @param string $value The pre-selected value
525
 * @param array $arr The array containting $key and $val
526
 * @param int $size The size of the select element
527
 * @param string $multiple use "multiple=\"multiple\" to have a multiple choice select list
528
 * @param string $extra More attributes when needed
529
 * @return string HTML drop-down list
530
 */	
531
function jx_selectList($name, $value, $arr, $size=1, $multiple="", $extra="") {
532
	if( !empty( $arr ) ) {
533
		$html = "<select class=\"inputbox\" name=\"$name\" size=\"$size\" $multiple $extra>\n";
534

  
535
		while (list($key, $val) = each($arr)) {
536
			$selected = "";
537
			if( is_array( $value )) {
538
				if( in_array( $key, $value )) {
539
					$selected = "selected=\"selected\"";
540
				}
541
			}
542
			else {
543
				if(strtolower($value) == strtolower($key) ) {
544
					$selected = "selected=\"selected\"";
545
				}
546
			}
547
			$html .= "<option value=\"$key\" $selected>$val";
548
			$html .= "</option>\n";
549
		}
550

  
551
		$html .= "</select>\n";
552
	}
553
	return $html;
554
}
555
function jx_scriptTag( $src = '', $script = '') {
556
	if( $src!='') {
557
		return '<script type="text/javascript" src="'.$src.'"></script>';
558
	}
559
	if( $script != '') {
560
		return '<script type="text/javascript">'.$script.'</script>';
561
	}
562
}
563
function jx_alertBox( $msg ) {
564
	return jx_scriptTag('', 'alert( \''. @mysql_escape_string( $msg ) .'\' );' );
565
}
566
function jx_docLocation( $url ) {
567
	return jx_scriptTag('', 'document.location=\''. $url .'\';' );
568
}
569
?>
570 0

  
trunk/.include/fun_up.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 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() ? 755 : 0755;
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
?>
141 0

  
trunk/.include/fun_edit.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 fun_edit.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-Edit Functions
39
	
40
	Have Fun...
41
------------------------------------------------------------------------------*/
42
//------------------------------------------------------------------------------
43
function savefile($file_name) {			// save edited file
44
	if( get_magic_quotes_gpc() ) {
45
		$code = stripslashes($GLOBALS['__POST']["code"]);
46
	}
47
	else {
48
		$code = $GLOBALS['__POST']["code"];
49
	}
50
	
51
	$res = $GLOBALS['jx_File']->file_put_contents( $file_name, $code );
52
	
53
	if( $res==false || PEAR::isError( $res )) {
54
		$err = basename($file_name).": ".$GLOBALS["error_msg"]["savefile"];
55
		if( PEAR::isError( $res ) ) {
56
			$err .= $res->getMessage();
57
		}
58
		show_error( $err );
59
	}
60
	
61
}
62
//------------------------------------------------------------------------------
63
function edit_file($dir, $item) {		// edit file
64
	global $mainframe, $mosConfig_live_site;
65
	
66
	$editor_mode = mosGetParam($_REQUEST,'editor_mode', 'simple');
67
	
68
	if(($GLOBALS["permissions"]&01)!=01) 
69
	  show_error($GLOBALS["error_msg"]["accessfunc"]);
70
	$fname = get_abs_item($dir, $item);
71
	if(!get_is_file($fname)) 
72
	  show_error($item.": ".$GLOBALS["error_msg"]["fileexist"]);
73
	if(!get_show_item($dir, $item)) 
74
	  show_error($item.": ".$GLOBALS["error_msg"]["accessfile"]);	
75
	
76
	if(isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"]=="yes") {
77
		// Save / Save As
78
		$item=basename(stripslashes($GLOBALS['__POST']["fname"]));
79
		$fname2=get_abs_item($dir, $item);
80
		if(!isset($item) || $item=="") 
81
		  show_error($GLOBALS["error_msg"]["miscnoname"]);
82
		if($fname!=$fname2 && @$GLOBALS['jx_File']->file_exists($fname2)) 
83
		  show_error($item.": ".$GLOBALS["error_msg"]["itemdoesexist"]);
84
		savefile($fname2);
85
		$fname=$fname2;
86
		if( !empty( $GLOBALS['__POST']['return_to'])) {
87
			$return_to = urldecode($GLOBALS['__POST']['return_to']);
88
			mosRedirect( $return_to );
89
		}
90
		elseif( !empty( $GLOBALS['__POST']['return_to_dir'])) {
91
			mosRedirect( $_SERVER['PHP_SELF'].'?option=com_joomlaxplorer&dir='.$dir, 'The File '.$item.' was saved.');
92
		}
93
	}
94
	
95
	// header
96
	$s_item=get_rel_item($dir,$item);	if(strlen($s_item)>50) $s_item="...".substr($s_item,-47);
97
	show_header($GLOBALS["messages"]["actedit"].": /".$s_item);
98
	
99
	// Form
100
	echo "<br/><form name=\"editfrm\" id=\"editfrm\" method=\"post\" action=\"".make_link("edit",$dir,$item)."\">\n";
101
	if( !empty( $GLOBALS['__GET']['return_to'])) {
102
		$close_action = 'window.location=\''.urldecode($GLOBALS['__GET']['return_to']).'\';';
103
		echo "<input type=\"hidden\" name=\"return_to\" value=\"". $GLOBALS['__GET']['return_to']."\" />\n";
104
	}
105
	else {
106
		$close_action = 'window.location=\''. make_link('list',$dir,NULL)."'";
107
	}
108
	if( $editor_mode == 'codepress' ) {
109
		$submit_action = 'document.editfrm.code.value=CodePress.getCode();document.editfrm.submit();';
110
	} else {
111
		$submit_action = 'document.editfrm.submit();';
112
	}
113
	echo "
114
<table class=\"adminform\">
115
	<tr>
116
		<td style=\"text-align: center;\">
117
			<input type=\"button\" value=\"".$GLOBALS["messages"]["btnsave"]."\" onclick=\"$submit_action\" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
118
			<input type=\"reset\" value=\"".$GLOBALS["messages"]["btnreset"]."\" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
119
			<input type=\"button\" value=\"".$GLOBALS["messages"]["btnclose"]."\" onclick=\"javascript:$close_action\" />
120
		</td>
121
	</tr>
122
	<tr>
123
		<td >
124
			<div style=\"width:70%;text-align: center;float:left;\">
125
				<input type=\"checkbox\" value=\"1\" name=\"return_to_dir\" id=\"return_to_dir\" />
126
				<label for=\"return_to_dir\">".$GLOBALS["messages"]["returndir"]."</label>
127
			</div>";
128
	if( $editor_mode == 'simple' ) {
129
		echo "
130
			<div style=\"width: 20%;float:right;\">".$GLOBALS["messages"]["line"]."
131
				: <input type=\"text\" name=\"txtLine\" class=\"inputbox\" size=\"6\" onchange=\"setCaretPosition(document.editfrm.code, this.value);return false;\" />&nbsp;&nbsp;&nbsp;".$GLOBALS["messages"]["column"]."
132
          		: <input type=\"text\" name=\"txtColumn\" class=\"inputbox\" size=\"6\" readonly=\"readonly\" />
133
          </div>";
134
	}
135
	echo "
136
		</td>
137
	</tr>
138
	<tr><td>";
139

  
140
	echo "<input type=\"hidden\" name=\"dosave\" value=\"yes\" />\n";
141
	echo "<input type=\"hidden\" name=\"editor_mode\" value=\"$editor_mode\" />\n";
142
	
143
	// Show File In TextArea
144
	$content = $GLOBALS['jx_File']->file_get_contents( $fname );
145
	if( get_magic_quotes_runtime()) {
146
		$content = stripslashes( $content );
147
	}
148
	$content = htmlspecialchars( $content );
149
	
150
	if( $editor_mode == 'simple' ) {
151
		echo '[ <strong>'.$GLOBALS['messages']['editor_simple'].'</strong> / <a href="javascript:;" onclick="return toggleEditorMode(\'codepress\');"> '.$GLOBALS['messages']['editor_syntaxhighlight'].'</a> ]';
152
		echo '<div id="editorarea">
153
		<textarea style="width:95%;" name="code" rows="25" cols="120" wrap="off" onmouseup="updatePosition(this)" onmousedown="updatePosition(this)" onkeyup="updatePosition(this)" onkeydown="updatePosition(this)" onfocus="updatePosition(this)">'
154
		. $content 
155
		.'</textarea>
156
		<textarea name="checkcode" style="display:none;">'.$content.'</textarea>
157
		</div><br/>';
158
	} else {
159
		echo '[<a href="javascript:;" onclick="return toggleEditorMode(\'simple\');"> '.$GLOBALS['messages']['editor_simple'].' </a>/ <strong>'.$GLOBALS['messages']['editor_syntaxhighlight'].'</strong> ]';
160
		echo '<code id="codepress" title="'.$dir.'/'.$item.'" class="cp"></code>';
161
		echo '<input type="hidden" name="code" value="" />';
162
		echo '<textarea name="checkcode" style="display:none;">'.$content.'</textarea>';
163
	}
164
	echo "
165
	</td>
166
	</tr>";
167
		if( $editor_mode == 'simple' ) {
168
			// Wordwrap (works only in IE)
169
			?><script type="text/javascript"><!--
170
				function chwrap() {
171
					if(document.editfrm.wrap.checked) {
172
						document.editfrm.code.wrap="soft";
173
					} else {
174
						document.editfrm.code.wrap="off";
175
					}
176
				}
177
			// -->
178
			</script>
179
			<?php
180
			echo "	
181
		<tr>
182
			<td align=\"right\">
183
				<label for=\"wrap\">".$GLOBALS["messages"]["wordwrap"].":</label>
184
				<input type=\"checkbox\" id=\"wrap\" name=\"wrap\" onclick=\"javascript:chwrap();\" value=\"1\">
185
			</td>		
186
		</tr>";
187
		}
188
		
189
		echo "
190
	<tr>
191
		<td align=\"right\">
192
			<label for=\"fname\">".$GLOBALS["messages"]["copyfile"]."</label>
193
			<input type=\"text\" name=\"fname\" value=\"".$item."\" size=\"40\" />
194
		</td>
195
	</tr>
196
</table>
197
<br/>";
198
	
199
	echo "
200
</form>
201
<br/>\n";
202
	
203
?><script language="JavaScript1.2" type="text/javascript">
204
<!--
205
if(document.editfrm && document.editfrm.code) document.editfrm.code.focus();
206

  
207
function toggleEditorMode( toggleTo ) {
208
	if( $('codepress')) {
209
		if( CodePress.getCode() != document.editfrm.checkcode.value ) {
210
			if( !confirm('You have unsaved changes. Are you sure you want to toggle the Editor Mode?')) {
211
				return false;
212
			}
213
		}
214
	} else {
215
		if( document.editfrm.code.value != document.editfrm.checkcode.value ) {
216
			if( !confirm('You have unsaved changes. Are you sure you want to toggle the Editor Mode?')) {
217
				return false;
218
			}
219
		}
220
	}
221
	document.editfrm.dosave.value='';
222
	document.editfrm.editor_mode.value=toggleTo;
223
	document.editfrm.submit();
224
}
225

  
226
//http://www.bazon.net/mishoo/home.epl?NEWS_ID=1345
227
function doGetCaretPosition (textarea) {
228

  
229
	var txt = textarea.value;
230
	var len = txt.length;
231
	var erg = txt.split("\n");
232
	var pos = -1;
233
	if(typeof textarea.selectionStart != "undefined") { // FOR MOZILLA
234
		pos = textarea.selectionStart;
235
	}
236
	else if(typeof document.selection != "undefined") { // FOR MSIE
237
		range_sel = document.selection.createRange();
238
		range_obj = textarea.createTextRange();
239
		range_obj.moveToBookmark(range_sel.getBookmark());
240
		range_obj.moveEnd('character',textarea.value.length);
241
		pos = len - range_obj.text.length;
242
	}
243
	if(pos != -1) {
244
		var ind = 0;
245
		for(;erg.length;ind++) {
246
			len = erg[ind].length + 1;
247
			if(pos < len)
248
			break;
249
			pos -= len;
250
		}
251
		ind++; pos++;
252
		return [ind, pos]; // ind = LINE, pos = COLUMN
253

  
254
	}
255
}
256
/**
257
* This function allows us to change the position of the caret
258
* (cursor) in the textarea
259
* Various workarounds for IE, Firefox and Opera are included
260
* Firefox doesn't count empty lines, IE does...
261
*/
262
function setCaretPosition( textarea, linenum ) {
263
	if (isNaN(linenum)) {
264
		updatePosition( textarea );
265
		return;
266
	}
267
	var txt = textarea.value;
268
	var len = txt.length;
269
	var erg = txt.split("\n");
270
		
271
	var ind = 0;
272
	var pos = 0;
273
	var nonempty = -1;
274
	var empty = -1;
275
	for(;ind < linenum;ind++) {
276
		/*alert( "Springe zu Zeile: "+linenum
277
				+"\naktuelle Zeile: "+ (ind+1) 
278
				+ "\naktuelle Position: "+pos 
279
				+ "\nText in dieser Zeile: "+erg[ind]);*/
280
		if( !erg[ind] && pos < len ) { empty++; pos++; continue; }
281
		else if( !erg[ind] ) break;
282
		pos += erg[ind].length;
283
		nonempty++;
284
	}
285
	try {
286
		pos -= erg[ind-1].length;	
287
	} catch(e) {}
288
	
289
	textarea.focus();
290
	
291
	if(textarea.setSelectionRange)
292
	{
293
		pos += nonempty;
294
		textarea.setSelectionRange(pos,pos);
295
	}
296
	else if (textarea.createTextRange) {
297
		pos -= empty;
298
		var range = textarea.createTextRange();
299
		range.collapse(true);
300
		range.moveEnd('character', pos);
301
		range.moveStart('character', pos);
302
		
303
		range.select();
304
	}
305
}
306
/** 
307
* Updates the Position Indicator fields
308
*/
309
function updatePosition(textBox) {
310
	var posArray = doGetCaretPosition(textBox);
311
    document.forms[0].txtLine.value = posArray[0];
312
    document.forms[0].txtColumn.value = posArray[1];
313
}
314
// -->
315
$ = function() { return document.getElementById(arguments[0]); }
316
</script><?php
317

  
318
	if( $editor_mode == 'codepress') {
319
		echo '<script src="'.$mosConfig_live_site.'/administrator/components/com_joomlaxplorer/_js/codepress/codepress.js" type="text/javascript" id="cp-script" lang="en-us"> </script>';
320
	}
321
}
322
//------------------------------------------------------------------------------
323
?>
324 0

  
trunk/.include/footer.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 footer.php, released on 2003-01-25.
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
	Footer File
39
	
40
	Have Fun...
41
------------------------------------------------------------------------------*/
42
//------------------------------------------------------------------------------
43
function show_footer() {			// footer for html-page
44
	echo"\n<br style=\"clear:both;\"/>
45
	<small>
46
	<a class=\"title\" href=\"".$GLOBALS['jx_home']."\" target=\"_blank\">joomlaXplorer</a>
47
 (<a href=\"http://virtuemart.net/index2.php?option=com_versions&amp;catid=2&amp;myVersion=". $GLOBALS['jx_version'] ."\" onclick=\"javascript:void window.open('http://virtuemart.net/index2.php?option=com_versions&catid=2&myVersion=". $GLOBALS['jx_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>)
48
	</small>
49
	</div>
50
	<hr/>";
51
}
52
//------------------------------------------------------------------------------
53
?>
54 0

  
trunk/.include/fun_mkitem.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 fun_mkdir.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
	Make Dir/File Functions
39
	
40
	Have Fun...
41
------------------------------------------------------------------------------*/
42
//------------------------------------------------------------------------------
43
function make_item($dir) {		// make new directory or file
44
	if(($GLOBALS["permissions"]&01)!=01) show_error($GLOBALS["error_msg"]["accessfunc"]);
45
	
46
	$mkname=$GLOBALS['__POST']["mkname"];
47
	$mktype=$GLOBALS['__POST']["mktype"];
48
	$symlink_target = $GLOBALS['__POST']['symlink_target'];
49
	
50
	$mkname=basename(stripslashes($mkname));
51
	if($mkname=="") show_error($GLOBALS["error_msg"]["miscnoname"]);
52
	
53
	$new = get_abs_item($dir,$mkname);
54

  
55
	if(@$GLOBALS['jx_File']->file_exists($new)) show_error($mkname.": ".$GLOBALS["error_msg"]["itemdoesexist"]);
56
	
57
	if($mktype=="dir") {
58
		$ok=@$GLOBALS['jx_File']->mkdir($new, 0777);
59
		$err=$GLOBALS["error_msg"]["createdir"];
60
	} elseif( $mktype == 'file') {
61
		$ok=@$GLOBALS['jx_File']->mkfile($new);
62
		$err=$GLOBALS["error_msg"]["createfile"];
63
	} elseif( $mktype == 'symlink' ) {
64
		if( empty( $symlink_target )) {
65
			show_error('Please provide a valid <strong>target</strong> for the symbolic link.');
66
		}
67
		if( !file_exists($symlink_target) || !is_readable($symlink_target)) {
68
			show_error('The file you wanted to make a symbolic link to does not exist or is not accessible by PHP.');
69
		}
70
		$ok = symlink( $symlink_target, $new );
71
		$err = 'The symbolic link could not be created.';
72
	}
73
	
74
	if($ok===false || PEAR::isError( $ok )) {
75
		if( PEAR::isError( $ok ) ) $err.= $ok->getMessage();
76
		show_error($err);
77
	}
78
	
79
	header("Location: ".make_link("list",$dir,NULL));
80
}
81
//------------------------------------------------------------------------------
82
?>
83 0

  
trunk/.include/fun_admin.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 fun_admin.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
	Administrative Functions
39
	
40
	Have Fun...
41
------------------------------------------------------------------------------*/
42
//------------------------------------------------------------------------------
43
function admin($admin, $dir) {			// Change Password & Manage Users Form
44
	show_header($GLOBALS["messages"]["actadmin"]);
45
	
46
	// Javascript functions:
47
	include _QUIXPLORER_PATH . "/.include/js_admin.php";
48
	
49
	// Change Password
50
	echo "<br/><HR width=\"95%\"><TABLE width=\"350\"><tr><td colspan=\"2\" class=\"header\"><B>";
51
	echo $GLOBALS["messages"]["actchpwd"].":</B></td></tr>\n";
52
	echo "<FORM name=\"chpwd\" action=\"".make_link("admin",$dir,NULL)."\" method=\"post\">\n";
53
	echo "<input type=\"hidden\" name=\"action2\" value=\"chpwd\">\n";
54
	echo "<tr><td>".$GLOBALS["messages"]["miscoldpass"].": </td><td align=\"right\">";
55
	echo "<input type=\"password\" name=\"oldpwd\" size=\"25\"></td></tr>\n";
56
	echo "<tr><td>".$GLOBALS["messages"]["miscnewpass"].": </td><td align=\"right\">";
57
	echo "<input type=\"password\" name=\"newpwd1\" size=\"25\"></td></tr>\n";
58
	echo "<tr><td>".$GLOBALS["messages"]["miscconfnewpass"].": </td><td align=\"right\">";
59
	echo "<input type=\"password\" name=\"newpwd2\" size=\"25\"></td></tr>\n";
60
	echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" value=\"".$GLOBALS["messages"]["btnchange"];
61
	echo "\" onClick=\"return check_pwd();\">\n</td></tr></FORM></TABLE>\n";
62
	
63
	// Edit / Add / Remove User
64
	if($admin) {
65
		echo "<HR width=\"95%\"><TABLE width=\"350\"><tr><td colspan=\"6\" class=\"header\" nowrap>";
66
		echo "<B>".$GLOBALS["messages"]["actusers"].":</B></td></tr>\n";
67
		echo "<tr><td colspan=\"5\">".$GLOBALS["messages"]["miscuseritems"]."</td></tr>\n";
68
		echo "<FORM name=\"userform\" action=\"".make_link("admin",$dir,NULL)."\" method=\"post\">\n";
69
		echo "<input type=\"hidden\" name=\"action2\" value=\"edituser\">\n";
70
		$cnt=count($GLOBALS["users"]);
71
		for($i=0;$i<$cnt;++$i) {
72
			// Username & Home dir:
73
			$user=$GLOBALS["users"][$i][0];	if(strlen($user)>15) $user=substr($user,0,12)."...";
74
			$home=$GLOBALS["users"][$i][2];	if(strlen($home)>30) $home=substr($home,0,27)."...";
75
			
76
			echo "<tr><td width=\"1%\"><input TYPE=\"radio\" name=\"user\" value=\"";
77
			echo $GLOBALS["users"][$i][0]."\"".(($i==0)?" checked":"")."></td>\n";
78
			echo "<td width=\"30%\">".$user."</td><td width=\"60%\">".$home."</td>\n";
79
			echo "<td width=\"3%\">".($GLOBALS["users"][$i][4]?$GLOBALS["messages"]["miscyesno"][2]:
80
				$GLOBALS["messages"]["miscyesno"][3])."</td>\n";
81
			echo "<td width=\"3%\">".$GLOBALS["users"][$i][6]."</td>\n";
82
			echo "<td width=\"3%\">".($GLOBALS["users"][$i][7]?$GLOBALS["messages"]["miscyesno"][2]:
83
				$GLOBALS["messages"]["miscyesno"][3])."</td></tr>\n";
84
		}
85
		echo "<tr><td colspan=\"6\" align=\"right\">";
86
		echo "<input type=\"button\" value=\"".$GLOBALS["messages"]["btnadd"];
87
		echo "\" onClick=\"javascript:location='".make_link("admin",$dir,NULL)."&action2=adduser';\">\n";
88
		echo "<input type=\"button\" value=\"".$GLOBALS["messages"]["btnedit"];
89
		echo "\" onClick=\"javascript:Edit();\">\n";
90
		echo "<input type=\"button\" value=\"".$GLOBALS["messages"]["btnremove"];
91
		echo "\" onClick=\"javascript:Delete();\">\n</td></tr></FORM></TABLE>\n";
92
	}
93
	
94
	echo "<HR width=\"95%\"><input type=\"button\" value=\"".$GLOBALS["messages"]["btnclose"];
95
	echo "\" onClick=\"javascript:location='".make_link("list",$dir,NULL)."';\"><br/><br/>\n";
96
?><script language="JavaScript1.2" type="text/javascript">
97
<!--
98
	if(document.chpwd) document.chpwd.oldpwd.focus();
99
// -->
100
</script><?php
101
}
102
//------------------------------------------------------------------------------
103
function changepwd($dir) {			// Change Password
104
	$pwd=md5(stripslashes($GLOBALS['__POST']["oldpwd"]));
105
	if($GLOBALS['__POST']["newpwd1"]!=$GLOBALS['__POST']["newpwd2"]) show_error($GLOBALS["error_msg"]["miscnopassmatch"]);
106
	
107
	$data=find_user($GLOBALS['__SESSION']["s_user"],$pwd);
108
	if($data==NULL) show_error($GLOBALS["error_msg"]["miscnouserpass"]);
109
	
110
	$data[1]=md5(stripslashes($GLOBALS['__POST']["newpwd1"]));
111
	if(!update_user($data[0],$data)) show_error($data[0].": ".$GLOBALS["error_msg"]["chpass"]);
112
	activate_user($data[0],NULL);
113
	
114
	header("location: ".make_link("list",$dir,NULL));
115
}
116
//------------------------------------------------------------------------------
117
function adduser($dir) {			// Add User
118
	if(isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"]=="true") {
119
		$user=stripslashes($GLOBALS['__POST']["user"]);
120
		if($user=="" || $GLOBALS['__POST']["home_dir"]=="") {
121
			show_error($GLOBALS["error_msg"]["miscfieldmissed"]);
122
		}
123
		if($GLOBALS['__POST']["pass1"]!=$GLOBALS['__POST']["pass2"]) show_error($GLOBALS["error_msg"]["miscnopassmatch"]);
124
		$data=find_user($user,NULL);
125
		if($data!=NULL) show_error($user.": ".$GLOBALS["error_msg"]["miscuserexist"]);
126
		
127
		$data=array($user,md5(stripslashes($GLOBALS['__POST']["pass1"])),
128
			stripslashes($GLOBALS['__POST']["home_dir"]),stripslashes($GLOBALS['__POST']["home_url"]),
129
			$GLOBALS['__POST']["show_hidden"],stripslashes($GLOBALS['__POST']["no_access"]),
130
			$GLOBALS['__POST']["permissions"],$GLOBALS['__POST']["active"]);
131
			
132
		if(!add_user($data)) show_error($user.": ".$GLOBALS["error_msg"]["adduser"]);
133
		header("location: ".make_link("admin",$dir,NULL));
134
		return;
135
	}
136
	
137
	show_header($GLOBALS["messages"]["actadmin"].": ".$GLOBALS["messages"]["miscadduser"]);
138
	
139
	// Javascript functions:
140
	include _QUIXPLORER_PATH . "/.include/js_admin2.php";
141
	
142
	echo "<form name=\"adduser\" action=\"".make_link("admin",$dir,NULL)."&action2=adduser\" method=\"post\">\n";
143
	echo "<input type=\"hidden\" name=\"confirm\" value=\"true\"><br/><TABLE width=\"450\">\n";
144
	echo "<tr><td>".$GLOBALS["messages"]["miscusername"].":</td>\n";
145
		echo "<td align=\"right\"><input type=\"text\" name=\"user\" size=\"30\"></td></tr>\n";
146
	echo "<tr><td>".$GLOBALS["messages"]["miscpassword"].":</td>\n";
147
		echo "<td align=\"right\"><input type=\"password\" name=\"pass1\" size=\"30\"></td></tr>\n";
148
	echo "<tr><td>".$GLOBALS["messages"]["miscconfpass"].":</td>\n";
149
		echo "<td align=\"right\"><input type=\"password\" name=\"pass2\" size=\"30\"></td></tr>\n";
150
	echo "<tr><td>".$GLOBALS["messages"]["mischomedir"].":</td>\n";
151
		echo "<td align=\"right\"><input type=\"text\" name=\"home_dir\" size=\"30\" value=\"";
152
		echo $GLOBALS["home_dir"]."\"></td></tr>\n";
153
	echo "<tr><td>".$GLOBALS["messages"]["mischomeurl"].":</td>\n";
154
		echo "<td align=\"right\"><input type=\"text\" name=\"home_url\" size=\"30\" value=\"";
155
		echo $GLOBALS["home_url"]."\"></td></tr>\n";
156
	echo "<tr><td>".$GLOBALS["messages"]["miscshowhidden"].":</td>";
157
		echo "<td align=\"right\"><select name=\"show_hidden\">\n";
158
		echo "<option value=\"0\">".$GLOBALS["messages"]["miscyesno"][1]."</option>";
159
		echo "<option value=\"1\">".$GLOBALS["messages"]["miscyesno"][0]."</option>\n";
160
		echo "</select></td></tr>\n";
161
	echo "<tr><td>".$GLOBALS["messages"]["mischidepattern"].":</td>\n";
162
		echo "<td align=\"right\"><input type=\"text\" name=\"no_access\" size=\"30\" value=\"^\\.ht\"></td></tr>\n";
163
	echo "<tr><td>".$GLOBALS["messages"]["miscperms"].":</td><td align=\"right\"><select name=\"permissions\">\n";
164
		$permvalues = array(0,1,2,3,7);
165
		for($i=0;$i<count($GLOBALS["messages"]["miscpermnames"]);++$i) {
166
			echo "<option value=\"".$permvalues[$i]."\">";
167
			echo $GLOBALS["messages"]["miscpermnames"][$i]."</option>\n";
168
		}
169
		echo "</select></td></tr>\n";
170
	echo "<tr><td>".$GLOBALS["messages"]["miscactive"].":</td>";
171
		echo "<td align=\"right\"><select name=\"active\">\n";
172
		echo "<option value=\"1\">".$GLOBALS["messages"]["miscyesno"][0]."</option>";
173
		echo "<option value=\"0\">".$GLOBALS["messages"]["miscyesno"][1]."</option>\n";
174
		echo "</select></td></tr>\n";
175
	echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" value=\"".$GLOBALS["messages"]["btnadd"];
176
		echo "\" onClick=\"return check_pwd();\">\n<input type=\"button\" value=\"";
177
		echo $GLOBALS["messages"]["btncancel"]."\" onClick=\"javascript:location='";
178
		echo make_link("admin",$dir,NULL)."';\"></td></tr></FORM></TABLE><br/>\n";
179
?><script language="JavaScript1.2" type="text/javascript">
180
<!--
181
	if(document.adduser) document.adduser.user.focus();
182
// -->
183
</script><?php
184
}
185
//------------------------------------------------------------------------------
186
function edituser($dir) {			// Edit User
187
	$user=stripslashes($GLOBALS['__POST']["user"]);
188
	$data=find_user($user,NULL);
189
	if($data==NULL) show_error($user.": ".$GLOBALS["error_msg"]["miscnofinduser"]);
190
	if($self=($user==$GLOBALS['__SESSION']["s_user"])) $dir="";
191
	
192
	if(isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"]=="true") {
193
		$nuser=stripslashes($GLOBALS['__POST']["nuser"]);
194
		if($nuser=="" || $GLOBALS['__POST']["home_dir"]=="") {
195
			show_error($GLOBALS["error_msg"]["miscfieldmissed"]);
196
		}
197
		if(isset($GLOBALS['__POST']["chpass"]) &&
198
			$GLOBALS['__POST']["chpass"]=="true")
199
		{
200
			if($GLOBALS['__POST']["pass1"]!=$GLOBALS['__POST']["pass2"]) show_error($GLOBALS["error_msg"]["miscnopassmatch"]);
201
			$pass=md5(stripslashes($GLOBALS['__POST']["pass1"]));
202
		} else $pass=$data[1];
203
		
204
		if($self) $GLOBALS['__POST']["active"]=1;
205
		
206
		$data=array($nuser,$pass,stripslashes($GLOBALS['__POST']["home_dir"]),
207
			stripslashes($GLOBALS['__POST']["home_url"]),$GLOBALS['__POST']["show_hidden"],
208
			stripslashes($GLOBALS['__POST']["no_access"]),$GLOBALS['__POST']["permissions"],$GLOBALS['__POST']["active"]);
209
			
210
		if(!update_user($user,$data)) show_error($user.": ".$GLOBALS["error_msg"]["saveuser"]);
211
		if($self) activate_user($nuser,NULL);
212
		
213
		header("location: ".make_link("admin",$dir,NULL));
214
		return;
215
	}
216
	
217
	show_header($GLOBALS["messages"]["actadmin"].": ".sprintf($GLOBALS["messages"]["miscedituser"],$data[0]));
218
	
219
	// Javascript functions:
220
	include _QUIXPLORER_PATH . "/.include/js_admin3.php";
221
	
222
	echo "<FORM name=\"edituser\" action=\"".make_link("admin",$dir,NULL)."&action2=edituser\" method=\"post\">\n";
223
	echo "<input type=\"hidden\" name=\"confirm\" value=\"true\"><input type=\"hidden\" name=\"user\" value=\"".$data[0]."\">\n";
224
	echo "<br/><TABLE width=\"450\">\n";
225
	echo "<tr><td>".$GLOBALS["messages"]["miscusername"].":</td>\n";
226
		echo "<td align=\"right\"><input type\"text\" name=\"nuser\" size=\"30\" value=\"";
227
		echo $data[0]."\"></td></tr>\n";
228
	echo "<tr><td>".$GLOBALS["messages"]["miscconfpass"].":</td>\n";
229
		echo "<td align=\"right\"><input type=\"password\" name=\"pass1\" size=\"30\"></td></tr>\n";
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff