ByteArrayOutputStreamout=new……..;
wb………
out.close();
ByteArrayInputStreamin=new………..(out.toByte…);
returnin;
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 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 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); ?>
2014五月16
Nutz:单机负载均衡或启动多实例注意事项
1、上传文件的文件池路径问题
upload.js
filePool : {
type : “cn.xuetang.common.file.FilePool”,
args : [“/temp/”, 2000]
}
将路径改到项目的路径下
public class FilePool extends NutFilePool {
public FilePool(String homePath, long size) {
super(webinfPath(homePath), size);
}
private static final String webinfPath(String str) {
return Mvcs.getServletContext().getRealPath(“/WEB-INF”)+str;
}
}
2、Nutz大字段缓存的问题
.nutz/tmp/dao
将org.nutz.dao.jdbc.nutz_jdbc_experts.js 拷贝到项目类路径下,修改相应的配置,文件夹不冲突即可。
2014五月16
Linux:后台执行Java类