Aug112013
php获取当前在线人数的方法
下面分享一种利用php实现简单的计算当前网站在线人数的方法,只是简单的通过计算访问者ip地址从而得出一个大致的结果,不能精确的计算当前在线人数,对精度要求过高的可参考本站文章:
php统计在线人数,精确的统计在线人数的办法
<?php
header('Content-type: text/html; charset=utf-8');
//author:www.phpernote.com
$online_log='count.txt';//保存在线人数数据的文件,
$time...阅读全文
抢沙发
Aug102013
Aug072013
批量处理文章内容
<?php
require_once (dirname ( __FILE__ ) . "./include/common.inc.php");
$dsql = "select aid,body from hk_addonarticle";
$db->Execute ( 'me', $dsql );
$Result=array();
while ( $arr = $db->GetArray () ) {
$body=preg_replace("/onclick=('|\")?(.*)\\1/sU",'',$arr ['body']);
$body=str_replace("style=\"cursor:pointer\" ","",$body);
$sql ="update ...阅读全文
Aug072013
php批量给添加图片alt属性
<?php
// require_once (dirname ( __FILE__ ) . "/include/common.inc.php");
// require_once ("/admin/inc/inc_archives_functions.php");
// $tables = array (
// '#@__addon7',
// '#@__addon8',
// '#@__addon9',
// '#@__addon10',
// '#@__addon11',
// '#@__addon12',
// '#@__addon13',
// '#@__addonarticle'
// );
// foreach ( $tables as $table ) {
// $...阅读全文
Aug072013
php批量处理图片大小
<?php
require_once (dirname ( __FILE__ ) . "/include/common.inc.php");
require_once ("/admin/inc/inc_archives_functions.php");
function myscandir($path) {
$mydir = dir ( $path );
while ( $file = $mydir->read () ) {
$p = $path . '/' . $file;
if (($file != ".") and ($file != "..")) {
$file_arr [] = $p;
}
if ((is_dir ( $p )) and ($fil...阅读全文
Aug072013
运行代码预览代码,代码另存为,复制代码功能的实现
一些以展示html特效的网站经常会在具体页面加一个运行代码这样的一个效果,即特效代码在textarea文本框内,下面有一个运行代码按钮,点击运行按钮,就直接运行了textarea内的代码。下面和大家分享一个这样的案例,其实这个挺简单的。
首先截图展示一下本示例的效果:
下面这段代码示例同时实现了预览代码,代码另存为和复制代码两个功能,注意这里的代码另存为,复制代码仅支持IE浏览器。...阅读全文
Aug052013
JS中如何判断null、undefined与NaN
javascript中如何判断一个变量是否是null,undefined还是NaN呢?下面我们看看具体的判断方法吧。
主要是通过 typeof 这个方法去判断,typeof 返回的是字符串,有六种可能的结果:”number”、”string”、”boolean”、”object”、”function”、”undefined”。
1.判断undefined:
var tmp=undefined;
if(typeof(tmp)=="...阅读全文
Aug042013
Aug042013
PHP加密解密的函数
分享一个PHP加密解密的函数,此函数实现了对部分变量值的加密的功能。
加密代码如下:
/*
*功能:对字符串进行加密处理
*参数一:需要加密的内容
*参数二:密钥
*/
function passport_encrypt($str,$key){ //加密函数
srand((double)microtime() * 1000000);
$encrypt_key=md5(rand(0, 32000));
$ctr=0;
$tmp='';
for($i=0;$i<strlen($str);$i++){
$ctr=$ctr==strl...阅读全文
Aug042013
php清除数组中的空值元素
对于一个一维的php数组,如何清除其中值为空的元素呢?直接的办法是foreach循环一下,一个个判断排除。不过这个方法还是略显复杂,下面分享一下今天看到的一个方法,很简洁也是头一次看到这种写法的,记录一下。
假设存在如下一个一维数组:
$array=array(0=>'phpernote',1=>'',2=>'com',3=>'');
清除该数组中的空元素可以这么写:
$array=array_filter($array,create_fun...阅读全文