其实这么说吧,只要是一些重复的来回的手工 *** 作,都可以由“极速点击虎”软件编排替代!实现办公自动化辅助,批量自动运行的!
用帝国做的商城系统,上传了很多产品图片,后来要求把缩略图改小,很伤脑筋,结果找到上面的帖子,但怎么搞也不行,可能那不是针对6.0.所有自己加以修改终于成功!!!以下为修改方法:
一、首先,在t_functions.php中添加一下两个函数
1.function Titlepic_all ($id, $classid, $userid, $username, $pwidth, $pheight)
2. {
3.global $empire,$class_r,$class_zr,$dbtbpre,$keys
4.$count = count ($id)
5.if (!$count)
6.{
7. printerror ('Noteditpic', 'history.go(-1)')
8.}
9.for ($i = 0($i <$count)++$i)
10.{
11. $r = $empire->fetch1 ('select * from phome_ecms_'.$class_r[$classid][tbname].' where id='.$id[$i].' and titlepic<>""')
12. if(!emptyempty($r[id])){
13. ImageResize("../../".$r[titlepic],$pwidth,$pheight,"../../".$r[titlepic])
14.
15. }
16.}
17.printerror ('TitlepicAllSuccess', $_SERVER['HTTP_REFERER'])
18. }
19.Function ImageResize($srcFile,$toW,$toH,$toFile="")
20.{
21. global $keys
22. if($toFile==""){ $toFile = substr($srcFile,0,-4)."small".substr($srcFile,-4)}
23. $info = ""
24. $data = GetImageSize($srcFile,$info)
25. switch ($data[2])
26. {
27. case 1:
28.if(!function_exists("imagecreatefromgif")){
29.echo "你的GD库不能使用GIF格式的图片,请使用Jpeg或PNG格式
30.
31.!<a href='<font>javascript:</font>go(-1)'>返回</a>"
32.exit()
33.}
34.$im = ImageCreateFromGIF($srcFile)
35.break
36. case 2:
37.if(!function_exists("imagecreatefromjpeg")){
38.Echo "你的GD库不能使用jpeg格式的图片,请使用其它格式的图
39.
40.片!<a href='<font>javascript:</font>go(-1)'>返回</a>"
41.Exit()
42.}
43.$im = ImageCreateFromJpeg($srcFile)
44.break
45. case 3:
46.$im = ImageCreateFromPNG($srcFile)
47.break
48.}
49.$srcW = ImageSX($im)
50.$srcH = ImageSY($im)
51.$keys= 0
52.if (($srcW>$toW) or ($srH>$toH)){
53.if(($srcW/$toW)>=($srcH/$toH)){
54.$temp_height=$toH
55.$temp_width=$srcW/($srcH/$toH)
56.$src_X=Abs(($toW-$temp_width)/2)
57.$src_Y=0
58.}
59.else{
60.$temp_width=$toW
61.$temp_height=$srcH/($srcW/$toW)
62.$src_X=0
63.$src_Y=Abs(($toH-$temp_height)/2)
64.}
65.$temp_img=ImageCreateTrueColor($temp_width,$temp_height)
66.imagecopyResampled($temp_img,$im,0,0,0,0,$temp_width,$temp_height,$srcW,$srcH)
67.$ni=ImageCreateTrueColor($toW,$toH)
68.imagecopyResampled($ni,$temp_img,0,0,$src_X,$src_Y,$toW,$toH,$toW,$toH)
69.
70.if(Function_exists('imagejpeg')) ImageJpeg($ni,$toFile)
71. else ImagePNG($ni,$toFile)
72. ImageDestroy($ni)
73.$keys= 1
74.}
75.ImageDestroy($im)
76.}
二、修改 e/admin/ListNews.php{还有个页面:e/admin/ListAllInfo.php},大约在最后几行“选中全部 </td></tr>”的后面添加以下代码:
<tr bgcolor="#FFFFFF">
<td height="25" colspan="8"><div align="right">
缩略图宽: <input name="pwidth" type="text" value="120" width="60">
缩略图高: <input name="pheight" type="text" value="120" width="60">
<input type="submit" name="Submit355" value="修改缩略图" onClick="document.listform.enews.value='Titlepic_all'">
</div></td></tr>
其中,图宽和图稿的默认值可按自己的情况设定,设定好后,以后 *** 作更方便。
三、在e/admin/ecmsinfo.php中添加如下代码:
//批量加标题图片
elseif($enews=="Titlepic_all")
{
$id=$_POST['id']
$classid=$_POST['classid']
$bclassid=$_POST['bclassid']
$pwidth=$_POST['pwidth']
$pheight=$_POST['pheight']
Titlepic_all($id,$classid,$logininid,$loginin,$pwidth,$pheight)
}
四、函数中用到“ printerror ('Noteditpic', 'history.go(-1)')”等 *** 作提示,这个提示可加在e/data/language/gb/pub/message.php;当然这一步不加也不影响 *** 作
在message.php 后面加:
'Noteditpic'=>'没有选择!',
'TitlepicAllSuccess'=>' *** 作成功!',
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)