Blame view

js/_tiny_mce/plugins/ajaxfilemanager/ajax_file_upload.php 2.19 KB
42868d70   andryeyev   Создал GIT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  <?php
  	/**
  	 * processing the uploaded files
  	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
  	 * @link www.phpletter.com
  	 * @since 22/May/2007
  	 *
  	 */	
  	
  	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
  	echo "{";
  	$error = "";
  	$info = "";
  	include_once(CLASS_UPLOAD);
  	$upload = new Upload();
  								
  	$upload->setInvalidFileExt(explode(",", CONFIG_UPLOAD_INVALID_EXTS));
  	if(empty($_POST['currentFolderPath']) || !isUnderRoot($_POST['currentFolderPath']))
  	{
  		$error = ERR_FOLDER_PATH_NOT_ALLOWED;
  	}else	if(!$upload->isFileUploaded('new_file'))
  	{
  		$error = ERR_FILE_NOT_UPLOADED;
  	}else if(!$upload->moveUploadedFile($_POST['currentFolderPath']))
  	{
  		$error = ERR_FILE_MOVE_FAILED;
  	}	
  	elseif(!$upload->isPermittedFileExt(explode(",", CONFIG_UPLOAD_VALID_EXTS)))
  	{		
  		$error = ERR_FILE_TYPE_NOT_ALLOWED;
  	}elseif(defined('CONFIG_UPLOAD_MAXSIZE') && CONFIG_UPLOAD_MAXSIZE && $upload->isSizeTooBig(CONFIG_UPLOAD_MAXSIZE))
  	{		
  		 $error = sprintf(ERROR_FILE_TOO_BID, transformFileSize(CONFIG_UPLOAD_MAXSIZE));
  	}else
  	{
  							include_once(CLASS_FILE);
  							$path = $upload->getFilePath();
  							$obj = new file($path);
  							$tem = $obj->getFileInfo();							
  							if(sizeof($tem))
  							{	
  								include_once(CLASS_MANAGER);
  							
  								$manager = new manager($upload->getFilePath(), false);			
  															
  								$fileType = $manager->getFileType($upload->getFileName());
  
  								foreach($fileType as $k=>$v)
  								{
  									$tem[$k] = $v;
  								}
  								
  								$tem['path'] = backslashToSlash($path);		
  								$tem['type'] = "file";
  								$tem['size'] = transformFileSize($tem['size']);
  								$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
  								$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);
  								$obj->close();
  								foreach($tem as $k=>$v)
  								{
  										$info .= sprintf(", %s:'%s'", $k, $v);									
  								}
  
  								$info .= sprintf(", url:'%s'",  getFileUrl($path));
  								$info .= sprintf(", tipedit:'%s'",  TIP_DOC_RENAME);		
  
  																				
  							}else 
  							{
  								$error = ERR_FILE_NOT_AVAILABLE;
  							}
  
  
  	}
  	echo "error:'" . $error . "'";
  	echo $info;
  	echo "}";
  	
  ?>