php把内容中图片连接地址替换成自己的

$files ='<img src="http://img.phprm.com/img/bid_v2/bid_v2_content/p_bid.gif" alt="普通任务" /><img width="272px" height="60px" style="padding-top: 10px;" src="http://img.imgzhubajie.com/img/index_v3/20100611001.gif">';
// 图片地址转换一下   $p=preg_replace('//image//', 'http://qq.ip138.com/image/', $pg[1]);
 $reg = "/<img[^>]*src="(http://(.+)/(.+).(jpg|gif|bmp|bnp))"/isu";
$img=preg_match_all($reg,$files,$imgs);

阅读全文

sqlite 数据库连接类

 */
class db_class {
 var $conn=null;
 var $querynum = 0;

 /**
  * 数据库连接,返回数据库连接标识符
  *
  * @param string $ 数据库服务器主机
  * @param string $ 数据库服务器帐号
  * @param string $ 数据库服务器密码
  * @param string $ 数据库名
  * @param bool $ 是否保持持续连接,1为持续连接,0为非持续连接
  * @return link_identifier $dbuser, $dbpw, $dbname,
  */
 function connect($dbhost, $pconnect = 0) {
  $error = '';
  $func = $pconnect == 1 ? 'sqlite_popen' : 'sqlite_open';
  if (!$this -> conn = $func($dbhost, 0666, $error)) {
   $this -> halt($error);
  }

阅读全文

ip网段转换程序(把ip地址转换成相对就的整数)

mysql教程_connect('localhost','root','root');
mysql_select_db('dfd');

$array = file("ip.txt");
foreach( $array as $k  )
{
 list ($ip,$s) = explode('/',$k);
 $ipe = str_replace('.0','.255',$ip);
 $ipint = iptoint($ip);
 $ipinte = iptoint($ipe); 
 //echo iptoint($ip) .'-'.iptoint($ipe),'<br />';
 $s = array($ip,$ipe,$ipint,$ipinte);
 save($s);
}

阅读全文

php $HTTP_COOKIE_VARS 实例投票资料限制

if ($http_cookie_vars["vote"]) {
 echo "<script>alert('您已经投过票了,请不要重复投票');history.back();</script>";
 exit;
}
$vcount=$_post["vcount"];
$lld=$_post["jump"];
$tys=$_post["tys"];
if (!$vcount) {
 echo "<script>alert('您还没有选择任何投票项目');history.back();</script>";
 exit;
}
$db=@mysql_connect("localhost","root","root") or die("数据库教程连接失败");
mysql_select_db("vote",$db);
if ($vcount&&$lld) {
 if ($tys=="1") {
  $sql="update vote set vcount=vcount+1 where id=$vcount";
  $result=mysql_query($sql,$db);
  setcookie("vote","vote",time()+3600);
  echo "<script>alert('投票成功!');location.href='vote.php?id=$lld';</script>";
 }
 else {
  for ($i=0;$i<sizeof($vcount);$i++) {
   $sql1="update vote set vcount=vcount+1 where id=$vcount[$i]";
   $result1=mysql_query($sql1,$db);
  }
  setcookie("vote","vote",time()+3600);
  echo "<script>alert('投票成功!');location.href='vote.php?id=$lld';</script>";
 }
}

阅读全文

php zend 配置,数据库加,模板引擎设置

今天我们来讲一下关于php mvc模板的zend使用方法与配置实例,这是一款从zend加载 config文件到加载数据库 getinstance()方法用来获取前端控制器实例 加载smarty模板插件等简单的配置方法。
*/
 //指明引用文件的路径
    set_include_path('.' .
    path_separator . './libary/'.           //指定zend所在目录
    path_separator . './application/models/'. //指定model所在目录
    path_separator . './libary/smarty/'.   
    path_separator . get_include_path());

阅读全文

正则表达式匹配字母 汉字 空格

验证由26个英文字母组成的字符串:^[a-za-z]+$
验证由26个大写英文字母组成的字符串:^[a-z]+$
验证由26个小写英文字母组成的字符串:^[a-z]+$
验证由数字和26个英文字母组成的字符串:^[a-za-z0-9]+$
验证由数字、26个英文字母或者下划线组成的字符串:^w+$
验证用户密码:^[a-za-z]w{5,17}$ 正确格式为:以字母开头,长度在6-18之间,只能包含字符、数字和下划线。
验证是否含有 ^%&',;=?$" 等字符:[^%&',;=?$"]+
验证汉字:^[u4e00-u9fa5],{0,}$
验证email地址:^w+[-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$
验证interneturl:^http://([w-]+.)+[w-]+(/[w-./?%&=]*)?$ ;^[a-za-z]+://(w+(-w+)*)(.(w+(-w+)*))*(?s*)?$
验证电话号码:^((d{3,4})|d{3,4}-)?d{7,8}$:--正确格式为:xxxx-xxxxxxx,xxxx-xxxxxxxx,xxx-xxxxxxx,xxx-xxxxxxxx,xxxxxxx,xxxxxxxx。
验证身份证号(15位或18位数字):^d{15}|d{}18$
验证一年的12个月:^(0?[1-9]|1[0-2])$ 正确格式为:"01"-"09"和"1""12"
验证一个月的31天:^((0?[1-9])|((1|2)[0-9])|30|31)$    正确格式为:01、09和1、31。

阅读全文