20155 月18
@At
public String test5(@Param("taskId") String taskId) {
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
if (task == null)
return "null";
ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(task.getProcessDefinitionId());
List<ActivityImpl> activitiList = def.getActivities();
System.out.println("getTaskDefinitionKey:::" + task.getTaskDefinitionKey());
NutMap map = new NutMap();
int type = 0;
getTaskActivitys(task.getTaskDefinitionKey(), activitiList, type, map);
return Json.toJson(map);
}
public static List<PvmActivity> getTaskActivitys(String activityId, List<ActivityImpl> activityList, int type, NutMap map) {
List<PvmActivity> activitiyIds = new ArrayList<>();
for (ActivityImpl activityImpl : activityList) {
String id = activityImpl.getId();
if (activityId.equals(id)) {
List<PvmTransition> outgoingTransitions = activityImpl.getOutgoingTransitions();//获取某节点所有线路
List<NutMap> list = new ArrayList<>();
for (PvmTransition tr : outgoingTransitions) {
NutMap map1 = new NutMap();
PvmActivity ac = tr.getDestination();//获取线路的终点节点
if (ac.getProperty("type").equals("userTask")) {
map.setv("type", type++);
map1.setv("id", ac.getId());
map1.setv("name", ac.getProperty("name"));
String conditionText=Strings.sNull(tr.getProperty("conditionText"));
if(!Strings.isEmpty(conditionText)){
map1.setv("conditionText",conditionText );
}
list.add(map1);
} else if (ac.getProperty("type").equals("exclusiveGateway")) {
getTaskActivitys(ac.getId(), activityList, type, map);
} else {
map.setv("type", type++);
break;
}
}
if (list.size() > 0)
map.addv("list", list);
break;
}
}
return activitiyIds;
}
20155 月12
通过配置文件实现(这个支持CXF spring注解)点这里
pom.xml
<!--CXF START-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-api</artifactId>
<version>2.7.15</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.7.15</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>2.7.15</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.7.15</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>2.7.15</version>
</dependency>
<!--CXF END-->
web.xml
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>com.auto.webservice.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/webservice/*</url-pattern>
</servlet-mapping>
CXFServlet.java:
package com.auto.webservice.servlet;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.frontend.ServerFactoryBean;
import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
import org.nutz.ioc.Ioc;
import org.nutz.lang.Strings;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.Mvcs;
import javax.jws.WebService;
import javax.servlet.ServletConfig;
import javax.xml.namespace.QName;
/**
* Created by wizzer on 15-4-10.
*/
@SuppressWarnings("serial")
public class CXFServlet extends CXFNonSpringServlet {
private final Log log = Logs.get();
@Override
protected void loadBus(ServletConfig sc) {
super.loadBus(sc);
//全局配置
Bus bus = getBus();
//添加白名单过滤器
bus.getInInterceptors().add(new IpAddressInInterceptor());
//使用全局配置
BusFactory.setDefaultBus(bus);
Ioc ioc = Mvcs.ctx().getDefaultIoc();
for (String name : ioc.getNames()) {
try {
Object obj = ioc.get(null, name);
if (!obj.getClass().getPackage().getName().equals("com.auto.webservice.server")) {
continue;
}
if (obj.getClass().getAnnotation(WebService.class) == null)
continue;
Class face = Class.forName(obj.getClass().getPackage().getName() + "." + Strings.upperFirst(name));
ServerFactoryBean serverFactoryBean = new ServerFactoryBean();
// 设置服务接口类
serverFactoryBean.setServiceClass(face);
// 服务请求路径
serverFactoryBean.setAddress("/" + name.substring(0, name.indexOf("Service")));
// 设置服务实现类
serverFactoryBean.setServiceBean(obj);
serverFactoryBean.setBindingId("http://schemas.xmlsoap.org/wsdl/soap12/");
serverFactoryBean.create();
} catch (Throwable e) {
}
}
}
}
接口类
WorkflowService.java
package com.auto.webservice.server;
import org.nutz.json.Json;
import javax.jws.WebService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by wizzer on 15-4-13.
*/
@WebService
public interface WorkflowService {
String start(String flowKey, String userId);//启动流程
}
实现类
WorkflowServiceImpl.java
package com.auto.webservice.server;
import org.activiti.engine.*;
import org.activiti.engine.form.FormProperty;
import org.activiti.engine.form.StartFormData;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskQuery;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import org.nutz.lang.Strings;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.Mvcs;
import javax.jws.WebService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by wizzer on 15-4-13.
*/
@IocBean(name = "workflowService")
@WebService
public class WorkflowServiceImpl implements WorkflowService {
private final Log log = Logs.get();
@Inject
Dao dao;
@Inject
FormService formService;
@Inject
IdentityService identityService;
@Inject
RepositoryService repositoryService;
@Inject
RuntimeService runtimeService;
@Inject
TaskService taskService;
/**
* 启动一个流程
*
* @param flowKey 流程模型key
* @param userId 用户ID
* @return
*/
public String start(String flowKey, String userId) {
Map<String, Object> map = new HashMap<String, Object>();
try {
if (!Strings.isEmpty(userId)) {
identityService.setAuthenticatedUserId(userId);
}
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(flowKey);
map.put("errcode", 0);
map.put("errmsg", "");
map.put("processInstanceId", processInstance.getId());
} catch (Exception e) {
log.error("WebServcice启动流程出错", e);
map.put("errcode", 1);
map.put("errmsg", e.getMessage());
} finally {
identityService.setAuthenticatedUserId(null);
}
return Json.toJson(map, JsonFormat.compact());
}
}
20155 月7
在nutz filter作用域内才能Mvcs.getIoc()
其他情况:
Mvcs.ctx().getDefaultIoc().get(xxx.class)
20154 月27
首先值得一提的是,taskService.createTaskQuery().taskCandidateOrAssigned(userId) 方法有bug,不会调用重写的工厂类,请使用taskService.createTaskQuery().taskCandidateUser(userId)方法。
CustomGroupEntityManager
/**
* 分组工厂类
* Created by wizzer on 15-4-27.
*/
@IocBean
public class CustomGroupEntityManager extends GroupEntityManager {
Dao dao= Mvcs.getIoc().get(Dao.class);
private final Log log = Logs.get();
@Override
public List<Group> findGroupsByUser(String userId) {
Sql sql = Sqls.create("SELECT a.* FROM sys_role a,sys_user_role b WHERE a.id=b.roleid AND b.userid=@c");
sql.params().set("c", userId);
sql.setCallback(Sqls.callback.maps());
dao.execute(sql);
List<Map> list=sql.getList(Map.class);
List<Group> groupList=new ArrayList<Group>();
for (Map m:list){
GroupEntity group=new GroupEntity();
group.setId(Strings.sNull(m.get("id")));
group.setName(Strings.sNull(m.get("name")));
group.setType("assignment");
group.setRevision(1);
groupList.add(group);
}
return groupList;
}
}
CustomGroupEntityManagerFactory
/**
* 分组接口类
* Created by wizzer on 15-4-27.
*/
@IocBean
public class CustomGroupEntityManagerFactory implements SessionFactory {
private GroupEntityManager groupEntityManager;
public void setGroupEntityManager(GroupEntityManager groupEntityManager) {
this.groupEntityManager = groupEntityManager;
}
@Override
public Class<?> getSessionType() {
return GroupIdentityManager.class;
}
@Override
public Session openSession() {
return groupEntityManager;
}
}
CustomUserEntityManager
/**
* 用户工厂类
* Created by wizzer on 15-4-24.
*/
@IocBean
public class CustomUserEntityManager extends UserEntityManager {
Dao dao= Mvcs.getIoc().get(Dao.class);
private final Log log = Logs.get();
@Override
public User findUserById(String userId) {
log.info("findUserById:::::::::::::::::::::::::::::::"+userId);
UserEntity userEntity = new UserEntity();
Sys_user sysUser = dao.fetch(Sys_user.class, Cnd.where("uid", "=", userId));
userEntity.setId(userId);
userEntity.setFirstName(sysUser.getRealname());
userEntity.setEmail(sysUser.getEmail());
userEntity.setRevision(1);
return userEntity;
}
@Override
public List<Group> findGroupsByUser(String userId) {
// TODO Auto-generated method stub
log.info("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
Sql sql = Sqls.create("SELECT a.* FROM sys_role a,sys_user_role b WHERE a.id=b.roleid AND b.userid=@c");
sql.params().set("c", userId);
sql.setCallback(Sqls.callback.maps());
dao.execute(sql);
List<Map> list=sql.getList(Map.class);
List<Group> groupList=new ArrayList<Group>();
for (Map m:list){
GroupEntity group=new GroupEntity();
group.setId(Strings.sNull(m.get("id")));
group.setName(Strings.sNull(m.get("name")));
group.setType("assignment");
group.setRevision(1);
groupList.add(group);
}
return groupList;
}
}
CustomUserEntityManagerFactory
/**
* 用户接口类
* Created by wizzer on 15-4-24.
*/
@IocBean
public class CustomUserEntityManagerFactory implements SessionFactory {
private UserEntityManager userEntityManager;
public void setUserEntityManager(UserEntityManager userEntityManager) {
this.userEntityManager = userEntityManager;
}
@Override
public Class<?> getSessionType() {
return UserIdentityManager.class;
}
@Override
public Session openSession() {
return userEntityManager;
}
}
在初始化activiti时追加代码:
List<SessionFactory> list=new ArrayList<SessionFactory>();
CustomGroupEntityManagerFactory customGroupManagerFactory=new CustomGroupEntityManagerFactory();
customGroupManagerFactory.setGroupEntityManager(new CustomGroupEntityManager());
CustomUserEntityManagerFactory customUserEntityManagerFactory=new CustomUserEntityManagerFactory();
customUserEntityManagerFactory.setUserEntityManager(new CustomUserEntityManager());
list.add(customGroupManagerFactory);
list.add(customUserEntityManagerFactory);
processEngineConfiguration.setCustomSessionFactories(list);
20154 月27
@SetupBy(value=StartSetup.class)
public class MainModule {
}
private void activitiInit(NutConfig config) {
log.info("Activiti Init Start...");
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration();
processEngineConfiguration.setDataSource(config.getIoc().get(DataSource.class));
processEngineConfiguration.setDatabaseSchemaUpdate("false");
processEngineConfiguration.setJobExecutorActivate(false);
processEngineConfiguration.setActivityFontName("宋体");
processEngineConfiguration.setLabelFontName("宋体");
processEngineConfiguration.setXmlEncoding("utf-8");
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
((Ioc2) config.getIoc()).getIocContext().save("app", "processEngine", new ObjectProxy(processEngine));
((Ioc2) config.getIoc()).getIocContext().save("app", "repositoryService", new ObjectProxy(processEngine.getProcessEngineConfiguration().getRepositoryService()));
((Ioc2) config.getIoc()).getIocContext().save("app", "runtimeService", new ObjectProxy(processEngine.getProcessEngineConfiguration().getRuntimeService()));
((Ioc2) config.getIoc()).getIocContext().save("app", "taskService", new ObjectProxy(processEngine.getProcessEngineConfiguration().getTaskService()));
((Ioc2) config.getIoc()).getIocContext().save("app", "formService", new ObjectProxy(processEngine.getProcessEngineConfiguration().getFormService()));
((Ioc2) config.getIoc()).getIocContext().save("app", "historyService", new ObjectProxy(processEngine.getProcessEngineConfiguration().getHistoryService()));
((Ioc2) config.getIoc()).getIocContext().save("app", "managementService", new ObjectProxy(processEngine.getProcessEngineConfiguration().getManagementService()));
((Ioc2) config.getIoc()).getIocContext().save("app", "identityService", new ObjectProxy(processEngine.getProcessEngineConfiguration().getIdentityService()));
log.info("Activiti Init End.");
}
20154 月24
public String getTemplateStr(String template, Map<String, String> para) {
StringWriter writer = new StringWriter();
try {
RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
StringReader reader = new StringReader(template);
SimpleNode node = runtimeServices.parse(reader, "Template name");
Template t = new Template();
t.setRuntimeServices(runtimeServices);
t.setData(node);
t.initDocument();
VelocityContext context = new VelocityContext();
if (para.size() > 0) {
for (String key : para.keySet()) {
context.put(key, para.get(key));
}
}
t.merge(context, writer);
} catch (Exception e) {
throw new RuntimeException("Error commiting transaction! cause:"+ e.getMessage());
}
return writer.toString();
}
@At("/form")
@Ok("vm:template.private.test")
public void form(HttpServletRequest req, HttpServletResponse resp) {
Map<String, Object> formParams = new HashMap<String, Object>();
formParams.put("formKey", "form/waizhibiaodan/01/01.form");
int timeout = 60 * 1000;
String str = Http.post("http://127.0.0.1/test/getFormKey", formParams, timeout);
NutMap map = Json.fromJson(NutMap.class, str);
String formData = map.getString("data");
Map<String, String> params = new HashMap<String, String>();
params.put("startDate", "2015-04-21");
params.put("endDate", "2015-04-25");
req.setAttribute("formData", getTemplateStr(formData, params));
}
20154 月21
mvn package -Dmaven.test.skip=true
20154 月16
processEngineConfiguration.setActivityFontName(“宋体”);
processEngineConfiguration.setLabelFontName(“宋体”);
windows环境变量:
JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
201410 月24
adb shell
su
chmod 777 /data/local/tcpdump
/data/local/tcpdump -p -vv -s 0 -w /sdcard/capture.pcap
20149 月29
select a.*
from wx_nickname a
left join (select distinct nickname_id from wx_group_nickname )b on
a.id = b.nickname_id
where b.nickname_id is null
20148 月28
第一步:编写插件类
package cn.xuetang.plugin;
import android.widget.Toast;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
/**
* Created by Wizzer on 14-8-28.
*/
public class ToastPlugin extends CordovaPlugin {
public ToastPlugin() {
}
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if (this.cordova.getActivity().isFinishing()) return true;
if (action.equals("show")) {
this.show(args.getString(0));
} else if (action.equals("showlong")) {
this.showlong(args.getString(0));
} else {
return false;
}
callbackContext.success();
return true;
}
public void show(String message) {
Toast.makeText(this.cordova.getActivity(), Toast.LENGTH_SHORT).show();
}
public void showlong(String message) {
Toast.makeText(this.cordova.getActivity(), message, Toast.LENGTH_LONG).show();
}
}
第二步:配置 res/xml/config.xml
<feature name="ToastPlugin">
<param name="android-package" value="cn.xuetang.plugin.ToastPlugin" />
</feature>
注:这里的 feature name ,要和↓↓面讲的的js文件里一致。
第三步:创建js文件 plugins/toast.js
/**
* Created by Wizzer on 14-8-28.
*/
cordova.define("cn.xuetang.plugin.ToastPlugin", function(require, exports, module) {
var exec = require('cordova/exec');
module.exports = {
/**
* 一共5个参数
第一个 :成功回调
第二个 :失败回调
第三个 :将要调用的类的配置名字(在config.xml中配置↑↑)
第四个 :调用的方法名(一个类里可能有多个方法 靠这个参数区分)
第五个 :传递的参数 以json的格式
*/
show: function(message) {
exec(null, null, "ToastPlugin", "show", [message]);
},
showlong: function(message) {
exec(null, null, "ToastPlugin", "showlong", [message]);
}
};
});
注:js里两个方法,分别对应类中的两个方法
第四步:修改 cordova_plugins.js 引用 tocas.js
在 module.exports = [ ] 中追加如下代码:
{
"file": "plugins/toast.js",
"id": "cn.xuetang.plugin.ToastPlugin",
"merges": [
"navigator.toast"
]
}
最后:调用
navigator.toast.show("再点击一次退出");
navigator.toast.showlong("再点击一次退出");
20148 月28
/**
* Created by Wizzer on 14-8-28.
*/
var num = 0;
var login = {
initialize: function () {
this.bindEvents();
},
bindEvents: function () {
document.addEventListener('backbutton', this.eventBackButton, false);
},
eventBackButton: function () {
num++;
if (num > 1) {
navigator.app.exitApp();
}
navigator.toast.show("再点击一次退出");
// 3秒后重新计数
var intervalID = window.setInterval(function() {
num=0;
window.clearInterval(intervalID);
}, 3000);
}
};
浮动提示插件见:
/?p=3026
20148 月26
.replaceAll(“[^a-zA-Z_\u4e00-\u9fa5]”, “”)
只剩下中文和英文字母了,悲催。
Caused by: java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x98\xB7’ for column ‘description’
20147 月8
网易微博登陆验证,第一次请求使用BASE64加密、第二次请求使用MD5+RSA加密,比较变态,于是使用JAVA+JS相结合的方式,调用其JS方法得到加密字符串。
/core1.7.0.js 是经过处理的,删掉几行在JAVA引用中会报错的浏览器对象。
import org.apache.http.HttpResponse;
import org.apache.http.client.CookieStore;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.velocity.util.StringUtils;
import org.nutz.lang.Files;
import org.nutz.lang.util.ClassTools;
import org.nutz.repo.Base64;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* Created by Wizzer on 14-7-7.
*/
public class Netease {
static String index_url = "http://t.163.com/session";
static String login1_url = "http://reg.163.com/services/httpLoginExchgKeyNew";
static String login2_url = "http://reg.163.com/httpLoginVerifyNew.jsp";
static String status_url = "http://t.163.com/share/check/status";
UrlUtil urlUtil = new UrlUtil();
public static void main(String[] args) {
CookieStore cookieStore = new Netease().login("email", "password");
}
public CookieStore login(String userid, String password) {
try {
DefaultHttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(login1_url + "?rnd=" + Base64.encodeToString(userid.getBytes(), true) + "&jsonp=setLoginStatus");
get.setHeader("Accept", "*/*");
get.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36");
HttpResponse response = client.execute(get);
int code = response.getStatusLine().getStatusCode();
if (code == 200) {
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line = "", res = "";
while (null != (line = reader.readLine())) {
res += line;
}
System.out.println("res:::" + res);
if (res.contains("200")) {
String[] str = StringUtils.split(urlUtil.getStr(res, "setLoginStatus(\"", "\")"), "\\n");
String o = str[1], h = str[2];
ScriptEngineManager sem = new ScriptEngineManager();
ScriptEngine se = sem.getEngineByName("javascript");
se.eval(getJs());
String jiami = "";
if (se instanceof Invocable) {
Invocable invoke = (Invocable) se;
jiami = invoke.invokeFunction("getCode",
password, o, h).toString();
System.out.println("jiami = " + jiami);
}
DefaultHttpClient client2 = new DefaultHttpClient();
client2.setCookieStore(client.getCookieStore());
HttpGet get2 = new HttpGet(login2_url + "?rcode=" + jiami + "&product=t&jsonp=setLoginStatus&savelogin=0&username=" + userid);
get2.setHeader("Accept", "*/*");
get2.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36");
HttpResponse response2 = client2.execute(get2);
int code2 = response2.getStatusLine().getStatusCode();
if (code2 == 200) {
InputStream in2 = response2.getEntity().getContent();
BufferedReader reader2 = new BufferedReader(new InputStreamReader(in2));
String line2 = "", res2 = "";
while (null != (line2 = reader2.readLine())) {
res2 += line2;
}
System.out.println("res2:::" + res2);
if (res.contains("200")) {
return client2.getCookieStore();
}
}
}
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private String getJs() {
String jscontent = Files.read(ClassTools.getClassLoader().getResource("").getPath() + "netease" + "/core1.7.0.js");
jscontent += "function getCode(p,o,h){\n" +
"\t\t\t\tvar l=new RSAKey();\n" +
"\t\t\t\tl.setPublic(h,o);\n" +
"\t\t\t\treturn l.encrypt(getMd5(p));\t\t\t\t\n" +
" }";
return jscontent;
}
}
20146 月9
img{max-width:800px;width:expression(this.width > 800 ? 800: true);height:auto;}
20146 月8
HSSFWorkbook wb = new HSSFWorkbook();
OutputStream out = new FileOutputStream(“x.xls”);
wb.write(out);
out.close();
return new File(“x.xls”);
ByteArrayOutputStream out = new ……..;
wb………
out.close();
ByteArrayInputStream in = new ………..(out.toByte…);
return in;
20146 月5
/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>
20145 月28
首先配置好运行环境:
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;
}
}
注意虚拟目录配置要在根目录上面。。
20145 月21
/**
* 发送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);
?>