PageRenderTime 56ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/functions/builtins/greetonuserjoin.php

http://phpbobot.googlecode.com/
PHP | 43 lines | 39 code | 4 blank | 0 comment | 17 complexity | 5b23c223d0b3220a49d88c1dd72fc9f9 MD5 | raw file
  1. <?php
  2. function greetonuserjoin($socket, $channel, $sender, $msg, $infos)
  3. {
  4. global $db, $registered, $auth;
  5. $errore = 0;
  6. $cond_f = array("user_IDUser", "chan_IDChan");
  7. $cond_o = array("=", "=");
  8. if(isset($infos[3]) && is_bot_op($sender) && ($registered[$sender] || $auth[$sender])) {
  9. $user = $infos[2];
  10. $value = $infos[3];
  11. } else {
  12. $user = $sender;
  13. $value = $infos[1];
  14. }
  15. $iduser = $db->find_user($user);
  16. if($iduser > 0) {
  17. $cond_v = array($iduser, $db->find_chan($channel));
  18. if(mb_strtoupper($value) == "ON") {
  19. $val = "TRUE";
  20. } else if(mb_strtoupper($value) == "OFF") {
  21. $val = "FALSE";
  22. } else {
  23. $errore = 1;
  24. }
  25. if($errore != 1) {
  26. $r = $db->select(array("enter"), array("cangreet"), array(""), $cond_f, $cond_o, $cond_v, 1);
  27. if(count($r) > 0)
  28. $db->update("enter", array("cangreet"), array($val), $cond_f, $cond_o, $cond_v);
  29. else
  30. $db->insert("enter", array("user_IDUser", "chan_IDChan", "greet_IDGreet", "modes", "kicks", "cangreet"), array($db->find_user($user), $db->find_chan($channel), 0, "", 0, "TRUE"));
  31. sendmsg($socket, _("greetonuserjoin-done"), $channel); //"Tutto ok!"
  32. } else {
  33. sendmsg($socket, _("greetonuserjoin-error"), $channel); //"Errore"
  34. }
  35. } else {
  36. sendmsg($socket, _("greetstatus-unknown_user"), $channel); //"Chi?????"
  37. }
  38. }
  39. ?>