// -*- C++ -*-
/* ******************************************************************** **
** Copyright (C) 1995-2000 Michael Oertel **
** Copyright (C) 2000- PHPOpenChat Development Team **
** http://www.ortelius.de/phpopenchat/ **
** **
** This program is free software. You can redistribute it and/or modify **
** it under the terms of the PHPOpenChat License Version 1.0 **
** **
** This program is distributed in the hope that it will be useful, **
** but WITHOUT ANY WARRANTY, without even the implied warranty of **
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **
** **
** You should have received a copy of the PHPOpenChat License **
** along with this program. **
** ******************************************************************** */
/**
* Include default values
*/
include "defaults_inc.php";
//start session
if($ENABLE_SESSION){
@session_start();
}
/**
* Check for access permissions of this page
*
* compare the given and the calculated checksum,
* if they don't match the user has no permissions
* and the script ends by printing a status header of 204
* (no content change by client browser)
*/
if(!check_permissions($nick,$pruef)){
//the user has no access permission for this page
header("Status: 204 OK\r\n");//browser don't refresh his content
exit;
}
/**
* Open a database connection
*
* This include returns a database identifier '$db_handle'
* used by some database querys.
*/
include ("connect_db_inc.php");
$db_handle=connect_db($DATABASEHOST,$DATABASEUSER,$DATABASEPASSWD);
if(!$db_handle){
exit;
}
$permissions = '';
$show_search_result .= $permissions;
if($action=='list' || !$friendsearch){
$result = mysql_query("SELECT * FROM chat_notify where Nick='$nick' order by Friend",$db_handle);
$num=mysql_num_rows($result);
$search_for_chatter = $MSG_FRIENDS_ADD_TITLE.': ';
$search_for_chatter .= nl.''.nl.''.nl.'';
if($num > 15){
$count_left = round($num / 2)-1;
$i=0;
while($i<=$count_left && $num>$i){
$friend=mysql_result($result,$i,"Friend");
$lastlogin = mysql_query("SELECT DATE_FORMAT(Zeit, '%d.%m.%Y - %H:%i') as Zeit FROM chat_data where Nick='$friend'",$db_handle);
$row_login = mysqli_fetch_object($lastlogin);
$showtime = $row_login->Zeit;
$table_left .= '
';
$online_status = mysql_query("SELECT Nick FROM chat where Nick='$friend'",$db_handle);
if(mysql_num_rows($online_status)>0){
$select_of_friends .= '
Online
';
}else{
$select_of_friends .= '
Offline
';
}
$select_of_friends .= '
'.$showtime.'
';
if($ENABLE_SESSION){
$select_of_friends .= '
';
$select_of_friends .= '
';
}else{
$select_of_friends .= '
';
$select_of_friends .= '
';
}
}
$select_of_friends .= '
';
}
unset($friend);
mysql_free_result($result);
}
if($action=='delete'){
$friend_to_delete = $_GET['friend'];
$result = mysql_query("delete from chat_notify where Friend='$friend_to_delete' && Nick='$nick'",$db_handle);
header("location: friends.$FILE_EXTENSION?action=list&nick=".rawurlencode($nick)."&pruef=$pruef&".SID);
}
if($friendsearch){
$friendsearch=addslashes($friendsearch);
$result = mysql_query("select Nick from chat_data where Nick like '$friendsearch%' AND Nick !='$nick' order by Nick",$db_handle);
if(mysql_num_rows($result)>0){
$show_search_result = $CHOOSE_NICK.':