Add files via upload
This commit is contained in:
		
							
								
								
									
										146
									
								
								z_daisy/route/doc.htm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										146
									
								
								z_daisy/route/doc.htm
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,146 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
!defined('DEBUG') AND exit('Access Denied.');
 | 
			
		||||
 | 
			
		||||
$action = param(1);
 | 
			
		||||
 | 
			
		||||
// hook thread_start.php
 | 
			
		||||
 | 
			
		||||
// 发表主题帖 | create new thread
 | 
			
		||||
if($action == 'create') {
 | 
			
		||||
	
 | 
			
		||||
	// hook thread_create_get_post.php
 | 
			
		||||
		
 | 
			
		||||
	user_login_check();
 | 
			
		||||
 | 
			
		||||
	if($method == 'GET') {
 | 
			
		||||
		
 | 
			
		||||
		// hook thread_create_get_start.php
 | 
			
		||||
		
 | 
			
		||||
		$fid = param(2, 0);
 | 
			
		||||
		$forum = $fid ? forum_read($fid) : array();
 | 
			
		||||
		
 | 
			
		||||
		$forumlist_allowthread = forum_list_access_filter($forumlist, $gid, 'allowthread');
 | 
			
		||||
		$forumarr = xn_json_encode(arrlist_key_values($forumlist_allowthread, 'fid', 'name'));
 | 
			
		||||
		if(empty($forumlist_allowthread)) {
 | 
			
		||||
			message(-1, lang('user_group_insufficient_privilege'));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		$header['title'] = lang('create_thread');
 | 
			
		||||
		$header['mobile_title'] = $fid ? $forum['name'] : '';
 | 
			
		||||
		$header['mobile_linke'] = url("forum-$fid");
 | 
			
		||||
		
 | 
			
		||||
		// hook thread_create_get_end.php
 | 
			
		||||
		
 | 
			
		||||
		include _include(APP_PATH.'view/htm/post.htm');
 | 
			
		||||
		
 | 
			
		||||
	} else {
 | 
			
		||||
		
 | 
			
		||||
		// hook thread_create_thread_start.php
 | 
			
		||||
		
 | 
			
		||||
		include XIUNOPHP_PATH.'xn_html_safe.func.php';
 | 
			
		||||
		
 | 
			
		||||
		$fid = param('fid', 0);
 | 
			
		||||
		$forum = forum_read($fid);
 | 
			
		||||
		empty($forum) AND message('fid', lang('forum_not_exists'));
 | 
			
		||||
		
 | 
			
		||||
		$r = forum_access_user($fid, $gid, 'allowthread');
 | 
			
		||||
		!$r AND message(-1, lang('user_group_insufficient_privilege'));
 | 
			
		||||
		
 | 
			
		||||
		$subject = htmlspecialchars(param('subject', '', FALSE));
 | 
			
		||||
		empty($subject) AND message('subject', lang('please_input_subject'));
 | 
			
		||||
		xn_strlen($subject) > 128 AND message('subject', lang('subject_length_over_limit', array('maxlength'=>128)));
 | 
			
		||||
		
 | 
			
		||||
		$message = param('message', '', FALSE);
 | 
			
		||||
		empty($message) AND message('message', lang('please_input_message'));
 | 
			
		||||
		$doctype = param('doctype', 0);
 | 
			
		||||
		$doctype > 10 AND message(-1, lang('doc_type_not_supported'));
 | 
			
		||||
		xn_strlen($message) > 2028000 AND message('message', lang('message_too_long'));
 | 
			
		||||
		
 | 
			
		||||
		$thread = array (
 | 
			
		||||
			'fid'=>$fid,
 | 
			
		||||
			'uid'=>$uid,
 | 
			
		||||
			'sid'=>$sid,
 | 
			
		||||
			'subject'=>$subject,
 | 
			
		||||
			'message'=>$message,
 | 
			
		||||
			'time'=>$time,
 | 
			
		||||
			'longip'=>$longip,
 | 
			
		||||
			'doctype'=>$doctype,
 | 
			
		||||
		);
 | 
			
		||||
		
 | 
			
		||||
		// hook thread_create_thread_before.php
 | 
			
		||||
		
 | 
			
		||||
		$tid = thread_create($thread, $pid);
 | 
			
		||||
		$pid === FALSE AND message(-1, lang('create_post_failed'));
 | 
			
		||||
		$tid === FALSE AND message(-1, lang('create_thread_failed'));
 | 
			
		||||
		
 | 
			
		||||
		// hook thread_create_thread_end.php
 | 
			
		||||
		message(0, lang('create_thread_sucessfully'));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
// 帖子详情 | post detail
 | 
			
		||||
} else {
 | 
			
		||||
	
 | 
			
		||||
	// thread-{tid}-{page}-{keyword}.htm
 | 
			
		||||
	$tid = param(1, 0);
 | 
			
		||||
	$page = param(2, 1);
 | 
			
		||||
	$keyword = param(3);
 | 
			
		||||
	$pagesize = $conf['postlist_pagesize'];
 | 
			
		||||
	//$pagesize = 10;
 | 
			
		||||
	//$page == 1 AND $pagesize++;
 | 
			
		||||
	
 | 
			
		||||
	// hook thread_info_start.php
 | 
			
		||||
	
 | 
			
		||||
	$thread = thread_read($tid);
 | 
			
		||||
	empty($thread) AND message(-1, lang('thread_not_exists'));;
 | 
			
		||||
	
 | 
			
		||||
	$fid = $thread['fid'];
 | 
			
		||||
	$forum = forum_read($fid);
 | 
			
		||||
	empty($forum) AND message(3, lang('forum_not_exists'));
 | 
			
		||||
	
 | 
			
		||||
	$postlist = post_find_by_tid($tid, $page, $pagesize);
 | 
			
		||||
	empty($postlist) AND message(4, lang('post_not_exists'));
 | 
			
		||||
	
 | 
			
		||||
	if($page == 1) {
 | 
			
		||||
		empty($postlist[$thread['firstpid']]) AND message(-1, lang('data_malformation'));
 | 
			
		||||
		$first = $postlist[$thread['firstpid']];
 | 
			
		||||
		unset($postlist[$thread['firstpid']]);
 | 
			
		||||
		$attachlist = $imagelist = $filelist = array();
 | 
			
		||||
		
 | 
			
		||||
		// 如果是大站,可以用单独的点击服务,减少 db 压力
 | 
			
		||||
		// if request is huge, separate it from mysql server
 | 
			
		||||
		thread_inc_views($tid);
 | 
			
		||||
	} else {
 | 
			
		||||
		$first = post_read($thread['firstpid']);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	$keywordurl = '';
 | 
			
		||||
	if($keyword) {
 | 
			
		||||
		$thread['subject'] = post_highlight_keyword($thread['subject'], $keyword);
 | 
			
		||||
		//$first['message'] = post_highlight_keyword($first['subject']);
 | 
			
		||||
		$keywordurl = "-$keyword";
 | 
			
		||||
	}
 | 
			
		||||
	$allowpost = forum_access_user($fid, $gid, 'allowpost') ? 1 : 0;
 | 
			
		||||
	$allowupdate = forum_access_mod($fid, $gid, 'allowupdate') ? 1 : 0;
 | 
			
		||||
	$allowdelete = forum_access_mod($fid, $gid, 'allowdelete') ? 1 : 0;
 | 
			
		||||
	
 | 
			
		||||
	forum_access_user($fid, $gid, 'allowread') OR message(-1, lang('user_group_insufficient_privilege'));
 | 
			
		||||
	
 | 
			
		||||
	$pagination = pagination(url("thread-$tid-{page}$keywordurl"), $thread['posts'] + 1, $page, $pagesize);
 | 
			
		||||
	
 | 
			
		||||
	$header['title'] = $thread['subject'].'-'.$forum['name'].'-'.$conf['sitename']; 
 | 
			
		||||
	//$header['mobile_title'] = lang('thread_detail');
 | 
			
		||||
	$header['mobile_title'] = $forum['name'];;
 | 
			
		||||
	$header['mobile_link'] = url("forum-$fid");
 | 
			
		||||
	$header['keywords'] = ''; 
 | 
			
		||||
	$header['description'] = $thread['subject']; 
 | 
			
		||||
	$_SESSION['fid'] = $fid;
 | 
			
		||||
	
 | 
			
		||||
	// hook thread_info_end.php
 | 
			
		||||
	include _include(APP_PATH.'plugin/z_doc/view/htm/doc.htm');
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// hook thread_end.php
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										146
									
								
								z_daisy/route/doc.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										146
									
								
								z_daisy/route/doc.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,146 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
!defined('DEBUG') AND exit('Access Denied.');
 | 
			
		||||
 | 
			
		||||
$action = param(1);
 | 
			
		||||
 | 
			
		||||
// hook thread_start.php
 | 
			
		||||
 | 
			
		||||
// 发表主题帖 | create new thread
 | 
			
		||||
if($action == 'create') {
 | 
			
		||||
	
 | 
			
		||||
	// hook thread_create_get_post.php
 | 
			
		||||
		
 | 
			
		||||
	user_login_check();
 | 
			
		||||
 | 
			
		||||
	if($method == 'GET') {
 | 
			
		||||
		
 | 
			
		||||
		// hook thread_create_get_start.php
 | 
			
		||||
		
 | 
			
		||||
		$fid = param(2, 0);
 | 
			
		||||
		$forum = $fid ? forum_read($fid) : array();
 | 
			
		||||
		
 | 
			
		||||
		$forumlist_allowthread = forum_list_access_filter($forumlist, $gid, 'allowthread');
 | 
			
		||||
		$forumarr = xn_json_encode(arrlist_key_values($forumlist_allowthread, 'fid', 'name'));
 | 
			
		||||
		if(empty($forumlist_allowthread)) {
 | 
			
		||||
			message(-1, lang('user_group_insufficient_privilege'));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		$header['title'] = lang('create_thread');
 | 
			
		||||
		$header['mobile_title'] = $fid ? $forum['name'] : '';
 | 
			
		||||
		$header['mobile_linke'] = url("forum-$fid");
 | 
			
		||||
		
 | 
			
		||||
		// hook thread_create_get_end.php
 | 
			
		||||
		
 | 
			
		||||
		include _include(APP_PATH.'view/htm/post.htm');
 | 
			
		||||
		
 | 
			
		||||
	} else {
 | 
			
		||||
		
 | 
			
		||||
		// hook thread_create_thread_start.php
 | 
			
		||||
		
 | 
			
		||||
		include XIUNOPHP_PATH.'xn_html_safe.func.php';
 | 
			
		||||
		
 | 
			
		||||
		$fid = param('fid', 0);
 | 
			
		||||
		$forum = forum_read($fid);
 | 
			
		||||
		empty($forum) AND message('fid', lang('forum_not_exists'));
 | 
			
		||||
		
 | 
			
		||||
		$r = forum_access_user($fid, $gid, 'allowthread');
 | 
			
		||||
		!$r AND message(-1, lang('user_group_insufficient_privilege'));
 | 
			
		||||
		
 | 
			
		||||
		$subject = htmlspecialchars(param('subject', '', FALSE));
 | 
			
		||||
		empty($subject) AND message('subject', lang('please_input_subject'));
 | 
			
		||||
		xn_strlen($subject) > 128 AND message('subject', lang('subject_length_over_limit', array('maxlength'=>128)));
 | 
			
		||||
		
 | 
			
		||||
		$message = param('message', '', FALSE);
 | 
			
		||||
		empty($message) AND message('message', lang('please_input_message'));
 | 
			
		||||
		$doctype = param('doctype', 0);
 | 
			
		||||
		$doctype > 10 AND message(-1, lang('doc_type_not_supported'));
 | 
			
		||||
		xn_strlen($message) > 2028000 AND message('message', lang('message_too_long'));
 | 
			
		||||
		
 | 
			
		||||
		$thread = array (
 | 
			
		||||
			'fid'=>$fid,
 | 
			
		||||
			'uid'=>$uid,
 | 
			
		||||
			'sid'=>$sid,
 | 
			
		||||
			'subject'=>$subject,
 | 
			
		||||
			'message'=>$message,
 | 
			
		||||
			'time'=>$time,
 | 
			
		||||
			'longip'=>$longip,
 | 
			
		||||
			'doctype'=>$doctype,
 | 
			
		||||
		);
 | 
			
		||||
		
 | 
			
		||||
		// hook thread_create_thread_before.php
 | 
			
		||||
		
 | 
			
		||||
		$tid = thread_create($thread, $pid);
 | 
			
		||||
		$pid === FALSE AND message(-1, lang('create_post_failed'));
 | 
			
		||||
		$tid === FALSE AND message(-1, lang('create_thread_failed'));
 | 
			
		||||
		
 | 
			
		||||
		// hook thread_create_thread_end.php
 | 
			
		||||
		message(0, lang('create_thread_sucessfully'));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
// 帖子详情 | post detail
 | 
			
		||||
} else {
 | 
			
		||||
	
 | 
			
		||||
	// thread-{tid}-{page}-{keyword}.htm
 | 
			
		||||
	$tid = param(1, 0);
 | 
			
		||||
	$page = param(2, 1);
 | 
			
		||||
	$keyword = param(3);
 | 
			
		||||
	$pagesize = $conf['postlist_pagesize'];
 | 
			
		||||
	//$pagesize = 10;
 | 
			
		||||
	//$page == 1 AND $pagesize++;
 | 
			
		||||
	
 | 
			
		||||
	// hook thread_info_start.php
 | 
			
		||||
	
 | 
			
		||||
	$thread = thread_read($tid);
 | 
			
		||||
	empty($thread) AND message(-1, lang('thread_not_exists'));;
 | 
			
		||||
	
 | 
			
		||||
	$fid = $thread['fid'];
 | 
			
		||||
	$forum = forum_read($fid);
 | 
			
		||||
	empty($forum) AND message(3, lang('forum_not_exists'));
 | 
			
		||||
	
 | 
			
		||||
	$postlist = post_find_by_tid($tid, $page, $pagesize);
 | 
			
		||||
	empty($postlist) AND message(4, lang('post_not_exists'));
 | 
			
		||||
	
 | 
			
		||||
	if($page == 1) {
 | 
			
		||||
		empty($postlist[$thread['firstpid']]) AND message(-1, lang('data_malformation'));
 | 
			
		||||
		$first = $postlist[$thread['firstpid']];
 | 
			
		||||
		unset($postlist[$thread['firstpid']]);
 | 
			
		||||
		$attachlist = $imagelist = $filelist = array();
 | 
			
		||||
		
 | 
			
		||||
		// 如果是大站,可以用单独的点击服务,减少 db 压力
 | 
			
		||||
		// if request is huge, separate it from mysql server
 | 
			
		||||
		thread_inc_views($tid);
 | 
			
		||||
	} else {
 | 
			
		||||
		$first = post_read($thread['firstpid']);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	$keywordurl = '';
 | 
			
		||||
	if($keyword) {
 | 
			
		||||
		$thread['subject'] = post_highlight_keyword($thread['subject'], $keyword);
 | 
			
		||||
		//$first['message'] = post_highlight_keyword($first['subject']);
 | 
			
		||||
		$keywordurl = "-$keyword";
 | 
			
		||||
	}
 | 
			
		||||
	$allowpost = forum_access_user($fid, $gid, 'allowpost') ? 1 : 0;
 | 
			
		||||
	$allowupdate = forum_access_mod($fid, $gid, 'allowupdate') ? 1 : 0;
 | 
			
		||||
	$allowdelete = forum_access_mod($fid, $gid, 'allowdelete') ? 1 : 0;
 | 
			
		||||
	
 | 
			
		||||
	forum_access_user($fid, $gid, 'allowread') OR message(-1, lang('user_group_insufficient_privilege'));
 | 
			
		||||
	
 | 
			
		||||
	$pagination = pagination(url("thread-$tid-{page}$keywordurl"), $thread['posts'] + 1, $page, $pagesize);
 | 
			
		||||
	
 | 
			
		||||
	$header['title'] = $thread['subject'].'-'.$forum['name'].'-'.$conf['sitename']; 
 | 
			
		||||
	//$header['mobile_title'] = lang('thread_detail');
 | 
			
		||||
	$header['mobile_title'] = $forum['name'];;
 | 
			
		||||
	$header['mobile_link'] = url("forum-$fid");
 | 
			
		||||
	$header['keywords'] = ''; 
 | 
			
		||||
	$header['description'] = $thread['subject']; 
 | 
			
		||||
	$_SESSION['fid'] = $fid;
 | 
			
		||||
	
 | 
			
		||||
	// hook thread_info_end.php
 | 
			
		||||
	include _include(APP_PATH.'plugin/z_doc/view/htm/doc.htm');
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// hook thread_end.php
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										151
									
								
								z_daisy/route/upload.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										151
									
								
								z_daisy/route/upload.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,151 @@
 | 
			
		||||
<?php
 | 
			
		||||
!defined('DEBUG') AND exit('Access Denied.');
 | 
			
		||||
echo $user['uid'];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
$datetime = date('Ym',time());
 | 
			
		||||
$targetDir = '../upload';
 | 
			
		||||
$uploadDir = '../../upload/attach/'.$datetime;
 | 
			
		||||
 | 
			
		||||
$cleanupTargetDir = true; 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if (!file_exists($targetDir)) {
 | 
			
		||||
    @mkdir($targetDir);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if (!file_exists($uploadDir)) {
 | 
			
		||||
    @mkdir($uploadDir);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if (isset($_REQUEST["name"])) {
 | 
			
		||||
    $fileName = $_REQUEST["name"];
 | 
			
		||||
} elseif (!empty($_FILES)) {
 | 
			
		||||
    $fileName = $_FILES["file"]["name"];
 | 
			
		||||
} else {
 | 
			
		||||
    $fileName = uniqid("file_");
 | 
			
		||||
}
 | 
			
		||||
// xxxxx 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
$typea =  substr($fileName, strrpos($fileName, '.') + 1);
 | 
			
		||||
//过滤中文名图片
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
echo "<br>";
 | 
			
		||||
echo $user['uid'];
 | 
			
		||||
echo "<br>";
 | 
			
		||||
echo xn_rand(15) ;
 | 
			
		||||
echo "<br>";
 | 
			
		||||
$n=3;
 | 
			
		||||
//function () { 
 | 
			
		||||
 | 
			
		||||
	$str = '0123456789abcdefghijklmnopqrstuvwxyz';
 | 
			
		||||
	$len = strlen($str);
 | 
			
		||||
	$return = '';
 | 
			
		||||
	for($i=0; $i<$n; $i++) {
 | 
			
		||||
		$r = xn_rand(1, $len);
 | 
			
		||||
		$return = $str[$r - 1];
 | 
			
		||||
	}
 | 
			
		||||
	return $return;
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
$fileName = $uid.'_'.xn_rand(15).".".$typea;
 | 
			
		||||
 | 
			
		||||
$fileName = iconv('UTF-8', 'GB2312', $fileName);
 | 
			
		||||
$filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName;
 | 
			
		||||
$uploadPath = $uploadDir . DIRECTORY_SEPARATOR . $fileName;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
$imgUrl= $uploadDir."/".$fileName;
 | 
			
		||||
echo str_replace("../../","",$imgUrl);
 | 
			
		||||
 | 
			
		||||
$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
 | 
			
		||||
$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 1;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if ($cleanupTargetDir) {
 | 
			
		||||
    if (!is_dir($targetDir) || !$dir = opendir($targetDir)) {
 | 
			
		||||
        die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    while (($file = readdir($dir)) !== false) {
 | 
			
		||||
        $tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file;
 | 
			
		||||
 | 
			
		||||
        if ($tmpfilePath == "{$filePath}_{$chunk}.part" || $tmpfilePath == "{$filePath}_{$chunk}.parttmp") {
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (preg_match('/\.(part|parttmp)$/', $file) && (@filemtime($tmpfilePath) < time() - $maxFileAge)) {
 | 
			
		||||
            @unlink($tmpfilePath);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    closedir($dir);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if (!$out = @fopen("{$filePath}_{$chunk}.parttmp", "wb")) {
 | 
			
		||||
    die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if (!empty($_FILES)) {
 | 
			
		||||
    if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) {
 | 
			
		||||
        die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!$in = @fopen($_FILES["file"]["tmp_name"], "rb")) {
 | 
			
		||||
        die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
 | 
			
		||||
    }
 | 
			
		||||
} else {
 | 
			
		||||
    if (!$in = @fopen("php://input", "rb")) {
 | 
			
		||||
        die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
while ($buff = fread($in, 4096)) {
 | 
			
		||||
    fwrite($out, $buff);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@fclose($out);
 | 
			
		||||
@fclose($in);
 | 
			
		||||
 | 
			
		||||
rename("{$filePath}_{$chunk}.parttmp", "{$filePath}_{$chunk}.part");
 | 
			
		||||
 | 
			
		||||
$index = 0;
 | 
			
		||||
$done = true;
 | 
			
		||||
for( $index = 0; $index < $chunks; $index++ ) {
 | 
			
		||||
    if ( !file_exists("{$filePath}_{$index}.part") ) {
 | 
			
		||||
        $done = false;
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
if ( $done ) {
 | 
			
		||||
    if (!$out = @fopen($uploadPath, "wb")) {
 | 
			
		||||
        die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ( flock($out, LOCK_EX) ) {
 | 
			
		||||
        for( $index = 0; $index < $chunks; $index++ ) {
 | 
			
		||||
            if (!$in = @fopen("{$filePath}_{$index}.part", "rb")) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            while ($buff = fread($in, 4096)) {
 | 
			
		||||
                fwrite($out, $buff);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            @fclose($in);
 | 
			
		||||
            @unlink("{$filePath}_{$index}.part");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        flock($out, LOCK_UN);
 | 
			
		||||
    }
 | 
			
		||||
    @fclose($out);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
		Reference in New Issue
	
	Block a user