Campus Technology Map

Other Technology Maps
http://clc.its.psu.edu/Labs/Locations/
http://www.yale.edu/its/media/computing/labs.html
http://its.pomona.edu/services/facilities/lab_availability/ (doesn't work)

The map's utility is directly proportional to geography -- the bigger the campus, the better it gets!



Ideas to file...



ALL CODE CAN BE FOUND AT http://code.google.com/p/gctechmap/

ALWAYS CHECK YOUR XHTML AND CSS!

MAKE SURE LABS SAY THEY'RE OPEN WHEN THEY REALLY ARE OPEN (AND VICE VERSA)

HOW DO I CENTRALIZE AND MANAGE CODE EFFECTIVELY? HOW DO I STOP THE MAP FROM BECOMING A BEHEMOTH THAT IS OUTSIDE OF MY CONTROL?

TOP PRIORITIES

 

 
- Show info for each lab (a lab map for each lab)
- Nested tabs for lab search!
- Transparent Flash video that overlays across map, giving you a tour of each part
    http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14201
    http://www.webworksite.com/overlay.shtml
 
  1. Indent and comment code... almost done
  2. Do IE/Safari stylesheets for all the other users -- since I redid the map, I'll need to do some slight mods for lte IE7
    1. http://www.tatanka.com.br/ies4linux/page/Main_Page
  3. Also fix Library floor issues... I thought I had already done that...
  4. Fix Science Library hours
  5. Move open_labs stats to files (and code it in Perl)
    1. We also need a way to get at this data without refreshing the page... check the TCDB suggestion page for a way to have AJAX dynamically pull the data from the DB
  6. Create a virtual tour for users
  7. Make a bug-reporting system (can link with e-mailing suggestions, like "If you'd like to suggest a feature, or if you see something wrong with the map, please e-mail me")
  8. Consolidate and simplify code -- CSS properties can be grouped (class="closed gencomp", for instance), which means that we can cut down on all those lab and printer styles
    1. I also need to go back through and change the relative positioning of the icons
    2. Set up common functions in functions.php
  9. Figure out ways to perfect toner e-mails
  10. Make the code consistent (variable names, structure, foreach loops) and efficient! I have a lot of duplicate code that needs taking care of
  11. Finish printers.php -- find a good way to handle the GENCOMP/BURLING issue (I should just make more icons... one for each printer)
  12. Take care of all the files that get arbitrarily large in size
  13. Make a dependency map of everything and do some planning! Look at places where I can cut down on code... I'm sure I've made some errors and duplicated things in places
    1. Where can I use arrays and foreach loops?
  14. Make a list of the problems I ran across in doing all of this! This will help both others and myself succeed in the future!
    1. Think before you code!
    2. Don't try to do too much with php alone!
      1. This increases page load time, reduces efficiency, and screws up things in a lot of places
  15. Try as much as possible to move away from shell scripts and towards Python/Perl. This helps with portability, even though I would never recommend that this be used on a Windows server
    1. I need to move open_labs.php over to Perl and have it write data to file/DB so that other scripts can read from it
  16. IIF is technically open from 5-7, even though there is no TC staffing it. It should also be shown as open until 1, even though there is no TC there
    1. We should change the hours for some of the labs to be open regardless of if a TC is staffing it or not
    2. Make a list of these labs and change hours list accordingly
  17. Fix holiday hours -- some labs still show up as open, like Gencomp and Scilab
    1. Should have a holiday/back-to-school script to update the holiday info in the DB, then have the PHP pull from that... is that the best solution?
    2. Even if a lab is open during the break (like the Libraries, for instance), when they close for the evening, the message "closed for break" still appears... what's the most elegant way to fix this?



What the map does:


    $date = date ( 'l' ); // assigns the variable $date the day of the week
    $hour = date ( 'H' ); // assigns the variable $hour the hour of the day (24 hour format, like TCDB)

    if (($date == 'Monday' || $date == 'Tuesday') && $hour >= 8 && $hour <= 23)
        {
            print 'open image goes here';
        }
    else
        {
            print 'closed image goes here';
        }
   
        An image is superimposed over the map in the appropriate place to show whether or not the lab is open/closed

I think they turn off the Scilib printer at night, which is why it has trouble displaying for me. Maybe I should make something where if the script can't contact a printer once, it should display a sort of out-of-order message...
   

What I'd like the map to do
:


ARCHIVING -- all of our archiving should be consistent (i.e. do we want to archive into folders by month or simply include the date in the file name?)

TONER
    TONER LEVELS

    TONER/OO E-MAILS

LABS/PRINTERS

AVAILABLE COMPUTERS

I was reading through some notes from my Internet Computing class about HTTP Applications... came across something interesting --
If we use CGI processes on the TCDB, I could pass a GET request to it and it could make things a lot easier...

For the login script...

#!/bin/bash
(sleep 3; echo "GET /cgi/comp_on.cgi?lab=gencomp HTTP/1.1") | telnet tcdb.grinnell.edu 80
exit 0

(Do I also need newline characters after the GET request, or will it terminate automatically?)

And for the logout script...

#!/bin/bash
(sleep 3; echo "GET /cgi/comp_off.cgi?lab=gencomp HTTP/1.1") | telnet tcdb.grinnell.edu 80
exit 0

In my lecture notes, they talk about CGI as being tough to use and outdated, but I think this is exactly what I want... I'll have to see
Anyway, the CGI process will then parse the query_string for the lab, then add or take away the number of available computers from that lab. Basically, I think it should
write a number to the "gencomp" file, which should be 1 more than whatever number is currently there. Therefore, the number starts out at 0 in the morning (maybe
we could have a script that does

#!/bin/bash
for each file in available_comps directory...
echo "0"
exit 0

at around 7:30am...

Then, for the comp_on script, it should add one, like so...

read contents of file, store read number in a variable
add 1 to the number, overwriting contents of file

The comp_off script should simply subtract one, instead

The benefits of this are...


We don't have to parse the server logs every X minutes... the requests are automatically taken care of
The code should be a lot cleaner and easier to read, and there should be a lot less code, as well
This will be easier to make modular... that way we should be able to handle any request (i.e. based on the name of the variable in the query_string
[here, "lab"], we should be able to write data to any number of different files; if we wanted to do stuff with printers or other agents later, perhaps we could... this is a minor issue but still something to consider)

We could also do a C/C++/Java script that uses the Winsock library

2009-02-24

Technically, I should use POST as the type of HTTP Request, since my program effects a change on the server (as per the HTTP specifications)
This shouldn't be too hard to fix, should just be able to add some \r\n to the $http_request variables

Final (?) Mac Script:
#!/bin/bash
(sleep 3; echo "GET /map/cgi/available_comps.php?id=$(hostname -s)&comp_on=TRUE&type=mac") | telnet tcdb.grinnell.edu 80
exit 0

Final(?) Windows script:

#!/usr/bin/env perl

use Net::Telnet;
use Sys::Hostname;

# Get hostname
$hostname = hostname();

# Initiate telnet connection on port 80, send "$hostname" as HTTP request
$telnet = new Net::Telnet (Port=> 80);
$telnet->open('tcdb.grinnell.edu');
$http_request = "GET /map/cgi/available_comps.php?id=$hostname&comp_on=TRUE&type=pc";
$telnet->print($http_request);





LAB SEARCH

GEOGRAPHICAL

STATISTICS

<?php // Google chart stuff

$hsize = 250 ;
$vsize = 100 ;
$chart_type = 'p3' ;

print "<p><a href=\"http://chart.apis.google.com/chart?
chs=$hsize
x$vsize
&chd=t:60,40
&cht=$chart_type
&chl=Hello|World\">Google Chart</a></p>";

?>



On Sat 15 Nov 2008 03:01:01 PM CST
18 out of the 18 public printers were available
SCILIB was closed

  • Make all of these stats available in human-readable and XML format


GENERAL PHP STUFF

LOGIN SYSTEM


SCRIPTING/LINUX STUFF
  • Log wget errors with -o flag, unless we move to Perl for all of this...


DATABASE STUFF -- After the historical data tracking and user interface, this stuff should be a priority!


(Is there a way to figure out when data is written to the DB, or to a specific table, and only then execute a script?)

Get the shift start_time from the hours_worked table in the DB, as well as the lab id. Then, look in the shifts table and see if there is a shift in the same lab for which the start_time is >= the start_time of that shift. If there is a shift that fits the criterion, do nothing, since it IS NOT the last shift. Otherwise, if we can't find a shift that has a start_time >= the start_time of the current shift, then it IS the last shift. once we know that, we should write the start_time of the current shift + 2 hrs to file (which should be the presumed end_time of the current shift). But we should only do this once (if we kept writing the time to file, we'd never reach the end_time!). To ensure we only do this once, we should start with empty files for each lab, then see if the file is empty...

(I don't want to do this with php, but here is the code...)

if (!(empty($closing_time_file))) {
// If the file is not empty, we've already written data to it, so we don't need to do anything
}
else {
// Open file pointer, write time + 7200 sec. to file
fwrite($fp, "time + 7200");
}

This should be done for each lab. Then, if the time written to file is less than the current time, the lab should be marked as closed (unless, of course, the TC on duty wants to mark it as open)

if ($current_date_time > $file_date_time) {
$open_status = FALSE;
}

Now, to create an interface for each lab, first check to see if the login cookie is set...

if (isset($_COOKIE['logon'])) {

well, I guess before that, we should have a set of variables that point to the open_status files. Perhaps we can keep this data in open_labs.php...
After we've determined the open status of a lab, do a quick foreach loop...

$array_of_open_statuses = array ($lab_a => $open_status_a, ...,
$lab_n => $open_status_n)

foreach ($array_of_open_statuses as $lab => $open_status) {
$fp = file("$HOME/labs/${"{$lab}_open_status"});
// If the open status is true, write a "1" to file
if ($open_status) {
fwrite ($fp, "1");
}
else {
// Otherwise, write a "0" to file
fwrite ($fp, "0");
}
}

On a side note, we should keep the variables in open_labs.php to be determined by the files, not the other way around. Technically, we could have a shell (or Java, Perl, Python?) script that performs a MySQL query every 5 minutes or so, writes data to a file, and then have the variables in open_labs.php determined from that

Then, in labs.php, check to see if $open_status is true and have a checkbox just like for the printer e-mails. And just as with the printers, have a php file to handle the form and change the status accordingly, redirecting you right back to index.php. Then, after having changed the file, open_labs.php will read from the file, see the change, and change the open_status of the lab accordingly


foreach $lab where Location == "Science, Room 1530" (we can do a quick regexp to parse for this info)
{
find class time;
mark lab as closed during class time;
}

GRAPHICS/DESIGN STUFF


ADMINISTRATIVE STUFF

$debug = FALSE;
if ($debug) {
print "yada yada yada";
}

Just change $debug to TRUE and it'll make the code a lot easier to maintain
And since we'll have a lot of debug messages, they should explain themselves very well, like "The $helpdesk_open variable is set to open, so both the Helpdesk and HELPDESK should show up as open"
Perhaps I can separate the debugging based on what needs to be debugged...

  • Look into delineating levels of access control. What should Micah and I have access to that other TCs don't, if anything? Perhaps other non-TCs should even have access to certain things...
  • Beef up the login system (HTTPS!)
  • Write up a small history/motivation for the map
    • Also, write up something to show other colleges why this might be useful
  • I should also look for how to handle exceptions that may occur... what happens if something breaks down, if a file gets too big, if a script stops working, if data isn't written to a file... this will be a big project... I mainly just need to reduce the interdependency of the scripts
    • Follow the principle of orthogonality
  • Make a SITE MAP
  • Check out yslow : http://developer.yahoo.com/yslow 
  • Make a [techmap] account/plan
    • Like jobs, et al., people should be able to edit the plan to submit ideas
      • But, this should only be available to users on campus. I'm seeing a bit of IP address finagling in the near future...
  • People should be able to install certain features and not install certain features when porting the map
    • What is required and what is fluff?
    • What is Grinnell specific and what is not?
  • Is wireless coverage pretty global across campus? Are there places that aren't covered? Would it be worth it to make a wireless map?
  • Check out Phing: http://phing.info/trac/
    http://immike.net/blog/2007/08/15/5-tools-every-php-programmer-should-know-about/
  • In init.php, I should have the variables take data from the DB. That way I can have a web interface to update all that stuff in the DB and the variables will cascade throughout the scripts accordingly... shell access is sweet, but my successor may not feel the same way
  • Add a v2.0 image at the end of summer

XHTML/CSS/Javascript CHANGES

OTHER STUFF (DREAMS)

TEST IN MULTIPLE BROWSERS

Browsers tested:


ACCESSIBILITY ISSUES -- I should make Accessibility a major focus, for this map and for future projects


OTHER ISSUES


THOUGHTS FROM MARK (Integrate this into the doc if you like, sort it some way else, or just leave it here)

STUFF THAT'S DONE


   # This script checks whether or not a printer responds to pings. If it does, echo 0 to the printer status file (printer is OK-- 0 is for NOT out-of-order); else echo 1 (printer is out-of-order)
[[ ping gencomp.grinnell.edu -c 4 ]]
if [ `echo $?` == 0 ]
then
echo 0 > gencomp_status
else
echo 1 > gencomp_status
echo "You should check its status page at http://gencomp.grinnell.edu or see if it responds to pings" | mail -s "The Gencomp printer may be out-of-order" helpdesk@grinnell.edu -c satherdy@grinnell.edu,botmille@grinnell.edu


...


exit 0


$helpdesk = mysql_query (yada yada yada) (where yada yada yada is the row and column in the DB, in the labs table, corresponding to the helpdesk open/closed status)

Then, once I have that variable defined for each lab, I can store all the labs in an array, then use a foreach loop to run through them...

[array here]
foreach ($labs as $lab_name => $staffed_status ) {
if ($staffed_status == 0) {
print code for closed lab
}
else {
print code for open lab
}

This is soooo much cleaner...


print $lab->get_name() " is ";
if ($always_open) {
print "always";
}
" open";


Grab printer status from Device status page, see if a paper jam or out of paper message appears, and roll from there - Change 24 hour time on lab search

grep "Tray" $status_page | wc -l

and then pass out-of-order messages accordingly





We actually don't need this info -- it's a lot easier. The message changes when only one tray is out vs. when the entire printer is out, so I just edited the paper.sh script


OTHER ARCHIVED IDEAS