Category Archives: PHP Templates

Classified Script FOR PHP

Classified Script v5.1 | Best PHP Classified Script. Get Online classified script – Want to know more about such premium quality classified script? Scuttle your own distinct classifieds site with High Quality, Powerful, and Feature rich, easy to use classified ads. Professionally developed PHP Classifieds script that was built with you – the site owner – in mind and to assist you in generating income from your website. Whether you are running classifieds for autos, motorcycles, bicycles, rv’s, guns, horses, or general merchandise, our product is the right package for you.

http://www.v-eva.com/products/Classified-Script-v5.1.html

Professionally developed PHP Classifieds script that was built with you - the site owner - in mind and to assist you in generating income from your website. Whether you are running classifieds for autos, motorcycles, bicycles, rv’s, guns, horses, or general merchandise, our product is the right package for you.

•Allow buyers and sellers to communicate directly
List each item with image, description, pricing, and others
•Charge a listing fee or let sellers do it for free
•Broadcast your ads contents via RSS feed
•Set the listings to require approval or auto-approve
•You can have map on site for each listing
•You can change design for your site with single click. You can also request us for custom design.

Classified Script Features
Site Settings•Change Site Title, Keywords and Description
•Enable/Disable WYSIWYG Editor for ad posting
•Change site Logo
•Active/Inactivate Ads auto Approval
•User Registration Required or not with option  Yes/NO
•Notifier: A HTML or plain text message appear on home page after defined seconds, You can use this option for optin form or any message for visitors. If you leave it blank, no message will appear for visitors.
•Google Analytics: Simply Put good analytics code or any other code for tracking.
•Google Map Key: You can have map on site for each listing.

http://www.v-eva.com/products/Classified-Script-v5.1.html

PHP scripts for PluXml-latest

# ------------------ BEGIN LICENSE BLOCK ------------------
#
# This file is part of PluXml : http://pluxml.org
#
# Copyright (c) 2010 Stephane Ferrari and contributors
# Copyright (c) 2008-2009 Florent MONTHEL and contributors
# Copyright (c) 2006-2008 Anthony GUERIN
# Licensed under the GPL license.
# See http://www.gnu.org/licenses/gpl.html
#
# ------------------- END LICENSE BLOCK -------------------

# Configuration avançée #
define('PLX_ROOT', './');
define('PLX_CORE', PLX_ROOT.'core/');
define('PLX_CONF', PLX_ROOT.'data/configuration/parametres.xml');

# On verifie que PluXml est installé
if(!file_exists(PLX_CONF)) {
 header('Location: '.PLX_ROOT.'install.php');
 exit;
}

# On inclut les librairies nécessaires
include(PLX_ROOT.'config.php');
include(PLX_CORE.'lib/class.plx.date.php');
include(PLX_CORE.'lib/class.plx.utils.php');
include(PLX_CORE.'lib/class.plx.capcha.php');
include(PLX_CORE.'lib/class.plx.erreur.php');
include(PLX_CORE.'lib/class.plx.glob.php');
include(PLX_CORE.'lib/class.plx.record.php');
include(PLX_CORE.'lib/class.plx.motor.php');
include(PLX_CORE.'lib/class.plx.feed.php');
include(PLX_CORE.'lib/class.plx.show.php');
include(PLX_CORE.'lib/class.plx.encrypt.php');

# Creation de l'objet principal et lancement du traitement
$plxMotor = new plxMotor(PLX_CONF);
$plxMotor->prechauffage();
$plxMotor->demarrage();

# Creation de l'objet d'affichage
$plxShow = new plxShow($plxMotor);

# On démarre la bufferisation
ob_start();
ob_implicit_flush(0);

# On charge les fichiers du thème
if($plxMotor->style == '' or !is_dir(PLX_ROOT.'themes/'.$plxMotor->style)) {
 header('Content-Type: text/plain');
 echo 'Le theme principal PluXml est introuvable ('.PLX_ROOT.'themes/'.$plxMotor->style.') !';
} elseif(file_exists(PLX_ROOT.'themes/'.$plxMotor->style.'/'.$plxMotor->template)) {
 # On impose le charset
header('Content-Type: text/html; charset='.PLX_CHARSET);
 # Insertion du template
include(PLX_ROOT.'themes/'.$plxMotor->style.'/'.$plxMotor->template);
} else {
 header('Content-Type: text/plain');
 echo 'Le fichier cible PluXml est introuvable ('.PLX_ROOT.'themes/'.$plxMotor->style.'/'.$plxMotor->template.') !';
}

# Affichage
if($plxMotor->aConf['urlrewriting']) {
 if($plxMotor->aConf['gzip'])
 plxUtils::ob_gzipped_page($plxMotor->aConf['racine']);
 else
 echo plxUtils::rel2abs($plxMotor->aConf['racine'], ob_get_clean());
} else {
 if($plxMotor->aConf['gzip'])
 plxUtils::ob_gzipped_page(false);
 else
 echo ob_get_clean();
}

?>

 

 

PHP hit counter 1.0

// LoadGif returns counter image
// input: $count - number to show, $folder - digits folder
function LoadGif($count, $folder)
{
 $counter_len=strlen($count);
 $counter_digits = array();
 $counter_width = 0;
 $counter_height = 0;
 for ($i = 0; $i < $counter_len; $i++) {
 $counter_digits[$i] = @imagecreatefromgif('./'.$folder.'/'.substr($count, $i, 1).'.gif');
 $counter_width += imagesx($counter_digits[$i]);
 if ($counter_height < imagesy($counter_digits[$i]))
 $counter_height = imagesy($counter_digits[$i]);
 }
 $im = imagecreatetruecolor($counter_width, $counter_height);
 $xpos = 0;
 for ($i = 0; $i < $counter_len; $i++) {
 imagecopy($im, $counter_digits[$i], $xpos, 0, 0, 0, imagesx($counter_digits[$i]), imagesy($counter_digits[$i]));
 $xpos += imagesx($counter_digits[$i]);
 }

 for ($i = 0; $i < $counter_len; $i++) {
 imagedestroy($counter_digits[$i]);
 }
 /* See if it failed */
 if(!$im)
 {
 /* Create a blank image */
 $im = imagecreatetruecolor (150, 30);
 $bgc = imagecolorallocate ($im, 255, 255, 255);
 $tc = imagecolorallocate ($im, 0, 0, 0);

 imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);

 /* Output an error message */
 imagestring ($im, 1, 5, 5, 'Error loading ' . $imgname, $tc);
 }

 return $im;
}

// Open counter file
$counterid=((isset($_GET['counterid'])) ? $_GET['counterid'] : 0);
$style=((isset($_GET['style'])) ? $_GET['style'] : 1);

$file = './'.$counterid.'.txt';
if (file_exists($file)) {
 $counterf=file($file);
 $counter=$counterf[0];
} else {
 $counter=0;
}
$counter++;
$f=fopen($file,"w");
fputs($f, $counter);
fclose($f);

header('Content-Type: image/gif');

$img = LoadGif($counter, $style);

imagegif($img);
imagedestroy($img);

?>

&amp;nbsp;

&amp;nbsp;

Export Data From MySql to CSV (xls)

//a small class for database connectivity
 class database {
 private $db_handle;
 private $user_name;
 private $password;
 private $data_base;
 private $host_name;
 private $sql;
 private $results;

function __construct($host = “localhost”, $user, $passwd) {
 $this->db_handle = mysql_connect($host, $user, $passwd);
 }

function dbSelect($db) {
 $this->data_base = $db;
 if (!mysql_select_db($this->data_base, $this->db_handle)) {
 error_log(mysql_error(), 3,/phplog.err”);
 die(“Error connecting to Database”);
 }
 }

function executeSql($sql_stmt) {
 $this->sql = $sql_stmt;
 $this->result = mysql_query($this->sql);
 }
 function returnResults() {
 return $this->result;
 }
 }

//database variables
 $host = “localhost”;
 $user = “root”;
 $passwd = “”;
 $db = “bg_db”;
 $sql = “SELECT * FROM table ORDER BY id”; // a query to fetch records from database

$dbObject = new database($host, $user, $passwd);
 $dbObject->dbSelect($db);
 $dbObject->executeSql($sql);

$res = $dbObject->returnResults(); // result reasource

$newFileName = “emp_names.csv”; //file name that you want to create
 $fpWrite = fopen($newFileName, “w”); // open file as writable
 $nameStr = “”;

$rows = mysql_fetch_assoc($res); // fetching associate records

$sStr = “”;

//first store the fields name as header of csv in $sStr
 foreach($rows as $key=>$val) {
 $sStr .= $key.,;
 }

//then store all records
 do {
 $sStr .= “– —–\n”; //to seprate every record
 foreach($rows as $key=>$row) {
 $sStr .= $row.,;
 }
 }while($rows = mysql_fetch_assoc($res));

$sStrExp = explode(“– —–”, $sStr);//separate every record
 foreach($sStrExp as $val) {
 $sStr2 .= rtrim($val,,);
 }

echo $sStr2;

fwrite($fpWrite, $sStr2); //now write to csv file
 fclose($fpWrite);//close file
 ?>

&amp;nbsp;

&amp;nbsp;

Unzip file using PHP

if (!function_exists(file_put_contents)) {
 // If not PHP5, creates a compatible function
 function file_put_contents($file, $data) {
 if ($tmp = fopen($file, “w”)) {
 fwrite($tmp, $data);
 fclose($tmp);
 return true;
 }
 echo<b>file_put_contents:</b> Cannot create file $file<br>;
 return false;
 }
 }

class dUnzip2 {
 function getVersion() {
 return2.6;
 }
 // Public
 var $fileName;
 var $compressedList; // You will problably use only this one!
 var $centralDirList; // Central dir list… It’s a kind of ‘extra attributes’ for a set of files
 var $endOfCentral; // End of central dir, contains ZIP Comments
 var $debug;

// Private
 var $fh;
 var $zipSignature = “\x50\x4b\x03\x04″; // local file header signature
 var $dirSignature = “\x50\x4b\x01\x02″; // central dir header signature
 var $dirSignatureE = “\x50\x4b\x05\x06″; // end of central dir signature

// Public
 function dUnzip2($fileName) {
 $this->fileName = $fileName;
 $this->compressedList = $this->centralDirList = $this->endOfCentral = Array ();
 }

function getList($stopOnFile = false) {
 if (sizeof($this->compressedList)) {
 $this->debugMsg(1, “Returning already loaded file list.);
 return $this->compressedList;
 }

// Open file, and set file handler
 $fh = fopen($this->fileName, “r”);
 $this->fh = &amp; $fh;
 if (!$fh) {
 $this->debugMsg(2, “Failed to load file.);
 return false;
 }

$this->debugMsg(1, “Loading list from ‘End of Central Dir’ index list…”);
 if (!$this->_loadFileListByEOF($fh, $stopOnFile)) {
 $this->debugMsg(1, “Failed! Trying to load list looking for signatures…”);
 if (!$this->_loadFileListBySignatures($fh, $stopOnFile)) {
 $this->debugMsg(1, “Failed! Could not find any valid header.);
 $this->debugMsg(2, “ZIP File is corrupted or empty);
 return false;
 }
 }

if ($this->debug) {
 #——- Debug compressedList
$kkk = 0;
 echo<table border=0′ style=’font: 11px Verdana; border: 1px solid #000′>”;
foreach ($this->compressedList as $fileName => $item) {
 if (!$kkk &amp;&amp; $kkk = 1) {
 echo<tr style=’background: #ADA’>”;
foreach ($item as $fieldName => $value)
 echo<td>$fieldName</td>;
 echo</tr>;
 }
 echo<tr style=’background: #CFC’>”;
foreach ($item as $fieldName => $value) {
 if ($fieldName == ‘lastmod_datetime’)
 echo<td title=$fieldName’ nowrap=’nowrap’>. date(“d/m/Y H:i:s”, $value) .</td>;
 else
 echo<td title=$fieldName’ nowrap=’nowrap’>$value</td>;
 }
 echo</tr>;
 }
 echo</table>;

#——- Debug centralDirList
$kkk = 0;
 if (sizeof($this->centralDirList)) {
 echo<table border=0′ style=’font: 11px Verdana; border: 1px solid #000′>”;
foreach ($this->centralDirList as $fileName => $item) {
 if (!$kkk &amp;&amp; $kkk = 1) {
 echo<tr style=’background: #AAD’>”;
foreach ($item as $fieldName => $value)
 echo<td>$fieldName</td>;
 echo</tr>;
 }
 echo<tr style=’background: #CCF’>”;
foreach ($item as $fieldName => $value) {
 if ($fieldName == ‘lastmod_datetime’)
 echo<td title=$fieldName’ nowrap=’nowrap’>. date(“d/m/Y H:i:s”, $value) .</td>;
 else
 echo<td title=$fieldName’ nowrap=’nowrap’>$value</td>;
 }
 echo</tr>;
 }
 echo</table>;
 }

#——- Debug endOfCentral
$kkk = 0;
 if (sizeof($this->endOfCentral)) {
 echo<table border=0′ style=’font: 11px Verdana’ style=’border: 1px solid #000′>”;
echo<tr style=’background: #DAA’><td colspan=’2′>dUnzip – End of file</td></tr>”;
foreach ($this->endOfCentral as $field => $value) {
 echo<tr>;
 echo<td style=’background: #FCC’>$field</td>”;
echo<td style=’background: #FDD’>$value</td>”;
echo</tr>;
 }
 echo</table>;
 }
 }

return $this->compressedList;
 }
 function getExtraInfo($compressedFileName) {
 return isset ($this->centralDirList[$compressedFileName]) ? $this->centralDirList[$compressedFileName] : false;
 }
 function getZipInfo($detail = false) {
 return $detail ? $this->endOfCentral[$detail] : $this->endOfCentral;
 }

function unzip($compressedFileName, $targetFileName = false, $applyChmod = false) {
 if (!sizeof($this->compressedList)) {
 $this->debugMsg(1, “Trying to unzip before loading file list… Loading it!);
 $this->getList(false, $compressedFileName);
 }

$fdetails = &amp; $this->compressedList[$compressedFileName];
 if (!isset ($this->compressedList[$compressedFileName])) {
 $this->debugMsg(2,File<b>$compressedFileName</b>’ is not compressed in the zip.);
 return false;
 }
 if (substr($compressedFileName, -1) ==/) {
 $this->debugMsg(2, “Trying to unzip a folder name ‘<b>$compressedFileName</b>.);
 return false;
 }
 if (!$fdetails['uncompressed_size']) {
 $this->debugMsg(1,File<b>$compressedFileName</b>’ is empty.);
 return $targetFileName ? file_put_contents($targetFileName, “”) : “”;
 }

fseek($this->fh, $fdetails['contents-startOffset']);
 $ret = $this->uncompress(fread($this->fh,  $fdetails['compressed_size']), $fdetails['compression_method'],  $fdetails['uncompressed_size'], $targetFileName);
 if ($applyChmod &amp;&amp; $targetFileName)
 chmod($targetFileName, 0777);

return $ret;
 }
 function unzipAll($targetDir = false, $baseDir = “”, $maintainStructure = true, $applyChmod = false) {
 if ($targetDir === false)
 $targetDir = dirname(__FILE__) ./;

$lista = $this->getList();
 if (sizeof($lista))
 foreach ($lista as $fileName => $trash) {
 $dirname = dirname($fileName);
 $outDN =$targetDir/$dirname;

if (substr($dirname, 0, strlen($baseDir)) != $baseDir)
 continue;

if (!is_dir($outDN) &amp;&amp; $maintainStructure) {
 $str = “”;
 $folders = explode(/, $dirname);
 foreach ($folders as $folder) {
 $str = $str ? “$str/$folder: $folder;
 if (!is_dir($targetDir/$str)) {
 $this->debugMsg(1, “Creating folder: $targetDir/$str);
 mkdir($targetDir/$str);
 if ($applyChmod)
 chmod($targetDir/$str, $applyChmod);
 }
 }
 }
 if (substr($fileName, -1, 1) ==/)
 continue;

$maintainStructure ? $this->unzip($fileName,  “$targetDir/$fileName, $applyChmod) : $this->unzip($fileName,  “$targetDir/. basename($fileName), $applyChmod);
 }
 }

function close() { // Free the file resource
 if ($this->fh)
 fclose($this->fh);
 }
 function __destroy() {
 $this->close();
 }

// Private (you should NOT call these methods):
 function uncompress($content, $mode, $uncompressedSize, $targetFileName = false) {
 switch ($mode) {
 case 0 :
 // Not compressed
 return $targetFileName ? file_put_contents($targetFileName, $content) : $content;
 case 1 :
 $this->debugMsg(2, “Shrunk mode is not supported… yet?”);
 return false;
 case 2 :
 case 3 :
 case 4 :
 case 5 :
 $this->debugMsg(2, “Compression factor ” . ($mode -1) . ” is not supported… yet?”);
 return false;
 case 6 :
 $this->debugMsg(2,Implode is not supported… yet?”);
 return false;
 case 7 :
 $this->debugMsg(2, “Tokenizing compression algorithm is not supported… yet?”);
 return false;
 case 8 :
 // Deflate
 return $targetFileName ? file_put_contents($targetFileName,  gzinflate($content, $uncompressedSize)) : gzinflate($content,  $uncompressedSize);
 case 9 :
 $this->debugMsg(2, “Enhanced Deflating is not supported… yet?”);
 return false;
 case 10 :
 $this->debugMsg(2, “PKWARE Date Compression Library Impoloding is not supported… yet?”);
 return false;
 case 12 :
 // Bzip2
 return $targetFileName ? file_put_contents($targetFileName, bzdecompress($content)) : bzdecompress($content);
 case 18 :
 $this->debugMsg(2, “IBM TERSE is not supported… yet?”);
 return false;
 default :
 $this->debugMsg(2, “Unknown uncompress method: $mode);
 return false;
 }
 }
 function debugMsg($level, $string) {
 if ($this->debug)
 if ($level == 1)
 echo<b style=’color: #777′>dUnzip2:</b> $string<br>”;
if ($level == 2)
 echo<b style=’color: #F00′>dUnzip2:</b> $string<br>”;
}

function _loadFileListByEOF(&amp; $fh, $stopOnFile = false) {
 // Check if there’s a valid Central Dir signature.
 // Let’s consider a file comment smaller than 1024 characters…
 // Actually, it length can be 65536.. But we’re not going to support it.

for ($x = 0; $x < 1024; $x++) {
 fseek($fh, -22$x, SEEK_END);

$signature = fread($fh, 4);
 if ($signature == $this->dirSignatureE) {
 // If found EOF Central Dir
 $eodir['disk_number_this'] = unpack(“v”, fread($fh, 2)); // number of this disk
 $eodir['disk_number'] = unpack(“v”, fread($fh, 2)); // number of the disk with the start of the central directory
 $eodir['total_entries_this'] = unpack(“v”, fread($fh, 2)); // total number of entries in the central dir on this disk
 $eodir['total_entries'] = unpack(“v”, fread($fh, 2)); // total number of entries in
 $eodir['size_of_cd'] = unpack(“V”, fread($fh, 4)); // size of the central directory
 $eodir['offset_start_cd'] = unpack(“V”, fread($fh, 4)); // offset of  start of central directory with respect to the starting disk number
 $zipFileCommentLenght = unpack(“v”, fread($fh, 2)); // zipfile comment length
 $eodir['zipfile_comment'] = $zipFileCommentLenght[1] ? fread($fh, $zipFileCommentLenght[1]) :; // zipfile comment
 $this->endOfCentral = Array (
 ‘disk_number_this’ => $eodir['disk_number_this'][1],
 ‘disk_number’ => $eodir['disk_number'][1],
 ‘total_entries_this’ => $eodir['total_entries_this'][1],
 ‘total_entries’ => $eodir['total_entries'][1],
 ‘size_of_cd’ => $eodir['size_of_cd'][1],
 ‘offset_start_cd’ => $eodir['offset_start_cd'][1],
 ‘zipfile_comment’ => $eodir['zipfile_comment'],

);

// Then, load file list
 fseek($fh, $this->endOfCentral['offset_start_cd']);
 $signature = fread($fh, 4);

while ($signature == $this->dirSignature) {
 $dir['version_madeby'] = unpack(“v”, fread($fh, 2)); // version made by
 $dir['version_needed'] = unpack(“v”, fread($fh, 2)); // version needed to extract
 $dir['general_bit_flag'] = unpack(“v”, fread($fh, 2)); // general purpose bit flag
 $dir['compression_method'] = unpack(“v”, fread($fh, 2)); // compression method
 $dir['lastmod_time'] = unpack(“v”, fread($fh, 2)); // last mod file time
 $dir['lastmod_date'] = unpack(“v”, fread($fh, 2)); // last mod file date
 $dir['crc-32'] = fread($fh, 4); // crc-32
 $dir['compressed_size'] = unpack(“V”, fread($fh, 4)); // compressed size
 $dir['uncompressed_size'] = unpack(“V”, fread($fh, 4)); // uncompressed size
 $fileNameLength = unpack(“v”, fread($fh, 2)); // filename length
 $extraFieldLength = unpack(“v”, fread($fh, 2)); // extra field length
 $fileCommentLength = unpack(“v”, fread($fh, 2)); // file comment length
 $dir['disk_number_start'] = unpack(“v”, fread($fh, 2)); // disk number start
 $dir['internal_attributes'] = unpack(“v”, fread($fh, 2)); // internal file attributes-byte1
 $dir['external_attributes1'] = unpack(“v”, fread($fh, 2)); // external file attributes-byte2
 $dir['external_attributes2'] = unpack(“v”, fread($fh, 2)); // external file attributes
 $dir['relative_offset'] = unpack(“V”, fread($fh, 4)); // relative offset of local header
 $dir['file_name'] = fread($fh, $fileNameLength[1]); // filename
 $dir['extra_field'] = $extraFieldLength[1] ? fread($fh, $extraFieldLength[1]) :; // extra field
 $dir['file_comment'] = $fileCommentLength[1] ? fread($fh, $fileCommentLength[1]) :; // file comment

// Convert the date and time, from MS-DOS format to UNIX Timestamp
 $BINlastmod_date = str_pad(decbin($dir['lastmod_date'][1]), 16,0, STR_PAD_LEFT);
 $BINlastmod_time = str_pad(decbin($dir['lastmod_time'][1]), 16,0, STR_PAD_LEFT);
 $lastmod_dateY = bindec(substr($BINlastmod_date, 0, 7)) + 1980;
 $lastmod_dateM = bindec(substr($BINlastmod_date, 7, 4));
 $lastmod_dateD = bindec(substr($BINlastmod_date, 11, 5));
 $lastmod_timeH = bindec(substr($BINlastmod_time, 0, 5));
 $lastmod_timeM = bindec(substr($BINlastmod_time, 5, 6));
 $lastmod_timeS = bindec(substr($BINlastmod_time, 11, 5));

$this->centralDirList[$dir['file_name']] = Array (
 ‘version_madeby’ => $dir['version_madeby'][1],
 ‘version_needed’ => $dir['version_needed'][1],
 ‘general_bit_flag’ => str_pad(decbin($dir['general_bit_flag'][1]
 ), 8,0, STR_PAD_LEFT), ‘compression_method’ =>  $dir['compression_method'][1], ‘lastmod_datetime’ =>  mktime($lastmod_timeH, $lastmod_timeM, $lastmod_timeS, $lastmod_dateM,  $lastmod_dateD, $lastmod_dateY), ‘crc-32=>  str_pad(dechex(ord($dir['crc-32'][3])), 2,0, STR_PAD_LEFT) .
 str_pad(dechex(ord($dir['crc-32'][2])), 2,0, STR_PAD_LEFT) .
 str_pad(dechex(ord($dir['crc-32'][1])), 2,0, STR_PAD_LEFT) .
 str_pad(dechex(ord($dir['crc-32'][0])), 2,0, STR_PAD_LEFT),  ‘compressed_size’ => $dir['compressed_size'][1], ‘uncompressed_size’  => $dir['uncompressed_size'][1], ‘disk_number_start’ =>  $dir['disk_number_start'][1], ‘internal_attributes’ =>  $dir['internal_attributes'][1], ‘external_attributes1′ =>  $dir['external_attributes1'][1], ‘external_attributes2′ =>  $dir['external_attributes2'][1], ‘relative_offset’ =>  $dir['relative_offset'][1], ‘file_name’ => $dir['file_name'],  ‘extra_field’ => $dir['extra_field'], ‘file_comment’ =>  $dir['file_comment'],);
 $signature = fread($fh, 4);
 }

// If loaded centralDirs, then try to identify the offsetPosition of the compressed data.
 if ($this->centralDirList)
 foreach ($this->centralDirList as $filename => $details) {
 $i = $this->_getFileHeaderInformation($fh, $details['relative_offset']);
 $this->compressedList[$filename]['file_name'] = $filename;
 $this->compressedList[$filename]['compression_method'] = $details['compression_method'];
 $this->compressedList[$filename]['version_needed'] = $details['version_needed'];
 $this->compressedList[$filename]['lastmod_datetime'] = $details['lastmod_datetime'];
 $this->compressedList[$filename]['crc-32'] = $details['crc-32'];
 $this->compressedList[$filename]['compressed_size'] = $details['compressed_size'];
 $this->compressedList[$filename]['uncompressed_size'] = $details['uncompressed_size'];
 $this->compressedList[$filename]['lastmod_datetime'] = $details['lastmod_datetime'];
 $this->compressedList[$filename]['extra_field'] = $i['extra_field'];
 $this->compressedList[$filename]['contents-startOffset'] = $i['contents-startOffset'];
 if (strtolower($stopOnFile) == strtolower($filename))
 break;
 }
 return true;
 }
 }
 return false;
 }
 function _loadFileListBySignatures(&amp; $fh, $stopOnFile = false) {
 fseek($fh, 0);

$return = false;
 for (;;) {
 $details = $this->_getFileHeaderInformation($fh);
 if (!$details) {
 $this->debugMsg(1, “Invalid signature. Trying to verify if is old style Data Descriptor…”);
 fseek($fh, 124, SEEK_CUR); // 12: Data descriptor – 4: Signature (that will be read again)
 $details = $this->_getFileHeaderInformation($fh);
 }
 if (!$details) {
 $this->debugMsg(1, “Still invalid signature. Probably reached the end of the file.);
 break;
 }
 $filename = $details['file_name'];
 $this->compressedList[$filename] = $details;
 $return = true;
 if (strtolower($stopOnFile) == strtolower($filename))
 break;
 }

return $return;
 }
 function _getFileHeaderInformation(&amp; $fh, $startOffset = false) {
 if ($startOffset !== false)
 fseek($fh, $startOffset);

$signature = fread($fh, 4);
 if ($signature == $this->zipSignature) {
 # $this->debugMsg(1, “Zip Signature!”);

// Get information about the zipped file
 $file['version_needed'] = unpack(“v”, fread($fh, 2)); // version needed to extract
 $file['general_bit_flag'] = unpack(“v”, fread($fh, 2)); // general purpose bit flag
 $file['compression_method'] = unpack(“v”, fread($fh, 2)); // compression method
 $file['lastmod_time'] = unpack(“v”, fread($fh, 2)); // last mod file time
 $file['lastmod_date'] = unpack(“v”, fread($fh, 2)); // last mod file date
 $file['crc-32'] = fread($fh, 4); // crc-32
 $file['compressed_size'] = unpack(“V”, fread($fh, 4)); // compressed size
 $file['uncompressed_size'] = unpack(“V”, fread($fh, 4)); // uncompressed size
 $fileNameLength = unpack(“v”, fread($fh, 2)); // filename length
 $extraFieldLength = unpack(“v”, fread($fh, 2)); // extra field length
 $file['file_name'] = fread($fh, $fileNameLength[1]); // filename
 $file['extra_field'] = $extraFieldLength[1] ? fread($fh, $extraFieldLength[1]) :; // extra field
 $file['contents-startOffset'] = ftell($fh);

// Bypass the whole compressed contents, and look for the next file
 fseek($fh, $file['compressed_size'][1], SEEK_CUR);

// Convert the date and time, from MS-DOS format to UNIX Timestamp
 $BINlastmod_date = str_pad(decbin($file['lastmod_date'][1]), 16,0, STR_PAD_LEFT);
 $BINlastmod_time = str_pad(decbin($file['lastmod_time'][1]), 16,0, STR_PAD_LEFT);
 $lastmod_dateY = bindec(substr($BINlastmod_date, 0, 7)) + 1980;
 $lastmod_dateM = bindec(substr($BINlastmod_date, 7, 4));
 $lastmod_dateD = bindec(substr($BINlastmod_date, 11, 5));
 $lastmod_timeH = bindec(substr($BINlastmod_time, 0, 5));
 $lastmod_timeM = bindec(substr($BINlastmod_time, 5, 6));
 $lastmod_timeS = bindec(substr($BINlastmod_time, 11, 5));

// Mount file table
 $i = Array (
 ‘file_name’ => $file['file_name'],
 ‘compression_method’ => $file['compression_method'][1],
 ‘version_needed’ => $file['version_needed'][1],
 ‘lastmod_datetime’ => mktime($lastmod_timeH,
 $lastmod_timeM,
 $lastmod_timeS,
 $lastmod_dateM,
 $lastmod_dateD,
 $lastmod_dateY
 ), ‘crc-32=> str_pad(dechex(ord($file['crc-32'][3])), 2,0, STR_PAD_LEFT) .
 str_pad(dechex(ord($file['crc-32'][2])), 2,0, STR_PAD_LEFT) .
 str_pad(dechex(ord($file['crc-32'][1])), 2,0, STR_PAD_LEFT) .
 str_pad(dechex(ord($file['crc-32'][0])), 2,0, STR_PAD_LEFT),  ‘compressed_size’ => $file['compressed_size'][1], ‘uncompressed_size’  => $file['uncompressed_size'][1], ‘extra_field’ =>  $file['extra_field'], ‘general_bit_flag’ =>  str_pad(decbin($file['general_bit_flag'][1]), 8,0, STR_PAD_LEFT),  ‘contents-startOffset’ => $file['contents-startOffset']);
 return $i;
 }
 return false;
 }
 }

$zip = new dUnzip2(‘zipfile.zip’);
 $zip->debug = false; // you can enable if you want to show whats happning
 $zip->getList();
 $zip->unzipAll();

?>

&amp;nbsp;

&amp;nbsp;

PHP scripts for Maintitem

<head>
 <title>Item Maintenance</title>
 <link type="text/css" rel="stylesheet" href="../stylea.css" />
 <link type="text/css" rel="stylesheet" media="print" href="../stylep.css" />
</head>
<body>

<?php
/* maintitem.php                                                       */
/* Item Maintenance                                                */
/* Copyright (C) 2005 Toivo Talikka                                           */

/* This program is free software; you can redistribute it and/or modify it under the terms of     */
/* of the GNU General Public License as published by the Free Software Foundation;            */
/* either version 2 of the License, or any later version.                              */

/* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;      */
/* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.      */
/* See the GNU General Public License for more details.                         */

/* You should have received a copy of the GNU General Public License along with this            */
/* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,     */
/* Boston, MA 02111-1307 USA                                             */
/*                                                             */
/* The GNU General Public Licence (GPL) can be viewed at:                                 */
/*            http://www.opensource.org/licenses/gpl-license.php                */
/*                                                        */
/* Toivo Talikka can be contacted by email:    toivo@totaldata.biz                       */
/* ---------------------------------------------------------------------------------------------*/


/* ----------------------------------------------------*/
/* Modification history                      */
/* 09/12/05 TJT Initial version                  */
/*                                */
/* ----------------------------------------------------*/

/* functions                        */
include("../../sub/submysql.php");
include("../../sub/subconfig.php");
include("../../sub/subdisplay.php");
include("../../sub/subtimedate.php");

/* HTML special characters converted before data is displayed        */
/* CRLF in description stored in the database to retain formatting   */

// ----------
// item form
function show_item($item, $subcategory, $description, $supplier, $item_index, $menu) {
global $sql_result_subcategories, $sql_result_suppliers;
 if ($item) {
 $sel_subcategory = $subcategory;
 $sel_supplier = $supplier;
 }
?>
 <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
 <table>
 <tbody>
 <tr>
 <td><strong>Item</strong></td>
<?php
 echo "<td><input type=\"text\" size=\"50\" name=\"item\" value=\"$item\" /></td>
 </tr>
 <tr>
 <td><strong>Subcategory</strong></td>
 <td><select name=\"sel_subcategory\"><option value=\"$subcategory\">$subcategory</option>"
;
 while ($row = mysqli_fetch_array($sql_result_subcategories)) {
 $subcat_opt = $row['subcategory'];
 echo "<option value=\"$subcat_opt\">$subcat_opt</option>";
 }
 echo "</select></td>
 </tr>
 <tr>
 <td><strong>Description</strong></td>
 <td><input type=\"text\" size=\"50\" name=\"description\" value=\"$description\" /></td>
 </tr>
 <tr>
 <td><strong>Supplier</strong></td>

 <td><select name=\"sel_supplier\"><option value=\"$supplier\">$supplier</option>"
;
 while ($row = mysqli_fetch_array($sql_result_suppliers)) {
 $supplier_opt = $row['supplier'];
 echo "<option value=\"$supplier_opt\">$supplier_opt</option>";
 }
 echo "</select></td>
 </tr>
 <tr><td><input type=\"hidden\" name=\"item_code\" value=\"$item\" /></td><td><input type=\"hidden\" name=\"item_index\" value=\"$item_index\" /></td></tr>"
;
?>
 <tr><td></td><td><table><tbody><tr><td><input type="submit" value="First" name="first" /></td><td><input type="submit" value="Previous" name="previous" /></td><td><input type="submit" value="Next" name="next" /></td><td><input type="submit" value="Last" name="last" /></td><td>&amp;nbsp;</td><td><input type="submit" value="Reset" name="reset" /></td><td>&amp;nbsp;</td><td>&amp;nbsp;</td><td><input type="submit" value="Clear" name="clear" /></td><td>&amp;nbsp;</td><td>&amp;nbsp;</td><td><input type="submit" value="Add" name="add" /></td><td><input type="submit" value="Update" name="update" /></td><td><input type="submit" value="List" name="list" /></td><td><input type="submit" value="Delete" name="delete" /></td></tr></tbody></table></td>
 </tr>
 </tbody>
 </table></form>
<?php
 sub_button($menu, "Menu");
 return;
 }

// -----------------
// create item array , list of subcategories and suppliers
function create_item_list($db_connection) {
global $item_array, $sql_result_subcategories, $sql_result_suppliers;

// sql query - list items
 $sql_item_list = "SELECT item, subcategory, description, supplier FROM item ORDER BY item";

// list items
 $sql_item_list_result = sub_query($sql_item_list, $db_connection);

 if (!$sql_item_list_result) {
 sub_company_heading($my_company, $module_name, $application);
 sub_message_error("Unable to access item table");
 sub_button($module, "Reset");
 sub_button($menu, "Menu");
 exit;
 }

// create item array
 $item_index = 0;

// escape single, double quote, backslash
 while ($row = mysqli_fetch_array($sql_item_list_result)) {
 $item_esc = addslashes($row['item']);
 $subcategory_esc = addslashes($row['subcategory']);
 $description_esc = addslashes($row['description']);
 $supplier_esc = addslashes($row['supplier']);
 $item_array[$item_index] = array($item_esc, $subcategory_esc, $description_esc, $supplier_esc);
 $item_index += 1;
 }
 $last_item = $item_index - 1;

// sql query - list of subcategories
 $sql_list_subcategories = "SELECT subcategory, category, description from subcategory ORDER BY category, subcategory";

// execute SQL query
 $sql_result_subcategories = sub_query($sql_list_subcategories, $db_connection);

 if (!$sql_result_subcategories) {
 sub_company_heading($my_company, $module_name, $application);
 sub_message_error("Unable to access subcategory table");
 sub_button($module, "Reset");
 sub_button($menu, "Menu");
 exit;
 }

// sql query - list of suppliers
 $sql_list_suppliers = "SELECT supplier, address, contact, telephone FROM supplier ORDER BY supplier";

// execute SQL query
 $sql_result_suppliers = sub_query($sql_list_suppliers, $db_connection);

 if (!$sql_result_suppliers) {
 sub_company_heading($my_company, $module_name, $application);
 sub_message_error("Unable to access supplier table");
 sub_button($module, "Reset");
 sub_button($menu, "Menu");
 exit;
 }
//  -1 if no items
 return $last_item;
 }

// ------------------------------
// display item form with no data
function no_item_data($item_index, $my_company, $module_name, $menu, $application) {
 sub_company_heading($my_company, $module_name, $application);
 show_item("", "", "", "", $item_index, $menu);
 return;
 }

// ---------------------------------------------------
// extract item data from item array and use htmlspecialchars
function get_item_html($item_index) {
global $item_array;

 if (!($item_index < 0)) {
 list($item_esc, $subcategory_esc, $description_esc, $supplier_esc) = $item_array[$item_index];
 $item_html = htmlspecialchars(stripslashes($item_esc), ENT_QUOTES);
 $subcategory_html = htmlspecialchars(stripslashes($subcategory_esc), ENT_QUOTES);
 $description_html = htmlspecialchars(stripslashes($description_esc), ENT_QUOTES);
 $supplier_html = htmlspecialchars(stripslashes($supplier_esc), ENT_QUOTES);
 return array($item_html, $subcategory_html, $description_html, $supplier_html);
 } else {
 return array("", "", "", "");
 }
}

// ---------------------------------------------------
// extract item data from item array, with backslashes
function get_item_esc($item_index) {
global $item_array;
 if (!($item_index < 0)) {
 return $item_array[$item_index];
 } else {
 return array("", "", "", "");
 }
}

// ---------------------------------
// main module
// ---------------------------------

 $module_name="Item Maintenance";
 $module="maintitem.php";
 $db = "billing";

// get config variables and create connection
 list($my_company, $date_format, $menu, $database, $date_separator, $db_connection, $application) = sub_config($db);

 $first_item = 0;
 $last_item = create_item_list($db_connection);

// check if form was submitted and which button was pressed, set switch
 $switch = "first";

 if (isset($_POST['update']))  {
 $switch = "update";
 }
 if (isset($_POST['previous']))  {
 $switch = "previous";
 }
 if (isset($_POST['next']))  {
 $switch = "next";
 }
 if (isset($_POST['first']))  {
 $switch = "first";
 }
 if (isset($_POST['last']))  {
 $switch = "last";
 }
 if (isset($_POST['reset']))  {
 $switch = "reset";
 }
 if (isset($_POST['clear']))  {
 $switch = "clear";
 }
 if (isset($_POST['add']))  {
 $switch = "add";
 }
 if (isset($_POST['list']))  {
 $switch = "list";
 }
 if (isset($_POST['delete']))  {
 $switch = "delete";
 }

switch($switch) {
//---------------------------------------------------
 case "first":
// start case - first item

 $item_index = $first_item;
 if ($last_item < 0) {
 no_item_data($last_item, $my_company, $module_name, $menu, $application);
 exit;
 }

// get item details from array processed for html
 list($item_html, $subcategory_html, $description_html, $supplier_html) = get_item_html($item_index);

// display form
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);

 break;
// end case first

//---------------------------------------------------
 case "add":
// start case - add pressed

// retrieve variables
 $item = trim($_POST['item']);
 $subcategory = trim($_POST['sel_subcategory']);
 $description = trim($_POST['description']);
 $supplier = trim($_POST['sel_supplier']);
 $item_index = $_POST['item_index'];

// escape quotes and slash
 $item_esc = addslashes($item);
 $subcategory_esc = addslashes($subcategory);
 $description_esc = addslashes($description);
 $supplier_esc = addslashes($supplier);

// htmlspecialchars
 $item_html = htmlspecialchars($item, ENT_QUOTES);
 $subcategory_html = htmlspecialchars($subcategory, ENT_QUOTES);
 $description_html = htmlspecialchars($description, ENT_QUOTES);
 $supplier_html = htmlspecialchars($supplier, ENT_QUOTES);

// validate input
 if ((!$item_esc) or (!$subcategory_esc) or (!$description_esc) or (!$supplier_esc)) {
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $last_item + 1, $menu);
 sub_message_warning("At least one field is blank");
 exit;
 }

// sql query - insert
 $sql_insert = "INSERT INTO item (item, subcategory, description, supplier) VALUES ('$item_esc', '$subcategory_esc', '$description_esc', '$supplier_esc')";

// sql query - lookup
 $sql_lookup = "SELECT item, subcategory, description, supplier FROM item WHERE item='$item_esc'";

// lookup item
 $sql_result = sub_query($sql_lookup,$db_connection);

 while ($row = mysqli_fetch_array($sql_result)) {
 $item2 =  $row['item'];
 $subcategory2 =  $row['subcategory'];
 $description2 =  $row['description'];
 $supplier2 =  $row['supplier'];

// htmlspecialchars
 $item2_html = htmlspecialchars($item2, ENT_QUOTES);
 $subcategory2_html = htmlspecialchars($subcategory2, ENT_QUOTES);
 $description2_html = htmlspecialchars($description2, ENT_QUOTES);
 $supplier2_html = htmlspecialchars($supplier2, ENT_QUOTES);
 }

 if (isset($item2)) {
 sub_company_heading($my_company, $module_name, $application);
 show_item($item2_html, $subcategory2_html, $description2_html, $supplier2_html, $last_item, $menu);
 sub_message_error("Item already exists");
 exit;
 }

 $sql_result = sub_query($sql_insert,$db_connection);

// force 'invalid item' status
 $new_item_index = $last_item + 1;

 if (!$sql_result) {
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $new_item_index, $menu);
 sub_message_error("Unable to add item");
 } else {
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $new_item_index, $menu);
 sub_message_info("A new item was added");
 }

 break;
// end case add

//---------------------------------------------------
 case "update":
// start case - update item
// item_index from the original item
// item name is the key and cannot be changed

// retrieve variables
 $item = trim($_POST['item']);
 $subcategory = trim($_POST['sel_subcategory']);
 $description = trim($_POST['description']);
 $supplier = trim($_POST['sel_supplier']);
 $item_index = $_POST['item_index'];

// escape quotes and slash
 $item_esc = addslashes($item);
 $subcategory_esc = addslashes($subcategory);
 $description_esc = addslashes($description);
 $supplier_esc = addslashes($supplier);

// htmlspecialchars
 $item_html = htmlspecialchars($item, ENT_QUOTES);
 $subcategory_html = htmlspecialchars($subcategory, ENT_QUOTES);
 $description_html = htmlspecialchars($description, ENT_QUOTES);
 $supplier_html = htmlspecialchars($supplier, ENT_QUOTES);

// validate input
 if ((!$item_esc) or (!$subcategory_esc) or (!$description_esc) or (!$supplier_esc)) {
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);
 sub_message_warning("At least one of the fields is blank");
 exit;
 }

// *******************
// validate item index
// *******************
 if (!is_numeric($item_index) or ($item_index > $last_item) or ($item_index < 0)) {
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);
 sub_message_error("Item does not exist, it cannot be updated");
 exit;
 }

// ***********************
// cannot change item key
// ***********************
// get item details from array
 list($item2_esc, $subcategory2_esc, $description2_esc, $supplier2_esc) = get_item_esc($item_index);

// compare form to array
 if (!($item_esc == $item2_esc)) {
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);
 sub_message_error("Item code was changed, item cannot be updated");
 exit;
 }

// sql query - update a row in item table
 $sql_update_item = "UPDATE item SET subcategory='$subcategory_esc', description='$description_esc', supplier='$supplier_esc' WHERE item='$item_esc'";

 $sql_update_item_result = sub_query($sql_update_item, $db_connection);

 if (!$sql_update_item_result) {
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);
 sub_message_error("Unable to update item");
 exit;
 }

// display form
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);
 sub_message_info("Item was updated");

 break;
// end case update

//---------------------------------------------------
 case "delete":
// start case delete

// retrieve variables
 $item = trim($_POST['item']);
 $subcategory = trim($_POST['sel_subcategory']);
 $description = trim($_POST['description']);
 $supplier = trim($_POST['sel_supplier']);
 $item_index = $_POST['item_index'];

// escape quotes and slash
 $item_esc = addslashes($item);

// htmlspecialchars
 $item_html = htmlspecialchars($item, ENT_QUOTES);
 $subcategory_html = htmlspecialchars($subcategory, ENT_QUOTES);
 $description_html = htmlspecialchars($description, ENT_QUOTES);
 $supplier_html = htmlspecialchars($supplier, ENT_QUOTES);

// *******************
// validate item index
// *******************
 if (!is_numeric($item_index) or ($item_index > $last_item) or ($item_index < 0)) {
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $last_item + 1, $menu);
 sub_message_error("Item does not exist, it cannot be deleted");
 exit;
 }

// ***********************
// cannot change item key
// ***********************
// get item details from array
 list($item2_esc, $subcategory2_esc, $description2_esc, $supplier2_esc) = get_item_esc($item_index);

// compare item
 if (!($item_esc == $item2_esc)) {
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);
 sub_message_error("Item code was changed, item cannot be deleted");
 exit;
 }

// sql delete query
 $sql_delete = "DELETE FROM item WHERE item='$item_esc'";

 $sql_delete_result = sub_query($sql_delete, $db_connection);

 if (!$sql_delete_result) {
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);
 sub_message_error("Unable to delete from item table");
 exit;
 } else {
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);
 sub_message_info("Item was deleted");
 exit;
 }

 break;
// end case delete

//---------------------------------------------------
 case "previous":
// start case - previous pressed

// retrieve hidden field from form
 $item_index = $_POST['item_index'];

 if (!is_numeric($item_index) or ($item_index > $last_item) or ($item_index < 0)) {
 no_item_data($last_item, $my_company, $module_name, $menu, $application);
 exit;
 }

// decrement item pointer, first --> last
 if (($item_index > 0) and ($item_index <= $last_item)) {
 $item_index -= 1;
 } else {
 $item_index = $last_item;
 }

// get item details from array in html format
 list($item_html, $subcategory_html, $description_html, $supplier_html) = get_item_html($item_index);

// display form
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);

 break;
// end case previous

//---------------------------------------------------
 case "next":
// start case - next pressed

// retrieve hidden field from form
 $item_index = $_POST['item_index'];

 if (!is_numeric($item_index) or ($item_index > $last_item) or ($item_index < 0)) {
 no_item_data($last_item, $my_company, $module_name, $menu, $application);
 exit;
 }

// increment item pointer, last --> first
 if (($item_index >= 0) and ($item_index < $last_item)) {
 $item_index += 1;
 } else {
 $item_index = 0;
 }

// get item details from array in html format
 list($item_html, $subcategory_html, $description_html, $supplier_html) = get_item_html($item_index);

// display the form
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);

 break;
// end case next

//---------------------------------------------------
 case "last":
// start case - last pressed

 $item_index = $last_item;

 if ($last_item < 0) {
 no_item_data($last_item, $my_company, $module_name, $menu, $application);
 exit;
 }

// get item details from array in html format
 list($item_html, $subcategory_html, $description_html, $supplier_html) = get_item_html($item_index);

// display form
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);

 break;
// end case last

//---------------------------------------------------
 case "reset":
// start case - reset pressed

// retrieve hidden field from form
 $item_index = $_POST['item_index'];

 if (!is_numeric($item_index) or ($item_index > $last_item) or ($item_index < 0)) {
 no_item_data($last_item, $my_company, $module_name, $menu, $application);
 exit;
 }

// get item details from array in html format
 list($item_html, $subcategory_html, $description_html, $supplier_html) = get_item_html($item_index);

// display form
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);

 break;
// end case reset

//---------------------------------------------------
 case "clear":
// start case - clear pressed

// retrieve hidden field from form
 $item_index = $_POST['item_index'];

 $item_html = "";
 $subcategory_html = "";
 $description_html = "";
 $supplier_html = "";

// display form
 sub_company_heading($my_company, $module_name, $application);
 show_item($item_html, $subcategory_html, $description_html, $supplier_html, $item_index, $menu);

 break;
// end case clear

//---------------------------------------------------
 case "list":
// start case - list items from the item array

// today's date
 list($timestamp, $today, $local_date) = get_date($date_format, $date_separator);

 $item_index = 0;
 echo "<h1>$my_company</h1><h1>&amp;nbsp;</h1><h1>Inventory Items &amp;nbsp; &amp;nbsp; &amp;nbsp; $local_date</h1><h1>&amp;nbsp;</h1>
 <table><tbody>
 <tr style=\"font-family: helvetica; background-color: #FFEC69; font-weight: bold\">"
;
 echo "<td>Item</td><td style=\"background-color: #FFFFFF;\">&amp;nbsp;</td><td>Subcategory</td><td>Description</td><td>Supplier</td></tr>";
 while (!($item_index > $last_item)) {
 list($item_html, $subcategory_html, $description_html, $supplier_html) = get_item_html($item_index);
 $item_index += 1;
 echo "<tr><td>$item_html</td><td>&amp;nbsp;</td><td>$subcategory_html</td><td>$description_html</td><td>$supplier_html</td></tr>";
 }
 echo "</tbody></table>";
 echo "<p><b>$item_index &amp;nbsp; items</b></p>";
 break;
// end case list

//---------------------------------------------------
 default:
 sub_company_heading($my_company, $module_name, $application);
 sub_message_error("case = default");
 }
?>
</body>
</html>

&amp;nbsp;

&amp;nbsp;

PHP scripts for orangehrm

/*TODO: This file seems to be not in use. TO BE REMOVED */

require_once ROOT_PATH . '/lib/confs/sysConf.php';
require_once ROOT_PATH . '/lib/common/CommonFunctions.php';

$srchlist[0] = array( 0 , 1 , 2 );
$srchlist[1] = array( '-Select-' , 'ID' , 'Description' );


 $sysConst = new sysConf();

 if($this->getArr['mtcode']=='BUG')
 $locRights = array('add' => true,'delete' => true, 'edit' => true, 'view' => true);
 else
 $locRights = $_SESSION['localRights'];

 $headingInfo=$this->popArr['headinginfo'];

 $currentPage = $this->popArr['currentPage'];

 $message= $this->popArr['message'];

 $styleSheet = CommonFunctions::getTheme();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link href="../../themes/<?php echo $styleSheet;?>/css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">@import url("../../themes/<?php echo $styleSheet;?>/css/style.css"); </style>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<script>

 function nextPage() {
 var i=eval(document.standardView.pageNO.value);
 document.standardView.pageNO.value=i+1;
 document.standardView.submit();
 }

 function prevPage() {
 var i=eval(document.standardView.pageNO.value);
 document.standardView.pageNO.value=i-1;
 document.standardView.submit();
 }

 function chgPage(pNO) {
 document.standardView.pageNO.value=pNO;
 document.standardView.submit();
 }

 function returnAdd() {

 location.href = "./CentralController.php?mtcode=<?php echo $this->getArr['mtcode']?>&amp;capturemode=addmode";

 }

 function returnDelete() {
 $check = 0;
 with (document.standardView) {
 for (var i=0; i < elements.length; i++) {
 if ((elements[i].type == 'checkbox') &amp;&amp; (elements[i].checked == true)){
 $check = 1;
 }
 }
 }

 if ( $check == 1 ){
 document.standardView.delState.value = 'DeleteMode';
 document.standardView.pageNO.value=1;
 document.standardView.submit();
 }else{
 alert("Select at least one record to delete");
 }
 }

 function returnSearch() {
 if (document.standardView.loc_code.value == 0) {
 alert("Select the field to search!");
 document.standardView.loc_code.Focus();
 return;
 };
 document.standardView.captureState.value = 'SearchMode';
 document.standardView.pageNO.value=1;
 document.standardView.submit();
 }


 function doHandleAll()
 {
 with (document.standardView) {
 if(elements['allCheck'].checked == false){
 doUnCheckAll();
 }
 else if(elements['allCheck'].checked == true){
 doCheckAll();
 }
 }
 }

 function doCheckAll()
 {
 with (document.standardView) {
 for (var i=0; i < elements.length; i++) {
 if (elements[i].type == 'checkbox') {
 elements[i].checked = true;
 }
 }
 }
 }

 function doUnCheckAll()
 {
 with (document.standardView) {
 for (var i=0; i < elements.length; i++) {
 if (elements[i].type == 'checkbox') {
 elements[i].checked = false;
 }
 }
 }
 }

 function clear_form() {
 document.standardView.loc_code.options[0].selected=true;
 document.standardView.loc_name.value='';
 }

</script>
<body>
<p>
<table width='100%' cellpadding='0' cellspacing='0' border='0' class='moduleTitle'><tr><td valign='top'>
<form name="standardView" method="post" action="<?php echo $_SERVER['PHP_SELF']?>?mtcode=<?php echo $this->getArr['mtcode']?>&amp;VIEW=MAIN">
 </td>
 <td width='100%'><h2>
 <?php echo $headingInfo[3]?>
 </h2></td>
 <td valign='top' align='right' nowrap style='padding-top:3px; padding-left: 5px;'></td></tr>
</table></p>
</p>
<p>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
 <tr>
 <td width="22%" nowrap><h3>
 <input type="hidden" name="captureState" value="<?php echo isset($this->postArr['captureState'])?$this->postArr['captureState']:''?>">
 <input type="hidden" name="delState" value="">

 <input type="hidden" name="pageNO" value="<?php echo isset($this->postArr['pageNO'])?$this->postArr['pageNO']:'1'?>">

<?php    if($locRights['add']) { ?>
 <img border="0" title="Add" onClick="returnAdd();" onMouseOut="this.src='../../themes/beyondT/pictures/btn_add.gif';" onMouseOver="this.src='../../themes/beyondT/pictures/btn_add_02.gif';" src="../../themes/beyondT/pictures/btn_add.gif">
<?php     } else { ?>
 <img onClick="alert('<?php echo $sysConst->accessDenied?>');" src="../../themes/beyondT/pictures/btn_add.gif">
<?php    }

if($headingInfo[2]==1) {

 if($locRights['delete']) { ?>
 <img title="Delete" onClick="returnDelete();" onMouseOut="this.src='../../themes/beyondT/pictures/btn_delete.gif';" onMouseOver="this.src='../../themes/beyondT/pictures/btn_delete_02.gif';" src="../../themes/beyondT/pictures/btn_delete.gif">
<?php     } else { ?>
 <img onClick="alert('<?php echo $sysConst->accessDenied?>');" src="../../themes/beyondT/pictures/btn_delete.gif">
<?php     }
}?>

</h3></td>
 <td width='78%'><IMG height='1' width='1' src='../../pictures/blank.gif' alt=''></td>
 </tr>
</table>
<p>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
 <tr>
 <td width="22%" nowrap><h3>
 Search</h3></td>
 <td width='78%' align="right"><IMG height='1' width='1' src='../../pictures/blank.gif' alt=''>
 <font color="#FF0000" size="-1" face="Verdana, Arial, Helvetica, sans-serif">
 <?php


 if (isset($this->getArr['message'])) {
 $expString  = $this->getArr['message'];
 $expString = explode ("%",$expString);
 $length = sizeof($expString);
 for ($x=0; $x < $length; $x++) {
 echo " " . $expString[$x];
 }
 }
 ?>
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; </font> </td>
 </tr>
</table>

<!--  newtable -->
 <table border="0" cellpadding="0" cellspacing="0" width="100%">
 <tr>
 <td width="13"><img name="table_r1_c1" src="../../themes/<?php echo $styleSheet; ?>/pictures/table_r1_c1.gif" width="13" height="12" border="0" alt=""></td>
 <td width="339" background="../../themes/<?php echo $styleSheet; ?>/pictures/table_r1_c2.gif"><img name="table_r1_c2" src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 <td width="13"><img name="table_r1_c3" src="../../themes/<?php echo $styleSheet; ?>/pictures/table_r1_c3.gif" width="13" height="12" border="0" alt=""></td>
 <td width="11"><img src="../../themes/beyondT/pictures/spacer.gif" width="1" height="12" border="0" alt=""></td>
 </tr>
 <tr>
 <td background="../../themes/<?php echo $styleSheet; ?>/pictures/table_r2_c1.gif"><img name="table_r2_c1" src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 <td><table  border="0" cellpadding="5" cellspacing="0" class="">
 <tr>
 <td width="200"><slot>Search By:</slot>&amp;nbsp;&amp;nbsp;<slot>
 <select name="loc_code">
<?php                        for($c=0;count($srchlist[0])>$c;$c++)
 if(isset($_POST['loc_code']) &amp;&amp; $_POST['loc_code']==$srchlist[0][$c])
 echo "<option selected value='" . $srchlist[0][$c] ."'>".$srchlist[1][$c] ."</option>";
 else
 echo "<option value='" . $srchlist[0][$c] ."'>".$srchlist[1][$c] ."</option>";
?>
 </select>
 </slot></td>
 <td width="200" noWrap><slot>Description</slot>&amp;nbsp;&amp;nbsp;<slot>
 <input type=text size="20" name="loc_name"  value="<?php echo isset($this->postArr['loc_name'])? stripslashes($this->postArr['loc_name']):''?>">
 </slot></td>
 <td align="right" width="180"><img title="Search" onClick="returnSearch();" onMouseOut="this.src='../../themes/beyondT/pictures/btn_search.gif';" onMouseOver="this.src='../../themes/beyondT/pictures/btn_search_02.gif';" src="../../themes/beyondT/pictures/btn_search.gif">&amp;nbsp;&amp;nbsp;<img title="Clear" onClick="clear_form();" onMouseOut="this.src='../../themes/beyondT/pictures/btn_clear.gif';" onMouseOver="this.src='../../themes/beyondT/pictures/btn_clear_02.gif';" src="../../themes/beyondT/pictures/btn_clear.gif"></td>

 </table></td>
 <td background="../../themes/<?php echo $styleSheet; ?>/pictures/table_r2_c3.gif"><img name="table_r2_c3" src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 <td><img src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 </tr>
 <tr>
 <td background="../../themes/<?php echo $styleSheet; ?>/pictures/table_r2_c1.gif"><img name="table_r2_c1" src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 <td><table  border="0" cellpadding="5" cellspacing="0" class="">

 </table></td>
 <td background="../../themes/<?php echo $styleSheet; ?>/pictures/table_r2_c3.gif"><img name="table_r2_c3" src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 <td><img src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 </tr>

 <tr>
 <td><img name="table_r3_c1" src="../../themes/<?php echo $styleSheet; ?>/pictures/table_r3_c1.gif" width="13" height="16" border="0" alt=""></td>
 <td background="../../themes/<?php echo $styleSheet; ?>/pictures/table_r3_c2.gif"><img name="table_r3_c2" src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 <td><img name="table_r3_c3" src="../../themes/<?php echo $styleSheet; ?>/pictures/table_r3_c3.gif" width="13" height="16" border="0" alt=""></td>
 <td><img src="../../themes/beyondT/pictures/spacer.gif" width="1" height="16" border="0" alt=""></td>
 </tr>
 </table>
 <table border="0" width="100%">
 <tr>
 <td height="40" valign="bottom" align="right">

<?php
$temp = $this->popArr['temp'];
if($temp)
 $recCount=$temp;
else
 $recCount=0;

 $noPages=(int)($recCount/$sysConst->itemsPerPage);

 if($recCount%$sysConst->itemsPerPage)
 $noPages++;

 if ($noPages > 1) {

 if ($currentPage==1)
 echo "<font color='Gray'>Previous</font>";
 else
 echo "<a href='#' onClick='prevPage()'>Previous</a>";

 echo "  ";

 for ( $c = 1 ; $noPages >= $c ; $c++) {
 if($c == $currentPage)
 echo "<font color='Gray'>" .$c. "</font>";
 else
 echo "<a href='#' onClick='chgPage(" .$c. ")'>" .$c. "</a>";

 echo "  ";
 }

 if ($currentPage == $noPages)
 echo "<font color='Gray'>Next</font>";
 else
 echo "<a href='#' onClick='nextPage()'>Next</a>";
 }
?>
 </td>
 <td width="25"></td>
 </tr>
 </table>

 <table border="0" cellpadding="0" cellspacing="0">
 <tr>
 <td width="13"><img name="table_r1_c1" src="../../themes/<?php echo $styleSheet; ?>/pictures/table_r1_c1.gif" width="13" height="12" border="0" alt=""></td>
 <td width="339" background="../../themes/<?php echo $styleSheet; ?>/pictures/table_r1_c2.gif"><img name="table_r1_c2" src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 <td width="13"><img name="table_r1_c3" src="../../themes/<?php echo $styleSheet; ?>/pictures/table_r1_c3.gif" width="13" height="12" border="0" alt=""></td>
 <td width="11"><img src="../../themes/beyondT/pictures/spacer.gif" width="1" height="12" border="0" alt=""></td>
 </tr>
 <tr>
 <td background="../../themes/<?php echo $styleSheet; ?>/pictures/table_r2_c1.gif"><img name="table_r2_c1" src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 <td><table width="100%" border="0" cellpadding="5" cellspacing="0" class="">
 <td width="50" NOWRAP scope="col">
 <?php if($headingInfo[2]==1) {?>
 <input type='checkbox' class='checkbox' name='allCheck' value='' onClick="doHandleAll();">
 <?php }?>
 </td>
 <td scope="col" width="250"><?php echo $headingInfo[0]?></td>
 <td scope="col" width="400"><?php echo $headingInfo[1]?></td>
 </table></td>
 <td background="../../themes/<?php echo $styleSheet; ?>/pictures/table_r2_c3.gif"><img name="table_r2_c3" src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 <td><img src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 </tr>

 <?php
 if ((isset($message)) &amp;&amp; ($message !='')) {

 for ($j=0; $j<count($message);$j++) {

 $descField=$message[$j][1];

 if($sysConst->viewDescLen <= strlen($descField)) {
 $descField = substr($descField,0,$sysConst->viewDescLen);
 $descField .= "....";
 }

 ?>
 <tr>
 <td background="../../themes/<?php echo $styleSheet; ?>/pictures/table_r2_c1.gif"><img name="table_r2_c1" src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 <td><table width="100%" border="0" cellpadding="5" cellspacing="0" class="">
 <?php    if(!($j%2)) {
 if($headingInfo[2]==1) { ?>
 <td width="50"><input type='checkbox' class='checkbox' name='chkLocID[]' value='<?php echo $message[$j][0]?>'></td>
 <?php         } else { ?>
 <td width="50"></td>
 <?php         }  ?>

 <td width="250"><a href="./CentralController.php?id=<?php echo $message[$j][0]?>&amp;mtcode=<?php echo $_GET['mtcode']?>&amp;capturemode=updatemode"><?php echo $message[$j][0]?></a></td>
 <td width="400" ><?php echo $descField?></td>
 <?php } else {
 if($headingInfo[2]==1) { ?>
 <td bgcolor="#EEEEEE" width="50"><input type='checkbox' class='checkbox' name='chkLocID[]' value='<?php echo $message[$j][0]?>'></td>
 <?php         } else { ?>
 <td bgcolor="#EEEEEE" width="50"></td>
 <?php         }  ?>
 <td bgcolor="#EEEEEE" width="250"><a href="./CentralController.php?id=<?php echo $message[$j][0]?>&amp;mtcode=<?php echo $_GET['mtcode']?>&amp;capturemode=updatemode"><?php echo $message[$j][0]?></a></td>
 <td bgcolor="#EEEEEE" width="400" ><?php echo $descField?></td>
 <?php } ?>
 </table></td>
 <td background="../../themes/<?php echo $styleSheet; ?>/pictures/table_r2_c3.gif"><img name="table_r2_c3" src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 <td><img src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 </tr>

 <?php }
 } else if ((isset($message)) &amp;&amp; ($message =='')) {

 $dispMessage = "No Records to Display !";
 echo '<font color="#FF0000" size="-1" face="Verdana, Arial, Helvetica, sans-serif">';
 echo $dispMessage;
 echo '</font>';
 }

 ?>

 <tr>
 <td><img name="table_r3_c1" src="../../themes/<?php echo $styleSheet; ?>/pictures/table_r3_c1.gif" width="13" height="16" border="0" alt=""></td>
 <td background="../../themes/<?php echo $styleSheet; ?>/pictures/table_r3_c2.gif"><img name="table_r3_c2" src="../../themes/beyondT/pictures/spacer.gif" width="1" height="1" border="0" alt=""></td>
 <td><img name="table_r3_c3" src="../../themes/<?php echo $styleSheet; ?>/pictures/table_r3_c3.gif" width="13" height="16" border="0" alt=""></td>
 <td><img src="../../themes/beyondT/pictures/spacer.gif" width="1" height="16" border="0" alt=""></td>
 </tr>

<!--  newtable -->

</form>
</body>
</html>

&amp;nbsp;

&amp;nbsp;

PHP scripts for svhp Compressed

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <style type="text/css">
 /*<![CDATA[*/
<!--
body {margin:0px; padding:0px; background-color: #ffffff; color: #000000; width:100%; text-align: justify; vertical-align: top; line-height: 180%; font-size: smaller; font-family: verdana, arial, helvetica, sans-serif;  }
input.url {width: 350px;}
.but { background-color: #ffffff; color: #000066; margin-right: 10px; margin-left: 0px; margin-top: 0px; margin-bottom: 0px; border-color: #ffd700; font-weight: bold; cursor: pointer;}
div.section{margin: 10px;}
div.border {margin: 20px; border-style: dashed; border-width: 1px; border-color: #000066; overflow: auto; text-align: left;}
div.cent{text-align: center;line-height: 100%;}
h1 {margin: 20px; font-size: 20px; background-color: #ffffff; color: #000066; text-align: center;}
p {margin: 20px;}
.small { line-height: 120%; font-size: smaller;}
.smallblue { line-height: 100%; font-size: 10px; color: #000066; background-color: #ffffff;}
.smallcent { text-align: center;}
a{text-decoration: none; font-weight: bold;}
a:link { color: #000066; background-color: #ffffff; }
a:visited {color:#000066; background-color: #ffffff;}
a:hover {color:#ffffff; background-color: #000066;}
a.small{font-size: 10px;}
-->
 /*]]>*/
 </style>
 <meta http-equiv="Content-Type"
 content="text/html; charset=iso-8859-1" />

 <link rel="icon" href="http://www.softswot.com/favicon.ico" />
 <link rel="shortcut icon" href="http://www.softswot.com/favicon.ico" />
 <meta name="Copyright Source Viewer" content="Copyright www.softswot.com 2004" />
 <title>
 Source Viewer - display and highlight the web page source
 code including all html and php code.
 </title>
 <meta name="Description"
 content="Source Viewer - display and highlight the web page source code including all html and php code." />
 <meta name="Keywords"
 content="view source, view php, source code, source, display, php code display, php code, php source, softswot" />
 </head>
 <body>
 <h1>
 Source Viewer
 </h1>
 <div>
 <div>
 <a href='http://www.softswot.com'
 class='small'>www.softswot.com</a><br />
 <span>Solutions through software
 innovation.<br />
 &amp;copy;2004</span>
 </div>
 <form
 action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
 <p>
 <input type="text" name="useurl" />
 <input type="submit"
 value="View URL html and php Code" /><br />
 <span>Input the URL of the file to view.
 The viewed file must be on the
 <?php  echo $_SERVER['HTTP_HOST']; ?> server, the
 server must support php and the viewed file must be in
 an allowed directory. Displayed code will include all
 html and php code. Using standard browser View Source
 php code is not displayed.</span>
 </p>
 </form>
 <?php
 error_reporting(E_ERROR);

 if(isset($_POST['useurl'])&amp;&amp; $_POST['useurl'])
 {
 global $allowdirs,$allowcur;
 $serpath = $_SERVER['PATH_TRANSLATED'];
 $urlpath = $_SERVER['PHP_SELF'];
 $useurl = stripslashes($_POST['useurl']);

 $urldir=dirname($urlpath);
 $serpathcomps = (explode('/',$serpath));
 $urlpathcomps = (explode('/',$urlpath));
 $serpathnum = sizeof($serpathcomps);
 $urlpathnum = sizeof($urlpathcomps);
 $urlhost = $_SERVER['HTTP_HOST'];
 $serurldif = $serpathnum-$urlpathnum;
 $serurlcnt=1;
 $serbase ='';
 while ($serurlcnt <= $serurldif)
 {
 $serbase .= "/$serpathcomps[$serurlcnt]";
 $serurlcnt++;
 }
 $usecomp = parse_url($useurl);
 $usepath = $usecomp['path'];
 $usedir=dirname($usepath);
 $serusepath = "$serbase$usepath";
 if($allowcur=='true')
 {
 array_push($allowdirs,$urldir);
 }
 $usedirok = false;
 foreach ($allowdirs as $allowdir)
 {
 if($usedir==$allowdir)
 {
 if(is_file($serusepath))
 {
 echo "<p>The code for <a href='$useurl'>$useurl</a> is displayed.</p>";
 echo "<div class='border'><p>";
 highlight_file($serusepath);
 echo '</p></div>';
 }
 else
 {
 echo "<p><b>The file to be viewed must be located on the server hosting $urlhost. </b> ";
 echo "The file $usepath does not appear to be a valid file on this host.</p>";
 }
 $usedirok = true;
 break;
 }
 }
 if($usedirok==false)
 {
 echo "<p><b>The directory $usedir is not available to be viewed. </b>";
 echo "To view files in this directory you must include it as an allowed directory. ";
 echo "To set $usedir as an allowed directory open this file ";
 echo "(using a text editor or your servers file edit function) ";
 echo "and add $usedir to the allowed directories array at the top of the file.</p>";
 }
 }
 ?>
 <div>
 <a href='http://www.softswot.com'
 class='small'>www.softswot.com</a><br />
 <span>Solutions through software
 innovation.<br />
 &amp;copy;2004</span>
 </div>
 <br />
 </div>
 </body>
</html>

&amp;nbsp;

&amp;nbsp;

PHP scripts for FormMailer

// ------- three variables you MUST change below  -------------------------------------------------------
$replyemail="you@your--domain"; //change to your email address
$valid_ref1="http://thedemosite.co.uk/contact.html"; //chamge to your domain name
$valid_ref2="http://www.thedemosite.co.uk/contact.html"; //chamge to your domain name

// -------- No changes required below here -------------------------------------------------------------
//
// email variable not set - load $valid_ref1 page
if (!isset($_POST['email']))
{
 echo "<script language=\"JavaScript\"><!--\n ";
 echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
 exit;
}
$ref_page=$_SERVER["HTTP_REFERER"];
$valid_referrer=0;
if($ref_page==$valid_ref1) $valid_referrer=1;
elseif($ref_page==$valid_ref2) $valid_referrer=1;
if((!$valid_referrer) OR ($_POST["block_spam_bots"]!=12))//you can change this but remember to change it in the contact form too
{
 echo '<h2>ERROR - not sent.';
 if (file_exists("debug.flag")) echo '<hr>"$valid_ref1" and "$valid_ref2" are incorrect within the file:<br>
 contact_process.php <br><br>On your system these should be set to: <blockquote>
 $valid_ref1="'
.str_replace("www.","",$ref_page).'"; <br>
 $valid_ref2="'
.$ref_page.'";
 </blockquote></h2>Copy and paste the two lines above
 into the file: contact_process.php <br> (replacing the existing variables and settings)'
;
 exit;
}

//check user input for possible header injection attempts!
function is_forbidden($str,$check_all_patterns = true)
{
 $patterns[0] = '/content-type:/';
 $patterns[1] = '/mime-version/';
 $patterns[2] = '/multipart/';
 $patterns[3] = '/Content-Transfer-Encoding/';
 $patterns[4] = '/to:/';
 $patterns[5] = '/cc:/';
 $patterns[6] = '/bcc:/';
 $forbidden = 0;
 for ($i=0; $i<count($patterns); $i++)
 {
 $forbidden = preg_match($patterns[$i], strtolower($str));
 if ($forbidden) break;
 }
 //check for line breaks if checking all patterns
 if ($check_all_patterns AND !$forbidden) $forbidden = preg_match("/(%0a|%0d|\\n+|\\r+)/i", $str);
 if ($forbidden)
 {
 echo "<font color=red><center><h3>STOP! Message not sent.</font></h3><br><b>
 The text you entered is forbidden, it includes one or more of the following:
 <br><textarea rows=9 cols=25>"
;
 foreach ($patterns as $key => $value) echo trim($value,"/")."\n";
 echo "\\n\n\\r</textarea><br>Click back on your browser, remove the above characters and try again.
 </b><br><br><br><br>Thankfully protected by phpFormMailer freely available from:
 <a href=\"http://thedemosite.co.uk/phpformmailer/\">http://thedemosite.co.uk/phpformmailer/</a>"
;
 exit();
 }
}

foreach ($_REQUEST as $key => $value) //check all input
{
 if ($key == "themessage") is_forbidden($value, false); //check input except for line breaks
 else is_forbidden($value);//check all
}

$name = $_POST["name"];
$email = $_POST["email"];
$thesubject = $_POST["thesubject"];
$themessage = $_POST["themessage"];

$success_sent_msg='<p align="center"><strong>&amp;nbsp;</strong></p>
 <p align="center"><strong>Your message has been successfully sent to us<br>
 </strong> and we will reply as soon as possible.</p>
 <p align="center">A copy of your query has been sent to you.</p>
 <p align="center">Thank you for contacting us.</p>'
;

$replymessage = "Hi $name

Thank you for your email.

We will endeavour to reply to you shortly.

Please DO NOT reply to this email.

Below is a copy of the message you submitted:
--------------------------------------------------
Subject: $thesubject
Query:
$themessage
--------------------------------------------------

Thank you"
;

$themessage = "name: $name \nQuery: $themessage";
mail("$replyemail",
 "$thesubject",
 "$themessage",
 "From: $email\nReply-To: $email");
mail("$email",
 "Receipt: $thesubject",
 "$replymessage",
 "From: $replyemail\nReply-To: $replyemail");
echo $success_sent_msg;
/*
 PHP Form Mailer - phpFormMailer (easy to use and more secure than many cgi form mailers)
 FREE from:

*/


?>

&amp;nbsp;

&amp;nbsp;

PHP scripts for source code utility

$max_size=200000;           # MAX_FILE_SIZE in bytes for file upload;
#    also limited by PHP settings variable: upload_max_filesize
$extensions="php,htm,inc";  # extensions allowed if begin with these; separated by comma only

ini_set("highlight.bg",      "#FFFFFF");    # white
ini_set("highlight.comment", "#FF8000");    # orange
ini_set("highlight.default", "#0000BB");    # blue
ini_set("highlight.html",    "#000000");    # black
ini_set("highlight.keyword", "#007700");    # green
ini_set("highlight.string",  "#DD0000");    # red



### No need to modify below here ############################################################


error_reporting(0);

$max_size_ini = ini_get("upload_max_filesize");
$max_size_ini = (int) $max_size_ini;  # remove M at end

$ext="(\." . str_replace (",", "|\.", $extensions) . ")";     # $ext="(\.php|\.htm|\.inc)";

if(!isset($Add_Line_Numbers)) $Add_Line_Numbers = "Separate";
if(!isset($ShowForm)) $ShowForm = "No";
if(!isset($file)) $ShowForm = "Yes";

echo<<<endHTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<TITLE>0PHP.com PHP Source Code Utility - Line Numberer and Syntax Highlighter</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<META HTTP-EQUIV="Content-Language" CONTENT="en-us">
<meta http-equiv="Content-Style-Type" content="text/css">
<STYLE type="text/css">
 A:hover   { COLOR: #FF0000; TEXT-DECORATION: underline}
</STYLE>
</HEAD>
<BODY BGCOLOR="white" link="navy" vlink="navy" alink="navy">

endHTML
;


if ($ShowForm=="Yes")
{
echo<<<endHTML


<div align="center"><center>
<table border="0" cellpadding="0" cellspacing="0"><tr><td>

<font face="Arial"><p align="center"><font size="+2"><b>PHP Source Code Utility<br>Line Numberer and Syntax Highlighter</b></font></p>

endHTML
;

echo "<form enctype = \"multipart/form-data\" action = \"$PHP_SELF\" method = \"post\">";

echo<<<endHTML

<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="20000">
Upload (filename and path): &amp;nbsp;
<input type = "file" name = "file" size="30">
<p>Line Numbers:&amp;nbsp; <select size="1" name="Add_Line_Numbers">
 <option>None</option>
 <option selected>Separate</option>
 <option>Joined</option>
</select>&amp;nbsp;
Redisplay this form at top:&amp;nbsp;
<input type="checkbox" name="ShowForm" value="Yes"><br>
<input type="reset" value="Reset">&amp;nbsp;
<input type = "submit" value = "Submit">
</form><br></font>

</td></tr>
</table>
</center></div>

<hr>

endHTML
;
}




if (isset($file))                       # is there a file to process?
{
if($file=="none" || $file_size<1)
{
echo "<H2><font face=\"Arial\"><font color=red>ERROR:</font> Max file size of $max_size_ini bytes exceeded, or file error!</font></H2><br>\n";
echo "<font face=\"Arial\" size=\"+1\"><a href=$PHP_SELF>Highlight source code another file</a><br><br><font>";
}
else
{
if (eregi($ext,$file_name))             # check file extension okay
{                                       # file is all okay - process it


$fcontents = file($file);
$nlines=count($fcontents);
$nlines2=number_format($nlines);
$nchars=number_format(strlen(join('',$fcontents)));

# print file name and info at top
if ($file_size < 1000) $size_txt = "Bytes";
else { $file_size = $file_size / 1000; $size_txt = "KB"; }

$last_modified=date("M d, Y - h:i:s A", filemtime("$file"));  # or now = time()

echo "
<p align=\"center\"><font face=\"Verdana\">
<font size=\"+2\">PHP Source Code of: '<font color=\"#FF0000\">$file_name</font>'<br>
</font><font size=1>Date: <font color=\"#FF0000\">$last_modified</font><br>
Size:
<font color=\"#FF0000\">$file_size $size_txt</font>&amp;nbsp; |&amp;nbsp;
<font color=\"#FF0000\">$nlines2 lines</font>&amp;nbsp; |&amp;nbsp;
<font color=\"#FF0000\">$nchars characters</font></font></font>
<hr>\n\n
<div align=\"left\">\n<table border=0 cellpadding=10 cellspacing=0><tr>\n<td nowrap>\n
"
;

 $digits=1;                               # need to even lines
if ($nlines>=10) $digits=2;
 if ($nlines>=100) $digits=3;
 if ($nlines>=1000) $digits=4;
 if ($nlines>=10000) $digits=5;


if ($Add_Line_Numbers == "None")
{
 echo "\n<!----------- begin source code ----------->\n\n\n";
 show_source($file);
 echo "\n\n\n<!----------- end source code ----------->\n\n\n";
}

elseif ($Add_Line_Numbers == "Joined")
{
 echo "\n\n<code>\n";
 while (list ($line_num, $line) = each ($fcontents))
 {
 $line_num++;
 $line_num=str_pad("$line_num", $digits, " ");
 $line_num=str_replace(' ','&amp;nbsp;',htmlspecialchars($line_num));
 $line = str_replace(' ','&amp;nbsp;',htmlspecialchars($line));
 echo "<b>Line $line_num:</b>&amp;nbsp; " . $line . "<br>\n";
 }
 echo "</code>\n\n";
}


else          # $Add_Line_Numbers == "Separate"
{
# show line numbers in left table cell

echo "<code><b>\n";
while (list($line_num, $line) = each ($fcontents))
{
 $line_num++;
 $line_num=str_pad("$line_num", $digits, " ");
 $line_num=str_replace(' ','&amp;nbsp;',htmlspecialchars($line_num));
 echo "Line $line_num:<br>\n";
}

echo "</b></code></td>\n<td nowrap>\n\n";
echo "\n<!----------- begin source code ----------->\n\n\n";

# show source in right table cell
show_source($file);

echo "\n\n\n<!----------- end source code ----------->\n\n\n";

}


echo "</td></tr>\n</table></div>\n<hr>\n";



# end ifs for checking if file okay to process
} else {
echo "<H2><font face=\"Arial\"><font color=red>ERROR:</font> Only files with extensions beginning with $extensions are allowed!</font></H2><br>\n";
}}}

?>


<p align="center"><font face="Verdana" size=1>PHP Source Code Utility - Version 1.0.0<br>
<a href="http://www.0php.com">Free PHP Scripts</a> - Copyright © <a href="http://www.0php.com">0php.com</a> 2002.</font>

</BODY></HTML>

&amp;nbsp;

&amp;nbsp;