<?php
function generateCode($size){
	$str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	$shuffled_str = str_shuffle($str);
	return substr($shuffled_str, 0, $size);
}
function isEmail($email) { // Email address verification, do not edit.

return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email));
		
}
function checkadminlogin(){
	if (!isset($_SESSION['admin']['name']) ) {
		header('location:login.php');
		exit;
	}
}

function array_count_this_value($array, $value) { 
  $values=array_count_values($array); 
  return $values[$value]; 
}  

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

function curServer() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"];
 }
 return $pageURL;
}

function formatMoney($num){
    $explrestunits = "" ;
    if(strlen($num)>3){
        $lastthree = substr($num, strlen($num)-3, strlen($num));
        $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits
        $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping.
        $expunit = str_split($restunits, 2);
        for($i=0; $i<sizeof($expunit); $i++){
            // creates each of the 2's group and adds a comma to the end
            if($i==0)
            {
                $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer
            }else{
                $explrestunits .= $expunit[$i].",";
            }
        }
        $thecash = $explrestunits.$lastthree;
    } else {
        $thecash = $num;
    }
    return $thecash; // writes the final format where $currency is the currency symbol.
} 

function curPageName() {
 return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}
function datef($dat){
	$da=explode("-",$dat);
	if($da[1]=="JAN"){
		$mon=01;
		}
		if($da[1]=="FEB"){
		$mon=02;
		}
		if($da[1]=="MAR"){
		$mon=03;
		}
		if($da[1]=="APR"){
		$mon=04;
		}
		if($da[1]=="MAY"){
		$mon=05;
		}
		if($da[1]=="JUN"){
		$mon=06;
		}
		if($da[1]=="JUL"){
		$mon=07;
		}
		if($da[1]=="AUG"){
		$mon=08;
		}
		if($da[1]=="SEP"){
		$mon=09;
		}
		if($da[1]=="OCT"){
		$mon=10;
		}
		if($da[1]=="NOV"){
		$mon=11;
		}
		if($da[1]=="DEC"){
		$mon=12;
		}
		$start=$da[2]."-".$mon."-".$da[0];
		return $start;
	}
	function times($dat){
	$da=explode("-",$dat);
	if($da[1]=="JAN"){
		$mon=01;
		}
		if($da[1]=="FEB"){
		$mon=02;
		}
		if($da[1]=="MAR"){
		$mon=03;
		}
		if($da[1]=="APR"){
		$mon=04;
		}
		if($da[1]=="MAY"){
		$mon=05;
		}
		if($da[1]=="JUN"){
		$mon=06;
		}
		if($da[1]=="JUL"){
		$mon=07;
		}
		if($da[1]=="AUG"){
		$mon=08;
		}
		if($da[1]=="SEP"){
		$mon=09;
		}
		if($da[1]=="OCT"){
		$mon=10;
		}
		if($da[1]=="NOV"){
		$mon=11;
		}
		if($da[1]=="DEC"){
		$mon=12;
		}
		$start=mktime(0, 0, 0, $mon, $da[0], $da[2]);;
		return $start;
	}
function flo($inte){
	$j=explode(".",$inte);
$d=$j[0];
if(isset($j[1])){
$d.= ".".substr($j[1],0,2);
}
return $d; 
	
	}	
function Pages($tbl_name,$limit,$cond,$path)
{
	$query = "SELECT COUNT(*) as num FROM $tbl_name where $cond";
	$row = mysql_fetch_array(mysql_query($query));
	$total_pages = $row['num'];

	$adjacents = "2";

	$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
	$page = ($page == 0 ? 1 : $page);

	if($page)
	$start = ($page - 1) * $limit;
	else
	$start = 0;

$sql = "SELECT id FROM $tbl_name where $cond LIMIT $start, $limit";
$result = mysql_query($sql);

	$prev = $page - 1;
	$next = $page + 1;
	$lastpage = ceil($total_pages/$limit);
	$lpm1 = $lastpage - 1;

	$pagination = "";
if($lastpage > 1)
{   
	$pagination .= "<ul class='pagination'>";
if ($page > 1)
	$pagination.= "<li class='prev'><a href='".$path."page=$prev' class='click' >&laquo; Previous</a></li>";
else
	$pagination.= "<li class='prev disabled'><a>&laquo; Previous</a></li>";   

if ($lastpage < 7 + ($adjacents * 2))
{   
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
	$pagination.= "<li class='active'><a>$counter</a></li>";
else
	$pagination.= "<li><a href='".$path."page=$counter'>$counter</a></li>";                   
}
}
elseif($lastpage > 5 + ($adjacents * 2))
{
if($page < 1 + ($adjacents * 2))       
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
	$pagination.= "<li class='active'><a>$counter</a></li>";
else
	$pagination.= "<li><a href='".$path."page=$counter'>$counter</a></li>";                   
}
	$pagination.= "<li>...</li>";
	$pagination.= "<li><a href='".$path."page=$lpm1'>$lpm1</a></li>";
	$pagination.= "<li><a href='".$path."page=$lastpage'>$lastpage</a></li>";       
}
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
	$pagination.= "<li><a href='".$path."page=1'>1</a></li>";
	$pagination.= "<li><a href='".$path."page=2'>2</a></li>";
	$pagination.= "<li>...</li>";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
	$pagination.= "<li class='active'><a>$counter</a></li>";
else
	$pagination.= "<li><a href='".$path."page=$counter'>$counter</a></li>";                   
}
	$pagination.= "<li>..</li>";
	$pagination.= "<li><a href='".$path."page=$lpm1'>$lpm1</a></li>";
	$pagination.= "<li><a href='".$path."page=$lastpage'>$lastpage</a></li>";       
}
else
{
	$pagination.= "<li><a href='".$path."page=1'>1</a></li>";
	$pagination.= "<li><a href='".$path."page=2'>2</a></li>";
	$pagination.= "<li>..</li>";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
	$pagination.= "<li class='active'><a>$counter</a></li>";
else
	$pagination.= "<li><a href='".$path."page=$counter'>$counter</a></li>";                   
}
}
}

if ($page < $counter - 1)
	$pagination.= "<li><a href='".$path."page=$next' class='click'>Next &raquo;</a></li>";
else
	$pagination.= "<li class='next disabled'><a>Next &raquo;</a></li>";
	$pagination.= "</ul>\n";       
}


return $pagination;
}
function paginateexte($start, $limit, $total, $otherParams='') {
	
	if ($otherParams!=''){
		$otherParams = $otherParams;
	}
	$allPages	 = ceil($total/$limit);
	$currentPage = floor($start/$limit) + 1;
	$pagination  = "";
	if ($allPages>10) {
		$maxPages = ($allPages>9) ? 9 : $allPages;

		if ($allPages>9) {
			if ($currentPage>=1&&$currentPage<=$allPages) {
				$pagination .= ($currentPage>4) ? "<td> ... </td>" : " ";
				$minPages    = ($currentPage>4) ? $currentPage : 5;
				$maxPages    = ($currentPage<$allPages-4) ? $currentPage : $allPages - 4;

				for($i = $minPages-4; $i<$maxPages+5; $i++) {
					$pagination .= ($i == $currentPage) ?$i : "<a href=\"".$otherParams."&start=".(($i-1)*$limit)."\">".$i."</a>";
				}
				$pagination .= ($currentPage<$allPages-4) ? "<td style='width:30px;'> ...</td> " : " ";
			} else {
				$pagination .= "<td style='width:30px;'>...</td> ";
			}
		}
	} else {
		for($i=1; $i<$allPages+1; $i++) {
			$pagination .= ($i==$currentPage) ?"<a class='number current'>".$i."</a>" : "<a class='number'  href=\"" . $otherParams."&start=" . (($i-1)*$limit)."\">" . $i . "</a>";
		}
	}

	 if ($currentPage>1){ 
		$pagination = "<a   href=\"" . $otherParams . "&start=0 \"><strong>&laquo;</strong> First</a><a  href=\"". $otherParams . "&start=" . (($currentPage-2)*$limit)."\"><strong >&laquo;</strong> Previous</a>" . $pagination;
	
	 }
	 if ($currentPage<$allPages){
		
		$pagination .= "<a  href=\"". $otherParams . "&start=" . ($currentPage*$limit)."\">Next <strong>&raquo;</strong></a><a  href=\"". $otherParams . "&start=" . (($allPages-1)*$limit)."\">Last <strong>&raquo;</strong></a>";
	 }
     echo $pagination;
	/*echo "<table align=\"center\" class=\"boxPagination\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr style='width:300px'>".$pagination."</tr></table>";*/
}
function reduceImage($img, $imgPath, $suffix, $quality)
{
    // Open the original image.
    $original = imagecreatefromjpeg("$imgPath/$img") or $original = imagecreatefrompng("$imgPath/$img") or $original = imagecreatefromgif("$imgPath/$img") or die("Error Opening original (<em>$imgPath/$img</em>)");
    list($width, $height, $type, $attr) = getimagesize("$imgPath/$img");
 
    // Resample the image.
    $tempImg = imagecreatetruecolor($width, $height) or die("Cant create temp image");
    imagecopyresized($tempImg, $original, 0, 0, 0, 0, $width, $height, $width, $height) or die("Cant resize copy");
 
    // Create the new file name.
    $newNameE = explode(".", $img);
    $newName = ''. $newNameE[0] .''. $suffix .'.'. $newNameE[1] .'';
 
    // Save the image.
    imagejpeg($tempImg, "$imgPath/$newName", $quality) or imagepng($tempImg, "$imgPath/$newName", $quality) or imagegif($tempImg, "$imgPath/$newName", $quality) or die("Cant save image");
 
    // Clean up.
    imagedestroy($original);
    imagedestroy($tempImg);
    return true;
}
function xss_clean($data)
{
// Fix &entity\n;
$data = str_replace(array('&amp;','&lt;','&gt;'), array('&amp;amp;','&amp;lt;','&amp;gt;'), $data);
$data = preg_replace('/(&#*\w+)[\x00-\x20]+;/u', '$1;', $data);
$data = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1;', $data);
$data = html_entity_decode($data, ENT_COMPAT, 'UTF-8');
 
// Remove any attribute starting with "on" or xmlns
$data = preg_replace('#(<[^>]+?[\x00-\x20"\'])(?:on|xmlns)[^>]*+>#iu', '$1>', $data);
 
// Remove javascript: and vbscript: protocols
$data = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([`\'"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu', '$1=$2nojavascript...', $data);
$data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu', '$1=$2novbscript...', $data);
$data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#u', '$1=$2nomozbinding...', $data);
 
// Only works in IE: <span style="width: expression(alert('Ping!'));"></span>
$data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?expression[\x00-\x20]*\([^>]*+>#i', '$1>', $data);
$data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?behaviour[\x00-\x20]*\([^>]*+>#i', '$1>', $data);
$data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*+>#iu', '$1>', $data);
 
// Remove namespaced elements (we do not need them)
$data = preg_replace('#</*\w+:\w[^>]*+>#i', '', $data);
 
do
{
        // Remove really unwanted tags
        $old_data = $data;
        $data = preg_replace('#</*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#i', '', $data);
}
while ($old_data !== $data);
 
// we are done...
return $data;
}

function calender($month,$year){
	
	 echo 
                '<table width="98%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#ccc" class="events_calendar_table">
                  <tr>
                    <th width="14%" height="30" bgcolor="#B86102"  style="text-align:center; padding-top:13px;"> <span class="style4">Monday</span> </th>
                    <th width="14%" height="30" bgcolor="#B86102" style="text-align:center; padding-top:13px;"> <span class="style4">Tuesday</span> </th>
                    <th width="14%" height="30" bgcolor="#B86102" style="text-align:center; padding-top:13px;"> <span class="style4">Wednesday</span> </th>
                    <th width="14%" height="30" bgcolor="#B86102" style="text-align:center; padding-top:13px;"> <span class="style4">Thursday</span> </th>
                    <th width="14%" height="30" bgcolor="#B86102" style="text-align:center; padding-top:13px;"> <span class="style4">Friday</span> </th>
                    <th width="14%" height="30" bgcolor="#d38229" style="text-align:center; padding-top:13px;"><span class="style6">Saturday</span></th>
                    <th width="14%" height="30" bgcolor="#b6742d" style="text-align:center; padding-top:13px;"> <span class="style6">Sunday</span></th>
                  </tr>';
              
         $num = cal_days_in_month(CAL_GREGORIAN, $month,$year); // 31
		 $i=0;
		 $j=1;
		 
		  $first = date('N', mktime(0, 0, 0, $month, 1, $year));
		  
		  $pday=date('j');
		  $pmon=date('n');
		  $pyear=date('Y');
while($i<=$num){
	if($i!=0 && strlen($i)==1){
		$n="0".$i;
		}else{
			$n=$i;
			}
			if(strlen($month)==1){
		$m="0".$month;
		}else{
			$m=$month;
			}
			
$da= $m."/".$n."/".$year;
if($j%7==1){
	echo " <tr>";
}

               echo '<td  style="text-align:center; padding:13px;" ';
					if($month==$pmon && $year==$pyear && $pday==$i){
						echo 'style="color:#F00; background-color:#68913C" ';
						
					} 
					if($j%7==6 || $j%7==0){ 
					echo 'bgcolor="#C6F691"';
					} 
					echo 'class="graphic_events_td"><a href="#" class="datea"';
					if($month==$pmon && $year==$pyear && $pday==$i){
						echo 'style="color:#B71B1B; font-weight:bold; text-decoration:underline;"';
						
					}else{
						echo 'style="color:#000;"';
						}
					echo '><div class="day_calendar">'; 
				echo '<span ';
					echo ">";
					if($i==0){echo "&nbsp;";}
					else{
						if(strlen($i)==1){
							$i="0".$i;
							}
						echo $i;} 
					
					echo '</span>';
					
					$dd=$m."/".$n."/".$year;
					$sel="select * from admin_events where date='$dd' order by time";
					$res=executeQuery($sel);
					while($rec=getAssoc($res)){
						
						echo '<br><span style=" text-align:center;font-size:10px; color:#00255D; font-weight:bold; ">'.$rec['time']."&nbsp;&nbsp;".$rec['name'].'</span>';
						}
					echo '</div></a></td>';
                    
              
if($j%7==0){
	echo " </tr>";
}
                   $j++;
				   if($j>=$first){
				   $i++;}}
          /*while($j%7){
			  echo "</td>";
			  $j++;}  */  
			  if($j%7!=0)  {
			 $c=7-(($j%7)-1); 
			 if($c!=7){
				 while($c!=0){
					 echo "<td></td>";
					 $c--;}
				 } }
               echo '</table>';
	
	
	
	}

function createthumb($name,$filename,$new_w,$new_h)
{
$system=explode(".",$name);
if (preg_match("/jpg|JPG|jpeg|JPEG/",$system[3])){$src_img=imagecreatefromjpeg($name);}

elseif (preg_match("/png|PNG/",$system[3])){$src_img=imagecreatefrompng($name);}

elseif (preg_match("/gif|GIF/",$system[3])){$src_img=imagecreatefromgif($name);}


$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) 
{
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) 
{
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) 
{
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 
if (preg_match("/png/",$system[1]))
{
imagepng($dst_img,$filename); 
} 
elseif (preg_match("/gif/",$system[1]))
{
imagegif($dst_img,$filename); 
}
else{
imagejpeg($dst_img,$filename); 
}

imagedestroy($dst_img); 
imagedestroy($src_img); 
}

function img_resize($target, $newcopy, $w, $h, $ext) {
    list($w_orig, $h_orig) = getimagesize($target);
    $scale_ratio = $w_orig / $h_orig;
    if (($w / $h) > $scale_ratio) {
           $w = $h * $scale_ratio;
    } else {
           $h = $w / $scale_ratio;
    }
    $img = "";
    $ext = strtolower($ext);
    if ($ext == "gif"){ 
    $img = imagecreatefromgif($target);
    } else if($ext =="png"){ 
    $img = imagecreatefrompng($target);
    } else { 
    $img = imagecreatefromjpeg($target);
    }
    $tci = imagecreatetruecolor($w, $h);
    // imagecopyresampled(dst_img, src_img, dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h)
    imagecopyresampled($tci, $img, 0, 0, 0, 0, $w, $h, $w_orig, $h_orig);
    if ($ext == "gif"){ 
        imagegif($tci, $newcopy);
    } else if($ext =="png"){ 
        imagepng($tci, $newcopy);
    } else { 
        imagejpeg($tci, $newcopy, 84);
    }
}

function img_thumb($target, $newcopy, $w, $h, $ext) {
    list($w_orig, $h_orig) = getimagesize($target);
    $src_x = ($w_orig / 2) - ($w / 2);
    $src_y = ($h_orig / 2) - ($h / 2);
    $ext = strtolower($ext);
    $img = "";
    if ($ext == "gif"){ 
    $img = imagecreatefromgif($target);
    } else if($ext =="png"){ 
    $img = imagecreatefrompng($target);
    } else { 
    $img = imagecreatefromjpeg($target);
    }
    $tci = imagecreatetruecolor($w, $h);
    imagecopyresampled($tci, $img, 0, 0, $src_x, $src_y, $w, $h, $w, $h);
    if ($ext == "gif"){ 
        imagegif($tci, $newcopy);
    } else if($ext =="png"){ 
        imagepng($tci, $newcopy);
    } else { 
        imagejpeg($tci, $newcopy, 84);
    }
}

function watermark_image($oldimage_name, $new_image_name){
    global $image_path;
    list($owidth,$oheight) = getimagesize($oldimage_name);
    $width =$owidth; $height = $oheight;    
    $im = imagecreatetruecolor($width, $height);
    $img_src = imagecreatefromjpeg($oldimage_name);
    imagecopyresampled($im, $img_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight);
    $watermark = imagecreatefrompng($image_path);
    list($w_width, $w_height) = getimagesize($image_path);        
    $pos_x = $width/2; 
    $pos_y = $height/2;
	//for Bottom Cornor
	//$pos_x = $width-$w_width; 
    //$pos_y = $height-$w_height;
    imagecopy($im, $watermark, $pos_x, $pos_y, 0, 0, $w_width, $w_height);
    imagejpeg($im, $new_image_name, 100);
    imagedestroy($im);
    unlink($oldimage_name);
    return true;
	
	//$image_path = "images/watermark.png";
	//watermark_image($old_name, $new_name);
}


function watermark_text($oldimage_name, $new_image_name){
    global $font_path, $font_size, $water_mark_text_1, $water_mark_text_2;
    list($owidth,$oheight) = getimagesize($oldimage_name);
    $width = $height = 300;    
    $image = imagecreatetruecolor($width, $height);
    $image_src = imagecreatefromjpeg($oldimage_name);
    imagecopyresampled($image, $image_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight);
   // $black = imagecolorallocate($image, 0, 0, 0);
    $blue = imagecolorallocate($image, 79, 166, 185);
   // imagettftext($image, $font_size, 0, 30, 190, $black, $font_path, $water_mark_text_1);
    imagettftext($image, $font_size, 0, 68, 190, $blue, $font_path, $water_mark_text_2);
    imagejpeg($image, $new_image_name, 100);
    imagedestroy($image);
    unlink($oldimage_name);
    return true;
	
	//$font_path = "images/GILSANUB.TTF";
	//$font_size = 30; // in pixcels
	//$water_mark_text_2 = "Lawa";

	// watermark_text($old_name, $new_name);
}
?>