[REF] [Fixed issue] "You've disabled alerts."

Think you've found a bug in Chatspot? Post it here and it will be looked into. Security issues should be PM'ed to Demerzel rather than posted here.

Moderator: Demerzel

[REF] [Fixed issue] "You've disabled alerts."

Postby Demerzel on Sun Dec 04, 2005 10:48 pm

An error message that i dont recognise and cant find. look into asap...

Can people please test this and report back to me, if you want a working options page

Code: Select all
<?php

/***************************************************************************
*                     chatspot_options.php
*                     -------------------
*      last updated      : July 3rd, 2005 
*      email             : kaniaz =at= ggmail.com (remove extra g),
*                          techboy =at= ffsmail.net (remove extra f).
*
***************************************************************************/

/***************************************************************************
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation; either version 2 of the License, or
*   (at your option) any later version.
*
***************************************************************************/

/* **[DESCRIPTION]*********************************************************************************************************
      - handles alerts
      - handles ignores
   ************************************************************************************************************************ */

define( 'CHATSPOT', true );
define( 'IN_PHPBB', true );
$phpbb_root_path = './../';

include_once( $phpbb_root_path . 'extension.inc' );
include_once( $phpbb_root_path . 'chatspot/chatspot_config.' . $phpEx );

error_reporting  (E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables
set_magic_quotes_runtime(0); // Disable magic_quotes_runtime

//Start session management
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//End session management

if( !$userdata[ 'session_logged_in' ] ) {
?>
<link rel="stylesheet" href="<?php echo $chatspot_config['stylesheet']?>" type="text/css">
<?php
chatspot_toast("Access Denied", "Access to this resource has been disallowed.<br/><br/>Log in first.", "red");
die();
}

if (empty($_GET))
{
?>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $chatspot_config[ 'charset' ]; ?>"/>

<link rel="stylesheet" href="<?php echo $chatspot_config['stylesheet']?>" type="text/css"/>
<link rel="stylesheet" href="style/moderate.css" type="text/css"/>
<title>options</title>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#006699">
<h1 style="text-align:center;">phpBBChatSpot Options</h1>

<b>Choose a mode:</b><br/><br/>
<a href="?mode=alert">Customize alerts</a><br/>
<a href="?mode=ignore">Customize ignores</a>

<p/>

<a href="javascript:void(0);" onClick="javascript:window.parent.scripts.restore_frames(); return false;" style="text-align:center; font-weight:strong; margin: 0 auto;">Return to chat</a>

</body>
</html>
<?php
}
else
{
if ($_GET['mode'] == "alert")


if (!empty($_POST)) {

$userdata['chatspot_alert'] = "";

$sql="UPDATE {$table_prefix}users SET chatspot_alert='";

$names=$_POST['itemlist'];

if (!isset($_POST['1'])) {
$sql .= "n' WHERE user_id='{$userdata['user_id']}';";
$db->sql_query($sql);
}

else {

if ($_POST['3']==2) {

if (count($names)==0)
die("You didn't specify anybody!");

foreach ($names as $name) {
$name=addslashes($name);

$id_sql="SELECT user_id FROM {$table_prefix}users WHERE username='$name'";

if (!$result = $db->sql_query($id_sql)) {
$id=0;
}

else {

if (!$row = $db->sql_fetchrow($result)) {
$id=0;
}

else {
$id=$row['user_id'];
}

}

if ($id==0) {
?>
<link rel="stylesheet" href="<?php echo $chatspot_config['stylesheet']?>" type="text/css"/>
<?php
chatspot_toast("Chatspot Error", "User $name not found.", "red");
die();
}

$sql .= $id . ",";
$added = $id . ",";
$userdata['chatspot_alert'] .= $added;

}

$sql .= "' WHERE user_id='{$userdata['user_id']}';";

$db->sql_query($sql);

}

else if ($_POST['3']==1) {
$sql = "UPDATE {$table_prefix}users SET chatspot_alert='e' WHERE user_id='{$userdata['user_id']}'";
$db->sql_query($sql);
$userdata['chatspot_alert'] = "e";
}



}

?>
<script language="javascript">
window.parent.scripts.restore_frames();
</script>
<?php
}

?>

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $chatspot_config[ 'charset' ]; ?>"/>

<link rel="stylesheet" href="<?php echo $chatspot_config['stylesheet']?>" type="text/css"/>
<link rel="stylesheet" href="style/moderate.css" type="text/css"/>
<title>Chatspot Micromanagement</title>
   
<script language="Javascript">
//Portions of this code adapted from the micromanagement file, and the wordpress plugin for managing lists
//(see wplists)

function discard() {

if(confirm('Are you sure you want to discard all your changes?')==true) {
window.parent.scripts.restore_frames();
}

}

function alert_toggle() {

if (alert==0) {
document.getElementById('alert_more_1').style.display='block';
alert=1;

if (allow==1) {
document.getElementById('alert_more_2').style.display='block';
}

}

else {
document.getElementById('alert_more_1').style.display='none';
document.getElementById('alert_more_2').style.display='none';
alert=0;
}

}

function alert_toggle_on() {
document.getElementById('alert_more_2').style.display='block';
allow=1;
}

function alert_toggle_off() {
document.getElementById('alert_more_2').style.display='none';
allow=0;
}

var alert=0;
var allow=0;
var name;
var boogam=0;

function add_allow() {
name=prompt("Enter the name of the person you wish to add.");

if (name.length==0) {
exit();
}

if (document.getElementById('itemlist').options.length==0) {
document.getElementById('alert_remove').innerHTML='remove';
}

document.getElementById('itemlist').options[document.getElementById('itemlist').options.length] = new Option(name, name);
boogam++;

if (document.getElementById('itemlist').options.length==8) {
document.getElementById('alert_add').innerHTML='';
}

}

function remove_allow()
   {
      var list = document.getElementById('itemlist');
      var length = list.options.length;
      for( i = length - 1; i > -1; i-- )
      {
         if( list.options[i].selected )
         {
            list.options[i] = null;
            boogam--;
         }
      }
      
      if (list.options.length==0) {
      document.getElementById('alert_remove').innerHTML='';
      document.getElementById('alert_add').innerHTML='add';
      }
   }
   
function process() {
var list = document.getElementById('itemlist');
var length = list.options.length;

for( i = length - 1; i > -1; i-- ) {
list.options[i].selected='selected';
}

document.forms[0].submit();
}
</script>

<!--Allows description of functions; see .js for more info-->
<script type="text/javascript" src="includes/nicetitle.js"></script>
<link rel="stylesheet" type="text/css" href="includes/nicetitle.css"/>

</head>

<body>
<h1><center>Options</center></h1>

<form name="options" method="post">

<p>
<strong>Alerts</strong><br/>
The "alert" functionality can be customized here.</p>

<?php

// We need code here to work out which of these are selected already.

// make the code alot easier to type...
$alert = $userdata['chatspot_alert'];

if ($alert == "e")
{
  $everybody = "checked";
}

if ($alert != "e" && alert != "n")
{
  $allow_spec = "checked";
  // go bang--->
  $alertusers = explode(",", $userdata['chatspot_alert']);
  for ($i = 0; $i < count($alertusers); $i++)
  {
// Nab Kaniaz's code from above, and switch it a bit.
$id_sql="SELECT username FROM {$table_prefix}users WHERE user_id='{$alertusers[$i]}';";

$result = $db->sql_query($id_sql);
$row = $db->sql_fetchrow($result);

$name = $row["username"];


   $alertusers[$i] = $name;
  }
}

if ($alert != "n")
{
  $allow = "checked";
}

?>

<input type="checkbox" name="1" id="allow_alert" onchange="alert_toggle();" <?php echo ($allow); ?>/><label for="1" title="Allow use of the alerts function. When you disable this, you will not be able to send alerts yourself either.">Let me receive alerts. </label><br/>

<div id="alert_more_1" style="display:none;">
<input type="radio" name="3" value="1" onchange="alert_toggle_off();" <?php echo ($everybody); ?>/><label for="3" title="Allow anybody to alert you. This is recommended unless you are in a workplace situation, etc.">Allow alerts from anybody.</label><br/>
<input type="radio" name="3" value="2" onchange="alert_toggle_on();" <?php echo ($allow_spec); ?>/><label for="3" title="Only allow people you list to alert you - useful if the function is being abused.">Allow people I specify to alert me.</label>
</div>

<div id="alert_more_2" style="display:none;">
<center>

<label for="allowlist" title="People listed here will be allowed to alert you.">
<strong>Alert Allow List</strong>
</label>

<p></p>
<select name="itemlist[]" id="itemlist" multiple="multiple" size="8" style="width:150px;" title="People listed here will be allowed to alert you.">
<?php
for ($i = 0; $i < count($alertusers)-1; $i++)
{
echo ("<option value=\"{$alertusers[$i]}\">{$alertusers[$i]}</option>");
}
?>
</select>
<p></p>

<div style="width:150px; margin:0 auto;"><a href="javascript:void(0);" onclick="add_allow();" style="float:left;" id="alert_add">add</a> <a onclick="remove_allow();" href="javascript:void(0);" style="float:right;" id="alert_remove">remove</a></div>

<br/>

<p>You are allowed up to eight people in your allow list.</p>

</center>
</div>

</form>

<?php
if ($alert != "n")
{
?>
<script language="javascript">
alert_toggle();
</script>
<?php
}

if ($alert != "e" && alert != "n")
{
?>
<script language="javascript">
alert_toggle_on();
</script>
<?php
}
?>
      
<div id="submitter"><a href="javascript:void(0);" style="float:right;" onclick="discard();">Discard and Return</a> <a href="javascript:void(0);" onClick="process(); return false;" style="float:left;">Save and Return</a></div>

</body>
</html>
<?php
}
elseif ($_GET['mode'] == "ignore")
{
//SECURITY: Check to see whether or not ignores are even on.
//          If the admin has disabled ignores, then stop here.

if ($micromanage[4]==0) {
?>
<link rel="stylesheet" href="<?php echo $chatspot_config['stylesheet']?>" type="text/css">
<?php
chatspot_toast("Access Denied", "Access to this resource has been disallowed.<br/><br/>Contact an administrator.", "red");
die();
}
?>

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $lang['ENCODING']; ?>">

<link rel="stylesheet" href="<?php echo $chatspot_config['stylesheet']?>" type="text/css">

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#006699">

<table class="formarea" width="100%" height="100%">
   <tr>
      <td>
         <table class="formarea" width="100%" height="100%">
            <tr>
               <td>
                  <table class="formarea" width="100%" height="100%">
                     <tr><th>phpBBChatSpot - Ignore Manager</th></tr>
                  </table>
               </td>
            </tr>
            <tr height="100%">
               <td align="left" valign="top">
               
               <?php
               
$ignorelist=$userdata["chatspot_ignores"];
       
//If we've got this far, everything has gone fine and we can proceed.
//kaniaz (note to self) [DELETE ON RELEASE]: it's $result["chatspot_ignores"] you bitch       
//                             Techboy says: it's $ignorelist now. silly.
       
//Check if the user POST'ed an checkbox variable. If so, this means that they have deleted one of their ignores.

//NOTE: This is the start of the code to manipulate a string and remove an ignore an user no longer wants. It is
//      heavily commented as some parts may be hard to follow.

if (isset($_POST['checkbox'])) {

//Make the POST variable a nice one, and it also needs to be converted so we can match it.
$checkbox=htmlentities($_POST['checkbox'], ENT_QUOTES);

//Put the ignore list into an variable called $append. $append actually gets deleted from, which is ironic,
//but not a problem. Computers don't notice irony, and that's the only thing that will be using this.
$append=$ignorelist;

//Place every single ignore into it's own place in the array $append.
$append=explode(",", $append);

//Count how many ignores we have, and minus one from the total to accomodate for the first number in an array (0).
$loopby=count($append)-1;

//Do some pre-loop setup.
$i=-1;

//While our current place in the array is not the final place...
while ($i!=$loopby) {

//Move our place in the array forward by one.
$i++;

//Read from this part of the array. Is it what we need to delete? If so, delete it.
if (strcmp($append[$i], $checkbox)==0) {
$append[$i]="";
}

}
//End of our while loop.

//Place the array back together into one variable.
$append=implode(",", $append);

//We now have to remove some of the "gunge" that has been left behind. For example, if the ignore list was:
//iced,cooly,aquarius,i,saw,drones - and we deleted "aquarius", we would of been left with:
//iced,cooly,,i,saw,drones which is wrong (note double commas). This code removes these old seperators.

$append=str_replace(",,", ",", $append); //Remove any double commas, as per the example above.
$append=ltrim($append, ",");             //Remove any commas at the start of the string.
$append=rtrim($append, ",");             //Remove any commas at the end of the string,

//Generate our SQL query we are going to run.
$sql="UPDATE {$table_prefix}users SET chatspot_ignores = '" . $append. "' WHERE username = '" . $userdata['username'] . "';";
                  
//Run the SQL query.
$sqlresult = $db->sql_query($sql);

//Error Handling :: If our SQL queries have gone wrong in some way, we must stop here and inform the user.
if (!$sqlresult) { ?>
<center><b>Removal failed. Please contact your Adminstrator.</b><p><a href="javascript:void(0);" onClick="javascript:window.parent.message_view.location='chatspot_options.<?php echo $phpEx . $SID; ?>?mode=ignore'; return false;">Return to ignore manager</a></center>

<?php
//And stop, as it's all failed.
die();

//Otherwise, if things went as planned:
} else {
?>
<center><b>Removal successful</b><p><a href="javascript:void(0);" onClick="javascript:window.parent.message_view.location='chatspot_options.<?php echo $phpEx . $SID; ?>?mode=ignore'; return false;">Return to ignore manager</a></center>
<?php
//And stop, as we are done and no longer need to process the rest of the code.
die();                   
}

}
//End of the ignoring updater code.                  
                  
//If the user has POST'ed an addignore variable, that means they want to add some ignore to their list. This is an
//relatively simple task, complicated mostly by error checking.

if (isset($_POST['addignore'])) {

//"nine orange ten, eleven, twelve"

//Error Checking :: Have they (somehow) entered an amount longer than 25, which is longer than usernames are allowed to be.
//                  If so, pack up shop and give up.
if (strlen($_POST['addignore'])>25) { ?>

<center><b>You have entered a username longer than the allowed length (25 characters).</b><p><a href="javascript:void(0);" onClick="javascript:window.parent.message_view.location='chatspot_options.<?php echo $phpEx . $SID; ?>?mode=ignore'; return false;">Return to ignore manager</a></center>

<?php

//Stop here. We don't want to let them insert an incorrect value.
die();
}

//Error Checking :: Have they entered their own username?
if (strcasecmp($_POST['addignore'], $userdata['username'])==0) { ?>
<center><b>You cannot ignore yourself.</b><p><a href="javascript:void(0);" onClick="javascript:window.parent.message_view.location='chatspot_options.<?php echo $phpEx . $SID; ?>?mode=ignore'; return false;">Return to ignore manager</a></center>

<?php

//Stop here, as we can't let them ignore themselves.
die();
}

//Error Checking :: Have they entered the name of a user that dosen't exist for some reason?
//Make SQL to run
$sql="SELECT username FROM {$table_prefix}users WHERE username = '" . $_POST['addignore'] . "';";

//Run It
$sqlresult = $db->sql_query($sql);

//Get What We Need. Is the name there? If not, they entered somebody that dosen't exist.
if (!$exists = $db->sql_fetchrow($sqlresult)) {
$db->sql_freeresult($sqlresult);
?>

<!-- ThisIsCamelCase. -->

<center><b>You have entered a username that dosen't exist.</b><p><a href="javascript:void(0);" onClick="javascript:window.parent.message_view.location='chatspot_options.<?php echo $phpEx . $SID; ?>?mode=ignore'; return false;">Return to ignore manager</a></center>

<?php
//Stop, we cannot have them continue.       
die();
}

//End of user existence error handling.

//If our script gets this far, there are no (obvious) errors and we can proceed easily.

//The user has not got any ignores already. Therefore we can just place it in without too many problems and with no use
//of magical appending code.
if ($userdata['chatspot_ignores'] == "") {

//Generate the SQL we are going to run.
$sql="UPDATE {$table_prefix}users SET chatspot_ignores = '" . htmlentities(get_user_id($_POST['addignore'], 1), ENT_QUOTES) . "' WHERE username = '" . $userdata['username'] . "';";
}

//If this was not the case above, they must already have ignores and therefore we must run an slightly modified query to append to the end of the ignore list and not overwrite anything.
else {

//Generate the SQL we are going to run.
$sql="UPDATE {$table_prefix}users SET chatspot_ignores = '" . $userdata['chatspot_ignores'] . "," . htmlentities(get_user_id($_POST['addignore'], 1), ENT_QUOTES) . "' WHERE username = '" . $userdata['username'] . "';";     
}
//Run the SQL.
//Error Handling :: If the SQL query has failed in some way, we need to abandon ship.
if (!$sqlresult = $db->sql_query($sql)) { ?>

<center><b>Adding this ignore failed. Please contact your Adminstrator</b><p><a href="javascript:void(0);" onClick="javascript:window.parent.message_view.location='chatspot_options.<?php echo $phpEx . $SID; ?>?mode=ignore'; return false;">Return to ignore manager</a></center>

<?php
//And stop as we have failed. I am sorry, master...
die(); }

//Else, it's all gone correct and we can inform the user of our success to make us look good. Hey, why not?
else {
?>

<center><b>Addition successful</b><p><a href="javascript:void(0);" onClick="javascript:window.parent.message_view.location='chatspot_options.<?php echo $phpEx . $SID; ?>?mode=ignore'; return false;">Return to ignore manager</a></center>

<?php
//And stop as there is no more code that we will need to process.
die();
}
}
//End of the adding ignore code.
//If both of these clauses did not get called, then they must of just loaded the page. Give the user a quick briefing...
?>
               
The ignore feature was designed to allow you to ignore another user of phpBBChatspot enteriely and stop receiving their messages. Please refer to the help section, accessible from the menu above, for more information.<p>

During chat, a (<img src="ignored.png"/>) icon appears next to the names of users you have ignored, to serve as a reminder that they may be talking and you are not receiving their messages.

<center>
<form name="addignore" method="post">
<input type="text" value="Username to Ignore" name="addignore" maxlength="25"><br/>
<input type="submit" value="Add Ignore">
</form>
</center>

<?php
//If the user has ignores, display the ignore list.
if(strcmp($userdata["chatspot_ignores"],"")!=0) {
?>

<center><b>Current Ignores</b></center><br/>

<?php
//The table's header always stays the same. We place this in now.
?>
<center>
<form name="updateignores" method="post">
<table cellpadding="2" cellspacing="0" border="0" width="350">
<tr><td class="table1" align="center">Name</td><td class="table0" align="center" width="50">Remove</td></tr>

<?php
//Now we begin to do the more challening stuff.

//Place all our ignores into seperate parts of the array.
$ignores = explode(",", $userdata["chatspot_ignores"]);

//Count how many ignores we have, minus one as arrays start with zero.
$loopby=count($ignores)-1;

//Do the while loop prep...
$i=-1;

//While our current place in the $ignores array is not the last place...
while ($i!=$loopby) {

//Move our current place forward one.
$i++;

//Print out the ignore into it's box, and print out the radio button you click to remove this ignore.
echo "<tr><td class=\"table1\" align=\"center\">" . get_username($ignores[$i], 1) . "</td><td class=\"table0\" align=\"center\"><input type=\"radio\" name=\"checkbox\" value=\"" . $ignores[$i] . "\"></td></tr>";

//Continue to do this until we are out of ignores.
}
//End of while loop. Put in the bottom of the table and the submit button...
?>
</table>
<br/>
<input type="submit" value="Remove Ignore">

</center>
</form>

<?php
//End of the if.
}

//If the above wasn't true, they haven't got any ignores so we just inform them of that.
else {
?>
<center><b>No current ignores</b></center>

<?php
//End of else.
}

//Now just place in the bottom of page with the "return to chat" link.
?>
      </td></tr>
      <tr>
      <td>
      
      <a href="javascript:void(0);" onClick="javascript:window.parent.scripts.restore_frames(); return false;">Return to chat</a>
      </td>
      </tr>
      </table>
      </td>
   </tr>
</table>
</body>
</html>
<?php
die();
}
else
{
?>
<link rel="stylesheet" href="<?php echo $chatspot_config['stylesheet']?>" type="text/css">
<?php
chatspot_toast("Error", "An error occoured: wrong mode param in get<br/><br/>Contact an administrator.", "red");
die();
}
}
?>
will do till I write a new one

tech
User avatar
Demerzel
Lead Developer
Lead Developer
 
Posts: 396
Joined: Thu Jul 21, 2005 5:22 pm
Location: Scotland, UK

REF Fixed issue "Youve disabled alerts "

Postby Abrahamevatte on Tue May 09, 2017 11:51 am

If all sound playback devices on Windows are disabled, ZGE process starts, and immediately terminates, with exception "Exception EZHalted in module ZGameEditor.exe at ..... dsound failed."
Abrahamevatte
Chatspot User
 
Posts: 1
Joined: Fri Apr 28, 2017 3:14 pm
Location: Poland


Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 1 guest

cron