<?php
if(!defined('APP_PATH')||!defined('I_PATH')){exit('Access Denied');}
class uploads extends controllerBase
{
	function __construct(){
		parent::__construct();
		$this->fileClass=syClass('syupload');
	}
	function index(){
		
		if (!empty($_FILES)){
			//print_r($_FILES);
			$fileinfos = $this->fileClass->upload_file($_FILES[$this->sysParams('isfiles',1)]);

			if(isset($fileinfos['fn']))
			{
				$fileinfos['fn']=str_replace('http:/' ,'http://', str_replace('//', '/' , $GLOBALS['iConfig']['ext']['http_path']."/".$fileinfos['fn']));
			}
			if (is_array($fileinfos)){
				echo '0';
					$f=explode('.',$fileinfos['fn']);
					echo ','.$fileinfos['fn'];
					
					echo ','.preg_replace('/.*\/.*\//si','',$f[0]);
					if(stripos($fileinfos['fn'],'jpg') || stripos($fileinfos['fn'],'gif') || stripos($fileinfos['fn'],'png') || stripos($fileinfos['fn'],'jpeg')){
						echo ',1';
					}else{
						echo ','.$f[1];
					}
			}else{
				echo $this->fileClass->errmsg;
			}
		}
	}
	function loadup(){
		//die;
		$this->inputid=$this->sysParams('inputid',1);
		$this->multi=$this->sysParams('multi') ? 'true':'false';
		if($this->sysParams('fileExt',1)){$this->fileExt=$this->sysParams('fileExt',1);}else{
			foreach(explode(',',syExt('filetype')) as $v){
				$fileExt.=';*.'.$v;
			}$this->fileExt=substr($fileExt,1);
		}
		$this->sizeLimit=$this->sysParams('sizeLimit') ? $this->sysParams('sizeLimit'):syExt('filesize');
		$this->fileover=$this->sysParams('fileover') ? $this->sysParams('fileover'):1;
		
		$this->display("uploads.html");
	}
}