Someone requested on my profile ( View Profile: PhoOwned - OtLand ):
Add this page as 'unban' in index.php:
Make new file unban.php and paste:
It's very simple script, but works ^_^
So..RoHaN O said:Hey! Was wondering if you could help me with a shop-unban system? I got no clue how to add one
Add this page as 'unban' in index.php:
PHP:
case "unban";
$topic = "Unban";
$subtopic = "unban";
include("unban.php");
break;
PHP:
<?php
$points_for_unban = 30;
if($logged)
{
$pp = $account_logged->getPremiumPoints();
if($pp >= $points_for_unban)
{
if($action == 'unban')
{
if(isset($_POST['char_name']))
{
$player = new OTS_Player();
$player->find($_POST['char_name']);
if($player->isLoaded())
{
$account = $player->getAccount();
if($account->isLoaded())
{
$account_bans = $SQL->query('SELECT `id` FROM `bans` WHERE `value` = ' . $account->getId() . ' AND `active` = 1 AND (`type` = 3 OR `type` = 5)')->fetchAll();
$remove = false;
$account_players = $account->getPlayersList();
if(empty($account_bans))
{
if($account_players->count() > 0)
{
foreach($account_players as $player)
{
$player_bans = $SQL->query('SELECT `id` FROM `bans` WHERE `value` = ' . $player->getId() . ' AND `active` = 1 AND (`type` = 2 OR `type` = 3 OR `type` = 5)')->fetchAll();
if(!empty($player_bans))
$remove = true;
}
}
}
else
$remove = true;
if($remove)
{
if($account_players->count() > 0)
foreach($account_players as $player)
$SQL->query('UPDATE `bans` SET `active` = 0 WHERE `value` = ' . $player->getId() . ' AND (`type` = 2 OR `type` = 5)');
$SQL->query('UPDATE `bans` SET `active` = 0 WHERE `value` = ' . $account->getId() . ' AND (`type` = 3 OR `type` = 5)');
$account_logged->setPremiumPoints($pp - $points_for_unban);
$account_logged->save();
$main_content .= 'Account has been unbanned.';
}
else
$main_content .= 'This account is not banned.';
}
else
$main_content .= 'Account of this player doesn\'t exist.';
}
else
$main_content .= 'Player ' . htmlspecialchars($_POST['char_name']) . ' doesn\'t exist.';
}
else
$main_content .= 'No character selected.';
$main_content .= '<br /><a href="?subtopic=unban">GO BACK</a>';
}
else
{
$main_content .= '<h2>Unban System</h2><br /><h4>Unban cost ' . $points_for_unban . ' premium points!</h4><br />';
$main_content .= 'Write nick of banned player [his account and all characters will be unbanned] that you want unban:<br /><form action="?" method="post"><input type="hidden" name="action" value="unban" /><input type="hidden" name="subtopic" value="unban" />';
$main_content .= '<input type="text" name="char_name" value="" /><input type="submit" value="Unban" /></form>';
}
}
else
$main_content .= 'You need ' . $points_for_unban . ' premium points or more to unban.';
}
else
$main_content .= '<b>Please login first.</b>';
?>
It's very simple script, but works ^_^