BHost,$this->BLogin,$this->BPass);
if (is_resource($MySQLink)) $this->BIsConnected = true;
return $this->BIsConnected;
}
private function DbQuery($BQuery)
{
if (!$this->BIsConnected) $this->DbConnect();
$BResult = mysql_query($BQuery);
return $BResult;
}
public function BStrip($BString)
{
$BChars = array(';','(',')','/','\\',']','[','+','=','^','<','>','&','"');
foreach($BChars as $BNotAllowed) $BString = str_replace($BNotAllowed,'',$BString);
return $BString;
}
public function BCheckNumBots($BId)
{
$Query = $this->DbQuery('SELECT COUNT(*) AS NbrBots FROM test.bot_botdata WHERE id="'.$BId.'" AND isaccepted="1"');
$ResQuery = mysql_fetch_array($Query);
return $ResQuery['NbrBots'];
}
public function BAddBot($BId,$BotName,$BotHost,$BotType,$Chan1,$Chan2,$Chan3,$Chan4,$Chan5)
{
$BBotName = $this->BStrip($BotName);
$BBotHost = $this->BStrip($BotHost);
$BBotType = $this->BStrip($BotType);
$BChan1 = $this->BStrip($Chan1);
$BChan2 = $this->BStrip($Chan2);
$BChan3 = $this->BStrip($Chan3);
$BChan4 = $this->BStrip($Chan4);
$BChan5 = $this->BStrip($Chan5);
$Chans = $BChan1;
if (!empty($BChan2)) { $Chans .= ','.$BChan2; }
if (!empty($BChan3)) { $Chans .= ','.$BChan3; }
if (!empty($BChan4)) { $Chans .= ','.$BChan4; }
if (!empty($BChan5)) { $Chans .= ','.$BChan5; }
if ($BBotName != $BotName) { return 0; }
else if ($this->IsBotIsFree($BBotName)) { return 6; }
else if ($BBotHost != $BotHost) { return 1; }
else if ($BBotType != $BotType) { return 2; }
else if (empty($BChan1)) { return 3; }
else if (($BChan1 != $Chan1) OR ($BChan2 != $Chan2) OR ($BChan3 != $Chan3) OR ($BChan4 != $Chan4) OR ($BChan5 != $Chan5))
{
return 4;
}
else {
$Query = $this->DbQuery('INSERT INTO test.bot_botdata VALUES("'.$BId.'","'.$BBotName.'","'.$BBotHost.'","'.$BBotType.'","'.$Chans.'",2,"")');
return 5;
}
}
public function BIsLogged()
{
if (!empty($_SESSION['userid']) && !empty($_SESSION['right']) && !empty($_SESSION['username']) && !empty($_SESSION['email']))
{
return true;
}
}
public function BGetAccount()
{
$Query = $this->DbQuery('SELECT COUNT(*) AS nbrAccount FROM test.bot_userdata');
$ResQuery = mysql_fetch_array($Query);
return $ResQuery['nbrAccount'];
}
public function BGetBots($BId)
{
if ($BId == 1) {
$Query = $this->DbQuery('SELECT COUNT(*) AS nbrBots FROM test.bot_botdata WHERE isaccepted="1"');
$ResQuery = mysql_fetch_array($Query);
return $ResQuery['nbrBots'];
} else if ($BId == 2) {
$Query = $this->DbQuery('SELECT COUNT(*) AS nbrBots FROM test.bot_botdata WHERE isaccepted="2"');
$ResQuery = mysql_fetch_array($Query);
return $ResQuery['nbrBots'];
} else if ($BId == 3) {
$Query = $this->DbQuery('SELECT COUNT(*) AS nbrBots FROM test.bot_botdata WHERE isaccepted="4"');
$ResQuery = mysql_fetch_array($Query);
return $ResQuery['nbrBots'];
}
}
public function BPurge()
{
$Query = $this->DbQuery('DELETE FROM test.bot_botdata WHERE isaccepted=4');
return 1;
}
public function LoadData($ToEdit)
{
$Query = $this->DbQuery('SELECT * FROM test.bot_botdata WHERE botname="'.$ToEdit.'"');
$ResQuery = mysql_fetch_array($Query);
return $ResQuery;
}
public function BGetMyBots($BIdSession)
{
$Query = $this->DbQuery('SELECT * FROM test.bot_botdata WHERE id="'.$BIdSession.'"');
while ($ResQuery = mysql_fetch_array($Query))
{
$MyBot = '
';
$MyBot .= ''.$ResQuery['botname'].'
|
';
$MyBot .= 'Host du bot : '.$ResQuery['bothost'].'
';
$MyBot .= 'Type du bot : '.$ResQuery['bottype'].'
';
$MyBot .= 'Chan(s) : '.$ResQuery['botchans'].'
';
$MyBot .= 'Statut : '.$this->GetStatus($ResQuery['isaccepted']).'
';
if (!empty($ResQuery['comment'])) $MyBot .= 'Commentaire : '.stripslashes($ResQuery['comment']).'';
$MyBot .= ' |
';
echo $MyBot;
}
}
public function BGetWaiting()
{
$Query = $this->DbQuery('SELECT * FROM test.bot_botdata WHERE isaccepted=2');
while ($ResQuery = mysql_fetch_array($Query))
{
$QueryOwner = $this->DbQuery('SELECT * FROM test.bot_userdata WHERE id='.$ResQuery['id']);
$ResQueryOwner = mysql_fetch_array($QueryOwner);
$MyBot = '';
$MyBot .= ''.$ResQuery['botname'].' (Mod)
|
';
$MyBot .= 'Host du bot : '.$ResQuery['bothost'].'
';
$MyBot .= 'Type du bot : '.$ResQuery['bottype'].'
';
$MyBot .= 'Chan(s) : '.$ResQuery['botchans'].'
';
$MyBot .= 'Owner : '.$ResQueryOwner['owner'].'
';
$MyBot .= 'eMail : '.$ResQueryOwner['email'].'
';
$MyBot .= 'Autres bots : '.$this->BOtherBot($ResQuery['id'],$ResQuery['botname']).'
';
$MyBot .= 'Statut : '.$this->GetStatus($ResQuery['isaccepted']).'
';
if (!empty($ResQuery['comment'])) $MyBot .= 'Commentaire : '.stripslashes($ResQuery['comment']).'';
$MyBot .= ' |
';
echo $MyBot;
}
}
public function BOtherBot($ID,$BotNameWaiting)
{
$Query = $this->DbQuery('SELECT * FROM test.bot_botdata WHERE id='.$ID);
while ($Res = mysql_fetch_array($Query))
{
if ($Res['botname'] != $BotNameWaiting) {
if (empty($Bots)) { $Bots = '
- '.$Res['botname'].' ('.$this->GetStatus($Res['isaccepted']).')'; }
else { $Bots .= '
- '.$Res['botname'].' ('.$this->GetStatus($Res['isaccepted']).')'; }
}
}
return $Bots;
}
public function BGetHisBots($BotName)
{
$BotName = $this->BStrip($BotName);
$Query = $this->DbQuery('SELECT * FROM test.bot_botdata WHERE botname LIKE "%'.$BotName.'%"');
while ($ResQuery = mysql_fetch_array($Query))
{
$MyBot = '';
$MyBot .= ''.$ResQuery['botname'].' (Mod) ';
if ($_SESSION['right'] == 768) { $MyBot .= '(Delete)'; }
$MyBot .= '
|
';
$MyBot .= 'Host du bot : '.$ResQuery['bothost'].'
';
$MyBot .= 'Type du bot : '.$ResQuery['bottype'].'
';
$MyBot .= 'Chan(s) : '.$ResQuery['botchans'].'
';
$MyBot .= 'Statut : '.$this->GetStatus($ResQuery['isaccepted']);
$MyBot .= '
';
if (!empty($ResQuery['comment'])) $MyBot .= 'Commentaire : '.stripslashes($ResQuery['comment']).'';
$MyBot .= ' |
';
echo $MyBot;
}
}
public function DelBot($BotName)
{
$this->DbQuery('DELETE FROM test.bot_botdata WHERE botname="'.$BotName.'"');
return 1;
}
public function GetStatus($BId)
{
if ($BId == 1) { return 'Accepté'; }
else if ($BId == 4) { return 'Refusé'; }
else if ($BId == 2) { return 'En attente'; }
else if ($BId == 3) { return 'Suspendu'; }
}
public function UpdateRobot($BotName,$BotHost,$BotType,$BotChans,$BotStatut,$BotComment)
{
$BotName = $this->BStrip($BotName);
$BotHost = $this->BStrip($BotHost);
$BotType = $this->BStrip($BotType);
$BotChans = $this->BStrip($BotChans);
$query = $this->DbQuery('SELECT * FROM test.bot_botdata WHERE botname="'.$BotName.'"');
$res = mysql_fetch_array($query);
if ($res['comment'] != stripslashes($BotComment) && !empty($BotComment)) {
$BotComment .= ' - '.$_SESSION['username'];
}
$BotComment = addslashes($BotComment);
$Query = $this->DbQuery("UPDATE test.bot_botdata SET bothost = '$BotHost', bottype = '$BotType', botchans = '$BotChans', isaccepted = '$BotStatut', comment = '$BotComment' WHERE botname = '$BotName'");
return 1;
}
public function LoadContent($BId)
{
$Bfiles = array(
'0'=>'include/bnews.php',
'1'=>'include/bregister.php',
'2'=>'include/bconcours.php',
'3'=>'include/whatisbot.php',
'4'=>'include/regabot.php',
'5'=>'include/isbotfree.php',
'6'=>'include/pools.php',
'7'=>'include/downs.php',
'8'=>'include/tuts.php',
'9'=>'include/mesbots.php',
'10'=>'include/addbot.php',
'11'=>'include/apsearch.php',
'12'=>'include/apwaiting.php',
'13'=>'include/appurge.php',
'14'=>'include/appools.php',
);
$NewBId = $this->BStrip($BId);
if (($BId != $NewBId) OR (strlen($BId) > 2)) { exit(); }
elseif (array_key_exists($BId,$Bfiles)) { include($Bfiles[$BId]); }
}
public function LoadMenu()
{
// Menu général
$BMenu1 = '
';
$BMenu1 .= '';
$BMenu1 .= '';
$BMenu1 .= '';
$BMenu1 .= '';
$BMenu1 .= '';
$BMenu1 .= '';
$BMenu1 .= '';
$BMenu1 .= '';
$BMenu1 .= 'Nous contacter
';
echo $BMenu1;
// Menu de login
if (!$this->BIsLogged())
{
$BMenu2 = '

';
echo $BMenu2;
} else {
$BMenu3 = '

';
$BMenu3 .= 'Loggué en tant que : '.$_SESSION['username'].'
Access : '.$this->GetRight().'
';
if ($_SESSION['right'] >= 512) {
$BMenu3 .= '';
$BMenu3 .= '';
}
if ($_SESSION['right'] == 768) {
$BMenu3 .= '';
$BMenu3 .= '';
}
$BMenu3 .= '';
$BMenu3 .= '';
$BMenu3 .= '';
echo $BMenu3;
}
// Menu de stats :P
$BMenu4 = '

';
$BMenu4 .= 'Utilisateurs : '.$this->BGetAccount().'
';
$BMenu4 .= 'Robots Acceptés : '.$this->BGetBots(1).'
';
$BMenu4 .= 'Robots en Attente : '.$this->BGetBots(2).'
';
$BMenu4 .= 'Robots Refusés : '.$this->BGetBots(3).'
';
echo $BMenu4;
}
public function GetRight()
{
$BRights = array(1=>'Membre',512=>'Admin lv1',768=>'Admin lv2');
if (!empty($_SESSION['right'])) {
return $BRights[ $_SESSION['right'] ];
}
}
public function EnumPool()
{
echo '';
$Query = $this->DbQuery('SELECT * FROM test.bot_pools');
while ($Res = mysql_fetch_array($Query))
{
echo '| '.$Res['lettre'].' | '.$Res['pseudo'].' |
';
}
echo '
';
return true;
}
public function EnumPoolEdit()
{
echo '';
return true;
}
public function PoolUpdate()
{
$Beg = ord('a');
while ($Beg <= ord('z'))
{
$this->DbQuery('UPDATE test.bot_pools SET pseudo="'.$_POST[ chr($Beg) ].'" WHERE lettre="'.chr($Beg).'"');
$Beg++;
}
}
/* public function PoolUpdate()
{
$this->DbQuery('DELETE FROM test.bot_pools');
$Beg = ord('a');
while ($Beg <= ord('z'))
{
$this->DbQuery('INSERT INTO test.bot_pools VALUES ("'.chr($Beg).'","test")');
$Beg++;
}
}*/
public function BLogin($BUser,$BPass)
{
$BUser = $this->BStrip($BUser);
$BPass = md5($this->BStrip($BPass));
$Query = $this->DbQuery('SELECT * FROM test.bot_userdata WHERE owner="'.$BUser.'"');
$ResQuery = mysql_fetch_array($Query);
if ($ResQuery['password'] == $BPass) {
$_SESSION['userid'] = $ResQuery['id'];
$_SESSION['right'] = $ResQuery['right'];
$_SESSION['username'] = $ResQuery['owner'];
$_SESSION['email'] = $ResQuery['email'];
return true;
}
}
public function IsBotIsFree($BotName)
{
$BotName = $this->BStrip($BotName);
$Query = $this->DbQuery('SELECT * FROM test.bot_botdata WHERE botname="'.$BotName.'" AND isaccepted="1"');
if (mysql_num_rows($Query) > 0)
{
return 1;
}
}
public function BRegister($BOwner,$BPassword,$BEmail)
{
$BOwner = $this->BStrip($BOwner);
$BPassword = md5($this->BStrip($BPassword));
$BEmail = $this->BStrip($BEmail);
// Verify if the account is already taken
$Query = $this->DbQuery('SELECT * FROM test.bot_userdata WHERE owner="'.$BOwner.'"');
if (mysql_num_rows($Query) > 0) return 1;
// Verify if the email is already taken
$Query = $this->DbQuery('SELECT * FROM test.bot_userdata WHERE email="'.$BEmail.'"');
if (mysql_num_rows($Query) > 0) return 2;
// Everything okay ? Register :)
$Query = $this->DbQuery("INSERT INTO test.bot_userdata VALUES('','$BOwner','$BPassword','$BEmail','1')");
return 0;
}
public function BLogout()
{
if ($this->BIsLogged()) {
unset($_SESSION);
session_destroy();
return true;
}
}
}
$BSite = new BClass();
?>