什么是SaaS? What is SaaS?

Software as a Service. Refers to software which works under the model of the user paying to use the software instead of the traditional model of paying for owning the software (or owning a license for it). Typically SaaS is used for software packages which are run across the internet.

软件即服务。不同于传统的购买软件、或购买软件授权的模式,它倾向于用户付费使用软件,用软件提供商提供服务。典型的SaaS一般被用于互联网。

出处:http://www.cryer.co.uk/glossary/s/saas.htm

参考:

http://www.hrbhzw.com/html/20073/info_cci_2066.html

http://www.enet.com.cn/article/2007/0405/A20070405524827.shtml

proftpd配置的几个要注意的地方

1. 必须要加的两行配置:

UseReverseDNS off
IdentLookups off

如果你发现你的ftp超级慢,几秒到十几秒都没有连接完毕,那加上这两行试试。

2  选择认证方式
proftpd支持很多的认证方式,如passwd, PAM, sql, ldap等。
ldap在国内貌似应用得不广,忽略。
数据库有一个很大的好处就是便于管理,便于和别的程序整合用户系统。但是它的查询非常昂贵,因为每一次登陆都要做很多次的数据库查询。用SQLNegativeCache可以好一点,但是对于一个ftpd来说,还是觉得昂贵了。
看官方的说法:
http://www.castaglia.org/proftpd/doc/contrib/ProFTPD-mini-HOWTO-SQL.html
Question: How can I make mod_sql go faster?
Answer: There are a couple of things you might try. First, if using a version of mod_sql from ProFTPD-1.2.7rc1 or later, make use of the SQLNegativeCache configuration directive.

Other forms of this question are "Why does mod_sql iterate through every user in the database?", or "Why is mod_sql so slow during logins?" Here’s the reason: mod_sql is designed to handle all authentication functions that the daemon throws at it. This includes the functions that iterate through all users (setpwent(), getpwent(), endpwent()) and the functions that iterate through all groups (setgrent(), getgrent(), endgrent()).

When you see mod_sql iterating through all groups or users, it is doing so because it has been asked to do so by the daemon. Since there is no good way to keep an open query around without adding more to the various backend modules than we already have, mod_sql pre-caches all users when setpwent() is called, and pre-caches all groups when setgrent() is called. This allows the getpwent() and getgrent() calls to be simple, at the cost of more time during login.

In simple situations, these functions are never called. When you start limiting access to directories, files, or various FTP commands based on user or group, that is when the daemon needs to iterate through the users and groups to check permissions. A basic FTP server, including virtual and anonymous servers, will never make the (potentially, very) expensive user iteration calls, but may iterate through all groups.

The SQLAuthenticate directive provides a method to tune mod_sql; by default, mod_sql will handle the various *pwent() and *grent() calls. When SQLAuthenticate is told not to handle userset or groupset, mod_sql simply passes the request on to whatever authentication handlers exist in the system. Keep in mind that using SQLAuthenticate in this way means that the proftpd daemon is not using the same information to authenticate the user as it is to control the user’s actions during their session.

For those of you who have used mod_sql in the past, these lookups should probably be set to off. Versions of mod_sql prior to 3.2.0 (or thereabouts) did not handle the {set|get|end}{pw|gr}ent functions at all, so by setting these lookups to off, you lose no functionality. Those of you new to mod_sql should to consider your needs: is the cost of iterating through every user stored in the database worth the ability to limit access based on users/groups from the database? If not, you will need to re-evaluate the way you are using the database, and where you should be storing your user/group information.

PAM是一个不错的选择,但是它默认使用的是系统上真实存在的用户,管理用户(增、删、改)都涉及到系统用户的变动。

passwd应该是建虚拟用户FTP的首选。它基本文本,速度快,开销小,可以让用户虚拟化,和系统用户可以没有直接关联,因为它指定了passwd文件,并代替系统的/etc/passwd供ftpd使用。http://www.castaglia.org/proftpd/doc/contrib/ProFTPD-mini-HOWTO-AuthFiles.html

其它还有几种认证方式,在这里可以找到介绍:http://proftpd.org/docs/faq/linked/faq-ch7.html

Joomla ACL 的简单举例

在Joomla component开发中,经常会用到系统级别的权限控制,ACL就是做这个用处的。

这里举一个小例子,展示Joomla ACL的使用方法,仅当备忘。

PHP代码
  1. $acl = &JFactory::getACL();   
  2. $acl->addACL( ‘com_swimtool’‘manage’‘users’‘super administrator’ );   
  3. //$acl->addACL( ‘com_swimtool’, ‘manage’, ‘users’, ‘administrator’ );   
  4. //$acl->addACL( ‘com_swimtool’, ‘manage’, ‘users’, ‘manager’ );   
  5.   
  6. $user = & JFactory::getUser();   
  7. if (!$user->authorize( ‘com_swimtool’‘manage’ )) {   
  8.     $mainframe->redirect(‘index.php’, JText::_(‘ALERTNOTAUTH’));   
  9. }   

这里,先用JFactory获取ACL的对象,再添加ACL规则,最后验证,验证失败则给出失败信息,不允许访问资源。

C语言 程序时间统计器

Unix command time for windows.

C++代码
  1. // time.cpp : Defines the entry point for the console application.  
  2. //  
  3.   
  4. #include <stdio.h>  
  5. #include <time.h>  
  6. #include <windows.h>  
  7.   
  8. int gettime() {  
  9.     time_t t;  
  10.     time(&t);  
  11.     return t;  
  12. }  
  13. void printtime(int t) {  
  14.     char buf[20];  
  15.     if (t<0) sprintf(buf,"%d s",0);  
  16.     else if (t<60) sprintf(buf,"%d s",t);  
  17.     else if (t<3600) sprintf(buf,"%d m %d s",t/60, t%60);  
  18.     else sprintf(buf,"%d h %d m %d s",t/3600, (t%3600)/60, (t%3600)%60);  
  19.     puts(buf);  
  20. }  
  21.   
  22. int main(int argc, char* argv[])  
  23. {  
  24.     if(argc<2) {  
  25.         puts("Nothing to run.");  
  26.         return 0;  
  27.     }  
  28.     STARTUPINFO si={0};  
  29.     PROCESS_INFORMATION pi;  
  30.     int i,t1,t2;  
  31.     char argstr[MAX_PATH]={""};  
  32.   
  33.     si.cb=sizeof(STARTUPINFO);  
  34.     t1=gettime();  
  35.     for(i=1;argv[i];i++) {  
  36.         strcat(argstr,argv[i]);  
  37.         strcat(argstr," ");  
  38.     }  
  39.     //puts(argv[1]);  
  40.     //printf("%d\n",t1);  
  41.   
  42.     if(CreateProcess(NULL,argstr,NULL,NULL,FALSE,0,NULL,NULL,&si,π)) {  
  43.         WaitForSingleObject(pi.hProcess,INFINITE);  
  44.         t2=gettime();  
  45.         //printf("%d\n",t2);  
  46.         printtime(t2-t1);  
  47.     } else {  
  48.         printf("Unable to run app!");  
  49.     }  
  50.     return 0;  
  51. }  

仿linux的time程序。