作者归档:℃冻番茄

关注一下 Facebook 的 HipHop (能把php转成c++,太酷了)

目前HipHop还是试验性质的,据说FaceBook用它用了一年多了,很稳定,但是毕竟它本身就是做出来给facebook用的。还是非常的希望它能继续发展,能解决php作为脚本语言上的众多劣势!

HipHop的介绍

HipHop for PHP transforms PHP source code into highly optimized C++. It was developed by Facebook and was released as open source in early 2010.
HipHop transforms your PHP source code into highly optimized C++ and then compiles it with g++ to build binary files. You keep coding in simpler PHP, then HipHop executes your source code in a semantically equivalent manner and sacrifices some rarely used features – such as eval() – in exchange for improved performance.
Facebook sees about a 50% reduction in CPU usage when serving equal amounts of Web traffic when compared to Apache and PHP. Facebook’s API tier can serve twice the traffic using 30% less CPU.
Why HipHop
One of the explicit design goals leading into HipHop was the ability to continue writing complex logic directly within PHP. Companies with large PHP codebases will generally rewrite their complex functionality directly as PHP extensions in either C or C++. Doing so ends up reducing the number of people who are able to work on the company’s entire codebase. By keeping this logic in PHP, Facebook is able to move fast and maintain a high number of engineers who are able to work across the entire codebase.
HipHop is not the right solution for everyone deploying PHP. We think it will be useful to companies running very large PHP infrastructures who do not wish to rewrite complex logic within C or C++.

Using HipHopcheckout and build instructionsgit clone git://github.com/facebook/hiphop-php.gitHipHop currently supports PHP version 5.2 and will be updated to support 5.3. The software is open source and we hope that it’s useful to many companies around the World.You can learn more on Building and installing or Building and installing on Ubuntu 9.10. See Running HipHop to learn more about compiling your source code.
Discussion and supportYou can discuss HipHop for PHP and report bugs on the HipHop developer mailing list (or feel free to submit a Pull Request).The wiki content is licensed under Creative Commons Attribution-ShareAlike License
上面是Facebook上的资料,可能国内上不了 facebook,想要资料先翻墙吧~~

http://wiki.github.com/facebook/hiphop-php/

xpad网络便签本基本完工,开放注册及下载

感谢新浪云计算平台提供的云计算服务

官方地址:http://xpad.sinaapp.com

xpad客户端:http://xpad.sinaapp.com/xpad.zip

程序采用vs2008开发,windows7系统可直接安装,windows xp则还需安装.net framework 3.5

.net framework 3.5下载:点 击下载X86_XP&2003精简版离线安装包


项目动态

xpad web版完工,主要功能:查看、编辑及新建便签

xpad桌面版完工,主要功能:查看、编辑及新建便签

目前xpad因为工作原因,需要放一段时间,以后陆续增加新的功能及支持手机平台。

同时也欢迎大家一起来使用它,有好的建议及想法或是bug也请告之!

今天截取了一些软件图,供不知道xpad的朋友有一个大致的了解!

 

x1.png2.png3.png4.png5.png6.png7.png8.png9.png10.png

xpad程序正在开发中,敬请期待!

http://xpad.sinaapp.com/

目前已完成文档上传、文档本地保存、登陆这几个主要功能

接着要完成的功能:打开网上文档,编辑或删除操作,添加注册功能,打开本地文档,自动记录最新的10个本地文档位置,快速打开。

放的API
API编码:UTF-8
数据格式:JSON

登陆
http://xpad.sinaapp.com/index.php?m=api&a=login
数据提交模式:post (u为用户名,p为密码)
返回值 json格式{"status":0,"msg":"\u767b\u9646\u8d85…"} status为状态,1为登陆成功,写入session,0为登陆失败msg为出错信息

保存文档
http://xpad.sinaapp.com/index.php?m=api&a=save
数据提交模式:post (content为文档内容)
返回值 json格式{"status":0,"msg":"\u767b\u9646\u8d85…"} status为状态,status为1发布成功,写入session,status为0发布失败msg为出错信息,status为2,表示上文档没有改变

正在开发一个基于新浪云计算平台的网络便利贴应用

工作的流程是:

xpad客户端采用c#开发

xpad便利贴程序开机最小化启动,右下角显示ico程序图标

当双击右下角xpad图标启动便利贴程序,可以方便的进行记事、编辑操作

当记录结束时,点文件=》保存或是按下ctrl+s保存,或是每隔一段时间进行自动保存

xpad服务端采用新浪云计算平台 php开发

当xpad保存文档时,客户端能过类似web service方式与服务端通讯,提交数据。服务端则加密保存数据库中。

同样,当xpad点击打开文档时,自动从服务端读取已保存的文档日期及摘要,以供打开编辑

目前完成的工作:

xpad客户端界面及最小化右下角图标运行

把常用的原创框架移值到新浪云计算平台

主要的功能:

会员注册、客户端进行登陆、客户端操作便利贴、在web中进行便利贴的操作、开放api、准备开放手机端(android)

 

xpad.png

windows7 搭建android开发环境

下载安装jdk  android_sdk eclipse 这些都正常

但有一点,希望大家不要走弯路了,最后一步,新建avd虚拟机时,请不要在eclipse里进行新建,一定会出错。

需要在cmd里新建,并且注意指定路径,不指定avd路径也一样出错

命令是 本人android sdk安装在d盘

d:

cd android_sdk/tools

注意,先确定你要的版本,target是多少,本人的机器上target1为android 1.5

android create avd -n G3 -t 1 -p D:/g3

到这里,就正常了,折腾了一天了。

 

g3.png

Avira AntiVir(小红伞)今天正式发布简体中文版

http://www.avira.com/zh-cn/pages/index.php

让人期待已久的Avira AntiVir(小红伞)今天正式登陆中国啦,Avira AntiVir(小红伞)简体中文语言官方网站已上线!号称杀软鼻祖、德国质量的安全产品 Avira (小红伞)于3月30日在北京推出中文版杀毒软件,这标志着 Avira 正式进入中国市场。据称,诞生24年来 Avira 全球范围拥有1亿多忠诚用户,而在中国市场,Avira 被形象地称为小红伞。

免费版下载地址

http://www.free-av.com/

目前国内免费的中文杀软又增加了一款,以前用小红伞有几年,后来因为那个刺耳的报警音还有英文的界面改换avast!了。不过小红伞确实属于不错的产品,杀毒能力强,速度快!

apache添加虚拟主机及绑定域名免重启方案[转]

第一步:打开apache的配置文件httpd.conf,去掉LoadModule rewrite_module modules/mod_rewrite.so前面的#号。
第二步:打配置文件尾部加上
RewriteEngine on
RewriteMap lowercase int:tolower
#定义映像文件
RewriteMap vhost txt:/apache/vhost/vhost.map
#处理变名
RewriteCond %{REQUEST_URI} !^/icons/
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
#这里做基于文件的重新映射
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1
RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/cgi-bin/$1

注意:vhost.map文件是域名和空间映像的文件,格式如下: www.abc.com  /vhostusr/www.abc.com
(你不会连/vhostuser/www.abc.com目录也没建吧,会报错的哟)
第三步:保存配置文件,重启apache,以后建立域名时,只要在vhost.map文件里添加相应记录,并建立相应文件夹就OK了~~~
其实这个可以用php脚本来完成的,很简单的~~呵呵~~~

XML/HTML代码
  1. <html>  
  2. <head>  
  3. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
  4. <meta http-equiv="Content-Style-Type" content="text/css">  
  5. <link rel="top" href="index.cgi" title="" />  
  6. <link rel="search" href="search.php" title="" />  
  7. <link rel="help" href="faq.php" title="" />  
  8. <link rel="author" href="memberlist.php" title="" />  
  9.   
  10. <title>注册 – youname.sun126.com</title>  
  11.   
  12. <style type="text/css">  
  13. <!–  
  14. body {  
  15.         background-color: #FFFFFF;  
  16.         scrollbar-face-color: #DEE3E7;  
  17.         scrollbar-highlight-color: #FFFFFF;  
  18.         scrollbar-shadow-color: #DEE3E7;  
  19.         scrollbar-3dlight-color: #D1D7DC;  
  20.         scrollbar-arrow-color:  #;  
  21.         scrollbar-track-color: #EFEFEF;  
  22.         scrollbar-darkshadow-color: #98AAB1;  
  23. }  
  24. font,th,td,p { font-family: ‘song’,Verdana }  
  25. a:link,a:active,a:visited { color : #; }  
  26. a:hover                { text-decoration: underline; color : #DD6900; }  
  27. hr        { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;}  
  28. .bodyline        { background-color: #FFFFFF; border: 1px #98AAB1 solid; }  
  29. .forumline        { background-color: #000000; border: 0px #9898ba solid; }  
  30. td.row1        { background-color: #f0f3fa; }  
  31. td.row2        { background-color: #fafbfc; }  
  32. td.row3        { background-color: #D1D7DC; }  
  33. td.rowpic {  
  34.                 background-color: #D1D9E2;  
  35.                 background-repeat: repeat-y;  
  36. }  
  37. th        {  
  38.         color: #333333; font-size: 12px; font-weight : bold;  
  39.         background-color: #9898BA; height: 25px;  
  40.   
  41. td.cat,td.catHead,td.catSides,td.catLeft,td.catRight,td.catBottom {  
  42.                         background-color:#d1d9e2; border: #9898ba; border-style: solid; height: 28px;  
  43. }  
  44.   
  45. td.cat,td.catHead,td.catBottom {  
  46.         height: 29px;  
  47.         border-width: 0px 0px 0px 0px;  
  48. }  
  49. th.thHead,th.thSides,th.thTop,th.thLeft,th.thRight,th.thBottom,th.thCornerL,th.thCornerR {  
  50.         font-weight: bold; border: #FFFFFF; border-style: solid; height: 28px;  
  51. }  
  52. td.row3Right,td.spaceRow {  
  53.         background-color: #D1D7DC; border: #9898ba; border-style: solid;  
  54. }  
  55.   
  56. th.thHead,td.catHead { font-size: 13px; border-width: 1px 1px 0px 1px; }  
  57. th.thSides,td.catSides,td.spaceRow         { border-width: 0px 1px 0px 1px; }  
  58. th.thRight,td.catRight,td.row3Right         { border-width: 0px 1px 0px 0px; }  
  59. th.thLeft,td.catLeft          { border-width: 0px 0px 0px 1px; }  
  60. th.thBottom,td.catBottom  { border-width: 0px 1px 1px 1px; }  
  61. th.thTop         { border-width: 1px 0px 0px 0px; }  
  62. th.thCornerL { border-width: 1px 0px 0px 1px; }  
  63. th.thCornerR { border-width: 1px 1px 0px 0px; }  
  64. .maintitle        {  
  65.         font-weight: bold; font-size: 22px; font-family: "’song’,Verdana",’song’,Verdana;  
  66.         text-decoration: none; line-height : 120%; color : #;  
  67. }  
  68. .gen { font-size : 13px; }  
  69. .genmed { font-size : 12px; }  
  70. .gensmall { font-size : 12px; }  
  71. .gen,.genmed,.gensmall { color : #; }  
  72. a.gen,a.genmed,a.gensmall { color: #; text-decoration: none; }  
  73. a.gen:hover,a.genmed:hover,a.gensmall:hover        { color: #DD6900; text-decoration: underline; }  
  74.   
  75. /* The register, login, search etc links at the top of the page */  
  76. .mainmenu                { font-size : 12px; color : # }  
  77. a.mainmenu                { text-decoration: none; color : #;  }  
  78. a.mainmenu:hover{ text-decoration: underline; color : #DD6900; }  
  79.   
  80. /* Forum category titles */  
  81. .cattitle                { font-weight: bold; font-size: 13px ; letter-spacing: 1px; color : #}  
  82. a.cattitle                { text-decoration: none; color : #; }  
  83. a.cattitle:hover{ text-decoration: underline; }  
  84.   
  85. /* Forum title: Text and link to the forums used in: index.cgi */  
  86. .forumlink                { font-weight: bold; font-size: 13px; color : #; }  
  87. a.forumlink         { text-decoration: none; color : #; }  
  88. a.forumlink:hover{ text-decoration: underline; color : #DD6900; }  
  89.   
  90. /* Used for the navigation text, (Page 1,2,3 etc) and the navigation bar when in a forum */  
  91. .nav                        { font-weight: bold; font-size: 12px; color : #;}  
  92. a.nav                        { text-decoration: none; color : #; }  
  93. a.nav:hover                { text-decoration: underline; }  
  94.   
  95. /* titles for the topics: could specify viewed link colour too */  
  96. .topictitle       {font-size: 12px; color : #; }  
  97. h1,h2       { font-weight: bold; font-size: 12px; color : #; }  
  98. a.topictitle:link   { text-decoration: none; color : #; }  
  99. a.topictitle:visited { text-decoration: none; color : #333333; }  
  100. a.topictitle:hover        { text-decoration: underline; color : #DD6900; }  
  101.   
  102. /* Name of poster in viewmsg.php and viewtopic.php and other places */  
  103. .name                        { font-size : 12px; color : #;}  
  104.   
  105. /* Location, number of posts, post date etc */  
  106. .postdetails                { font-size : 12px; color : #; }  
  107.   
  108. /* The content of the posts (body of text) */  
  109. .postbody { font-size : 13px; line-height: 18px}  
  110. a.postlink:link        { text-decoration: none; color : # }  
  111. a.postlink:visited { text-decoration: none; color : #333333; }  
  112. a.postlink:hover { text-decoration: underline; color : #DD6900}  
  113.   
  114. /* Quote & Code blocks */  
  115. .code {  
  116.         font-family: ‘song’,Verdana; font-size: 12px; color: #006600;  
  117.         background-color: #FAFAFA; border: #D1D7DC; border-style: solid;  
  118.         border-left-width: 1px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px  
  119. }  
  120.   
  121. .quote {  
  122.         font-family: ‘song’,Verdana; font-size: 12px; color: #444444; line-height: 125%;  
  123.         background-color: #FAFAFA; border: #D1D7DC; border-style: solid;  
  124.         border-left-width: 1px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px  
  125. }  
  126.   
  127. /* Copyright and bottom info */  
  128. .copyright                { font-size: 12px; font-family: ‘song’,Verdana; color: #444444; letter-spacing: -1px;}  
  129. a.copyright                { color: #444444; text-decoration: none;}  
  130. a.copyright:hover { color: #; text-decoration: underline;}  
  131.   
  132. /* Form elements */  
  133. input,textarea, select {  
  134.         color : #;  
  135.         font: normal 12px ‘song’,Verdana;  
  136.         border-color : #;  
  137. }  
  138.   
  139. /* The text input fields background colour */  
  140. input.post, textarea.post, select {  
  141.         background-color : #FFFFFF;  
  142. }  
  143.   
  144. input { text-indent : 2px; }  
  145.   
  146. /* The buttons used for bbCode styling in message post */  
  147. input.button {  
  148.         background-color : #EFEFEF;  
  149.         color : #;  
  150.         font-size: 12px; font-family: ‘song’,Verdana;  
  151. }  
  152.   
  153. /* The main submit button option */  
  154. input.mainoption {  
  155.         background-color : #FAFAFA;  
  156.         font-weight : bold;  
  157. }  
  158.   
  159. /* None-bold submit button */  
  160. input.liteoption {  
  161.         background-color : #FAFAFA;  
  162.         font-weight : normal;  
  163. }  
  164. >  
  165. </style>  
  166. </head>  
  167. <body  bgcolor="#FFFFFF" text="#" link="#" vlink="#333333" />  
  168. <a name="top"></a>  
  169.   
  170. <!–栏目条–>  
  171. <style type=text/css>  
  172. A.title1:link {font-size:17.9px;font-family:arial;font-weight:bold;text-decoration:none;color:#ffffff;}  
  173. A.title1:visited {font-size:17.9px;font-family:arial;font-weight:bold;text-decoration:none;color:#ffffff;}  
  174. A.title1:active {font-size:17.9px;font-family:arial;font-weight:bold;text-decoration:none;color:#ffffff;}  
  175. A.title1:hover {font-size:17.9px;font-family:arial;font-weight:bold;text-decoration:none;color:#ffffff;}  
  176. A.title2:link {text-decoration:none;color:#000000;font-size:12px}  
  177. A.title2:visited {text-decoration:none;color:#000000;font-size:12px}  
  178. A.title2:active {text-decoration:none;color:#ff0000;font-size:12px}  
  179. A.title2:hover {text-decoration:none;color:#ff0000;font-size:12px}  
  180. </style>  
  181. <?php  
  182. if (empty($HTTP_POST_VARS[reg])) {  
  183.   
  184.     ?>  
  185. <form action="<?=$PHP_SELF?>" enctype="multipart/form-data" method="post">  
  186. <table border="0" cellpadding="3" cellspacing="1" width="95%" align=center class="forumline">  
  187.         <tr>  
  188.                 <th class="thHead" colspan="2" height="25" valign="middle"> <a href=http://www.sun126.com>精彩奇讯科技虚拟主机自助申请系统</a> 请填写注册信息</th>  
  189.         </tr>  
  190.         <tr>  
  191.                 <td class="row2" colspan="2"><span class="gensmall">请输入在本服务器新增的域名:</span></td>  
  192.         </tr>  
  193.         <tr>  
  194.                 <td class="row1" width="20%"><span class="gen">域名名称:   http://</span>& lt;/td>  
  195.                 <td class="row2"><input type="text" class="post" style="width:100px" name="domain" size="10" maxlength="25"><span class="gen"><font color=red>.sun126.com</font></span></td>  
  196.         </tr>  
  197.                 <tr>  
  198.                 <td  class="row1" colspan="2" align="center" height="28">  
  199. <input type="hidden" name="dateformat" value="Y-m-d H:m" maxlength="14" class="post" />  
  200.                 <input type="hidden" name="reg" value="1" /><input type="submit" name="submit" value="发送" class="mainoption" />  <input type="reset" value="重设" name="reset" class="liteoption" /></td>  
  201.         </tr>  
  202. </table>  
  203. </form>  
  204. </center>  
  205. </body>  
  206. </html>  
  207. <?php }  
  208. ?>  
  209. <?php  
  210.   
  211.   
  212. if ($HTTP_POST_VARS[reg]) {  
  213. for($i=0;$i<9;$i++){  
  214. $char1=chr(rand(97,122));  
  215. $chara.=$char1;  
  216. }  
  217.     $domain = $HTTP_POST_VARS[domain] . ".sun126.com   /" . $HTTP_POST_VARS[domain];  
  218.     // 检查并创建目录开始*******************************  
  219.     if (is_dir(‘d:/vhostuser/user_’.$chara.’_’.$HTTP_POST_VARS[domain])) {  
  220.         $domain = "http://" . $domain;  
  221.         echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"95%\" align=center class=\"forumline\"><tr>  
  222.                 <td class=\"row2\" colspan=\"2\"><span class=\"gensmall\">此域名已经使用,请更换~~<a href=$PHP_SELF>返回</a></span></td>  
  223.         </tr>  
  224.         <tr>  
  225.                 <td class=\"row2\" colspan=\"2\"><span class=\"gensmall\">      <a href=$domain target=_blank><FONT COLOR=BLUE><u>点击查看已开空间</u></FONT></a>< /span></td>  
  226.         </tr></table>";  
  227.         exit;  
  228.     } else {  
  229.         mkdir(‘d:/vhostuser/user_’.$chara.’_’.$HTTP_POST_VARS[domain]);  
  230.     }  
  231.   
  232.     $HTTP_POST_VARS[reg] = "0";  
  233.     $domain = "http://" . $domain;  
  234.     echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"95%\" align=center class=\"forumline\"><tr>  
  235.                 <td class=\"row2\" colspan=\"2\"><span class=\"gensmall\">空间开设成空!~~<a href=$PHP_SELF>返回</a></span><span class=\"gensmall\">    <a href=$domain target=_blank><FONT COLOR=BLUE>点击查看已开空间</FONT></a>  <a href=http://www.sun126.com>< 联系我们 – 精彩奇讯科技></a> </span></td>  
  236.         </tr></table>";  
  237. }  
  238.   
  239. ?>   

很久没发过php代码了,今天发个支持file及memcache的缓存封装类

主要的作用就是就是简化缓存操作,类型分文件缓存和memcache内存级缓存两种,能过常量进行相关配置

通过cache()函数进行缓存操作

PHP代码
  1. <?php   
  2. //缓存存放类型   
  3. define(‘CACHETYPE’‘file’);   
  4. //memcache服务器地址   
  5. define(‘MEMCACHE_HOST’,‘localhost’);   
  6. //memcache服务器端口地址   
  7. define(‘MEMCACHE_PORT’,11211);   
  8. //文件类型缓存的话,设定存放位置   
  9. define(‘CACHE_PATH’,‘cache/’);   
  10.   
  11. function cache($name,$var=,$s=0)   
  12. {   
  13.     $c=new cache;   
  14.     $name=str_replace(‘ ‘,,substr($name,0,30)).‘_’.substr(md5($name),8,16);   
  15.     if(CACHETYPE==‘memcache’return $c->memcacheCache($name,$var,$s);   
  16.     else return $c->fileCache($name,$var,$s);   
  17.        
  18. }   
  19.   
  20. class cache   
  21. {   
  22.     function memcacheCacheRead($m,$name)   
  23.     {   
  24.         $return=$m->get($name);   
  25.         if(empty($return)) return false;   
  26.         else{   
  27.             return $return;   
  28.         }   
  29.     }   
  30.   
  31.     function memcacheCache($name,$var,$s)   
  32.     {   
  33.         $m=self::memcache();   
  34.         if(empty($var)){   
  35.             return self::memcacheCacheRead($m,$name);   
  36.         }else{   
  37.             $m->set($name,$var,0,$s);   
  38.             return self::memcacheCacheRead($m,$name);   
  39.         }   
  40.     }   
  41.   
  42.     function fileCache($name,$var,$s)   
  43.     {      
  44.         $filename=CACHE_PATH.$name.‘.php’;   
  45.         if(empty($var)){   
  46.             if(file_exists($filename)){   
  47.                 return self::readCache($filename);   
  48.             }else return false;   
  49.         }else{   
  50.             if($this->writeCache($filename,$var,$s)){   
  51.                 return self::readCache($filename);   
  52.             }else  
  53.                 throw new Exception(‘File cache write error!’);   
  54.         }   
  55.     }   
  56.   
  57.   
  58.     function writeCache($filename,$var,$s)   
  59.     {   
  60.         $var=array(‘var’=>$var,‘s’=>$s);   
  61.         $content=serialize($var);   
  62.         $content=‘<?php exit;?>’.$content;   
  63.         fclose(fopen($filename,‘w’));   
  64.         if(file_put_contents($filename,$content)){   
  65.             return true;   
  66.         }else{   
  67.             return false;   
  68.         }   
  69.     }   
  70.   
  71.     function readCache($filename)   
  72.     {   
  73.         $content=@file_get_contents($filename);   
  74.         $var=unserialize(str_replace(‘<?php exit;?>’,,$content));   
  75.         $mtime=filemtime($filename);   
  76.         if(time()-$mtime>=$var[‘s’]){   
  77.             @unlink($filename);   
  78.             return false;   
  79.         }else{   
  80.             return $var[‘var’];   
  81.         }   
  82.     }   
  83.   
  84.     function memcache()   
  85.     {   
  86.         $mem = new Memcache;   
  87.         $mem->connect(MEMCACHE_HOST,MEMCACHE_PORT) or die("Memcache could not connect");   
  88.         return $mem;   
  89.     }   
  90. }   
  91.   
  92. //演示   
  93.   
  94. if(!$name=cache("name")){   
  95.     $name=cache("name",‘test memcache’,20);   
  96. }   
  97. print_r($name);   
  98. ?>