var n=document.getElementById("aa").outerHTML;
aa是div的id
声明:此文系舞林cuzn(www.wulinlw.org)原创稿件,转载请保留版权
环境是lnmp
项目换了ci,整合ucenter的同步登录的时候出现问题,在uc后台发现出现通信不成功的情况。
在本地测试都是正常的,但是在显示就不行了,检查通信吧,uc检查通信的时候是去请求项目的/api/uc.php文件,
如:http://wulin.aliapp.com/api/uc.php
我们直接访问这个文件。发现路径url没变,页面内容却是主页的,也就是没有访问到这个文件,通信当然就不成功了。
然后测试发现,所有二级页面下的php文件都是这样,仔细想想,应该是nginx的配置出了问题
ci的配置uri模式是“AUTO”,$config['uri_protocol'] = 'AUTO';
下面给出正确的配置
server
{
listen 80;
server_name aaa.wulin.cn;
root /www/wulin;
index index.html index.htm index.php index.shtml;
//这里是隐藏index.php的
location / {
if ($request_filename !~* /(upload|api|tc|js|javascript|css|images|fckeditor|userfiles|crontab|
robots\.txt|index\.php)/) {
rewrite ^/(.*)$ /index.php?$1 last;
break;
}
}
//主要是下面这段
//发现url里面有uc.php的时候就指向那个文件,其他文件要访问同理
location ~ uc\.php{
fastcgi_param SCRIPT_FILENAME /www/wulin/api/uc.php;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
#access_log /var/log/192.168.10.60-access.log;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME /www/wulin/index.php;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
location ~ /\.ht
{
deny all;
}
}
这下就好了,重新载入配置即可。
/etc/init.d/nginx reload
在访问http://wulin.aliapp.com/api/uc.php,出现:Authracation has expiried
这就对了,在到uc后台查看,发现通信成功了,测试同步登陆退出也正常了。
ci貌似在nginx下的配置确实有点麻烦。。。
声明:此文系舞林cuzn(www.wulinlw.org)原创稿件,转载请保留版权
项目最近很忙,没有时间写统计功能,暂时手工查询
ucenter里面uc_members表里面的regdate字段是int(11),存储的是unix时间戳,如1338912020
当我们要查询某就一天的注册量的时候,就需要根据这个字段来查。
下面介绍是2个mysql时间处理函数 UNIX_TIMESTAMP 和 FROM_UNIXTIME
SELECT *
FROM `uc_members`
WHERE regdate > UNIX_TIMESTAMP( '2012-06-06' )
这样就可以查找2012-06-06之后注册的用户了,
UNIX_TIMESTAMP当不给参数的时候,产生一个当前时间的unix时间戳,给定日期则将给定时间转换成unix时间戳
另一个函数FROM_UNIXTIME正好相反,将unix时间戳转换成字符串的时间,如2012-06-06 00:00:20
FROM_UNIXTIME( 1338912020 , '%Y-%m-%d' )
即可将时间转换成字符串,直观的显示出来
他们的参数和php的date函数的参数类似。
声明:此文系舞林cuzn(www.wulinlw.org)原创稿件,转载请保留版权
首先将system/libraries/Pagination.php的文件复制一份到application/libraries 下面..改名叫Pagination_cuzn.php
这个文件我传附件..反正大改了..把所有生成url的地方全部改了....你们自己对照的看把
然后就是写一个url的处理函数...用来在html里面传递参数什么的
//处理分页URL
//返回url参数字符串 /user/flea array('a'=1,'b'=>'')
function get_fenye_url($url='',$str=array(),$arr = array()){
$tempstr = '';
if(!empty($arr)){
$thArr = array_keys($arr);
$thKey = $thArr[0];
$str[$thKey] = $arr[$thKey];
}
foreach($str as $key=>$val){
if(!empty($val)){
if(empty($tempstr)){
$tempstr .= $key . '=' . $val;
}else{
$tempstr .= '&' . $key . '=' . $val;
}
}
}
$tempstr = empty($tempstr) ? $url : $url . '?' . $tempstr ;
// var_dump("<pre>",array('url'=>$url,'tempstr'=>$tempstr,'newArr'=>$str));
// return $tempstr ;
return array('url'=>$url,'tempstr'=>$tempstr,'newArr'=>$str) ;
}
用法
<p><b>区域</b>
<a <?php if(empty($area)){echo 'class="xz"';} ?> href="<?php $str = $this->mfun->get_fenye_url($returnUrl['url'],$returnUrl['newArr'],array('area'=>0)); echo $str['tempstr']; ?>">不限</a>
<?php foreach($areaArr as $k=>$v){ ?>
<a <?php if($area == $v['id']){echo 'class="xz"';} ?> href="<?php $str = $this->mfun->get_fenye_url($returnUrl['url'],$returnUrl['newArr'],array('area'=>$v['id'])); echo $str['tempstr']; ?>"><?php echo $v['cname']; ?></a>
<?php } ?>
</p>
<div class="orderit">
<span>排序:</span><span><select class="odrslct" id="order_slct" onchange="tiaozhuan(this.value); ">
<option label="默认排序方式" value="<?php $str = $this->mfun->get_fenye_url($returnUrl['url'],$returnUrl['newArr'],array('px'=>0)); echo $str['tempstr']; ?>" <?php if(empty($px)){echo 'selected="selected"';} ?>>默认排序方式</option>
<option label="面积从小到大" value="<?php $str = $this->mfun->get_fenye_url($returnUrl['url'],$returnUrl['newArr'],array('px'=>1)); echo $str['tempstr']; ?>" <?php if($px==1){echo 'selected="selected"';} ?>>面积从小到大</option>
<option label="面积从大到小" value="<?php $str = $this->mfun->get_fenye_url($returnUrl['url'],$returnUrl['newArr'],array('px'=>2)); echo $str['tempstr']; ?>" <?php if($px==2){echo 'selected="selected"';} ?>>面积从大到小</option>
<option label="租金从低到高" value="<?php $str = $this->mfun->get_fenye_url($returnUrl['url'],$returnUrl['newArr'],array('px'=>3)); echo $str['tempstr']; ?>" <?php if($px==3){echo 'selected="selected"';} ?>>租金从低到高</option>
<option label="租金从高到低" value="<?php $str = $this->mfun->get_fenye_url($returnUrl['url'],$returnUrl['newArr'],array('px'=>4)); echo $str['tempstr']; ?>" <?php if($px==4){echo 'selected="selected"';} ?>>租金从高到低</option>
<option label="时间从新到旧" value="<?php $str = $this->mfun->get_fenye_url($returnUrl['url'],$returnUrl['newArr'],array('px'=>5)); echo $str['tempstr']; ?>" <?php if($px==5){echo 'selected="selected"';} ?>>时间从新到旧</option>
<option label="时间从旧到新" value="<?php $str = $this->mfun->get_fenye_url($returnUrl['url'],$returnUrl['newArr'],array('px'=>6)); echo $str['tempstr']; ?>" <?php if($px==6){echo 'selected="selected"';} ?>>时间从旧到新</option>
</select>
</span>
<span>
<a href="/" class="onarup">面积</a></span>
<span><a <?php if($px==3){$pxzj=4; echo 'class="onarup"';}elseif($px==4){$pxzj=3 ;echo 'class="onardn"';}else{$pxzj=3; echo 'class="arup"'; } ?> href="<?php $str = $this->mfun->get_fenye_url($returnUrl['url'],$returnUrl['newArr'],array('px'=>$pxzj)); echo $str['tempstr']; ?>">租金</a>
<span><a <?php if($px==5){$pxsj=6; echo 'class="onarup"';}elseif($px==6){$pxsj=5 ;echo 'class="onardn"';}else{$pxsj=5; echo 'class="arup"'; } ?> href="<?php $str = $this->mfun->get_fenye_url($returnUrl['url'],$returnUrl['newArr'],array('px'=>$pxsj)); echo $str['tempstr']; ?>">时间</a>
</span>
</div>
控制器处理
$this->load->library(array('pagination_cuzn'));
function czlist(){
//查询区域
$data['areaArr']= $this->mfun->get_area_class_fun()->result_array();
//房屋类型
$data['fwTypeArr'] = $this->mfun->get_ershou_data('fw_type');
//装修类型
$data['zxTypeArr'] = $this->mfun->get_ershou_data('zx_type');
// var_dump("<pre>",$data['zxTypeArr']);
$whereArr = array();
$wi = 1;
$whereArr[$wi++]= array('ershou_chuzhu.area'=>$this->mfun->get_site_area());
$joinArr=array(array('ershou_xiaoqu as xq','xq.xqid = dede_ershou_chuzhu.xqid','left'));
$selectStr='ershou_chuzhu.*,xq.pqid,xq.address,xq.cityid';
$orderArr = array('ershou_chuzhu.czid'=>'desc');
$urlArr = array();
$ui=1;
//分页参数
if(isset($_GET['offset'])){
$data['offset'] = $_GET['offset'];
}else{
$data['offset'] = 0;
}
//区域
if(isset($_GET['area'])){
$data['area'] = $_GET['area'];
}else{
$data['area'] = 0;
}
if(!empty($data['area'])){
$whereArr[$wi++]= array('cityid'=>$data['area']);
}
//租金
if(isset($_GET['zj'])){
$data['zj'] = $_GET['zj'];
}else{
$data['zj'] = 0;
}
switch ($data['zj']){
case 1 : $whereArr[$wi++]= array('rent <='=>600);break;
case 2 : $whereArr[$wi++]= array('rent >='=>600);$whereArr[$wi++]= array('rent <='=>800);break;
case 3 : $whereArr[$wi++]= array('rent >='=>800);$whereArr[$wi++]= array('rent <='=>1000);break;
case 4 : $whereArr[$wi++]= array('rent >='=>1000);$whereArr[$wi++]= array('rent <='=>1500);break;
case 5 : $whereArr[$wi++]= array('rent >='=>1500);$whereArr[$wi++]= array('rent <='=>2000);break;
case 6 : $whereArr[$wi++]= array('rent >='=>2000);$whereArr[$wi++]= array('rent <='=>2500);break;
case 7 : $whereArr[$wi++]= array('rent >='=>2500);break;
}
//类型
if(isset($_GET['lx'])){
$data['lx'] = $_GET['lx'];
}else{
$data['lx'] = 0;
}
if(!empty($data['lx'])){
$whereArr[$wi++]= array('fw_type'=>$data['lx']);
}
//装修
if(isset($_GET['zx'])){
$data['zx'] = $_GET['zx'];
}else{
$data['zx'] = 0;
}
if(!empty($data['zx'])){
$whereArr[$wi++]= array('zx_type'=>$data['zx']);
}
//户型
if(isset($_GET['hx'])){
$data['hx'] = $_GET['hx'];
}else{
$data['hx'] = 0;
}
if(!empty($data['hx'])){
if($data['hx']<=5){
$whereArr[$wi++]= array('shi'=>$data['hx']);
}else{
$whereArr[$wi++]= array('shi >'=>$data['hx']);
}
}
//关键字搜索
$orlikeArr = array();
// var_dump($_GET['keyword']);
if(isset($_GET['keyword'])){
$keyword = $_GET['keyword'];
}else{
$keyword = 0;
}
if(empty($_POST['keyword']) && empty($keyword)){
$data['keyword'] = 0;
}elseif(!empty($_POST['keyword']) && empty($keyword)){
$data['keyword'] = $_POST['keyword'];
}elseif(empty($_POST['keyword']) && !empty($keyword)){
$data['keyword'] = $keyword;
}else{
$data['keyword'] = '0';
}
//排序
if(isset($_GET['px'])){
$data['px'] = $_GET['px'];
}else{
$data['px'] = 0;
}
switch ($data['px']){
case 1 : $orderArr = array('ershou_chuzhu.czid'=>'desc');break;
case 2 : $orderArr = array('ershou_chuzhu.czid'=>'desc');break;
case 3 : $orderArr = array('rent'=>'asc');break;
case 4 : $orderArr = array('rent'=>'desc');break;
case 5 : $orderArr = array('ershou_chuzhu.addtime'=>'desc');break;
case 6 : $orderArr = array('ershou_chuzhu.addtime'=>'asc');break;
}
$config['page_query_string']=TRUE;
$data['url'] = "/xershou1/czlist/";
$urlArr = array('area'=>$data['area'],'zj'=>$data['zj'],'lx'=>$data['lx'],'zx'=>$data['zx'],'px'=>$data['px']);
// $this->mfun->get_fenye_url($data['url'],$urlArr,array('offset'=>$data['offset']));
$data['returnUrl'] = $this->mfun->get_fenye_url($data['url'],$urlArr);
if(!empty($data['keyword']) && $data['keyword']!='输入小区名称或关键字'){
$orlikeArr = array('name'=>$data['keyword'],'title'=>$data['keyword']);
$config['base_url'] = $data['returnUrl']['tempstr']."?keyword=".$data['keyword'];
}else{
$config['base_url'] = $data['returnUrl']['tempstr'];
}
$data['page']=$config['per_page'] = 1;//分页数
$config['query_string_segment'] = 'offset';
$data['cur_page'] = $config['cur_page'] = $data['offset'];
$data['total_rows'] = $config['total_rows'] = $total_num = $this->mfun->get_fenye_fun(0,'ershou_chuzhu',$whereArr,$orderArr,$config['per_page'],$config['cur_page'],array(),$joinArr,$selectStr,array(),$orlikeArr);
$this->pagination_cuzn->initialize($config);
$data['pagination'] = $this->pagination_cuzn->create_links();
$data['chuzhuArr'] = $this->mfun->get_fenye_fun(1,'ershou_chuzhu',$whereArr,$orderArr,$config['per_page'],$config['cur_page'],array(),$joinArr,$selectStr,array(),$orlikeArr)->result_array();
$this->load->view('xershou_chuzu_list1',$data);
}
声明:此文系舞林cuzn(www.wulinlw.org)原创稿件,转载请保留版权
/*
* 分页函数
* 参数1:查询类型 0:查询数量 1:查询数据
* 参数2:表
* 参数3:查询条件 where 条件 格式arrar(array('k1'=>v1),array('k2'=>v2))
* 参数4:order 条件 格式array('字段'=>排序)
* 参数5:分页数
* 参数6:分页偏移量
* 参数7:like条件 因为用的少..所以放后面..以后全部同理 用法 条件 格式array('字段'=>值) == WHERE title LIKE '%value%' 目前用的是最简单的like 以后遇到复杂的在改
* 参数8:joinArr join连接表 格式 array(array('表名','连接条件','连接方向'))
* 参数9:要查询的字段 $string
* 参数10:加入in查询 传入array('字段'=>'值的数组') 例如 $names = array('Frank', 'Todd', 'James'); $this->db->where_in('username', $names); 生成: WHERE username IN ('Frank', 'Todd', 'James')
* 参数11:orlike条件 用法和like一样...没有把这2个合并是因为括号不兼容
* 参数12:加入not in查询 用法和in一样...主要是SB CI不支持" and c.isnew != 1 and c.isnew != 3"这种模式..只能用not in 来代替
*/
function get_fenye_fun($type,$table,$whereArr=array(),$orderArr=array(),$page,$offset=0,$likeArr=array(),$joinArr=array(),$selectStr='',$inWhereArr=array(),$orlikeArr=array(),$noinWhereArr=array()){
// $this->db->from('kehu_member_gendan');
// return $this->db->count_all_results();
if(!empty($whereArr)){
foreach($whereArr as $k=>$v){
// var_dump($v);
foreach($v as $kk=>$vv){
$this->db->where($kk,$vv);
}
}
}
if(!empty($orderArr)){
foreach($orderArr as $k=>$v){
$this->db->order_by($k,$v);
}
}
if(!empty($likeArr)){
foreach($likeArr as $k=>$v){
$this->db->like($k,$v);
}
}
if(!empty($orlikeArr)){
foreach($orlikeArr as $k=>$v){
$this->db->or_like($k,$v);
}
}
if(!empty($joinArr)){
foreach($joinArr as $k=>$v){
$this->db->join($v[0], $v[1], $v[2]);
}
}
if(!empty($selectStr)){
$this->db->select($selectStr);
}
if(!empty($inWhereArr)){
foreach($inWhereArr as $k=>$v){
$this->db->where_in($k,$v);
}
}
if(!empty($noinWhereArr)){
foreach($noinWhereArr as $k=>$v){
$this->db->where_not_in($k,$v);
}
}
if(empty($type)){
$this->db->from($table);
return $this->db->count_all_results();
}else{
$this->db->limit($page, $offset);
return $this->db->get($table);
}
}
用法
function czlist(){
//查询区域
$data['areaArr']= $this->mfun->get_area_class_fun()->result_array();
// var_dump("<pre>",$data['areaArr']);
//房屋类型
$data['fwTypeArr'] = $this->mfun->get_ershou_data('fw_type');
$whereArr = array();
$wi = 1;
// $whereArr[0]= array('ershou_chuzhu.area'=>$this->mfun->get_site_area());
// $whereArr[2]= array('rent <'=>600);
// $whereArr[3]=array('rent >'=>800);
$joinArr=array(array('ershou_xiaoqu as xq','xq.xqid = dede_ershou_chuzhu.xqid','left'));
$selectStr='ershou_chuzhu.*,ershou_chuzhu.rent as rent1,xq.pqid,xq.address,xq.cityid';
//区域
$data['area'] = $this->uri->segment(3,0);
if(!empty($data['area'])){
$whereArr[$wi++]= array('ershou_chuzhu.area'=>$this->mfun->get_site_area());
// $whereArr[]['cityid'] = $data['area'] ;
}
//租金
$data['zj'] = $this->uri->segment(4,0);
switch ($data['zj']){
case 1 : $whereArr[$wi++]= array('rent <='=>600);
case 2 : $whereArr[$wi++]= array('rent >='=>600);$whereArr[$wi++]= array('rent <='=>800);
case 3 : $whereArr[$wi++]= array('rent >='=>800);$whereArr[$wi++]= array('rent <='=>1000);
case 4 : $whereArr[$wi++]= array('rent >='=>1000);$whereArr[$wi++]= array('rent <='=>1500);
case 4 : $whereArr[$wi++]= array('rent >='=>1500);$whereArr[$wi++]= array('rent <='=>1500);
}
// var_dump("<pre>",$whereArr);die;
$config['base_url'] = "/xershou/czlist/".$data['area'].'/'.$data['zj'];//分页连接
$data['page']=$config['per_page'] = 10;//分页数
$data['cur_page'] = $config['cur_page'] = $this->uri->segment(5,0);
$config['uri_segment'] = 5;
$data['total_rows'] = $config['total_rows'] = $total_num = $this->mfun->get_fenye_fun(0,'ershou_chuzhu',$whereArr,array('ershou_chuzhu.czid'=>'desc'),$config['per_page'],$config['cur_page'],array(),$joinArr,$selectStr);
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['chuzhuArr'] = $this->mfun->get_fenye_fun(1,'ershou_chuzhu',$whereArr,array('ershou_chuzhu.czid'=>'desc'),$config['per_page'],$config['cur_page'],array(),$joinArr,$selectStr)->result_array();
$this->load->view('xershou_chuzu_list',$data);
}
声明:此文系舞林cuzn(www.wulinlw.org)原创稿件,转载请保留版权