本文目录一览:
- 1、请问这些网页是用什么语言来编写的???
- 2、Provider (0x8002000A) 超出当前范围。
- 3、golang 在文本文档中查找到指定内容要怎么才能读取整行
- 4、php和go语言哪个好
- 5、iris 真的是最快的Golang 路由框架吗
- 6、帮我看看这代码是不是zend加密的?该如何解密?
请问这些网页是用什么语言来编写的???
纯HTML啊,原文件如下:
!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”
html xmlns=””
head
meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″ /
title5q校园网/title
link href=”” rel=”stylesheet” type=”text/css” media=”all” /
link rel=”stylesheet” href=”” type=”text/css” media=”all” /
link rel=”stylesheet” href=”” type=”text/css” media=”all” /
link href=”” rel=”stylesheet” type=”text/css”
style type=”text/css”
#menu a.login{
background:url() no-repeat 0 -2px;
display:inline-block;
width:51px;
text-align:center;
color:#0087C5;
}
#menu a.help{
background:url() no-repeat;
display:inline-block;
width:51px;
text-align:center;
color:#0087C5;
}
#content{ margin-left:4px; margin-top:10px; }
#login_content_1{
margin:0px;
padding:0px;
border:0px;
height:601px;
width:191px;
float:left;
background-image: url();
background-repeat: no-repeat;
}
#login_content_2{ margin:0px; padding:0px; border:0px; background:url(); height:601px; width:191px;background-repeat: no-repeat; float:left;}
#login_content_3{ margin:0px; padding:0px; border:0px; background:url(); height:601px; width:179px;background-repeat: no-repeat; float:left;}
#login_content_5{ margin:0px; padding:0px; border:0px; background:url(); height:601px; width:163px;background-repeat: no-repeat; float:left;}
#login_content_6{ margin:0px; padding:0px; border:0px; background:url(); height:601px; width:272px;background-repeat: no-repeat; float:left;}
#login_name{margin-top:60px; margin-left:60px; color:#FFFFFF;}
.login_input{border:1px solid #78827d; width:135px; height:18px; line-height:18px; margin-bottom:3px;}
#login_name div{color:#FFFFFF;}
#login_name a{color:#FFFFFF;}
#login_name a:hover{text-decoration:none;color:#FFFFFF;}
.button01{margin:10px 20px;}
.button02{margin:10px;}
#login_name a.glowTxt{font-size: 12pt; font-weight: bold; color: #FFFC1C; }
#footer {
WIDTH: auto
}
#footer P {
PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px
}
#footer .f1 {
BORDER-RIGHT: #dfe6ec 1px; BORDER-TOP: #dfe6ec 1px solid; BACKGROUND: #f5f5f5; BORDER-LEFT: #dfe6ec 1px; COLOR: #0085c0; BORDER-BOTTOM: #dfe6ec 1px solid
}
#footer .f1 A {
COLOR: #0085c0; TEXT-DECORATION: none
}
/style
script src=””/script
script
var imAccount = “”;
var imPassword = “”;
String.prototype.trim = function() {
return this.replace(/^\s*|\s*$/g,””);
}
function isValidateTag(tag){
var tagReg= /[+-()~*:|]/;
if(tag.indexOf(“\n”)!=-1||tag.indexOf(“\r”)!=-1||tag.indexOf(“\\”)!=-1)
return false;
else if(tag.indexOf(“‘”)!=-1||tag.indexOf(‘”‘)!=-1)
return false;
else if(tag.indexOf(“+”)!=-1
||tag.indexOf(“-“)!=-1||tag.indexOf(“”)!=-1
||tag.indexOf(“”)!=-1
||tag.indexOf(“(“)!=-1
||tag.indexOf(“)”)!=-1
||tag.indexOf(“~”)!=-1
||tag.indexOf(“*”)!=-1
||tag.indexOf(“:”)!=-1
||tag.indexOf(“”)!=-1
||tag.indexOf(“|”)!=-1){
return false;
}
return true;
}
function check_login(obj){
try{
var user_name = obj.user_name.value.trim() ;
var password = obj.password.value.trim() ;
if(user_name==””){
alert(“请输入登陆帐号”) ;
obj.user_name.focus() ;
return false;
}
if(obj.user_name.value.trim().length4){
alert(“登录id 不能小于4位”) ;
obj.user_name.focus() ;
return false ;
}
if(obj.user_name.value.trim().length20){
alert(“登录id 不能大于20位”) ;
obj.user_name.focus() ;
return false ;
}
if(!isValidateTag(user_name)){
alert(“请不要在帐号中输入以下字符“+ -()~*:| ””) ;
obj.user_name.focus() ;
return false;
}
if(password==””){
alert(“请输入登陆密码”) ;
obj.password.focus() ;
return false;
}
}catch(e){alert(e);}
imAccount = user_name;
imPassword = password;
var url = “/login/LoginAjax.jsp?rnd=”+Math.random()+”user_name=”+escape(user_name)+”password=”+escape(password);
Request.sendPOST(url, “{status:-1,errno:5}”, doLoginRes, true, doLoginFailed);
return false ;
}
function doLoginRes(req, data) {
var stat = {status:-100};
eval(“stat=”+req.responseText);
if(stat.status==0){
try { web5q.Start5QIM(imAccount, imPassword); } catch(e) {}
var str=stat.mop_status ;
window.location=”/society/SocietyUserFirst.do” ;
}else{
if(stat.errno==4){
window.location=”/regist/redirect.jsp” ;
return ;
}else if(stat.errno==5){
window.location=”/login/LoginActivation.jsp?user_name=”+document.LoginForm.user_name.value.trim() ;
return ;
}else
doLoginFailed(stat) ;
}
}
function doLoginFailed(stat) {
var errmsg = “未知错误”;
switch (stat.errno) {
case 1:
errmsg = “用户不存在”;
break;
case 2:
errmsg = “密码错误”;
break;
case 3:
errmsg = “异常错误”;
break;
case 5:
errmsg = “您的邮箱还没有激活您不能登陆”;
break;
}
alert(errmsg) ;
document.LoginForm.user_name.focus() ;
}
function setFoc(){
document.LoginForm.user_name.focus() ;
}
//浏览器信息统计 wanghw add since 2006-8-7
function browserTotal(type){
if(null==type||type==””)return;
var info = “”;
if(type==”flash”){
var installedVersion = com.deconcept.FlashObjectUtil.getPlayerVersion();
info = installedVersion.major+”.”+installedVersion.minor+”.”+installedVersion.rev;
}else if(type==”ie”){
info = getBrowserVer();
}else if(type==”timeout”){
info = window.location.href;
}else{return;}
var url = “”+type+”info=”+info;
var divId = document.getElementById(“browser”);
if(divId) {
divId.src = url;
}else{
var stat = document.createElement(“img id=’browser’ src='” + url + “‘ style=’display:none;’ /”);
document.body.insertBefore(stat);
}
}
//取得浏览器版本 wanghw add since 2006-8-7
function getBrowserVer(){
var o;
o=window.navigator.appName
var s=window.navigator.appVersion;
if(s.indexOf(“MSIE”)!=-1){
s=s.slice(s.indexOf(“MSIE”)+4).slice(1,4);
}else{
alert(“您好,目前5q系统仅支持IE6(Internet Explorer 6.0.),我们检测到您的浏览器不是IE,为了保障你的顺畅试用,我们建议您更换浏览器进行浏览。\n我们会尽快解决兼容性的问题,给你造成不便,敬请谅解”);//2006-8-8
s=s.slice(0,3);
}
return o+”:”+s;
}
//超时处理统计函数 wanghw add since 2006-8-7
function timeOut(){
if(Hi.loadingTmr==0)return;
hideCoverAllFrm();
$(“loadingMsg”).style.display = “none”;
if (Hi.loadingTmr 0) {
clearTimeout(Hi.loadingTmr);
Hi.loadingTmr = 0;
}
//wanghw add since 2006-08-03
browserTotal(“timeout”);
}
/script
/head
body onload=”setFoc();browserTotal(‘ie’);browserTotal(‘flash’)”
noscriptiframe id=”noscript” src=”;info=not_js” style=”display:none”/iframe/noscript
div id=”head”
div style=height:4px;font-size:0;background:#D5D5D5 /div
div id=”menu” span class=”rr” a href=”javascript:document.LoginForm.user_name.focus()” class=”login”登录/a a href=”” target=”_blank” class=”help”帮助/a /span /div
table cellpadding=0 cellspacing=0 width=100% height=39
tr
td width=159div id=”logo”img src=”” border=”0″ style=”cursor:pointer” //div/td
td valign=bottom width=”280″div id=”menu1″
li id=”m1″a href=”javascript:void(0)” 首页 /a/li
img align=absmiddle src=;
li id=”m12″a href=”/regist/L.do?a=2efe4070dcb14fb2″ 注册 /a/li
img align=absmiddle src=;
li id=”m5″a href=”/login/LoginList.jsp” 学校 /a/li
img align=absmiddle src=;
li id=”m13″a href=”” target=”_blank” 帮助 /a/li
/td
td valign=”bottom” style=”padding-top:0px; margin:10px; position:relative; top:2px; background:url(”) repeat-x; vertical-align:bottom”
span onclick=”$(‘tmp’).src=”;”a href=”tour.jsp” target=”_blank”img src=”” border=”0″ alt=”” style=” position:relative; top:-2px; ” //a/span
/td
/tr
/table
/div
img id=”tmp” style=”display:none”/
div id=”content”
div id=”login_content_1″/divdiv id=”login_content_2″/divdiv id=”login_content_3″/divdiv id=”login_content_5″div style=”top:191px;”img src=”” border=”0″ usemap=”#Map” /
map name=”Map” id=”Map”area shape=”rect” coords=”11,10,152,45″ href=”” target=”_blank” onfocus=”blur();” onclick=”$(‘tjimg’).src=”;”//map/div/div
div id=”login_content_6″
form name=”LoginForm” action=”/login/LoginDo.jsp” method=”post” onsubmit=”return check_login(this);”
div id=”login_name”
登录id input name=”user_name” type=”text” class=”login_input” /br /
密码 input name=”password” type=”password” class=”login_input” /
div class=”button01″input type=”image” src=”” border=”0″ align=”absmiddle” height=”28″/ a href=”/passwd/pw_email.jsp” target=”_blank”找回密码/a/div
!–divimg src=”” border=”0″ align=”absmiddle” / 还没加入啊,是06级新生么?/div–
divbr/ span onclick=”$(‘tmp’).src=”;”a href=”tour.jsp” target=”_blank”还没加入?了解一下先!/a/span/div
!–div class=”button02″Yes→ a href=”” target=”_blank” onclick=”$(‘tjimg’).src=”;”img src=”” border=”0″ align=”absmiddle” //a/div–
!–div class=”button02″No→ a href=”/regist/L.do?a=2efe4070dcb14fb2″img src=”” border=”0″ align=”absmiddle” //a/div–
div class=”button02″a href=”” onclick=”$(‘tjimg’).src=”;” target=”_blank”img src=”” border=”0″ align=”absmiddle” //a/div
/div
/form
/div
div style=”background: url() no-repeat; MARGIN-LEFT: 2px; WIDTH: 989px; HEIGHT: 82px”
TABLE style=”margin-top:0px; LINE-HEIGHT: 22px” align=center
TBODY
TR
TD style=”COLOR: #808080″ align=middleA href=”” target=_blank新手课堂/A | A href=”” target=_blank主页美化圈/A | A href=”” target=_blank5q官方活动圈/A | A href=”” target=_blank圈主俱乐部/A | A href=”” target=_blank改进5q/A | A href=”” target=_blank问题报告/A | A href=”” target=_blank给我们留言/A | A href=”” target=_blank关于我们/A | A href=”” target=_blank隐私条款/A | A href=”” target=_blank举报中心/A/TD
/TR
TR
TD style=”COLOR: #808080″ align=center千橡公司 京ICP证041489号 Copyright? 1997-2006 All Rights Reserved./TD
/TR
/TBODY
/TABLE
/DIV
OBJECT ID=”web5q” CLASSID=”CLSID:5C56F4A7-71FC-4FFD-A9D7-18FB87A9DFC6″ /OBJECT
!–图片辅助统计–
img name=”tjimg” style=”display:none”/
/body
script
!–
var requiredVersion = new com.deconcept.PlayerVersion([8,0,0]);
var installedVersion = com.deconcept.FlashObjectUtil.getPlayerVersion();
if(installedVersion.versionIsValid(requiredVersion) == false)
{
alert(“没有安装Flash 8,自动安装需要时间,请稍候,并在弹出窗口选择确定安装”);
document.write(‘object style=”display:none” id=”shell_object” name=”shell” classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″ \
codebase=”” width=”0″ height=”0″\
param name=”movie” value=”” /\
param name=FlashVars value=”loc=en_USrequired_version=8,0,24,0″ /\
embed id=”shell_object” name=”shell” type=”application/x-shockwave-flash” src=”” flashvars=”loc=en_USrequired_version=8,0,24,0″width=”0″ height=”0″ pluginspage=””/embed\
/object’);
}
—
/script
/html
Provider (0x8002000A) 超出当前范围。
仔细看下数据库 tel这个字段
是不是设置为 INT 类型
如果是 改正为 CHAR 或者 VARchar 类型
否则就更正 contact 字段 把字节长度变大一些
golang 在文本文档中查找到指定内容要怎么才能读取整行
package main
import (
“fmt”
“io/ioutil”
“log”
“strings”
)
func main() {
content, err := ioutil.ReadFile(“/usr/share/applications/gvim.desktop”)
if err != nil {
log.Fatal(err)
}
lines := strings.Split(string(content), “\n”)
for _, v := range lines {
trimline := strings.TrimSpace(v)
if strings.Contains(trimline, “text/plain”) {
fmt.Println(trimline)
}
}
}
php和go语言哪个好
前言
最近工作中遇到的一个场景,php项目中需要使用一个第三方的功能,而恰好有一个用Golang写好的类库。那么问题就来了,要如何实现不同语言之间的通信呢?下面就来一起看看吧。
常规的方案
1、 用Golang写一个http/TCP服务,php通过http/TCP与Golang通信
2、将Golang经过较多封装,做为php扩展。
3、PHP通过系统命令,调取Golang的可执行文件
存在的问题
1、http请求,网络I/O将会消耗大量时间
2、需要封装大量代码
3、PHP每调取一次Golang程序,就需要一次初始化,时间消耗很多
优化目标
1、Golang程序只初始化一次(因为初始化很耗时)
2、所有请求不需要走网络
3、尽量不大量修改代码
解决方案
1、简单的Golang封装,将第三方类库编译生成为一个可执行文件
2、PHP与Golang通过双向管道通信
使用双向管道通信优势
1:只需要对原有Golang类库进行很少的封装
2:性能最佳 (IPC通信是进程间通信的最佳途径)
3:不需要走网络请求,节约大量时间
4:程序只需初始化一次,并一直保持在内存中
具体实现步骤
1:类库中的原始调取demo
package main
import (
“fmt”
“github.com/yanyiwu/gojieba”
“strings”
)
func main() {
x := gojieba.NewJieba()
defer x.Free()
s := “小明硕士毕业于中国科学院计算所,后在日本京都大学深造”
words := x.CutForSearch(s, true)
fmt.Println(strings.Join(words, “/”))
}
保存文件为main.go,就可以运行
2:调整后代码为:
package main
import (
“bufio”
“fmt”
“github.com/yanyiwu/gojieba”
“io”
“os”
“strings”
)
func main() {
x := gojieba.NewJieba(
“/data/tmp/jiebaDict/jieba.dict.utf8”,
“/data/tmp/jiebaDict/hmm_model.utf8”,
“/data/tmp/jiebaDict/user.dict.utf8”
)
defer x.Free()
inputReader := bufio.NewReader(os.Stdin)
for {
s, err := inputReader.ReadString(‘\n’)
if err != nil err == io.EOF {
break
}
s = strings.TrimSpace(s)
if s != “” {
words := x.CutForSearch(s, true)
fmt.Println(strings.Join(words, ” “))
} else {
fmt.Println(“get empty \n”)
}
}
}
只需要简单的几行调整,即可实现:从标准输入接收字符串,经过分词再输出
测试:
# go build test
# ./test
# //等待用户输入,输入”这是一个测试“
# 这是 一个 测试 //程序
3:使用cat与Golang通信做简单测试
//准备一个title.txt,每行是一句文本
# cat title.txt | ./test
正常输出,表示cat已经可以和Golang正常交互了
4:PHP与Golang通信
以上所示的cat与Golang通信,使用的是单向管道。即:只能从cat向Golang传入数据,Golang输出的数据并没有传回给cat,而是直接输出到屏幕。但文中的需求是:php与Golang通信。即php要传数据给Golang,同时Golang也必须把执行结果返回给php。因此,需要引入双向管道。
在PHP中管道的使用:popen(“/path/test”) ,具体就不展开说了,因为此方法解决不了文中的问题。
双向管道:
$descriptorspec = array(
0 = array(“pipe”, “r”),
1 = array(“pipe”, “w”)
);
$handle = proc_open(
‘/webroot/go/src/test/test’,
$descriptorspec,
$pipes
);
fwrite($pipes[‘0’], “这是一个测试文本\n”);
echo fgets($pipes[1]);
解释:使用proc_open打开一个进程,调用Golang程序。同时返回一个双向管道pipes数组,php向$pipe[‘0’]中写数据,从$pipe[‘1’]中读数据。
好吧,也许你已经发现,我是标题档,这里重点要讲的并不只是PHP与Golang如何通信。而是在介绍一种方法: 通过双向管道让任意语言通信。(所有语言都会实现管道相关内容)
测试:
通过对比测试,计算出各个流程占用的时间。下面提到的title.txt文件,包含100万行文本,每行文本是从b2b平台取的商品标题
1: 整体流程耗时
time cat title.txt | ./test /dev/null
耗时:14.819秒,消耗时间包含:
进程cat读出文本
通过管道将数据传入Golang
Golang处理数据,将结果返回到屏幕
2:计算分词函数耗时。方案:去除分词函数的调取,即:注释掉Golang源代码中的调取分词那行的代码
time cat title.txt | ./test /dev/null
耗时:1.817秒时间,消耗时间包含:
进程cat读出文本
通过管道将数据传入Golang
Golang处理数据,将结果返回到屏幕
分词耗时 = (第一步耗时) – (以上命令所耗时)
分词耗时 : 14.819 – 1.817 = 13.002秒
3:测试cat进程与Golang进程之间通信所占时间
time cat title.txt /dev/null
耗时:0.015秒,消耗时间包含:
进程cat读出文本
通过管道将数据传入Golang
go处理数据,将结果返回到屏幕
管道通信耗时:(第二步耗时) – (第三步耗时)
管道通信耗时: 1.817 – 0.015 = 1.802秒
4:PHP与Golang通信的时间消耗
编写简单的php文件:
?php
$descriptorspec = array(
0 = array(“pipe”, “r”),
1 = array(“pipe”, “w”)
);
$handle = proc_open(
‘/webroot/go/src/test/test’,
$descriptorspec,
$pipes
);
$fp = fopen(“title.txt”, “rb”);
while (!feof($fp)) {
fwrite($pipes[‘0’], trim(fgets($fp)).”\n”);
echo fgets($pipes[1]);
}
fclose($pipes[‘0’]);
fclose($pipes[‘1’]);
proc_close($handle);
流程与上面基本一致,读出title.txt内容,通过双向管道传入Golang进程分词后,再返回给php (比上面的测试多一步:数据再通过管道返回)
time php popen.php /dev/null
耗时:24.037秒,消耗时间包含:
进程PHP读出文本
通过管道将数据传入Golang
Golang处理数据
Golang将返回结果再写入管道,PHP通过管道接收数据
将结果返回到屏幕
结论:
1 :整个分词过程中的耗时分布
使用cat控制逻辑耗时: 14.819 秒
使用PHP控制逻辑耗时: 24.037 秒(比cat多一次管道通信)
单向管道通信耗时: 1.8 秒
Golang中的分词函数耗时: 13.002 秒
2:分词函数的性能: 单进程,100万商品标题分词,耗时13秒
以上时间只包括分词时间,不包括词典载入时间。但在本方案中,词典只载入一次,所以载入词典时间可以忽略(1秒左右)
3:PHP比cat慢 (这结论有点多余了,呵呵)
语言层面慢: (24.037 – 1.8 – 14.819) / 14.819 = 50%
单进程对比测试的话,应该不会有哪个语言比cat更快。
相关问题:
1:以上Golang源码中写的是一个循环,也就是会一直从管道中读数据。那么存在一个问题:是不是php进程结束后,Golang的进程还会一直存在?
管道机制自身可解决此问题。管道提供两个接口:读、写。当写进程结束或者意外挂掉时,读进程也会报错,以上Golang源代码中的err逻辑就会执行,Golang进程结束。
但如果PHP进程没有结束,只是暂时没有数据传入,此时Golang进程会一直等待。直到php结束后,Golang进程才会自动结束。
2:能否多个php进程并行读写同一个管道,Golang进程同时为其服务?
不可以。管道是单向的,如果多个进程同时向管道中写,那Golang的返回值就会错乱。
可以多开几个Golang进程实现,每个php进程对应一个Golang进程。
最后,上面都是瞎扯的。如果你了解管道、双向管道,上面的解释对你基本没啥用。但如果你不了解管道,调试上面的代码没问题,但稍有修改就有可能掉坑里。
iris 真的是最快的Golang 路由框架吗
对各种Go http路由框架的比较, Iris明显胜出,它的性能远远超过其它Golang http路由框架。
但是,在真实的环境中,Iris真的就是最快的Golang http路由框架吗?
Benchmark测试分析
在那篇文章中我使用的是Julien Schmidt的 测试代码,他模拟了静态路由、Github API、Goolge+ API、Parse API的各种情况,因为这些API是知名网站的开放的API,看起来测试挺真实可靠的。
但是,这个测试存在着一个严重的问题,就是Handler的业务逻辑非常的简单,各个框架的handler类似,比如Iris的Handler的实现:
funcirisHandler(_ *iris.Context) {}funcirisHandlerWrite(c *iris.Context) { io.WriteString(c.ResponseWriter, c.Param(“name”))}funcirisHandlerTest(c *iris.Context) { io.WriteString(c.ResponseWriter, c.Request.RequestURI)}
几乎没有任何的业务逻辑,最多是往Response中写入一个字符串。
这和生产环境中的情况严重不符!
实际的产品肯定会有一些业务的处理,比如参数的校验,数据的计算,本地文件的读取、远程服务的调用、缓存的读取、数据库的读取和写入等,有些操作可能花费的时间很多,一两个毫秒就可以搞定,有的却很耗时,可能需要几十毫秒,比如:
从一个网络连接中读取数据 写数据到硬盘中 调用其它服务,等待服务结果的返回 ……
这才是我们常用的case,而不是一个简单的写字符串。
因此那个测试框架的Handler还应该加入时间花费的情况。
模拟真实的Handler的情况
我们模拟一下真实的情况,看看Iris框架和Golang内置的Http路由框架的性能如何。
首先使用Iris实现一个Http Server:
packagemainimport(“os””strconv””time””github.com/kataras/iris”)funcmain() { api := iris.New() api.Get(“/rest/hello”,func(c *iris.Context) { sleepTime, _ := strconv.Atoi(os.Args[1])ifsleepTime 0{ time.Sleep(time.Duration(sleepTime) * time.Millisecond) } c.Text(“Hello world”) }) api.Listen(“:8080”)}
我们可以传递给它一个时间花费的参数sleepTime,模拟这个Handler在处理业务时要花费的时间,它会让处理这个Handler的暂停sleepTime毫秒,如果为0,则不需要暂停,这种情况类似上面的测试。
然后我们使用Go内置的路由功能实现一个Http Server:
packagemainimport(“log””net/http””os””strconv””time”)// There are some golang RESTful libraries and mux libraries but i use the simplest to test.funcmain() { http.HandleFunc(“/rest/hello”,func(w http.ResponseWriter, r *http.Request) { sleepTime, _ := strconv.Atoi(os.Args[1])ifsleepTime 0{ time.Sleep(time.Duration(sleepTime) * time.Millisecond) } w.Write([]byte(“Hello world”)) }) err := http.ListenAndServe(“:8080”,nil)iferr !=nil{ log.Fatal(“ListenAndServe: “, err) }}
编译两个程序进行测试。
1、首先进行业务逻辑时间花费为0的测试
运行程序 iris 0,然后执行 wrk -t16 -c100 -d30s 进行并发100,持续30秒的测试。
iris的吞吐率为46155 requests/second。
运行程序 gomux 0,然后执行 wrk -t16 -c100 -d30s 进行并发100,持续30秒的测试。
Go内置的路由程序的吞吐率为55944 requests/second。
两者的吞吐量差别不大,iris略差一点
2、然后进行业务逻辑时间花费为10的测试
运行程序 iris 10,然后执行 wrk -t16 -c100 -d30s 进行并发100,持续30秒的测试。
iris的吞吐率为97 requests/second。
运行程序 gomux 10,然后执行 wrk -t16 -c100 -d30s 进行并发100,持续30秒的测试。
Go内置的路由程序的吞吐率为9294 requests/second。
3、最后进行业务逻辑时间花费为1000的测试
这次模拟一个极端的情况,业务处理很慢,处理一个业务需要1秒的时间。
运行程序 iris 1000,然后执行 wrk -t16 -c100 -d30s 进行并发100,持续30秒的测试。
iris的吞吐率为1 requests/second。
运行程序 gomux 1000,然后执行 wrk -t16 -c100 -d30s 进行并发100,持续30秒的测试。
Go内置的路由程序的吞吐率为95 requests/second。
可以看到,如果加上业务逻辑的处理时间,Go内置的路由功能要远远好于Iris, 甚至可以说Iris的路由根本无法应用的有业务逻辑的产品中,随着业务逻辑的时间耗费加大,iris的吞吐量急剧下降。
而对于Go的内置路由来说,业务逻辑的时间耗费加大,单个client会等待更长的时间,但是并发量大的网站来说,吞吐率不会下降太多。
比如我们用1000的并发量测试 gomux 10和 gomux 1000。
gomux 10: 吞吐率为47664 gomux 1000: 吞吐率为979
这才是Http网站真实的情况,因为我们要应付的网站的并发量,网站应该支持同时有尽可能多的用户访问,即使单个用户得到返回页面需要上百毫秒也可以接受。
而Iris在业务逻辑的处理时间增大的情况下,无法支持大的吞吐率,即使在并发量很大的情况下(比如1000),吞吐率也很低。
深入了解Go http server的实现
Go http server实现的是每个request对应一个goroutine (goroutine per request), 考虑到Http Keep-Alive的情况,更准确的说是每个连接对应一个goroutine(goroutine per connection)。
因为goroutine是非常轻量级的,不会像Java那样 Thread per request会导致服务器资源不足,无法创建很多的Thread, Golang可以创建足够多的goroutine,所以goroutine per request的方式在Golang中没有问题。而且这还有一个好处,因为request是在一个goroutine中处理的,不必考虑对同一个Request/Response并发读写的问题。
如何查看Handler是在哪一个goroutine中执行的呢?我们需要实现一个函数来获取goroutine的Id:
funcgoID()int{varbuf[64]byte n := runtime.Stack(buf[:], false) idField := strings.Fields(strings.TrimPrefix(string(buf[:n]),”goroutine “))[0] id, err := strconv.Atoi(idField)iferr !=nil{panic(fmt.Sprintf(“cannot get goroutine id: %v”, err)) }returnid}
然后在handler中打印出当前的goroutine id:
func(c *iris.Context) { fmt.Println(goID()) ……}
和
func(w http.ResponseWriter, r *http.Request) { fmt.Println(goID()) ……}
启动 gomux 0,然后运行 ab -c 5 -n 5 测试一下,apache的ab命令使用5个并发并且每个并发两个请求访问服务器。
可以看到服务器的输出:
因为没有指定 -k参数,每个client发送两个请求会创建两个连接。
你可以加上 -k参数,可以看出会有重复的goroutine id出现,表明同一个持久连接会使用同一个goroutine处理。
以上是通过实验验证我们的理论,下面是代码分析。
net/http/server.go的 第2146行 go c.serve()表明,对于一个http连接,会启动一个goroutine:
func(srv *Server) Serve(l net.Listener) error {deferl.Close()iffn := testHookServerServe; fn !=nil{ fn(srv, l) }vartempDelay time.Duration// how long to sleep on accept failureiferr := srv.setupHTTP2(); err !=nil{returnerr }for{ rw, e := l.Accept() …… tempDelay =0 c := srv.newConn(rw) c.setState(c.rwc, StateNew) // before Serve can returngoc.serve() }}
而这个 c.serve方法会从连接中 读取request交由handler处理:
func(c *conn) serve() { ……for{ w, err := c.readRequest() …… req := w.req serverHandler{c.server}.ServeHTTP(w, w.req)ifc.hijacked() {return } w.finishRequest()if!w.shouldReuseConnection() {ifw.requestBodyLimitHit || w.closedRequestBodyEarly() { c.closeWriteAndWait() }return } c.setState(c.rwc, StateIdle) }}
而 ServeHTTP的实现如下,如果没有配置handler或者路由器,则使用缺省的 DefaultServeMux。
func(sh serverHandler) ServeHTTP(rw ResponseWriter, req *Request) { handler := sh.srv.Handlerifhandler ==nil{ handler = DefaultServeMux }ifreq.RequestURI ==”*” req.Method ==”OPTIONS”{ handler = globalOptionsHandler{} } handler.ServeHTTP(rw, req)}
可以看出这里并没有新开goroutine,而是在同一个connection对应的goroutine中执行的。如果试用Keep-Alive,还是在这个connection对应的goroutine中执行。
正如注释中所说的那样:
// HTTP cannot have multiple simultaneous active requests.[*] // Until the server replies to this request, it can’t read another, // so we might as well run the handler in this goroutine. // [*] Not strictly true: HTTP pipelining. We could let them all process // in parallel even if their responses need to be serialized. serverHandler{c.server}.ServeHTTP(w, w.req)
因此业务逻辑的时间花费会影响单个goroutine的执行时间,并且反映到客户的浏览器是是延迟时间latency增大了,如果并发量足够多,影响的是系统中的goroutine的数量以及它们的调度,吞吐率不会剧烈影响。
Iris的分析
如果你使用Iris查看每个Handler是使用哪一个goroutine执行的,会发现每个连接也会用不同的goroutine执行,可是性能差在哪儿呢?
或者说,是什么原因导致Iris的性能急剧下降呢?
Iris服务器的监听和为连接启动一个goroutine没有什么明显不同,重要的不同在与Router处理Request的逻辑。
原因在于Iris为了提供性能,缓存了context,对于相同的请求url和method,它会从缓存中使用相同的context。
func(r *MemoryRouter) ServeHTTP(res http.ResponseWriter, req *http.Request) {ifctx := r.cache.GetItem(req.Method, req.URL.Path); ctx !=nil{ ctx.Redo(res, req)return } ctx := r.getStation().pool.Get().(*Context) ctx.Reset(res, req)ifr.processRequest(ctx) {//if something found and served then add it’s clone to the cache r.cache.AddItem(req.Method, req.URL.Path, ctx.Clone()) } r.getStation().pool.Put(ctx)}
由于并发量较大的时候,多个client的请求都会进入到上面的 ServeHTTP方法中,导致相同的请求会进入下面的逻辑:
ifctx := r.cache.GetItem(req.Method, req.URL.Path); ctx !=nil{ ctx.Redo(res, req)return}
ctx.Redo(res, req)导致不断循环,直到每个请求处理完毕,将context放回到池子中。
所以对于Iris来说,并发量大的情况下,对于相同的请求(req.URL.Path和Method相同)会进入排队的状态,导致性能低下。
帮我看看这代码是不是zend加密的?该如何解密?
//没有具体调试,中间有个别乱字符,反正这样已经可以看清楚很多了,你自己再细看,细改
?php
/*********************/
/* */
/* Version : 5.1.0 */
/* Author : RM */
/* Comment : 071223 */
/* */
/*********************/
function _obfuscate_cWwfD2UGW3ZycCZxCmQZE2Vd( )
{
global $skyuc;
$_obfuscate_fMfssw = array( );
$_obfuscate_3y0Y = “SELECT user_id, user_name, email, join_time, last_time FROM “.TABLE_PREFIX.”admin ORDER BY user_id DESC”;
$_obfuscate_fMfssw = array( );
$_obfuscate_TZ9ZmTEoi3QY5E = $skyuc-db-_obfuscate_O2QPeG5mYRBuO18BfwU9Ew( $_obfuscate_3y0Y );
while ( $_obfuscate_gkt = $skyuc-db-fetch_array( $_obfuscate_TZ9ZmTEoi3QY5E ) )
{
$_obfuscate_gkt[‘join_time’] = _obfuscate_ej0lcF0vcgh5bw( $skyuc-options[‘date_format’].” “.$skyuc-options[‘time_format’], $_obfuscate_gkt[‘join_time’], FALSE, FALSE );
$_obfuscate_gkt[‘last_time’] = _obfuscate_ej0lcF0vcgh5bw( $skyuc-options[‘date_format’].” “.$skyuc-options[‘time_format’], $_obfuscate_gkt[‘last_time’], FALSE, FALSE );
$_obfuscate_fMfssw[] = $_obfuscate_gkt;
}
$skyuc-db-free_result( $_obfuscate_TZ9ZmTEoi3QY5E );
return $_obfuscate_fMfssw;
}
require( dirname( __FILE__ ).”/global.php” );
if ( empty( $skyuc-GPC[‘act’] ) )
{
$skyuc-GPC[‘act’] = “login”;
}
$exc = new _l8o1a75( TABLE_PREFIX.”admin”, $skyuc-db, “user_id”, “user_name” );
if ( $skyuc-GPC[‘act’] == “logout” )
{
_obfuscate_AVxyeGtkKBUndG44YXlm( “cpsession”, “”, FALSE, TRUE, TRUE );
_obfuscate_AVxyeGtkKBUndG44YXlm( “adminid”, “”, FALSE, TRUE, TRUE );
_obfuscate_AVxyeGtkKBUndG44YXlm( “admin_pass”, “”, FALSE, TRUE, TRUE );
$db-_obfuscate_dDtscngYEGltXHg( “DELETE FROM “.TABLE_PREFIX.”cpsession WHERE adminid = “.$skyuc-session-vars[‘adminid’].” AND hash = ‘”.$db-escape_string( $skyuc-GPC[COOKIE_PREFIX.”cpsession”] ).”‘” );
$skyuc-session-_obfuscate_JiMofFtzGWM2GB1ybjYT( );
if ( !empty( $skyuc-session-vars[‘sessionurl_js’] ) )
{
_obfuscate_BgwNNztob2cEdgwmG3oHPxERCyA( “privilege.php?act=login”.$skyuc-session-vars[‘sessionurl_js’] );
}
else
{
_obfuscate_BgwNNztob2cEdgwmG3oHPxERCyA( “privilege.php?act=login” );
}
}
if ( $skyuc-GPC[‘act’] == “login” )
{
if ( intval( $skyuc-options[‘humanverify’] ) HV_ADMIN )
{
require_once( DIR.”/includes/class_humanverify.php” );
$verification = u18a5lewy4k::_obfuscate_YyRoZG8idX94DhEyEg( $skyuc );
$human_verify = $verification-_obfuscate_CHYdBnR5FGEsHGx1CGg( );
$smarty-assign( “humanverify”, $human_verify );
}
$smarty-assign( “sessionhash”, $skyuc-session-vars[‘dbsessionhash’] );
$smarty-assign( “scriptpath”, $skyuc-scriptpath );
$smarty-assign( “securitytoken”, $skyuc-userinfo[‘securitytoken’] );
$smarty-_obfuscate_E2Iicm4fNA( “login.tpl” );
}
if ( $skyuc-GPC[‘act’] == “signin” )
{
$skyuc-input-_obfuscate_c3sMXXFzZBIkeW94aV0X( “p”, array(
“username” = TYPE_STR,
“password” = TYPE_STR,
“humanverify” = TYPE_ARRAY_STR
) );
if ( !empty( $skyuc-GPC[‘humanverify’] ) )
{
require_once( DIR.”/includes/class_humanverify.php” );
$verify = u18a5lewy4k::_obfuscate_YyRoZG8idX94DhEyEg( $skyuc );
if ( !$verify-_obfuscate_dnNrf2kdfhMLBSg4( $skyuc-GPC[‘humanverify’] ) )
{
_obfuscate_Xmd6d3IbBg( $_LANG[‘captcha_error’], 1 );
}
}
$sql = “SELECT user_id, user_name, password, action_list, last_time\n \t\t\t\tFROM “.TABLE_PREFIX.”admin\n \t\t\t WHERE user_name = ‘”.$db-escape_string( $skyuc-GPC[‘username’] ).”‘ AND password = ‘”.md5( $skyuc-GPC[‘password’] ).”‘”;
$row = $skyuc-db-_obfuscate_bmdgO2klIzAaOXF6J3oLJ3o( $sql );
if ( $row )
{
define( “NOSHUTDOWNFUNC”, 1 );
_obfuscate_N3MES84AxZjNWF7L1sTZSo( $row[‘user_id’], $row[‘user_name’], $row[‘action_list’], $row[‘last_time’] );
$cpsession = $skyuc-session-_obfuscate_dy4_P3JxJiBmcGg9GW40Gnk( );
$skyuc-db-_obfuscate_dDtscngYEGltXHg( “INSERT INTO “.TABLE_PREFIX.”cpsession (adminid, hash, dateline) VALUES (“.$row[‘user_id’].”, ‘”.$skyuc-db-escape_string( $cpsession ).”‘, “.TIMENOW.”)” );
_obfuscate_AVxyeGtkKBUndG44YXlm( “cpsession”, $cpsession, FALSE, TRUE, TRUE );
$skyuc-db-query( “UPDATE “.TABLE_PREFIX.”admin SET last_time=”.TIMENOW.”, last_ip='”.ALT_IP.”‘ WHERE user_id=”.$row[‘user_id’] );
if ( empty( $skyuc-GPC[COOKIE_PREFIX.”adminid”] ) )
{
_obfuscate_AVxyeGtkKBUndG44YXlm( “adminid”, $row[‘user_id’], TRUE, TRUE, TRUE );
_obfuscate_AVxyeGtkKBUndG44YXlm( “admin_pass”, md5( $row[‘password’].COOKIE_SALT ), FALSE, TRUE, TRUE );
}
_obfuscate_BgwNNztob2cEdgwmG3oHPxERCyA( “index.php” );
}
else
{
include_once( DIR.”/includes/functions_log_error.php” );
log_skyuc_error( $skyuc-GPC[‘username’], “security” );
_obfuscate_Xmd6d3IbBg( $_LANG[‘login_faild’], 1 );
}
}
else if ( $skyuc-GPC[‘act’] == “list” )
{
$smarty-assign( “ur_here”, $_LANG[’03_admin_list’] );
$smarty-assign( “action_link”, array(
“href” = “privilege.php?act=add”,
“text” = $_LANG[’02_admin_add’]
) );
$smarty-assign( “full_page”, 1 );
$smarty-assign( “admin_list”, _obfuscate_cWwfD2UGW3ZycCZxCmQZE2Vd( ) );
_obfuscate_HDx0NH9rBGYePDsiYiMoHhI( );
$smarty-_obfuscate_E2Iicm4fNA( “privilege_list.tpl” );
}
else if ( $skyuc-GPC[‘act’] == “query” )
{
$smarty-assign( “admin_list”, _obfuscate_cWwfD2UGW3ZycCZxCmQZE2Vd( ) );
_obfuscate_e3YWEXZncjJtExFsOAQaNA( $smarty-fetch( “privilege_list.tpl” ) );
}
else if ( $skyuc-GPC[‘act’] == “add” )
{
_obfuscate_LWNyCzttbwgWJw( “admin_manage” );
$smarty-assign( “ur_here”, $_LANG[’02_admin_add’] );
$smarty-assign( “action_link”, array(
“href” = “privilege.php?act=list”,
“text” = $_LANG[’03_admin_list’]
) );
$smarty-assign( “form_act”, “insert” );
$smarty-assign( “action”, “add” );
_obfuscate_HDx0NH9rBGYePDsiYiMoHhI( );
$smarty-_obfuscate_E2Iicm4fNA( “privilege_info.tpl” );
}
else if ( $skyuc-GPC[‘act’] == “insert” )
{
_obfuscate_LWNyCzttbwgWJw( “admin_manage” );
$skyuc-input-_obfuscate_c3sMXXFzZBIkeW94aV0X( “p”, array(
“user_name” = TYPE_STR,
“email” = TYPE_STR,
“password” = TYPE_STR
) );
if ( $skyuc-GPC_exists[‘user_name’] )
{
$is_only = $exc-_obfuscate_Bn00DmVndg( “user_name”, $skyuc-GPC[‘user_name’] );
if ( !$is_only )
{
_obfuscate_Xmd6d3IbBg( sprintf( $_LANG[‘user_name_exist’], $skyuc-GPC[‘user_name’] ), 1 );
}
}
if ( $skyuc-GPC_exists[’email’] )
{
$is_only = $exc-_obfuscate_Bn00DmVndg( “email”, $skyuc-GPC[’email’] );
if ( !$is_only )
{
_obfuscate_Xmd6d3IbBg( sprintf( $_LANG[’email_exist’], $skyuc-GPC[’email’] ), 1 );
}
}
$join_time = TIMENOW;
$password = md5( $skyuc-GPC[‘password’] );
$sql = “INSERT INTO “.TABLE_PREFIX.”admin (user_name, email, password, join_time) VALUES (‘”.$skyuc-GPC[‘user_name’].”‘, ‘”.$skyuc-GPC[’email’].( “‘, ‘”.$password.”‘, ‘{$join_time}’)” );
$skyuc-db-_obfuscate_dDtscngYEGltXHg( $sql );
$new_id = $skyuc-db-insert_id( );
$link[0][‘text’] = $_LANG[‘go_allot_priv’];
$link[0][‘href’] = “privilege.php?act=allotid=”.$new_id.”user=”.$skyuc-GPC[‘user_name’].””;
$link[1][‘text’] = $_LANG[‘continue_add’];
$link[1][‘href’] = “privilege.php?act=add”;
_obfuscate_Xmd6d3IbBg( $_LANG[‘add’].” “.$skyuc-GPC[‘user_name’].” “.$_LANG[‘action_succeed’], 0, $link );
admin_log( $skyuc-GPC[‘user_name’], “add”, “privilege” );
}
else if ( $skyuc-GPC[‘act’] == “edit” )
{
$admin_name = _obfuscate_BxJtK280anUHKGwyLH5zeRUSYTw( $skyuc-session-vars[‘adminid’].”_admin_name” );
if ( $admin_name == “demo” )
{
$link[] = array(
“text” = $_LANG[‘back_list’],
“href” = “privilege.php?act=list”
);
_obfuscate_Xmd6d3IbBg( $_LANG[‘edit_admininfo_cannot’], 0, $link );
}
$id = $skyuc-input-_obfuscate_ZAo_ZCRcNAhk( “r”, “id”, TYPE_UINT );
if ( $skyuc-session-vars[‘adminid’] !== $id )
{
_obfuscate_LWNyCzttbwgWJw( “admin_manage” );
}
$sql = “SELECT user_id, user_name, email, password FROM “.TABLE_PREFIX.”admin WHERE user_id = ‘”.$id.”‘”;
$user_info = $skyuc-db-_obfuscate_bmdgO2klIzAaOXF6J3oLJ3o( $sql );
$smarty-assign( “ur_here”, $_LANG[‘admin_edit’] );
$smarty-assign( “action_link”, array(
“text” = $_LANG[’03_admin_list’],
“href” = “privilege.php?act=list”
) );
$smarty-assign( “user”, $user_info );
$smarty-assign( “form_act”, “update” );
$smarty-assign( “action”, “edit” );
_obfuscate_HDx0NH9rBGYePDsiYiMoHhI( );
$smarty-_obfuscate_E2Iicm4fNA( “privilege_info.tpl” );
}
else if ( $skyuc-GPC[‘act’] == “update” )
{
_obfuscate_LWNyCzttbwgWJw( “admin_manage” );
$admin_id = $skyuc-input-_obfuscate_ZAo_ZCRcNAhk( “p”, “id”, TYPE_UINT );
$admin_name = $skyuc-input-_obfuscate_ZAo_ZCRcNAhk( “p”, “user_name”, TYPE_STR );
$admin_email = $skyuc-input-_obfuscate_ZAo_ZCRcNAhk( “p”, “email”, TYPE_STR );
$skyuc-input-_obfuscate_c3sMXXFzZBIkeW94aV0X( “p”, array(
“nav_list” = TYPE_ARRAY_STR,
“new_password” = TYPE_STR,
“pwd_confirm” = TYPE_STR,
“old_password” = TYPE_STR
) );
$nav_list = _obfuscate_fRE5( !empty( $skyuc-GPC[‘nav_list’] ), “, nav_list = ‘”.@join( “,”, $skyuc-GPC[‘nav_list’] ).”‘”, “” );
$password = _obfuscate_fRE5( !empty( $skyuc-GPC[‘new_password’] ), “, password = ‘”.md5( $skyuc-GPC[‘new_password’] ).”‘”, “” );
if ( !empty( $admin_name ) )
{
$is_only = $exc-num( “user_name”, $admin_name, $admin_id );
if ( $is_only == 1 )
{
_obfuscate_Xmd6d3IbBg( sprintf( $_LANG[‘user_name_exist’], $admin_name ), 1 );
}
}
if ( !empty( $admin_email ) )
{
$is_only = $exc-num( “email”, $admin_email, $admin_id );
if ( $is_only == 1 )
{
_obfuscate_Xmd6d3IbBg( sprintf( $_LANG[’email_exist’], $admin_email ), 1 );
}
}
$pwd_modified = FALSE;
if ( !empty( $skyuc-GPC[‘new_password’] ) )
{
$sql = “SELECT password FROM “.TABLE_PREFIX.”admin”.( ” WHERE user_id = ‘”.$admin_id.”‘” );
$row = $skyuc-db-_obfuscate_bmdgO2klIzAaOXF6J3oLJ3o( $sql );
$old_password = $row[‘password’];
if ( $old_password != md5( $skyuc-GPC[‘old_password’] ) )
{
$link[] = array(
“text” = $_LANG[‘go_back’],
“href” = “javascript:history.back(-1)”
);
_obfuscate_Xmd6d3IbBg( $_LANG[‘pwd_error’], 0, $link );
}
if ( $skyuc-GPC[‘new_password’] != $skyuc-GPC[‘pwd_confirm’] )
{
$link[] = array(
“text” = $_LANG[‘go_back’],
“href” = “javascript:history.back(-1)”
);
_obfuscate_Xmd6d3IbBg( $_LANG[‘js_languages’][‘password_error’], 0, $link );
}
else
{
$pwd_modified = TRUE;
}
}
$sql = “UPDATE “.TABLE_PREFIX.”admin”.( ” SET user_name = ‘”.$admin_name.”‘, email = ‘{$admin_email}’ \t{$password} \t{$nav_list} ” ).” WHERE user_id =”.$admin_id;
$skyuc-db-_obfuscate_dDtscngYEGltXHg( $sql );
admin_log( $admin_name, “edit”, “privilege” );
if ( $pwd_modified )
{
$skyuc-db-_obfuscate_dDtscngYEGltXHg( “DELETE FROM “.TABLE_PREFIX.”session WHERE adminid = ‘”.$skyuc-session-vars[‘adminid’].”‘” );
$msg = $_LANG[‘edit_password_succeed’];
}
else
{
$msg = $_LANG[‘edit_profile_succeed’];
}
$link[] = array(
“text” = $_LANG[‘back_admin_list’],
“href” = “privilege.php?act=list”
);
_obfuscate_Xmd6d3IbBg( $_LANG[‘edit’].”{$msg}scriptparent.document.getElementById(‘header-frame’).contentWindow.document.location.reload();/script”, 0, $link );
}
else if ( $skyuc-GPC[‘act’] == “modif” )
{
$admin_name = _obfuscate_BxJtK280anUHKGwyLH5zeRUSYTw( $skyuc-session-vars[‘adminid’].”_admin_name” );
if ( $admin_name == “demo” )
{
$link[] = array(
“text” = $_LANG[‘back_admin_list’],
“href” = “privilege.php?act=list”
);
_obfuscate_Xmd6d3IbBg( $_LANG[‘edit_admininfo_cannot’], 0, $link );
}
include_once( ADM.”/inc_menu.php” );
foreach ( $modules as $key = $value )
{
ksort( $modules[$key] );
}
ksort( $modules );
foreach ( $modules as $key = $val )
{
$menus[$key][‘label’] = $_LANG[$key];
if ( is_array( $val ) )
{
foreach ( $val as $k = $v )
{
$menus[$key][‘children’][$k][‘label’] = $_LANG[$k];
$menus[$key][‘children’][$k][‘action’] = $v;
}
}
else
{
$menus[$key][‘action’] = $val;
}
}
$sql = “SELECT user_id, user_name, email, nav_list FROM “.TABLE_PREFIX.”admin WHERE user_id = “.$skyuc-session-vars[‘adminid’];
$user_info = $skyuc-db-_obfuscate_bmdgO2klIzAaOXF6J3oLJ3o( $sql );
$nav_arr = trim( $user_info[‘nav_list’] ) == “” ? array( ) : explode( “,”, $user_info[‘nav_list’] );
$nav_lst = array( );
foreach ( $nav_arr as $val )
{
$arr = explode( “|”, $val );
$nav_lst[$arr[1]] = $arr[0];
}
$smarty-assign( “lang”, $_LANG );
$smarty-assign( “ur_here”, $_LANG[‘modif_info’] );
$smarty-assign( “action_link”, array(
“text” = $_LANG[’03_admin_list’],
“href” = “privilege.php?act=list”
) );
$smarty-assign( “user”, $user_info );
$smarty-assign( “menus”, $modules );
$smarty-assign( “nav_arr”, $nav_lst );
$smarty-assign( “form_act”, “update” );
$smarty-assign( “action”, “modif” );
_obfuscate_HDx0NH9rBGYePDsiYiMoHhI( );
$smarty-_obfuscate_E2Iicm4fNA( “privilege_info.tpl” );
}
else if ( $skyuc-GPC[‘act’] == “allot” )
{
require( DIR.”/languages/”.$skyuc-options[‘lang’].”/admincp/priv_action.php” );
_obfuscate_LWNyCzttbwgWJw( “allot_priv” );
$id = $skyuc-input-_obfuscate_ZAo_ZCRcNAhk( “g”, “id”, TYPE_UINT );
$priv_str = $skyuc-db-_obfuscate_aH8afmpdBnVfGWU( “SELECT action_list FROM “.TABLE_PREFIX.”admin WHERE user_id =”.$id.”” );
if ( $priv_str[‘action_list’] == “all” )
{
$link[] = array(
“text” = $_LANG[‘back_admin_list’],
“href” = “privilege.php?act=list”
);
_obfuscate_Xmd6d3IbBg( $_LANG[‘edit_admininfo_cannot’], 0, $link );
}
$sql = “SELECT action_id, parent_id, action_code FROM “.TABLE_PREFIX.”admin_action WHERE parent_id = 0”;
$res = $skyuc-db-_obfuscate_aSRoDjhcKmZdYQ( $sql );
while ( $rows = $skyuc-db-fetch_array( $res ) )
{
$priv_arr[$rows[‘action_id’]] = $rows;
}
$sql = “SELECT action_id, parent_id, action_code FROM “.TABLE_PREFIX.”admin_action WHERE parent_id “._obfuscate_XGMVcmkUDQNdjgN( array_keys( $priv_arr ) );
$result = $skyuc-db-_obfuscate_aSRoDjhcKmZdYQ( $sql );
while ( $priv = $skyuc-db-fetch_array( $result ) )
{
$priv_arr[$priv[‘parent_id’]][‘priv’][$priv[‘action_code’]] = $priv;
}
foreach ( $priv_arr as $action_id = $action_group )
{
$priv_arr[$action_id][‘priv_list’] = join( “,”, @array_keys( $action_group[‘priv’] ) );
foreach ( $action_group[‘priv’] as $key = $val )
{
$priv_arr[$action_id][‘priv’][$key][‘cando’] = strpos( $priv_str[‘action_list’], $val[‘action_code’] ) !== FALSE || $priv_str[‘action_list’] == “all” ? 1 : 0;
}
}
$smarty-assign( “lang”, $_LANG );
$smarty-assign( “ur_here”, $_LANG[‘allot_priv’].” [ “.$skyuc-input-_obfuscate_ZAo_ZCRcNAhk( “g”, “user”, TYPE_STR ).” ] ” );
$smarty-assign( “action_link”, array(
“href” = “privilege.php?act=list”,
“text” = $_LANG[’03_admin_list’]
) );
$smarty-assign( “priv_arr”, $priv_arr );
$smarty-assign( “form_act”, “update_allot” );
$smarty-assign( “user_id”, $id );
_obfuscate_HDx0NH9rBGYePDsiYiMoHhI( );
$smarty-_obfuscate_E2Iicm4fNA( “privilege_allot.tpl” );
}
else if ( $skyuc-GPC[‘act’] == “update_allot” )
{
_obfuscate_LWNyCzttbwgWJw( “admin_manage” );
$id = $skyuc-input-_obfuscate_ZAo_ZCRcNAhk( “p”, “id”, TYPE_UINT );
$admin = $skyuc-db-_obfuscate_aH8afmpdBnVfGWU( “SELECT user_name FROM “.TABLE_PREFIX.”admin”.( ” WHERE user_id = “.$id ) );
$admin_name = $admin[‘user_name’];
$act_list = @join( “,”, @$skyuc-input-_obfuscate_ZAo_ZCRcNAhk( “p”, “action_code”, TYPE_ARRAY_STR ) );
$sql = “UPDATE “.TABLE_PREFIX.”admin”.( ” SET action_list = ‘”.$act_list.”‘ ” ).( “WHERE user_id = “.$id );
$skyuc-db-_obfuscate_dDtscngYEGltXHg( $sql );
if ( $skyuc-session-vars[‘adminid’] === $id )
{
_obfuscate_LQIbX3kUIWEKfXozXGpyCTsSCmc( $id.”_action_list”, $act_list );
}
admin_log( $admin_name, “edit”, “privilege” );
$link[] = array(
“text” = $_LANG[‘back_admin_list’],
“href” = “privilege.php?act=list”
);
_obfuscate_Xmd6d3IbBg( $_LANG[‘edit’].” “.$admin_name.” “.$_LANG[‘action_succeed’], 0, $link );
}
else if ( $skyuc-GPC[‘act’] == “remove” )
{
_obfuscate_OCEuGngTZWJzGw1vZH4teg( “admin_manage” );
$id = $skyuc-input-_obfuscate_ZAo_ZCRcNAhk( “g”, “id”, TYPE_UINT );
$admin_name = $skyuc-db-_obfuscate_aH8afmpdBnVfGWU( “SELECT user_name FROM “.TABLE_PREFIX.”admin”.( ” WHERE user_id=”.$id ) );
if ( $admin_name == “demo” )
{
_obfuscate_fwJ5Cw8qQHY9W18_YXMp( $_LANG[‘edit_remove_cannot’] );
}
if ( $id == 1 )
{
_obfuscate_fwJ5Cw8qQHY9W18_YXMp( $_LANG[‘remove_cannot’] );
}
if ( $exc-drop( $id ) )
{
$skyuc-db-_obfuscate_dDtscngYEGltXHg( “DELETE FROM “.TABLE_PREFIX.( “session WHERE adminid =”.$id ) );
admin_log( $admin_name, “remove”, “privilege” );
}
$url = “privilege.php?act=query”.str_replace( “act=remove”, “”, $_SERVER[‘QUERY_STRING’] );
_obfuscate_BgwNNztob2cEdgwmG3oHPxERCyA( $url );
}
?
原创文章,作者:PRBM,如若转载,请注明出处:https://www.506064.com/n/135726.html