把SESSION放到memcache中[php][转]

 

本人在php5.3.8版试验,很easy,不需要额外代码,直接用下面php.ini的配置就行:

session.save_handler = memcache
#有多个时直接用”,”分隔即可,11211为memcached服务端守护进程端口,根据环境自行修改
session.save_path = ‘tcp://127.0.0.1:11211′


当然也可以直接在程序里面设置:

ini_set(‘session.save_handler’,'memcache’);
ini_set(‘session.save_path’,'tcp://127.0.0.1:11211′);

如果你是apache服务器话也可以在 .htaccess :

php_value session.save_handler “memcache”
php_value session.save_path “tcp://192.168.1.105:11211″

注意:因为 php的memcache扩展有两种,一种是php_memcache,一种是php_memcached,
如果你用的是php_memcached,save_handler的配置得变成如下形式:

php.ini:session.save_handler = memcached

程序中:ini_set(‘session.save_handler’,'memcached’);

使用过程中发现,用memcache存储session以后,nginx下如果memcachd没有启动的话,它会给报502的Error

友情提示:

session 数据都保存在 memory 中,不经过磁盘,数据库等,速度快。
可以多台机器共用一个/组memcached服务器,达到多台机器共享session信息,方便多机集群的session问题处理。至于session在集群时会遇到的问题请到下面的链接详看:
粘滞会话(Sticky Sessions)
http://www.xwuxin.com/?p=1958

memcached不支持持久化(这方面你可以考虑redis),但对于session 数据来说不算大问题。
由于memcached的内存管理机制,当session存储的数据超过1MB的时候有数据丢失问题。

 

转载自:http://www.xwuxin.com

php文件解密

//条件判断很重要,参考了别人的$pos = strpos($b, "'");
$b =gzinflate(base64_decode('加密代码'));
$a='test.php';
$c = 1;
while(strpos($b, "eval")){
$c+=1;
$pos = strpos($b, "'");
$b=substr($b, $pos + 1);
$b=trim(str_replace("' )) );","",$b));
$b=gzinflate(base64_decode($b));
}
echo '解密成功。次数:'.$c;
file_put_contents($a,$b);

 

加密的代码就不贴了 就是 base64+gzinflate加密

$.parseJSON(data)只支持标准的JSON

$.parseJSON()只支持标准的JSON,不标准的还是用eval("("+data+")")吧

什么 是标准的呢?

key和value都带引号的就是标准的;   而且必须是双引号,单引号也不行

string msg = "";
Model.Users currentUser;
string jsonStr = "";
//JavaScriptSerializer js = new JavaScriptSerializer();
bool result = bll.UserLogin(loginID, loginPwd, out msg, out currentUser);
if (!result) {
 jsonStr = "{\"result\":\"false\",\"msg\":\"" + msg + "\"}";
 context.Response.Write(jsonStr);
} else {
 //记录登陆成功的用户到Session中
 context.Session.Add("currUser", currentUser);

 if (string.IsNullOrEmpty(redirectUrl)) {
  jsonStr = "{\"result\":\"true\",\"msg\":\"OK\",\"redirect\":\"\"}";
  context.Response.Write(jsonStr);
 } else {
  jsonStr = "{\"result\":\"true\",\"msg\":\"OK\",\"redirect':\"" + context.Server.UrlDecode(redirectUrl) + "\"}";
  context.Response.Write(jsonStr);
 }
}

检验voucher异常

#检查voucher transfer之前voucher有无异常
SELECT *
FROM voucher a
LEFT JOIN voucher_action b ON(a.voucher_id = b.voucher_id)
LEFT JOIN voucher_campaign_issue c ON(a.voucher_id = c.voucher_id)
LEFT JOIN voucher_submission_error d ON(a.voucher_id = d.voucher_id)
WHERE a.status_id < 5
AND (
     a.issue_time IS NOT NULL
     OR a.expiry_time IS NOT NULL
     OR a.submission_id IS NOT NULL
     OR a.transfer_time IS NOT NULL
     OR a.transfer_channel IS NOT NULL
     OR b.id is not null
     OR c.id is not null
     OR d.error_id is not null
)

#检查voucher transfer之后voucher有无异常
SELECT *
FROM voucher a
LEFT JOIN voucher_action b ON(a.voucher_id = b.voucher_id)
LEFT JOIN voucher_campaign_issue c ON(a.voucher_id = c.voucher_id)
LEFT JOIN voucher_submission_error d ON(a.voucher_id = d.voucher_id)
WHERE a.status_id = 5
AND (
     a.issue_time IS NOT NULL
     OR a.expiry_time IS NOT NULL
     OR a.submission_id IS NOT NULL
     OR a.transfer_time IS NULL
     #OR a.transfer_channel IS NULL
     OR b.id is not null
     OR c.id is not null
     OR d.error_id is not null
)

#检查voucher issue之前是否有异常
SELECT a.voucher_id, CONCAT(a.prefix, a.voucher_no) AS voucher, b.id, c.campaign_id, d.error_id
FROM voucher a
LEFT JOIN voucher_action b ON (a.voucher_id = b.voucher_id)
LEFT JOIN voucher_campaign_issue c ON(a.voucher_id = c.voucher_id)
LEFT JOIN voucher_submission_error d ON(a.voucher_id = d.voucher_id)
WHERE a.status_id < 6 AND (b.id IS NOT NULL OR c.id IS NOT NULL OR d.error_id IS NOT NULL)

#检查voucher issue之后是否有异常
SELECT a.voucher_id, CONCAT(a.prefix, a.voucher_no) AS voucher, b.id, c.campaign_id, d.error_id
FROM voucher a
LEFT JOIN voucher_action b ON (a.voucher_id = b.voucher_id AND b.action_id = 6)
LEFT JOIN voucher_campaign_issue c ON(a.voucher_id = c.voucher_id)
LEFT JOIN voucher_submission_error d ON(a.voucher_id = d.voucher_id)
WHERE a.status_id = 6 AND (b.id IS NULL OR a.transfer_time IS NULL OR a.issue_time IS NULL OR a.expiry_time IS NULL OR a.transfer_channel IS NULL)


#检查tenant submit之后时候有异常
SELECT a.voucher_id, CONCAT(a.prefix, a.voucher_no) AS voucher, b.id, c.campaign_id, e.submission_id
FROM voucher a
LEFT JOIN voucher_action b ON (a.voucher_id = b.voucher_id and b.action_id = 8)
LEFT JOIN voucher_campaign_issue c ON(a.voucher_id = c.voucher_id)
LEFT JOIN voucher_store_submission e ON(a.submission_id = e.submission_id)
WHERE a.status_id = 7 AND (b.id IS NULL OR c.id IS NULL OR e.submission_id is NULL)


#检查reimburse之后voucher是否有异常
SELECT *
FROM voucher
WHERE status_id = 9
AND (
     transfer_time IS NULL
     OR issue_time IS null
     OR submission_time IS NULL
     OR expiry_time IS NULL
     OR transfer_channel IS NULL
     OR submission_id IS NULL
     OR reimburse_time IS NULL
     )
    

Evo Transfer涉及到的table

Evo Transfer涉及到的table

 

Voucher

Voucher_action

Voucher_batch_action

Voucher_campaign_issue

Voucher_info_transfer

 

Transfer to corporate sales

Voucher ——– Transfer_time(add),  Issue_time(add), expiry_time(add), status_id(2-6), transfer_channel(null-6)

Voucher_action ——– insert issue action

Voucher_batch_action ——– insert transfer record, insert issue record

Voucher_info_transfer  ——– insert info transfer record

 

Transfer to Event

Voucher ——– Transfer_time(add),  Issue_time(add), expiry_time(add), status_id(2-6), transfer_channel(null-7)

Voucher_action ——–insert issue action

Voucher_batch_action ——– insert transfer record, insert issue record

Voucher_info_transfer  ——– insert info transfer record

 

Transfer for Other Purpose

Voucher ——– Transfer_time(add),  Issue_time(add), expiry_time(add), status_id(2-6), transfer_channel(null-50)

Voucher_action ——–insert issue action

Voucher_batch_action ——– insert transfer record, insert issue record

Voucher_info_transfer  ——– insert info transfer record

 

Transfer to Customer Service

Voucher ——– Transfer_time(add),  Issue_time(null), expiry_time(null), status_id(2-5), transfer_channel(null)

Voucher_action ——–no insert issue action

Voucher_batch_action ——–insert transfer record, no insert issue record

Voucher_info_transfer  ——–insert info transfer record

 

 

 

 

 

Python的50个模块,满足你各种需要

Python具有强大的扩展能力,我列出了50个很棒的Python模块,包含几乎所有的需要:比如Databases,GUIs,Images, Sound, OS interaction, Web,以及其他。推荐收藏。 



Graphical interface wxPython http://wxpython.org   

Graphical interface pyGtk http://www.pygtk.org   

Graphical interface pyQT http://www.riverbankcomputing.co.uk/pyqt/   

Graphical interface Pmw http://pmw.sourceforge.net/   

Graphical interface Tkinter 3000 http://effbot.org/zone/wck.htm   

Graphical interface Tix http://tix.sourceforge.net/   

        

Database MySQLdb http://sourceforge.net/projects/mysql-python   

Database PyGreSQL http://www.pygresql.org/   

Database Gadfly http://gadfly.sourceforge.net/   

Database SQLAlchemy http://www.sqlalchemy.org/   

Database psycopg http://www.initd.org/pub/software/psycopg/   

Database kinterbasdb http://kinterbasdb.sourceforge.net/   

Database cx_Oracle http://www.cxtools.net/default.aspx?nav=downloads   

Database pySQLite http://initd.org/tracker/pysqlite   

        

MSN Messenger msnlib http://auriga.wearlab.de/~alb/msnlib/   

MSN Messenger pymsn http://telepathy.freedesktop.org/wiki/Pymsn   

MSN Messenger msnp http://msnp.sourceforge.net/   

Network Twisted http://twistedmatrix.com/   

Images PIL http://www.pythonware.com/products/pil/   

Images gdmodule http://newcenturycomputers.net/projects/gdmodule.html   

Images VideoCapture http://videocapture.sourceforge.net/   

        

Sciences and Maths scipy http://www.scipy.org/   

Sciences and Maths NumPy http://numpy.scipy.org/   

Sciences and Maths numarray http://www.stsci.edu/resources/software_hardware/numarray   

Sciences and Maths matplotlib http://matplotlib.sourceforge.net/   

        

Games Pygame http://www.pygame.org/news.html   

Games Pyglet http://www.pyglet.org/   

Games PySoy http://www.pysoy.org/   

Games pyOpenGL http://pyopengl.sourceforge.net/   

        

Jabber jabberpy http://jabberpy.sourceforge.net/   

        

Web scrape http://zesty.ca/python/scrape.html   

Web Beautiful Soup http://crummy.com/software/BeautifulSoup   

Web pythonweb http://www.pythonweb.org/   

Web mechanize http://wwwsearch.sourceforge.net/mechanize/   

        

Localisation geoname.py http://www.zindep.com/blog-zindep/Geoname-python/   

        

Serial port pySerial http://pyserial.sourceforge.net/   

Serial port USPP http://ibarona.googlepages.com/uspp   

        

Parallel Port pyParallel http://pyserial.sourceforge.net/pyparallel.html   

        

USB Port pyUSB http://bleyer.org/pyusb/   

        

Windows ctypes http://starship.python.net/crew/theller/ctypes/   

Windows pywin32 http://sourceforge.net/projects/pywin32/   

Windows pywinauto http://www.openqa.org/pywinauto/   

Windows pyrtf http://pyrtf.sourceforge.net/   

Windows wmi http://timgolden.me.uk/python/wmi.html   

        

PDA/GSM/Mobiles pymo http://www.awaretek.com/pymo.html   

PDA/GSM/Mobiles pyS60 http://sourceforge.net/projects/pys60   

        

Sound pySoundic http://pysonic.sourceforge.net/   

Sound pyMedia http://pymedia.org/   

Sound FMOD http://www.fmod.org/   

Sound pyMIDI http://www.cs.unc.edu/Research/assist/developer.shtml   

        

GMail libgmail http://libgmail.sourceforge.net/   

Google pyGoogle http://pygoogle.sourceforge.net/   

Expect pExpect http://pexpect.sourceforge.net/   

WordNet pyWordNet http://osteele.com/projects/pywordnet/   

Command line cmd http://blog.doughellmann.com/2008/05/pymotw-cmd.html   

Compiler backend llvm-py http://mdevan.nfshost.com/llvm-py/   

3D VPython http://vpython.org