/*
// Used for Y,N columns
CREATE FUNCTION YesNo (x CHAR(1)) RETURNS CHAR(1)
RETURN IF(UPPER(x) = 'Y','Y','N');
//Clean an Integer
CREATE FUNCTION CleanINT (x VARCHAR(255)) RETURNS VARCHAR(255)
RETURN IF(REPLACE(REPLACE(REPLACE(REPLACE(x, ' ', ''), '$', ''), ',', ''), '%', '') = '','0',REPLACE(REPLACE(REPLACE(REPLACE(x, ' ', ''), '$', ''), ',', ''), '%', ''));
CREATE FUNCTION Percentage (num VARCHAR(255), decimalplaces INT(1), divideby VARCHAR(255)) RETURNS VARCHAR(255)
RETURN ROUND(CleanINT(num) / IF(CleanINT(divideby) = 0,'100',CleanINT(divideby)), IF(decimalplaces = '', '2', decimalplaces));
CREATE FUNCTION ZipDistance (zip1 INT(5), zip2 INT(5)) RETURNS DECIMAL(10,2)
RETURN SELECT (DEGREES( ACOS( SIN( RADIANS( db1.Latitude ) ) * SIN( RADIANS(db2.Latitude ) ) + COS( RADIANS( db1.Latitude ) ) * COS( RADIANS( db2.Latitude ) ) * COS(RADIANS( db1.Longitude - db2.Longitude ) ) ) ) *60 * 1.1515) FROM ZipCodeDB as db1, ZipCodeDB as db2 WHERE db1.ZipCode = zip1 AND db1.CityType = 'P' AND db2.ZipCode = zip2 AND db2.CityType='P';
CREATE FUNCTION `NullOrValue`(s VARCHAR(255)) RETURNS char(255)
RETURN IF(s = '',NULL,s)
*/
function BuildFrontEndBreadcrumb($CategoryID, $AddTXT = "")
{
global $MySQL;
$ThisParentID = $CategoryID;
$j = 1;
while ($j != "0") {
$x++;
$GetCategories = $MySQL->Query("SELECT ID, ParentID, Name FROM `Galleries` WHERE ID = '$ThisParentID';");
$ThisID = $GetCategories['ID'];
$ThisName = $GetCategories['Name'];
$ThisParentID = $GetCategories['ParentID'];
$EasyNavARRAY[$x]['ID'] = $ThisID;
$EasyNavARRAY[$x]['Name'] = $ThisName;
if ($ThisParentID == 0) {
break;
$j = 0;
}
}
$ReverseArray = array_reverse($EasyNavARRAY);
$ReturnHTML = "Galleries > ";
foreach ($ReverseArray as $key => $value) {
$k++;
$ID = $ReverseArray[$key]['ID'];
$Name = $ReverseArray[$key]['Name'];
if ($ID == $CategoryID && $AddTXT == "") {
$ReturnHTML .= "$Name";
} else {
$ReturnHTML .= "$Name > ";
}
}
if ($AddTXT != "") {
$ReturnHTML .= " $AddTXT";
}
return $ReturnHTML;
}
function BuildBreadcrumb($CategoryID, $AddTXT = "")
{
global $MySQL;
$ThisParentID = $CategoryID;
$j = 1;
while ($j != "0") {
$x++;
$GetCategories = $MySQL->Query("SELECT ID, ParentID, Name FROM `Galleries` WHERE ID = '$ThisParentID';");
$ThisID = $GetCategories['ID'];
$ThisName = $GetCategories['Name'];
$ThisParentID = $GetCategories['ParentID'];
$EasyNavARRAY[$x]['ID'] = $ThisID;
$EasyNavARRAY[$x]['Name'] = $ThisName;
if ($ThisParentID == 0) {
break;
$j = 0;
}
}
$ReverseArray = array_reverse($EasyNavARRAY);
$ReturnHTML = "Admin Home > ";
foreach ($ReverseArray as $key => $value) {
$k++;
$ID = $ReverseArray[$key]['ID'];
$Name = $ReverseArray[$key]['Name'];
if ($ID == $CategoryID && $AddTXT == "") {
$ReturnHTML .= "$Name";
} else {
$ReturnHTML .= "$Name > ";
}
}
if ($AddTXT != "") {
$ReturnHTML .= " $AddTXT";
}
return $ReturnHTML;
}
class Images {
/*
@version 1
@param string $File location of tmp image to be uploaded
*/
function UploadImage($File)
{
if (file_exists($File)) {
$DocumentRoot = $_SERVER["DOCUMENT_ROOT"];
$MD5FileName = md5_file($File) . ".jpg";
$FinalPath = "$DocumentRoot/images/upload/" . "$MD5FileName";
move_uploaded_file($File, $FinalPath);
chmod($FinalPath, 0755);
$this->ImageFile = $FinalPath;
$this->ImageName = $MD5FileName;
} else {
echo "File doest not exist";
}
}
/*
@version 1
@param string $SaveFile location where resized image it to be saved
@param int $MaxWidth maximum width the image is allowed to be
*/
function ResizeImage($SaveFile, $MaxWidth)
{
$orig = @imagecreatefromjpeg($this->ImageFile);
$Save = $SaveFile . $this->ImageName;
if (!$orig) {
return 0;
}
$orig_x = imagesx($orig);
$orig_y = imagesy($orig);
if ($orig_x > $MaxWidth) {
$image_x = "$MaxWidth";
} else {
$image_x = "$orig_x";
}
$image_y = round(($orig_y * $image_x) / $orig_x);
$image = imagecreatetruecolor($image_x, $image_y);
imagecopyresampled($image, $orig, 0, 0, 0, 0, $image_x, $image_y, $orig_x, $orig_y);
imagejpeg($image, $Save);
}
/*
@version 1
@return string Returns the MD5 image file name
*/
function ImageMD5FileName()
{
return $this->ImageName;
}
}
function BuildCategoryListStructure($CategoryID, $Content, $IndentCount = -1, $Selected = "")
{
global $MySQL;
$IndentCount++;
if ($CategoryID == "0") {
$GetCategories = $MySQL->QueryArray("SELECT ID, Name FROM `Galleries` WHERE `ParentID` IS NULL ORDER BY `Order`, `Name` ASC;");
} else {
$GetCategories = $MySQL->QueryArray("SELECT ID, Name FROM `Galleries` WHERE `ParentID` = '$CategoryID' ORDER BY `Order`, `Name` ASC;");
}
$Indent = str_repeat("... ", $IndentCount);
if ($GetCategories) {
foreach ($GetCategories as $key => $value) {
$ID = $GetCategories[$key]['ID'];
$CategoryName = $GetCategories[$key]['Name'];
$Count = $GetCategories[$key]['Count'];
if ($Content == "") {
$DisplayContent = "$CategoryName";
} else {
// $DisplayContent = "$Content > $CategoryName";
$DisplayContent = "$CategoryName";
}
$DisplayContent = htmlentities(html_entity_decode($DisplayContent));
if ($Selected == $ID) {
$ReturnContent .= "";
} else {
$ReturnContent .= "";
}
$ReturnContent .= BuildCategoryListStructure($ID, $DisplayContent, $IndentCount, $Selected = "");
}
} else {
return;
}
return $ReturnContent;
}
class DisplayFunctions {
function RotatingBG()
{
$this->x = $this->x + 1;
if ($this->x % 2) {
return "#EBEBEB";
} else {
return "#FFFFFF";
}
}
/**
* DisplayFunctions::BuildTable()
*
* @param array $ArrayContents Array contents of the table cell content to be built
* @param int $Columns number of columns per row
* @return string Returns HTML table
*/
function BuildTable($ArrayContents, $Columns, $CellHorizontalAlign = "left", $CellVerticalAlign = "top")
{
$Width = round(100 / $Columns) . "%";
$x = 1;
foreach($ArrayContents as $key => $value) {
if ($x == "1") {
$TableContent .= "
$value | ";
$x++;
} elseif ($x < $Columns) {
$TableContent .= "$value | ";
$x++;
} elseif ($x == $Columns) {
$TableContent .= "$value |
";
$x = 1;
}
}
$x = $x - 1;
if ($x != $Columns && $x != 0) {
foreach(range($x, ($Columns) - 1) as $number) {
$TableContent .= " | ";
}
$TableContent .= " | ";
}
return "";
}
/**
* DisplayFunctions::BuildSelectMenuFromArray()
*
* @param array $ThisArray
* @param mixed $MenuName Form Name of Select
* @param mixed $SelectedID Selected value
* @return Returns select menu based on array input
* @return
*/
function BuildSelectMenuFromArray($ThisArray, $MenuName, $SelectedID = "")
{
if (is_array($ThisArray)) {
foreach($ThisArray as $key => $value) {
$OptionName = htmlentities($value);
if ($key == $SelectedID) {
$OptionValues .= "\n";
} else {
$OptionValues .= "\n";
}
}
}
return "";
}
/**
* DisplayFunctions::BuildRadioMenuFromArray()
*
* @param mixed $ThisArray
* @param mixed $MenuName
* @param string $SelectedID
* @return
*/
function BuildRadioMenuFromArray($ThisArray, $MenuName, $SelectedID = "")
{
if (is_array($ThisArray)) {
foreach($ThisArray as $key => $value) {
$x++;
$OptionName = htmlentities($value);
$ThisID = "$MenuName_$x";
if ($key == $SelectedID || ($SelectedID == "" && $x == 1)) {
$OptionValues .= "
\n";
} else {
$OptionValues .= "
\n";
}
}
}
return $OptionValues;
}
function BuildCheckboxFromArray($ThisArray, $MenuName, $SelectedArray = array())
{
if (is_array($ThisArray)) {
foreach($ThisArray as $key => $value) {
$x++;
$OptionName = htmlentities($value);
$ThisID = "$MenuName_$x";
$ThisMenuName = $MenuName . "[]";
if (in_array($key, $SelectedArray)) {
$OptionValues .= "$OptionName
\n";
} else {
$OptionValues .= "$OptionName
\n";
}
}
}
return $OptionValues;
}
/**
* DisplayFunctions::BuildCheckbox()
*
* @param string $Name
* @param string $Checked
* @return Return HTML checkbox
*/
function BuildCheckbox($Name, $Value, $Checked = "N", $JSOnClick = "")
{
if ($JSOnClick != "") {
$JS = "OnClick=\"$JSOnClick\"";
}
if ($Checked == "Y") {
return "";
} else {
return "";
}
}
function BuildStatesDropDown($MenuName, $Selected = "")
{
global $MySQL;
$OptionValues = "\n";
$GetStates = $MySQL->QueryArray("SELECT * FROM `States` WHERE 1 ORDER BY StateCode ASC;");
foreach($GetStates as $key => $value) {
$StateCode = $GetStates[$key]['StateCode'];
$State = $GetStates[$key]['State'];
if ($Selected == $StateCode) {
$OptionValues .= "\n";
} else {
$OptionValues .= "\n";
}
}
return "";
}
}
function MySQLSafeString($String)
{
if (get_magic_quotes_gpc()) {
return mysql_real_escape_string(stripslashes(trim($String)));
} else {
return mysql_real_escape_string(trim($String));
}
}
function HTMLSafeString($String)
{
return htmlentities($String);
}
class MySQL {
// Setup error reporting when class is originally called
function MySQL()
{
MySQL::SetErrorReporting();
MySQL::Connect("localhost", "mytechgu_swifts", "sc@20210628!");
MySQL::SelectDB("mytechgu_swiftls");
}
function MySQLConnection ()
{
return $this->Connection;
}
/*
Connect to the MySQL Server
@version 1
@param string $Host MySQL Host
@param string $Username MySQL Username
@param string $Password MySQL Password
*/
function Connect($Host, $Username, $Password)
{
$this->Connection = mysql_connect("$Host", "$Username", "$Password") or die(MySQL::Error("Function Connect: " . mysql_error()));
}
/*
@version 1
@param string $DB Select MySQL database
*/
function SelectDB($DB)
{
mysql_select_db("$DB") or die(MySQL::Error("Function SelectDB: " . mysql_error()));
}
/*
@version 1
@param string $Query MySQL Query
@return array Array of results for this query in the form of Name[0][keyname]
*/
function QueryArray($Query)
{
// echo "$Query\n";
$Return = array();
$SQL_Query = mysql_query("$Query", $this->Connection) or die(MySQL::Error("Function QueryArray: ---$Query--- " . mysql_error()));
$i = 0;
if ($myrow = mysql_fetch_assoc($SQL_Query)) {
do {
$i++;
foreach ($myrow as $key => $value) {
$Return[$i][$key] = $value;
}
} while ($myrow = mysql_fetch_assoc($SQL_Query));
}
// $Return[rows] = $i;
return $Return;
}
/*
@version 1
@param string $Query MySQL Query
@return array Array of results for this query in the form of Name[keyname]
*/
function Query($Query)
{
// echo "$Query\n";
$Return = array();
$SQL_Query = mysql_query("$Query", $this->Connection) or die(MySQL::Error("Function Query: ---$Query--- " . mysql_error()));
if ($myrow = mysql_fetch_assoc($SQL_Query)) {
do {
$i++;
foreach ($myrow as $key => $value) {
$Return[$key] = $value;
}
} while ($myrow = mysql_fetch_assoc($SQL_Query));
}
return $Return;
}
/*
@version 1
@param string $Query MySQL Query
*/
function SingleQuery($Query)
{
// echo "$Query\n";
$SQL_Query = mysql_query("$Query", $this->Connection) or die(MySQL::Error("Function SingleQuery: ---$Query--- " . mysql_error()));
}
/*
@version 1
@return string Insert ID of last query
*/
function InsertID()
{
return mysql_insert_id();
}
/*
Dont display error messages
@version 1
*/
function SetErrorReporting()
{
// error_reporting(0);
}
/*
Shows error messages
@version 1
@param string $Message Error message to display
*/
function Error($Message)
{
$ErrorMSG = mysql_error();
echo "$Message";
}
}
class Template {
/*
@version 1
@param string $TemplateFile location of the dreamweaver template to use
*/
function Template($TemplateFile)
{
$this->Template = file_get_contents($TemplateFile);
}
/*
@version 1
@param string $TemplateRegion Template region to replace
@param string $Value Value to replace with
*/
function SetContent($TemplateRegion, $Value)
{
$Value = str_replace('$', '\\$', $Value);
if ($TemplateRegion == "Title") {
$this->Template = preg_replace("@.*?@si", "$Value", $this->Template);
}
$this->Template = preg_replace("@.*?@si", "$Value", $this->Template);
}
/*
@version 1
@return Displays the template HTML
*/
function Display($Eval = "N")
{
if ($Eval == "Y") {
$Content = $this->Template;
eval("?>" . $Content);
} else {
return $this->Template;
}
}
}
?>
Fatal error: Uncaught Error: Class 'MySQL' not found in /home/mytechgu/PROD/SCL_PROD/galleries.php:13
Stack trace:
#0 {main}
thrown in /home/mytechgu/PROD/SCL_PROD/galleries.php on line 13