Location: PHPKode > projects > WebDebEx > webdebex/html/functions.php
<?php


// *****************************************************
// *** Main Include Function for all other PHP files ***
// *****************************************************


// Stop PHP interpreter time
$_REQUEST[php_time_start] = getmicrotime();


// Starts the gz compressed header
ob_start("ob_gzhandler");


// Init of required Variables
$_REQUEST[conf_Title]    = "WebDebEx";
$_REQUEST[conf_Version]  = "Alpha Version 0.1";
$_REQUEST[conf_Autor]    = "(c) Andreas Kreisl";
$_REQUEST[conf_Homepage] = "<A HREF='http://www.bluepaw.de/' TARGET='_new'>www.bluepaw.de</A>";
$_REQUEST[conf_Cookie]   = "webdebex";


require_once("config.php");

$_REQUEST[db_link]       = NULL;
$_REQUEST[db_querycount] = NULL;

$_REQUEST[db_session]      = NULL;
$_REQUEST[db_session_name] = NULL;
$_REQUEST[db_session_dom]  = NULL;




// Include the other Functions
require_once("functions_db.php");
require_once("functions_session.php");
require_once("functions_rest.php");


// Extra Functions
function MyEnd() {
		ob_end_flush(); 
		return true;
	}


function getmicrotime() { 
		list($usec, $sec) = explode(" ",microtime()); 
		return ((float)$usec + (float)$sec); 
	}


function MyHeader() {
		echo "<HTML>";
		echo "<HEAD>";
			echo "<TITLE>$_REQUEST[conf_Title]</TITLE>";
		echo "</HEAD>";
		echo "<LINK REL='stylesheet' TYPE='text/css' HREF='style.css'>";
	
		echo "<BODY>";
		echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1 BGCOLOR=WHITE WIDTH=750 HEIGHT=100% ALIGN=CENTER><TR><TD ALIGN=LEFT VALIGN=TOP HEIGHT=1 STYLE='background-color:silver;'>";
		//echo "<H1>$_REQUEST[conf_Title]</H1>";
		echo "<IMG SRC='icons/logo.gif'>";
		echo "</TD></TR><TR><TD ALIGN=CENTER VALIGN=TOP STYLE='border-right: 1px solid BLACK; border-left: 1px solid BLACK; border-top: 1px solid BLACK;'>";
if($_REQUEST[db_session]>0) MyMenu();
	}


function MyFooter() {
		echo "</TD></TR><TR><TD ALIGN=CENTER VALIGN=TOP HEIGHT=1 STYLE='border-right: 1px solid BLACK; border-left: 1px solid BLACK;'>";
		echo "-= <I>{$_REQUEST[conf_Version]}</I> =-&nbsp;&nbsp;&nbsp;";
		echo "-= {$_REQUEST[conf_Autor]} @ {$_REQUEST[conf_Homepage]} =-&nbsp;&nbsp;&nbsp;";

	
		$_REQUEST[php_time_end] = getmicrotime();
		$time = round($_REQUEST[php_time_end] - $_REQUEST[php_time_start], 3);
		printf("-= php time : %.3f / Querys : %d =-",$time,$_REQUEST[db_querycount]);
	
		echo "</TD></TR></TABLE>";
		echo "</BODY></HTML>";
	}

function MyMenu() {
		echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 STYLE='width:100%;border-bottom: 1px solid BLACK;'><TR>";
			echo "<TD STYLE='text-align:left;background-color: #E0E0E0;'>&nbsp;&nbsp;$_REQUEST[db_session_name]&nbsp;&nbsp;</TD>";
			echo "<TD STYLE='width:150px;text-align:center;background-color: #E0E0E0;'><A HREF='user_list.php'>List all</A></TD>";
			echo "<TD STYLE='width:150px;text-align:center;background-color: #E0E0E0;'><A HREF='user_add.php'>Add new</A></TD>";
			echo "<TD STYLE='width:100px;text-align:center;background-color: #E0E0E0;'><A HREF='logout.php'>Logout</A></TD>";
		if($_REQUEST[db_session]==$_REQUEST[adm_id]) {
			echo "</TR><TR>";
			$res = DBQuery("SELECT dom_name FROM domains WHERE dom_id = $_REQUEST[db_session_dom]");
			$row = mysql_fetch_assoc($res);
			echo "<TD STYLE='text-align:left;background-color: #E0E0E0;'>&nbsp;&nbsp;$row[dom_name]&nbsp;&nbsp;</TD>";
				echo "<TD STYLE='text-align:center;background-color: #E0E0E0;'><A HREF='dom_list.php'>List all Domains</A></TD>";
				echo "<TD STYLE='text-align:center;background-color: #E0E0E0;'><A HREF='dom_add.php'>Add new Domain</A></TD>";
				echo "<TD STYLE='text-align:center;background-color: #E0E0E0;'><A HREF='dom_alias.php'>System Aliases</A></TD>";
		}
		echo "</TR></TABLE>";
	}

function CheckString($value,$len) {
		$tmp = stripslashes(strip_tags(trim($value)));

		for($i=0;$i<strlen($tmp);++$i) {
				if(  ($tmp[$i]>='A')&&($tmp[$i]<='Z')  )  continue;
				if(  ($tmp[$i]>='a')&&($tmp[$i]<='z')  )  continue;
				if(  ($tmp[$i]>='0')&&($tmp[$i]<='9')  )  continue;
				if(  ($tmp[$i]=='.')||($tmp[$i]=='-')||($tmp[$i]=='_')||($tmp[$i]=='@')||($tmp[$i]=='*')||($tmp[$i]==' ')      )  continue;
				$tmp[$i]=";";
			}

		$tmp = str_replace(";","",$tmp);
		$tmp = substr($tmp,0,$len);
		return $tmp;
	}

function CheckInt($value) {
		return (int)CheckString($value,32);
	}

function CheckDouble($value) {
		return (double)CheckString($value,32);
	}


// *****************************
// *** File Based Operations ***
// *****************************
function fcountHR($size) {
		$a = array("", "K", "M", "G", "T", "P");
		$pos = 0;
		while ($size >= 1000) {
				$size /= 1000;
				$pos++;
			}
	
		if($pos>0) return round($size,2)." ".$a[$pos];
		else return round($size,2);
	} 

function fsizeHR($size) {
		$a = array("B", "KB", "MB", "GB", "TB", "PB");
		$pos = 0;
		while ($size >= 1024) {
				$size /= 1024;
				$pos++;
			}
	
		return round($size,2)." ".$a[$pos];
	} 


function fsize($file){
       $size = 0;

       if(!is_link($file)) {

       if(is_dir($file))
               if ($dh = opendir($file))
                       while (($filecnt = readdir($dh)) !== false) {
                               if($filecnt == "." || $filecnt == "..")continue;
                               if(is_dir($file."/".$filecnt))
                                       $size += fsize($file."/".$filecnt);
                               else
                                       $size += filesize($file."/".$filecnt);
                       }
               else
                       return false;
       else
               $size = filesize($file);

       }

       return $size;
	} 




?>
Return current item: WebDebEx