Skip to content

Instantly share code, notes, and snippets.

@griggsk
griggsk / computer-drupal.php
Created November 29, 2010 20:00
Computer Availability Map UI for Drupal
<?php
drupal_add_css("sites/all/themes/osulibraries/comp_map.css");
drupal_add_js('setTimeout("window.location.reload()",300000);', 'inline');
db_set_active('comp_map');
$total_pc_results = db_query("SELECT * FROM compstatus WHERE computer_type='PC'");
$avail_pc_results = db_query("SELECT * FROM compstatus WHERE status='0' AND computer_type='PC'");
$pcs = mysql_num_rows($avail_pc_results) . '/' . mysql_num_rows($total_pc_results);
@griggsk
griggsk / computers.php
Created November 29, 2010 19:54
Computer Availability Map UI
<?php
#add your database username and password
$user="username";
$password="password";
$database="computer_availability";
#connect to the database
$DB = mysql_connect('mysqlcluster.adm.yourmysqlserver.edu', $user, $password);
@mysql_select_db($database) or die("Unable to select database");
@griggsk
griggsk / statuschange.php
Created November 29, 2010 19:53
Computer Availability status change script
#add your database username and password
$user="username";
$password="password";
$database="computer_availability";
#unless the computers name was empty
if($_POST['workstation'] != ""){
$workstation = strtoupper($_POST['workstation']);
}
else{ #build the computer's name from the host
@griggsk
griggsk / logout.pl
Created November 29, 2010 19:51
Computer Availability Map logout script
#!/usr/bin/perl -w
use LWP;
use Sys::Hostname;
my $host = hostname();
#the hostname after which you can find out the IP address
my $ipaddr = inet_ntoa(scalar gethostbyname($host || 'localhost'));
$ua = LWP::UserAgent->new;
@griggsk
griggsk / login.pl
Created November 29, 2010 19:50
Computer Availability Map login script
#!/usr/bin/perl -w
use LWP;
use Sys::Hostname;
my $host = hostname();
#the hostname after which you can find out the IP address
my $ipaddr = inet_ntoa(scalar gethostbyname($host || 'localhost'));
$ua = LWP::UserAgent->new;
@griggsk
griggsk / computer_availability.sql
Created November 29, 2010 19:49
Computer Availability Database
CREATE DATABASE 'computer_availability'
CREATE TABLE `compstatus` (
`computer_name` varchar(250) NOT NULL default "",
`status` int(11) default NULL,
`computer_type` varchar(250) default NULL,
`left_pos` int(11) default NULL,
`top_pos` int(11) default NULL,
`updated_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`computer_name`)
)