Will this work with a file other than posting.php?


  -----  
Author Message

Presents
Member

Sat Dec 30, 2006 10:42 am   Post subject: Will this work with a file other than posting.php?
Well, I have a file from a MOD called warning.php

It's basically a Warning MOD, and after a warning, the moderators are sent back to the index.

Is it possible to use the Redirection Suite and direct them back to the topic in which they were viewing before they warned the user?

Here is the code of the warning.php


Code:

<?php
//
// phpBB Header
//
define(\'IN_PHPBB\', true);
$phpbb_root_path = \'./\';
include($phpbb_root_path . \'extension.inc\');
include($phpbb_root_path . \'common.\'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_VIEWONLINE);
init_userprefs($userdata);

if($userdata[\'user_level\'] == USER)
{
   // No users allowed!
   redirect(append_sid(\"index.$phpEx\"));
}

//
// Output page header and load page template
//
$page_title = $lang[\'warnmod_title\'];

//
// Do warnings, Unwarnings & Bans, This crap explains itself.
//
if($HTTP_GET_VARS[\'mode\'] == \'warn\')
{
   $profiledata = get_userdata(intval($HTTP_GET_VARS[POST_USERS_URL]));
   if (!$profiledata)
   {
      message_die(GENERAL_MESSAGE, $lang[\'No_user_id_specified\']);
   }
   if($profiledata[\'user_warnings\'] >= MAGIC_BAN_NUMBER)
   {
      $mode = \'ban\';
   }
   else
   {
      $mode = \'warn\';
   }
}
elseif($HTTP_GET_VARS[\'mode\'] == \'unwarn\')
{
   $profiledata = get_userdata(intval($HTTP_GET_VARS[POST_USERS_URL]));
   if (!$profiledata)
   {
      message_die(GENERAL_MESSAGE, $lang[\'No_user_id_specified\']);
   }
   if(!$profiledata[\'user_warnings\'])
   {
      message_die(GENERAL_MESSAGE, $lang[\'User_has_no_warnings\'] . \'<br /><br />\' . sprintf($lang[\'Click_return_index\'], \'<a href=\"\' . append_sid(\"index.$phpEx\") . \'\">\', \'</a>\'));
   }
   $mode = \'unwarn\';
}
elseif($HTTP_GET_VARS[\'mode\'] == \'unban\')
{
   $profiledata = get_userdata(intval($HTTP_GET_VARS[POST_USERS_URL]));
   if (!$profiledata)
   {
      message_die(GENERAL_MESSAGE, $lang[\'No_user_id_specified\']);
   }
   $mode = \'unban\';
}
else
{
   // Go away, your not doing anything anyway.
   redirect(append_sid(\"index.$phpEx\"));
}

// Temp fix to prevent banning admins/mods.
if($profiledata[\'user_level\'] != USER)
{
$message = \'You do not have the permission to ban an admin or moderator.\' . \'<br /><br />\' . sprintf($lang[\'Click_return_index\'], \'<a href=\"\' . append_sid(\"index.$phpEx\") . \'\">\', \'</a>\');
message_die(GENERAL_MESSAGE, $message, $lang[\'warnmod_title\']);
}

//
// Ok, Modes are set now - Lets play with them.
//
if($mode == \'ban\')
{
   $ban_config_rank = intval($board_config[\'warnmod_banrank\']);
   // Ok, Lets make them happy and change the rank... Lazy admins!
   $sql = \"UPDATE \". USERS_TABLE .\" SET user_rank = \'\" . $ban_config_rank . \"\' WHERE user_id = \'\" . $profiledata[\'user_id\'] . \"\'\";
   if( !$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, \"Couldn\'t update user rank\", \"Database Error\", __LINE__, __FILE__, $sql);
   }
   // Change the warnings counter to show they are banned.
   $sql = \"UPDATE \" . USERS_TABLE . \" SET user_warnings = 4 WHERE user_id = \" . $profiledata[\'user_id\'];
   if (!$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, \"Couldn\'t update warning count\", \"\", __LINE__, __FILE__, $sql);
   }
   // Lets check the banlist...
   $sql = \"SELECT ban_userid FROM \" . BANLIST_TABLE . \" WHERE ban_userid = \" . $profiledata[\'user_id\'];
   if(! $result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, \"Couldn\'t obtain banlist information\", \"\", __LINE__, __FILE__, $sql);
   }
   if ($db->sql_fetchrowset($result))
   {
      message_die(GENERAL_MESSAGE, $lang[\'User_already_banned_warnmod\'] . \'<br /><br />\' . sprintf($lang[\'Click_return_index\'], \'<a href=\"\' . append_sid(\"index.$phpEx\") . \'\">\', \'</a>\'));
   }
   // Lets ban this little devil.
   $sql = \"INSERT INTO \" . BANLIST_TABLE . \" (ban_userid) VALUES (\" . $profiledata[\'user_id\'] . \")\";
   if (!$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, \"Couldn\'t insert ban_userid info into database\", \"\", __LINE__, __FILE__, $sql);
   }
   // Tell them the good news!
   $message = $lang[\'User_successfully_banned_warnmod\'] . \'<br /><br />\' . sprintf($lang[\'Click_return_index\'], \'<a href=\"\' . append_sid(\"index.$phpEx\") . \'\">\', \'</a>\');
   message_die(GENERAL_MESSAGE, $message, $lang[\'warnmod_title\']);
}
elseif($mode == \'unban\')
{
   // This has to be a rare thing...
   $unban_config_rank = intval($board_config[\'warnmod_unbanrank\']);
   // Ok, Lets make them happy and change the rank... Lazy admins!
   $sql = \"UPDATE \". USERS_TABLE .\" SET user_rank = \'\" . $unban_config_rank . \"\' WHERE user_id = \'\" . $profiledata[\'user_id\'] . \"\'\";
   if( !$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, \"Couldn\'t update user rank\", \"Database Error\", __LINE__, __FILE__, $sql);
   }
   // Change the warnings counter to show they are unbanned.
   $sql = \"UPDATE \" . USERS_TABLE . \" SET user_warnings = 0 WHERE user_id = \" . $profiledata[\'user_id\'];
   if (!$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, \"Couldn\'t update warning count\", \"\", __LINE__, __FILE__, $sql);
   }
   // Lets check the banlist...
   $sql = \"SELECT ban_userid FROM \" . BANLIST_TABLE . \" WHERE ban_userid = \" . $profiledata[\'user_id\'];
   if(! $result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, \"Couldn\'t obtain banlist information\", \"\", __LINE__, __FILE__, $sql);
   }
   if (!$db->sql_fetchrowset($result))
   {
      message_die(GENERAL_MESSAGE, $lang[\'User_not_banned_warnmod\'] . \'<br /><br />\' . sprintf($lang[\'Click_return_index\'], \'<a href=\"\' . append_sid(\"index.$phpEx\") . \'\">\', \'</a>\'));
   }
   // Lets unban this little bundle of joy.
   $sql = \"DELETE FROM \" . BANLIST_TABLE . \" WHERE ban_userid = \" . $profiledata[\'user_id\'] . \" LIMIT 1\";
   if (!$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, \"Couldn\'t insert ban_userid info into database\", \"\", __LINE__, __FILE__, $sql);
   }
   // Tell them the good news!
   $message = $lang[\'User_successfully_unbanned_warnmod\'] . \'<br /><br />\' . sprintf($lang[\'Click_return_index\'], \'<a href=\"\' . append_sid(\"index.$phpEx\") . \'\">\', \'</a>\');
   message_die(GENERAL_MESSAGE, $message, $lang[\'warnmod_title\']);

}
elseif($mode == \'unwarn\')
{
   // Hmm, Looks like somebody has been good today
   $newWarnlevel = intval($profiledata[\'user_warnings\']);
   $newWarnlevel--;
   $sql = \"UPDATE \" . USERS_TABLE . \" SET user_warnings = $newWarnlevel WHERE user_id = \" . $profiledata[\'user_id\'];
   if (!$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, \"Couldn\'t update warning count\", \"\", __LINE__, __FILE__, $sql);
   }
   $message = $lang[\'User_successfully_unwarned_warnmod\'] . \'<br /><br />\' . sprintf($lang[\'Click_return_index\'], \'<a href=\"\' . append_sid(\"index.$phpEx\") . \'\">\', \'</a>\');
   message_die(GENERAL_MESSAGE, $message, $lang[\'warnmod_title\']);
}
elseif($mode == \'warn\')
{
   // Whats the point of warning a banned user...
   $sql = \"SELECT ban_userid FROM \" . BANLIST_TABLE . \" WHERE ban_userid = \" . $profiledata[\'user_id\'];
   if(! $result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, \"Couldn\'t obtain banlist information\", \"\", __LINE__, __FILE__, $sql);
   }
   if ($db->sql_fetchrowset($result))
   {
      message_die(GENERAL_MESSAGE, $lang[\'User_already_banned_warnmod\'] . \'<br /><br />\' . sprintf($lang[\'Click_return_index\'], \'<a href=\"\' . append_sid(\"index.$phpEx\") . \'\">\', \'</a>\'));
   }
   // Oh noes! Somebody did something wrong!
   $newWarnlevel = intval($profiledata[\'user_warnings\']);
   $newWarnlevel++;
   $sql = \"UPDATE \" . USERS_TABLE . \" SET user_warnings = $newWarnlevel WHERE user_id = \" . $profiledata[\'user_id\'];
   if (!$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, \"Couldn\'t update warning count\", \"\", __LINE__, __FILE__, $sql);
   }
   $message = $lang[\'User_successfully_warned_warnmod\'] . \'<br /><br />\' . sprintf($lang[\'Click_return_index\'], \'<a href=\"\' . append_sid(\"index.$phpEx\") . \'\">\', \'</a>\');
   message_die(GENERAL_MESSAGE, $message, $lang[\'warnmod_title\']);
}
else
{
   // Hmm, what the heck did i do wrong to make it do this?
   redirect(append_sid(\"index.$phpEx\"));
}

//
// Output page and footer
//

include($phpbb_root_path . \'includes/page_tail.\'.$phpEx);

?>




Thanks for reading!
 

Thoul
Administrator

Wed Jan 03, 2007 11:36 am   Post subject: re: Will this work with a file other than posting.php?
Probably not. It looks like that file doesn't have access to the topic id number of the topic they were viewing. It might be possible with some additional edits to viewtopic.php. Installing Redirection Suite on warning.php would be kind of touch and go, though, as it won't match any of the existing install steps.
 

Page 1 of 1
Display posts from previous: