<?php
$conf_basedir	= "../../";	//相对主目录的位置
$conf_where		= "admin";	//选择调用相应模块
$directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
include_once($conf_basedir."base.inc.php");

include_once(CORE_LIB . "/PHPExcel/Classes/PHPExcel.php"); 
include_once(CORE_LIB . "/PHPExcel/Classes/PHPExcel/IOFactory.php"); 
include_once(CORE_LIB . "/PHPExcel/Classes/PHPExcel/Reader/Excel5.php"); 
include_once(CORE_LIB . "/PHPExcel/Classes/PHPExcel.php"); 
include_once(CORE_LIB . "/growth/GrowthRewardUpload.php"); 



$upload_name = "Filedata";

$growth = new GrowthRewardUpload();

$referer = $_SERVER['HTTP_REFERER'];

$filename = $_FILES[$upload_name]['name'];
$tmp_name = $_FILES[$upload_name]['tmp_name'];
$file_extend = $growth->getFileExt($filename);

if($file_extend == '.xls' || $file_extend == '.XLS'){
    //获取Excel上传的文档
    $uid_arr = $growth->uploadexcel($tmp_name);
    $newfilename = md5(time()).$file_extend;//上传后文件名  
    $upload_dir = getcwd();
    $upload_dir = str_replace("module/growth", "", $upload_dir)."../uploads/growth/"; 
    $broker_number = count($uid_arr);//上传经纪人数量
    if ($broker_number<1) {
        $error=3;//文件内容有误
    } else if($broker_number<1001){
        $ass = move_uploaded_file($_FILES[$upload_name]["tmp_name"], $upload_dir.$newfilename);
        $error =0;
    } else {
        $error=2;//上传人数超过1000人
    }  
    

}else{
    $error=1;//文件格式错误
}

echo $error.",".$filename.",".$newfilename.",".$broker_number;



?>