文章标签 ‘PHP’
2015十二月15

LNMP:Nginx+PHP Ci框架配置注意事项

CodeIgniter

php.ini  修改:

cgi.fix_pathinfo=1

 

nginx/vhost/ 域名配置:

 

server {
listen 80;
server_name www.wizzer.cn wizzer.cn;
root “/data/www/www.wizzer.cn”;
location / {
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?$1 last;
break;
}
}
location ~ \.php(.*)$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}

2014七月1

原创:帝国CMS7.0批量上传图片集插件

版本特点:

1、使用系统自带的水印系统,勾选即可使用;

2、可勾选生成缩略图。

使用方法:

1、将 uploadify 文件夹解压至 ../e/extend/

2、系统–>数据表与系统模型–>管理数据表–>图片系统数据表–>管理字段–> morepic 修改:
将“输入表单替换html代码.html”文件内容,拷贝替换掉“输入表单替换html代码”

3、搞定。

 

ps:uploadify.php 第49行,没有用到的,可以删掉提高效率。

效果

 

下载地址:

1、原版下载(或附件):http://pan.baidu.com/s/1kTDmdyZ
2、上传时获取照片附加属性(曝光、光圈、相机型号等)版本:
     http://pan.baidu.com/s/1qWuLahQ 

 

 

2014六月5

帝国CMS:头部导航栏当前栏目高亮

/e/class/userfun.php

function currentPage($classid,$thisid){
        global $class_r;
        $fr=explode('|',$class_r[$classid][featherclass]);
        $topbclassid=$fr[1]?$fr[1]:$classid;//取得第一级栏目id
        if ($topbclassid==$thisid) {
                  echo "class='cur'";
                }
        else {
        }
}

头部模板:

<ul>
<li <?php  if(empty($GLOBALS[navclassid])){echo "class='cur'";} ?>><a id="nav-hover0" href="[!--news.url--]">首页</a></li>
<?php 
$i=0;
$path="";
?>
[e:loop={'select classid,classname,classpath,wburl from [!db.pre!]enewsclass where bclassid=0 order by classid',0,24,0}]
<?php 
  $i=$i+1;
  $path=$public_r[newsurl].$bqr[classpath];
  if(!empty($bqr[wburl])){
      $path=$bqr[wburl];
  }
?>
<li <?=currentPage($GLOBALS[navclassid],$bqr[classid])?>>
<a  id="nav-hover<?=$i?>" href="<?=$path?>" title="<?=$bqr[classname]?>" target="_self" ><?=$bqr[classname]?></a>
</li>
[/e:loop]
</ul>
2014五月28

Windows :Nginx + PHP 配置虚拟目录

首先配置好运行环境:

windows下配置nginx+php环境

其次修改nginx配置文件:

server {
        listen       80;
        server_name  localhost;
	location ~ ^/bbs/.+\.php$ {
	   alias		E:/xuetang/cn/bbs;
	   rewrite		/bbs/(.*\.php?) /$1 break;
	   fastcgi_index	index.php;
	   fastcgi_pass		127.0.0.1:9000;
	   fastcgi_param	SCRIPT_FILENAME E:/xuetang/cn/bbs$fastcgi_script_name;
	   include		fastcgi_params;
	}
	location ~ ^/bbs($|/.*) {
	   alias		E:/xuetang/cn/bbs/$1;
	   index		index.php index.html index.htm;
	}

        location / {
            root   E:/xuetang/cn/www;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ \.php$ {
            root           E:/xuetang/cn/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
}

注意虚拟目录配置要在根目录上面。。

2014五月21

PHP:POST发送JSON字符串

/**  
 * 发送post请求  
 * @param string $url 请求地址  
 * @param array $post_data post数据  
 * @return string  
 */  
function send_post($url, $post_data) {   

	$ch = curl_init($url);
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
	curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(
		'Content-Type: application/json',
		'Content-Length: ' . strlen($post_data))
	);  
	return curl_exec($ch);   
}   


<?php
		header("Content-type: text/html; charset=utf-8");
		include_once('../functions.php');
		$send_msg="test";//发送内容
		$data = array("openid" => "oXS2NuPCEB836NRMrsXXXXXX", "content" => $send_msg);
        $data_string = json_encode($data);
		echo send_post('http://XXX.cn/api/wx/push/custom/text?mykey=XXXXXX', $data_string);  
?>
2010六月28

PHP webservice客户端 推送文章和附件(xsd:base64Binary)

<?php
//设定字符集
header('Content-Type:text/html;charset=utf-8');

//调用webserver接口class类
require_once('./lib/nusoap.php');

require_once('Article.class.php');     //封装文章信息类
require_once('Attribute.class.php');    //封装字段attr类
require_once('Appendix.class.php');     //封装附件信息类

//-------------------封装推送信息内容开始
$a1 = new Attribute();
$a1->setAttrName('aaa');
$a1->setAttrValue('aaaaa');
$a2 = new Attribute();
$a2->setAttrName('bbb');
$a2->setAttrValue('bbbbbb');
$ar[] = $a1;
$ar[] = $a2;
echo $ar[0]->getAttrName('aaa');

$Article = new Article();
$Article->setArticleContent(mb_convert_encoding('vvvvvvvvvvv<a href="a.txt">a.txt</a>...<img src="tmp.jpg">','UTF-8','GBK'));   //文章正文
$Article->setArticleTitle(mb_convert_encoding("12212AAABBBABAAA".date('Ymd'),'UTF-8','GBK'));   //文章题目
$Article->setAttr($ar);      //文章定制属性组
$Article->setCreateTime(date('YmdHis'));   //文章创立时间
$Article->setDepartment("tongjiju");    //用户部门
$Article->setDescription("description");      //文章描述
$Article->setImportant("0");      //文章级别
$Article->setKeyword("keyword");       //文章关键字
$Article->setLoginName("tongjiju");     //用户登录名
$Article->setModifyTime(date('YmdHis'));   //文章修改时间
$Article->setPassword("tongjiju");     //用登录口令
$Article->setWebName(mb_convert_encoding("市政府子网站群二期 > 市统计局 > 市情简介",'UTF-8','GBK')); //网站的名称
$Article->setCommendId(0);
$client = new nusoap_client("http://221.122.*.*:7006/cmsweb/services/TransferArticle?wsdl", true);
$err = $client->getError();
if ($err) {
echo "<h2>Constructor error</h2><pre>". $err ."</pre>";
}
$godata='';
//文章中存在附件 'finishMark'=>false-------------------------------------------------------------
$godata=array('article'=>$Article,'finishMark'=>false);
$result = $client->call("transferContent", $godata);
if ($client->fault) {
echo "<h2>Fault</h2><pre>";
print_r($result);
echo "</pre>";
} else {
$err = $client->getError();
if ($err) {
   echo "<h2>Error</h2><pre>" . $err . "</pre>";
} else {
   echo "<h2>Result</h2><pre>";
   print_r($result);
   echo "</pre>";
}
}
$aid=$result['transferContentReturn'];

if ($aid){

//第一个附件 'finishMark'=>false-------------------------------------------------------------
$filepath='a.txt';
$fp=fopen($filepath, "rb");
    $filedata=fread($fp, filesize($filepath));
fclose($fp);
$Appendix = new Appendix();
$Appendix->setFileContent(base64_encode($filedata));
$Appendix->setFileName('a.txt');
$Appendix->setFileType('txt');
$godataf=array('aid'=>$aid,'apd'=>$Appendix,'finishMark'=>false);
$resultf = $client->call("transferAppendix", $godataf);
echo '<br><br>';
echo "<h2>Result_f</h2><pre>";
print_r($resultf);
echo "</pre>";

//最后附件 'finishMark'=>true-------------------------------------------------------------
$filepath2='tmp.jpg';
$fp2=fopen($filepath2, "rb");
    $filedata2=fread($fp2, filesize($filepath2));
fclose($fp2);
$Appendix2 = new Appendix();
$Appendix2->setFileContent(base64_encode($filedata2));
$Appendix2->setFileName('tmp.jpg');
$Appendix2->setFileType('image_title');//image_title 此图片为标题图
$godataf2=array('aid'=>$aid,'apd'=>$Appendix2,'finishMark'=>true);
$resultf2 = $client->call("transferAppendix", $godataf2);
echo '<br><br>';
echo "<h2>Result_f2</h2><pre>";
print_r($resultf2);
echo "</pre>";
}
?>