Blame view

js/_tiny_mce/plugins/ajaxfilemanager/ajax_delete_file.php 1.31 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
  <?php
  	/**
  	 * delete selected files
  	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
  	 * @link www.phpletter.com
  	 * @since 22/April/2007
  	 *
  	 */
  	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
  	$error = "";
  	if(!isset($_POST['selectedDoc']) || !is_array($_POST['selectedDoc']) || sizeof($_POST['selectedDoc']) < 1)
  	{
  		$error = ERR_NOT_FILE_SELECTED;
  	}
  	elseif(empty($_POST['currentFolderPath']) || !isUnderRoot($_POST['currentFolderPath']))
  	{
  		$error = ERR_FOLDER_PATH_NOT_ALLOWED;
  	}
  	else 
  	{
  		include_once(CLASS_FILE);
  		$file = new file();
  		
  		foreach($_POST['selectedDoc'] as $doc)
  		{
  			if(is_dir($_POST['currentFolderPath'] . $doc) 
  				&& (!CONFIG_SYS_EXC_DIR_PATTERN || !preg_match(CONFIG_SYS_EXC_DIR_PATTERN, $doc) 
  				&& (!CONFIG_SYS_INC_DIR_PATTERN || preg_match(CONFIG_SYS_INC_DIR_PATTERN, $doc))))
  				{
  					$file->delete(addTrailingSlash($_POST['currentFolderPath']) . $doc);
  				}elseif(is_file($_POST['currentFolderPath'] . $doc) 
  				&& (!CONFIG_SYS_EXC_FILE_PATTERN || !preg_match(CONFIG_SYS_EXC_FILE_PATTERN, $doc) 
  				&& (!CONFIG_SYS_INC_FILE_PATTERN || preg_match(CONFIG_SYS_INC_FILE_PATTERN, $doc))))
  				{
  					$file->delete(addTrailingSlash($_POST['currentFolderPath']) . $doc);
  				}
  			
  		}
  	}
  	echo "{error:'" . $error . "'}";
  ?>