⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upload.lasso

📁 站长俱乐部新闻发布程序 采用全新代码设计,完全不同于国内所有程序 采用国际流行的左右栏风格,清爽简洁 适合于有国际业务的企业,个人网站,工作室,追求简单风格,内容少的网站使用 IE和Fi
💻 LASSO
字号:
[//lasso


                                                                        
	include('config.lasso');


                                                                       
	var(
		'Type'			=	action_param('Type'),
		'CurrentFolder'	=	action_param('CurrentFolder'),
		'ServerPath'	=	action_param('ServerPath'),
		'NewFile'		=	null,
		'NewFileName'	=	string,
		'OrigFilePath'	=	string,
		'NewFilePath'	=	string,
		'errorNumber'	=	0,
		'customMsg'		=	''
	);

	$Type == '' ? $Type = 'File';


    /*.....................................................................     
    Calculate the path to the current folder.                                                                           
    */                                                                          
	$ServerPath == '' ? $ServerPath = $config->find('UserFilesPath');
		
	var('currentFolderURL' = $ServerPath 
		+ $config->find('Subdirectories')->find(action_param('Type'))
		+ action_param('CurrentFolder')
	);


	/*.....................................................................    
	Custom tag sets the HTML response.                                                               
	*/
	
	define_tag(
		'sendresults',
		-namespace='fck_',
		-priority='replace',
		-required='errorNumber',
		-type='integer',
		-optional='fileUrl',
		-type='string',
		-optional='fileName',
		-type='string',
		-optional='customMsg',
		-type='string',
		-description='Sets the HTML response for the FCKEditor Quick Upload feature.'
	);
		$__html_reply__ = '\
<script type="text/javascript">
	window.parent.OnUploadCompleted(' + #errorNumber + ',"' 
		+ string_replace(#fileUrl, -find='"', -replace='\\"') + '","' 
		+ string_replace(#fileName, -find='"', -replace='\\"') + '","' 
		+ string_replace(#customMsg, -find='"', -replace='\\"') + '");
</script>
		';
	/define_tag;


	if($config->find('Enabled'));
		/*.................................................................     
		Process an uploaded file.                                                                        
		*/                                                                          
		inline($connection);
			/*.............................................................     
			Was a file actually uploaded?                                                              
			*/                                                              
			file_uploads->size ? $NewFile = file_uploads->get(1) | $errorNumber = 202;
							
			if($errorNumber == 0);
				/*.........................................................     
				Split the file's extension from the filename in order
				to follow the API's naming convention for duplicate
				files. (Test.txt, Test(1).txt, Test(2).txt, etc.)                                                          
				*/                                                          
				$NewFileName = $NewFile->find('OrigName');													
				$OrigFilePath = $currentFolderURL + $NewFileName;
				$NewFilePath = $OrigFilePath;
				local('fileExtension') = '.' + $NewFile->find('OrigExtension');					
				local('shortFileName') = $NewFileName->removetrailing(#fileExtension)&;
	
	
				/*.........................................................     
				Make sure the file extension is allowed.                                                          
				*/ 
								
				if($config->find('DeniedExtensions')->find($Type) >> $NewFile->find('OrigExtension'));
					$errorNumber = 202;
				else;
					/*.....................................................     
					Rename the target path until it is unique.                                                    
					*/                                                      										
					while(file_exists($NewFilePath));
						$NewFileName = #shortFileName + '(' + loop_count + ')' + #fileExtension;
						$NewFilePath = $currentFolderURL + $NewFileName;
					/while;
					
					
					/*.....................................................     
					Copy the uploaded file to its final location.                                                     
					*/                                                      
					file_copy($NewFile->find('path'), $NewFilePath);
	
	
					/*.....................................................    
					Set the error code for the response.                                          
					*/                                                      						
					select(file_currenterror( -errorcode));
						case(0);
							$OrigFilePath != $NewFilePath ? $errorNumber = 201;
						case;
							$errorNumber = 202;
					/select;
				/if;
			/if;
		/inline;
	else;
		$errorNumber = 1;
		$customMsg = 'This file uploader is disabled. Please check the "editor/filemanager/upload/lasso/config.lasso" file.';
	/if;
	
	fck_sendresults(
		-errorNumber=$errorNumber,
		-fileUrl=$NewFilePath,
		-fileName=$NewFileName,
		-customMsg=$customMsg
	);
]	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -