<?php
/*
Library name: EZXFoundatonPHP.php - Ver 1.0
Purpose: PHP library for streamlining web application development
Copyright (c) 2006 Robert P. Gavila
Release date: January 21, 2006
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
If you have any questions, please contact the library author by electronic
or paper mail at the following address:
Robert Gavila
20-23 43 Street
Astoria, New York 11105-1225
Email: robert@gavila.com
*/
/* EZXFoundation non-secure functions */
function EZXScreenHeading ($_Title, $_UserName, $_MenuName, $_LogoTitle, $_Subtitle)
{
print ("<!-- EZXFoundation Base Code -->\n");
print ("<!-- EZXScreenHeading() -->\n");
print ("<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"\n");
print (" "http://www.w3.org/TR/html4/strict.dtd">\n");
print ("<HTML>\n");
print ("<HEAD>\n");
print ("<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">\n");
print ("<META NAME="Keywords" CONTENT="EZ Photo Services">\n");
print ("<META NAME="Description" CONTENT="Stock and Wedding Photography">\n");
print ("<META http-equiv="Content-Script-Type" content="text/javascript">\n");
print ("<link rel="stylesheet" type="text/css" href="../EZXFoundationCSS.css" />\n");
print ("<!-- 1: Field for Title -->\n");
print ("<TITLE>$_Title</TITLE>\n");
print ("</HEAD>\n");
print ("\n");
print ("<BODY bgcolor="#F3E3B1">\n");
print ("<!-- CSS compatibility issue: Mozilla Firefox requires bgcolor in BODY tab -->\n");
print ("<TABLE width="100%" border="0" cellspacing="2" cellpadding="5">\n");
print (" <TR>\n");
print (" <TD class="tableCellLeft">\n");
print (" <!-- 2: Field for signed on user -->\n");
print (" <DIV class="userNameStyle">$_UserName</DIV>\n");
print (" </TD>\n");
print (" <TD class="tableCellRight">\n");
print (" <!-- 3: Field for the current menu name -->\n");
print (" <DIV class="menuNameStyle">$_MenuName</DIV>\n");
print (" </TD>\n");
print (" </TR>\n");
print ("</TABLE>\n");
print ("<A NAME="_TOP1"></A>\n");
print ("<TABLE width="100%" border="0" cellspacing="2" cellpadding="5">\n");
print (" <TR>\n");
print (" <TD class="tableCellCenter">\n");
print (" <!-- 4: Field for the top banner branding logo -->\n");
print (" <DIV class="logoTitle">\n");
print (" $_LogoTitle\n");
print (" </DIV>\n");
print (" </TD>\n");
print (" </TR>\n");
print (" <TR>\n");
print (" <TD class="tableCellCenter">\n");
print (" <!-- 5: Field for the subtitle that describes the currently selected operation -->\n");
print (" <DIV class="screenSubtitle">$_Subtitle</DIV>\n");
print (" </TD>\n");
print (" </TR>\n");
print ("</TABLE>\n");
print ("<HR>\n");
print ("<!-- End of EZXScreenHeading() -->\n");
return (TRUE);
}
function EZXTopNavigation($_TopNavigationLinks)
{
print ("<!-- EZXFoundation Base Code -->\n");
print ("<!-- EZXTopNavigation() -->\n");
print ("<TABLE width="100%" border="0" cellspacing="2" cellpadding="5">\n");
print (" <TR>\n");
print (" <TD class="tableCellCenter">\n");
print (" <DIV class="topNavigator">\n");
if (!is_array ($_TopNavigationLinks))
// process as a single string
if ($_TopNavigationLinks == "")
{
// Empty string
} else {
print (" <!-- 1: Top navigator selection processed as a string -->\n");
print (" $_TopNavigationLinks\n");
}
else
{
// process as an array
$_records = 0;
$_records = count($_TopNavigationLinks);
print (" <!-- 1: Top navigator selections stored and processed as an array -->\n");
for ($i = 0; $i < $_records; $i++)
{
if(!$_TopNavigationLinks[$i] == "")
print ("$_TopNavigationLinks[$i]  \n");
}
}
print (" </DIV>\n");
print (" </TD>\n");
print (" </TR>\n");
print ("</TABLE>\n");
print ("<!-- End of EZXTopNavigation() -->\n");
return (TRUE);
}
function EZXSideNavigation($_SideNavigationLinks)
{
$_SideNav = "N";
$_NavWidth = 0;
$_WorkWidth = 0;
print ("<!-- EZXFoundation Base Code -->\n");
print ("<!-- EZXSideNavigation() -->\n");
print ("<TABLE width="100%" border="1" cellspacing="2" cellpadding="5">\n");
print (" <TR>\n");
print ("<!-- table columns set up to 12:88 or 0:100, based on side links -->\n");
if (!is_array ($_SideNavigationLinks))
// process as a single string
if ($_SideNavigationLinks == "")
{
$_NavWidth = 0;
$_WorkWidth = 100;
} else {
$_NavWidth = 12;
$_WorkWidth = 88;
print (" <TD class="tableCellLeftNav" width="$_NavWidth%">\n");
print (" <DIV class="sideNavigator">\n");
print (" <!-- 1: Side navigator selection processed as a string -->\n");
print (" $_SideNavigationLinks\n");
print (" </DIV>\n");
print (" </TD>\n");
$_SideNav = "Y";
}
else
{
// process as an array
$_records = 0;
$_records = count($_SideNavigationLinks);
if ($_records > 0 && (!$_SideNavigationLinks[0]=="") )
{
$_NavWidth = 12;
$_WorkWidth = 88;
print (" <TD class="tableCellLeftNav" width="$_NavWidth%">\n");
print (" <DIV class="sideNavigator">\n");
print (" <!-- 1: Side navigator selections stored and processed as an array -->\n");
for ($i = 0; $i < $_records; $i++)
{
if(!$_SideNavigationLinks[$i] == "")
print ("$_SideNavigationLinks[$i]<BR>\n");
}
print (" </DIV>\n");
print (" </TD>\n");
$_SideNav = "Y";
} else {
$_NavWidth = 0;
$_WorkWidth = 100;
}
}
print (" <TD class="tableCellWorkBody" width="$_WorkWidth%">\n");
print ("<!-- End of EZXSideNavigation() -->\n");
return (TRUE);
}
function EZXBeginWorkArea()
{
print ("<!-- EZXFoundation Base Code -->\n");
print ("<!-- EZXBeginWorkArea() -->\n");
print (" <DIV class="defaultWorkArea">\n");
print ("<!-- End of EZXBeginWorkArea() -->\n");
return (TRUE);
}
function EZXEndWorkArea()
{
print ("<!-- EZXFoundation Base Code -->\n");
print ("<!-- EZXEndWorkArea() -->\n");
print (" </DIV>\n");
print (" </TD>\n");
print (" </TR>\n");
print ("</TABLE>\n");
print ("<!-- Horizontal rule for visual demarcation -->\n");
print ("<HR>\n");
print ("<!-- End of EZXEndWorkArea() -->\n");
return (TRUE);
}
function EZXBottomNavigation($_BottomNavigationLinks)
{
$___today = date("l F j Y");
$___time = date("G:i:s");
print ("<!-- EZXFoundation Base Code -->\n");
print ("<!-- EZXBottomNavigation() -->\n");
print ("<TABLE width="100%" border="1" cellspacing="2" cellpadding="0">\n");
print (" <TR>\n");
if (!is_array ($_BottomNavigationLinks))
// process as a single string
if ($_BottomNavigationLinks == "")
{
// Empty string
} else {
print (" <!-- 1: Bottom navigator selection processed as a string -->\n");
print (" $_BottomNavigationLinks\n");
}
else
{
// process as an array
$_records = 0;
$_records = count($_BottomNavigationLinks);
print (" <!-- 1: Bottom navigator selections stored and processed as an array -->\n");
for ($i = 0; $i < $_records; $i++)
{
if(!$_BottomNavigationLinks[$i] == "")
print (" <TD class="tableCellCenter">\n");
print (" <DIV class="bottomNavigator">\n");
print ("$_BottomNavigationLinks[$i]  \n");
print (" </DIV>\n");
print (" </TD>\n");
}
}
print (" <TD class="tableCellDate" width="180">\n");
print (" <DIV class="dateStampStyle">\n");
print (" $___today\n");
print (" </DIV>\n");
print (" </TD>\n");
print (" <TD class="tableCellTime" width="70">\n");
print (" <DIV class="timeStampStyle">\n");
print (" $___time\n");
print (" </DIV>\n");
print (" </TD>\n");
print (" </TR>\n");
print ("</TABLE>\n");
print ("<!-- End of EZXBottomNavigation() -->\n");
return (TRUE);
}
function EZXScreenFootnotes()
{
print ("<!-- EZXFoundation Base Code -->\n");
print ("<!-- EZXScreenFootnotes() -->\n");
print ("<TABLE width="100%" border="1" cellspacing="2" cellpadding="0">\n");
print ("<TR>\n");
print ("<TD class="tableCellCopyright">\n");
print ("<DIV class="copyrightStyle">\n");
print ("© 2006 Robert Gavila All rights reserved.\n");
print ("</DIV>\n");
print ("</TD>\n");
print ("</TR>\n");
print ("</TABLE>\n");
print ("</BODY>\n");
print ("</HTML>\n");
print ("<!-- EZXScreenFootnotes() -->\n");
return (TRUE);
}
/* End of non-secure EZXFoundation functions */
/*
-------------------------------------------------------------------------------------------
The following code was borrowed from the very excellent text,
"MySQL", Second Edition, P. DuBois, p. 515
This code is excluded from the GNU Lesser General Public License Terms
applied to the code above this line.
function quote_value ($str)
Application:
$last = quote_value ("O'Malley");
$first = quote_value ("Brian");
$query = "INSERT INTO member (last_name, first_name)"
. " VALUES($last,$first)";
The next two functions were borrowed from other sections of the same book
"MySQL", Second Edition, P. DuBois
function script_param ($name)
function remove_backslashes ($val)
-------------------------------------------------------------------------------------------
*/
function quote_value ($str)
{
if (!isset ($str))
return ("NULL");
if (function_exists ("mysql_real_escape_string"))
return ("'".mysql_real_escape_string($str)."'");
if (function_exists ("mysql_escape_string"))
return ("'".mysql_escape_string($str)."'");
return("'".addslashes ($str)."'");
}
function script_param ($name)
{
global $HTTP_GET_VARS, $HTTP_POST_VARS;
unset ($val);
if ( isset ( $_GET[$name] ) )
$val = $_GET[$name];
else if ( isset ($_POST[$name] ) )
$val = $_POST[$name];
else if ( isset ($HTTP_GET_VARS[$name] ) )
$val = $HTTP_GET_VARS[$name] ;
else if ( isset ($HTTP_POST_VARS[$name] ) )
$val = $HTTP_POST_VARS[$name];
if (isset ($val) && get_magic_quotes_gpc () )
$val = remove_backslashes ($val);
# return @$val rather than $val to prevent "undefined value"
# messages in case $val is unset and warnings are enabled
return (@$val);
}
function remove_backslashes ($val)
{
if (!is_array ($val))
$val = stripslashes ($val);
else
{
reset ($val);
while (list ($k, $v) = each ($val) )
$val[$k] = remove_backslashes ($v);
}
return ($val);
}
?>