>>> 帝国网站管理系统5.1开源测试版下载
帝国CMS进入开源时代
 帝国论坛帝国网站管理系统交流区模板/标签/插件共享交流现提供生成新闻头条中图片标题的部分源代码,请高手整合!! 【本版专题贴子】  
主题:现提供生成新闻头条中图片标题的部分源代码,请高手整合!! [加入收藏夹]   

hui_1980
用户头衔:书生

精华贴   :0
发贴数   :35
经验值   :203
注册时间:2007-10-21
信息 搜索 好友 发送悄悄话 开源第一波:帝国备份王2008开源版发布】   [第 1 楼]
现提供生成新闻头条中图片标题的部分源代码,请高手整合!!
首先声明,版权不归我所有,只是个借鉴

<?php
/*******************************************\
* 版权所有 杜京 2007.06.28 中国新闻社(北京) *
* 网名:官不聊生 QQ:30300969 请勿用于商业! *
\*******************************************/
$text = $_GET['title'];
$border = $_GET['border'];
$font = $_GET['fonts'];
if(empty($_GET['url'])){
        $url = 'http://www.gxhangpai.cn';
}else{
        $url = $_GET['url'];
}
$type = $_GET['type'];
$fontsize = '25';
$text = iconv("GB2312","UTF-8",$text);
$imagedir = date('Y-m-d');
if(!file_exists($imagedir)){
         mkdir($imagedir,0777);
           //chmod($imagedir,0777);
           //return true;
}
$imagename = explode(" ",$_GET['pubdate']);
$imagename0 = $imagename['0'];
$imagename0 = explode("-",$imagename0);
$imagename1 = $imagename['1'];
$imagename1 = explode(":",$imagename1);
$imagename = $imagename0[0].$imagename0[1].$imagename0[2].$imagename1[0].$imagename1[1].$imagename1[2];

$box = imagettfbbox ($fontsize, 0, $font, $text);
$textW = $box[2] - $box[0];
$textH= $box[3]-$box[5];
$paddingx = 15;
$paddingy = 15;
$width = $textW+$paddingx;
$height= $textH+$paddingy;

$textx = $paddingx/2;
$texty = $height - $paddingy;

$shadoffx = 1;
$shadoffy = 1;

$img = imagecreatetruecolor($width,$height);
$white = imagecolorallocate($img,255,255,255);
$black = imagecolorallocate($img,0,0,0);
$lightgrey = imagecolorallocate($img,200,200,200);
$grey = imagecolorallocate($img,200,200,200);
$bgcol = imagecolorallocate($img,227,235,255);
$rgb = $_GET['rgb'];
$rgb = explode(",",$rgb);
$fgcol = imagecolorallocate($img,$rgb['0'],$rgb['1'],$rgb['2']);
imagefill($img,0,0,$bgcol);

imagettftext($img, $fontsize, 0, $textx+$shadoffx, $texty+$shadoffy, $grey, $font, $text);

imagettftext($img, $fontsize, 0, $textx, $texty, $fgcol, $font, $text);

if ($border == "flat")
  {
   imageline ($img,0,0,$width,0,$white);imageline ($img,0,0,0,$height,$white);
   imageline ($img,1,1,$width,1,$grey);imageline ($img,1,1,1,$height-1,$grey);
   imageline ($img,0,$height-1,$width-1,$height-1,$white);imageline ($img,$width-1,$height-1,$width-1,0,$white);
   imageline ($img,2,$height-2,$width-2,$height-2,$grey);imageline ($img,$width-2,$height-2,$width-2,2,$grey);
  }
if ($border == "out")
  {
   imageline ($img,0,0,$width,0,$white);imageline ($img,0,0,0,$height,$white);
   imageline ($img,1,1,$width,1,$lightgrey);imageline ($img,1,1,1,$height-1,$lightgrey);
   imageline ($img,0,$height-1,$width-1,$height-1,$black);imageline ($img,$width-1,$height-1,$width-1,0,$black);
   imageline ($img,2,$height-2,$width-2,$height-2,$grey);imageline ($img,$width-2,$height-2,$width-2,2,$grey);

  }
if ($border == "in")
  {
   imageline ($img,0,0,$width,0,$black);imageline ($img,0,0,0,$height,$black);
   imageline ($img,1,1,$width,1,$grey);imageline ($img,1,1,1,$height-1,$grey);
   imageline ($img,0,$height-1,$width-1,$height-1,$white);imageline ($img,$width-1,$height-1,$width-1,0,$white);
   imageline ($img,2,$height-2,$width-2,$height-2,$lightgrey);imageline ($img,$width-2,$height-2,$width-2,2,$lightgrey);
  }

//Header ("Content-type: image/png");
//imagepng($img);

imagepng($img,$imagedir.'/'.$imagename.'.png');
imagedestroy($img);
ob_start();
$text = iconv("UTF-8","GB2312",$text);
$content ="<a href='".$url."' target='_blank'><img src='/dede/".$imagedir."/".$imagename.".png' border='0' alt='".$text."'></a>";
echo $content;
$page = ob_get_contents();
ob_end_clean();
$cwd = getcwd();
$file = "$cwd" .'/'. $type."_topnews.inc";
@chmod($file,0777);
$fw = fopen($file, "w");
fputs($fw,$page, strlen($page));
fclose($fw);
echo "<script>javascript:window.location.href='maketopnews_homepage.php?type=".$type."'</script>";
die();
?>

以下是预览代码

<?php
/*******************************************\
* 版权所有 杜京 2007.06.28 中国新闻社(北京) *
* 网名:官不聊生 QQ:30300969 请勿用于商业! *
\*******************************************/
$text = $_GET['title'];
$border = $_GET['border'];
$font = $_GET['fonts'];
$fontsize = '25';
$text = iconv("GB2312","UTF-8",$text);

$box = imagettfbbox ($fontsize, 0, $font, $text);
$textW = $box[2] - $box[0];
$textH= $box[3]-$box[5];
$paddingx = 15;
$paddingy = 15;
$width = $textW+$paddingx;
$height= $textH+$paddingy;

$textx = $paddingx/2;
$texty = $height - $paddingy;

$shadoffx = 1;
$shadoffy = 1;

$img = imagecreatetruecolor($width,$height);
$white = imagecolorallocate($img,255,255,255);
$black = imagecolorallocate($img,0,0,0);
$lightgrey = imagecolorallocate($img,200,200,200);
$grey = imagecolorallocate($img,200,200,200);
$bgcol = imagecolorallocate($img,227,235,255);
$rgb = $_GET['rgb'];
$rgb = explode(",",$rgb);
$fgcol = imagecolorallocate($img,$rgb['0'],$rgb['1'],$rgb['2']);
imagefill($img,0,0,$bgcol);

imagettftext($img, $fontsize, 0, $textx+$shadoffx, $texty+$shadoffy, $grey, $font, $text);

imagettftext($img, $fontsize, 0, $textx, $texty, $fgcol, $font, $text);

if ($border == "flat")
  {
   imageline ($img,0,0,$width,0,$white);imageline ($img,0,0,0,$height,$white);
   imageline ($img,1,1,$width,1,$grey);imageline ($img,1,1,1,$height-1,$grey);
   imageline ($img,0,$height-1,$width-1,$height-1,$white);imageline ($img,$width-1,$height-1,$width-1,0,$white);
   imageline ($img,2,$height-2,$width-2,$height-2,$grey);imageline ($img,$width-2,$height-2,$width-2,2,$grey);
  }
if ($border == "out")
  {
   imageline ($img,0,0,$width,0,$white);imageline ($img,0,0,0,$height,$white);
   imageline ($img,1,1,$width,1,$lightgrey);imageline ($img,1,1,1,$height-1,$lightgrey);
   imageline ($img,0,$height-1,$width-1,$height-1,$black);imageline ($img,$width-1,$height-1,$width-1,0,$black);
   imageline ($img,2,$height-2,$width-2,$height-2,$grey);imageline ($img,$width-2,$height-2,$width-2,2,$grey);

  }
if ($border == "in")
  {
   imageline ($img,0,0,$width,0,$black);imageline ($img,0,0,0,$height,$black);
   imageline ($img,1,1,$width,1,$grey);imageline ($img,1,1,1,$height-1,$grey);
   imageline ($img,0,$height-1,$width-1,$height-1,$white);imageline ($img,$width-1,$height-1,$width-1,0,$white);
   imageline ($img,2,$height-2,$width-2,$height-2,$lightgrey);imageline ($img,$width-2,$height-2,$width-2,2,$lightgrey);
  }

header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
?>


由于水平有限不知道该如何整合,请高手赐教




2008-03-09 08:58:58 已设置保密 顶部 回复 引用 报告 编辑 删除

sooden
用户头衔:版主

精华贴   :9
发贴数   :1526
经验值   :3631
注册时间:2006-01-02
信息 搜索 好友 发送悄悄话 《帝国网站管理系统》零基础实例入门教程】   [第 2 楼]


头条标题为什么非要用图片呢?




流氓不可怕,就怕流氓有文化。

不在线可QQ 8686588 留言,上线必回。

QQ机器人测试:有兴趣的+QQ 993612958
2008-03-10 09:05:37 已设置保密 顶部 回复 引用 报告 编辑 删除

hui_1980
用户头衔:书生

精华贴   :0
发贴数   :35
经验值   :203
注册时间:2007-10-21
信息 搜索 好友 发送悄悄话 开源第一波:帝国备份王2008开源版发布】   [第 3 楼]

不为啥,就是喜欢
我想多一个功能不多,真的很难吗?!
刚开始接触帝国,感觉确实不错,相比phpcms更具有扩展性




2008-03-10 09:30:29 已设置保密 顶部 回复 引用 报告 编辑 删除

sooden
用户头衔:版主

精华贴   :9
发贴数   :1526
经验值   :3631
注册时间:2006-01-02
信息 搜索 好友 发送悄悄话 《帝国网站管理系统》零基础实例入门教程】   [第 4 楼]

不难,做成一个插件就可以了,动态调用




流氓不可怕,就怕流氓有文化。

不在线可QQ 8686588 留言,上线必回。

QQ机器人测试:有兴趣的+QQ 993612958
2008-03-10 09:54:04 已设置保密 顶部 回复 引用 报告 编辑 删除

诚信家维
用户头衔:秀才

精华贴   :0
发贴数   :81
经验值   :501
注册时间:2006-12-28
信息 搜索 好友 发送悄悄话 开源第一波:帝国备份王2008开源版发布】   [第 5 楼]

的确很需要啊



我的小站http://www.bjjdw.net
2008-06-12 06:15:13 已设置保密 顶部 回复 引用 报告 编辑 删除

快速回复
内容

表情
使用EBB代码 使用smile代码 显示签名 自动分析url 自动分析img
     【进入高级模式】   (按 Ctrl+Enter 直接提交)
    顶部  加入收藏夹
关于帝国 | 广告服务 | 联系我们 | 法律声明 | 隐私条款 | 许可协议
Powered by: EBB Version 2.2.1