代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
PHP
】
文件上传类
作者:
Dezai.CN
/ 发布于
2011/6/11
/
527
<div><span style="color: rgb(0,0,0); font-weight: bold"><?php</span> <span style="color: rgb(177,177,0)">include</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(255,0,0)">'class.upload.php'</span><span style="color: rgb(102,204,102)">)</span>; <span style="font-style: italic; color: rgb(128,128,128)">// Create the upload object</span> <span style="color: rgb(0,0,255)">$uploader</span> = <span style="color: rgb(0,0,0); font-weight: bold">new</span> swd_upload; <span style="font-style: italic; color: rgb(128,128,128)">// Set an upload limit</span> <span style="color: rgb(0,0,255)">$uploader</span>-><span style="color: rgb(0,102,0)">max_size</span> *= <span style="color: rgb(204,102,204)">15</span>; <span style="font-style: italic; color: rgb(128,128,128)">// 15 MB</span> <span style="font-style: italic; color: rgb(128,128,128)">// Add some extensions</span> <span style="color: rgb(0,0,255)">$uploader</span>-><span style="color: rgb(0,102,0)">add_extension</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(255,0,0)">'jpg'</span>, <span style="color: rgb(255,0,0)">'bmp'</span>, <span style="color: rgb(255,0,0)">'png'</span><span style="color: rgb(102,204,102)">)</span>; <span style="font-style: italic; color: rgb(128,128,128)">// Set an upload dir</span> <span style="color: rgb(0,0,255)">$uploader</span>-><span style="color: rgb(0,102,0)">upload_path</span> = <span style="color: rgb(255,0,0)">'./uploads/'</span>; <span style="font-style: italic; color: rgb(128,128,128)">// Upload file(s)</span> <span style="color: rgb(0,0,255)">$uploader</span>-><span style="color: rgb(0,102,0)">upload</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span>; <span style="font-style: italic; color: rgb(128,128,128)">// Show the upload form. Use display_transloader() for the transloader.</span> <span style="color: rgb(0,0,255)">$uploader</span>-><span style="color: rgb(0,102,0)">display_uploader</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(255,0,0)">'upload.php'</span>, <span style="color: rgb(204,102,204)">20</span><span style="color: rgb(102,204,102)">)</span>; <span style="font-style: italic; color: rgb(128,128,128)">// Show allowed extensions to user</span> <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(0,0,255)">$uploader</span>-><span style="color: rgb(0,102,0)">get_extensions</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,0); font-weight: bold">true</span><span style="color: rgb(102,204,102)">)</span>; <span style="font-style: italic; color: rgb(128,128,128)">// Display all uploaded files</span> <span style="color: rgb(0,0,255)">$uploader</span>-><span style="color: rgb(0,102,0)">get_uploaded_files</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span>; <span style="font-style: italic; color: rgb(128,128,128)">// Display all errors</span> <span style="color: rgb(0,0,255)">$uploader</span>-><span style="color: rgb(0,102,0)">get_errors</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(0,0,0); font-weight: bold">?></span> <div style="font-family: monospace" class="php"> <span style="color: rgb(0,0,0); font-weight: bold"><?php</span> <span style="color: rgb(0,0,0); font-weight: bold">class</span> swd_upload <span style="color: rgb(102,204,102)">{</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * ========================================================================= * UPLOAD CLASS * ========================================================================= * * @author: Nicolas Oelgart * @copyright: Nicolas Oelgart * @version: Revision: 1.8 * @date: 25th August 2006 * @last modified: 16th October 2006 * @license: GPL * * @website: www.nicoswd.com * @email: nico@nicoswd.com * * @requirements: PHP 4.2 + * * ========================================================================= * * Copyright (C) 2006 Nicolas Oelgart * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * ========================================================================= */</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Max upload size in bytes. Set to FALSE fot no limit. * Note: 1048576 byes = 1 MB * * @var integer */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$max_size</span> = <span style="color: rgb(204,102,204)">1048576</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Allowed uploads at the same time. * * @var integer */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$max_uploads</span> = <span style="color: rgb(204,102,204)">5</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Default allowed file extensions. (Lowercase) * * @var array */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$extensions</span> = <a href="http://www.php.net/array" target="_blank"><span style="color: rgb(0,0,102)">array</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(255,0,0)">'jpg'</span>, <span style="color: rgb(255,0,0)">'zip'</span>, <span style="color: rgb(255,0,0)">'pdf'</span><span style="color: rgb(102,204,102)">)</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Upload path. Will be created if not exists. * * @var string */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$upload_path</span> = <span style="color: rgb(255,0,0)">'./uploads/'</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Will create subdirs based on the date format in the next variable. * * @var boolean */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$enable_subdirs</span> = <span style="color: rgb(0,0,0); font-weight: bold">true</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Subdir format. Must be a valid format for PHP's date() function. * See first table on this page: http://us2.php.net/date * * @var string */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$subdir_format</span> = <span style="color: rgb(255,0,0)">'Ym'</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Creates blank index files in each upload and subdirectory if TRUE. * * @var boolean */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$create_index</span> = <span style="color: rgb(0,0,0); font-weight: bold">true</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Filename for index files. * * @var string */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$index_file</span> = <span style="color: rgb(255,0,0)">'index.html'</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Overwrite existing files. Will create an unique filename if FALSE. * * @var boolean */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$overwrite</span> = <span style="color: rgb(0,0,0); font-weight: bold">false</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * All error messages are here. You may wish to rephrase them. * * @var array */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$default_errors</span> = <a href="http://www.php.net/array" target="_blank"><span style="color: rgb(0,0,102)">array</span></a> <span style="color: rgb(102,204,102)">(</span> <span style="font-style: italic; color: rgb(128,128,128)">// Default errors</span> <span style="color: rgb(255,0,0)">''</span>, <span style="color: rgb(255,0,0)">'The uploaded file exceeds the upload_max_filesize directive.'</span>, <span style="color: rgb(255,0,0)">'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'</span>, <span style="color: rgb(255,0,0)">'The uploaded file was only partially uploaded.'</span>, <span style="color: rgb(255,0,0)">'No file was uploaded.'</span>, <span style="color: rgb(255,0,0)">'Missing a temporary folder.'</span>, <span style="color: rgb(255,0,0)">'Failed to write file to disk.'</span>, <span style="color: rgb(255,0,0)">'Unknown File Error.'</span>, <span style="font-style: italic; color: rgb(128,128,128)">// Custom errors</span> <span style="color: rgb(255,0,0)">'Extension (%s) not allowed. "%s" not uploaded.'</span>, <span style="color: rgb(255,0,0)">'File over allowed size of %d bytes.'</span>, <span style="color: rgb(255,0,0)">'The upload of "%s" failed. Please try again.'</span>, <span style="color: rgb(255,0,0)">'Max uploads of %d has been reached or an unexpected error ocurred.'</span>, <span style="color: rgb(255,0,0)">'An unexpected error ocurred. %s has not been uploaded.'</span>, <span style="color: rgb(255,0,0)">'Could not create upload directory. Upload cancelled.'</span>, <span style="color: rgb(255,0,0)">'Failed to open file. Please check the URL.'</span>, <span style="color: rgb(255,0,0)">'The server has disabled this function. Please contact the administrator.'</span>, <span style="color: rgb(255,0,0)">'The upload directory is not writable. Could not upload file.'</span> <span style="color: rgb(102,204,102)">)</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * ==================================================================================== * END CONFIGURATION. * ==================================================================================== * * You may not edit below unless you know what you're doing. */</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Holds all errors that ocurred while uplading. * * @var array */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$errors</span> = <a href="http://www.php.net/array" target="_blank"><span style="color: rgb(0,0,102)">array</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Holds all names of all uploaded files. * * @var array */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$uploaded_files</span> = <a href="http://www.php.net/array" target="_blank"><span style="color: rgb(0,0,102)">array</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Holds the formatted subdir name if enabled. * * @var string */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$subdir</span> = <span style="color: rgb(255,0,0)">''</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Holds the $_FILES['swd_upload'] array. * * @var array */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$files</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Holds the $_POST['swd_transload'] file URL. * * @var string */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$transload</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Holds the current key. * * @var integer */</span> <span style="color: rgb(0,0,0); font-weight: bold">var</span> <span style="color: rgb(0,0,255)">$_key</span>; <span style="font-style: italic; color: rgb(128,128,128)">/** * Class constructor * * Sets main variables. */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> swd_upload<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">files</span> = <span style="color: rgb(0,0,255)">$_FILES</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(255,0,0)">'swd_upload'</span><span style="color: rgb(102,204,102)">]</span>; <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">transload</span> = <span style="color: rgb(0,0,255)">$_POST</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(255,0,0)">'swd_transload'</span><span style="color: rgb(102,204,102)">]</span>; <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">enable_subdirs</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">subdir</span> = <a href="http://www.php.net/date" target="_blank"><span style="color: rgb(0,0,102)">date</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">subdir_format</span><span style="color: rgb(102,204,102)">)</span> .<span style="color: rgb(255,0,0)">'/'</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Checks quick if the filename is valid, and if the number of max uploads * hasn't been passed yet. Sends array key to move() if everything ok here. * * @return mixed */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> upload<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span>!<a href="http://www.php.net/is_array" target="_blank"><span style="color: rgb(0,0,102)">is_array</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">files</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(255,0,0)">'error'</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">)</span> OR !<span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">is_valid_upload_path</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">false</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">foreach</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">files</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(255,0,0)">'error'</span><span style="color: rgb(102,204,102)">]</span> <span style="color: rgb(177,177,0)">AS</span> <span style="color: rgb(0,0,255)">$key</span> => <span style="color: rgb(0,0,255)">$error</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$filename</span> = <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">files</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(255,0,0)">'name'</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(0,0,255)">$key</span><span style="color: rgb(102,204,102)">]</span>; <span style="color: rgb(0,0,255)">$this</span>->_key = <span style="color: rgb(0,0,255)">$key</span>; <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/empty" target="_blank"><span style="color: rgb(0,0,102)">empty</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$filename</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">continue</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">else</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/sizeof" target="_blank"><span style="color: rgb(0,0,102)">sizeof</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">uploaded_files</span><span style="color: rgb(102,204,102)">)</span> >= <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">max_uploads</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">set_error</span><span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/sprintf" target="_blank"><span style="color: rgb(0,0,102)">sprintf</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">default_errors</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">11</span><span style="color: rgb(102,204,102)">]</span>, <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">max_uploads</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">false</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">else</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">is_valid_file</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$filename</span><span style="color: rgb(102,204,102)">)</span> AND <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$error</span> === <span style="color: rgb(204,102,204)">0</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">move</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">else</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span>!<a href="http://www.php.net/empty" target="_blank"><span style="color: rgb(0,0,102)">empty</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$error</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">set_error</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">default_errors</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(0,0,255)">$error</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Transloads a file from another host to the upload directory. * * @return boolean */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> transload<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/ini_get" target="_blank"><span style="color: rgb(0,0,102)">ini_get</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(255,0,0)">'allow_url_fopen'</span><span style="color: rgb(102,204,102)">)</span> == <span style="color: rgb(204,102,204)">0</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">set_error</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">default_errors</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">15</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">false</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span>!<span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">is_valid_upload_path</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">false</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span>!<a href="http://www.php.net/empty" target="_blank"><span style="color: rgb(0,0,102)">empty</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">transload</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$filename</span> = <a href="http://www.php.net/basename" target="_blank"><span style="color: rgb(0,0,102)">basename</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">transload</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(0,0,255)">$contents</span> = <span style="color: rgb(255,0,0)">''</span>; <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span>!<span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">is_valid_file</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$filename</span>, <span style="color: rgb(0,0,0); font-weight: bold">false</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">false</span>; <span style="color: rgb(102,204,102)">}</span> <a href="http://www.php.net/set_time_limit" target="_blank"><span style="color: rgb(0,0,102)">set_time_limit</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(204,102,204)">0</span><span style="color: rgb(102,204,102)">)</span>; @<a href="http://www.php.net/ini_set" target="_blank"><span style="color: rgb(0,0,102)">ini_set</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(255,0,0)">'user_agent'</span>, <span style="color: rgb(255,0,0)">'PHP'</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span>!<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$fp</span> = @<a href="http://www.php.net/fopen" target="_blank"><span style="color: rgb(0,0,102)">fopen</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">transload</span>, <span style="color: rgb(255,0,0)">'rb'</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">set_error</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">default_errors</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">14</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">false</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">while</span> <span style="color: rgb(102,204,102)">(</span>!<a href="http://www.php.net/feof" target="_blank"><span style="color: rgb(0,0,102)">feof</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$fp</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$contents</span> .= <a href="http://www.php.net/fread" target="_blank"><span style="color: rgb(0,0,102)">fread</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$fp</span>, <span style="color: rgb(204,102,204)">8192</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">max_size</span> AND <span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/strlen" target="_blank"><span style="color: rgb(0,0,102)">strlen</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$contents</span><span style="color: rgb(102,204,102)">)</span> > <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">max_size</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">set_error</span><span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/sprintf" target="_blank"><span style="color: rgb(0,0,102)">sprintf</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">default_errors</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">9</span><span style="color: rgb(102,204,102)">]</span>, <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">max_size</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">false</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(102,204,102)">}</span> <a href="http://www.php.net/fclose" target="_blank"><span style="color: rgb(0,0,102)">fclose</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$fp</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$upload</span> = @<a href="http://www.php.net/fopen" target="_blank"><span style="color: rgb(0,0,102)">fopen</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">upload_path</span> . <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">subdir</span> . <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">rand_name</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$filename</span><span style="color: rgb(102,204,102)">)</span>, <span style="color: rgb(255,0,0)">'w'</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <a href="http://www.php.net/fwrite" target="_blank"><span style="color: rgb(0,0,102)">fwrite</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$upload</span>, <span style="color: rgb(0,0,255)">$contents</span><span style="color: rgb(102,204,102)">)</span>; <a href="http://www.php.net/fclose" target="_blank"><span style="color: rgb(0,0,102)">fclose</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$upload</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">uploaded_files</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(102,204,102)">]</span> = <span style="color: rgb(0,0,255)">$filename</span>; <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">true</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Checks if the file has a valid extension and if the size is not over the * max upload limit. * * @param string Filename * @param boolean If true, checks for size as well. * * @return boolean */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> is_valid_file<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$filename</span>, <span style="color: rgb(0,0,255)">$checksize</span> = <span style="color: rgb(0,0,0); font-weight: bold">true</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span>!<a href="http://www.php.net/in_array" target="_blank"><span style="color: rgb(0,0,102)">in_array</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">file_extension</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$filename</span><span style="color: rgb(102,204,102)">)</span>, <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">extensions</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">set_error</span><span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/sprintf" target="_blank"><span style="color: rgb(0,0,102)">sprintf</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">default_errors</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">8</span><span style="color: rgb(102,204,102)">]</span>, <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">file_extension</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$filename</span><span style="color: rgb(102,204,102)">)</span>, <span style="color: rgb(0,0,255)">$filename</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">false</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$checksize</span> AND <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">max_size</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">files</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(255,0,0)">'size'</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(0,0,255)">$this</span>->_key<span style="color: rgb(102,204,102)">]</span> > <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">max_size</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">set_error</span><span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/sprintf" target="_blank"><span style="color: rgb(0,0,102)">sprintf</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">default_errors</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">9</span><span style="color: rgb(102,204,102)">]</span>, <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">max_size</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">false</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">true</span>; <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Moves the uploaded file from the temp directory to the upload directory. */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> move<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$filename</span> = <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">files</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(255,0,0)">'name'</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(0,0,255)">$this</span>->_key<span style="color: rgb(102,204,102)">]</span>; <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/is_uploaded_file" target="_blank"><span style="color: rgb(0,0,102)">is_uploaded_file</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">files</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(255,0,0)">'tmp_name'</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(0,0,255)">$this</span>->_key<span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$upload_name</span> = <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">rand_name</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$filename</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span>@<a href="http://www.php.net/move_uploaded_file" target="_blank"><span style="color: rgb(0,0,102)">move_uploaded_file</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">files</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(255,0,0)">'tmp_name'</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(0,0,255)">$this</span>->_key<span style="color: rgb(102,204,102)">]</span>, <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">upload_path</span> . <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">subdir</span> . <span style="color: rgb(0,0,255)">$upload_name</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <a href="http://www.php.net/array_push" target="_blank"><span style="color: rgb(0,0,102)">array_push</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">uploaded_files</span>, <span style="color: rgb(0,0,255)">$upload_name</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">else</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">set_error</span><span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/sprintf" target="_blank"><span style="color: rgb(0,0,102)">sprintf</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">default_errors</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">10</span><span style="color: rgb(102,204,102)">]</span>, <span style="color: rgb(0,0,255)">$filename</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">else</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">set_error</span><span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/sprintf" target="_blank"><span style="color: rgb(0,0,102)">sprintf</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">default_errors</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">12</span><span style="color: rgb(102,204,102)">]</span>, <span style="color: rgb(0,0,255)">$filename</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Checks if the upload path (and subdir if enabled) exists and attempts * to create it if not. Also creates empty index files if enabled. * * @return boolean */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> is_valid_upload_path<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$paths</span> = <a href="http://www.php.net/array" target="_blank"><span style="color: rgb(0,0,102)">array</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">upload_path</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">enable_subdirs</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <a href="http://www.php.net/array_push" target="_blank"><span style="color: rgb(0,0,102)">array_push</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$paths</span>, <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">upload_path</span> . <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">subdir</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">foreach</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$paths</span> <span style="color: rgb(177,177,0)">AS</span> <span style="color: rgb(0,0,255)">$path</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span>!<a href="http://www.php.net/file_exists" target="_blank"><span style="color: rgb(0,0,102)">file_exists</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$path</span><span style="color: rgb(102,204,102)">)</span> AND !@<a href="http://www.php.net/mkdir" target="_blank"><span style="color: rgb(0,0,102)">mkdir</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$path</span>, <span style="color: rgb(204,102,204)">0755</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">set_error</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">default_errors</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">13</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">false</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">else</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span>!<a href="http://www.php.net/is_writable" target="_blank"><span style="color: rgb(0,0,102)">is_writable</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$path</span><span style="color: rgb(102,204,102)">)</span> AND !<a href="http://www.php.net/chmod" target="_blank"><span style="color: rgb(0,0,102)">chmod</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$path</span>, <span style="color: rgb(204,102,204)">755</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">set_error</span><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">default_errors</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">17</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">false</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">create_index</span> AND !<a href="http://www.php.net/file_exists" target="_blank"><span style="color: rgb(0,0,102)">file_exists</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$path</span> . <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">index_file</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> @<a href="http://www.php.net/touch" target="_blank"><span style="color: rgb(0,0,102)">touch</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$path</span> . <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">index_file</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,0); font-weight: bold">true</span>; <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Adds one or more extensions to the allowed extensions array. * * @param mixed Allowed extensions. Can either be an array or strings as arguments. * * @return boolean */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> add_extension<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$extensions</span> = <a href="http://www.php.net/func_get_args" target="_blank"><span style="color: rgb(0,0,102)">func_get_args</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">extensions</span> = <a href="http://www.php.net/array_merge" target="_blank"><span style="color: rgb(0,0,102)">array_merge</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">extensions</span>, <span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/is_array" target="_blank"><span style="color: rgb(0,0,102)">is_array</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$extensions</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">0</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">)</span> ? <span style="color: rgb(0,0,255)">$extensions</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">0</span><span style="color: rgb(102,204,102)">]</span> : <span style="color: rgb(0,0,255)">$extensions</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Removes one or more extensions from the allowed extensions array. * * @param mixed Extensions that need to be removed. Can either be an array or strings as arguments. * * @return boolean */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> remove_extension<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$extensions</span> = <a href="http://www.php.net/func_get_args" target="_blank"><span style="color: rgb(0,0,102)">func_get_args</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">extensions</span> = <a href="http://www.php.net/array_diff" target="_blank"><span style="color: rgb(0,0,102)">array_diff</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">extensions</span>, <span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/is_array" target="_blank"><span style="color: rgb(0,0,102)">is_array</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$extensions</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">0</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">)</span> ? <span style="color: rgb(0,0,255)">$extensions</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(204,102,204)">0</span><span style="color: rgb(102,204,102)">]</span> : <span style="color: rgb(0,0,255)">$extensions</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Returns all allowed extensions either as array or string. * * @param boolean Returns the extensions as array if FALSE. * @param string Separator between extensions. * * @return mixed */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> get_extensions<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$as_string</span> = <span style="color: rgb(0,0,0); font-weight: bold">false</span>, <span style="color: rgb(0,0,255)">$separator</span> = <span style="color: rgb(255,0,0)">', '</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$extensions</span> = <a href="http://www.php.net/array_unique" target="_blank"><span style="color: rgb(0,0,102)">array_unique</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">extensions</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$as_string</span> ? <a href="http://www.php.net/implode" target="_blank"><span style="color: rgb(0,0,102)">implode</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$separator</span>, <span style="color: rgb(0,0,255)">$extensions</span><span style="color: rgb(102,204,102)">)</span> : <span style="color: rgb(0,0,255)">$extensions</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Returns the last characters after the last dot in the given string. * * @param string Filename * * @return string Extension */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> file_extension<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$filename</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">return</span> <a href="http://www.php.net/strtolower" target="_blank"><span style="color: rgb(0,0,102)">strtolower</span></a><span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/substr" target="_blank"><span style="color: rgb(0,0,102)">substr</span></a><span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/strrchr" target="_blank"><span style="color: rgb(0,0,102)">strrchr</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$filename</span>, <span style="color: rgb(255,0,0)">'.'</span><span style="color: rgb(102,204,102)">)</span>, <span style="color: rgb(204,102,204)">1</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Generates a unique name for the uploaded file if enabled. * * @param string Filename * * @return string Random name */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> rand_name<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$original</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">overwrite</span> OR !<a href="http://www.php.net/file_exists" target="_blank"><span style="color: rgb(0,0,102)">file_exists</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">upload_path</span> . <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">subdir</span> . <span style="color: rgb(0,0,255)">$original</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,255)">$original</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(177,177,0)">else</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">rand_name</span><span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/substr" target="_blank"><span style="color: rgb(0,0,102)">substr</span></a><span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/md5" target="_blank"><span style="color: rgb(0,0,102)">md5</span></a><span style="color: rgb(102,204,102)">(</span><a href="http://www.php.net/rand" target="_blank"><span style="color: rgb(0,0,102)">rand</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(204,102,204)">1</span>, <span style="color: rgb(204,102,204)">5000</span><span style="color: rgb(102,204,102)">)</span> . <a href="http://www.php.net/time" target="_blank"><span style="color: rgb(0,0,102)">time</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(102,204,102)">)</span> . <a href="http://www.php.net/rand" target="_blank"><span style="color: rgb(0,0,102)">rand</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(204,102,204)">50</span>, <span style="color: rgb(204,102,204)">7000</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span>, <span style="color: rgb(204,102,204)">-5</span><span style="color: rgb(102,204,102)">)</span> .<span style="color: rgb(255,0,0)">'_'</span>. <span style="color: rgb(0,0,255)">$original</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Adds an error to the array. * * @param string Error message * * @return none */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> set_error<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$error</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">errors</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(102,204,102)">]</span> = <span style="color: rgb(0,0,255)">$error</span>; <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Displays the upload form based on the allowed max uploads. * * @param string If the form should be submitted to another file, this needs to be changed to the target filename. * * @return string Upload form */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> display_uploader<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$action</span> = <span style="color: rgb(0,0,0); font-weight: bold">false</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">'<div id="swd_upload">'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">'<form action="'</span>. <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$action</span> ? <span style="color: rgb(0,0,255)">$action</span> : <a href="http://www.php.net/basename" target="_blank"><span style="color: rgb(0,0,102)">basename</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$_SERVER</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(255,0,0)">'PHP_SELF'</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> .<span style="color: rgb(255,0,0)">'" method="post" enctype="multipart/form-data">'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <span style="color: rgb(177,177,0)">for</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$i</span> = <span style="color: rgb(204,102,204)">0</span>; <span style="color: rgb(0,0,255)">$i</span> < <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">max_uploads</span>; <span style="color: rgb(0,0,255)">$i</span>++<span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\t</span>"</span> .<span style="color: rgb(255,0,0)">'<input type="file" name="swd_upload[]" />'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <span style="color: rgb(102,204,102)">}</span> <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\t</span>"</span> .<span style="color: rgb(255,0,0)">'<input type="submit" value="Upload files" />'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">'</form>'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">'</div>'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Displays the transloader form. * * @param mixed Target filename for the form, or FALSE for self. * @param integer Size for the text field. * * @return string Upload form. */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> display_transloader<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$action</span> = <span style="color: rgb(0,0,0); font-weight: bold">false</span>, <span style="color: rgb(0,0,255)">$size</span> = <span style="color: rgb(204,102,204)">20</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">'<div id="swd_transload">'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">'<form action="'</span>. <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$action</span> ? <span style="color: rgb(0,0,255)">$action</span> : <a href="http://www.php.net/basename" target="_blank"><span style="color: rgb(0,0,102)">basename</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$_SERVER</span><span style="color: rgb(102,204,102)">[</span><span style="color: rgb(255,0,0)">'PHP_SELF'</span><span style="color: rgb(102,204,102)">]</span><span style="color: rgb(102,204,102)">)</span><span style="color: rgb(102,204,102)">)</span> .<span style="color: rgb(255,0,0)">'" method="post">'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\t</span>"</span>. <span style="color: rgb(255,0,0)">'<input type="text" size="'</span>. <span style="color: rgb(0,0,255)">$size</span> .<span style="color: rgb(255,0,0)">'" name="swd_transload" />'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\t</span>"</span>. <span style="color: rgb(255,0,0)">'<input type="submit" value="Transload" />'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">'</form>'</span> .<span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">'</div>'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * Returns all errors either as array or as HTML list. * * @param boolean If true, returns errors as array. * * @return mixed */</span> <span style="color: rgb(0,0,0); font-weight: bold">function</span> get_errors<span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$as_array</span> = <span style="color: rgb(0,0,0); font-weight: bold">false</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">if</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$as_array</span> OR <a href="http://www.php.net/sizeof" target="_blank"><span style="color: rgb(0,0,102)">sizeof</span></a><span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">errors</span><span style="color: rgb(102,204,102)">)</span> === <span style="color: rgb(204,102,204)">0</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <span style="color: rgb(177,177,0)">return</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$as_array</span> ? <span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">errors</span> : <span style="color: rgb(255,0,0)">''</span><span style="color: rgb(102,204,102)">)</span>; <span style="color: rgb(102,204,102)">}</span> <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">'<div id="swd_errors">'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">'<ul>'</span> .<span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <span style="color: rgb(177,177,0)">foreach</span> <span style="color: rgb(102,204,102)">(</span><span style="color: rgb(0,0,255)">$this</span>-><span style="color: rgb(0,102,0)">errors</span> <span style="color: rgb(177,177,0)">AS</span> <span style="color: rgb(0,0,255)">$error</span><span style="color: rgb(102,204,102)">)</span> <span style="color: rgb(102,204,102)">{</span> <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\t</span>"</span>. <span style="color: rgb(255,0,0)">'<li>'</span>. <span style="color: rgb(0,0,255)">$error</span> .<span style="color: rgb(255,0,0)">'</li>'</span>. <span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <span style="color: rgb(102,204,102)">}</span> <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">'</ul>'</span> .<span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <a href="http://www.php.net/echo" target="_blank"><span style="color: rgb(0,0,102)">echo</span></a> <span style="color: rgb(255,0,0)">'</div>'</span> .<span style="color: rgb(255,0,0)">"<span style="color: rgb(0,0,153); font-weight: bold">\r</span><span style="color: rgb(0,0,153); font-weight: bold">\n</span>"</span>; <span style="color: rgb(102,204,102)">}</span> <span style="font-style: italic; color: rgb(128,128,128)">/** * ========================================================================= * UPLOAD CLASS END * ========================================================================= * Copyright (C) 2006 by Nicolas Oelgart. */</span> <span style="color: rgb(102,204,102)">}</span> <span style="color: rgb(0,0,0); font-weight: bold">?></span> </div> </div>
试试其它关键字
文件上传类
同语言下
.
用net匹配并替换iOS标准的emoji表情符号
.
处理带Emoji表情的的字符串
.
获取微信昵称时 过滤特殊字符
.
通过判断上传文件的头字符来判断文件的类型
.
模拟百度URL加密解密算法
.
以太坊检查地址是否合法
.
实现crontab解析类
.
获取每个月的开始和结束时间
.
图片上传工具类
.
APP手机应用信息采集
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3