The PhP code is in ~www/php.

The source code resides in a svn repository on repo.eecs.berkeley.edu in the gsrc project:

We do our work as the www user on moog, so there is no need for individual logins on source.

That said, if you wanted to check out the php source for some reason, use:

svn co https://repo.eecs.berkeley.edu/svn/projects/gsrc/php/

How PhP Works on the sites

  1. A http request comes in and /usr/local/apache/conf/httpd.conf is consulted. This file maps the different website urls to different locations. This file also makes Apache aware of PhP files.
  2. We use virtual hosts to run multiple websites on one server. /usr/local/apache/conf/extra/httpd-vhosts.conf contains sections for each host.
    BTW - SSL connections are handled by /usr/local/apache/conf/extra/httpd-ssl.conf. SSL is used by the login page.
    For each virtual host, the httpd-vhosts.conf file contains
     Include "/usr/local/apache/conf/rewrite.conf"
    
  3. The /usr/local/apache/conf/rewrite.conf file handles rewrites for thinks like bugzilla and the wiki. The last line is:
    RewriteRule ^(.*)$ /home/www/php/get.php [L,NS]
    
    This line says that if the request has not been handled elsewhere, read /home/www/php/get.php
    The rewrite log is very large, but it can be found at /usr/local/apache/conf/rewrite_log If you need to view that file, you might want to use tail and grep
    tail -10000 /usr/local/apache/logs/rewrite_log | grep events/11/symposium2011_notice.pdf
    
    The above command might return:
    128.32.48.155 - - [06/Oct/2011:11:52:59 --0700] [www.e3s-center.org/sid#3d7070][rid#7e4558/subreq] (2) init rewrite engine with requested uri /e3scenter//events/11/symposium2011_notice.pdf
    128.32.48.155 - - [06/Oct/2011:11:52:59 --0700] [www.e3s-center.org/sid#3d7070][rid#7e4558/subreq] (1) pass through /e3scenter//events/11/symposium2011_notice.pdf
    128.32.48.155 - - [06/Oct/2011:11:52:59 --0700] [www.e3s-center.org/sid#3d7070][rid#5fd0b8/initial] (2) init rewrite engine with requested uri /events/11/symposium2011_notice.pdf
    128.32.48.155 - - [06/Oct/2011:11:52:59 --0700] [www.e3s-center.org/sid#3d7070][rid#5fd0b8/initial] (2) rewrite '/events/11/symposium2011_notice.pdf' -> '/home/www/php/get.php'
    
    Note that the above rewrites to /home/www/php/get.php, which is where most files end up.
  4. /home/www/php/get.php looks at the server portion of the URL and then includes the corresponding get.php file.
    The code looks like:
    if ($sites[$_SERVER['SERVER_NAME']]) {
        include "${_SERVER['SERVER_NAME']}/get.php";
    } else {
        html_unknown($_SERVER['SCRIPT_URL']);
    }
    
    If the URL is http://chess.eecs.berkeley.edu, then $_SERVER['SERVER_NAME'] will be set to chess.eecs.berkeley.edu, so /home/www/php/chess.eecs.berkeley.edu/get.php will be read.
    Each of the separate websites has corresponding get.php file.
  5. The layout for each website is controlled by php files in the layout/html.inc.php file, for example, /home/www/php/chess.eecs.berkeley.edu/layout/html.inc.php.
  6. The /home/www/php directory has two major subdirectories:
    /home/www/php/include - common includes, such as arrays that define strings
    /home/www/php/subpages - used for subpages such as the admin pages.

To Upgrade PHP

See this question