Vista Community College Vista Community College (Logo)
News | Admissions | Publications | Departments | Library | Staff | Services | Community | Search | Help 
Help || Maps & Location | Sitemap | Contact | Search | Problems/HELP! | About 
VCC ) Help ) About 
All page source code, unless otherwise noted, copyright 1999, 2000 Brian Garcia.

NO parts of this page may be reproduced without written permission and a link back to the source. I fully support other developers and am willing to help - I just want to know I'm helping.

Please support all of these awesome organizations/groups/companies by paying them a visit. These are the technologies that drive much you see on the Internet - and they are mostly developed and distributed for free. Without these, we would have to shell out thousands of dollars for a server and the software to run it.

This webpage is brought to you by the almighty engines of:


PHP - a server side scripting language, distributed open source and free. All pages on this site are PHP.



MySQL - Portions of this site use a MySQL database, distributed and used as shareware



Apache - This website is hosted on an Apache server, also open source freeware



RedHat Linux - The server is primarily on a RedHat Linux 6.2 box.



Phorum - A freeware, open source message board system. The version on this site is a modified version, but this is a very powerful and highly configurable tool.


For the curious, here are some details about how each page works:
  • Each individual page is simple the raw html with no headers etc. This lets any page be edited in a simple manner with nothing getting in the way or tabls to balance; a computer illiterate person could just Save As HTML and drop it into the page.
  • Each page is wrapped in a header and footer at render time - you can not see the effect by viewing source.
  • The header contains the table at the top, the links to the style sheet, and the main menu. It then itself includes a file dynamically, depending on the variable defined by the page (see below).
  • The footer contains the counter (which is generic for the entire page, and counts both unique visitors and total page requests - the statistics for the individual sites are parsed from the logs), and general page information.
  • The only added code to the base html is (the code for this page):

    < ?
               /* Variables */
               $Title = "About";
               $Level = "../";
               $Level2 = "./";
               $Submenu = "help";

               /* Headers */
               include ("../shared/header.inc");
    ? >

    HTML CONTENT

    < ?
               include ("../shared/footer.inc");
    ? >

  • Title - this is used in the navigation bar at the top (eg, VCC ) Help ) About), and the title of the page itself (as it appears on the top of your browser). It is also used in pages like the 404 error page.
  • Level - The primary level. Because I'm too lazy to keep track? No. Mainly because the folder structure has 6 different copies of the page - root (default), root high visibility, root text only, root spanish, spanish high visbility, spanish text only. Since these are frequently subfolders of each other, it is much easier to use this system to keep track of what level a file is at - ie, the spanish high vis would be ../../../ to get back to root. Also, some of the folders, even in root, go several deep - some departments have subfolders, and without defining the level, it would be impossible to tell the page where to get the header, footer, graphics, etc.
  • Level2 - Pretty much used as a placeholder in most pages, in case the folder is moved.
  • Submenu - The most important line. This tells the page which submenu to get (see below) from the shared directory; this is the root of the dynamic menu system. Instead of a complicated program to detect the page and location, then generate each menu on the fly from a database, I find it easier and more reliable to use a bare bones text only system.

    The menu system works as follows:
  • The header loads the general tables, graphics, and static main menu (the one on the top).
  • The header then has a include ("$Level/shared/submenu.$Submenu.inc") PHP tag. Thus, each submenu is a text document with the names and links; it is simply loaded into the page from there.
  • An advantage to this is that to change the values of a menu, it is necessary only to open that one text file, which contains only that menu, make a change, and save it. This will immediately take effect for all pages in that folder.
  • Another advantage is that as many menu combinations can be made or added as anyone wished - a special or temporary section or page could have a submenu dedicated to it alone. It would take thirty seconds of editing a small text file.

    Some random facts:
  • Because of the nature of the above systems, pages average 20 kb, including all headers, the menu, and content.
  • Because of the 20 kb file size, even modem users won't notice much of a delay in the page loading. Most pages shoot for 40 kb as small.
  • Because of all that, the ENTIRE site, including all subsites and versions and files, is 2.5 mb. The normal English site is 1.1 mb total. 0.2 of that is the search pages, another 0.2 is the images, and 0.4 is the forum - meaning that the normal content is around 0.3 mb.
  • File types used in this page include .php and .inc; PHP is the extension for the pages, and INC is the extension for, well, INCluded files. They're basically just text files. Graphically, all files are .png or .gif; PNG is a Portable Network Graphic, which is a replacement for GIF - it has massive compression with 16 million colors and transparency. GIFs have 256 colors. JPGs are 16 million colors but have very lossy compression and can become distorted - but are generally smaller than PNG files. Basically, PNG is the best all around format. JPG is best used on high color images with few straight, high contrast lines - like pictures. GIFs are best used on low color files that should be small - like text. I tend to use PNG more than the others. It, unlike gif, is an independent, open source format.

    Code examples:
  • All codes are copyright 2000 Brian Garcia, and may be redistributed with this line included.
  • These examples are included mostly for educational purposes. Vista is an institute of education; this page is an instrument of education.
  • These are some examples of what a PHP code looks like. It is formatted and commented for ease of visibility and to explain what is ging on.
  • Keep in mind that this is connecting to, reading from, and writing to a database. I do not think I need to post the table layouts; imagine them.
  • Also keep in mind that this is fairly advanced server-side scripting that you will not be able to duplicate without access to your own server and programming knowledge. Half the battle is installing and configuring the server and database to work together perfectly.

    Counter
    < ?
        
    /* Call Database */
         $db = mysql_connect("
    --servername--", "--username--", "--password--");
         mysql_select_db("
    --databasename--",$db);
        
        
    /* Lookup total hits and declare variables */
         $query = "SELECT * FROM counter_general";
         $result = MYSQL_QUERY($query);
         $counter = mysql_result($result,"hits");
        
        
    /* Add a hit */
         $query="update counter_general set hits = hits+1";
         $result = MYSQL_QUERY($query);
        
        
    /* Lookup "unique" hits and declare variables */
         $query = "SELECT hits_u FROM counter_unique";
         $result = MYSQL_QUERY($query);
         $counter_u= mysql_result($result,"hits_u");
        
        
    /* Lookup most recent ip and declare variables */
         $query = "SELECT lastip1 FROM counter_unique";
         $result = MYSQL_QUERY($query);
         $recent = mysql_result($result,"lastip1");
        
        
    /* Check visitor IP against Database */
         if ($REMOTE_ADDR == $recent) {
         }
         else {
             $query="update counter_unique set hits_u = hits_u+1, lastip1 = '$REMOTE_ADDR'";
             $result = MYSQL_QUERY($query);
       }
    ? >

    Upload
    <?
        if($dofile)
        {
            $cleanfile = stripslashes($userfile);
            $path = "../docs";
            $debug = "$path/$filename";
            copy($cleanfile,$debug);
            print "File Uploaded to $debug";
            print "<br>";
            print "<a href='$Server/
    --folder--/upload.php'>REFRESH</a>";
        }
    ?>

    <form method="post" enctype="multipart/form-data" action="<? echo $PHP_SELF?>">
    <input type=file name="userfile">
    <input type=text name="filename">
    <input type=Submit name="dofile">
    </form>

    ADMIN
    < ?
        
    /* NOTES */
         /*
         'echo $PHP_SELF' will, quiet nicely, refresh the content of the page without reloading, letting us make
         dynamic changes and maintain variables without writing cookies, writing to the server, and without refreshing

         VistaADMIN 1.0 by Brian Garcia, copyright 2000 - no reproduction is authorized
         */


        
    /* Call Database */
         $db = mysql_connect("
    --servername--", "--username--", "--password--");
         mysql_select_db("
    --database--",$db);

        
    /* What to do when they push your buttons */
         if ($submit) {

        
    /* If we're EDITing (determined by checking if the id variable - if it is, the page has loaded something from the database) */
             if ($id) {
                 $sql = "UPDATE Recent_News SET header_text='$header_text' , poster_name='$poster_name' , post_date='$post_date' , news_text='$news_text' , link_1='$link_1' , link_2='$link_2' WHERE id=$id";

        
    /* If we're not EDITing, we're ADDing, eh? */
         } else {
             $sql = "INSERT INTO Recent_News (header_text , poster_name , post_date , news_text , link_1 , link_2) VALUES ('$header_text' , '$poster_name' , '$post_date' , '$news_text' , '$link_1' , '$link_2')";
         }

        
    /* Write to the Database */
         $result = mysql_query($sql);

        
    /* Print something pretty */
         echo "Record updated/edited!<p>";
         echo "<a href='http://169.229.79.69/
    --folder--/news.php'>REFRESH</a>";

        
    /* If we're not EDITing, and not ADDing, we MUST want to DELETE - same routine */
         } elseif ($delete) {
             $sql = "DELETE FROM Recent_News WHERE id=$id";
             $result = mysql_query($sql);
             echo "Record deleted!<p>";
             echo "<a href='http://169.229.79.69/
    --folder--/news.php'>REFRESH</a>";
         } else {

        
    /* When the page loads (id is not set), write the pretty table from the Database */
         if (!$id) {
             $result = mysql_query("SELECT * FROM Recent_News",$db);

        
    /* Go for a loop WHILE there is still data in the table */
             while ($myrow = mysql_fetch_array($result)) {
                 printf("<a name='%s'>\n", $myrow["post_date"]);
                 echo "<table border='0' cellspacing='0' cellpadding='1' width=100%>\n";
                 echo " <tr>\n";
                 echo " <td class='NewsHeader'>\n";
                 printf(" %s - <i>%s </i>- <i>%s</i>\n", $myrow["header_text"], $myrow["poster_name"], $myrow["post_date"]);
                 echo " </td>\n";
                 printf("<td class='copyright' align='right'><a href=\"%s?id=%s\" class='copyright'>EDIT</a> | <a href=\"%s?id=%s&delete=yes\" class='copyright'>DELETE</a>  \n", $PHP_SELF, $myrow["id"], $PHP_SELF, $myrow["id"]);
                 echo " </td>\n";
                 echo " </tr>\n";
                 echo " <tr>\n";
                 echo " <td class='NewsBody' colspan='2'>\n";
                 printf(" %s <br>\n", $myrow["news_text"]);
                 printf(" <a href='%s'>%s</a> | <a href='%s'>%s</a>\n", $myrow["link_1"], $myrow["link_1"], $myrow["link_2"], $myrow["link_2"]);
                 echo " </td>\n";
                 echo " </tr>\n";
                 echo "</table>\n";
             }
         }
    ? >

    < form method="post" action="<? echo $PHP_SELF?>">

    < ?
        
    /* If ID is true on page load, meaning that they chose edit */
         if ($id) {

        
    /* Load Database and declare variables to plug into the form */
             $sql = "SELECT * FROM Recent_News WHERE id=$id";
             $result = mysql_query($sql);
             $myrow = mysql_fetch_array($result);
             $id = $myrow["id"];
             $header_text = $myrow["header_text"];
             $poster_name = $myrow["poster_name"];
             $post_date = $myrow["post_date"];
             $news_text = $myrow["news_text"];
             $link_1 = $myrow["link_1"];
             $link_2 = $myrow["link_2"];
    ? >

    <input type=hidden name="id" value="<?php echo $id ?>">

    <?
         }
    ? >

    TABLE WITH FORM ETC

    </form>



    Home | En español | High Visibility | Text Only
    Vista Forum