include_once('mysql_anthony.inc');
function format_the_newsdate($date)
{
if($date)
{
$time = strtotime($date);
$date = date("M d Y", $time);
}
return $date;
}
function format_the_date($date)
{
if($date)
{
$bits = array();
$bits = explode('-',$date);
$y = $bits[0];
$m = $bits[1];
$d = $bits[2];
$bits = array();
$bits = explode(" ",$d);
if($d[1])
$d = $bits[0];
$time = mktime(0, 0, 0, date($m), date($d), date($y));
$date = date("M j, Y", $time);
$date = date("m/d/y", $time);
return $date;
}
else
return date("m/d/y");
}
function format_the_datetime($date)
{
$timestamp = strtotime($date);
$date = date("m/d/Y g:i A",$timestamp);
return $date;
}
function format_the_date2($date)
{
$y = substr($date, 2, 2);
$m = substr($date, 4, 2);
$d = substr($date, 6, 2);
$date = "$m/$d/$y";
return $date;
}
function format_the_time($time)
{
$h = substr($time, 0, 2);
$m = substr($time, 2, 2);
$s = substr($time, 4, 2);
$time = "$h:$m:$s";
return $time;
}
function format_phone($phone)
{
if(strlen($phone) == 16)
{
$a = substr($phone, 1, 3);
$b = substr($phone, 4, 3);
$c = substr($phone, 7, 4);
$phone = "($a) $b-$c";
}
if(strlen($phone) == 11)
{
$a = substr($phone, 1, 3);
$b = substr($phone, 4, 3);
$c = substr($phone, 7, 4);
$phone = "($a) $b-$c";
}
if(strlen($phone) == 10)
{
$a = substr($phone, 0, 3);
$b = substr($phone, 3, 3);
$c = substr($phone, 6, 4);
$phone = "($a) $b-$c";
}
elseif(strlen($phone) == 7)
{
$a = substr($phone, 0, 3);
$b = substr($phone, 3, 4);
$phone = "$a-$b";
}
return $phone;
}
function format_fax_number($phone)
{
$phone = str_replace(")","",$phone);
$phone = str_replace("(","",$phone);
$phone = str_replace(" ","",$phone);
$phone = str_replace("-","",$phone);
$phone = str_replace(".","",$phone);
if(strlen($phone) == 16)
{
$a = substr($phone, 1, 3);
$b = substr($phone, 4, 3);
$c = substr($phone, 7, 4);
$phone = "+1-$a-$b-$c";
}
if(strlen($phone) == 11)
{
$a = substr($phone, 1, 3);
$b = substr($phone, 4, 3);
$c = substr($phone, 7, 4);
$phone = "+1-$a-$b-$c";
}
if(strlen($phone) == 10)
{
$a = substr($phone, 0, 3);
$b = substr($phone, 3, 3);
$c = substr($phone, 6, 4);
$phone = "+1-$a-$b-$c";
}
elseif(strlen($phone) == 7)
{
$a = substr($phone, 0, 3);
$b = substr($phone, 3, 4);
$phone = "+1-818-$a-$b";
}
return $phone;
}
function getLastDayOfMonth($month, $year)
{
return idate('d', mktime(0, 0, 0, ($month + 1), 0, $year));
}
function return_month($start_day = "01",$start_month,$start_year, $cview="month")
{
$day_rep_name_arr = array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
if(!$set_today)
{
$today = date("d",time());
}
else {
$today = $set_today;
}
$lastmonth = mktime(0, 0, 0, $start_month-1, 1, $start_year);
$nextmonth = mktime(0, 0, 0, $start_month+1, 1, $start_year);
$n_year = mktime(0, 0, 0, $start_month+12, date("d"), $start_year);
$previous_month = date("m", $lastmonth);
$previous_year = date("Y", $lastmonth);
$next_month = date("m",$nextmonth);
$next_year = date("Y",$nextmonth);
$n_year = date("Y",$n_year);
$now = mktime(0, 0, 0, $start_month, 1, $start_year);
$month = date("F",$now);
$year = date("y",$now);
$lastmonths_lastday = getLastDayOfMonth($previous_month, $previous_year);
$currentmonths_lastday = getLastDayOfMonth($start_month, $start_year);
$nextmonths_lastday = getLastDayOfMonth($next_month, $next_year);
$month_start_day_rep = date("D", mktime(0, 0, 0, $start_month, 1, $start_year));
$month_end_day_rep = date("D", mktime(0, 0, 0, $start_month, $currentmonths_lastday, $start_year));
$res = array_search("$month_start_day_rep", $day_rep_name_arr);
$res = $res - 1;
$start_day_lastmonth = $lastmonths_lastday-$res;
$res = array_search("$month_end_day_rep", $day_rep_name_arr);
$nextmonths_neededays = 6 - $res;
for($i=$start_day_lastmonth;$i<=$lastmonths_lastday;$i++)
{
$calendar_dates[] = "$previous_year-$previous_month-$i";
}
for($i=1;$i<=$currentmonths_lastday;$i++)
{
$calendar_dates[] = "$start_year-$start_month-$i";
}
for($i=1;$i<=$nextmonths_neededays;$i++)
{
$calendar_dates[] = "$next_year-$next_month-$i";
}
$tic=0;
$ticker = 0;
while(list($k,$v)=each($calendar_dates))
{
$bits = array();
$bits = explode("-",$v);
$y = $bits[0];
$m = $bits[1];
$d = $bits[2];
if($m == $start_month)
$fontcolor = "#000000";
else
$fontcolor = "#999999";
if($d <= 9)
$formatted_day = "0$d";
else
$formatted_day = $d;
if($m <= 9)
$formatted_month = "$m";
else
$formatted_month = $m;
$tmp = "$y-$formatted_month-$formatted_day";
$events_id = $event_info[$tmp];
$eventdesc = $event_arr[$events_id];
if(date("Y-m-d") == $tmp)
$bg = "bgcolor=#d9f7ff";
else
$bg = "";
if($ticker == 0)
$create_month.= "
";
$create_month.= "| ";
$create_month.= "\n";
$create_month.= " | \n";
if($ticker == 6)
{
$create_month.= "
\n";
$ticker = 0;
}
else {
$ticker++;
}
}
$themonth.= "
 |
 |
|
$month, $year |
";
$themonth.= "";
$themonth.= "";
$themonth.= "| S | ";
$themonth.= "M | ";
$themonth.= "T | ";
$themonth.= "W | ";
$themonth.= "T | ";
$themonth.= "F | ";
$themonth.= "S | ";
$themonth.= "
";
$themonth.= $create_month;
$themonth.= "
";
return $themonth;
}
function return_mon_abree($selected_day = "01",$selected_month,$selected_year,$bgcolormain, $bgcolorsecond, $plannermain_id, $link1,$link2)
{
if(!$selected_month)
{
$select_month = date("m");
$select_year = date("Y");
}
else {
$select_month = $selected_month;
$select_year = $selected_year;
}
$create_month.= "\n";
$tic = 0;
for($i=1;$i<=12;$i++)
{
$str = mktime(0, 0, 0, $i, 1, $select_year);
$nextmonth = date("M",$str);
$formatmonth = date("m",$str);
if($tic == 0)
{
$create_month.="\n";
}
$create_month.="| $nextmonth | \n";
$tic++;
if($tic == 3)
{
$create_month.="
\n";
$tic = 0;
}
}
$create_month.= "
\n";
return $create_month;
}
function return_calendar_text ($str, $num = 15)
{
if(strlen($str) > $num)
{
$str = substr($str,0,$num);
$str = "$str";
}
return $str;
}
function return_calendar_hour($hour,$per="")
{
if($hour < 12)
{
$hour = "$hour";
$temp_per = "am";
}
else {
$temp_per = "pm";
}
$temp_time = $hour;
if($hour == "00")
{
$temp_per = "am";
$temp_time = "12";
}
if($hour > 12)
{
$temp_time = $hour-12;
}
if($per == "per")
return $temp_per;
else
return $temp_time;
}
function return_shorter_copy ($str, $num = 12)
{
if(strlen($str) > $num)
{
$str = substr($str,0,$num);
$str = "$str...";
}
return $str;
}
function return_shorter_text($str,$num = 10)
{
$str = strip_tags($str);
$bits = array();
$bits = explode(" ",$str);
for($i=0;$i<=$num;$i++)
{
$tmp = $bits[$i];
$newstring = "$newstring $tmp";
}
return $newstring;
}
function rotateImage($src, $degrees)
{
$source = imagecreatefromjpeg($src);
$rotate = imagerotate($source, $degrees, 0);
imagejpeg($rotate,$src,100);
}
function format_the_blogdate($date)
{
if($date)
{
$bits = array();
$bits = explode('-',$date);
$y = $bits[0];
$m = $bits[1];
$d = $bits[2];
$bits = array();
$bits = explode(" ",$d);
if($d[1])
$d = $bits[0];
$time = mktime(0, 0, 0, date($m), date($d), date($y));
$date = date("j M", $time);
}
$date = str_replace(" ","
",$date);
return $date;
}
function validEmail($email)
{
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex)
{
$isValid = false;
}
else
{
$domain = substr($email, $atIndex+1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ($localLen < 1 || $localLen > 64)
{
// local part length exceeded
$isValid = false;
}
else if ($domainLen < 1 || $domainLen > 255)
{
// domain part length exceeded
$isValid = false;
}
else if ($local[0] == '.' || $local[$localLen-1] == '.')
{
// local part starts or ends with '.'
$isValid = false;
}
else if (preg_match('/\\.\\./', $local))
{
// local part has two consecutive dots
$isValid = false;
}
else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
{
// character not valid in domain part
$isValid = false;
}
else if (preg_match('/\\.\\./', $domain))
{
// domain part has two consecutive dots
$isValid = false;
}
else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local)))
{
// character not valid in local part unless
// local part is quoted
if (!preg_match('/^"(\\\\"|[^"])+"$/',
str_replace("\\\\","",$local)))
{
$isValid = false;
}
}
if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A")))
{
// domain not found in DNS
$isValid = false;
}
}
return $isValid;
}
?>