【PHP】密码必须是字母+数字+特殊符的正则

Continue Read..
$passwd = 'Aa12345#';
if(!preg_match("/([a-z])+/",$passwd)){
echo '无小写字母';
}
if(!preg_match("/([A-Z])+/",$passwd)){
echo '无大写字母';
}
if(!preg_match("/([0-9])+/",$passwd)){
echo '无数字';
}
if(!preg_match("/([`|!|#|$|%|^|&|*|(|)|,|.|;|'])+/",$passwd)){
echo '无特殊符';
}

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

【PHP+MYSQL】直接在页面写sql语句操作数据库

Continue Read..

公司换了阿里的服务器。。。。数据库phpmysql一直打不开(太卡了)。。。没得办法  。。就写了个php文件来处理数据库

直接上代码(代码基于dede写的,,要改其他框架的自己看)

 

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

【ThinkPhp】分页

Continue Read..

把TP3.0以上版本的分页类修改了   

使用方法直接贴代码算了

首先在common.php  加2个公共函数  一个是分页的   一个是类别url生成的

/*

 *分页通用函数 

 *参数1 type 类型  0查总数   1查数据  2查单条

 *参数2 table 查询表  

 *参数3 selectStr查询的字段

 *参数4 whereArr 查询条件

 *参数5 page第几页 ($page-1)*$pagenum   

 *参数6 pagenum  分页数

 *参数7 joinArr join条件

 *参数8 orderArr order条件

 */

 

function get_fenye($type,$table,$selectStr='',$whereArr='',$page=1,$pagenum=20,$joinArr=array(),$orderArr = ""){

$dao = D($table);

if(!empty($selectStr)){

$dao->field($selectStr);

}

if(!empty($whereArr)){

$dao->where($whereArr);

}

if(!empty($orderArr)){

$dao->order($orderArr);

}

if(!empty($joinArr)){

$dao->join($joinArr);

}

if($type==0){

$data = $dao->count();

}elseif($type==1){

$data = $dao->limit(($page-1)*$pagenum . ',' . $pagenum)->select();

}elseif($type==2){

$data = $dao->find();

// echo $dao->getLastSql();

}

return $data;

}

//返回url参数字符串  /user/flea  $str=array('a'=1,'b'=>'')    $arr替换值

function get_urlc($url='',$str=array(),$arr=array()){

$tempstr = '';

if(!empty($arr)){

foreach($arr as $k=>$v){

$str[$k]=$v;

}

}

foreach($str as $key=>$val){

if(!empty($val)){

if(empty($tempstr)){

$tempstr .= $key . '=' . $val;

}else{

$tempstr .= '&' . $key . '=' . $val;

}

}

}

$tempstr = empty($tempstr) ? $url : $url . '?' . $tempstr ;

return $tempstr ;

}

 

 

类别url生成的方法如下

<div class="casechose" style="padding-top:0px">

          <div class="caption left">功能:</div>

          <div class="caption_txt left"><span <?php if(empty($data['_gongneng'])){echo 'class="green"';}  ?> ><a  href="<?php  echo get_urlc($data['_url'],$data['searchstr'],array('gn'=>0)); ?>" >全部</a></span>

           <foreach name="data.gongneng" item="v">

  <span <?php if($data['_gongneng']==$v['id']){echo 'class="green"';}  ?> ><a  href="<?php  echo get_urlc($data['_url'],$data['searchstr'],array('gn'=>$v['id'])); ?>">{$v.vdata}</a></span>

  </foreach>

         </div>

          <div class="clearall"></div>

        </div>

 

 

然后就是写分页的action

 function index(){

        //第几页

        $data['_page'] = is_numeric($_GET["page"]) && !empty($_GET["page"]) ? intval($_GET["page"]) : 1; 

        //分页

        $data['_url'] = '/Company/index/'  ;

        $whereArr = "siteid = ".$_SESSION['siteid'];

        

        import("@.ORG.Util.PageCuzn"); //导入分页类

        $data['searchstr'] = array(

//            'pid' => $data['pid']    //这里主要是跟参数的...

        );

        

        

        $data['count'] = get_fenye(0,'company',"",$whereArr,$data['_page'],C('pagenum'),array()); //取得满足条件的记录数

        $data['data'] = get_fenye(1,'company',"",$whereArr,$data['_page'],C('pagenum'),array()," lasttime desc,  companyid desc"); //取得满足条件的记录数

        

        $p = new Page($data['count'],$data['_page'],C('pagenum'),$data['_url'],$data['searchstr']); //总记录数,当前页码,每页数,URL,URL参数

        $data['page'] = $p->getNavigation(); //分页显示

        

        $this->assign('data', $data);  

        $this->display();

    }

 

 

 

最后是分页css

/* 分页 */

.page{margin:0 auto; text-align:center; height:28px;overflow:hidden;}

.page span{display:inline-block;height:26px; line-height:26px; padding:0 10px; margin-right:5px; zoom:1;}

.page span.on{border:1px solid #dcdcdc; background:#ccc;}

.page b{padding:0 10px 0 5px;font-size:14px;}

.page a { display:inline-block;height:26px; line-height:26px;padding:0 10px;border:1px solid #dcdcdc; margin-right:5px; zoom:1; font-size:14px;}

.page a:hover{background:#005EAC;color:#fff;text-decoration:none;}

点击查看原图

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

【CI】易宝php支付功能代码

Continue Read..
PHP代码
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Yb extends CI_Controller {
//	public function __construct(){
//		parent::__construct();
//		$this->load->model('mfun');
//	}
	
	function index(){
		$this->load->view('ybindex');
	}
	
	function queren(){
		$data['p0_Cmd'] = "Buy";
		$data['p1_MerId'] = "10001126856";
		$data['p2_Order'] = $_POST['p2_Order'];
		$data['p3_Amt'] = $_POST['p3_Amt'];
		$data['p4_Cur'] = "CNY";
		$data['p5_Pid'] = "";
		$data['p6_Pcat'] = "";
		$data['p7_Pdesc'] = "";
		$data['p8_Url'] = "http://xxx.com/yb/chenggong";
		$data['p9_SAF'] = "0";
		$data['pa_MP'] = "";
		$data['pd_FrpId'] = $_POST['pd_FrpId'];
		$data['pr_NeedResponse'] = "1";
		
		
		
		$str = "";
		$str .= $data['p0_Cmd'];
		$str .= $data['p1_MerId'];
		$str .= $data['p2_Order'];
		$str .= $data['p3_Amt'];
		$str .= $data['p4_Cur'];
		$str .= $data['p5_Pid'];
		$str .= $data['p6_Pcat'];
		$str .= $data['p7_Pdesc'];
		$str .= $data['p8_Url'];
		$str .= $data['p9_SAF'];
		$str .= $data['pa_MP'];
		$str .= $data['pd_FrpId'];
		$str .= $data['pr_NeedResponse'];
		
		$key = "69cl522AV6q613Ii4W6u8K6XuW8vM1N6bFgyv769220IuYe9u37N4y7rI4Pl";
		
		$data['hmac'] = $this->HmacMd5($str,$key);
		$this->load->view('ybqueren',$data);
	}
	
	function chenggong(){
		$data['p1_MerId'] = "10001126856";
		$data['r0_Cmd'] = $_REQUEST['r0_Cmd'];
		$data['r1_Code'] = $_REQUEST['r1_Code'];
		$data['r2_TrxId'] = $_REQUEST['r2_TrxId'];
		$data['r3_Amt'] = $_REQUEST['r3_Amt'];
		$data['r4_Cur'] = $_REQUEST['r4_Cur'];
		$data['r5_Pid'] = $_REQUEST['r5_Pid'];
		$data['r6_Order'] = $_REQUEST['r6_Order'];
		$data['r7_Uid'] = $_REQUEST['r7_Uid'];
		$data['r8_MP'] = $_REQUEST['r8_MP'];
		$data['r9_BType'] = $_REQUEST['r9_BType'];
		$data['hmac'] = $_REQUEST['hmac'];
		
		//不参与hmac
		$data['rb_BankId'] = $_REQUEST['rb_BankId'];
		$data['rp_PayDate'] = $_REQUEST['rp_PayDate'];
		$data['rq_CardNo'] = $_REQUEST['rq_CardNo'];
		$data['ru_Trxtime'] = $_REQUEST['ru_Trxtime'];
		
		$str="";
		$str .= $data['p1_MerId'];
		$str .= $data['r0_Cmd'];
		$str .= $data['r1_Code'];
		$str .= $data['r2_TrxId'];
		$str .= $data['r3_Amt'];
		$str .= $data['r4_Cur'];
		$str .= $data['r5_Pid'];
		$str .= $data['r6_Order'];
		$str .= $data['r7_Uid'];
		$str .= $data['r8_MP'];
		$str .= $data['r9_BType'];
		$key = "69cl522AV6q613Ii4W6u8K6XuW8vM1N6bFgyv769220IuYe9u37N4y7rI4Pl";
		$hmac = $this->HmacMd5($str,$key);
		if($data['hmac'] == $hmac){
			if($data['r1_Code'] == 1){
				if($data['r9_BType'] == 1){
					echo "交易成功!"."
";
					echo "点单编号:".$data['r6_Order']."
";
					echo "所付金额:".$data['r3_Amt']."
";
					echo "易宝支付订单号:".$data['r2_TrxId']."
";
					echo "浏览器重定向"."
";
				}elseif($data['r9_BType'] == 2){
					echo "success";
					echo "交易成功!"."
";
					echo "点单编号:".$data['r6_Order']."
";
					echo "所付金额:".$data['r3_Amt']."
";
					echo "易宝支付订单号:".$data['r2_TrxId']."
";
					echo "服务器点对点通讯"."
";
				}
				
			}else{
				echo "交易失败";
			}
		}else{
			echo "签名被篡改";
		}
		
		
		
	}
	
	function HmacMd5($data,$key){
		// RFC 2104 HMAC implementation for php.
		// Creates an md5 HMAC.
		// Eliminates the need to install mhash to compute a HMAC
		// Hacked by Lance Rushing(NOTE: Hacked means written)
		
		//需要配置环境支持iconv,否则中文参数不能正常处理
		$key = iconv("GB2312","UTF-8",$key);
		$data = iconv("GB2312","UTF-8",$data);
		
		$b = 64; // byte length for md5
		if (strlen($key) > $b) {
		$key = pack("H*",md5($key));
		}
		$key = str_pad($key, $b, chr(0x00));
		$ipad = str_pad('', $b, chr(0x36));
		$opad = str_pad('', $b, chr(0x5c));
		$k_ipad = $key ^ $ipad ;
		$k_opad = $key ^ $opad;
		
		return md5($k_opad . pack("H*",md5($k_ipad . $data)));
	}
}

 

 

 

提交代码

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>易宝测试</title>

</head>

<body>

<form action="/yb/queren/" method="post" name="form" id="form">

<table>

<tr>

<td colspan="4">

订单编号:<input type="text" name="p2_Order" />

支付金额:<input type="text" name="p3_Amt" />

</td>

</tr>

<tr><td colspan="4">请选择网站支付银行</td></tr>

<tr>

<td>

<input type="radio" name="pd_FrpId" value="ICBC-NET" />工商银行

<input type="radio" name="pd_FrpId" value="CMBCHINA-NET" />招商银行

<input type="radio" name="pd_FrpId" value="ABC-NET" />农业银行

<input type="radio" name="pd_FrpId" value="CCB-NET" />建设银行

</td>

</tr>

<tr><td colspan="4"><input type="submit" value="确认" /></td></tr>

</table>

</form>

</body>

</html>

 

 

确认代码

 

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>易宝测试</title>

</head>

<body>

<form action="https://www.yeepay.com/app-merchant-proxy/node" method="post" name="form" id="form">

<table>

<tr>

<td colspan="4">

你的订单编号是:<?php echo $p2_Order;  ?>

支付金额是:<?php echo $p3_Amt;  ?>

</td>

</tr>

<tr>

<td>

<input type="hidden" name="p0_Cmd" value="<?php echo $p0_Cmd;?>" />

<input type="hidden" name="p1_MerId" value="<?php echo $p1_MerId;?>" />

<input type="hidden" name="p2_Order" value="<?php echo $p2_Order;?>" />

<input type="hidden" name="p3_Amt" value="<?php echo $p3_Amt;?>" />

<input type="hidden" name="p4_Cur" value="<?php echo $p4_Cur;?>" />

<input type="hidden" name="p5_Pid" value="<?php echo $p5_Pid;?>" />

<input type="hidden" name="p6_Pcat" value="<?php echo $p6_Pcat;?>" />

<input type="hidden" name="p7_Pdesc" value="<?php echo $p7_Pdesc;?>" />

<input type="hidden" name="p8_Url" value="<?php echo $p8_Url;?>" />

<input type="hidden" name="p9_SAF" value="<?php echo $p9_SAF;?>" />

<input type="hidden" name="pa_MP" value="<?php echo $pa_MP;?>" />

<input type="hidden" name="pd_FrpId" value="<?php echo $pd_FrpId;?>" />

<input type="hidden" name="pr_NeedResponse" value="<?php echo $pr_NeedResponse;?>" />

<input type="hidden" name="hmac" value="<?php echo $hmac;?>" />

</td>

</tr>

<tr><td colspan="4"><input type="submit" value="确认" /></td></tr>

</table>

</form>

</body>

</html>


声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权