connect(); // Upload Images Function function upload_image($file, $folder, $file_name){ $uploaded_image_path = ""; if($file['name'] != ""){ if (($file['type'] == "image/gif") || ($file['type'] == "image/jpg") || ($file['type'] == "image/pjpeg") || ($file['type'] == "image/jpeg")){ $ext = strtolower(substr($file['name'], -3, 3)); $uploaded_image_path = $folder . $file_name.".". $ext; copy($file['tmp_name'], "../" . $uploaded_image_path) or die("Could not upload the image"); } } return $uploaded_image_path; } //end of upload image function //######################################################### // Delete File function delFile($file){ if( is_file($file) and file_exists($file) ){ unlink($file); return true; } else return false; } //end of delete File function //######################################################### function validImage($file_path){ if(is_file($file_path) and file_exists($file_path)) return true; else return false; } function showImage($image, $width, $height, $alt="", $title="") { if(validImage($image)){ if($width=="") $w = ""; else $w = "width=$width"; if($height=="") $h = ""; else $h = "height=$height"; $alt = ($alt=="")?"":" alt='".$alt."'"; $title = ($title=="")?"":" title='".$title."'"; echo ""; } else echo ""; } // end of showimage //######################################################### function showLink($value,$path) { echo "$value"; } //######################################################### function myDate($date) { if($date != NULL or $date != '') return date("d-m-Y",strtotime($date)); } //######################################################### function sendmail($mailTo, $mailFrom, $mailFromName, $mailSubject, $mailMessage ) { $mailCharset = "charset=iso-8859-1"; // must be accurate (e.g. "Windows - 1252" is invalid) $headers = "From: $mailFromName <$mailFrom>\r\n"; $headers .= "Content-type: text/html; charset=$mailCharset\r\n"; if(mail($mailTo, $mailSubject, stripslashes($mailMessage), $headers)) return true; }//End of function sendMail // Function that returns the value of next or previous month function cal_month($year, $month, $move){ switch($move){ case 'n'; if($month==12){ $month=1; $year++; } else{ $month++; } break; case 'p'; if($month==1) { $month=12; $year--; } else { $month--; } break; } return $year.'-'.$month.'-01'; }// End of Function //############################################################ function micro_time($start_time) { list($usec, $sec) = explode(" ", microtime()); $micro_time = ((float)$usec + (float)$sec); if ($start_time == 0) { return $micro_time; } else { $total_time = $micro_time - $start_time; return $total_time; } } //############################################################# function pagination($total_pages, $on_page, $base_url){ $base_url .= (strpos($base_url, '?') === false) ? '?' : '&'; $seperator = '  '; if ($total_pages <2 ) { return false; } $page_string=''; } function convertDate($date) { $getDate=explode(" ", $date); $breakDate=explode("-",$getDate[0]); $newDate=$breakDate[2]."-".$breakDate[1]."-".$breakDate[0]; return $newDate; } function imageResize($width, $height, $target1, $target2) { $percentage1 = ($target1 / $width); $percentage2 = ($target2 / $height); $width = round($width * $percentage1); $height = round($height * $percentage2); echo "width=\"$width\" height=\"$height\""; } function showImg($image) { $imgExt=array('jpg','bmp','png','gif'); if (strpos($image,$imgExt[0]) || strpos($image,$imgExt[1]) || strpos($image,$imgExt[2]) || strpos($image,$imgExt[3])) { $img=""; }else{ $img=""; } return $img; } President of Pakistan