$filename = upfile(is_array($fileData) ? $_FILES[fileData][tmp_name] : $fileData, $array); $newfile = "{$webdb['www_url']}/{$webdb['updir']}/{$dir}/{$filename}"; //插入数据,关闭层 echo '<html>'; echo '<head>'; echo '<title>Insert Image</title>'; echo '<meta http-equiv="content-type" content="text/html; charset=gb2312">'; echo '</head>'; echo '<body>'; if ($utype == '311') { //用户没有设置图片大小,并且系统固定了图片大小,系统会自动裁图 $turepath = ROOT_PATH . "{$webdb['updir']}/{$dir}/{$filename}"; if (!$_POST['imgWidth'] && !$_POST['imgHeight'] && $webdb[ArticlePicWidth] && $webdb[ArticlePicHeight]) { $img_array = getimagesize($turepath); if ($img_array[0] > $webdb[ArticlePicWidth] || $img_array[1] > $webdb[ArticlePicHeight]) { gdpic($turepath, $turepath, $webdb[ArticlePicWidth], $webdb[ArticlePicHeight], 1); $img_array = getimagesize($turepath); $_POST['imgWidth'] = $img_array[0]; $_POST['imgHeight'] = $img_array[1]; } } echo '<script type="text/javascript">parent.KE.plugin["' . $filetype . '"].insert("' . $_POST['id'] . '", "' . $newfile . '","' . $array[name] . '","' . $_POST['imgWidth'] . '","' . $_POST['imgHeight'] . '","' . $_POST['imgBorder'] . '");</script>'; } elseif (!$_GET[Ctype]) { echo "<SCRIPT LANGUAGE=\"JavaScript\">parent.KindInsertImage('{$newfile}','{$imgWidth}','{$imgHeight}','{$imgBorder}','{$imgTitle}','{$imgAlign}','{$imgHspace}','{$imgVspace}')</SCRIPT>"; } else { echo "<SCRIPT LANGUAGE=\"JavaScript\">parent.KindInsertImageP8FLV('{$newfile}','{$imgWidth}','{$imgHeight}','{$_GET['Ctype']}')</SCRIPT>"; } echo '</body>'; echo '</html>'; exit; }
//如果是从文章内容提取的图片,需要重命为另一张,否则影响到原来的 if (strstr($postdb[content], $postdb[picurl])) { $smallpic = str_replace(".", "_", $postdb[picurl]) . ".gif"; } else { $smallpic = "{$postdb['picurl']}"; } $Newpicpath = ROOT_PATH . "{$webdb['updir']}/{$smallpic}"; $picWidth > 500 && ($picWidth = 300); $picWidth < 50 && ($picWidth = 300); $picHeight > 500 && ($picHeight = 225); $picHeight < 50 && ($picHeight = 225); //多生成一张3:4的图片,方便标签调用 gdpic(ROOT_PATH . "{$webdb['updir']}/{$postdb['picurl']}", "{$Newpicpath}.jpg", $picHeight ? $picHeight : 225, $picWidth ? $picWidth : 300, $webdb[autoCutSmallPic] ? array('fix' => 1) : ''); //多生成一张1:1的图片,方便标签调用 gdpic(ROOT_PATH . "{$webdb['updir']}/{$postdb['picurl']}", "{$Newpicpath}.jpg.jpg", $picWidth ? $picWidth : 300, $picWidth ? $picWidth : 300, $webdb[autoCutSmallPic] ? array('fix' => 1) : ''); gdpic(ROOT_PATH . "{$webdb['updir']}/{$postdb['picurl']}", $Newpicpath, $picWidth ? $picWidth : 300, $picHeight ? $picHeight : 225, $webdb[autoCutSmallPic] ? array('fix' => 1) : ''); if (file_exists($Newpicpath)) { $postdb[picurl] = $smallpic; //FTP上传文件到远程服务器 if ($webdb[ArticleDownloadUseFtp]) { ftp_upfile($Newpicpath, $postdb[picurl]); } } } else { if (file_exists(ROOT_PATH . "{$webdb['updir']}/{$post_picurl}.jpg")) { move_attachment($lfjuid, tempdir("{$post_picurl}.jpg"), $downloadDIR, 'small'); } if (file_exists(ROOT_PATH . "{$webdb['updir']}/{$post_picurl}.jpg.jpg")) { move_attachment($lfjuid, tempdir("{$post_picurl}.jpg.jpg"), $downloadDIR, 'small'); } }
$fname = $fidDB[name]; foreach ($photodb as $key => $photo) { //图片目录转移 move_attachment($userdb[uid], tempdir($photo), "article/{$postdb['fid']}"); if (file_exists(ROOT_PATH . "{$webdb['updir']}/article/{$postdb['fid']}/" . basename($photo))) { $photo = "article/{$postdb['fid']}/" . basename($photo); } if ($batch == 0) { $postdb[title] = $namedb[$key]; } else { $postdb[title] = $title; } if (!$postdb[picurl] && $webdb[if_gdimg]) { $smallpic = str_replace(".", "_", $photo) . ".gif"; $Newpicpath = ROOT_PATH . "{$webdb['updir']}/{$smallpic}"; gdpic(ROOT_PATH . "{$webdb['updir']}/{$photo}", $Newpicpath, 200, 150); if (file_exists($Newpicpath)) { $postdb[picurl] = "{$smallpic}"; } else { $postdb[picurl] = "{$photo}"; } } elseif (!$postdb[picurl]) { $postdb[picurl] = "{$photo}"; } $postdb[content] = addslashes(En_TruePath("<CENTER><IMG onclick=window.open(this.src); src='" . tempdir($photo) . "' onload=makesmallpic(this,500,700); border=0><br><br>{$namedb[$key]}</CENTER>")); $postdb[yz] = 1; $erp = $Fid_db[iftable][$postdb[fid]]; if ($batch == 0 || $ck == 0) { $timestamp++; $db->query("\n\t\t\tINSERT INTO {$pre}article{$erp} ( `title`, `fid`,`fname`,`pages`, `posttime`, `list`, `uid`, `username`, `author`,`picurl`,`ispic`, `yz`, `keywords`,`style`, `template`, `target`,`ip` ) \n\t\t\tVALUES\n\t\t\t('{$postdb['title']}','{$postdb['fid']}','{$fname}','1','{$timestamp}','{$timestamp}','{$userdb['uid']}','{$userdb['username']}','{$postdb['author']}','{$postdb['picurl']}',1,'{$postdb['yz']}','{$postdb['keywords']}','{$postdb['style']}','{$postdb['template']}','{$postdb['target']}','{$onlineip}')\n\t\t\t"); $rs = $db->get_one("SELECT * FROM {$pre}article{$erp} ORDER BY aid DESC LIMIT 1");
} if ($isiframe == 1) { $postdb[jumpurl] = ''; } elseif ($isiframe == 2) { $postdb[iframeurl] = ''; } else { $postdb[iframeurl] = $postdb[jumpurl] = ''; } //设法生成缩略图 if (!$postdb[picurl] && ($file_db = get_content_attachment($postdb[content]))) { if ($file_db[0] && eregi("(jpg|gif)\$", $file_db[0]) && !eregi("sysimage\\/file", $file_db[0])) { $postdb[picurl] = $file_db[0]; if ($webdb[if_gdimg]) { $postdb[picurl] = str_replace(".", "_", $file_db[0]) . '.gif'; $Newpicpath = ROOT_PATH . "{$webdb['updir']}/{$postdb['picurl']}"; gdpic(ROOT_PATH . "{$webdb['updir']}/{$file_db['0']}", $Newpicpath, 200, 150); if (!file_exists($Newpicpath)) { $postdb[picurl] = $file_db[0]; } } } } if ($postdb[picurl]) { $postdb[ispic] = 1; } else { $postdb[ispic] = 0; } //图片目录转移 $postdb[content] = move_attachment($lfjdb[uid], $postdb[content], "{$_pre}/{$fid}"); //获取远程图片 $postdb[content] = get_outpic($postdb[content], $fid, $GetOutPic);
function move_attachment($uid, $str, $newdir, $type = '') { global $webdb, $db, $pre, $id, $aid, $fid, $timestamp, $webdb, $Fid_db; if (!$str || !$uid || !$newdir) { return $str; } $_id = $id ? $id : $aid; //Ä¿Ç°½ö¶ÔÎÄÕÂ×÷´¦Àí,з¢ÎÄÕÂʱ,Éè·¨»ñÈ¡ID if (!$webdb[module_id] && !$_id) { $erp = $Fid_db[iftable][$fid]; $rs = $db->get_one("SHOW TABLE STATUS LIKE '{$pre}article{$erp}'"); $_id = $rs[Auto_increment]; } $filedb = get_content_attachment($str); foreach ($filedb as $key => $value) { $name = basename($value); if ($rs = $db->get_one("SELECT * FROM {$pre}upfile WHERE filename='{$name}'")) { if ($_id && !in_array($_id, explode(",", $rs[ids]))) { $db->query("UPDATE `{$pre}upfile` SET `num`=`num`+1,ids='{$rs['ids']},{$_id}' WHERE filename='{$name}'"); } continue; } $detail = explode("_", $name); //»ñÈ¡ÎļþµÄUIDÓëÓû§µÄUIDÒ»Ñùʱ.²Åɾ³ý.²»ÒªÂÒɾ³ý if ($detail[0] && $detail[0] == $uid) { $turepath = ROOT_PATH . $webdb[updir] . "/" . $value; if (!is_dir(ROOT_PATH . $webdb[updir] . "/" . $newdir)) { makepath(ROOT_PATH . $webdb[updir] . "/" . $newdir); } //×Ô¶¯ËõС̫´óÕŵÄͼƬ if ($webdb[ArticlePicWidth] && $webdb[ArticlePicHeight] && (eregi(".gif\$", $turepath) || eregi(".jpg\$", $turepath))) { $img_array = getimagesize($turepath); if ($img_array[0] > $webdb[ArticlePicWidth] || $img_array[1] > $webdb[ArticlePicHeight]) { gdpic($turepath, $turepath, $webdb[ArticlePicWidth], $webdb[ArticlePicHeight], 1); } } //ͼƬ¼Óˮӡ if ($type != 'small' && $webdb[is_waterimg] && (eregi(".gif\$", $turepath) || eregi(".jpg\$", $turepath))) { include_once ROOT_PATH . "inc/waterimage.php"; imageWaterMark($turepath, $webdb[waterpos], ROOT_PATH . $webdb[waterimg]); } if (@rename($turepath, ROOT_PATH . $webdb[updir] . "/{$newdir}/{$name}")) { $str = str_replace("{$value}", "{$newdir}/{$name}", $str); $db->query("INSERT INTO `{$pre}upfile` ( `module_id` , `ids` , `fid` , `uid` , `posttime` , `url` , `filename` , `num` ) VALUES ('{$webdb['module_id']}','{$_id}','{$fid}','{$uid}','{$timestamp}','{$newdir}/{$name}','{$name}','1')"); } } } return $str; }
function post_info_photo() { global $ftype, $fid, $webdb, $photodb, $groupdb, $_pre, $web_admin; if ($web_admin) { $picnum = 80; } else { $picnum = $groupdb[post_info_pic_num]; } foreach ($_FILES as $key => $value) { $i = (int) substr($key, 10); if (is_array($value)) { $postfile = $value['tmp_name']; $array[name] = $value['name']; $array[size] = $value['size']; } else { $postfile = ${$key}; $array[name] = ${$key . '_name'}; $array[size] = ${$key . '_size'}; } if ($ftype[$i] == 'in' && $array[name]) { $jj++; if ($jj > $picnum) { unset($photodb[$i]); continue; } if (!eregi("(gif|jpg|png)\$", $array[name])) { showerr("只能上传GIF,JPG,PNG格式的文件,你不能上传此文件:{$array['name']}"); } $array[path] = $webdb[updir] . "/{$_pre}/{$fid}"; $array[updateTable] = 1; //统计用户上传的文件占用空间大小 $filename = upfile($postfile, $array); $photodb[$i] = "{$_pre}/{$fid}/{$filename}"; $smallimg = $photodb[$i] . '.gif'; $Newpicpath = ROOT_PATH . "{$webdb['updir']}/{$smallimg}"; gdpic(ROOT_PATH . "{$webdb['updir']}/{$photodb[$i]}", $Newpicpath, 300, 220); /*加水印*/ if ($webdb[is_waterimg] && $webdb[if_gdimg]) { include_once ROOT_PATH . "inc/waterimage.php"; $uploadfile = ROOT_PATH . "{$webdb['updir']}/{$photodb[$i]}"; imageWaterMark($uploadfile, $webdb[waterpos], ROOT_PATH . $webdb[waterimg]); } } } }
} elseif (strlen($postdb[content]) > 10000) { showerr("内容不能大于10000个字节"); } if ($postdb[picurl] && !eregi("(jpg|gif|png)\$", $postdb[picurl])) { showerr("封面只能是JPG,PNG,GIF格式的图片"); } /*缩略图处理*/ if ($postdb[picurl] && !strstr($postdb[picurl], "http://")) { //图片目录转移 move_attachment($lfjdb[uid], tempdir($postdb[picurl]), "special/{$postdb['fid']}"); if (file_exists(ROOT_PATH . "{$webdb['updir']}/special/{$postdb['fid']}/" . basename($postdb[picurl]))) { $postdb[picurl] = "special/{$postdb['fid']}/" . basename($postdb[picurl]); } $water_info = getimagesize(ROOT_PATH . "{$webdb['updir']}/{$postdb['picurl']}"); if ($webdb[if_gdimg] && $water_info[0] > 150) { gdpic(ROOT_PATH . "{$webdb['updir']}/{$postdb['picurl']}", ROOT_PATH . "{$webdb['updir']}/{$postdb['picurl']}", 200, 150); } } $postdb[title] = filtrate($postdb[title]); $postdb[content] = filtrate($postdb[content]); $postdb[picurl] = filtrate($postdb[picurl]); $postdb[banner] = filtrate($postdb[banner]); $postdb[allowpost] = @implode(",", $postdb[allowpost]); } } if ($job == 'listsp') { $rows = 10; if ($page < 1) { $page = 1; } $min = ($page - 1) * $rows;