<?php require_once('includes/requirelogin.inc.php'); require_once('includes/requirepost.inc.php'); $file=$_FILES['file']; if (!$file) { return; } if (!$Allowed_UploadFile_Ext) $Allowed_UploadFile_Ext=array(); if (!in_array(pathinfo($file['name'],PATHINFO_EXTENSION),$Allowed_UploadFile_Ext)) $file['error']=UPLOAD_ERR_EXTENSION; $upload_status=array(); if (function_exists("apc_fetch")) $upload_status=apc_fetch("upload_$_POST[APC_UPLOAD_PROGRESS]"); if ($file['error']!=UPLOAD_ERR_OK) { $upload_status['error']=$file['error']; } else { $relative_path=implode('/',str_split(base_convert(time(),10,36),1)); $dir=$Config->Paths['upload'].'/'.$relative_path; @mkdir($dir,0750,true); $ext=pathinfo($file['name'],PATHINFO_EXTENSION); $filename=uniqid(rand()).'.'.$ext; $upload_status['path']=$relative_path.'/'.$filename; if (function_exists("apc_store")) apc_store("upload_$_POST[APC_UPLOAD_PROGRESS]",$upload_status); $UPLOADED_FILE=$dir.'/'.$filename; if (!move_uploaded_file($file['tmp_name'],$UPLOADED_FILE)) { @unlink($file['tmp_name']); $UPLOADED_FILE=null; } } if (function_exists("apc_store")) apc_store("upload_$_POST[APC_UPLOAD_PROGRESS]",$upload_status); $xml=simplexml_load_string("<?xml version='1.0'?><progress/>"); $xml->addChild('percent','100'); $xml->addChild('cancelled','0'); if ($upload_status['path']) $xml->addChild('path',$upload_status['path']); if ($upload_status['error']) { $xml->addChild('error',$upload_status['error']); $upload_status['done']=1; } $xml->addChild('done',1); $CMD_TMPL_NAME='upload.do'; $dataset['progress-xml']=$xml->asXML(); ?>