Erik\'s DeliCafe - Content Management System'); define('BG_COLOR_WHITE', '#FFFFFF'); define('BG_COLOR_BLACK', '#000000'); define('BG_COLOR_1', '#CCCCCC'); define('BG_COLOR_2', '#F1F1F1'); define('TEXTBOX_STYLE_1', 'border:1px solid #CCCCCC'); define('TEXTBOX_STYLE_2', 'border:1px solid #CCCCCC;text-align:right'); define('TEXTBOX_STYLE_3', 'border:0px solid #FFFFFF'); define('SITE_DOMAIN','http://www.eriksdelicafe.com'); define('ROOT_PATH','/'); define('CKEDITOR_URL',''); define('CKFINDER_URL',''); define('CKFINDER_ROOT',ROOT_PATH.'ckfinder/'); define('CKEDITOR_STYLE_CSS',SITE_DOMAIN.ROOT_PATH.'sysadmin/includes/css/'); define('CKEDITOR_STYLE_CSS1',SITE_DOMAIN.ROOT_PATH.'sysadmin/includes/css/ckstyle1.css'); define('CKEDITOR_STYLE_CSS2',SITE_DOMAIN.ROOT_PATH.'sysadmin/includes/css/ckstyle2.css'); define('CKEDITOR_STYLE_CSS3',SITE_DOMAIN.ROOT_PATH.'sysadmin/includes/css/ckstyle3.css'); define('CKEDITOR_STYLE_CSS4',SITE_DOMAIN.ROOT_PATH.'sysadmin/includes/css/ckstyle4.css'); define('CKEDITOR_STYLE_CSS5',SITE_DOMAIN.ROOT_PATH.'sysadmin/includes/css/ckstyle5.css'); define('CKEDITOR_STYLE_CSS6',SITE_DOMAIN.ROOT_PATH.'sysadmin/includes/css/ckstyle6.css'); define('CKEDITOR_STYLE_CSS7',SITE_DOMAIN.ROOT_PATH.'sysadmin/includes/css/ckstyle7.css'); define('CKEDITOR_STYLE_CSS8',SITE_DOMAIN.ROOT_PATH.'sysadmin/includes/css/ckstyle8.css'); define('CKEDITOR_STYLE_CSS9',SITE_DOMAIN.ROOT_PATH.'sysadmin/includes/css/ckstyle9.css'); define('CKEDITOR_STYLE_CSS10',SITE_DOMAIN.ROOT_PATH.'sysadmin/includes/css/ckstyle10.css'); define('META_TITLE_NOTE','7-10 words maximum are recommended. It is best if the title is different for every page and describes the content that is found on the page.'); define('META_KEYWORDS_NOTE','10-15 keywords and/or phrases maximum are recommended. It is best if the keywords are different for every page and describes the content that is found on the page. Each keyword or phrase should be separated by a comma with no spaces after the comma. (i.e. key phrase one,key phrase two,etc)'); define('META_DESCRIPTION_NOTE','1-2 short sentences maximum are recommended. It is best if the description is different for every page and briefly describes the content that is found on the page.'); define('NO_ITEMS','

These items are coming soon, please check back.

'); ?>alert('FTP server connection failed!');"; } else { if (ftp_login($conn_id,$ftp_user,$ftp_pass)) { if (ftp_chmod($conn_id,eval("return({$mode});"),$directory)) { $ret = true; } else { echo ""; } } else { echo ""; } } ftp_close($conn_id); return $ret; } function CreateFile($filename,$id,$opt) { $ret = false; if (CheckFileName($filename)) { if (ChmodFolder('','0777')) { if ($opt == "location_catering") { $search = array("{PAGE_ID}"); $replace = array($id); $content = str_replace($search,$replace,Query("tbl_settings","location_catering_page_template","id",1)); } elseif ($opt == "store_location") { $search = array("{STORE_LOCATION_ID}"); $replace = array($id); $content = str_replace($search,$replace,Query("tbl_settings","store_location_page_template","id",1)); } $dest_fn = "../".$filename; if (!$handle = fopen($dest_fn,'w')) { echo ""; } else { if (fwrite($handle,$content) === FALSE) { echo ""; } else { $ret = true; } } fclose($handle); ChmodFolder('','0750'); } } return $ret; } function CheckFileName($filename) { $ret = false; $handle = opendir("../"); while (false !== ($file = readdir($handle))) { $ret = true; if ($file != "." && $file != "..") { if ($file == $filename) { $ret = false; break; } } } return $ret; } function GetPageURL($id,$opt) { $ret = ""; if ($opt == "location_catering") { $filename = Query("tbl_location_catering_pages","filename","id",$id); } elseif ($opt == "store_location") { $filename = Query("tbl_store_locations","filename","id",$id); } if (!empty($filename)) { $ret = "".SITE_DOMAIN.$filename.""; } return $ret; } function ConvertZero($num) { //$ret = ""; //if ($num > 0) { $ret = $num; } $ret = $num; return $ret; } function writePreviewActions($id) { if ($id <> "") { $confirm_alert = "Confirm to Update?"; $button_text = "Update"; $submit_action = "update"; } else { $confirm_alert = "Confirm to Save?"; $button_text = "Save"; $submit_action = "save"; } echo "
\n"; echo "
\n"; echo " | "; echo "\n"; foreach ($_POST as $key => $value) { if ($key <> "Submit" and $key <> "submit_action") { if (!is_array($value)) { echo "\n"; } else { for ($i = 0; $i < sizeof($value); $i++) { echo "\n"; } } } } echo "\n"; echo "
"; echo "
 
\n"; } function formatBytes($b,$p = null) { $units = array("B","KB","MB","GB","TB","PB","EB","ZB","YB"); $c=0; if(!$p && $p !== 0) { foreach($units as $k => $u) { if(($b / pow(1024,$k)) >= 1) { $r["bytes"] = $b / pow(1024,$k); $r["units"] = $u; $c++; } } return number_format($r["bytes"],2) . " " . $r["units"]; } else { return number_format($b / pow(1024,$p)) . " " . $units[$p]; } } function GetSubpageName() { $ret = array(); $result = mysql_query("SELECT * FROM `tbl_subpages` ORDER BY `id` ASC"); for ($i = 0; $i < mysql_num_rows($result); $i++) { mysql_data_seek($result,$i); $data = mysql_fetch_object($result); $ret[] = $data->menu_title; } return $ret; } function GetPageName() { $ret = array(); $result = mysql_query("SELECT * FROM `tbl_pages` ORDER BY `id` ASC"); for ($i = 0; $i < mysql_num_rows($result); $i++) { mysql_data_seek($result,$i); $data = mysql_fetch_object($result); $ret[] = $data->menu_title; } return $ret; } function ProcessMagicQuotes($input) { if (get_magic_quotes_gpc()) { $ret = trim(stripslashes($input)); } else { $ret = trim($input); } return $ret; } function GetCountries() { $ret = array("United States"); $result = mysql_query("SELECT * FROM tbl_countries WHERE active = 'Yes' ORDER BY country_name ASC"); for ($i = 0; $i < mysql_num_rows($result); $i++) { mysql_data_seek($result,$i); $data = mysql_fetch_object($result); $ret[] = $data->country_name; } return $ret; } function GetStates($country_id) { $ret = array(); $result = mysql_query("SELECT * FROM `tbl_country_states` WHERE `country_id` = ".SqlNum($country_id)." ORDER BY state_name ASC"); for ($i = 0; $i < mysql_num_rows($result); $i++) { mysql_data_seek($result,$i); $data = mysql_fetch_object($result); $ret[] = $data->state_name; } return $ret; } function CURL_Get($url) { $ret = ""; $ch = curl_init(); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_URL,$url); $ret = curl_exec($ch); curl_close($ch); unset($ch); return $ret; } function BriefText($text,$num,$opt) { $ret = ""; $search = array("'<[\/\!]*?[^<>]*?>'si","'\x0d'si","' 'si","'\\n'si","'\\t'si","'".chr(160)."'si"); $replace = array(" "," "," "," "," "," "); $search1 = array(" ."," ,","“","”","’",""","&","<",">"," ","¡","¢","£","¤","¥","¦","§","¨","©","ª","«","¬","­","®","¯","°","±","²","³","´","µ","¶","·","¸","¹","º","»","¼","½","¾","¿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ"); $replace1 = array(".",",","“","”","’","\"","&","<",">","","¡","¢","£","¤","¥","¦","§","¨","©","ª","«","¬","­","®","¯","°","±","²","³","´","µ","¶","·","¸","¹","º","»","¼","½","¾","¿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ"); $text = strip_tags(preg_replace($search,$replace,trim($text))); $text = trim(str_replace($search1,$replace1,$text)); if ($opt == 1) { $ret = substr(trim($text),0,$num); if (strlen(trim($text)) > $num) { $ret .= "..."; } } elseif ($opt == 2) { $count = 0; $tmp = explode(" ",$text); for ($i = 0; $i < sizeof($tmp); $i++) { if (ord($tmp[$i]) <> 0 and strtolower($tmp[$i]) <> " ") { if ($new_text <> "") { $new_text .= " "; } $new_text .= $tmp[$i]; $count++; if ($count == $num) { break; } } } $ret = trim($new_text); if ($i < (sizeof($tmp)-1)) { $ret .= "..."; } } return $ret; } function ListingDisplay($text,$num,$opt) { $ret = ""; $search = array("'<[\/\!]*?[^<>]*?>'si","'\x0d'si","' 'si","'\\n'si","'\\t'si","'".chr(160)."'si"); $replace = array(" "," "," "," "," "," "); $search1 = array(" ."," ,","“","”","’",""","&","<",">"," ","¡","¢","£","¤","¥","¦","§","¨","©","ª","«","¬","­","®","¯","°","±","²","³","´","µ","¶","·","¸","¹","º","»","¼","½","¾","¿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ"); $replace1 = array(".",",","“","”","’","\"","&","<",">","","¡","¢","£","¤","¥","¦","§","¨","©","ª","«","¬","­","®","¯","°","±","²","³","´","µ","¶","·","¸","¹","º","»","¼","½","¾","¿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ"); if ($opt == 1) { $ret = substr(trim(htmlspecialchars($text)),0,$num); if (strlen(trim(htmlspecialchars($text))) > $num) { $ret .= "..."; } } elseif ($opt == 2) { $text = strip_tags(preg_replace($search,$replace,trim($text))); $text = str_replace($search1,$replace1,$text); $tmp = explode(" ",$text); for ($i = 0; $i < sizeof($tmp); $i++) { if (ord($tmp[$i]) <> 0 and strtolower($tmp[$i]) <> " ") { if ($new_text <> "") { $new_text .= " "; } $new_text .= $tmp[$i]; } } $ret = substr(trim($new_text),0,$num); if (strlen(trim($new_text)) > $num) { $ret .= "..."; } } return $ret; } function PreventEmpty($val) { $ret = ""; if (trim($val) == "") { $ret = " "; } else { $ret = trim($val); } return $ret; } function CompareCheckbox($value,$source) { $ret = false; $tmp = explode(",",$source); for ($i = 0; $i < count($tmp); $i++) { if (trim($tmp[$i]) == trim($value)) { $ret = true; break; } } return $ret; } function Positioning($tablename,$id,$position) { $new_pos = 0; $pos_query = "SELECT id FROM ".$tablename." WHERE id <> ".SqlNum($id)." ORDER BY position ASC"; $pos_result = mysql_query($pos_query); for ($pos_i = 0; $pos_i < mysql_num_rows($pos_result); $pos_i++) { mysql_data_seek($pos_result,$pos_i); $pos_data = mysql_fetch_object($pos_result); $new_pos++; if ($new_pos == $position) { $new_pos++; } $pos_query = "UPDATE `".$tablename."` SET `position` = '".$new_pos."' WHERE `id` = '".$pos_data->id."' LIMIT 1"; mysql_query($pos_query); } } function Positioning1($tablename,$id,$position,$field,$value) { $new_pos = 0; $pos_query = "SELECT id FROM ".$tablename." WHERE id <> ".SqlNum($id)." AND ".$field." = ".SqlText($value)." ORDER BY position ASC"; $pos_result = mysql_query($pos_query); for ($pos_i = 0; $pos_i < mysql_num_rows($pos_result); $pos_i++) { mysql_data_seek($pos_result,$pos_i); $pos_data = mysql_fetch_object($pos_result); $new_pos++; if ($new_pos == $position) { $new_pos++; } $pos_query = "UPDATE `".$tablename."` SET `position` = '".$new_pos."' WHERE `id` = '".$pos_data->id."' LIMIT 1"; mysql_query($pos_query); } } function Positioning2($tablename,$id,$position,$field,$value) { $new_pos = 0; $pos_query = "SELECT id, ".$field." FROM ".$tablename." WHERE id <> ".SqlNum($id)." ORDER BY ".$field." ASC, position ASC"; $pos_result = mysql_query($pos_query); for ($pos_i = 0; $pos_i < mysql_num_rows($pos_result); $pos_i++) { mysql_data_seek($pos_result,$pos_i); $pos_data = mysql_fetch_array($pos_result); if ($cur_value <> $pos_data[1]) { $new_pos = 0; $cur_value = $pos_data[1]; } $new_pos++; if ($new_pos == $position and $cur_value == $value) { $new_pos++; } $pos_query = "UPDATE `".$tablename."` SET `position` = '".$new_pos."' WHERE `id` = '".$pos_data[0]."' LIMIT 1"; mysql_query($pos_query); } } function Positioning3($tablename,$field,$value) { $new_pos = 0; $pos_query = "SELECT id FROM ".$tablename." WHERE ".$field." = ".SqlText($value)." ORDER BY position ASC"; $pos_result = mysql_query($pos_query); for ($pos_i = 0; $pos_i < mysql_num_rows($pos_result); $pos_i++) { mysql_data_seek($pos_result,$pos_i); $pos_data = mysql_fetch_object($pos_result); $new_pos++; $pos_query = "UPDATE `".$tablename."` SET `position` = '".$new_pos."' WHERE `id` = '".$pos_data->id."' LIMIT 1"; mysql_query($pos_query); } } function iptc_maketag($rec,$dat,$val) { $len = strlen($val); if ($len < 0x8000) { return chr(0x1c).chr($rec).chr($dat). chr($len >> 8). chr($len & 0xff). $val; } else { return chr(0x1c).chr($rec).chr($dat). chr(0x80).chr(0x04). chr(($len >> 24) & 0xff). chr(($len >> 16) & 0xff). chr(($len >> 8 ) & 0xff). chr(($len ) & 0xff). $val; } } function FileUpload($type,$fn,$dest) { if (is_uploaded_file($_FILES[$fn]['tmp_name']) and $_FILES[$fn]['size'] > 0) { ini_set("memory_limit","1024M"); $uploaded_file_tmp_name = $_FILES[$fn]['tmp_name']; $uploaded_file_type = $_FILES[$fn]['type']; if ($type == "jpeg" or $type == "image") { $source_fn = $uploaded_file_tmp_name; $tmp = getimagesize($source_fn,$info); $iptc_old = iptcparse($info["APP13"]); if (isset($info['APP13']) and sizeof($iptc_old) > 1) { foreach (array_keys($iptc_old) as $s) { $tag = str_replace("2#", "", $s); $iptc_new .= iptc_maketag(2, $tag, $iptc_old[$s][0]); } } for ($i = 0; $i < count($dest); $i++) { $dest_opt = explode(",",$dest[$i]); $this_fn = $dest_opt[0]; $this_fn_width = $dest_opt[1]; $this_fn_height = $dest_opt[2]; $this_image_crop = $dest_opt[3]; if ($this_image_crop == "Yes") { $ratio = 1; $size = getimagesize($source_fn); if ($size[1] * ($this_fn_width / $size[0]) >= $this_fn_height) { $ratio = $this_fn_width / $size[0]; } if ($size[0] * ($this_fn_height / $size[1]) >= $this_fn_width) { $ratio = $this_fn_height / $size[1]; } $w = $size[0] * $ratio; $h = $size[1] * $ratio; $src_x = ($size[0] - ($this_fn_width / $ratio)) / 2; $im1 = imagecreatetruecolor($this_fn_width,$this_fn_height); if ($uploaded_file_type == "image/jpeg" or $uploaded_file_type == "image/pjpeg") { $image = imagecreatefromjpeg($source_fn); imagecopyresampled($im1,$image,0,0,$src_x,0,$w,$h,$size[0],$size[1]); imagejpeg($im1,$this_fn,100); if (isset($info['APP13']) and sizeof($iptc_old) > 1) { $content = iptcembed($iptc_new, $this_fn, 0); $fp = fopen($this_fn, "w"); fwrite($fp, $content); fclose($fp); } } if ($uploaded_file_type == "image/png" or $uploaded_file_type == "image/x-png") { $image = imagecreatefrompng($source_fn); // Make the background transparent imageantialias($im1,true); imagealphablending($im1,false); imagesavealpha($im1,true); $transparent = imagecolorallocatealpha($im1,0,0,0,127); imagefill($im1,0,0,$transparent); // - end imagecopyresampled($im1,$image,0,0,$src_x,0,$w,$h,$size[0],$size[1]); imagepng($im1,$this_fn,9); } if ($uploaded_file_type == "image/gif") { $image = imagecreatefromgif($source_fn); // Make the background transparent $black = imagecolorallocate($im1,0,0,0); imagecolortransparent($im1,$black); //$transparent = imagecolorallocatealpha($im1,0,0,0,127); //imagecolortransparent($im1,$transparent); // - end imagecopyresampled($im1,$image,0,0,$src_x,0,$w,$h,$size[0],$size[1]); imagegif($im1,$this_fn,100); } } else { if ($this_fn_width == 0 and $this_fn_height == 0) { copy($source_fn,$this_fn); } else { $size = getimagesize($source_fn, $source_file_info); $ratio = 1; if ($this_fn_width > 0 and $this_fn_height > 0) { if ($size[0] > $this_fn_width) { $ratio = $this_fn_width / $size[0]; } if ($size[1] * $ratio > $this_fn_height) { $ratio = $this_fn_height / $size[1]; } } elseif ($this_fn_width > 0 and $this_fn_height == 0) { if ($size[0] > $this_fn_width) { $ratio = $this_fn_width / $size[0]; } } elseif ($this_fn_width == 0 and $this_fn_height > 0) { if ($size[1] > $this_fn_height) { $ratio = $this_fn_height / $size[1]; } } $w = $size[0] * $ratio; $h = $size[1] * $ratio; $im1 = imagecreatetruecolor($w,$h); if ($uploaded_file_type == "image/jpeg" or $uploaded_file_type == "image/pjpeg") { $image = imagecreatefromjpeg($source_fn); imagecopyresampled($im1,$image,0,0,0,0,$w,$h,$size[0],$size[1]); imagejpeg($im1,$this_fn,100); if (isset($info['APP13']) and sizeof($iptc_old) > 1) { $content = iptcembed($iptc_new, $this_fn, 0); $fp = fopen($this_fn, "w"); fwrite($fp, $content); fclose($fp); } } if ($uploaded_file_type == "image/png" or $uploaded_file_type == "image/x-png") { $image = imagecreatefrompng($source_fn); // Make the background transparent imageantialias($im1,true); imagealphablending($im1,false); imagesavealpha($im1,true); $transparent = imagecolorallocatealpha($im1,0,0,0,127); imagefill($im1,0,0,$transparent); // - end imagecopyresampled($im1,$image,0,0,0,0,$w,$h,$size[0],$size[1]); imagepng($im1,$this_fn,9); } if ($uploaded_file_type == "image/gif") { $image = imagecreatefromgif($source_fn); // Make the background transparent $black = imagecolorallocate($im1,0,0,0); imagecolortransparent($im1,$black); //$transparent = imagecolorallocatealpha($im1,0,0,0,127); //imagecolortransparent($im1,$transparent); // - end imagecopyresampled($im1,$image,0,0,0,0,$w,$h,$size[0],$size[1]); imagegif($im1,$this_fn,100); } } } } } else { $source_fn = $uploaded_file_tmp_name; for ($i = 0; $i < count($dest); $i++) { $dest_opt = explode(",",$dest[$i]); $this_fn = $dest_opt[0]; copy($source_fn,$this_fn); } } unlink($uploaded_file_tmp_name); } } function DateNow() { $timestamp = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")); $ret = date("Y-m-d",$timestamp); return $ret; } function TimeNow() { $timestamp = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")); $ret = date("H:i:s",$timestamp); return $ret; } function FormatDate($strTime,$opt) { $ret = explode("-",$strTime); $timestamp = mktime(0,0,0,$ret[1],$ret[2],$ret[0]); if ($opt == 1) { $ret = date("m-d-Y",$timestamp); } if ($opt == 2) { $ret = date("m/d/Y",$timestamp); } if ($opt == 3) { $ret = date("n.j.y",$timestamp); } if ($opt == 4) { $ret = date("l, F jS, Y",$timestamp); } if ($opt == 5) { $ret = date("F jS, Y",$timestamp); } if ($opt == 6) { $ret = date("D, j M y",$timestamp); } if ($opt == 7) { $ret = date("M. jS, Y",$timestamp); } if ($opt == 8) { $ret = date("F j, Y",$timestamp); } if ($opt == 9) { $ret = date("F Y",$timestamp); } if ($opt == 10) { $ret = date("d F Y",$timestamp); } return $ret; } function FormatTime($strTime,$opt) { $ret = explode(":",$strTime); $timestamp = mktime($ret[0],$ret[1],$ret[2],date("m"),date("d"),date("Y")); if ($opt == 1) { $ret = date("g:i A",$timestamp); } if ($opt == 2) { $ret = date("g:ia",$timestamp); } return $ret; } function Query($Table,$getField,$matchField,$matchValue) { $rsQuery = mysql_query("SELECT ".trim($getField)." FROM ".trim($Table)." WHERE ".trim($matchField)." = ".SqlText($matchValue)); @mysql_data_seek($rsQuery,0); $datQuery = @mysql_fetch_row($rsQuery); $ret = $datQuery[0]; return $ret; } function PrepareLink($input) { $ret = ProcessVal(str_replace(' ','_',trim($input))); return $ret; } function ProcessVal($input) { $ret = htmlspecialchars(trim($input)); return $ret; } function SqlDate($input) { if (get_magic_quotes_gpc()) { $input = trim(stripslashes($input)); } else { $input = trim($input); } $input = DateConvert($input,1); $ret = "'".mysql_real_escape_string($input)."'"; return $ret; } function SqlText($input) { if (get_magic_quotes_gpc()) { $input = trim(stripslashes($input)); } else { $input = trim($input); } $ret = "'".mysql_real_escape_string($input)."'"; return $ret; } function SqlNum($input) { if (get_magic_quotes_gpc()) { $input = trim(stripslashes($input)); } else { $input = trim($input); } $input = trim(str_replace(",","",$input)); if (trim($input) == "" or !is_numeric($input)) { $input = 0; } $ret = "'".mysql_real_escape_string($input)."'"; return $ret; } function NumFormat($num){ $dec_pt = strpos($num, "."); If ($dec_pt == 0) { $tempStr = $num.".00"; } else { If ((strlen($num)-1)-$dec_pt >= 2){ $tempStr = $num; } else { $tempStr = $num."0"; } } $comma_pos = 0; $retval = ""; $start = "F"; For ($i = strlen($tempStr)-1; $i >= 0; $i--) { $retval = substr($tempStr, $i, 1).$retval; if ($start == "F") { if (substr($tempStr, $i, 1) == ".") { $start = "T"; } } else { $comma_pos++; if ($comma_pos == 3) { $comma_pos = 0; if (($i-1 >= 0) and (substr($tempStr, $i-1, 1) <> "-")) { $retval = ",".$retval; } } } } if ($retval == ".00") { $retval = "0.00"; } return($retval); } function DateConvert($strDate,$opt) { $ret = ""; $ret = trim($strDate); $tempDate = explode("-",$strDate); if ($opt == 1) { $strDay = trim($tempDate[1]); if (strlen($strDay) == 1) { $strDay = "0".$strDay; } $strMonth = trim($tempDate[0]); if (strlen($strMonth) == 1) { $strMonth = "0".$strMonth; } $strYear = $tempDate[2]; if (@checkdate($strMonth,$strDay,$strYear)) { $ret = $strYear."-".$strMonth."-".$strDay; } else { $ret = "0000-00-00"; } } elseif ($opt == 2) { $strDay = trim($tempDate[2]); if (strlen($strDay) == 1) { $strDay = "0".$strDay; } $strMonth = trim($tempDate[1]); if (strlen($strMonth) == 1) { $strMonth = "0".$strMonth; } $strYear = $tempDate[0]; if (@checkdate($strMonth,$strDay,$strYear)) { $ret = $strMonth."-".$strDay."-".$strYear; } else { $ret = ""; } } return $ret; } function TimeConvert($strTime) { $ret = explode(":",$strTime); $timestamp = mktime($ret[0],$ret[1],$ret[2],date("m"),date("d"),date("Y")); $ret = date("g:i:s A",$timestamp); return $ret; } ?>