/q_client.php
PHP | 1510 lines | 1468 code | 0 blank | 42 comment | 225 complexity | 033b93b2a26f9b0fbf67055f5d3e8c1d MD5 | raw file
- <?php
- /*
- Classe du robot, uniquement
- */
- class QClient {
- private static $_instance;
- private static $data;
- public static function getInstance(){
- if(!isset(self::$_instance)){ self::$_instance = new self; }
- return self::$_instance;
- }
- function __construct(){echo __CLASS__,": crיation de l'instance\n";}
- function __destruct(){echo __CLASS__,": destruction de l'instance\n";}
- function __clone(){trigger_error("Le clפnage n'est pas autorisי.",E_USER_ERROR);}
- private static function callback_dropkeys($array,$drop=array()){
- $return = array();
- foreach($array AS $key => $value){
- if(!in_array($key,$drop)) $return[]=$value;
- else echo "Clef ignorיe: $key ($value)\n";
- }
- return $return;
- }
- public static function handle($array){
- echo "##### ",__CLASS__," #####\n";
- $cmd=$array[2]=strtoupper(substr($array[2],1));
- self::$data = $array;
- # self::callback_dropkeys($array,array(2));
- echo "Commande: $cmd\n";
- print_r(self::$data);
- echo count(self::$data);
- switch($cmd){
- case 'HELP':self::help();break;# Commandes de niveau 0
- case 'AUTH':self::auth();break;
- case 'HELLO':self::hello();break;
- case 'VALIDATE':self::validate();break;
- case 'WHOAMI':self::whoami();break;# Commandes de niveau 1 et plus
- case 'VOICE':self::voice();break;
- case 'OP':self::op();break;
- case 'DEOPALL':self::deopall();break;
- case 'DEVOICEALL':self::devoiceall();break;
- case 'WELCOME':self::welcome();break;
- case 'SETTOPIC':self::settopic();break;
- case 'CHANMODE':self::chanmode();break;
- case 'CHANFLAGS':self::chanflags();break;
- case 'CHANLEV':self::chanlev();break;
- case 'WHOIS':self::whois();break;# Commandes de niveau 900
- case 'CHANWHO':self::chanwho();break;
- case 'KILL':self::kill();break;
- case 'GLOBALE':self::desynch();break;
- case 'ADDUSER':self::adduser();break;# Commandes de niveau 1000
- case 'DELUSER':self::deluser();break;
- case 'SETUSER':self::setuser();break;
- case 'GETUSER':self::getuser();break;
- case 'ADDCHAN':self::addchan();break;
- case 'DELCHAN':self::delchan();break;
- case 'CHANSET':self::chanset();break;
- case 'SET':self::set();break;
- case 'GET':self::get();break;
- /*case 'CRAW':self::craw();break;
- case 'SRAW':self::sraw();break;
- case 'DNSBL':self::dnsbl();break;
- case 'LOCATE':self::locate();break;
- case 'CLVENC':self::clvenc();break;# Commandes de deboguage
- case 'CLVDEC':self::clvdec();break;
- case 'CHMENC':self::chmenc();break;
- case 'CHMDEC':self::chmdec();break;*/
- case 'SAVE':self::save();break;
- case 'RESTART':self::restart();break;
- case 'DIE':self::shutdown();break;
- case 'STATUS':self::status();break;
- case 'VERSION':self::version();break;
- default:self::error();break;
- }
- }
- public static function handlec($parray){
- self::$data = array($parray[0],$parray[1],ltrim(strtoupper(substr($parray[2],1)),":"));
- if(count($parray)>3){
- $rest = array_slice($parray,3);
- foreach($rest AS $piece) self::$data[]=$piece;
- }
- echo "Donnיes publiques: ".implode(' ',$parray)." (".count($parray).")\n";
- switch(self::$data[2]){
- case "ACTION":self::p_action();break;
- case "PREG":self::p_preg();break;
- //case "LOCATE":self::p_locate();break;
- case "DNSBL":self::p_dnsbl();break;
- }
- }
-
- private static function success(){$cm=QCommands::getInstance();$cm->notice(self::$data[0],"Effectuי.");}
- private static function error(){
- $cm = QCommands::getInstance();
- $cm->notice(self::$data[0],"La commande ".self::$data[2]." n'existe pas ou votre niveau d'accטs est insuffisant.");
- }
- ###########################
- #### Commandes privיes ####
- ###########################
- private static function help(){
- echo "Demande d'aide\n";
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- $r = QRegister::getInstance();
- if(count(self::$data)==4){
- list($client,,,$command) = self::$data;
- echo "Commande d'aide: $command\n";
- switch(strtoupper($command)){
- case "HELLO":
- $cm->notice($client,array(
- "Syntaxe: HELLO <votre@email.com> <votre@email.com>",
- "La commande HELLO vous permet de crיer un compte utilisateur en utilisant votre pseudonyme actuel.",
- "Exemple si votre pseudo est \"banane\" et que vous tapez: /MSG Q HELLO banane@frou.fr banane@frou.fr",
- "Ceci crיera le compte \"banane\" aprטs votre rיponse א l'email envoyי א banane@frou.fr"
- ));
- break;
- case "VALIDATE":
- $cm->notice($client,array(
- "Syntaxe: VALIDATE <clef>",
- "La commande VALIDATE vous permet de terminer l'enregistrement du compte utilisateur,",
- "le paramטtre <clef> reprיsente la clef qui a יtי envoyיe par email lors de la commande HELLO."
- ));
- break;
- case "AUTH":
- $cm->notice($client,array(
- "Syntaxe: AUTH <mot-de-passe>",
- "La commande AUTH vous permet d'utiliser votre compte utilisateur prיcיdement crיי avec la commande HELLO ( cf HELP HELLO )",
- "Ceci vous permet d'utiliser vos niveaux d'accטs salons et les commandes du service Q"
- ));
- break;
- }
- if($db->isAuthed($client)){
- if($r->getaccount($r->getClientaccount($client),"level")!==false){
- $level = $r->getaccount($r->getClientaccount($client),"level");
- echo __CLASS__.": le client $client est de niveau $level\n";
- }
- if(isset($level)&&$level>=1){
- switch(strtoupper($command)){
- case 'CHANFLAGS':
- $cm->notice($client,array(
- 'Syntaxe: CHANFLAGS <#canal> [<+/-attributs>]',
- 'Cette commande vous permet de paramטtrer votre canal, ou plus prיcisיment le comportement du service sur ce dernier.',
- '-',
- '+w WELCOME - Affiche le message de bienvenue aux utilisateurs rejoignants le canal, pour ךtre dispensי voir le CHANLEV +w',
- '-',
- 'Attributs d\'Automatisme',
- 'Les paramטtres suivants s\'appliquent lors de l\'entrיe d\'un utilisateur sur le canal.',
- '+a AUTOOP - Donne automatiquement le status d\'opיrateur aux utilisateurs ayant un Accטs Opיrateurs (CHANLEV +o) sur le canal.',
- '+g AUTOVOICE - Donne automatiquement le status de modיrateur aux utilisateurs ayant un Accטs Modיrateur (CHANLEV +v) sur le canal.',
- '+o AUTOOPALL - Donne automatiquement le status d\'Opיrateur (+o)',
- '+v AUTOVOICEALL - Donne automatiquement le status de Modיrateur. (+v)',
- '+c AUTOLIMIT - Limite automatiquement le canal afin d\'יviter un engorgement par des attaques de clones/proxys (peut causer du tord aux vrais utilisateurs), pour le rיglage de l\'intervale voir la commande: AUTOLIMIT',
- '-',
- 'Attributs d\'Action',
- 'Les paramטtres suivants s\'appliquent lors d\'actions venant des utilisateurs (changement du sujet, des modes, ...)',
- '+b BITCHMODE* - Le service applique strictement les attributs utilisateurs (+o,+v) et interdit toute modification.',
- '+f TOPICLOCK* - Le service autorise la modification du sujet uniquement par la commande SETTOPIC.',
- '+m MODELOCK* - Le service autorise la modification des modes uniquement par la commande CHANMODE.',
- '+e ENFORCEBANS* - Le service expulse automatiquement les utilisateurs ciblיs par les exclusions.',
- '+p PROTECT - Le service interdit la modification des status utilisateurs par ceux n\'ayant pas d\'accטs',
- 'NOTER QUE: le non-respect rיpיtי des chanflags ci-dessus engendre un retrait de status immיdiat. (protection contre le vol de canal)',
- '* = N\'affecte pas les Superviseurs (CHANLEV +x).',
- '-',
- 'Paramטtres Restritifs',
- '+d DEOPCHAN* - Le service interdit le status d\'Opיrateur (+o) א tous les utilisateurs.',
- '+q NOVOICES* - Le service interdit le status de Modיrateur (+v) א tous les utilisateurs.',
- '+i INVITEONLY* - Le service restreint le canal (+i) aux utilisateurs ayant utilisיs la commande INVITE.',
- '+r REGONLY - Seuls les utilisateurs enregistrיs sont autorisיs א rejoindre le canal.',
- '* = N\'affecte pas les Superviseurs (CHANLEV +x) et le service.',
- '-',
- 'Paramטtres Staff',
- '+t TOPICBURST - Le service renvoie automatiquement le sujet enregistrי depuis la commande SETTOPIC.',
- '+s SUSPEND - Le service n\'est plus actif sur le canal. (les paramטtres sont sauvegardיs)',
- //'+h HELPCHAN - Le service aide les opיrateurs du canal א modיrer les utilisateurs.',
- '-',
- 'MEMO CHANLEV: Fondateur (+f), Superviseur (+x), propriיtaire (+n), maמtre (+m), opיrateur (+o) et modיrateur (+v)',
- 'HELP CHANLEV pour plus de dיtails.'
- ));
- break;
- case 'CHANLEV':
- $cm->notice($client,array(
- 'Syntaxe: CHANLEV <canal> [<compte>] [+/-<attributs>]',
- 'Cette commande permet d\'attribuer/rיtribuer des droits utilisateurs sur le canal.',
- 'Here we go.',
- 'Attributs des Niveaux d\'Accטs',
- '+f FOUNDER - Le Fondateur peut ajouter/retirer des Propriיtaires, Jokers, Maמtres, Opיrateurs et Modיrateurs.',
- 'NOTER QUE: Cet attribut est rattachי au compte, invisible aux utilisateurs et ne peut pas ךtre cedי.',
- '+x SUPERVISOR - Le Superviseur peut outre-passer toutes les restrictions du service.',
- 'Rפle: peut utiliser les commandes si le canal est DEOPCHAN, NOVOICES et est immunisי aux rטgles: BITCHMODE, TOPICLOCK, MODELOCK, ENFORCEBANS',
- '+n OWNER - Le Propriיtaire peut ajouter/retirer des Maמtres, Opיrateurs et Modיrateurs.',
- 'Il peut utiliser les commandes: CHANMODES, CHANFLAGS',
- '+m MASTER - Le Maמtre peut ajouter/retirer des Opיrateurs et Modיrateurs, modifier le sujet du canal (cf HELP SETTOPIC) et exclure des utilisateurs. (cf HELP BAN)',
- '+o OP - L\'Opיrateur peut ajouter/retirer des Modיrateurs.',
- '+v VOICE - Le Modיrateur peut s\'exprimer quand le canal est [CHAN]MODE +m',
- '-',
- 'Attributs d\'Automatismes',
- '+a AUTOOP - Si l\'utilisateur est attribuי +o (Opיrateur) le status d\'Opיrateur (@) lui sera automatiquement dispensי.',
- '+g AUTOVOICE - Si l\'utilisateur est attribuי +v (Modיrateur) le status de Modיrateur (+) lui sera automatiquement dispensי.',
- '+j AUTOINVITE - L\'utilisateur est automatiquement invitי lors de son identification (AUTH). N\'a rien en rapport avec le CHANFLAG +i qui est appliquי autrement.',
- '+s SECRET - Le Fondateur n\'est pas affichי dans les Accטs du canal. (mis par dיfaut)',
- 'Attributs Restrictifs',
- '+d DEOP - L\'utilisateur n\'est pas autorisי א recevoir le status d\'Opיrateur (@) sur le canal.',
- '+q QUIET - L\'utilisateur n\'est pas autorisי א recevoir le status de Modיrateur (+) sur le canal.'
- ));
- break;
- case 'DEOPALL':
- $cm->notice($client,array(
- 'Syntaxe: DEOPALL <#canal>',
- 'Retire le status d\'Opיrateur (@) א tous les opיrateurs du canal.',
- ));
- break;
- case 'DEVOICEALL':
- $cm->notice($client,array(
- 'Syntaxe: DEVOICEALL <#canal>',
- 'Retire le status de Modיrateur (+) א tous les modיrateurs du canal.',
- ));
- break;
- }
- }
- if(isset($level)&&$level>=900){
- switch(strtoupper($command)){
- case 'SUSPEND':
- $cm->notice($client,array(
- 'Syntaxe: SUSPEND <#canal>',
- 'Le service se retire du canal et n\'autorise pas son utilisation sur ce dernier.',
- 'L\'Attribut +s sera ajoutי au canal.',
- 'Niveau requis: Opיrateur (Niv. 900)'
- ));
- break;
- case 'UNSUSPEND':
- $cm->notice($client,array(
- 'Syntaxe: UNSUSPEND <#canal>',
- 'Le service retourne sur le canal et autorise son utilisation sur ce dernier.',
- 'Application: Attribut de canal Dי-Suspendu ( CHANFLAG +s )',
- 'Niveau requis: Opיrateur (Niv. 900)'
- ));
- break;
- }
- }
- if(isset($level)&&$level==1000){
- switch(strtoupper($command)){
- case "WHOAMI":
- $cm->notice($client,array(
- "Syntaxe: WHOAMI",
- "La commande WHOAMI vous permet d'afficher vos champs de connexion ( pseudo, adresse internet, nom rיel, numיrique, ... )",
- "Elle permet (optionnellement) d'afficher vos information de compte"
- ));
- break;
- case "WHOIS":
- $cm->notice($client,array(
- "Syntaxe: WHOIS <pseudo>",
- "WHOIS permet d'afficher les champs utilisateur bruts d'un pseudo donnי.",
- "En fonction de votre niveau, les informations peuvent ךtre masquיes/affichיes.",
- ));
- break;
- case "ADDUSER":
- $cm->notice($client,array(
- "Syntaxe: ADDUSER <compte> <email@isp.com>",
- "ADDUSER permet de crיer manuellement un compte utilisateur,",
- "par dיfaut, le compte est de niveau 1 et le mot de passe n'est pas rיglי. ( compte dיsactivי )"
- ));
- break;
- case "DELUSER":
- $cm->notice($client,array(
- "Syntaxe: DELUSER <compte>",
- "DELUSER permet de supprimer manuellement un compte utilisateur, cette commande est irrיversible et tous",
- "les accטs salon sont rיcursivement dיtruits.",
- ));
- break;
- case "SETUSER":
- $cm->notice($client,array(
- "Syntaxe: SETUSER <compte> <champ> <valeur>",
- "SETUSER permet de gטrer les champs d'un compte utilisateur.",
- "Les champs disponibles sont: LEVEL, EMAIL, PASSWORD, NOEXPIRES, VHOST",
- "Les champs GREETING sont des champs optionnels et ne sont pas configurables",
- "par les admins, ces champs peuvent ךtre consultיs via la commande GETUSER."
- ));
- break;
- case "GETUSER":
- $cm->notice($client,array(
- "Syntaxe: GETUSER [<champ>]",
- "GETUSER permet d'afficher les champs d'un utilisateur,",
- "si aucun paramטtre n'est fourni, tous les champs seront affichיs."
- ));
- break;
- case "USERINFO":
- $cm->notice($client,array(
- "Syntaxe: USERINFO <compte>",
- "USERINFO permet d'afficher les donnיes d'un compte dans leur intיgralitי,",
- "seuls les administrateurs rיseaux sont abilitיs א utiliser cette commande."
- ));
- break;
- case "ADDCHAN":
- $cm->notice($client,array(
- "Syntaxe: ADDCHAN <#canal> <fondateur>",
- "ADDCHAN permet d'ajouter un canal enregistrי, ce dernier est statique et ne peut ךtre retirי",
- "que par un administrateur rיseau/service ou aprטs expiration de la derniטre date d'utilisation."
- ));
- break;
- case "DELCHAN":
- $cm->notice($client,array(
- "Syntaxe: DELCHAN <#canal>",
- "DELCHAN permet de supprimer un canal enregistrי, supprimant tous les enregistrements ( chanlev, chanflags et chanmode )"
- ));
- break;
- case "CHANSET":
- $cm->notice($client,array(
- "Syntaxe: CHANINFO <#canal> [<champ>]",
- "CHANINFO permet d'afficher les donnיes d'un canal enregistrי. ( chanmode, chanflags, fondateur, crיateur )",
- "Les champs disponibles sont: CHANMODE, CHANFLAGS, FOUNDER, CREATOR"
- ));
- break;
- }
- }
- }
- }elseif(count(self::$data)==3){
- list($client,,) = self::$data;
- $cm->notice($client,array(
- "Commandes sans niveau d'accטs",
- "HELP [<commande>] - Affiche l'aide complטte ou sur la commande spיcifiיe",
- "HELLO <courrier@electronique.com> <courrier@electronique.com> - Demander l'enregistrement de votre compte utilisateur, les adresses de courrier doivent ךtre identiques.",
- "VALIDATE <clef> - Terminer l'enregistrement de votre compte utilisateur, la clef est fournie dans l'email de demande de compte ( voir HELLO )",
- "AUTH <mot-de-passe> - Vous identifier sous votre compte utilisateur"
- ));
- if($r->getaccount($r->getClientaccount($client),'level')!==false){
- $level = $r->getaccount($r->getClientaccount($client),'level');
- echo __CLASS__.": le client $client est de niveau $level\n";
- if($db->isAuthed(self::$data[0])){
- if(isset($level)&&$level>=1){
- $cm->notice(self::$data[0],array(
- "-",
- "Utilisateur Enregistrי ( Niveau 1 )",
- "WHOAMI - Affiche vos champs utilisateur (pseudo, numיrique, status...)",
- "CHANLEV <#canal> - Affiche les accטs utilisateur du canal",
- "CHANFLAGS <#canal> [+/-<chanflags>] - Rטgle les attributs du canal",
- "CHANMODE <#canal> [+/-<chanmode>] - Rטgle les modes du canal",
- ));
- }
- if(isset($level)&&$level>=900){
- $cm->notice(self::$data[0], array(
- "-",
- "Opיrateurs IRC (Niveau 900)",
- "WHOIS <utilisateur> - Affiche les informations sur l'utilisateur",
- "CHANWHO <#canal> - Affiche les informations relatives au canal",
- "CLEARMODE <#canal> [modes a nettoyer] - Retire tous les modes du canal ciblי",
- "KILL <pseudo> [<motif>] - Dיconnecte un utilisateur du rיseau avec ou sans le motif",
- "GLINE <#canal|utilisateur@adresse> [<durיe>] [<motif>] - Exclure un utilisateur/canal du rיseau",
- "SERVERS - Affiche la liste des serveurs connectיs"
- ));
- }
- if(isset($level)&&$level==1000){
- $cm->notice(self::$data[0], array(
- "-",
- "Administrateurs IRC ( Niveau 1000 )",
- "ADDUSER <compte> <email> [<niveau>] - Crיי un compte utilisateur",
- "DELUSER <compte> - Supprime un compte utilisateur",
- "SETUSER <compte> <champ> <valeur> - Modifier les champs d'un compte",
- "ADDCHAN <#canal> <fondateur> [<type de salon>] [<attr salon>]",
- "DELCHAN <#canal> - Supprime un canal",
- "CHANSET <#canal> [<option>] [<arguments>] - Sans option, affiche toutes les informations du canal sinon affiche la valeur de l'option, les arguments modifient la valeur de l'option.",
- "SRAW <token> <paramטtres> - Execute une commande serveur brute ( attention, ceci peut crasher le serveur si mal utilisי )",
- "CRAW <token> <paramטtres> - Execute une commande client brute ( idem )",
- "GLOBALE <message> - Envoie un message par le serveur א tous les opיrateurs connectיs",
- "SHUTDOWN - Stoppe le service ( יteint le processus )",
- "RECONNECT - Redיmarre la connexion au serveur"
- ));
- }
- }
- }
- }
- }
- private static function p_preg(){
- $cm = QCommands::getInstance();
- # PREG <MASQUE> <PHRASE>
- if(preg_match("/^(?<patern>\/[^ ]+[\/ei])\s(?<text>.*+)/",implode(' ', array_slice(self::$data,3)),$cases)){
- $cm->message(self::$data[1],"Requete de PREG avec patron \"".$cases['patern']."\" et le texte ".preg_quote($cases['text'],'/'));
- $result=preg_match($cases['patern'], preg_quote($cases['text'],'/'), $matches);
- if($result>0){
- $cm->message(self::$data[1],"Rיsultat: ".$result);
- foreach($matches AS $key => $match){ $cm->message(self::$data[1], "$key: $match"); }
- }elseif($result==0){
- $cm->message(self::$data[1],"Aucun rיsultat");
- }else{
- switch(preg_last_error()){
- case PREG_BACKTRACK_LIMIT_ERROR:
- $cm->message(self::$data[1],"Erreur: La limite de backslashes est dיpassיe");
- break;
- case PREG_INTERNAL_ERROR:
- $cm->message(self::$data[1],"Erreur interne");
- break;
- case PREG_NO_ERROR:
- $cm->message(self::$data[1],"Aucune erreur");
- break;
- default:
- $cm->message(self::$data[1],"Erreur non prise en charge, veuillez vous rיfיrer א la documentation pcre");
- break;
- }
- }
- }
- }
- private static function p_action(){
- # <SSCCC> <#canal> <:[SOH]ACTION slaps blah with bleh[SOH]>
- if(count(self::$data)>3){
- $db = QDatabase::getInstance();
- $str = implode(' ',array_slice(self::$data,2));
- if(preg_match("/".CL_NICKNAME."/i", $str)){
- $retstring = preg_replace("/".CL_NICKNAME."/i", $db->num2nick(self::$data[0]), $str);
- QCommands::getInstance()->message(self::$data[1],$retstring);
- }
- }
- }
- ###############################################
- # Commandes de niveau 0 (sans enregistrement) #
- ###############################################
- private static function hello(){
- # <SSCCC> <Q_NUM> HELLO <email> <email>
- $cm = QCommands::getInstance();
- if(count(self::$data)==3){QCommands::getInstance()->notice(self::$data[0],array("Syntaxe: HELLO <email> <email>","Pour d'avantage d'informations veuillez utiliser: HELP HELLO"));}
- if(count(self::$data)==5){
- list($client,,,$email1,$email2) = self::$data;
- $db = QDatabase::getInstance();
- $r = QRegister::getInstance();
- $account = $db->num2nick($client);# On rיcupטre le pseudo du client
- if(!$r->isaccount($account)){
- if($email1 === $email2){
- if(filter_var($email1,FILTER_VALIDATE_EMAIL) && !$r->isqueued($account)){
- if(self::mail_verify($email1)){
- $cm->notice($client,"Prיparation du courrier en cours, veuillez patienter");
- $r->addqueued($account,$email1);
- $key = $r->getqueued($account,"key");
- $for = sprintf('%s <%s>',$account,$email1);
- $subject = "Confirmation d'enregistrement de votre compte utilisateur";
- $headers = array(
- "From: \"MadGamerZ IRC\" <QBot@irc.madgamerz.fr>",
- "Reply-To: noreply@irc.madgamerz.fr",
- "Content-Type: text/plain",
- "X-Mailer: PHP-".phpversion()
- );
- $message = array(
- "Cher nouvel utilisateur,",
- "vous avez rיcemment demandי la crיation d'un compte pour l'utilisateur ".$account.".",
- "Afin d'achever la procיdure veuillez effectuer cette commande sur IRC :",
- "/MSG Q VALIDATE ".$key,
- "ATTENTION: ne copiez/collez pas la commande, retappez la entiטrement sur IRC !",
- " ",
- "Merci d'utiliser MadGamerZ IRC"
- );
- $mailed = mail($for,$subject,implode("\r\n",$message),implode("\n",$headers));
- if($mailed==true){
- $cm->notice($client,array(
- "Un courrier יlectronique vous a יtי envoyי afin d'achever la procיdure d'enregistrement,",
- "comme le message est rיdigי en HTML, il est possible que ce dernier arrive dans le dossier SPAM de votre boמte mail."
- ));
- } else { $cm->notice($client,"Une erreur est survenue lors de l'envoi du courrier, veuillez retenter l'opיration."); $r->delqueued($account); }
- } else { $cm->notice($client,"Etes vous sur que ce serveur de messagerie existe ? Erreur MX"); }
- } else { $cm->notice($client,"L'adresse fournie est incorrecte."); }
- } else { $cm->notice($client,"Les deux adresses de courrier יlectronique doivent ךtre identiques."); }
- } else { $cm->notice($client,"Syntaxe: /MSG Q HELLO <adresse@electronique.com> <adresse@electronique.com>"); }
- } else { $cm->notice(self::$data[0],"Ce compte existe dיjא, vous ne pouvez pas l'enregistrer א nouveau."); }
- }
- private static function validate(){
- # Fonction pour achever l'enregistrement du nom utilisateur.
- # <SSCCC> <Q_NUM> VALIDATE <KEYCODE>
- $cm = QCommands::getInstance();
- if(count(self::$data)==3) $cm->notice(self::$data[0],array("Syntaxe: /MSG Q validate <clef>","La clef vous est fournie dans le courriel d'enregistrement."));
- if(count(self::$data)==4){
- list($client,$clef) = self::$data;
- $db = QDatabase::getInstance();
- $r = QRegister::getInstance();
- $account = $db->num2nick($client);
- if($r->isqueued($account)){
- if($clef===$r->getqueued($account,"key")){
- $r->addaccount($account,$r->getqueued($account,"email"),1);
- $r->updateaccount($account,"password",$clef);
- $r->delqueued($account);
- $cm->notice($client,array(
- "L'enregistrement de votre compte est terminי!",
- "Pour l'utiliser veuillez taper: /MSG Q AUTH ".$clef,
- "ATTENTION: le staff de MadGamerZ ne vous demandera jamais votre mot-de-passe ( nous les connaissons )",
- "si quelqu'un vous le demande, veuillez contacter un opיrateur/administrateur au plus vite afin de signaler l'abus.",
- " ",
- "L'יquipe de MadGamerZ IRC vous souhaite un agrיable chat !",
- "Pour de l'aide sur l'utilisation du service, veuillez vous rendre sur #help"
- ));
- }else{
- $try = (int)$r->getqueued($account,"try");
- if($try > 0){
- $cm->notice($client,"La clef fournie est invalide, ".$try." tentatives restantes.");
- $r->setqueued($account,"try",--$try);
- }else{$cm->skill($client,"Tentative d'usurpation d'identitי.");$r->delqueued($account);}
- }
- }else{$cm->notice($client,"Votre compte n'est pas en instance de validation.");}
- }
- }
- private static function auth(){
- $cm = QCommands::getInstance();
- if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: AUTH <mot-de-passe>");
- if(count(self::$data)==4){
- list($client,,,$passwd) = self::$data;
- $db = QDatabase::getInstance();
- $account = $db->num2nick($client);
- if(!$db->isAuthed($client)){
- $r = QRegister::getInstance();
- if($r->isaccount($account)){
- if($r->getaccount($account,'password')!==false && $passwd===$r->getaccount($account,'password')){
- $db = QDatabase::getInstance();
- $r->addAccountclient($account,$client);
- $cm->account($client,$account,$r->getaccount($account,"id"),$r->getaccount($account,"created"),$r->getaccount($account,"level"));
- $db->parsemodes($client,array('+r',$account));
- $cm->notice($client,"Vous ךtes maintenant connectי avec le compte $account");
- $db->updateclient($client,'account',$account);
- if($r->getaccount($account,"vhost")!==false){
- if(($db->getclient($client,"virtualhost")===false) or $db->getclient($client,"virtualhost")!=$r->getaccount($account,"vhost")){
- list($user,$host) = explode("@",$r->getaccount($account,"vhost"));
- $cm->sethost($client,$user,$host);
- $db->parsemodes($client,array('+h',$user.'@'.$host));
- }
- }
- if($db->getclient($client,'channels')!==false&&$db->getclient($client,'channels')!=null){
- $names = $db->getclient($client,'channels');
- print_r($names);
- foreach($names AS $name){
- if($r->isreg($name)&&$r->isChanlev($name,$account)){
- if($r->getChanlev($name,$account,'a')&&!in_array('o',$db->getchanmember($name,$client))){
- $cm->mode($name,'+o',$client);
- }
- if($r->getChanlev($name,$account,'g')&&!in_array('v',$db->getchanmember($name,$client))){
- $cm->mode($name,'+v',$client);
- }
- }
- }
- }else{echo __FUNCTION__,": Le client $client n'a pas de salon.\n";}
- }else{$cm->notice($client,"Le mot-de-passe fourni n'est pas valide ou le mot-de-passe pour ce compte n'existe pas.");}
- }else{$cm->notice($client,"Le compte liי א votre pseudo n'existe pas");}
- }else{$cm->notice($client,"Vous utilisez actuellement un compte utilisateur, veuillez vous reconnecter.");}
- }
- }
- ##
- # Fonctions nickserv
- ##
- private static function requestnick(){
- $cm=QCommands::getInstance();
- if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: REQUESTNICK <pseudo> <mot-de-passe>");
- if(count(self::$data)==4){
- list($client,,$account,$password)=self::$data;
- $r = QRegister::getInstance();
- if($r->isaccount($account)){
-
- }
- }
- }
- ##
- # Commandes de niveau 1 (utilisateur enregistrי)
- ##
- private static function whoami(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- if(count(self::$data)==1){
- list($client,) = self::$data;
- if($db->isAuthed($client)){
- $account = $db->getclient($client,'account');
- $r = QRegister::getInstance();
- $chars = QChars::getInstance();
- $cm->notice($client,array(
- "Identitי: ".$db->getclient($client,'nickname')." ".$db->getclient($client,'hostname')."@".$db->getclient($client,'username'),
- "Nom rיel: ".$db->getclient($client,'realname'),
- "Numיrique: ".$db->getclient($client,'numeric'),
- "Ip 64bits: ".$db->getclient($client,'b64ip'),
- "Modes: ".$db->getclient($client,'usermode')." (hex: ".$chars->usermode_encode(substr($db->getclient($client,'usermode'),1)).")")
- );
- if($db->isAdmin($client)){ $cm->notice($client,'Administrateur IRC'); }
- elseif($db->isOper($client)){ $cm->notice($client,'Opיrateur IRC'); }
- else { $cm->notice($client,"Utilisateur IRC"); }
- if($db->getclient($client,'opername')!==false){ $cm->notice($client, "Nom d\'opיrateur: ".$db->getclient($client,'opername')); }
- if($db->getclient($client,'virtualhost')!==false){ $cm->notice($client, "Hפte virtuel: ".$db->getclient($client,'virtualhost')); }
- $cm->notice($client,array(
- "Dיtails de votre compte utilisateur",
- "Id utilisateur: ".$r->getaccount($account,'id'),
- "Niveau du compte: ".$r->getaccount($account,'level'),
- "Date et heure de crיation: ".strftime('%c',$r->getaccount($account,'created'))
- )
- );
- }
- } else { $cm->notice(self::$data[0],'Syntaxe: WHOAMI'); }
- }
- }
- private static function settopic(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- $r = QRegister::getInstance();
- $account = $db->getclient(self::$data[0],'account');
- if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: SETTOPIC <#canal> [<nouveau sujet>]");
- if(count(self::$data)==4){# Consultation
- list($client,,,$name) = self::$data;
- if($r->isreg($name)){
- if($r->isChanlev($name,$account)){
- if($r->getChanlev($name,$account,'t')||$r->getChanlev($name,$account,'m')||$r->getChanlev($name,$account,'n')){
- if($r->getreg($name,"topic")!==false){ $cm->notice($client,"Le sujet du canal $name est: ".$r->getreg($name,"topic")); }
- else { $cm->notice($client,"Aucun sujet n'a יtי choisi pour ce canal."); }
- } else { $cm->notice($client,"Votre niveau d'accטs sur $name ne vous permet pas d'utiliser SETTOPIC."); }
- } else { $cm->notice($client,"Vous n'avez pas d'accטs sur $name"); }
- } else { $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי."); }
- }
- if(count(self::$data)>4){# Rיglage
- list($client,,,$name) = self::$data;
- if($r->isreg($name)){
- if($r->isChanlev($name,$account)){
- if($r->getChanlev($name,$account,'t')||$r->getChanlev($name,$account,'m')||$r->getChanlev($name,$account,'n')){
- $str=implode(' ',array_slice(self::$data,4));
- $cm->topic($name,$str);
- $db->updatechan($name,'topic',$str);
- $r->updatereg($name,"topic",$str);$cm->notice($client,"Effectuי");
- } else { $cm->notice($client,"Votre niveau d'accטs sur $name ne vous permet pas d'utiliser SETTOPIC."); }
- } else { $cm->notice($client,"Vous n'avez pas d'accטs sur $name"); }
- } else { $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי."); }
- }
- } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
- }
- private static function welcome(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: WELCOME <#canal> [message de bienvenue]");
- if(count(self::$data)==4){ // Consultation
- list($client,,,$name) = self::$data;
- if($r->isreg($name)){
- if($r->isChanlev($name,$account)){
- if($r->getChanlev($name,$account,'m')||$r->getChanlev($name,$account,'n')){
- if($r->getreg($name,"welcome")!==false && $r->getreg($name,"welcome")!=null){ $cm->notice($client,"Le message d'accueil du canal $name est: ".$r->getreg($name,"welcome")); }
- else{$cm->notice($client,"$name: aucun message d'accueil n'a יtי dיfini."); }
- }else{$cm->notice($client,"Votre niveau d'accטs sur $name ne vous permet pas d'utiliser WELCOME."); }
- } else {$cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande."); }
- } else { $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי."); }
- }elseif(count(self::$data)>4){ // Rיglage
- list($client,,,$name,) = self::$data;
- if($r->isreg($name)){
- if($r->isChanlev($name,$account)){
- if($r->getChanlev($name,$account,'m')||$r->getChanlev($name,$account,'n')){
- $str = implode(' ',array_slice(self::$data,4));
- $r->updatereg($name,"welcome",$str);
- $cm->notice($client,"Effectuי");
- } else { $cm->notice($client,"Votre niveau d'accטs sur $name ne vous permet pas d'utiliser WELCOME."); }
- } else { $cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande."); }
- } else { $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי."); }
- }
- } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
- }
- private static function chanlev(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- print_r(self::$data);
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if(count(self::$data)==3){$cm->notice(self::$data[0],'Syntaxe: CHANLEV <#canal> [<compte>] [<+/-droits>]');}
- if(count(self::$data)==4){# Consultation globale
- list($client,,,$name)=self::$data;
- if($r->isreg($name)){
- if($r->isChanlev($name,$account)){
- $cm->notice($client,array(
- "Information sur le canal ".$name,
- "Fondateur: ".$r->getreg($name,'founder'),
- "Ajoutי par l'administrateur ".$r->getreg($name,'adder').", le ".strftime("%A %d %B %Y א %X",$r->getreg($name,'created')),
- " ",
- "Compte - Accטs"
- ));
- $chars = QChars::getInstance();
- $levs = $r->getreg($name,"chanlev");# Attention, renvoie un tableau
- foreach($levs AS $acc => $lev) $cm->notice($client,$acc." - ".$chars->chanlev_decode($lev));
- }else $cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande.");
- }else $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי.");
- }
- if(count(self::$data)==5){# Consultation individuelle
- list($client,,,$name,$uaccount) = self::$data;
- if($r->isreg($name)){
- if($r->isChanlev($name,$account)){
- if($r->isChanlev($name,$uaccount)){$cm->notice($client,"Chanlev de $uaccount sur $name: ".$r->getRegaccount($name,$uaccount));}
- else{$cm->notice($client,"Il semble que le compte utilisateur $uaccount n'ai pas d'accטs sur $name.");}
- }
- }else{$cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי");}
- }
- if(count(self::$data)==6){# Modification
- list($client,,,$name,$uaccount,$flags) = self::$data;
- if($r->isreg($name)){
- if($r->isChanlev($name,$account)){
- if($r->isChanlev($name,$uaccount)){
- if(preg_match('#^[\-\+]([abdgmnoqstvw]+)#',$flags,$changes)){
- $attribs = str_split($changes[1]);
- if(in_array(array('n','m','o','v','t'),$attribs)){
- if(in_array('n',$attribs)){
- if($r->getChanlev($name,$account,'f')){$r->parseChanlev($name,$uaccount,$flags);$cm->notice($client,'Effectuי');}
- else{$cm->notice($client,"Vous n'avez pas les droits nיcessaires sur $name pour modifier ce CHANLEV");}
- }
- if(in_array('m',$attribs)){
- if($r->getChanlev($name,$account,'f')||$r->getChanlev($name,$account,'n')){
- $r->parseChanlev($name,$uaccount,$flags);$cm->notice($client,'Effectuי');
- }else{$cm->notice($client,"Vous n'avez pas les droits nיcessaires sur $name pour modifier ce CHANLEV");}
- }
- if(in_array(array('a','o','g','v','t'),$attribs)){
- if($r->getChanlev($name,$account,'f')||$r->getChanlev($name,$account,'n')||$r->getChanlev($name,$account,'m')){
- $r->parseChanlev($name,$uaccount,$flags);$cm->notice($client,'Effectuי');
- }else{$cm->notice($client,"Vous n'avez pas les droits nיcessaires sur $name pour modifier ce CHANLEV");}
- }
- }else{$r->parseChanlev($name,$uaccount,$flags);}
- //$r->parseChanlev($name,$account,$flags);// Routine externe
- $cm->notice($client,"Chanlev de $uaccount sur $name: ".$r->getRegaccount($name,$uaccount));
- }else $cm->notice($client,"L'un des attributs semble incorrect.");
- }else $cm->notice($client,"Il semble que le compte utilisateur $account n'ai pas d'accטs sur $name.");
- }else $cm->notice($client,"Vous n'avez pas d'accטs sur $name.");
- }else $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי");
- }
- }else{$cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
- }
- private static function chanflags(){
- print_r(self::$data);
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if(count(self::$data)==3){$cm->notice(self::$data[0],'Syntaxe: CHANFLAGS <#canal> [<+/-attributs>]');}
- if(count(self::$data)==4){
- list($client,,,$name) = self::$data;
- if($r->isreg($name)){
- if($r->isChanlev($name,$account)){
- $chars = QChars::getInstance();
- $chanflags = $chars->chanflags_decode($r->getreg($name,"chanflags"));
- $cm->notice($client,"Le chanflag du canal ".$name." est: +".$chanflags);
- } else { $cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande."); }
- } else { $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי"); }
- }
- if(count(self::$data)==5){
- list($client,,$name,$flags) = self::$data;
- if($r->isreg($name)){
- if($r->isChanlev($name,$account)){
- if($r->getChanlev($name,$account,'n')||$r->getChanlev($name,$account,'m')){
- $r->parseChanflags($name,$flags);
- $chars = QChars::getInstance();
- $cm->notice($client,"Les modes du canal $name sont actuellement: +".$chars->chanflags_decode($r->getreg($name,"chanflags")));
- }else{$cm->notice($client,"Vous n'avez pas le niveau d'accטs requis pour modifier les CHANFLAGS de $name");}
- }else{$cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande.");}
- }else{$cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי");}
- }
- }else{$cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
- }
- # CHANMODE <#canal> [<changements>]
- private static function chanmode(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if(count(self::$data)==3) $cm->notice(self::$data[0],'Syntaxe: CHANMODE <#canal> [<+/-modes>]');
- if(count(self::$data)==4){ // Consultation
- list($client,,$name)=self::$data;
- $r = QRegister::getInstance();
- if($r->isreg($name)){
- if($r->isChanlev($name,$account)){
- if($r->getaccount($account,'level')>=900||$r->getChanlev($name,$account,'n')||$r->getChanlev($name,$account,'m')){
- $chars = QChars::getInstance();
- $chanmode = $chars->chanmode_decode($r->getreg($name,'chanmode'));
- $cm->notice($client,"Les modes du canal ".$name." sont actuellement: +".$chanmode);
- }else{$cm->notice($client,"Vous n'avez pas le niveau d'accטs requis pour consulter le CHANMODE de ce canal");}
- }else{$cm->notice($client,"Vous devez possיder un accטs sur ".$name." pour utiliser cette commande.");}
- }else{$cm->notice($client,"Le canal ".$name." semble ne pas ךtre enregistrי");}
- }elseif(count(self::$data)==5){ // Rיglage
- list($client,,$name,$modes)=self::$data;
- $r = QRegister::getInstance();
- if($r->isreg($name)){
- if($r->isChanlev($name,$account)){
- if($r->getaccount($account,'level')>=900||$r->getChanlev($name,$account,'n')||$r->getChanlev($name,$account,'m')){
- $r->parseChmodes($name,$modes);
- $chars = QChars::getInstance();
- if($r->ischanflag($name,'m')){# Si ModeLock actif, les modes sont modifiיs directement par le service
- $cm->mode($name,'-imnpstrDdRucCNMT+'.$chars->chanmode_decode($r->getreg($name,'chanmode')),null);
- $cm->snotice($client,"modelock: les modes de $name ont יtיs modifiיs sans prיavis.");
- }
- $cm->notice($client,"Les modes du canal $name sont maintenant: +".$chars->chanmode_decode($r->getreg($name,'chanmode')));
- }else{$cm->notice($client,"Vous n'avez pas le niveau d'accטs nיcessaire sur $name pour modifier le CHANMODE");}
- }else{$cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande.");}
- }else{$cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי");}
- }
- }else{$cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
- }
- # DEOPALL <#canal>
- private static function deopall(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if(count(self::$data)==2) $cm->notice(self::$data[0],"Syntaxe: DEOPALL <#canal>");
- if(count(self::$data)==3){
- list($client,,$name)=self::$data;
- if($r->isreg($name)){
- if($r->isChanlev($name,$account)){
- if($r->getaccount($account,'level')>=900||$r->getChanlev($name,$account,'n')||$r->getChanlev($name,$account,'m')){
- $clients = $db->getchanmembers($name);
- if($clients!==false){
- foreach($clients AS $client => $modes){if(strpos($modes,'o')!==false){$queue[]=$client;$db->updatechanmember($name,$client,array('-'=>'o'));}}
- $i=count($queue);$deop=array();
- while($i){
- $deop[]=$queue[$i-1];
- if(count($deop)==6){$cm->mode($name,'-oooooo',implode(' ',$deop));$deop=array();}
- $i--;
- }
- if(count($deop)>0){$cm->mode($name,'-'.str_repeat('o',count($deop)),implode(' ',$deop));}
- }
- }else{$cm->notice($client,"Vous n'avez pas le niveau d'accטs nיcessaire sur $name pour utiliser DEOPALL");}
- }else{$cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande.");}
- }else{$cm->notice(self::$data[0],"Le canal $name semble ne pas ךtre enregistrי");}
- }
- }else{$cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
- }
- private static function opall(){
- $db=QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){# L'utilisateur est identifiי ?
- $acc = $db->getclient(self::$data[0],'account');# Nous rיcupיrons le compte utilisateur.
- if(count(self::$data)==2) QCommands::getInstance()->notice(self::$data[0],array("Syntaxe: DEOPALL <#canal>","Vous devez ךtre maמtre (+m) au minimum."));
- if(count(self::$data)==3){
- list($client,,$name)=self::$data;
- $r = QRegister::getInstance();
- if($r->isreg($name)&&$r->ischanlev($name,$acc)){# Le canal est enregistrי et l'utilisateur y a accטs ?
- QCommands::getInstance()->notice($client,"Veuillez patienter...");
- if(($r->getchanlev($name,$acc,'m')||$r->getchanlev($name,$acc,'n'))||($db->isoper($client)||$db->isadmin($client))){
- foreach($db->getchanmembers($name) AS $client => $modes){
- if(strpos($modes,'o')===false){$queue[]=$client;$db->updatechanmember($name,$client,array('+'=>'o'));}
- }
- }
- } else { QCommands::getInstance()->notice(self::$data[0],"Soit le canal ".$name." n'est pas enregistrי, soit vous n'avez pas d'accטs sur ce dernier."); }# Protection pour יviter de vיrifier l'enregistrement d'un canal via la commande.
- }
- } else { QCommands::getInstance()->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
- }
- private static function voice(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- $r = QRegister::getInstance();
- $account = $db->getclient(self::$data[0],'account');
- if(count(self::$data)==2) $cm->notice(self::$data[0],'Syntaxe: VOICE <#canal>');
- if(count(self::$data)==3){
- list($client,,$name)=self::$data;
- if($r->isreg($name)){
- list($client,,$name) = self::$data;
- if($r->isChanlev($name,$account)){
- if($r->getChanlev($name,$account,'v')){
- $db->updatechanmember($name,$client,array('+'=>'v'));
- $cm->mode($name,"+v",$client);
- $cm->notice($client,"Effectuי");
- }
- } else { $cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande."); }
- } else { $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי"); }
- }
- } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
- }
- private static function op(){
- return;
- }
- ##
- # Commandes de niveau 9 (opיrateur irc)
- ##
- private static function whois(){
- # 0 1 2
- # <src> WHOIS <cible>
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- $r = QRegister::getInstance();
- if($r->getaccount($db->getclient(self::$data[0],'account'),'level')>=900){
- if(count(self::$data)==3) $cm->notice(self::$data[0],'Syntaxe: WHOIS <pseudo>');
- if(count(self::$data)==4){
- list($client,,,$target)=self::$data;
- if(preg_match('/^\#([^ ]+)/',$target,$match)){
- if($r->isaccount($match[1])){
- $cm->notice($client,array(
- "Compte ".$match[1],
- "Identifiant: ".$r->getaccount($match[1],'id'),
- "Niveau: ".$r->getaccount($match[1],'level'),
- "Date de crיation: ".strftime("%A %d %B %Y א %X",$r->getaccount($match[1],'created'))
- ));
- }
- } else {
- if($db->nick2num($target)!==false){
- $target = $db->nick2num($target);
- $cm->notice($client,array(
- $db->getclient($target,"nickname")." (".$db->getclient($target,'username')."@".$db->getclient($target,'hostname').") * ".$db->getclient($target,'realname'),
- "modes: ".$db->getclient($target,'usermode'),
- "numיrique: ".$db->getclient($target,'numeric'),
- "ip 64bits (ircu): ".$db->getclient($target,'b64ip'),
- "s'est connectי le ".strftime("%A %d %B %Y א %X",$db->getclient($target,'connts'))
- ));
- if($db->getclient($target,"account")!==false) $cm->notice($client,"Compte: ".$db->getclient($target,'account'));
- if($db->getclient($target,"virtualhost")!==false) $cm->notice($client,"Adresse virtuelle: ".$db->getclient($target,'virtualhost'));
- } else { $cm->notice($client,"Cet utilisateur n'existe pas sur le rיseau."); }
- }
- }
- } else { $cm->notice(self::$data[0],"Votre niveau d'accטs n'est pas suffisant pour utiliser cette commande."); }
- } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
- }
- private static function chanwho(){
- $cm = QCommands::getInstance();
- if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: CHANWHO <#canal>");
- if(count(self::$data)==4){
- list($client,,$name) = self::$data;
- $db = QDatabase::getInstance();
- if($db->ischan($name)){
- $cm->notice($client,array(
- "Nom: ".$name,
- "Date de crיation: ".strftime("%c",$db->getchan($name,"created")),
- "Modes: ".$db->getchan($name,"modes"),
- "Sujet: ".$db->getchan($name,"topic")
- ));
- if($db->getchanmembers($name)!==false){
- $cm->notice($client,"Utilisateurs prיsents sur le salon:");
- $users = $db->getchanmembers($name);
- foreach($users AS $numeric => $mode){
- $cm->notice($client,$db->num2nick($numeric).(!empty($mode) ? " [".$mode."]" : null));
- }
- } else { $cm->notice($client,"Ce salon ne compte actuellement aucun membre."); }
- }
- }
- }
- private static function desynch(){
- $cm = QCommands::getInstance();
- if(isset(self::$data[2])){ $cm->desynch(implode(" ",array_slice(self::$data,2))); }
- }
- private static function join(){
- $c = QConfig::getInstance();
- $db = QDatabase::getInstance();
- $cm = QCommands::getInstance();
- echo count(self::$data);
- if(count(self::$data)==3){
- list($client,,$name) = self::$data;
- if($db->isOper($client)){
- if(!$db->ischan($name)){
- $db->addchan($name, null, null, null, null);
- $cm->join($name);
- $cm->smode($name,"+o",SV_NUMERIC.CL_NUMERIC);
- } else { $cm->notice($client,"Ce salon existe dיjא, je ne peux le rejoindre"); }
- } else { $cm->notice($client,"Cette commande est rיservיe aux opיrateurs IRC"); }
- } else { $cm->notice($client,array("utilisation: JOIN <#salon>","Noter que cette commande fait simplement joindre le salon au bot.","Le salon ne sera pas conservי en mיmoire.")); }
- }
- private static function part(){
- $db = QDatabase::getInstance();
- $cm = QCommands::getInstance();
- if(count(self::$data)==3){
- list($client,,$name) = self::$data;
- if($db->isOper($client)){
- if($db->ischan($name)){
- $db->delchan($name);
- $cm->part($name);
- $cm->notice($client,"Effectuי");
- }
- } else { $cm->notice($client,"Cette commande est rיservיe aux opיrateurs IRC"); }
- } else { $cm->notice($client,array("utilisation: PART <#salon>","Cette commande fait partir le bot d'un salon temporaire.")); }
- }
- private static function kill(){
- $db = QDatabase::getInstance();
- $cm = QCommands::getInstance();
- if($db->isAuthed(self::$data[0])){
- $r = QRegister::getInstance();
- $level = $r->getaccount($db->getclient(self::$data[0],'account'),'level');
- if($level>=900){
- if(count(self::$data)==2){$cm->notice(self::$data[0],'Syntaxe: KILL <cible> [<motif>]');}
- if(count(self::$data)>=3){
- print_r(self::$data);
- list($client,,$nick) = array_slice(self::$data,2);
- //list($client,,$nick) = array_slice(self::$data,0,2);
- $nicknum = $db->nick2num($nick);
- if(count(self::$data)>3) $str = implode(' ',array_slice(self::$data,4));
- if($db->isAuthed($nicknum)){
- $ulevel = $r->getaccount($db->getclient($nicknum,'account'),'level');
- if($ulevel<$level){
- if(isset($str)) $cm->skill($nicknum,$str);
- else $cm->skill($nicknum,'Dיconnectי.');
- }else{$cm->notice($client,'Vous ne pouvez pas dיconnecter un utilisateur d\'un niveau supיrieur ou יgal au votre.');}
- }else{
- if(isset($str)) $cm->skill($nicknum,$str);
- else $cm->skill($nicknum,'Dיconnectי.');
- }
- }
- }else{$cm->notice(self::$data[0],'Votre niveau d\'accטs ne vous autorise pas א utiliser cette commande.');}
- }else{$cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
- }
- private static function who(){
- $db = QDatabase::getInstance();
- $cm = QCommands::getInstance();
- if($db->isOper(self::$data[0])){
- $cm->who(self::$data[3],null);
- $this->who_replyto = self::$data[0];
- }
- }
- private static function servers(){
- $db = QDatabase::getInstance();
- if($db->isOper(self::$data[0])){
- $cm = QCommands::getInstance();
- $servers = $db->listServers();
- foreach($servers AS $servnum => $server){
- $cm->notice(self::$data[0],array(
- "Nom du serveur: ".$server["name"]." (".$server["hops"]." hops)",
- "Dיmarrי le ".strftime('%c',$server["connts"])." et reliי le ".strftime('%c',$server["linkts"]),
- "Numיrique: ".substr($server["numaxcl"],0,2),
- "Attributs de protocole: ".$server["flags"],
- "Description: ".$server["description"]
- ));
- }
- }
- }
- ##################################################
- ####### Commandes Administrateurs (1000) #########
- ##################################################
- private static function clvenc(){
- $cl = self::$data[2];
- $cm = QCommands::getInstance();
- $chars = QChars::getInstance();
- if(count(self::$data)==3){$cm->notice(self::$data[0],"rיsultat: ".$chars->chanlev_encode($cl));}
- else{$cm->notice(self::$data[0],'Syntaxe: CLVENC <flags>');}
- }
- private static function clvdec(){
- $cl = self::$data[2];
- $cm = QCommands::getInstance();
- $chars = QChars::getInstance();
- $cm->notice(self::$data[0],"rיsultat: ".$chars->chanlev_decode($cl));
- }
- private static function chmenc(){
- $cl = self::$data[2];
- $cm = QCommands::getInstance();
- $chars = QChars::getInstance();
- $cm->notice(self::$data[0],"rיsultat: ".$chars->chanmode_encode($cl));
- }
- private static function chmdec(){
- $cl = self::$data[2];
- $cm = QCommands::getInstance();
- $chars = QChars::getInstance();
- $cm->notice(self::$data[0],"rיsultat: ".$chars->chanmode_decode($cl));
- }
- private static function adduser(){
- $cm = QCommands::getInstance();
- if($db->isAuthed(self::$data[0])){
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if($r->getaccount($account,"level")==1000){
- if(count(self::$data)==4){# adduser <compte> <mail@isp.com>
- list($client,,$uaccount,$email) = self::$data;
- if(!$r->isaccount($uaccount)){
- if(filter_var($email,FILTER_VALIDATE_EMAIL)){$r->addaccount($uaccount,$email,1);$cm->notice($client,"Effectuי");}
- }else{$cm->notice($client,"Le compte que vous tentez de crיer existe dיjא.");}
- }
- elseif(count(self::$data)==5){# adduser <compte> <mail@isp.com> <niveau>
- list($client,,$uaccount,$email,$ulevel) = self::$data;
- if(!$r->isaccount($uaccount)){
- if(filter_var($email,FILTER_VALIDATE_EMAIL) && is_numeric($ulevel)){
- if($r->getaccount($account,"level")>$ulevel){
- $r->addaccount($uaccount,$email,$ulevel);
- $cm->notice($client,"Effectuי");
- }else{$cm->notice($client,"Vous ne pouvez pas ajouter un compte d'un niveau d'accטs supיrieur ou יgal au votre.");}
- }else{$cm->notice($client,"Soit l'adresse de courrier יlectronique fournie est fausse, soit le niveau d'accטs n'est pas un nombre.");}
- }else{$cm->notice($client,"Le compte que vous tentez de crיer existe dיjא.");}
- }else{$cm->notice(self::$data[0],"Syntaxe: ADDUSER <compte> <courrier@electronique.com> [<niveau d'accטs>]");}
- }else{$cm->notice(self::$data[0],"Votre niveau d'accטs n'est pas suffisant pour utiliser cette commande.");}
- }else{$cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
- }
- private static function deluser(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if($r->getaccount($account,'level')==1000){
- if(count(self::$data)==2){$cm->notice(self::$data[0],'Syntaxe: DELUSER <compte>');}
- elseif(count(self::$data)==3){
- list($client,,$uaccount) = self::$data;
- if($r->isaccount($uaccount)){
- $ulevel = $r->getaccount($uaccount,'level');
- if($ulevel<$r->getaccount($account,'level')){$r->delaccount($account);$cm->notice($client,"Le compte $account a יtי dיtruit");}else{$cm->notice($client,'Vous ne pouvez pas dיtruire un compte d\'un niveau supיrieur ou יgal au votre.');}
- }else{$cm->notice($client,"Impossible, le compte $account n'existe pas");}
- }
- }else{$cm->notice(self::$data[0],'Votre niveau d\'accטs n\'est pas suffisant pour utiliser cette commande.');}
- }else{$cm->notice(self::$data[0],'Vous devez ךtre identifiי pour utiliser cette commande.');
- }
- }
- private static function setuser(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- $r = QRegister::getInstance();
- $account = $db->getclient(self::$data[0],'account');
- if(($level=$r->getaccount($account,'level'))==1000){
- if(count(self::$data)==3||count(self::$data)==4){$cm->notice(self::$data[0],array('Syntaxe: SETUSER <compte> [<champ>] [<argument>]','Les champs: EMAIL, LEVEL, PASSWORD, GREETING, VHOST et NOEXPIRES prennent un ou plusieurs argument.'));}
- if(count(self::$data)>=5){
- print_r(self::$data);
- list($client,,,$account,$field,$value) = self::$data;
- if($r->isaccount($account)){
- switch(strtoupper($field)){
- case 'NOEXPIRES':
- if($value=="oui"){
- $r->updateaccount($account,'noexpires',1);
- $cm->notice($client,"Le compte $account n'expirera pas.");
- }elseif($value=="non"){
- $r->updateaccount($account,'noexpires',0);
- $cm->notice($client,"Le compte ".$account." expirera aprטs 90 jours sans utilisation.");
- }else{ $cm->notice($client,"La valeur ".$value." pour NOEXPIRES est incorrecte, veuillez utiliser \'oui\' ou \'non\'."); }
- break;
- case 'EMAIL':
- if(filter_var($value,FILTER_VALIDATE_EMAIL)){
- $r->updateaccount($account,$field,$value);$cm->notice($client,"Email du compte ".$account." reglי sur ".$value);
- }else{
- $cm->notice($client,'Cette adresse email n\'est pas valide.');
- }
- break;
- case 'LEVEL':
- if(is_numeric($value)){
- $r->updateaccount($account,$field,$value);$cm->notice($client,"Niveau utilisateur du compte ".$account." reglי sur ".$value);
- }else{
- $cm->notice($client,'Cet argument n\'est pas de type numיrique.');
- }
- break;
- case 'PASSWORD':
- $r->updateaccount($account,$field,$value);
- $cm->notice($client,"Le mot-de-passe du compte ".$account." a יtי modifiי pour ".$value);
- break;
- case 'GREETING':
- if(isset($value)){
- $greeting=implode(' ',array_slice(self::$data,5));$r->updateaccount($account,"greeting",$greeting);$cm->notice($client,"Le message d'accueil pour le compte ".$account." a יtי dיfini sur ".$greeting);
- }else{
- $r->updateaccount($account,"greeting",null);$cm->notice($client,"Le message d'accueil pour le compte ".$account." a יtי effacי");
- }
- break;
- case 'VHOST':
- if(preg_match("/^[\w\d]{2,11}\@[\w\d\-\.]+$/",$value)){
- $r->updateaccount($account,$field,$value);
- $cm->notice($client,"L'hפte virtuel pour le compte ".$account." a יtי dיfini sur ".$value);
- } else { $cm->notice($client,"L'hפte renseignי n'est pas valide."); }
- break;
- default:
- $cm->notice($client,array('Ce champ n\'existe pas, les champs disponibles sont:',
- 'EMAIL <adresse@mail.com>','LEVEL <1-999>','PASSWORD <mot-de-passe>','GREETING <phrase d\'accueil>','VHOST <prefixe@hotevirtuel.com>'
- ));
- break;
- }
- } else $cm->notice($client,"Le compte demandי n'existe pas.");
- }
- } else $cm->notice(self::$data[0],'Votre niveau d\'accטs ne vous autorise pas א utiliser cette commande.');
- } else $cm->notice(self::$data[0],'Vous devez ךtre identifiי pour utiliser cette commande.');
- }
- private static function getuser(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- $r = QRegister::getInstance();
- $account = $db->getclient(self::$data[0],'account');
- if($r->getaccount($account,'level')==1000){
- if(count(self::$data)==3) $cm->notice(self::$data[0],'Syntaxe: GETUSER <compte> [<champ>]');
- if(count(self::$data)==4){
- list($client,,,$account)=self::$data;
- if($r->isaccount($account)){
- $cm->notice($client,array(
- "Niveau du compte: ".$r->getaccount($account,'level'),
- "Courrier יlectronique: ".$r->getaccount($account,'email'),
- "Mot-de-passe: ".$r->getaccount($account,'password'),
- "Enregistrי le ".strftime("%c",$r->getaccount($account,"created"))
- ));
- if($r->getaccount($account,'noexpires')===false){$r->updateaccount($account,'noexpires',1);
- }else{
- if($r->getaccount($account,'noexpires')==0){$cm->notice($client,"Le compte expirera.");}else{$cm->notice($client,"Le compte n'expirera pas.");}
- }
- if($r->getAccountclients($account)!==false){
- $cm->notice($client,"Utilisateurs du compte:");
- $users = $r->getAccountclients($account);
- foreach($users AS $user){ $cm->notice($client,$db->num2nick($user)." [Numיrique: $user]"); }
- }
- }else{$cm->notice($client,"Le compte demandי n'existe pas.");}
- }
- elseif(count(self::$data)==5){
- list($client,,$account,$field) = self::$data;
- if($r->isaccount($account)){
- switch(strtoupper($field)){
- case "LEVEL":$cm->notice($client,"Le niveau du compte $account est de ".$r->getaccount($account,"level"));break;
- case "EMAIL":$cm->notice($client,"Le courrier יlectronique du compte $account est ".$r->getaccount($account,"email"));break;
- case "PASSWORD":$cm->notice($client,"Le mot-de-passe du compte $account est ".$r->getaccount($account,"password"));break;
- case "VHOST":
- if($r->getaccount($account,"vhost")!==false){$cm->notice($client,"L'adresse virtuelle du compte $account est: ".$r->getaccount($account,"vhost"));}else{$cm->notice($client,"L'adresse virtuelle du compte $account n'a pas יtי choisie.");}
- break;
- case "NOEXPIRES":
- if($r->getaccount($account,'noexpires')==0){$cm->notice($client,"Le compte $account expirera.");}else{$cm->notice($client,"Le compte $account n'expirera pas.");}
- break;
- case "CLIENTS":
- if($r->getAccountclients($account)!==false){
- $cm->notice($client,"Utilisateurs du compte:");
- $users = $r->getAccountclients($account);
- foreach($users AS $user){$cm->notice($client,$db->num2nick($user)." [Numיrique: $user]");}
- }
- break;
- default:
- if($r->getaccount($account,$field)===false){$cm->notice($client,"Ce champ est inconnu ou vous n'y avez pas accטs.");}else{$cm->notice($client,"Valeur du champ $field: ".$r->getaccount($account,$field));}
- break;
- }
- }else{$cm->notice($client,"Le compte demandי n'existe pas.");}
- }
- }else{$cm->notice(self::$data[0],"Votre niveau d'accטs n'est pas suffisant pour utiliser cette commande.");}
- }else{$cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
- }
- #############################################
- ######### Fonctions sur les canaux ##########
- #############################################
- private static function addchan(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if($r->getaccount($account,'level')>=900){
- if(count(self::$data)<=4) $cm->notice(self::$data[0],"Syntaxe: ADDCHAN <#canal> <[#]fondateur>");
- if(count(self::$data)==5){
- # addchan #salon <fondateur>
- list($client,,,$name,$account) = self::$data;
- $r = QRegister::getInstance();
- if(!$r->isreg($name)){
- if($r->isaccount($account)){
- $db = QDatabase::getInstance();
- # addreg($name,$founder,$oper,$chantype=null,$chanflags=null)
- $r->addreg($name,$account,$db->num2nick($client),null,null);
- # addchan($name,$created,$modes=null,$topic=null,$clients=null,$bans=null)
- $db->addchan($name,time(),null,null,null,null);
- $cm->notice($client,"Le salon $name a יtי enregistrי sur le compte $account.");
- $cm->join($name);
- $cm->smode($name,"+o",SV_NUMERIC.CL_NUMERIC);
- $cm->clearmode($name,"klimnpstrDdRucCNMT");
- $cm->mode($name,"+ntCN",null);
- }else{$cm->notice($client,"Le compte $account n'existe pas.");}
- }else{$cm->notice($client,"Le salon $name est dיjא enregistrי.");}
- }
- }else{$cm->notice(self::$data[0],'Votre niveau d\'accטs n\'est pas suffisant pour utiliser cette commande.');}
- }else{$cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
- }
- private static function delchan(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){# L'utilisateur est identifiי ?
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if($r->getaccount($account,"level")>=900){
- if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: DELCHAN <#canal>");
- if(count(self::$data)==4){# delchan #canal
- list($client,,,$name) = self::$data;
- if($r->isreg($name)){
- $r->delreg($name);
- $cm->part($name);
- $cm->notice($client,"Effectuי");
- } else { $cm->notice($client,"Le canal $name n'est pas enregistrי."); }
- }
- } else $cm->notice(self::$data[0],"Votre niveau d'accטs est insuffisant pour executer cette commande.");
- } else $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");
- }
- private static function chanset(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){# L'utilisateur est identifiי ?
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if($r->getaccount($account,"level")>=900){
- if(count(self::$data)==3) $cm->notice(self::$data[0],'Syntaxe: CHANSET <#canal> [<utilisateur>] [<+/-flags>]');
- if(count(self::$data)==4){# chanset <#canal> - Consultation des options
- list($client,,$name) = self::$data;
- if($r->isreg($name)){
- $chars = QChars::getInstance();
- $cm->notice($client,array(
- 'Nom du canal: '.$r->getreg($name,'name'),// חa peut sembler יtrange mais $name renvoie la clef et non le nom du canal
- 'Enregistrי le '.strftime('%c',$r->getreg($name,'created')).' par l\'opיrateur '.$r->getreg($name,'adder'),
- 'Fondateur: '.$r->getreg($name,'founder'),
- 'Type de canal: '.$r->getreg($name,'chantype'),
- 'Modes: +'.$chars->chanmode_decode($r->getreg($name,'chanmode')),
- 'Limite: '.$r->getreg($name,'limit').', Clef: '.$r->getreg($name,'key'),
- 'Chanflags: +'.$chars->chanflags_decode($r->getreg($name,'chanflags')),
- 'Sujet sauvegardי: '.$r->getreg($name,'topic'),
- 'Message d\'accueil: '.$r->getreg($name,'welcome')
- ));
- } else { $cm->notice(self::$data[0],"Le canal $name n'est pas enregistrי."); }
- }
- elseif(count(self::$data)==3){# chanset <#canal> <option> - Consultation de l'option
- list($client,,$name,$option) = self::$data;
- if($r->isreg($name)){
- $chars = QChars::getInstance();
- switch(strtolower($option)){
- case 'created': $cm->notice($client,"$name a יtי enregistrי le ".strftime('%c',$r->getreg($name,'created'))." par l'opיrateur ".$r->getreg($name,'adder')); break;
- case 'founder': $cm->notice($client,"$name est enregistrי sur le compte de ".$r->getreg($name,'founder')); break;
- case 'chantype': $cm->notice($client,"$name est de type ".$r->getreg($name,'chantype')); break;
- case 'chanmode': $cm->notice($client,"les modes de $name sont +".$chars->chanmode_decode($r->getreg($name,'chanmode'))); break;
- case 'chanflags': $cm->notice($client,"les chanflags de $name sont +".$chars->chanflags_decode($r->getreg($name,'chanflags'))); break;
- case 'topic': $cm->notice($client,"le sujet de $name est: ".$r->getreg($name,'topic')); break;
- case 'welcome': $cm->notice($client,"le message de bienvenue de $name est: ".$r->getreg($name,'welcome')); break;
- default: $cm->notice($client,"Ce champ n'existe pas ou n'est pas affichable."); break;
- }
- } else { $cm->notice(self::$data[0],"Le canal $name n'est pas enregistrי."); }
- }
- elseif(count(self::$data)>=4){
- list($client,,$name,$option) = array_slice(self::$data,0,4);
- $params = array_slice(self::$data,4);
- if($r->isreg($name)){
- $chars = QChars::getInstance();
- switch(strtolower($option)){
- case 'founder':
- if($r->isaccount($params[0])){ $r->updatereg($name,'founder',$params[0]); $cm->notice($client,'Effectuי'); }
- else { $cm->notice($client,'Le compte '.$params[0].' n\'existe pas.'); }
- break;
- case 'chantype':
- if(in_array($params[0],array('classic','oper','help','coding'))){ $r->updatereg($name,'chantype',$params[0]); $cm->notice($client,'Effectuי'); }
- else { $cm->notice($client,'Le chantype '.$params[0].' n\'est pas valide.'); }
- break;
- case 'chanflags':
- # Cette partie ne traite pas de 'bien ou pas' car elle est directement sous-traitיe
- $r->parseChanflags(strtolower($params[0]));
- $cm->notice($client,'Nouveau chanflag pour le canal $name: '.$chars->chanflags_decde($r->getreg($name,'chanflags')));
- break;
- case 'topic':
- # TOPICLEN 250
- $topic = implode(' ',array_slice($params,5));
- $topic = substr($topic,0,(-250-strlen($topic)));
- $cm->notice($client,'Nouveau sujet choisi: $topic');
- break;
- }
- }
- }
- } else { $cm->notice(self::$data[0],"Votre niveau d'accטs est insufisant."); }
- } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
- }
- private static function craw(){
- $allowed_raws = array(TOKEN_PRIVMSG,TOKEN_NOTICE,TOKEN_JOIN,TOKEN_LEAVE);
- if(QDatabase::getInstance()->isAuthed(self::$data[0])){# L'utilisateur est identifiי
- $account = QDatabase::getInstance()->getclient(self::$data[0],'account');
- if(QRegister::getInstance()->getaccount($account,"level")==1000){
- if(count(self::$data)==3) QCommands::getInstance()->notice(self::$data[0],array("Syntaxe: CRAW <TOKEN> [<texte>]","Les TOKENs autorisיs sont les suivants: ".implode(", ",$allowed_raws)));
- if(count(self::$data)>=4){
- if(in_array(self::$data[2],$allowed_raws)){
- if(isset(self::$data[3])) QCommands::getInstance()->craw(self::$data[2]." ".implode(" ",array_slice(self::$data,3)));
- else QCommands::getInstance()->craw(self::$data[2]);
- }
- else QCommands::getInstance()->notice(self::$data[0],"Le raw client ".self::$data[3]." n'est pas autorisי.");
- }
- }
- }else{QCommands::getInstance()->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
- }
- private static function sraw(){
- $allowed_raws = array(TOKEN_PRIVMSG,TOKEN_NOTICE,TOKEN_JOIN,TOKEN_LEAVE);
- if(QDatabase::getInstance()->isAuthed(self::$data[0])){# L'utilisateur est identifiי
- $account = QDatabase::getInstance()->getclient(self::$data[0],'account');
- if(QRegister::getInstance()->getaccount($account,"level")==1000){
- if(count(self::$data)==3) QCommands::getInstance()->notice(self::$data[0],"Syntaxe: ");
- if(count(self::$data)>=4){
- /*switch($tok){
- case "P";
- case "O";
- case "J";
- case "L":
- if(isset(self::$data[3])) QCommands::getInstance()->craw(self::$data[3]);
- break;
- default: QCommands::getInstance()->notice(self::$data[0],"Le raw client ".self::$data[2]." n'est pas autorisי."); break;
- }*/
- }
- }
- }else{QCommands::getInstance()->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
- }
- private static function dbsave(){
- $db = QDatabase::getInstance();
- $db->save();
- $cm = QCommands::getInstance(); $cm->notice(self::$data[0],"Effectuי");
- }
- private static function save(){
- $r = QRegister::getInstance();
- $r->save();
- $cm = QCommands::getInstance(); $cm->notice(self::$data[0],"Effectuי");
- }
- private static function dnsbl(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){# L'utilisateur est identifiי ?
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if($r->getaccount($account,"level")==1000){
- if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: DNSBL <adresse IP/nom d'hפte>");
- if(count(self::$data)==4){
- print_r(self::$data);
- $cm->notice(self::$data[0],"Scan de l'adresse ".self::$data[3]);
- $records = QDnsbl::lookup(self::$data[3]);
- if($records!==false){
- foreach($records as $blacklist => $record){
- $cm->notice(self::$data[0],"Liste noire: $blacklist Code: ".$record['code']." ".(isset($record['txt']) ? " Motif: ".$record['txt']." (".$record['ip'].")" : "Pas de motif"));
- }
- }else{
- $cm->notice(self::$data[0],"Aucun rיsultat trouvי");
- }
- $cm->notice(self::$data[0],"Scan terminי");
- }
- } else { $cm->notice(self::$data[0],"Votre niveau d'accטs est insufisant."); }
- } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
- }
- private static function locate(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){# L'utilisateur est identifiי ?
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if($r->getaccount($account,"level")>=900){
- $locator = QLocation::getInstance();
- if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: LOCATE <adresse IP/nom d'hפte>");
- if(count(self::$data)==4){
- $cm->notice(self::$data[0],"Tentative de localisation pour ".self::$data[2]." lancיe");
- if(($location=$locator->locate(self::$data[2]))!==false){
- $cm->notice(self::$data[0],"Pays: ".$location['country_name']." (".$location['country_code'].") Continent: ".$location['continent']." (".$location['continent_code'].")");
- if(isset($location['city'])) $cm->notice(self::$data[0],"Nom de la ville: ".$location['city']);
- if(isset($location['organization'])) $cm->notice(self::$data[0],"Nom de l'organisation: ".$location['organization']);
- }else{$cm->notice(self::$data[0],"La localisation n'a pu ךtre trouvיe, soyez sur d'avoir bien formulי la requטte.");}
- }
- } else { $cm->notice(self::$data[0],"Votre niveau d'accטs est insufisant."); }
- } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
- }
- ########################################
- ### Messages Publics ( sur canaux ) ####
- ########################################
- # Format d'entrיe:
- # <client> <canal> <commande> [<arguments>]
- private static function p_locate(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){# L'utilisateur est identifiי ?
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if($r->getaccount($account,'level')>=900){
- $locator = QLocation::getInstance();
- # <client> P <channel> :<command>
- if(count(self::$data)==3) $cm->message(self::$data[1],"Syntaxe: LOCATE <adresse IP/nom d'hפte>");
- if(count(self::$data)==4){
- if(($loc=$locator->locate(self::$data[3]))!==false){
- if(!empty($loc['continent'])&&!empty($loc['continent_code'])){
- $cm->message(self::$data[1],"Continent: ".$loc['continent']." (".$loc['continent_code'].")");
- }
- $cm->message(self::$data[1],"Pays: ".$loc['country_name']." (".$loc['country_code'].")");
- if(!empty($loc['city'])) $cm->message(self::$data[1],"Ville: ".$loc['city']);
- if(!empty($loc['region'])) $cm->message(self::$data[1],"Rיgion: ".$loc['region']);
- if(!empty($loc['organization'])) $cm->message(self::$data[1],"organisation: ".$loc['organization']);
- if(!empty($loc['timezone'])) $cm->message(self::$data[1],"Fuseau horaire: ".$loc['timezone']);
- }else{$cm->message(self::$data[1],"Adresse IP/Nom d'hפte inconnu ou adresse non rיsolvable.");}
- }
- } else { $cm->notice(self::$data[0],"Votre niveau d'accטs est insufisant."); }
- } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
- }
- private static function p_dnsbl(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){# L'utilisateur est identifiי ?
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if($r->getaccount($account,'level')>=900){
- $dnsbl = QDnsbl::getInstance();
- # <client> <channel> <command> [<arguments>]
- if(count(self::$data)==3) $cm->message(self::$data[1],"Syntaxe: DNSBL <adresse IP/nom d'hפte>");
- if(count(self::$data)==4){
- if(($rbl=$dnsbl->lookup(self::$data[3]))!==false){
- foreach($rbl AS $key => $value){
- $cm->message(self::$data[1],$key);
- foreach($value AS $key => $value){
- $cm->message(self::$data[1],"$key => $value");
- }
- }
- }else{$cm->message(self::$data[1],"Aucun rיsultat trouvי/Nom d'hפte inconnu.");}
- }
- } else { $cm->notice(self::$data[0],"Votre niveau d'accטs est insufisant."); }
- } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
- }
- private static function restart(){
- if(QDtatabase::getInstance()->isAuthed(self::$data[0])){
- $account = QDatabase::getInstance()->getclient(self::$data[0],'account');
- if(QRegister::getInstance()->getaccount($account,'level')==1000){QCore::getInstance()->restart();}
- else{QCommmands::getInstance()->notice(self::$data[0],"Votre niveau d'accטs est insufisant.");}
- }else{QCommmands::getInstance()->notice(self::$data[0],"Votre niveau d'accטs est insufisant.");}
- }
- private static function status(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){# L'utilisateur est identifiי ?
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if($r->getaccount($account,'level')>=999){
- $cm->notice(self::$data[0],"Mיmoire utilisיe par PHP: ".memory_get_usage(true));
- } else { $cm->notice(self::$data[0],"Votre niveau d'accטs est insufisant."); }
- } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
- }
- private static function shutdown(){
- $cm = QCommands::getInstance();
- $db = QDatabase::getInstance();
- if($db->isAuthed(self::$data[0])){# L'utilisateur est identifiי ?
- $account = $db->getclient(self::$data[0],'account');
- $r = QRegister::getInstance();
- if($r->getaccount($account,'level')>=999){
- $q = QCore::getInstance();
- $reason = null;
- if(count(self::$data)>2) $reason = implode(' ',array_slice(self::$data,3));
- $q->stop($reason);
- exit;
- } else { $cm->notice(self::$data[0],"Votre niveau d'accטs est insufisant."); }
- } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
- }
- private static function version(){QCommands::getInstance()->notice(self::$data[0],"VERSION :".Q_VERSION."");}
- private static function mail_verify($adrs){return(getmxrr(array_slice(explode("@",$adrs),0,1),$mxhosts)===false) ? (int)0 : (int)1;}
- }
- function tostring($array,$start=0){ return(implode(" ",array_slice($array,$start))); }
- function toarray($string,$seg=""){ return(explode($seg,$string)); }
- ?>