$typeid = $_GET['typeid'];
if( ! intval( $typeid ) )
{
echo '请传值给typeid';
exit;
}
$path = $_GET['path'];
if( $path =="" )
{
echo '请传值给path ,如 a/b/c/';
exit;
}
function getfile($path)
{
$dirs = array();
foreach(glob("$path*") as $d)
{
$tmp = explode('.',$d);
$k = end($tmp);
if(is_file($d) && ( $k=='jpg' || $k =='gif' || $k=='png'))
{
$dirs[] = $d;
}
}
return $dirs;
}
$array = getfile($path);
foreach( $array as $v => $vv )
{
//www.111com.net取名字
$t_name = explode( '/',$vv ); ;
$tV = end($t_name);
list($name,$ext) = explode('.',$tV);
$sql ="INSERT INTO `dedecms_archives` (`typeid`, `typeid2`, `sortrank`, `flag`, `ismake`, `channel`, `arcrank`, `click`, `money`, `title`, `shorttitle`, `color`, `writer`, `source`, `litpic`, `pubdate`, `senddate`, `mid`, `keywords`, `lastpost`, `scores`, `goodpost`, `badpost`, `voteid`, `notpost`, `description`, `filename`, `dutyadmin`, `tackid`, `mtype`, `weight`) VALUES
($typeid, '0', 1394943742, 'c,p', 1, 17, 0, 156, 0, '$name', 'S".$typeid.mt_rand(0,99999)."', '', 'admin', '未知', '/$vv', 1394943742, 1394943720, 1, '$name', 0, 0, 0, 0, 0, 0, '', '', 1, 0, 0, 11)";
mysql_query( $sql ) or die( mysql_error().$sql );
$aid= mysql_insert_id();
$sql2 ="INSERT INTO `dedecms_addonarticle17` (`aid`, `typeid`, `body`, `redirecturl`, `templet`, `userip`, `s_type`) VALUES
($aid, $typeid, '', '', '', '192.168.1.108', 'S12000".$name."')";
mysql_query( $sql2 ) or die( mysql_error().$sql2 );
$sql3 ="INSERT INTO `dedecms_arctiny` (`id`, `typeid`, `typeid2`, `arcrank`, `channel`, `senddate`, `sortrank`, `mid`) VALUES
($aid, $typeid, '0', 0, 17, 1394943720, 1394943742, 1)";
mysql_query( $sql3 ) or die( mysql_error().$sql3 );
}
echo '导入成功';
print_r($array);
|