以内容标题文字,渲染在随机的背景图片内,生成为一张全新的图片进行展示步骤一在根目录的api文件夹内建立一个pic php文件,放入下面的代码。
以内容标题文字,渲染在随机的背景图片内,生成为一张全新的图片进行展示
步骤一
在根目录的api文件夹内建立一个pic.php文件,放入下面的代码:
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
if(isset($_SERVER['HTTP_REFERER'])){
if(strpos($_SERVER['HTTP_REFERER'],APP_PATH)==0){
pic();
}
else{
echo "Welcome to Picture Generation library system";
}
}
elseif(checkrobot()){
pic();
}else{
echo "Welcome to Picture Generation library system";
}
//判断是不是蜘蛛
function checkrobot($useragent=''){
static $kw_spiders = array('bot', 'crawl', 'spider' ,'slurp', 'sohu-search', 'lycos', 'robozilla');
static $kw_browsers = array('msie', 'netscape', 'opera', 'konqueror', 'mozilla');
$useragent = strtolower(empty($useragent) ? $_SERVER['HTTP_USER_AGENT'] : $useragent);
if(strpos($useragent, 'http') === false && dstrpos($useragent, $kw_browsers)) return false;
if(dstrpos($useragent, $kw_spiders)) return true;
return false;
}
function dstrpos($string, $arr, $returnvalue = false) {
if(empty($string)) return false;
foreach((array)$arr as $v) {
if(strpos($string, $v) !== false) {
$return = $returnvalue ? $v : true;
return $return;
}
}
return false;
}
?>
内容页模板调用代码:
<img src="/pic/{$title}.jpg"/>