PageRenderTime 100ms CodeModel.GetById 30ms app.highlight 43ms RepoModel.GetById 17ms app.codeStats 1ms

/web/sfbrowser/index.php

http://sfbrowser.googlecode.com/
PHP | 462 lines | 420 code | 39 blank | 3 comment | 21 complexity | 099d2fd5cbfd0f8cf19badf12deaad26 MD5 | raw file
  1<<?php echo '?'; ?>xml version="1.0"?>
  2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  4	<head>
  5		<title>jquery filebrowser</title>
  6		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  7		<link rel="stylesheet" type="text/css" media="screen" href="style/screen.css" />
  8
  9		<!--script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script-->
 10
 11		<script type="text/javascript" src="scripts/jquery-1.7b2.js"></script>
 12		<?php include("connectors/php/init.php"); ?>
 13		<script type="text/javascript">
 14			function addFiles(aFiles) {
 15				if ($('#addfiles>ul').length==0) $('#addfiles').html('<ul/>');
 16				for (var i=0;i<aFiles.length;i++) $("#addfiles>ul").append("<li><a onclick=\"$.sfb({select:addFiles,plugins:[],file:'"+aFiles[i].file+"'});\">"+aFiles[i].file+"</a> is "+aFiles[i].size+" <a onclick=\"$(this).parent().remove()\">[x]</a></li>");
 17			}
 18			function addImages(aFiles) {
 19				$.each(aFiles,function(i,o){
 20					$("#addimages").append("<img src=\""+o.file+"\" onclick=\"$(this).remove();\" />");
 21				});
 22			}
 23			$(function(){
 24				var fnTop = function(){$(document).scrollTop(0)};
 25				$("h1").text("jQuery."+$.sfbrowser.id+" "+$.sfbrowser.version).click(fnTop);
 26				$("#page tr:odd").addClass("odd");
 27				$("#page tbody>tr").find("td:eq(0)").addClass("property");
 28				var mMenu = $("<ul id=\"menu\" />").appendTo("#header>div");
 29				$("<li><a href=\"#\">SFBrowser</a></li>").appendTo(mMenu).click(fnTop);
 30				$("h2").each(function(i,o){
 31					mMenu.append("<li><a href=\"#"+$(this).text()+"\">"+$(this).text()+"</a></li>");
 32					$(this).attr("id",$(this).text());
 33				});
 34			});
 35			//$(window).load(function() {
 36			//	$.fn.sfbrowser({x:20,y:20,w:700});
 37			//});
 38		</script>
 39	</head>
 40	<body>
 41		<div id="header">
 42			<div><h1><span>SFBrowser</span></h1></div>
 43		</div>
 44		<div id="page">
 45			<p><img src="data/screenshot.jpg" align="right" alt="screenshot" />SFBrowser is a file browser and uploader for jQuery. It returns a list of objects with containing the names and additional information of the selected files.<br/>
 46			You can use it, like any open-file-dialog, to select one or more files. Most inherent functionalities are also there like: file upload, file preview, creating folders and renaming or deleting files and folders.<br/>
 47			You can download as <a href="http://code.google.com/p/sfbrowser/downloads">zip</a> or do a <a href="http://sfbrowser.googlecode.com/svn/trunk">repository checkout</a>. If you stumble upon anything out of the ordinary you can <a href="http://code.google.com/p/sfbrowser/issues">file them here</a>.</p>
 48
 49			<h3>features</h3>
 50			<ul>
 51				<li>ajax file upload</li>
 52				<li>optional as3 swf upload (queued multiple uploads, upload progress, upload canceling, selection filtering, size filtering)</li>
 53				<li>localisation (English, Dutch or Spanish)</li>
 54				<li>server side script connector</li>
 55				<li>plugin environment (with filetree and imageresize plugin)</li>
 56				<li>data caching (minimal server communication)</li>
 57				<li>sortable file table</li>
 58				<li>file filtering</li>
 59				<li>file renaming</li>
 60				<li>file duplication</li>
 61				<li>file download</li>
 62				<li>file/folder context menu</li>
 63				<li>file preview (image, audio, video, text/ascii and swf)</li>
 64				<li>folder creation</li>
 65				<li>multiple files selection</li>
 66				<li>inline or overlay window</li>
 67				<li>window dragging and resizing</li>
 68				<li>cookie for size, position and path</li>
 69				<li>keyboard shortcuts</li>
 70				<li>key file selection</li>
 71			</ul>
 72
 73			<h3>caution</h3>
 74			<p>The initial intentions for this jQuery plugin were for use in a CMS, and those are normally password protected. SFBrowser does try do do things as secure as possible: incoming data is always checked on validity and paths are always compared to the base path set in the server side config file. However: if you intend to use this plugin in an unprotected part of your site you'd do good to doublecheck and test (hack) the server side scripts yourself. You are using this plugin at your own risk.<br/>
 75			Should you find holes, leaks or anything else that can be improved <a href="http://code.google.com/p/sfbrowser/issues">report them here</a>.</p>
 76
 77
 78			<h2>installation</h2>
 79
 80			<p>SFBrowser can (theoretically) be connected to different server side languages. For sake of clarity this document will asume you're running PHP, so when PHP is mentioned further on you can interpret it as every other server side scripting connector. Check the connectors paragraph if you want to use another server side scripting language.</p>
 81
 82			<ul>
 83				<li>adjust 'sfbrowser/connectors/php/config.php' to your needs</li>
 84				<li>include the 'sfbrowser/connectors/php/init.php' in the head of the html</li>
 85				<li>if not on localhost set the correct chmod of the upload folder and it's contents</li>
 86			</ul>
 87
 88			<h3>configuration file</h3>
 89			<p>The 'sfbrowser/connectors/php/config.php' file contains a few basic constants.</p>
 90			<table cellpadding="0" cellspacing="0">
 91				<thead><tr><th>property</th><th>type</th><th>description</th><th>default</th></tr></thead>
 92				<tbody>
 93					<tr><td>SFB_PATH</td>			<td>String</td>		<td>path of sfbrowser (relative to the page it is run from)</td><td>"sfbrowser/"</td></tr>
 94					<tr><td>SFB_BASE</td>			<td>String</td>		<td>upload folder (relative to <span class="property">SFB_PATH</span>)</td><td>"../data/"</td></tr>
 95					<tr><td>SFB_LANG</td>			<td>String</td>		<td>language ISO code</td><td>"en"</td></tr>
 96					<tr><td>PREVIEW_BYTES</td>		<td>Integer</td>	<td>ASCII files can be previewed up to a certain amout of bytes.</td><td>600</td></tr>
 97					<tr><td>SFB_DENY</td>			<td>String</td>		<td>forbidden file extensions</td><td>"php,php3,phtml"</td></tr>
 98					<tr><td>FILETIME</td>			<td>String</td>		<td>datetime format</td><td>"j-n-Y H:i"</td></tr>
 99					<tr><td>SFB_ERROR_RETURN</td>	<td>String</td>		<td>return value in case of error</td><td>"&lt;html&gt;&lt;head&gt;&lt;meta http-equiv="Refresh" content="0;URL=http:/" /&gt;&lt;/head&gt;&lt;/html&gt;"</td></tr>
100					<tr><td>SFB_PLUGINS</td>		<td>String</td>		<td>case sensitive, comma separated string with plugin names</td><td>""imageresize,filetree""</td></tr>
101					<tr><td>SFB_DEBUG</td>			<td>Boolean</td>	<td>debug boolean, enables log file and console trace</td><td>false</td></tr>
102				</tbody>
103			</table>
104
105			<h3>localisation</h3>
106			<p>You can easily make SFBrowser into another language. Simply copy one of the existing language js files (sfbrowser/lang/[iso].js and sfbrowser/plugins/[name]/lang/[iso].js) and name them the <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements">ISO_3166 code</a> of the new language (in lowercase). Then edit the <span class="property">SFB_LANG</span> constant in 'sfbrowser/connectors/php/config.php' to that ISO code.<br/>
107			Should you make any language file other than the ones already present, I'd be happy to include them in a later release. Please send them to: sfbrowser at sjeiti dot com.</p>
108
109			<h3>debug</h3>
110			<p>Setting the <span class="property">SFB_DEBUG</span> value will do three things. Setting the value to true will cause inclusion of the uncompressed scripts rather than the minified ones. It will enable tracing in the console window. It will log all server side actions into 'sfbrowser/connectors/php/log.txt'.
111
112
113			<h3>javascript</h3>
114
115			<p>You can call up SFBrowser by '$.fn.sfbrowser();' or the shorter '$.sfb();'</p>
116			<p>SFBrowser has a number of properties you can parse:</p>
117			<table cellpadding="0" cellspacing="0">
118				<thead><tr><th>property</th><th>type</th><th>description</th><th>default</th></tr></thead>
119				<tbody>
120					<tr><td>title</td>	<td>String</td>		<td>title of the SFBrowser window</td><td>"SFBrowser"</td></tr>
121					<tr><td>select</td>	<td>Function</td>	<td>calback function on choose</td><td>function(a){trace(a)}</td></tr>
122					<tr><td>file</td>	<td>String</td>		<td>selected file</td><td>""</td></tr>
123					<tr><td>folder</td>	<td>String</td>		<td>a subfolder (relative to base, to which all returned files are relative)</td><td>""</td></tr>
124					<tr><td>dirs</td>	<td>Boolean</td>	<td>allow visibility and creation/deletion of subdirectories.</td><td>true</td></tr>
125					<tr><td>upload</td>	<td>Boolean</td>	<td>allow upload of files</td><td>true</td></tr>
126					<tr><td>swfupload</td><td>Boolean</td>	<td>use swf uploader instead of form hack</td><td>false</td></tr>
127					<tr><td>allow</td>	<td>Array&lt;String&gt;</td>		<td>allowed file extensions</td><td>[]</td></tr>
128					<tr><td>resize</td>	<td>Array&lt;Integer&gt;</td>		<td>maximum image constraint: array(width,height) or null</td><td>null</td></tr>
129					<tr><td>inline</td>	<td>String</td>		<td>a JQuery selector for inline browser</td><td>"body"</td></tr>
130					<tr><td>fixed</td>	<td>Boolean</td>	<td>keep the browser open after selection (only works when inline is not "body")</td><td>false</td></tr>
131					<tr><td>cookie</td>	<td>Boolean</td>	<td>use a cookie to remember path, x, y, w, h</td><td>false</td></tr>
132					<tr><td>x</td>		<td>Integer</td>	<td>x position, centered if left null</td><td>null</td></tr>
133					<tr><td>y</td>		<td>Integer</td>	<td>y position, centered if left null</td><td>null</td></tr>
134					<tr><td>w</td>		<td>Integer</td>	<td>width</td><td>460</td></tr>
135					<tr><td>h</td>		<td>Integer</td>	<td>height</td><td>480</td></tr>
136				
137					<tr><th colspan="4">the following properties normally need no change</th></tr>
138					<tr><td>img</td>	<td>Array&lt;String&gt;</td>	<td>image file extensions for preview</td><td>["gif", "jpg", "jpeg", "png"]</td></tr>
139					<tr><td>ascii</td>	<td>Array&lt;String&gt;</td>	<td>text file extensions for preview</td><td>["txt", "xml", "html", "htm", "eml", "ffcmd", "js", "as", "php", "css", "java", "cpp", "pl", "log"]</td></tr>
140					<tr><td>movie</td>	<td>Array&lt;String&gt;</td>	<td>movie file extensions for preview</td><td>["mp3","mp4","m4v","m4a","3gp","mov","flv","f4v"]</td></tr>
141					
142					<tr><th colspan="4">The following properties are set automaticly from the init file, explicitly setting these from js can lead to unexpected results.</th></tr>
143					<tr><td>sfbpath</td><td>String</td>		<td>the path of sfbrowser</td><td>"sfbrowser/"</td></tr>
144					<tr><td>base</td>	<td>String</td>		<td>the upload folder</td><td>"data/"</td></tr>
145					<tr><td>deny</td>	<td>Array&lt;String&gt;</td>		<td>denied file extensions</td><td>["php", "php3", "phtml"]</td></tr>
146					<tr><td>icons</td>	<td>Array&lt;String&gt;</td>		<td>list of existing file icons</td><td>["jpg", "html", "ico"...(etc)]</td></tr>
147					<tr><td>preview</td><td>Integer</td>	<td>amount of bytes for ascii preview</td><td>600</td></tr>
148					<tr><td>connector</td><td>String</td>	<td>server side script type</td><td>"php"</td></tr>
149					<tr><td>lang</td><td>Object</td>		<td>language object</td><td>see lang/en.js</td></tr>
150					<tr><td>plugins</td><td>Array</td>		<td>plugins</td><td>[]</td></tr>
151					<tr><td>maxsize</td><td>Integer</td>	<td>upload_max_filesize in bytes</td><td>2097152</td></tr>
152					<tr><td>debug</td><td>Boolean</td>		<td>allows trace to console</td><td>false</td></tr>
153					
154				</tbody>
155			</table>
156
157			<h3>select</h3>
158			<p>The <span class="property">select</span> property is something you will want to set if you want SFBrowser to be usefull. It's value has to be a function with one parameter: an array containing objects for the selected files (for instance: function(a){alert(a)};). Each object in that array has the following properties (where applicable):</p>
159			<table id="returnobjects" cellpadding="0" cellspacing="0">
160				<thead><tr><th>property</th><th>type</th><th>description</th></tr></thead>
161				<tbody>
162					<tr><td>file</td>		<td>String</td>		<td>the file including its path (relative to base)</td></tr>
163					<tr><td>mime</td>		<td>String</td>		<td>the filetype</td></tr>
164					<tr><td>rsize</td>		<td>Integer</td>	<td>the size in bytes</td></tr>
165					<tr><td>size</td>		<td>String</td>		<td>the size formatted to B, kB, MB, GB etc...</td></tr>
166					<tr><td>time</td>		<td>Integer</td>	<td>the time in seconds from Unix Epoch</td></tr>
167					<tr><td>date</td>		<td>String</td>		<td>the time formatted in 'j-n-Y H:i'</td></tr>
168					<tr><td>width</td>		<td>Integer</td>	<td>if image, the width</td></tr>
169					<tr><td>height</td>		<td>Integer</td>	<td>if image, the height</td></tr>
170				</tbody>
171			</table>
172			<p>Keep in mind that all returned filepaths are relative to <span class="property">base</span> (or rather <span class="property">SFB_BASE</span>). If you run SFBrowser from within a CMS you'll have to alter the returned paths to the correct frontend path.</p>
173
174			<h3>allow and deny</h3>
175			<p>These properties are arrays containing file extensions that are, or are not shown in SFBrowser. This also applies to the file types that you upload.<br/>
176			For security reasons the main deny list is located at 'sfbrowser/connectors/php/config.php' by the name of <span class="property">SFB_DENY</span> (a comma separated list of extensions). Additional file types can be denied through javascript with the <span class="property">deny</span> property.<br/>
177			If <span class="property">allow</span> is left empty (which is the default) all file types are allowed except those listed in <span class="property">deny</span>.<br/>
178			Denying is stronger than allowing so an extension in both arrays will always be denied. The <span class="property">SFB_DENY</span> constant in 'sfbrowser/connectors/php/config.php' always has priority over the <span class="property">deny</span> property parsed through javascript.</p>
179
180
181			<h2>usage</h2>
182
183			<p>SFBrowser is designed to work like a normal OS's filebrowser, however, some interactions are not possible from within most web-browsers.</p>
184
185			<h3>file selection</h3>
186			<p>There are three ways to select a file: either press the 'Choose' button, double click the file, or select 'Choose' from the (right-click) context menu.</p>
187			<p>To select multiple files you can hold CTRL while clicking files, or press CTRL-A to select all files.</p>
188
189			<h3>context menu</h3>
190			<p><img src="data/contextmenu.png" align="right" alt="contextmenu" />Right clicking a file will popup a context menu with additional (or obvious) file operations. The two functions in here that are not found anywhere else in the interface are 'Duplicate' and 'Resize'.</p>
191			<p>'Duplicate' creates a copy of the selected file and appends it with a number (multiple file duplication does not work yet).</p>
192			
193			<h3>keyboard shortcuts</h3>
194			<p>SFBrowser also comes with a number of keyboard shortcuts to make your life easier:</p>
195			<table cellpadding="0" cellspacing="0">
196				<thead><tr><th>shortcut</th><th>action</th></tr></thead>
197				<tbody>
198					<tr><td>Escape or CTRL-q</td>		<td>closes SFBrowser</td></tr>
199					<tr><td>CTRL-f</td>					<td>opens SFBrowser (only after one run)</td></tr>
200					<tr><td>F2</td>						<td>rename selected file</td></tr>
201					<tr><td>Return</td>					<td>choose file and close SFBrowser</td></tr>
202					<tr><td>CTRL-a</td>					<td>select all files</td></tr>
203					<tr><td>CTRL-click</td>				<td>select multiple files</td></tr>
204				</tbody>
205			</table>
206		
207
208
209			<h2>examples</h2>
210
211			<h3>a simple one</h3>
212			<p>The selected files are added to a list and their sizes are shown. Select multiple files by pressing CTRL and selecting. Start <a onclick="$.sfb({select:addFiles,plugins:[]});">adding files.</a></p>
213			<pre class="example">$.sfb({select:addFiles,plugins:[]});</pre> 
214			<div id="addfiles"></div>
215
216			<h3>swf uploader</h3>
217			<p>The <a onclick="$.sfb({select:addFiles,plugins:[]});">swf uploader</a> allows multiple simultanious uploads but does require the <a href="http://get.adobe.com/shockwave/" target="_blank">Adobe Shockwave plugin</a>.</p>
218			<pre class="example">$.sfb({select:addFiles,plugins:[],swfupload:true});</pre> 
219			<div class="addfiles"></div>
220			
221			<h3>allowing only images</h3>
222			<p>The <span class="property">allow</span> property is set to accept only images. The selected images are added to a div. Note also the title of the SFBrowser is now changed to: <a onclick="$.sfb({folder:'ImageFolder/',title:'Add some images',allow:['jpeg','png','gif','jpg'],resize:[640,480],select:addImages});">Add some images</a>.</p>
223			<pre class="example">$.sfb({
224	 folder:	'ImageFolder/'
225	,title:		'Add some images'
226	,allow:		['jpeg','png','gif','jpg']
227	,resize:	[640,480]
228	,select:	addImages
229});</pre> 
230
231			<h3>inline</h3>
232			<p>When you set the <span class="property">inline</span> property to something other than "body" SFBrowser will no appear as an overlay but inside the new value. The value has to be a regular JQuery selector with a single result. A selector with possible multiple results will really screw things up. If you're unsure about your selector simply add ':eq(0)' to it to ensure a single result<br/>
233			Contrary to an overlay, an inline SFBrowser will keep the rest of your page clickable.<br/>
234			Setting the <span class="property">fixed</span> property to 'true' will also disable closing the filebrowser (this will only work on inline SFBrowsers). However, calling up a new instance of SFBrowser will close any previous instance.<br/>
235			<a onclick="$.sfb({ inline:'#inhere', fixed:true, select:function(a){alert(a.length)} });">Open inline fixed</a></p>
236			<pre class="example">$.sfb({ inline:'#inhere', fixed:true, select:function(a){alert(a.length+" files selected")} });</pre> 
237			<div id="inhere"></div>
238
239
240			<h2>plugins</h2>
241
242			<p>Plugins can be used to extend or alter the basic functionality of SFBrowser. These have to be set in 'sfbrowser/connectors/php/config.php'.<br/>
243			Once set, the init will automaticly fill the $.sfbrowser.defaults.plugins variable. You can override this by parsing the <span class="property">plugins</span> variable in your SFBrowser call (as shown in example 1).</p>
244			<p>Right now SFBrowser comes with two plugins: filetree and imageresize.</p>
245
246			<h3>filetree</h3>
247			<p><img src="data/filetree.png" align="left" alt="filetree" style="margin: 0px 30px 30px 0px;" />This plugin adds an additional filetree to the left of the filetable.</p>
248
249			<h3>imageresize</h3>
250			<p><img src="data/resize_image.jpg" align="left" alt="imageresize" style="margin: 0px 30px 30px 0px;" />This plugin lets you resize and crop jpeg images. Indexed color images (gif and png) require different code that isn't implemented yet.<br />
251			Selecting 'Resize' from a files context menu will bring up a window as shown here. Larger images are always scaled down to fit the window, this scale is shown as a percentage above the image. You can resize the window if you want to bring the scaling up to one hundred percent.<br/>
252			Dragging the red squares resizes the image. Dragging the blue squares will crop the image. You can also manually enter the desired with or height.<br/>
253			Since upscaling mostly results in ugly images, upscaling is turned off. The images aspect ratio will always be maintained (meaning you can't just resize the width, the height will always follow accordingly).</p>
254
255			<h3>plugin creation</h3>
256			<p>A plugin can be one Javascript file (filetree plugin) but it can also make use of PHP (imageresize plugin).<br/>
257			If a plugin contains either or both a config.php and/or and init.php file the initialisation will include them. It is then assumed that all javascript and/or css inclusion will be handled by that init.php file.<br/>
258			If no init.php file is found, the SFBrowser initialisation will then try to find and add both the plugin.js and/or the plugin.css.<br/>
259			Right now that is all the documentation there is for plugin development. If you want to develop one simply have to look at the existing two and follow their structure. </p>
260
261
262			<h2>connectors</h2>
263
264			<p>A connector folder should at least have the following files.</p>
265			<ul>
266				<li>sfbrowser/connectors/[type]/config.[type]</li>
267				<li>sfbrowser/connectors/[type]/init.[type]</li>
268				<li>sfbrowser/connectors/[type]/sfbrowser.[type]</li>
269			</ul>
270
271			<h3>config file</h3>
272			<p>The config file should at least have the following settings:</p>
273			<ul>
274				<li>path of sfbrowser</li>
275				<li>the base upload folder</li>
276				<li>the language ISO code</li>
277				<li>ASCII preview ammount</li>
278				<li>a list of forbidden file extensions</li>
279				<li>an error return code (for severe misuse)</li>
280			</ul>
281			<p>The config file is used in both the init file (to parse to sfbrowser js) and in the actual sfbrowser file (which does the actual server side thinking).</p>
282
283			<h3>init file</h3>
284			<p>The init file must be called in the html documents header in order to write these lines:</p>
285			<pre>&lt;link rel="stylesheet" type="text/css" media="screen" href="sfbrowser/css/sfbrowser.css" /&gt;
286&lt;script type="text/javascript" src="sfbrowser/array.js"&gt;&lt;/script&gt;
287&lt;script type="text/javascript" src="sfbrowser/jquery.tinysort.min.js"&gt;&lt;/script&gt;
288&lt;script type="text/javascript" src="sfbrowser/jquery.sfbrowser.min.js"&gt;&lt;/script&gt;
289&lt;script type="text/javascript" src="sfbrowser/lang/en.js"&gt;&lt;/script&gt;
290&lt;script type="text/javascript"&gt;
291	&lt;!--
292	$.sfbrowser.defaults.connector = "php";
293	$.sfbrowser.defaults.sfbpath = "sfbrowser/";
294	$.sfbrowser.defaults.base = "../data/";
295	$.sfbrowser.defaults.preview = 600;
296	$.sfbrowser.defaults.deny = ["php","php3","phtml"];
297	$.sfbrowser.defaults.icons = ['ai','as','avi','bmp','cs','default',(...)];
298	--&gt;
299&lt;/script&gt;</pre>
300			<p>As you might have noticed, most of these lines are formed to what is set in the config file. The icons variable is a folder readout from the sfbrowser/icons/ folder.</p>
301			
302			<h3>sfbrowser file</h3>
303			<p>The sfbrowser file is the actual connector to the SFBrowser plugin. Mostly it will require some POST variables and a JSON output object.<br/>
304			A POST will always contain a variable "a" that will determine the action to be taken.</p>
305			<p>For all actions counts: make absolutely sure that the incoming data corresponds with that set in the config file!</p>
306			<ul>
307				<li>Do not upload forbidden filetypes.</li>
308				<li>Only upload, rename, create, view, change and delete within base upload path.</li>
309				<li>Rename files, but not the file extension.</li>
310				<li>Do not return, force download or preview forbidden filetypes.</li>
311			</ul>
312			<p>Mostly, a POST (or GET in case of force download) will contain the variable "folder" and the variable "file". Check both of these against the base upload folder set in the config. If it's outside, somebody is probably screwing around.<br/>
313			Just to be sure, check the number of _GET, _POST and _FILES variables. A _POST["a"] can only get a certain ammount of each, if these differ, something fishy might be going on.<br/>
314			If suspicious action occurs you can redirect them to the return error code set in the config file in order to block acces or whatever you'd like to do(??haven't really figured out how to go from there, consider it a loose stub??).</p>
315			<p>A number of the JSON outputs contain file descriptions. In the description of the types of actions the file object is referred to as &lt;FileObject&gt;. It looks like this:</p>
316			<pre>JSON FileObject: {
317	 file:		&lt;String&gt;	file name
318	,mime:		&lt;String&gt;	file extention
319	,rsize:		&lt;uint&gt;		file size in bytes
320	,size:		&lt;String&gt;	file size in kB, MB or whatever
321	,time:		&lt;uint&gt;		time in Unix Epoch
322	,date:		&lt;String&gt;	time in "j-n-Y H:i"
323	,width:		&lt;uint&gt;		image width in pixels
324	,height:	&lt;uint&gt;		image height in pixels
325}</pre>
326			<p>The following are the possible values for _POST["a"]: the possible actions that can be taken and the required return values.</p>
327
328			<h3>_POST["a"]=="chi" :: retreive file list</h3>
329			<pre>input:
330	_POST["folder"] &lt;String&gt;	path to folder
331action:
332	Read the contents of a folder
333	Filter out the forbidden file types
334	If applicable, filter for allowed file types
335output: JSON {
336	 error:		&lt;String&gt;	error message (see lang.js)
337	,msg:		&lt;String&gt;	succes message (see lang.js)
338	,data:		&lt;Object&gt;	object containing &lt;FileObject&gt;'s
339}
340example: {
341	error:	"",
342	msg:	"fileListing",
343	data: {
344		a: &lt;FileObject&gt;,
345		b: &lt;FileObject&gt;,
346		c: &lt;FileObject&gt;,
347		...
348	}
349}</pre>
350
351			<h3>_POST["a"]=="fu" :: file upload</h3>
352			<pre>input:
353	_FILES["fileToUpload"]	&lt;Object&gt;	file object
354	_POST["file"]		&lt;String&gt;	path to folder
355	_POST["deny"]		&lt;String&gt;	pipe separated string of denied file extensions ("php|tpl|log")
356	_POST["allow"]		&lt;String&gt;	pipe separated string of allowed file extensions ("gif|jpg|jpeg|png")
357	_POST["resize"]		&lt;Array&gt;		resize image to [width,heigth]
358	
359action:
360	Check for _FILES["fileToUpload"]["error"]
361	Check _FILES["fileToUpload"]["tmp_name"] for actual upload
362	Check forbidden filetypes
363	Check allowed filetypes
364	Check upload folder for similarly named file
365	Move file to upload folder
366	If applicable, resize image
367output: JSON {
368	 error:		&lt;String&gt;	error message (see lang.js)
369	,msg:		&lt;String&gt;	succes message (see lang.js)
370	,data:		&lt;FileObject&gt;	uploaded file
371}</pre>
372
373			<h3>_POST["a"]=="kung" :: duplicate file</h3>
374			<pre>input:
375	_POST["file"]	&lt;String&gt;	file name
376	_POST["folder"]	&lt;String&gt;	file folder
377action:
378	Create new non-existing file name
379	Duplicate file to that name
380output: JSON {
381	 error:		&lt;String&gt;	error message (see lang.js)
382	,msg:		&lt;String&gt;	succes message (see lang.js)
383	,data:		&lt;FileObject&gt;	duplicated file
384}</pre>
385
386			<h3>_POST["a"]=="ka" :: file delete</h3>
387			<pre>input:
388	_POST["file"]	&lt;String&gt;	file name
389	_POST["folder"]	&lt;String&gt;	file folder
390action:
391	delete file
392output: JSON {
393	 error:		&lt;String&gt;	error message (see lang.js)
394	,msg:		&lt;String&gt;	succes message (see lang.js)
395}</pre>
396
397			<h3>_POST["a"]=="sui" :: file force download</h3>
398			<pre>input:
399	_POST["file"]	&lt;String&gt;	file name
400	_POST["folder"]	&lt;String&gt;	file folder
401action:
402	Force file download
403output: nothing</pre>
404
405			<h3>_POST["a"]=="mizu" :: read txt file contents</h3>
406			<pre>input:
407	_POST["file"]	&lt;String&gt;	file name
408	_POST["folder"]	&lt;String&gt;	file folder
409action:
410	Read and return file contents
411output: JSON {
412	 error:		&lt;String&gt;	error message (see lang.js)
413	,msg:		&lt;String&gt;	succes message (see lang.js)
414	,data: {
415		text:	&lt;String&gt;	first x amount of bytes from ascii file
416	}
417}</pre>
418
419			<h3>_POST["a"]=="ho" :: rename file</h3>
420			<pre>input:
421	_POST["file"]	&lt;String&gt;	original file name
422	_POST["folder"]	&lt;String&gt;	file folder
423	_POST["nfile"]	&lt;String&gt;	new file name
424action:
425	Check if new file name is valid
426	Rename file
427output: JSON {
428	 error:		&lt;String&gt;	error message (see lang.js)
429	,msg:		&lt;String&gt;	succes message (see lang.js)
430}</pre>
431
432			<h3>_POST["a"]=="tsuchi" :: add folder</h3>
433			<pre>input:
434	_POST["folder"]		&lt;String&gt;	folder to create new folder into
435	_POST["foldername"]	&lt;String&gt;	new folder name
436action:
437	Create new folder
438output: JSON {
439	 error:		&lt;String&gt;	error message (see lang.js)
440	,msg:		&lt;String&gt;	succes message (see lang.js)
441	,data:		&lt;FileObject&gt;	newly created folder
442}</pre>
443
444			<h3>_POST["a"]=="bar" :: image resize (in imageresize plugin)</h3>
445			<pre>input:
446	_POST["file"]	&lt;String&gt;	file name
447	_POST["folder"]	&lt;String&gt;	file folder
448	_POST["w"]	&lt;uint&gt;		new width
449	_POST["h"]	&lt;uint&gt;		new height
450action:
451	Resize image
452output: JSON {
453	 error:		&lt;String&gt;	error message (see lang.js)
454	,msg:		&lt;String&gt;	succes message (see lang.js)
455}</pre>
456
457		</div>
458		<div id="footer"> 
459			<div>??? 2008 <a href="http://www.sjeiti.com/">Ron Valstar</a></div>
460		</div>
461	</body>
462</html>