<?php
///////////////////////////////////////////////////////////////////////////////////////
// PHPizabi 0.848b C1 [ALICIA]                               http://www.phpizabi.net //
///////////////////////////////////////////////////////////////////////////////////////
// Please read the license.txt file before using / modifying this software           //
// Original author:         Claude Desjardins, R - feedback@realitymedias.com        //
// Last modification date:  August 26th 2006                                         //
// Version:                 PHPizabi 0.848b C1                                       //
//                                                                                   //
// (C) 2005, 2006 Real!ty Medias / PHPizabi - All rights reserved                    //
///////////////////////////////////////////////////////////////////////////////////////

	/* Check Structure Availability */
	if (!defined("CORE_STRAP")) die("Out of structure call");
	
	// TEMPLATE HANDLING ////////////////////////////////////////////////////////////////// FINAL //
	/*
		Initialize the template engine and
		load the template file. Get objects,
		convert self user.
	*/
	$tpl = new template;
	$tpl -> Load("file");
	
	if (isset($_GET["id"]) && is_numeric($_GET["id"])) $tpl -> AssignUser($_GET["id"]);
	else die("No user ID provided, unable to act");
	
	
	if (isset($_POST["Submit"])) {
	
		if (
			is_uploaded_file($_FILES["file"]["tmp_name"]) 
			and preg_match('/\\.jpg$|\\.jpeg$|\\.gif$|\\.png$|\\.zip$|\\.tar$/i', basename($_FILES["file"]["name"]))
		) {
			
			$filename = strtolower(rand(1,999)."_".basename($_FILES["file"]["name"]));
			move_uploaded_file($_FILES["file"]["tmp_name"], "system/cache/temp/{$filename}");
				
			$ext = strtolower(substr(basename($_FILES["file"]["name"]), strlen(basename($_FILES["file"]["name"]))-3));
			if (in_array($ext, explode(",", $CONF["ATTACHMENT_ALLOWED_EXTENTIONS"]))) {
				
				/*
					If the user is online, we will send the page
					to the lane system
				*/
				if (_fnc("user", $_GET["id"], "last_load") > date("U")-300) {
	
					_fnc("laneMakeToken", "file", $_GET["id"], array(
						"{user.username}" => me("username"),
						"{file}" => "system/cache/temp/".$filename,
					));
				}
				
				/*
					Show the success message
				*/
				$tpl->Zone("page", "success");
			}
		}
	}
	
	
	else $tpl->Zone("page", "enabled");

	
	$tpl -> Flush();
	
?>