https://static.iklfy.com/attach/2012/06/18/1328872193_5353f7f6.png

PHP版网站缓存加快打开速度!

说明:
1,在服务器缓存了压缩过的文件,再次访问减少再压缩时间,降低CPU占用率。
2,通过设置客户端文件缓存时间,降低再次请求次数,可降低85%以上。
3,图片因为已经是压缩格式,只是设置客户端缓存时间,不做压缩处理。
使用方法:
1,服务器必须支持gzip,Rewrite功能。
2,在.htacess文件的“RewriteBase /”下面一行添加下面的代码,见图
RewriteRule (.*.css$|.*.js$|.*.jpg$|.*.gif$|.*.png$) gzip.php?$1 [L>
3,上传gzip.php到根目录
4,在根目录建cache文件夹,保证可读写。
https://static.iklfy.com/attach/2012/06/18/1328871899_58277269.png

WordPress如何判断当前用户是否为管理员

很多都有一些这样的需求,比如给管理员评论加上特殊的标记,比如给管理员输出特殊的内容等等。
我就碰到了这样一个需要判断当前用户是否为管理员的需求。
我在网上搜索了好多网页,貌似清一色都是说用is_admin这个函数,其实这个函数只是用来判断是否显示控制板或管理栏,也就是说是否处于后台控制面板中。这样这个函数对于前台模板这样的需求是没有用了。
后来经过再次查找,其实应该是current_user_can这个函数,这个函数用来判断当前用户是否具有某级别的权限。
看如下图表
https://static.iklfy.com/static/images/index/1.jpg

CSS透明度在各浏览器下的兼容

几款浏览器对透明度的支持方式各不相同,为了保证在IE, Firefox, Chrome, Safari等主流浏览器下都能正常显示透明度的效果,我们可以定义一个透明度的class,因为一写就要写3条,省的每次都复制来复制去了。
具体代码如下:
.transparent{
filter:alpha(opacity=60); /*支持 IE 浏览器*/
-moz-opacity:0.60; /*支持 FireFox 浏览器*/
pacity:0.60; /*支持 Chrome, Opera, Safari 等浏览器*/
}
https://static.iklfy.com/static/images/index/1.jpg

今天在新年的最后一天,我将离开BOB,转向WordPress

昨晚花了不少的时间对这个程序转换到WordPress程序,刚好今天是除夕夜!
其实并不是BOBLOG不好,而且更新太慢,有点跟不上社会的脚步,
之前我并不太看好WP,但是在辗转了N年之后,没想到又会重新回到WordPress的大家庭中来!
唉,发一段代码,也许大家有能用到,此代码的作用是将boblog2.1.1版本中的UBB代码全部替换为WordPress3.3.1中的标签!!
其他的部分我就不发了,相信用到的人也不会太多!这里发布一下我新站的地址,
我的新站将会改用 www.iklfy.com (备案中,暂时不启用) 而本站域名将不变!
www.iklfy.com BOBLOG博客
www.iklfy.com WordPress博客
欢迎大家前往我的新博客,目前数据已经完整迁移过去了!
https://static.iklfy.com/static/images/index/15.jpg

上传图片显示

<input type="file" name="file1" id="file1" size="40" onchange="changeSrc(this)"/>
<img src="about:blank" id="fileChecker" alt="test" height="18"/>
<script type="text/javascript">
var oFileChecker = document.getElementById("fileChecker");
function changeSrc(filePicker)
{
oFileChecker.src = filePicker.value;//读图片
}
</script>
https://static.iklfy.com/static/images/index/23.jpg

直接用$获取值而不$_GET

<?
function my_addslashes($string, $force = 0) {
!defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
if(!MAGIC_QUOTES_GPC || $force) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = my_addslashes($val, $force);
}
} else {
$string = addslashes($string);
}
}
return $string;
}
foreach(array('_COOKIE', '_POST', '_GET') as $_request) {
foreach($$_request as $_key => $_value) {
$_key{0} != '_' && $$_key = my_addslashes($_value);
}
}
echo $urls;
?>
https://static.iklfy.com/static/images/index/11.jpg

调用腾讯的API接口获取你所在当前城市名称

<?php   
/*
调用腾讯的API接口
返回结果 var IPData = new Array("114.238.55.147","","江苏省","淮安市");
0 为 IP地址
1 为 null
2 为 省份
3 为 城市
*/
function get_ip_place(){
$ip=file_get_contents("http://fw.qq.com/ipaddress");
$ip=str_replace('"',' ',$ip);
$ip2=explode("(",$ip);
$a=substr($ip2[1],0,-2);
$b=explode(",",$a);
return $b;
}
$ip=get_ip_place();
print_r($ip);
print_r($ip[0]); // 这个就是你当前外网IP地址
print_r($ip[2]); // 这个就是你所在的省份
print_r($ip[3]); //这个就是你所在的城市了
?>
https://static.iklfy.com/attach/2012/06/18/1316613632_7522dd13.png

PHPWind 8.5和8.7版的伪静态.htaccess规则

日前PHPWind发布了8.7的新版本,站长们升级后有些伪静态规则不能使用。本文介绍修改Apache的.htaccess来实现伪静态的效果,效果如下:

一、修改根目录下.htaccess规则,代码如下:
RewriteEngine on
RewriteRule f(\d+)_(.*)_(.*)$ /thread.php?fid=$1&page=$2&type=$3 [L]
RewriteRule f(\d+)_(.*)$ /thread.php?fid=$1&page=$2 [L]
RewriteRule f(\d+)$ /thread.php?fid=$1&page=$2 [L]
RewriteRule (\d+)_(.*)_(.*)_(.*).html$ /read.php?tid=$1&page=$2&fpage=$3&uid=$4 [L]
RewriteRule (\d+)_(.*)_(.*).html$ /read.php?tid=$1&page=$2&fpage=$3 [L]
RewriteRule (\d+)_(.*).html$ /read.php?tid=$1&page=$2 [L]
RewriteRule (\d+).html /read.php?tid=$1 [L]
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2 [L]
Re
https://static.iklfy.com/static/images/index/3.jpg

PHP缩略图类

<?php
/**
* @author www.iklfy.com
* @copyright 2011
* @filename thumb.class.php
*/
$arrFile = array('p1.jpg', 'p2.gif', 'p4.txt', 'p3.png');
/**
* 得到等比例缩放的长宽
*/
function getNewSize($maxWidth, $maxHeight, $srcWidth, $srcHeight)
{
if ($srcWidth < $srcHeight)
{
$maxWidth = ($maxHeight / $srcHeight) * $srcWidth;
}
else
{
$maxHeight = ($maxWidth / $srcWidth) * $srcHeight;
}
return array('width' => $maxWidth, 'height' => $maxHeight);
}
https://static.iklfy.com/static/images/index/14.jpg

PHP下载类代码

<?php
/**
* @author www.iklfy.com
* @copyright 2011
* @filename download.class.php
*/
/*
//文件下载类,以下调用示例代码
$download = new download('php,exe,html', false);
if (!$download->downloadfile($filename))
{
echo $download->geterrormsg();
}
*/
class download
{
var $debug = true;
var $errormsg = '';
var $Filter = array();
var $filename = '';
var $mineType = 'text/plain';
var $xlq_filetype = array();
https://static.iklfy.com/static/images/index/13.jpg

javaScript document

对象属性
document.title //设置文档标题等价于HTML的title标签
document.bgColor //设置页面背景色
document.fgColor //设置前景色(文本颜色)
document.linkColor //未点击过的链接颜色
document.alinkColor //激活链接(焦点在此链接上)的颜色
document.vlinkColor //已点击过的链接颜色
document.URL //设置URL属性从而在同一窗口打开另一网页
document.fileCreatedDate //文件建立日期,只读属性
document.fileModifiedDate //文件修改日期,只读属性
document.fileSize //文件大小,只读属性
document.cookie //设置和读出cookie
document.charset //设置字符集 简体中文:gb2312

———————————————————————
常用对象方法
document.write() //动态向页面写入内容
document.createElement(Tag) //创建一个html标签对象
document.getElementById(ID) //获得指定ID值的对象
document.getElementsByName(Name) //获得指定Name值的对象
document.body.appendChild(oTag)

———————————————————————
body-主体子对象
https://static.iklfy.com/attach/2012/06/18/1301244421_11987880.png

PHP判断系统类型,语言,浏览器类型,当前IP代码(2011.05.20)

晚上帮QQ上一个朋友改了个引导页面,需要用到这些,一时没有准确的,于是写这个类文件;
怎么用就看演示文件吧.
功能呢,就是判断访问者的IP地址,系统版本,浏览器类型,系统语言这些....
然后就是是否记录这些信息到日志文件,默认为不记录(建议只在需要的时候开启).
日志文件为自动创建.
https://static.iklfy.com/static/images/index/11.jpg

jquery替换HTML页面中的值

<script type="text/javascript">
//检索A标记,符合的条件的改自己的值
$().ready(function(){
$('a').each(function(){
if($(this).text()=='Yxly330'){
$(this).text('快乐飞扬论坛');
}
})
})
//替换唯一标签的值
document.title = "快乐飞扬论坛";
</script>
https://static.iklfy.com/static/images/index/19.jpg

PHP获取当前url路径的函数及服务器变量

代码如下:
<?php
echo $_SERVER['DOCUMENT_ROOT']."<br>"; //获得服务器文档根变量
echo $_SERVER['PHP_SELF']."<br>"; //获得执行该代码的文件服务器绝对路径的变量
echo __FILE__."<br>"; //获得文件的文件系统绝对路径的变量
echo dirname(__FILE__); //获得文件所在的文件夹路径的函数
?>

1,$_SERVER["QUERY_STRING">
说明:查询(query)的字符串
2,$_SERVER["REQUEST_URI">
说明:访问此页面所需的URI
3,$_SERVER["SCRIPT_NAME">
说明:包含当前脚本的路径
4,$_SERVER["PHP_SELF">
说明:当前正在执行脚本的文件名
https://static.iklfy.com/static/images/index/7.jpg

jquery给博客增加“页面加载中”特效!

第一步:加载jquery.min.js
  <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>

第二步:在</head>前添加一段JS代码
  <script type="text/javascript">
$(function(){
$('#loading-one').empty().append('页面加载完毕.').parent().fadeOut('slow');
});
</script>

第三步:在<body>后添加显示效果样式
  <div id="loading" onclick="javascript:turnoff('loading')">
<p id="loading-one" onclick="javascript:turnoff('loading')">页面载入中,请稍后...</p>
</div>