<?php
//==========================================================================
// includes.php
//
// common function used by the tracker
//
// Copyright (c) 2006 Kenneth J. Snyder
// Licensed under the GNU GPL. For full terms see the file LICENSE
// -------------------------------------------------------------------------
//
// Created: 10Mar2006 Snyder, Kenneth J. hide@address.com
//
// Revised:
//
//==========================================================================
include_once("config.php");
function getversion () {
$VSTVERSION=shell_exec("./getvstversion");
return $VSTVERSION;
} // function getversion
function validate_email($email){
$exp = ".+@.+\..+.";
if(eregi($exp,$email)){
return true;
} else {
return false;
}
}
function check_unique_username ($dbconn,$USERNAME) {
$Select="select count(USRNAME) from vst.clients where USRNAME='";
$Select.=$USERNAME."' FOR FETCH ONLY";
$Result=odbc_exec($dbconn,$Select);
odbc_fetch_row($Result);
if (odbc_result($Result,1)==1) {
return true;
} else {
return false;
}
}
function footer ($FROMLOC,$adminemail) {
$FROMLOC=substr(substr($FROMLOC, -abs(strpos ($FROMLOC,".")) ),1);
$VSTVERSION=getversion();
echo "<BR>";
echo "<TABLE width='100%'>";
echo "<TR class='band'><TD>";
echo "<a href='mailto:$adminemail?subject=Question%20about%20Vehicle%20Service%20Tracker&body=From:%20$FROMLOC'>";
echo "<address>$adminemail</address></a>";
echo "</TD><TD align='right'>";
echo "<B>Vehicle Service Tracker v$VSTVERSION</B>";
echo "</TD></TR>";
echo "</TABLE>";
} // function footer
function authuser ($dbconn,$user,$sid) {
if ($user!="demo") { // always allow demo user
$SelectSID="select rtrim(SID) from vst.CLIENTS where USRNAME='$user'";
//echo "Select sid statment [$SelectSID]";
$Result=odbc_exec($dbconn,$SelectSID);
odbc_fetch_row($Result);
$SelectedSID=odbc_result($Result,1);
//echo "<BR>SelectedSID [$SelectedSID] sid [$sid]";
if ( ($SelectedSID!=$sid) || !($sid) ) {
//echo "<BR> it doesn't equal it";
odbc_close_all();
header("Location: login.php?rc=14");
die("sent back to login");
}
//die ("allowed");
} // if demo user
} // function authuser
function titleBar ($SID,$USERNAME,$VIN,$YEAR,$MAKE,$MODEL,$COLOR,
$GASMILE,$IMAGE,$GORD,$MORK) {
$EditVehicleURL="newvehicle.php?SID=$SID&USERNAME=$USERNAME&";
$EditVehicleURL.="EDIT=EDIT&VIN=$VIN&YEAR=$YEAR&MAKE=$MAKE&";
$EditVehicleURL.="MODEL=$MODEL&COLOR=$COLOR&GAS=$GASMILE&";
$EditVehicleURL.="IMAGE=$IMAGE&GORD=$GORD&MORK=$MORK";
$EditVehicleURL=htmlentities($EditVehicleURL);
// Show the title bar
// --------------------------
echo "<CENTER><B>";
echo "<a href='main.php?SID=$SID&USERNAME=$USERNAME'>Back to Main</a>";
echo "</B></CENTER>";
echo "<p class='Header2'>Vehicle: $YEAR $MAKE $MODEL ";
echo "Color: $COLOR VIN: $VIN ";
echo " ";
echo " ";
echo "<a href='".$EditVehicleURL."'>";
echo "<small> [ edit vehicle ] </small></A></P>";
} // function titlebar
function TimeoutInsert($dbconn,$USERNAME) {
$TimeOut="update vst.clients set LASTLOGIN=current_timestamp ";
$TimeOut.="where usrname='$USERNAME'";
odbc_exec($dbconn,$TimeOut);
odbc_commit($dbconn);
} // function TimeoutInsert
//function CheckTimeout($dbconn,$USERNAME) {
// $Select="select LASTLOGIN