// -*- 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;
}
if($ENABLE_SESSION){
$permissions = '';
}else{
$permissions = '
';
}
//Function to input a text line in the database
include "write_line_inc.php";
/**
* Deletes a chatter from group
*
* @param string $nick
* @param string $chatter_to_del
* @param string $group
* @global $db_handle
* @author Michael Oertel
*/
function del_chatter($nick,$chatter_to_del,$group){
global $db_handle;
//delete a chatter from the group of ignored chatter
if($group=="ignored_chatter"){
//get all of the already ignored chatter of nickname
$result=mysql_query("SELECT Ignor FROM chat WHERE Nick = '$nick'",$db_handle);
if(mysql_num_rows($result)==1){
/**
* Ignored chatter
*
* contains a list of ignored chatter seperated by "|"
*
* @var string $ignored_chatter
*/
$ignored_chatter = mysql_result($result,0,"Ignor");
}
mysql_free_result($result);
$ignored_chatter = str_replace("|$chatter_to_del|","|",$ignored_chatter);
if($ignored_chatter=="|"){
$result=mysql_query("UPDATE chat SET Ignor='' WHERE Nick='$nick'",$db_handle);
}else{
$result=mysql_query("UPDATE chat SET Ignor='$ignored_chatter' WHERE Nick='$nick'",$db_handle);
}
return TRUE;
}
return FALSE;
}
/**
* Adds a chatter to group
*
* @param string $nick
* @param string $chatter_to_add
* @param string $group
* @global $db_handle
* @author Michael Oertel
*/
function add_chatter($nick,$chatter_to_add,$group){
global $db_handle;
//add a chatter from the group of ignored chatter
if($group=="ignored_chatter"){
//get all of the already ignored chatter of nickname
$result=mysql_query("SELECT Ignor FROM chat WHERE Nick = '$nick'",$db_handle);
if(mysql_num_rows($result)==1){
/**
* Ignored chatter
*
* contains a list of ignored chatter seperated by "|"
*
* @var string $ignored_chatter
*/
$ignored_chatter = mysql_result($result,0,"Ignor");
}
mysql_free_result($result);
if($ignored_chatter==""){
$ignored_chatter="|";
}
$ignored_chatter = "|$chatter_to_add$ignored_chatter";
$result=mysql_query("UPDATE chat SET Ignor='$ignored_chatter' WHERE Nick='$nick'",$db_handle);
return TRUE;
}
return FALSE;
}
//this makes this all working together with the context menu
if($_GET['silent']){
$result = mysql_query("SELECT count(*) AS count FROM chat WHERE Ignor LIKE '%|$chatter|%'",$db_handle);
$s_result = mysql_result($result,0,'count');
if($s_result){ //chatter war ignoriert und wird nicht mehr ignoriert
$del = '-->';
$ignored_chatter = $_GET['chatter'];
echo '';
}else{//chatter wird ignoriert
$add ='<--';
$chatter = $_GET['chatter'];
echo '';
}
}
if(($del)&&($ignored_chatter)){
// the form button "-- >>" is pressed and a chatter was selected
// the chatter is no longer ignored
if(!del_chatter($nick,$ignored_chatter,"ignored_chatter")){
echo "Error while deleting a chatter from the group of ignored users.";
exit;
}
}
if(($add)&&($chatter)){
// the form button "<< --" is pressed and a chatter to ignore was selected
// the chatter will be ignored
if(!add_chatter($nick,$chatter,"ignored_chatter")){
echo "Error while adding a chatter to the group of ignored users.";
exit;
}
/**
* Examination, how often the chatter was ignored already by other users
*
* If the ignored chatter ignored by more than $KICK_COUNT chatters,
* the chatter will be kicked out of the chat.
*
* @var integer $ignore_count
*/
$ignore_count=mysql_result(mysql_query("SELECT count(*) AS count FROM chat WHERE Ignor LIKE '%|$chatter|%'",$db_handle),0,"count");
$paten_check = mysql_result(mysql_query("select count(*) as count from paten where nick like '$chatter'"),0,'count');
if($ignore_count>=$KICK_COUNT && !$paten_check){
$result=mysql_query("UPDATE chat SET User_busy='2' WHERE Nick='$chatter'",$db_handle);
$channel=mysql_result(mysql_query("SELECT Raum FROM chat WHERE Nick='$chatter'",$db_handle),0,"Raum");
schreib_zeile("$MODERATOR_NAME:$chatter$KICKED.",$channel);
}
$ignore_hint = " $MSG_IGNORE_NUMBER: $ignore_count";
$ignore_hint .= " $MSG_IGNORE_ALSO: ".$KICK_COUNT."";
}
$result=mysql_query("SELECT Ignor FROM chat WHERE Nick = '$nick'",$db_handle);
if(mysql_num_rows($result)==1){
$kick = mysql_result($result,0,"Ignor");
}
$option_value = explode("|",$kick);
$select_of_ignored_chatter = "\n\t\t\t\t\t";
//all of not kicked chatter
$nick_result=mysql_query("SELECT Nick FROM chat WHERE Nick <> '$nick' ORDER BY Nick",$db_handle);
$select_of_all_chatters = "\n\t\t\t\t\t";
$result=mysql_query("SELECT Allow FROM channels WHERE Name = '$nick'",$db_handle);
if(mysql_num_rows($result)>0){$kick = mysql_result($result,0,"Allow");}
$result=mysql_query("SELECT Allow FROM channels WHERE Name='$nick'",$db_handle);
if(mysql_num_rows($result)>0){
$tmp=mysql_result($result,0,"Allow");
}
mysql_free_result($result);
mysql_close($db_handle);
if(!$_GET['silent'])
include("ignore_tpl.php");
?>