<?

################################
##########   SQL NEWS   ########
################################

function getOneNews($news_id){
  
  $query = "select * from $DB.news_db WHERE news_id = '$news_id'";
  return $result = mysql_query($query);
}


function getLastNews($tendu){
        $query = "SELECT * FROM $DB.news_db 
	WHERE news_tendu<='$tendu'
	ORDER BY news_date desc, news_time desc";
        return $result = mysql_query($query);
}


################################
##########  SQL EDITO   ########
################################

function getOneEdito($edito_id){
  
  $query = "select * from $DB.editos_db WHERE edito_id = '$edito_id'";
  return $result = mysql_query($query);
}


function getLastEdito(){
  
	$query = "select * from $DB.editos_db ORDER BY edito_date DESC";
	return $result = mysql_query($query);
}

function getAllEdito(){
  
	$query = "select * from $DB.editos_db ORDER BY edito_date DESC";
	return $result = mysql_query($query);
}

################################
##########  SQL PHOTOS  ########
################################


function getOnePhoto($vid_id){
  
  $query = "select * from $DB.photos_db WHERE photo_id = '$vid_id'";
  return $result = mysql_query($query);
}


function getAllPhotos() {
	$query = "select * from $DB.photos_db ORDER BY photo_date desc, photo_time desc";
        return $result = mysql_query($query);
}


function getLastPhotos(){
        $query = "select * from $DB.photos_db ORDER BY photo_id desc";
        return $result = mysql_query($query);
}

function getPhotosByType( $type){

        $query = "select * from $DB.photos_db 
		WHERE photo_type='$type'
		ORDER BY photo_date desc";
        return $result = mysql_query($query);
}

function getPhotosByYearAndTypeAndTendu($year, $type, $tendu){

	if ($year == 2000) {
        $query = "select * from $DB.photos_db 
		WHERE photo_type='$type' AND photo_tendu<='$tendu' AND YEAR(photo_date)<='$year'
		ORDER BY photo_date desc";
	}
	else {
        $query = "select * from $DB.photos_db 
		WHERE photo_type='$type' AND photo_tendu<='$tendu' AND YEAR(photo_date)='$year'
		ORDER BY photo_date desc";
	}
        return $result = mysql_query($query);
}




function getLastPhotosByTendu($tendu){
	 
	$query = "select * from $DB.photos_db 
		WHERE photo_tendu<='$tendu'
		ORDER BY photo_id desc";
	
        return $result = mysql_query($query);
}


################################
##########  SQL VIDEOS  ########
################################


function getOneVideo($vid_id){
  
  $query = "select * from $DB.videos_db WHERE video_id = '$vid_id'";
  return $result = mysql_query($query);
}


function getAllVideos() {
	$query = "select * from $DB.videos_db ORDER BY video_date desc, video_time desc";
        return $result = mysql_query($query);
}


function getLastVideos(){
        $query = "select * from $DB.videos_db ORDER BY video_id desc";
        return $result = mysql_query($query);
}

function getVideosByType( $type){

        $query = "select * from $DB.videos_db 
		WHERE video_type='$type'
		ORDER BY video_date desc";
        return $result = mysql_query($query);
}

function getVideosByYearAndTypeAndTendu($year, $type, $tendu){

	if ($year == 2000) {
        $query = "select * from $DB.videos_db 
		WHERE video_type='$type' AND video_tendu<='$tendu' AND YEAR(video_date)<='$year'
		ORDER BY video_date desc";
	}
	else {
        $query = "select * from $DB.videos_db 
		WHERE video_type='$type' AND video_tendu<='$tendu' AND YEAR(video_date)='$year'
		ORDER BY video_date desc";
	}
        return $result = mysql_query($query);
}




function getLastVideosByTendu($tendu){
	 
	$query = "select * from $DB.videos_db 
		WHERE video_tendu<='$tendu'
		ORDER BY video_id desc";
	
        return $result = mysql_query($query);
}


##################################
##########  SQL CONTACTS  ########
##################################

function getAssoInfos(){
	$query = "select * from $DB.asso_db";
        return $result = mysql_query($query);
}

function getOneLinkById($ID){
	$query = "select * from $DB.links_db WHERE link_id='$ID'";
        return $result = mysql_query($query);
}

function getAllLinks(){
        $query = "select * from $DB.links_db";
        return $result = mysql_query($query);
}


###############################
##########  SQL USERS  ########
###############################


function getOneUserByName($login){
	$query = "select * from $DB.users_db WHERE user_login='$login'";
        return $result = mysql_query($query);
}

function getOneUserByPseudo($pseudo){
	$query = "select * from $DB.users_db WHERE user_pseudo='$pseudo'";
        return $result = mysql_query($query);
}


function getOneUserById($ID){
	$query = "select * from $DB.users_db WHERE user_id='$ID'";
        return $result = mysql_query($query);
}


function getAllUsers(){
	$query = "select * from $DB.users_db WHERE user_right < 7
	ORDER BY user_right desc";
        return $result = mysql_query($query);
}

function getUsersByStatut($statut){
  $query = "SELECT * FROM $DB.users_db WHERE user_statut='$statut' ORDER BY user_right desc";
  return $result = mysql_query($query);
}

################################
##########  SQL MEMBERS  ########
################################

function getAllMembers(){
	$query = "select * from $DB.users_db WHERE user_right >= 7";
        return $result = mysql_query($query);
}

function getAnExistingStatut($statut){
	$query = "select * from $DB.users_db WHERE user_statut = '$statut'";
        return $result = mysql_query($query);
}


####################################
##########   SQL Blacklist  ########
####################################

function getOneBlacklistById($id){
	$query = "select * from $DB.blacklist_db WHERE blacklist_id='$id'";
        return $result = mysql_query($query);
}

function getOneBlacklistByLogin($login){
	$query = "select * from $DB.blacklist_db WHERE blacklist_login='$login'";
        return $result = mysql_query($query);
}


function getAllBlacklist(){
	$query = "select * from $DB.blacklist_db";
        return $result = mysql_query($query);
}

function getAllBlacksite(){
	$query = "select * from $DB.blacksites_db";
        return $result = mysql_query($query);
}

function getOneBlacksiteById($id){
	$query = "select * from $DB.blacksites_db WHERE blacksite_id='$id'";
        return $result = mysql_query($query);
}


?>