forked from fengoffice/fengoffice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathck_upload_handler.php
36 lines (28 loc) · 1.22 KB
/
ck_upload_handler.php
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
<?php
$exp = explode("/", $_SERVER['REQUEST_URI']);
$iname = $exp[1];
define('CONSOLE_MODE', true);
define('APP_ROOT', realpath(dirname(__FILE__)));
define('TEMP_PATH', realpath(APP_ROOT . '/tmp/'));
// Include library
//require_once APP_ROOT . '/index.php';
require_once APP_ROOT . '/config/config.php';
if (count($_FILES) > 0) {
$file_info = array_shift($_FILES);
$file_name = rand() . $file_info['name'];
$file_name = preg_replace("/[^a-zA-Z0-9.]/", "_", $file_name);
$file_url = ROOT_URL . "/tmp/" . $file_name;
//Exclude non image files.
/* $pattern = '/^.*\.(jpeg|JPEG|jpg|JPG|gif|GIF|png|PNG|bmp|BMP)$/';
preg_match($pattern, $file_name, $matches, PREG_OFFSET_CAPTURE);
if(count($matches) <= 0)
die('Invalid File');*/
copy($file_info['tmp_name'], TEMP_PATH . "/" . $file_name);
unlink($file_info['tmp_name']);
$err_msg = "";
$func = preg_replace("/[^0-9]/", "", $_GET['CKEditorFuncNum']);
echo "<script type=\"text/javascript\">";
echo "window.parent.CKEDITOR.tools.callFunction($func, '" . str_replace("'", "\\'", $file_url) . "', '" .str_replace("'", "\\'", $err_msg). "');";
echo "</script>";
}
?>