001 | header( "Content-type:text/html;charset=utf8" ); |
003 | require_once( '/../dedecms/include/common.inc.php' ); |
005 | error_reporting(E_ALL); |
009 | date_default_timezone_set( 'Europe/London' ); |
013 | set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/' ); |
015 | /** PHPExcel_IOFactory */ |
017 | include 'PHPExcel/IOFactory.php' ; |
021 | $typeid = $_GET[ 'typeid' ]; |
023 | $dopost = $_GET[ 'do' ]; |
025 | if ($dopost == "exdata" ){ |
027 | if (!empty($_GET[ 'n' ])){ |
029 | $inputFileName = './' .$_GET[ 'n' ]. '.xlsx' ; |
031 | $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); |
033 | $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true , true , true ); |
037 | $dsql->Execute( 'all' , "select bio2,bio1 from `dede_addonshop`" ); |
039 | while ($rowall = $dsql->GetArray( 'all' )) { |
045 | foreach ($sheetData as $ v ) { |
047 | foreach ($rowarr as $vt) { |
049 | if (in_array($ v [ 'B' ],$vt)&&$ v [ 'A' ]==$vt[ 'bio1' ]){ |
053 | 的数据已在表中,请在excel文件里面删除这一条后再添加!"; |
063 | $row = $dsql->GetOne( "select aid,bio2 from `dede_addonshop` order by aid desc" ); |
081 | if ($bio2==$sheetData[count($sheetData)][ 'B' ]){ |
083 | ShowMsg( "不能重复添加内容" , 'javascript:;' ); |
091 | $arcrow = $dsql->GetOne( "select id from `dede_archives` order by id desc" ); |
095 | $arcid = $arcrow[ 'id' ]; |
105 | $tinyrow = $dsql->GetOne( "select id from `dede_arctiny` order by id desc" ); |
109 | $tinyid = $tinyrow[ 'id' ]; |
119 | $ id = max($aid,$arcid,$tinyid); |
121 | $alphalpha = array( 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' , 'AA' , 'AB' , 'AC' , 'AD' , 'AE' , 'AF' , 'AG' , 'AH' , 'AI' , 'AJ' , 'AK' , 'AL' , 'AM' , 'AN' , 'AO' , 'AP' , 'AQ' , 'AR' , 'AS' , 'AT' , 'AU' , 'AV' , 'AW' , 'AX' , 'AY' , 'AZ' ); |
125 | $fieldnum = count($sheetData[1]); |
127 | $fields = $fieldvalue = '' ; |
129 | for ($i=0; $i < $fieldnum; $i++) { |
131 | $fields .= $sheetData[1][$alphalpha[$i]]. ',' ; |
135 | $fields = substr($fields, 0,-1); |
139 | foreach ($sheetData as $value) { |
141 | $pubdate = GetMkTime(GetDateTimeMk( time ())); |
143 | $click = mt_rand(50, 200); |
145 | if ($value[ 'A' ]== 'bio1' |$value[ 'A' ]== '厂商' ){ |
155 | for ($i=0; $i < $fieldnum; $i++) { |
157 | $fieldvalue .= " ,'" .$value[$alphalpha[$i]]. "' " ; |
163 | $C = trim($value[ 'C' ]); |
169 | $arcquery = "INSERT INTO `dede_archives`(id,typeid,title,mid,channel,pubdate,senddate,click,ismake)VALUES ('$id','$typeid','$C','1','6','$pubdate','$senddate','$click','-1');" ; |
171 | $dsql->ExecuteNoneQuery($arcquery); |
175 | $query = "INSERT INTO `dede_addonshop`(aid,typeid,$fields) |
177 | VALUES ( '$id' , '$typeid' {$fieldvalue});"; |
179 | $dsql->ExecuteNoneQuery($query); |
185 | $tinyquery = "INSERT INTO `dede_arctiny`(id,typeid,channel,mid,senddate)VALUES ('$id','$typeid','6','1','$senddate');" ; |
187 | $dsql->ExecuteNoneQuery($tinyquery); |
191 | $num = count($sheetData)-2; |
193 | ShowMsg( "恭喜,成功插入 " .$num. " 条数据!" , 'javascript:;' ); |
|