PageRenderTime 59ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/q_client.php

https://bitbucket.org/gregorytoullie/php-q-source-snircd
PHP | 1510 lines | 1468 code | 0 blank | 42 comment | 225 complexity | 033b93b2a26f9b0fbf67055f5d3e8c1d MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. Classe du robot, uniquement
  4. */
  5. class QClient {
  6. private static $_instance;
  7. private static $data;
  8. public static function getInstance(){
  9. if(!isset(self::$_instance)){ self::$_instance = new self; }
  10. return self::$_instance;
  11. }
  12. function __construct(){echo __CLASS__,": crיation de l'instance\n";}
  13. function __destruct(){echo __CLASS__,": destruction de l'instance\n";}
  14. function __clone(){trigger_error("Le clפnage n'est pas autorisי.",E_USER_ERROR);}
  15. private static function callback_dropkeys($array,$drop=array()){
  16. $return = array();
  17. foreach($array AS $key => $value){
  18. if(!in_array($key,$drop)) $return[]=$value;
  19. else echo "Clef ignorיe: $key ($value)\n";
  20. }
  21. return $return;
  22. }
  23. public static function handle($array){
  24. echo "##### ",__CLASS__," #####\n";
  25. $cmd=$array[2]=strtoupper(substr($array[2],1));
  26. self::$data = $array;
  27. # self::callback_dropkeys($array,array(2));
  28. echo "Commande: $cmd\n";
  29. print_r(self::$data);
  30. echo count(self::$data);
  31. switch($cmd){
  32. case 'HELP':self::help();break;# Commandes de niveau 0
  33. case 'AUTH':self::auth();break;
  34. case 'HELLO':self::hello();break;
  35. case 'VALIDATE':self::validate();break;
  36. case 'WHOAMI':self::whoami();break;# Commandes de niveau 1 et plus
  37. case 'VOICE':self::voice();break;
  38. case 'OP':self::op();break;
  39. case 'DEOPALL':self::deopall();break;
  40. case 'DEVOICEALL':self::devoiceall();break;
  41. case 'WELCOME':self::welcome();break;
  42. case 'SETTOPIC':self::settopic();break;
  43. case 'CHANMODE':self::chanmode();break;
  44. case 'CHANFLAGS':self::chanflags();break;
  45. case 'CHANLEV':self::chanlev();break;
  46. case 'WHOIS':self::whois();break;# Commandes de niveau 900
  47. case 'CHANWHO':self::chanwho();break;
  48. case 'KILL':self::kill();break;
  49. case 'GLOBALE':self::desynch();break;
  50. case 'ADDUSER':self::adduser();break;# Commandes de niveau 1000
  51. case 'DELUSER':self::deluser();break;
  52. case 'SETUSER':self::setuser();break;
  53. case 'GETUSER':self::getuser();break;
  54. case 'ADDCHAN':self::addchan();break;
  55. case 'DELCHAN':self::delchan();break;
  56. case 'CHANSET':self::chanset();break;
  57. case 'SET':self::set();break;
  58. case 'GET':self::get();break;
  59. /*case 'CRAW':self::craw();break;
  60. case 'SRAW':self::sraw();break;
  61. case 'DNSBL':self::dnsbl();break;
  62. case 'LOCATE':self::locate();break;
  63. case 'CLVENC':self::clvenc();break;# Commandes de deboguage
  64. case 'CLVDEC':self::clvdec();break;
  65. case 'CHMENC':self::chmenc();break;
  66. case 'CHMDEC':self::chmdec();break;*/
  67. case 'SAVE':self::save();break;
  68. case 'RESTART':self::restart();break;
  69. case 'DIE':self::shutdown();break;
  70. case 'STATUS':self::status();break;
  71. case 'VERSION':self::version();break;
  72. default:self::error();break;
  73. }
  74. }
  75. public static function handlec($parray){
  76. self::$data = array($parray[0],$parray[1],ltrim(strtoupper(substr($parray[2],1)),":"));
  77. if(count($parray)>3){
  78. $rest = array_slice($parray,3);
  79. foreach($rest AS $piece) self::$data[]=$piece;
  80. }
  81. echo "Donnיes publiques: ".implode(' ',$parray)." (".count($parray).")\n";
  82. switch(self::$data[2]){
  83. case "ACTION":self::p_action();break;
  84. case "PREG":self::p_preg();break;
  85. //case "LOCATE":self::p_locate();break;
  86. case "DNSBL":self::p_dnsbl();break;
  87. }
  88. }
  89. private static function success(){$cm=QCommands::getInstance();$cm->notice(self::$data[0],"Effectuי.");}
  90. private static function error(){
  91. $cm = QCommands::getInstance();
  92. $cm->notice(self::$data[0],"La commande ".self::$data[2]." n'existe pas ou votre niveau d'accטs est insuffisant.");
  93. }
  94. ###########################
  95. #### Commandes privיes ####
  96. ###########################
  97. private static function help(){
  98. echo "Demande d'aide\n";
  99. $cm = QCommands::getInstance();
  100. $db = QDatabase::getInstance();
  101. $r = QRegister::getInstance();
  102. if(count(self::$data)==4){
  103. list($client,,,$command) = self::$data;
  104. echo "Commande d'aide: $command\n";
  105. switch(strtoupper($command)){
  106. case "HELLO":
  107. $cm->notice($client,array(
  108. "Syntaxe: HELLO <votre@email.com> <votre@email.com>",
  109. "La commande HELLO vous permet de crיer un compte utilisateur en utilisant votre pseudonyme actuel.",
  110. "Exemple si votre pseudo est \"banane\" et que vous tapez: /MSG Q HELLO banane@frou.fr banane@frou.fr",
  111. "Ceci crיera le compte \"banane\" aprטs votre rיponse א l'email envoyי א banane@frou.fr"
  112. ));
  113. break;
  114. case "VALIDATE":
  115. $cm->notice($client,array(
  116. "Syntaxe: VALIDATE <clef>",
  117. "La commande VALIDATE vous permet de terminer l'enregistrement du compte utilisateur,",
  118. "le paramטtre <clef> reprיsente la clef qui a יtי envoyיe par email lors de la commande HELLO."
  119. ));
  120. break;
  121. case "AUTH":
  122. $cm->notice($client,array(
  123. "Syntaxe: AUTH <mot-de-passe>",
  124. "La commande AUTH vous permet d'utiliser votre compte utilisateur prיcיdement crיי avec la commande HELLO ( cf HELP HELLO )",
  125. "Ceci vous permet d'utiliser vos niveaux d'accטs salons et les commandes du service Q"
  126. ));
  127. break;
  128. }
  129. if($db->isAuthed($client)){
  130. if($r->getaccount($r->getClientaccount($client),"level")!==false){
  131. $level = $r->getaccount($r->getClientaccount($client),"level");
  132. echo __CLASS__.": le client $client est de niveau $level\n";
  133. }
  134. if(isset($level)&&$level>=1){
  135. switch(strtoupper($command)){
  136. case 'CHANFLAGS':
  137. $cm->notice($client,array(
  138. 'Syntaxe: CHANFLAGS <#canal> [<+/-attributs>]',
  139. 'Cette commande vous permet de paramטtrer votre canal, ou plus prיcisיment le comportement du service sur ce dernier.',
  140. '-',
  141. '+w WELCOME - Affiche le message de bienvenue aux utilisateurs rejoignants le canal, pour ךtre dispensי voir le CHANLEV +w',
  142. '-',
  143. 'Attributs d\'Automatisme',
  144. 'Les paramטtres suivants s\'appliquent lors de l\'entrיe d\'un utilisateur sur le canal.',
  145. '+a AUTOOP - Donne automatiquement le status d\'opיrateur aux utilisateurs ayant un Accטs Opיrateurs (CHANLEV +o) sur le canal.',
  146. '+g AUTOVOICE - Donne automatiquement le status de modיrateur aux utilisateurs ayant un Accטs Modיrateur (CHANLEV +v) sur le canal.',
  147. '+o AUTOOPALL - Donne automatiquement le status d\'Opיrateur (+o)',
  148. '+v AUTOVOICEALL - Donne automatiquement le status de Modיrateur. (+v)',
  149. '+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',
  150. '-',
  151. 'Attributs d\'Action',
  152. 'Les paramטtres suivants s\'appliquent lors d\'actions venant des utilisateurs (changement du sujet, des modes, ...)',
  153. '+b BITCHMODE* - Le service applique strictement les attributs utilisateurs (+o,+v) et interdit toute modification.',
  154. '+f TOPICLOCK* - Le service autorise la modification du sujet uniquement par la commande SETTOPIC.',
  155. '+m MODELOCK* - Le service autorise la modification des modes uniquement par la commande CHANMODE.',
  156. '+e ENFORCEBANS* - Le service expulse automatiquement les utilisateurs ciblיs par les exclusions.',
  157. '+p PROTECT - Le service interdit la modification des status utilisateurs par ceux n\'ayant pas d\'accטs',
  158. '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)',
  159. '* = N\'affecte pas les Superviseurs (CHANLEV +x).',
  160. '-',
  161. 'Paramטtres Restritifs',
  162. '+d DEOPCHAN* - Le service interdit le status d\'Opיrateur (+o) א tous les utilisateurs.',
  163. '+q NOVOICES* - Le service interdit le status de Modיrateur (+v) א tous les utilisateurs.',
  164. '+i INVITEONLY* - Le service restreint le canal (+i) aux utilisateurs ayant utilisיs la commande INVITE.',
  165. '+r REGONLY - Seuls les utilisateurs enregistrיs sont autorisיs א rejoindre le canal.',
  166. '* = N\'affecte pas les Superviseurs (CHANLEV +x) et le service.',
  167. '-',
  168. 'Paramטtres Staff',
  169. '+t TOPICBURST - Le service renvoie automatiquement le sujet enregistrי depuis la commande SETTOPIC.',
  170. '+s SUSPEND - Le service n\'est plus actif sur le canal. (les paramטtres sont sauvegardיs)',
  171. //'+h HELPCHAN - Le service aide les opיrateurs du canal א modיrer les utilisateurs.',
  172. '-',
  173. 'MEMO CHANLEV: Fondateur (+f), Superviseur (+x), propriיtaire (+n), maמtre (+m), opיrateur (+o) et modיrateur (+v)',
  174. 'HELP CHANLEV pour plus de dיtails.'
  175. ));
  176. break;
  177. case 'CHANLEV':
  178. $cm->notice($client,array(
  179. 'Syntaxe: CHANLEV <canal> [<compte>] [+/-<attributs>]',
  180. 'Cette commande permet d\'attribuer/rיtribuer des droits utilisateurs sur le canal.',
  181. 'Here we go.',
  182. 'Attributs des Niveaux d\'Accטs',
  183. '+f FOUNDER - Le Fondateur peut ajouter/retirer des Propriיtaires, Jokers, Maמtres, Opיrateurs et Modיrateurs.',
  184. 'NOTER QUE: Cet attribut est rattachי au compte, invisible aux utilisateurs et ne peut pas ךtre cedי.',
  185. '+x SUPERVISOR - Le Superviseur peut outre-passer toutes les restrictions du service.',
  186. 'Rפle: peut utiliser les commandes si le canal est DEOPCHAN, NOVOICES et est immunisי aux rטgles: BITCHMODE, TOPICLOCK, MODELOCK, ENFORCEBANS',
  187. '+n OWNER - Le Propriיtaire peut ajouter/retirer des Maמtres, Opיrateurs et Modיrateurs.',
  188. 'Il peut utiliser les commandes: CHANMODES, CHANFLAGS',
  189. '+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)',
  190. '+o OP - L\'Opיrateur peut ajouter/retirer des Modיrateurs.',
  191. '+v VOICE - Le Modיrateur peut s\'exprimer quand le canal est [CHAN]MODE +m',
  192. '-',
  193. 'Attributs d\'Automatismes',
  194. '+a AUTOOP - Si l\'utilisateur est attribuי +o (Opיrateur) le status d\'Opיrateur (@) lui sera automatiquement dispensי.',
  195. '+g AUTOVOICE - Si l\'utilisateur est attribuי +v (Modיrateur) le status de Modיrateur (+) lui sera automatiquement dispensי.',
  196. '+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.',
  197. '+s SECRET - Le Fondateur n\'est pas affichי dans les Accטs du canal. (mis par dיfaut)',
  198. 'Attributs Restrictifs',
  199. '+d DEOP - L\'utilisateur n\'est pas autorisי א recevoir le status d\'Opיrateur (@) sur le canal.',
  200. '+q QUIET - L\'utilisateur n\'est pas autorisי א recevoir le status de Modיrateur (+) sur le canal.'
  201. ));
  202. break;
  203. case 'DEOPALL':
  204. $cm->notice($client,array(
  205. 'Syntaxe: DEOPALL <#canal>',
  206. 'Retire le status d\'Opיrateur (@) א tous les opיrateurs du canal.',
  207. ));
  208. break;
  209. case 'DEVOICEALL':
  210. $cm->notice($client,array(
  211. 'Syntaxe: DEVOICEALL <#canal>',
  212. 'Retire le status de Modיrateur (+) א tous les modיrateurs du canal.',
  213. ));
  214. break;
  215. }
  216. }
  217. if(isset($level)&&$level>=900){
  218. switch(strtoupper($command)){
  219. case 'SUSPEND':
  220. $cm->notice($client,array(
  221. 'Syntaxe: SUSPEND <#canal>',
  222. 'Le service se retire du canal et n\'autorise pas son utilisation sur ce dernier.',
  223. 'L\'Attribut +s sera ajoutי au canal.',
  224. 'Niveau requis: Opיrateur (Niv. 900)'
  225. ));
  226. break;
  227. case 'UNSUSPEND':
  228. $cm->notice($client,array(
  229. 'Syntaxe: UNSUSPEND <#canal>',
  230. 'Le service retourne sur le canal et autorise son utilisation sur ce dernier.',
  231. 'Application: Attribut de canal Dי-Suspendu ( CHANFLAG +s )',
  232. 'Niveau requis: Opיrateur (Niv. 900)'
  233. ));
  234. break;
  235. }
  236. }
  237. if(isset($level)&&$level==1000){
  238. switch(strtoupper($command)){
  239. case "WHOAMI":
  240. $cm->notice($client,array(
  241. "Syntaxe: WHOAMI",
  242. "La commande WHOAMI vous permet d'afficher vos champs de connexion ( pseudo, adresse internet, nom rיel, numיrique, ... )",
  243. "Elle permet (optionnellement) d'afficher vos information de compte"
  244. ));
  245. break;
  246. case "WHOIS":
  247. $cm->notice($client,array(
  248. "Syntaxe: WHOIS <pseudo>",
  249. "WHOIS permet d'afficher les champs utilisateur bruts d'un pseudo donnי.",
  250. "En fonction de votre niveau, les informations peuvent ךtre masquיes/affichיes.",
  251. ));
  252. break;
  253. case "ADDUSER":
  254. $cm->notice($client,array(
  255. "Syntaxe: ADDUSER <compte> <email@isp.com>",
  256. "ADDUSER permet de crיer manuellement un compte utilisateur,",
  257. "par dיfaut, le compte est de niveau 1 et le mot de passe n'est pas rיglי. ( compte dיsactivי )"
  258. ));
  259. break;
  260. case "DELUSER":
  261. $cm->notice($client,array(
  262. "Syntaxe: DELUSER <compte>",
  263. "DELUSER permet de supprimer manuellement un compte utilisateur, cette commande est irrיversible et tous",
  264. "les accטs salon sont rיcursivement dיtruits.",
  265. ));
  266. break;
  267. case "SETUSER":
  268. $cm->notice($client,array(
  269. "Syntaxe: SETUSER <compte> <champ> <valeur>",
  270. "SETUSER permet de gטrer les champs d'un compte utilisateur.",
  271. "Les champs disponibles sont: LEVEL, EMAIL, PASSWORD, NOEXPIRES, VHOST",
  272. "Les champs GREETING sont des champs optionnels et ne sont pas configurables",
  273. "par les admins, ces champs peuvent ךtre consultיs via la commande GETUSER."
  274. ));
  275. break;
  276. case "GETUSER":
  277. $cm->notice($client,array(
  278. "Syntaxe: GETUSER [<champ>]",
  279. "GETUSER permet d'afficher les champs d'un utilisateur,",
  280. "si aucun paramטtre n'est fourni, tous les champs seront affichיs."
  281. ));
  282. break;
  283. case "USERINFO":
  284. $cm->notice($client,array(
  285. "Syntaxe: USERINFO <compte>",
  286. "USERINFO permet d'afficher les donnיes d'un compte dans leur intיgralitי,",
  287. "seuls les administrateurs rיseaux sont abilitיs א utiliser cette commande."
  288. ));
  289. break;
  290. case "ADDCHAN":
  291. $cm->notice($client,array(
  292. "Syntaxe: ADDCHAN <#canal> <fondateur>",
  293. "ADDCHAN permet d'ajouter un canal enregistrי, ce dernier est statique et ne peut ךtre retirי",
  294. "que par un administrateur rיseau/service ou aprטs expiration de la derniטre date d'utilisation."
  295. ));
  296. break;
  297. case "DELCHAN":
  298. $cm->notice($client,array(
  299. "Syntaxe: DELCHAN <#canal>",
  300. "DELCHAN permet de supprimer un canal enregistrי, supprimant tous les enregistrements ( chanlev, chanflags et chanmode )"
  301. ));
  302. break;
  303. case "CHANSET":
  304. $cm->notice($client,array(
  305. "Syntaxe: CHANINFO <#canal> [<champ>]",
  306. "CHANINFO permet d'afficher les donnיes d'un canal enregistrי. ( chanmode, chanflags, fondateur, crיateur )",
  307. "Les champs disponibles sont: CHANMODE, CHANFLAGS, FOUNDER, CREATOR"
  308. ));
  309. break;
  310. }
  311. }
  312. }
  313. }elseif(count(self::$data)==3){
  314. list($client,,) = self::$data;
  315. $cm->notice($client,array(
  316. "Commandes sans niveau d'accטs",
  317. "HELP [<commande>] - Affiche l'aide complטte ou sur la commande spיcifiיe",
  318. "HELLO <courrier@electronique.com> <courrier@electronique.com> - Demander l'enregistrement de votre compte utilisateur, les adresses de courrier doivent ךtre identiques.",
  319. "VALIDATE <clef> - Terminer l'enregistrement de votre compte utilisateur, la clef est fournie dans l'email de demande de compte ( voir HELLO )",
  320. "AUTH <mot-de-passe> - Vous identifier sous votre compte utilisateur"
  321. ));
  322. if($r->getaccount($r->getClientaccount($client),'level')!==false){
  323. $level = $r->getaccount($r->getClientaccount($client),'level');
  324. echo __CLASS__.": le client $client est de niveau $level\n";
  325. if($db->isAuthed(self::$data[0])){
  326. if(isset($level)&&$level>=1){
  327. $cm->notice(self::$data[0],array(
  328. "-",
  329. "Utilisateur Enregistrי ( Niveau 1 )",
  330. "WHOAMI - Affiche vos champs utilisateur (pseudo, numיrique, status...)",
  331. "CHANLEV <#canal> - Affiche les accטs utilisateur du canal",
  332. "CHANFLAGS <#canal> [+/-<chanflags>] - Rטgle les attributs du canal",
  333. "CHANMODE <#canal> [+/-<chanmode>] - Rטgle les modes du canal",
  334. ));
  335. }
  336. if(isset($level)&&$level>=900){
  337. $cm->notice(self::$data[0], array(
  338. "-",
  339. "Opיrateurs IRC (Niveau 900)",
  340. "WHOIS <utilisateur> - Affiche les informations sur l'utilisateur",
  341. "CHANWHO <#canal> - Affiche les informations relatives au canal",
  342. "CLEARMODE <#canal> [modes a nettoyer] - Retire tous les modes du canal ciblי",
  343. "KILL <pseudo> [<motif>] - Dיconnecte un utilisateur du rיseau avec ou sans le motif",
  344. "GLINE <#canal|utilisateur@adresse> [<durיe>] [<motif>] - Exclure un utilisateur/canal du rיseau",
  345. "SERVERS - Affiche la liste des serveurs connectיs"
  346. ));
  347. }
  348. if(isset($level)&&$level==1000){
  349. $cm->notice(self::$data[0], array(
  350. "-",
  351. "Administrateurs IRC ( Niveau 1000 )",
  352. "ADDUSER <compte> <email> [<niveau>] - Crיי un compte utilisateur",
  353. "DELUSER <compte> - Supprime un compte utilisateur",
  354. "SETUSER <compte> <champ> <valeur> - Modifier les champs d'un compte",
  355. "ADDCHAN <#canal> <fondateur> [<type de salon>] [<attr salon>]",
  356. "DELCHAN <#canal> - Supprime un canal",
  357. "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.",
  358. "SRAW <token> <paramטtres> - Execute une commande serveur brute ( attention, ceci peut crasher le serveur si mal utilisי )",
  359. "CRAW <token> <paramטtres> - Execute une commande client brute ( idem )",
  360. "GLOBALE <message> - Envoie un message par le serveur א tous les opיrateurs connectיs",
  361. "SHUTDOWN - Stoppe le service ( יteint le processus )",
  362. "RECONNECT - Redיmarre la connexion au serveur"
  363. ));
  364. }
  365. }
  366. }
  367. }
  368. }
  369. private static function p_preg(){
  370. $cm = QCommands::getInstance();
  371. # PREG <MASQUE> <PHRASE>
  372. if(preg_match("/^(?<patern>\/[^ ]+[\/ei])\s(?<text>.*+)/",implode(' ', array_slice(self::$data,3)),$cases)){
  373. $cm->message(self::$data[1],"Requete de PREG avec patron \"".$cases['patern']."\" et le texte ".preg_quote($cases['text'],'/'));
  374. $result=preg_match($cases['patern'], preg_quote($cases['text'],'/'), $matches);
  375. if($result>0){
  376. $cm->message(self::$data[1],"Rיsultat: ".$result);
  377. foreach($matches AS $key => $match){ $cm->message(self::$data[1], "$key: $match"); }
  378. }elseif($result==0){
  379. $cm->message(self::$data[1],"Aucun rיsultat");
  380. }else{
  381. switch(preg_last_error()){
  382. case PREG_BACKTRACK_LIMIT_ERROR:
  383. $cm->message(self::$data[1],"Erreur: La limite de backslashes est dיpassיe");
  384. break;
  385. case PREG_INTERNAL_ERROR:
  386. $cm->message(self::$data[1],"Erreur interne");
  387. break;
  388. case PREG_NO_ERROR:
  389. $cm->message(self::$data[1],"Aucune erreur");
  390. break;
  391. default:
  392. $cm->message(self::$data[1],"Erreur non prise en charge, veuillez vous rיfיrer א la documentation pcre");
  393. break;
  394. }
  395. }
  396. }
  397. }
  398. private static function p_action(){
  399. # <SSCCC> <#canal> <:[SOH]ACTION slaps blah with bleh[SOH]>
  400. if(count(self::$data)>3){
  401. $db = QDatabase::getInstance();
  402. $str = implode(' ',array_slice(self::$data,2));
  403. if(preg_match("/".CL_NICKNAME."/i", $str)){
  404. $retstring = preg_replace("/".CL_NICKNAME."/i", $db->num2nick(self::$data[0]), $str);
  405. QCommands::getInstance()->message(self::$data[1],$retstring);
  406. }
  407. }
  408. }
  409. ###############################################
  410. # Commandes de niveau 0 (sans enregistrement) #
  411. ###############################################
  412. private static function hello(){
  413. # <SSCCC> <Q_NUM> HELLO <email> <email>
  414. $cm = QCommands::getInstance();
  415. 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"));}
  416. if(count(self::$data)==5){
  417. list($client,,,$email1,$email2) = self::$data;
  418. $db = QDatabase::getInstance();
  419. $r = QRegister::getInstance();
  420. $account = $db->num2nick($client);# On rיcupטre le pseudo du client
  421. if(!$r->isaccount($account)){
  422. if($email1 === $email2){
  423. if(filter_var($email1,FILTER_VALIDATE_EMAIL) && !$r->isqueued($account)){
  424. if(self::mail_verify($email1)){
  425. $cm->notice($client,"Prיparation du courrier en cours, veuillez patienter");
  426. $r->addqueued($account,$email1);
  427. $key = $r->getqueued($account,"key");
  428. $for = sprintf('%s <%s>',$account,$email1);
  429. $subject = "Confirmation d'enregistrement de votre compte utilisateur";
  430. $headers = array(
  431. "From: \"MadGamerZ IRC\" <QBot@irc.madgamerz.fr>",
  432. "Reply-To: noreply@irc.madgamerz.fr",
  433. "Content-Type: text/plain",
  434. "X-Mailer: PHP-".phpversion()
  435. );
  436. $message = array(
  437. "Cher nouvel utilisateur,",
  438. "vous avez rיcemment demandי la crיation d'un compte pour l'utilisateur ".$account.".",
  439. "Afin d'achever la procיdure veuillez effectuer cette commande sur IRC :",
  440. "/MSG Q VALIDATE ".$key,
  441. "ATTENTION: ne copiez/collez pas la commande, retappez la entiטrement sur IRC !",
  442. " ",
  443. "Merci d'utiliser MadGamerZ IRC"
  444. );
  445. $mailed = mail($for,$subject,implode("\r\n",$message),implode("\n",$headers));
  446. if($mailed==true){
  447. $cm->notice($client,array(
  448. "Un courrier יlectronique vous a יtי envoyי afin d'achever la procיdure d'enregistrement,",
  449. "comme le message est rיdigי en HTML, il est possible que ce dernier arrive dans le dossier SPAM de votre boמte mail."
  450. ));
  451. } else { $cm->notice($client,"Une erreur est survenue lors de l'envoi du courrier, veuillez retenter l'opיration."); $r->delqueued($account); }
  452. } else { $cm->notice($client,"Etes vous sur que ce serveur de messagerie existe ? Erreur MX"); }
  453. } else { $cm->notice($client,"L'adresse fournie est incorrecte."); }
  454. } else { $cm->notice($client,"Les deux adresses de courrier יlectronique doivent ךtre identiques."); }
  455. } else { $cm->notice($client,"Syntaxe: /MSG Q HELLO <adresse@electronique.com> <adresse@electronique.com>"); }
  456. } else { $cm->notice(self::$data[0],"Ce compte existe dיjא, vous ne pouvez pas l'enregistrer א nouveau."); }
  457. }
  458. private static function validate(){
  459. # Fonction pour achever l'enregistrement du nom utilisateur.
  460. # <SSCCC> <Q_NUM> VALIDATE <KEYCODE>
  461. $cm = QCommands::getInstance();
  462. 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."));
  463. if(count(self::$data)==4){
  464. list($client,$clef) = self::$data;
  465. $db = QDatabase::getInstance();
  466. $r = QRegister::getInstance();
  467. $account = $db->num2nick($client);
  468. if($r->isqueued($account)){
  469. if($clef===$r->getqueued($account,"key")){
  470. $r->addaccount($account,$r->getqueued($account,"email"),1);
  471. $r->updateaccount($account,"password",$clef);
  472. $r->delqueued($account);
  473. $cm->notice($client,array(
  474. "L'enregistrement de votre compte est terminי!",
  475. "Pour l'utiliser veuillez taper: /MSG Q AUTH ".$clef,
  476. "ATTENTION: le staff de MadGamerZ ne vous demandera jamais votre mot-de-passe ( nous les connaissons )",
  477. "si quelqu'un vous le demande, veuillez contacter un opיrateur/administrateur au plus vite afin de signaler l'abus.",
  478. " ",
  479. "L'יquipe de MadGamerZ IRC vous souhaite un agrיable chat !",
  480. "Pour de l'aide sur l'utilisation du service, veuillez vous rendre sur #help"
  481. ));
  482. }else{
  483. $try = (int)$r->getqueued($account,"try");
  484. if($try > 0){
  485. $cm->notice($client,"La clef fournie est invalide, ".$try." tentatives restantes.");
  486. $r->setqueued($account,"try",--$try);
  487. }else{$cm->skill($client,"Tentative d'usurpation d'identitי.");$r->delqueued($account);}
  488. }
  489. }else{$cm->notice($client,"Votre compte n'est pas en instance de validation.");}
  490. }
  491. }
  492. private static function auth(){
  493. $cm = QCommands::getInstance();
  494. if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: AUTH <mot-de-passe>");
  495. if(count(self::$data)==4){
  496. list($client,,,$passwd) = self::$data;
  497. $db = QDatabase::getInstance();
  498. $account = $db->num2nick($client);
  499. if(!$db->isAuthed($client)){
  500. $r = QRegister::getInstance();
  501. if($r->isaccount($account)){
  502. if($r->getaccount($account,'password')!==false && $passwd===$r->getaccount($account,'password')){
  503. $db = QDatabase::getInstance();
  504. $r->addAccountclient($account,$client);
  505. $cm->account($client,$account,$r->getaccount($account,"id"),$r->getaccount($account,"created"),$r->getaccount($account,"level"));
  506. $db->parsemodes($client,array('+r',$account));
  507. $cm->notice($client,"Vous ךtes maintenant connectי avec le compte $account");
  508. $db->updateclient($client,'account',$account);
  509. if($r->getaccount($account,"vhost")!==false){
  510. if(($db->getclient($client,"virtualhost")===false) or $db->getclient($client,"virtualhost")!=$r->getaccount($account,"vhost")){
  511. list($user,$host) = explode("@",$r->getaccount($account,"vhost"));
  512. $cm->sethost($client,$user,$host);
  513. $db->parsemodes($client,array('+h',$user.'@'.$host));
  514. }
  515. }
  516. if($db->getclient($client,'channels')!==false&&$db->getclient($client,'channels')!=null){
  517. $names = $db->getclient($client,'channels');
  518. print_r($names);
  519. foreach($names AS $name){
  520. if($r->isreg($name)&&$r->isChanlev($name,$account)){
  521. if($r->getChanlev($name,$account,'a')&&!in_array('o',$db->getchanmember($name,$client))){
  522. $cm->mode($name,'+o',$client);
  523. }
  524. if($r->getChanlev($name,$account,'g')&&!in_array('v',$db->getchanmember($name,$client))){
  525. $cm->mode($name,'+v',$client);
  526. }
  527. }
  528. }
  529. }else{echo __FUNCTION__,": Le client $client n'a pas de salon.\n";}
  530. }else{$cm->notice($client,"Le mot-de-passe fourni n'est pas valide ou le mot-de-passe pour ce compte n'existe pas.");}
  531. }else{$cm->notice($client,"Le compte liי א votre pseudo n'existe pas");}
  532. }else{$cm->notice($client,"Vous utilisez actuellement un compte utilisateur, veuillez vous reconnecter.");}
  533. }
  534. }
  535. ##
  536. # Fonctions nickserv
  537. ##
  538. private static function requestnick(){
  539. $cm=QCommands::getInstance();
  540. if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: REQUESTNICK <pseudo> <mot-de-passe>");
  541. if(count(self::$data)==4){
  542. list($client,,$account,$password)=self::$data;
  543. $r = QRegister::getInstance();
  544. if($r->isaccount($account)){
  545. }
  546. }
  547. }
  548. ##
  549. # Commandes de niveau 1 (utilisateur enregistrי)
  550. ##
  551. private static function whoami(){
  552. $cm = QCommands::getInstance();
  553. $db = QDatabase::getInstance();
  554. if($db->isAuthed(self::$data[0])){
  555. if(count(self::$data)==1){
  556. list($client,) = self::$data;
  557. if($db->isAuthed($client)){
  558. $account = $db->getclient($client,'account');
  559. $r = QRegister::getInstance();
  560. $chars = QChars::getInstance();
  561. $cm->notice($client,array(
  562. "Identitי: ".$db->getclient($client,'nickname')." ".$db->getclient($client,'hostname')."@".$db->getclient($client,'username'),
  563. "Nom rיel: ".$db->getclient($client,'realname'),
  564. "Numיrique: ".$db->getclient($client,'numeric'),
  565. "Ip 64bits: ".$db->getclient($client,'b64ip'),
  566. "Modes: ".$db->getclient($client,'usermode')." (hex: ".$chars->usermode_encode(substr($db->getclient($client,'usermode'),1)).")")
  567. );
  568. if($db->isAdmin($client)){ $cm->notice($client,'Administrateur IRC'); }
  569. elseif($db->isOper($client)){ $cm->notice($client,'Opיrateur IRC'); }
  570. else { $cm->notice($client,"Utilisateur IRC"); }
  571. if($db->getclient($client,'opername')!==false){ $cm->notice($client, "Nom d\'opיrateur: ".$db->getclient($client,'opername')); }
  572. if($db->getclient($client,'virtualhost')!==false){ $cm->notice($client, "Hפte virtuel: ".$db->getclient($client,'virtualhost')); }
  573. $cm->notice($client,array(
  574. "Dיtails de votre compte utilisateur",
  575. "Id utilisateur: ".$r->getaccount($account,'id'),
  576. "Niveau du compte: ".$r->getaccount($account,'level'),
  577. "Date et heure de crיation: ".strftime('%c',$r->getaccount($account,'created'))
  578. )
  579. );
  580. }
  581. } else { $cm->notice(self::$data[0],'Syntaxe: WHOAMI'); }
  582. }
  583. }
  584. private static function settopic(){
  585. $cm = QCommands::getInstance();
  586. $db = QDatabase::getInstance();
  587. if($db->isAuthed(self::$data[0])){
  588. $r = QRegister::getInstance();
  589. $account = $db->getclient(self::$data[0],'account');
  590. if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: SETTOPIC <#canal> [<nouveau sujet>]");
  591. if(count(self::$data)==4){# Consultation
  592. list($client,,,$name) = self::$data;
  593. if($r->isreg($name)){
  594. if($r->isChanlev($name,$account)){
  595. if($r->getChanlev($name,$account,'t')||$r->getChanlev($name,$account,'m')||$r->getChanlev($name,$account,'n')){
  596. if($r->getreg($name,"topic")!==false){ $cm->notice($client,"Le sujet du canal $name est: ".$r->getreg($name,"topic")); }
  597. else { $cm->notice($client,"Aucun sujet n'a יtי choisi pour ce canal."); }
  598. } else { $cm->notice($client,"Votre niveau d'accטs sur $name ne vous permet pas d'utiliser SETTOPIC."); }
  599. } else { $cm->notice($client,"Vous n'avez pas d'accטs sur $name"); }
  600. } else { $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי."); }
  601. }
  602. if(count(self::$data)>4){# Rיglage
  603. list($client,,,$name) = self::$data;
  604. if($r->isreg($name)){
  605. if($r->isChanlev($name,$account)){
  606. if($r->getChanlev($name,$account,'t')||$r->getChanlev($name,$account,'m')||$r->getChanlev($name,$account,'n')){
  607. $str=implode(' ',array_slice(self::$data,4));
  608. $cm->topic($name,$str);
  609. $db->updatechan($name,'topic',$str);
  610. $r->updatereg($name,"topic",$str);$cm->notice($client,"Effectuי");
  611. } else { $cm->notice($client,"Votre niveau d'accטs sur $name ne vous permet pas d'utiliser SETTOPIC."); }
  612. } else { $cm->notice($client,"Vous n'avez pas d'accטs sur $name"); }
  613. } else { $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי."); }
  614. }
  615. } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
  616. }
  617. private static function welcome(){
  618. $cm = QCommands::getInstance();
  619. $db = QDatabase::getInstance();
  620. if($db->isAuthed(self::$data[0])){
  621. $account = $db->getclient(self::$data[0],'account');
  622. $r = QRegister::getInstance();
  623. if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: WELCOME <#canal> [message de bienvenue]");
  624. if(count(self::$data)==4){ // Consultation
  625. list($client,,,$name) = self::$data;
  626. if($r->isreg($name)){
  627. if($r->isChanlev($name,$account)){
  628. if($r->getChanlev($name,$account,'m')||$r->getChanlev($name,$account,'n')){
  629. 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")); }
  630. else{$cm->notice($client,"$name: aucun message d'accueil n'a יtי dיfini."); }
  631. }else{$cm->notice($client,"Votre niveau d'accטs sur $name ne vous permet pas d'utiliser WELCOME."); }
  632. } else {$cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande."); }
  633. } else { $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי."); }
  634. }elseif(count(self::$data)>4){ // Rיglage
  635. list($client,,,$name,) = self::$data;
  636. if($r->isreg($name)){
  637. if($r->isChanlev($name,$account)){
  638. if($r->getChanlev($name,$account,'m')||$r->getChanlev($name,$account,'n')){
  639. $str = implode(' ',array_slice(self::$data,4));
  640. $r->updatereg($name,"welcome",$str);
  641. $cm->notice($client,"Effectuי");
  642. } else { $cm->notice($client,"Votre niveau d'accטs sur $name ne vous permet pas d'utiliser WELCOME."); }
  643. } else { $cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande."); }
  644. } else { $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי."); }
  645. }
  646. } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
  647. }
  648. private static function chanlev(){
  649. $cm = QCommands::getInstance();
  650. $db = QDatabase::getInstance();
  651. if($db->isAuthed(self::$data[0])){
  652. print_r(self::$data);
  653. $account = $db->getclient(self::$data[0],'account');
  654. $r = QRegister::getInstance();
  655. if(count(self::$data)==3){$cm->notice(self::$data[0],'Syntaxe: CHANLEV <#canal> [<compte>] [<+/-droits>]');}
  656. if(count(self::$data)==4){# Consultation globale
  657. list($client,,,$name)=self::$data;
  658. if($r->isreg($name)){
  659. if($r->isChanlev($name,$account)){
  660. $cm->notice($client,array(
  661. "Information sur le canal ".$name,
  662. "Fondateur: ".$r->getreg($name,'founder'),
  663. "Ajoutי par l'administrateur ".$r->getreg($name,'adder').", le ".strftime("%A %d %B %Y א %X",$r->getreg($name,'created')),
  664. " ",
  665. "Compte - Accטs"
  666. ));
  667. $chars = QChars::getInstance();
  668. $levs = $r->getreg($name,"chanlev");# Attention, renvoie un tableau
  669. foreach($levs AS $acc => $lev) $cm->notice($client,$acc." - ".$chars->chanlev_decode($lev));
  670. }else $cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande.");
  671. }else $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי.");
  672. }
  673. if(count(self::$data)==5){# Consultation individuelle
  674. list($client,,,$name,$uaccount) = self::$data;
  675. if($r->isreg($name)){
  676. if($r->isChanlev($name,$account)){
  677. if($r->isChanlev($name,$uaccount)){$cm->notice($client,"Chanlev de $uaccount sur $name: ".$r->getRegaccount($name,$uaccount));}
  678. else{$cm->notice($client,"Il semble que le compte utilisateur $uaccount n'ai pas d'accטs sur $name.");}
  679. }
  680. }else{$cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי");}
  681. }
  682. if(count(self::$data)==6){# Modification
  683. list($client,,,$name,$uaccount,$flags) = self::$data;
  684. if($r->isreg($name)){
  685. if($r->isChanlev($name,$account)){
  686. if($r->isChanlev($name,$uaccount)){
  687. if(preg_match('#^[\-\+]([abdgmnoqstvw]+)#',$flags,$changes)){
  688. $attribs = str_split($changes[1]);
  689. if(in_array(array('n','m','o','v','t'),$attribs)){
  690. if(in_array('n',$attribs)){
  691. if($r->getChanlev($name,$account,'f')){$r->parseChanlev($name,$uaccount,$flags);$cm->notice($client,'Effectuי');}
  692. else{$cm->notice($client,"Vous n'avez pas les droits nיcessaires sur $name pour modifier ce CHANLEV");}
  693. }
  694. if(in_array('m',$attribs)){
  695. if($r->getChanlev($name,$account,'f')||$r->getChanlev($name,$account,'n')){
  696. $r->parseChanlev($name,$uaccount,$flags);$cm->notice($client,'Effectuי');
  697. }else{$cm->notice($client,"Vous n'avez pas les droits nיcessaires sur $name pour modifier ce CHANLEV");}
  698. }
  699. if(in_array(array('a','o','g','v','t'),$attribs)){
  700. if($r->getChanlev($name,$account,'f')||$r->getChanlev($name,$account,'n')||$r->getChanlev($name,$account,'m')){
  701. $r->parseChanlev($name,$uaccount,$flags);$cm->notice($client,'Effectuי');
  702. }else{$cm->notice($client,"Vous n'avez pas les droits nיcessaires sur $name pour modifier ce CHANLEV");}
  703. }
  704. }else{$r->parseChanlev($name,$uaccount,$flags);}
  705. //$r->parseChanlev($name,$account,$flags);// Routine externe
  706. $cm->notice($client,"Chanlev de $uaccount sur $name: ".$r->getRegaccount($name,$uaccount));
  707. }else $cm->notice($client,"L'un des attributs semble incorrect.");
  708. }else $cm->notice($client,"Il semble que le compte utilisateur $account n'ai pas d'accטs sur $name.");
  709. }else $cm->notice($client,"Vous n'avez pas d'accטs sur $name.");
  710. }else $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי");
  711. }
  712. }else{$cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
  713. }
  714. private static function chanflags(){
  715. print_r(self::$data);
  716. $cm = QCommands::getInstance();
  717. $db = QDatabase::getInstance();
  718. if($db->isAuthed(self::$data[0])){
  719. $account = $db->getclient(self::$data[0],'account');
  720. $r = QRegister::getInstance();
  721. if(count(self::$data)==3){$cm->notice(self::$data[0],'Syntaxe: CHANFLAGS <#canal> [<+/-attributs>]');}
  722. if(count(self::$data)==4){
  723. list($client,,,$name) = self::$data;
  724. if($r->isreg($name)){
  725. if($r->isChanlev($name,$account)){
  726. $chars = QChars::getInstance();
  727. $chanflags = $chars->chanflags_decode($r->getreg($name,"chanflags"));
  728. $cm->notice($client,"Le chanflag du canal ".$name." est: +".$chanflags);
  729. } else { $cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande."); }
  730. } else { $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי"); }
  731. }
  732. if(count(self::$data)==5){
  733. list($client,,$name,$flags) = self::$data;
  734. if($r->isreg($name)){
  735. if($r->isChanlev($name,$account)){
  736. if($r->getChanlev($name,$account,'n')||$r->getChanlev($name,$account,'m')){
  737. $r->parseChanflags($name,$flags);
  738. $chars = QChars::getInstance();
  739. $cm->notice($client,"Les modes du canal $name sont actuellement: +".$chars->chanflags_decode($r->getreg($name,"chanflags")));
  740. }else{$cm->notice($client,"Vous n'avez pas le niveau d'accטs requis pour modifier les CHANFLAGS de $name");}
  741. }else{$cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande.");}
  742. }else{$cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי");}
  743. }
  744. }else{$cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
  745. }
  746. # CHANMODE <#canal> [<changements>]
  747. private static function chanmode(){
  748. $cm = QCommands::getInstance();
  749. $db = QDatabase::getInstance();
  750. if($db->isAuthed(self::$data[0])){
  751. $account = $db->getclient(self::$data[0],'account');
  752. $r = QRegister::getInstance();
  753. if(count(self::$data)==3) $cm->notice(self::$data[0],'Syntaxe: CHANMODE <#canal> [<+/-modes>]');
  754. if(count(self::$data)==4){ // Consultation
  755. list($client,,$name)=self::$data;
  756. $r = QRegister::getInstance();
  757. if($r->isreg($name)){
  758. if($r->isChanlev($name,$account)){
  759. if($r->getaccount($account,'level')>=900||$r->getChanlev($name,$account,'n')||$r->getChanlev($name,$account,'m')){
  760. $chars = QChars::getInstance();
  761. $chanmode = $chars->chanmode_decode($r->getreg($name,'chanmode'));
  762. $cm->notice($client,"Les modes du canal ".$name." sont actuellement: +".$chanmode);
  763. }else{$cm->notice($client,"Vous n'avez pas le niveau d'accטs requis pour consulter le CHANMODE de ce canal");}
  764. }else{$cm->notice($client,"Vous devez possיder un accטs sur ".$name." pour utiliser cette commande.");}
  765. }else{$cm->notice($client,"Le canal ".$name." semble ne pas ךtre enregistrי");}
  766. }elseif(count(self::$data)==5){ // Rיglage
  767. list($client,,$name,$modes)=self::$data;
  768. $r = QRegister::getInstance();
  769. if($r->isreg($name)){
  770. if($r->isChanlev($name,$account)){
  771. if($r->getaccount($account,'level')>=900||$r->getChanlev($name,$account,'n')||$r->getChanlev($name,$account,'m')){
  772. $r->parseChmodes($name,$modes);
  773. $chars = QChars::getInstance();
  774. if($r->ischanflag($name,'m')){# Si ModeLock actif, les modes sont modifiיs directement par le service
  775. $cm->mode($name,'-imnpstrDdRucCNMT+'.$chars->chanmode_decode($r->getreg($name,'chanmode')),null);
  776. $cm->snotice($client,"modelock: les modes de $name ont יtיs modifiיs sans prיavis.");
  777. }
  778. $cm->notice($client,"Les modes du canal $name sont maintenant: +".$chars->chanmode_decode($r->getreg($name,'chanmode')));
  779. }else{$cm->notice($client,"Vous n'avez pas le niveau d'accטs nיcessaire sur $name pour modifier le CHANMODE");}
  780. }else{$cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande.");}
  781. }else{$cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי");}
  782. }
  783. }else{$cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
  784. }
  785. # DEOPALL <#canal>
  786. private static function deopall(){
  787. $cm = QCommands::getInstance();
  788. $db = QDatabase::getInstance();
  789. if($db->isAuthed(self::$data[0])){
  790. $account = $db->getclient(self::$data[0],'account');
  791. $r = QRegister::getInstance();
  792. if(count(self::$data)==2) $cm->notice(self::$data[0],"Syntaxe: DEOPALL <#canal>");
  793. if(count(self::$data)==3){
  794. list($client,,$name)=self::$data;
  795. if($r->isreg($name)){
  796. if($r->isChanlev($name,$account)){
  797. if($r->getaccount($account,'level')>=900||$r->getChanlev($name,$account,'n')||$r->getChanlev($name,$account,'m')){
  798. $clients = $db->getchanmembers($name);
  799. if($clients!==false){
  800. foreach($clients AS $client => $modes){if(strpos($modes,'o')!==false){$queue[]=$client;$db->updatechanmember($name,$client,array('-'=>'o'));}}
  801. $i=count($queue);$deop=array();
  802. while($i){
  803. $deop[]=$queue[$i-1];
  804. if(count($deop)==6){$cm->mode($name,'-oooooo',implode(' ',$deop));$deop=array();}
  805. $i--;
  806. }
  807. if(count($deop)>0){$cm->mode($name,'-'.str_repeat('o',count($deop)),implode(' ',$deop));}
  808. }
  809. }else{$cm->notice($client,"Vous n'avez pas le niveau d'accטs nיcessaire sur $name pour utiliser DEOPALL");}
  810. }else{$cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande.");}
  811. }else{$cm->notice(self::$data[0],"Le canal $name semble ne pas ךtre enregistrי");}
  812. }
  813. }else{$cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande.");}
  814. }
  815. private static function opall(){
  816. $db=QDatabase::getInstance();
  817. if($db->isAuthed(self::$data[0])){# L'utilisateur est identifiי ?
  818. $acc = $db->getclient(self::$data[0],'account');# Nous rיcupיrons le compte utilisateur.
  819. if(count(self::$data)==2) QCommands::getInstance()->notice(self::$data[0],array("Syntaxe: DEOPALL <#canal>","Vous devez ךtre maמtre (+m) au minimum."));
  820. if(count(self::$data)==3){
  821. list($client,,$name)=self::$data;
  822. $r = QRegister::getInstance();
  823. if($r->isreg($name)&&$r->ischanlev($name,$acc)){# Le canal est enregistrי et l'utilisateur y a accטs ?
  824. QCommands::getInstance()->notice($client,"Veuillez patienter...");
  825. if(($r->getchanlev($name,$acc,'m')||$r->getchanlev($name,$acc,'n'))||($db->isoper($client)||$db->isadmin($client))){
  826. foreach($db->getchanmembers($name) AS $client => $modes){
  827. if(strpos($modes,'o')===false){$queue[]=$client;$db->updatechanmember($name,$client,array('+'=>'o'));}
  828. }
  829. }
  830. } 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.
  831. }
  832. } else { QCommands::getInstance()->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
  833. }
  834. private static function voice(){
  835. $cm = QCommands::getInstance();
  836. $db = QDatabase::getInstance();
  837. if($db->isAuthed(self::$data[0])){
  838. $r = QRegister::getInstance();
  839. $account = $db->getclient(self::$data[0],'account');
  840. if(count(self::$data)==2) $cm->notice(self::$data[0],'Syntaxe: VOICE <#canal>');
  841. if(count(self::$data)==3){
  842. list($client,,$name)=self::$data;
  843. if($r->isreg($name)){
  844. list($client,,$name) = self::$data;
  845. if($r->isChanlev($name,$account)){
  846. if($r->getChanlev($name,$account,'v')){
  847. $db->updatechanmember($name,$client,array('+'=>'v'));
  848. $cm->mode($name,"+v",$client);
  849. $cm->notice($client,"Effectuי");
  850. }
  851. } else { $cm->notice($client,"Vous devez possיder un accטs sur $name pour utiliser cette commande."); }
  852. } else { $cm->notice($client,"Le canal $name semble ne pas ךtre enregistrי"); }
  853. }
  854. } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
  855. }
  856. private static function op(){
  857. return;
  858. }
  859. ##
  860. # Commandes de niveau 9 (opיrateur irc)
  861. ##
  862. private static function whois(){
  863. # 0 1 2
  864. # <src> WHOIS <cible>
  865. $cm = QCommands::getInstance();
  866. $db = QDatabase::getInstance();
  867. if($db->isAuthed(self::$data[0])){
  868. $r = QRegister::getInstance();
  869. if($r->getaccount($db->getclient(self::$data[0],'account'),'level')>=900){
  870. if(count(self::$data)==3) $cm->notice(self::$data[0],'Syntaxe: WHOIS <pseudo>');
  871. if(count(self::$data)==4){
  872. list($client,,,$target)=self::$data;
  873. if(preg_match('/^\#([^ ]+)/',$target,$match)){
  874. if($r->isaccount($match[1])){
  875. $cm->notice($client,array(
  876. "Compte ".$match[1],
  877. "Identifiant: ".$r->getaccount($match[1],'id'),
  878. "Niveau: ".$r->getaccount($match[1],'level'),
  879. "Date de crיation: ".strftime("%A %d %B %Y א %X",$r->getaccount($match[1],'created'))
  880. ));
  881. }
  882. } else {
  883. if($db->nick2num($target)!==false){
  884. $target = $db->nick2num($target);
  885. $cm->notice($client,array(
  886. $db->getclient($target,"nickname")." (".$db->getclient($target,'username')."@".$db->getclient($target,'hostname').") * ".$db->getclient($target,'realname'),
  887. "modes: ".$db->getclient($target,'usermode'),
  888. "numיrique: ".$db->getclient($target,'numeric'),
  889. "ip 64bits (ircu): ".$db->getclient($target,'b64ip'),
  890. "s'est connectי le ".strftime("%A %d %B %Y א %X",$db->getclient($target,'connts'))
  891. ));
  892. if($db->getclient($target,"account")!==false) $cm->notice($client,"Compte: ".$db->getclient($target,'account'));
  893. if($db->getclient($target,"virtualhost")!==false) $cm->notice($client,"Adresse virtuelle: ".$db->getclient($target,'virtualhost'));
  894. } else { $cm->notice($client,"Cet utilisateur n'existe pas sur le rיseau."); }
  895. }
  896. }
  897. } else { $cm->notice(self::$data[0],"Votre niveau d'accטs n'est pas suffisant pour utiliser cette commande."); }
  898. } else { $cm->notice(self::$data[0],"Vous devez ךtre identifiי pour utiliser cette commande."); }
  899. }
  900. private static function chanwho(){
  901. $cm = QCommands::getInstance();
  902. if(count(self::$data)==3) $cm->notice(self::$data[0],"Syntaxe: CHANWHO <#canal>");
  903. if(count(self::$data)==4){
  904. list($client,,$name) = self::$data;
  905. $db = QDatabase::getInstance();
  906. if($db->ischan($name)){
  907. $cm->notice($client,array(
  908. "Nom: ".$name,
  909. "Date de crיation: ".strftime("%c",$db->getchan($name,"created")),
  910. "Modes: ".$db->getchan($name,"modes"),
  911. "Sujet: ".$db->getchan($name,"topic")
  912. ));
  913. if($db->getchanmembers($name)!==false){
  914. $cm->notice($client,"Utilisateurs prיsents sur le salon:");
  915. $users = $db->getchanmembers($name);
  916. foreach($users AS $numeric => $mode){
  917. $cm->notice($client,$db->num2nick($numeric).(!empty($mode) ? " [".$mode."]" : null));
  918. }
  919. } else { $cm->notice($client,"Ce salon ne compte actuellement aucun membre."); }
  920. }
  921. }
  922. }
  923. private static function desynch(){
  924. $cm = QCommands::getInstance();
  925. if(isset(self::$data[2])){ $cm->desynch(implode(" ",array_slice(self::$data,2))); }
  926. }
  927. private static function join(){
  928. $c = QConfig::getInstance();
  929. $db = QDatabase::getInstance();
  930. $cm = QCommands::getInstance();
  931. echo count(self::$data);
  932. if(count(self::$data)==3){
  933. list($client,,$name) = self::$data;
  934. if($db->isOper($client)){
  935. if(!$db->ischan($name)){
  936. $db->addchan($name, null, null, null, null);
  937. $cm->join($name);
  938. $cm->smode($name,"+o",SV_NUMERIC.CL_NUMERIC);
  939. } else { $cm->notice($client,"Ce salon existe dיjא, je ne peux le rejoindre"); }
  940. } else { $cm->notice($client,"Cette commande est rיservיe aux opיrateurs IRC"); }
  941. } 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.")); }
  942. }
  943. private static function part(){
  944. $db = QDatabase::getInstance();
  945. $cm = QCommands::getInstance();
  946. if(count(self::$data)==3){
  947. list($client,,$name) = self::$data;
  948. if($db->isOper($client)){
  949. if($db->ischan($name)){
  950. $db->delchan($name);
  951. $cm->part($name);
  952. $cm->notice($client,"Effectuי");
  953. }
  954. } else { $cm->notice($client,"Cette commande est rיservיe aux opיrateurs IRC"); }
  955. } else { $cm->notice($client,array("utilisation: PART <#salon>","Cette commande fait partir le bot d'un salon temporaire.")); }
  956. }
  957. private static function kill(){
  958. $db = QDa

Large files files are truncated, but you can click here to view the full file