<?php
 
function no_album_user($user_id)
{
$sql="select id from myalbum where u_id='$user_id'";
$res=@mysql_query($sql);
$num=@mysql_num_rows($res);
return $num; 
}
 
function show_album_imagea($album,$im,$w,$h)
{
  if(file_exists("images/myalbumphoto/".$album."/".$im) && $im!='' )
	  $temp= "<img src=\"include/phpThumb.php?src=../images/myalbumphoto/".$album."/".$im."&w=$w&h=$h&err=../images/buggd.jpg\"; border='0'  />";
 else
	  $temp ="<img src=\"include/phpThumb.php?src=../images/myalbumphoto/nophoto.jpg&w=$w&h=$h\"; border='0' />";
	return $temp;
}


function show_album_image($album,$im,$w,$h)
{
  if(file_exists("images/myalbumphoto/".$album."/".$im) && $im!='' )
	  $temp= "<img src=\"include/phpThumb.php?src=../images/myalbumphoto/".$album."/".$im."&w=$w&h=$h&err=../images/buggd.jpg\"; border='0' class=\"imgb\" onmouseover=\"this.className='imgbh';\" onmouseout=\"this.className='imgb';\" />";
 else
	  $temp ="<img src=\"include/phpThumb.php?src=../images/myalbumphoto/nophoto.jpg&w=$w&h=$h\"; border='0' />";
	return $temp;
}

function show_album_cover($id,$w,$h)
{
	$query1="select image from album_image where album_id='$id' and def_img='1'";
	$result=mysql_query($query1) or die(mysql_error());	
	$row=mysql_fetch_array($result);
	$im=$row[0];
	
	return show_album_imagea($id,$im,$w,$h);
	
}

function get_album_name($albumid)
{
	$query="select album_name from myalbum where id='$albumid'";
	$res=mysql_query($query);
	$num=mysql_num_rows($res);
	if( $num > 0 )
	  {
	  	$row=mysql_fetch_array($res);
		return $row[0];
	  }
	return " ";
}
function get_noofphotos_inalbum($albumid)
{
	$query="select count(id) from album_image where album_id='$albumid'";
	$res=@mysql_query($query);
	$num=@mysql_num_rows($res);
	
	return $num;
}


class MkDate{
	
		function find_date($opt){	
		if($opt==1){
			$date=date("Y-m-d");
		}else if($opt==2){			
			$mktime=mktime(0,0,0,date("m"),date("d")-1,date("Y"));
			$date=date("Y-m-d",$mktime);
		}else if($opt==3){
			$mktime=mktime(0,0,0,date("m"),date("d")-5,date("Y"));
			$date=date("Y-m-d",$mktime);
		}else if($opt==4){
			$mktime=mktime(0,0,0,date("m"),date("d")-15,date("Y"));
			$date=date("Y-m-d",$mktime);
		}else if($opt==5){
			$mktime=mktime(0,0,0,date("m"),date("d")-30,date("Y"));
			$date=date("Y-m-d",$mktime);
		}else if($opt==6){
			$mktime=mktime(0,0,0,date("m"),date("d"),date("Y")-1);
			$date=date("Y-m-d",$mktime);
		}else if($opt==7){
			$mktime=mktime(0,0,0,date("m"),date("d")-1,date("Y")-2);
			$date=date("Y-m-d",$mktime);
		}		
		return $date;		
	}
	
	// to make date format from database format	
	function mkDateFormat($dateval,$opt){		
		if(!$dateval){return false;}	
			$date_arr=explode('-',$dateval);
			$date_arr[0]=(integer)$date_arr[0];
		if(!$date_arr[0]){return false;}					
			$mktime=mktime(0,0,0,$date_arr[1],$date_arr[2],$date_arr[0]);
		switch($opt){
			case 'M':
				$date=date("M-d",$mktime);
				break;				
			case 'D':
				$date=date("m-D-Y",$mktime);				
				break;
			default:
				$date=date("m-d-Y",$mktime);	
		}
	return $date;
	}
	

	

	
}

?>