Beispiel #1
0
 public static function info_command($nick, $ircdata = array())
 {
     $chan = core::get_chan(&$ircdata, 0);
     // get the channel.
     if ($chan == '' || $chan[0] != '#') {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'INFO'));
         return false;
         // wrong syntax
     }
     // make sure they've entered a channel
     if (!($channel = services::chan_exists($chan, array('channel', 'timestamp', 'last_timestamp', 'suspended', 'suspend_reason')))) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_UNREGISTERED_CHAN, array('chan' => $chan));
         return false;
     }
     // make sure the channel exists
     if ($channel->suspended == 1) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_SUSPENDED_1, array('chan' => $channel->channel));
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_SUSPENDED_2, array('reason' => $channel->suspend_reason));
     } else {
         $founder = database::select('chans_levels', array('id', 'channel', 'target', 'flags'), array('channel', '=', $chan));
         $founders = '';
         while ($f_row = database::fetch($founder)) {
             if (strpos($f_row->flags, 'F') !== false) {
                 $founders .= $f_row->target . ', ';
             }
         }
         // get the founder(s)
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_1, array('chan' => $channel->channel));
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_2, array('nicks' => substr($founders, 0, -2)));
         $desc = chanserv::get_flags($channel->channel, 'd');
         if ($desc != null) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_3, array('desc' => $desc));
         }
         // description?
         if (core::$chans[$chan]['topic'] != '') {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_4, array('topic' => core::$chans[$chan]['topic']));
         }
         // topic
         $email = chanserv::get_flags($channel->channel, 'e');
         if ($email != null) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_5, array('email' => $email));
         }
         // is there an email?
         $url = chanserv::get_flags($channel->channel, 'u');
         if ($url != null) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_6, array('url' => $url));
         }
         // or a url?
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_7, array('time' => date("F j, Y, g:i a", $channel->timestamp)));
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_8, array('time' => date("F j, Y, g:i a", $channel->last_timestamp)));
         $modelock = chanserv::get_flags($channel->channel, 'm');
         if ($modelock != null) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_9, array('mode_lock' => $modelock));
         }
         // is there a mode lock?
         $entrymsg = chanserv::get_flags($channel->channel, 'w');
         if ($entrymsg != null) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_10, array('entrymsg' => $entrymsg));
         }
         // is there an entry msg?
         $list = '';
         if (chanserv::check_flags($channel->channel, array('T'))) {
             $list .= 'Topiclock, ';
         }
         if (chanserv::check_flags($channel->channel, array('K'))) {
             $list .= 'Keeptopic, ';
         }
         if (chanserv::check_flags($channel->channel, array('G'))) {
             $list .= 'Guard, ';
         }
         if (chanserv::check_flags($channel->channel, array('S'))) {
             $list .= 'Secure, ';
         }
         if (chanserv::check_flags($channel->channel, array('F'))) {
             $list .= 'Fantasy';
         }
         if (substr($list, -2, 2) == ', ') {
             $list = substr($list, 0, -2);
         }
         // compile our list of options
         if ($list != '') {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_11, array('options' => $list));
         }
         // if our list doesn't equal '', eg. empty show the info.
         if (core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified')) !== false && core::$config->chanserv->expire != 0) {
             $expiry_time = core::$config->chanserv->expire * 86400;
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_12, array('time' => date("F j, Y, g:i a", $channel->last_timestamp + $expiry_time)));
         }
         // if the nick in question has staff powers, we show the expiry times.
     }
 }
Beispiel #2
0
 public static function on_create($nusers, $channel)
 {
     $access_array = self::get_access($channel->channel);
     // get the access array
     foreach ($nusers as $nick => $modes) {
         if ($nick == core::$config->chanserv->nick) {
             continue;
         }
         // skip us :D
         $hostname = core::get_full_hostname($nick);
         // get the hostname ready.
         if ($reason = chanserv::check_levels($nick, $channel->channel, array('b'), true, false, true)) {
             ircd::mode(core::$config->chanserv->nick, $channel->channel, '+b *@' . core::$nicks[$nick]['host']);
             ircd::kick(core::$config->chanserv->nick, $nick, $channel->channel, $reason);
         }
         // check for bans before access
         foreach ($access_array as $target => $access) {
             if ($target == $nick) {
                 $remove_access = false;
                 // don't remove access
                 self::give_access($channel->channel, $nick, $access, chanserv::check_flags($chan, array('S')));
                 // give them access
                 continue 2;
                 // continue to next loop cause we've found a match
             } elseif (strpos($target, '@') !== false && services::match($hostname, $target)) {
                 $remove_access = false;
                 // don't remove access
                 self::give_access($channel->channel, $nick, $access, chanserv::check_flags($chan, array('S')));
                 // give them access
                 continue 2;
                 // continue to next loop cause we've found a match
             } elseif (strpos(core::$chans[$channel->channel]['users'][$nick], 'o') !== false) {
                 $remove_access = true;
                 // set remove access to true
                 continue 1;
                 // continue to next loop to check other access records
             } elseif (strpos(core::$chans[$channel->channel]['users'][$nick], 'h') !== false) {
                 $remove_access = true;
                 // set remove access to true
                 continue 1;
                 // continue to next loop to check other access records
             } else {
                 continue 1;
                 // continue to next loop to check other access records
             }
             // we check if the user has access, if they do break;
             // we also check if they dont have access and have op, if they do remove it.
         }
         // loop through the access records
         if ($remove_access) {
             ircd::mode(core::$config->chanserv->nick, $channel->channel, '-oh ' . $nick . ' ' . $nick);
         }
         // easy fix to stop stuff like this below happening.
         // [20:27:19] * ChanServ sets mode: -o N0valyfe
         // [20:27:19] * ChanServ sets mode: +o N0valyfe
     }
     // loop through the users
 }
Beispiel #3
0
 public function main(&$ircdata, $startup = false)
 {
     if (ircd::on_topic(&$ircdata) || ircd::on_ftopic(&$ircdata)) {
         $chan = core::get_chan(&$ircdata, 2);
         $topic = core::$chans[$chan]['topic'];
         $setter = core::$chans[$chan]['topic_setter'];
         // i forgot this was done by the protocol modules
         if ($channel = services::chan_exists($chan, array('channel', 'topic'))) {
             if (chanserv::check_flags($chan, array('T')) && chanserv::check_flags($chan, array('K')) && $channel->topic != $topic) {
                 ircd::topic(core::$config->chanserv->nick, $channel->channel, $channel->topic);
                 database::update('chans', array('topic_setter' => core::$config->chanserv->nick), array('channel', '=', $chan));
                 return false;
                 // reset it i reckon.
             } elseif ($channel->topiclock == 0) {
                 database::update('chans', array('topic' => $topic, 'topic_setter' => $setter), array('channel', '=', $chan));
                 // OTHERWISE, update it.
             }
             // some housekeepin.
         }
         // make sure the channel exists.
     }
     // now we check for topiclocking
     // moved this from cs_set to here
     // there was 2 versions O.o
 }
Beispiel #4
0
 public static function identify_command($nick, $ircdata = array())
 {
     $password = $ircdata[0];
     if (trim($password) == '') {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_SYNTAX_RE, array('help' => 'IDENTIFY'));
         return false;
     }
     // wrong syntax damit!
     if ($user = services::user_exists($nick, false, array('display', 'pass', 'identified', 'validated', 'salt', 'vhost'))) {
         if ($user->validated == 0) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_AWAITING_VALIDATION);
             return false;
         } elseif ($user->identified == 1) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ALREADY_IDENTIFIED);
             return false;
         } else {
             if ($user->pass == sha1($password . $user->salt)) {
                 timer::remove(array('ns_identify', 'secured_callback', array($nick)));
                 // remove the secured timer. if there is one
                 ircd::on_user_login($nick);
                 // registered mode
                 database::update('users', array('identified' => 1, 'last_hostmask' => core::get_full_hostname($nick), 'last_timestamp' => 0), array('display', '=', $nick));
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_IDENTIFIED);
                 // right, standard identify crap
                 core::alog(core::$config->nickserv->nick . ': ' . core::get_full_hostname($nick) . ' identified for nick ' . core::$nicks[$nick]['nick']);
                 // logchan
                 if ($user->vhost != '' && isset(modules::$list['os_vhost'])) {
                     if (substr_count($user->vhost, '@') == 1) {
                         $new_host = explode('@', $user->vhost);
                         $ident = $new_host[0];
                         $host = $new_host[1];
                         ircd::setident(core::$config->operserv->nick, $user->display, $ident);
                         ircd::sethost(core::$config->operserv->nick, $user->display, $host);
                     } else {
                         ircd::sethost(core::$config->operserv->nick, $user->display, $user->vhost);
                     }
                 }
                 // first thing we do, check if they have a vhost, if they do, apply it.
                 $failed_attempts = database::select('failed_attempts', array('nick', 'mask', 'time'), array('nick', '=', $nick));
                 if (database::num_rows($failed_attempts) > 0) {
                     services::communicate(core::$config->nickserv->nick, $nick, '' . database::num_rows($failed_attempts) . ' failed login(s) since last login.');
                     while ($row = database::fetch($failed_attempts)) {
                         services::communicate(core::$config->nickserv->nick, $nick, 'Failed login from: ' . $row->mask . ' on ' . date("F j, Y, g:i a", $row->time) . '');
                     }
                     // loop through the failed attempts messaging them to the user
                     database::delete('failed_attempts', array('nick', '=', $nick));
                     // clear them now that they've been seen
                 }
                 // we got any failed attempts? HUMM
                 $hostname = core::get_full_hostname($nick);
                 // generate a hostname.
                 if (core::$config->settings->mode_on_id == 'yes' && isset(modules::$list['cs_levels'])) {
                     foreach (core::$chans as $chan => $cdata) {
                         $access_array = cs_levels::get_access($chan);
                         // get the access array
                         if ($nick == core::$config->chanserv->nick) {
                             continue;
                         }
                         // skip us :D
                         $hostname = core::get_full_hostname($nick);
                         // get the hostname ready.
                         foreach ($access_array as $target => $access) {
                             if ($target == $nick) {
                                 $remove_access = false;
                                 // don't remove access
                                 cs_levels::give_access($chan, $nick, $access, chanserv::check_flags($chan, array('S')));
                                 // give them access
                                 continue 2;
                                 // continue to next loop cause we've found a match
                             } elseif (strpos($target, '@') !== false && services::match($hostname, $target)) {
                                 $remove_access = false;
                                 // don't remove access
                                 cs_levels::give_access($chan, $nick, $access, chanserv::check_flags($chan, array('S')));
                                 // give them access
                                 continue 2;
                                 // continue to next loop cause we've found a match
                             } elseif (strpos(core::$chans[$chan]['users'][$nick], 'o') !== false) {
                                 $remove_access = true;
                                 // set remove access to true
                                 continue 1;
                                 // continue to next loop to check other access records
                             } else {
                                 continue 1;
                                 // continue to next loop to check other access records
                             }
                             // we check if the user has access, if they do break;
                             // we also check if they dont have access and have op, if they do remove it.
                         }
                         // loop through the access records
                     }
                     // loop through channels, check if they are in any
                 }
                 // check if mode_on_id is set, also cs_access is enabled, and lets do a remote access gain :D
             } else {
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_PASSWORD);
                 core::alog(core::$config->nickserv->nick . ': Invalid password from ' . core::get_full_hostname($nick));
                 // some logging stuff
                 database::insert('failed_attempts', array('nick' => $nick, 'mask' => core::get_full_hostname($nick), 'time' => core::$network_time));
                 core::$nicks[$nick]['failed_attempts']++;
                 // ooh, we have something to log :)
                 if (core::$nicks[$nick]['failed_attempts'] == 5) {
                     ircd::kill(core::$config->nickserv->nick, $nick, 'Maxmium FAILED login attempts reached.');
                 }
                 // have they reached the failed attempts limit? we gonna f*****g KILL mwhaha
             }
             // invalid password? HAX!!
         }
         // are they already identifed?
     } else {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_UNREGISTERED);
         return false;
         // doesn't even exist..
     }
     // right now we need to check if the user exists, and password matches
 }
Beispiel #5
0
 public function main(&$ircdata, $startup = false)
 {
     if (ircd::on_msg(&$ircdata)) {
         $nick = core::get_nick(&$ircdata, 0);
         $chan = core::get_chan(&$ircdata, 2);
         //if ( core::search_nick( $chan ) !== false )
         //return false;
         // bail if it thinks chan == nick.
         if (!($channel = services::chan_exists($chan, array('channel')))) {
             return false;
         }
         // channel isnt registered, halt immediatly..
         // either something has cocked up or someone
         // has forced us into a channel :S
         if (chanserv::check_flags($chan, array('F')) === false) {
             return false;
         }
         // we gotta check if the channel has fantasy commands enabled first
         if (commands::on_fantasy_cmd(&$ircdata, 'help', core::$config->chanserv->nick)) {
             if (ircd::$halfop) {
                 $help =& chanserv::$help->CS_HELP_FANTASY_ALL1;
             } else {
                 $help =& chanserv::$help->CS_HELP_FANTASY_ALL2;
             }
             foreach ($help as $line) {
                 services::communicate(core::$config->chanserv->nick, $nick, $line, array('p' => core::$config->chanserv->fantasy_prefix));
             }
         }
         // !help command
         if (commands::on_fantasy_cmd(&$ircdata, 'owner', core::$config->chanserv->nick) && ircd::$owner) {
             if (chanserv::check_levels($nick, $channel->channel, array('q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '+q', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+q ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+q ' . $nick);
             }
             // check if another param is specified
         }
         // !owner command
         if (commands::on_fantasy_cmd(&$ircdata, 'deowner', core::$config->chanserv->nick) && ircd::$owner) {
             if (chanserv::check_levels($nick, $channel->channel, array('q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '-q', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-q ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-q ' . $nick);
             }
             // check if another param is specified
         }
         // !deowner command
         if (commands::on_fantasy_cmd(&$ircdata, 'protect', core::$config->chanserv->nick) && ircd::$protect) {
             if (chanserv::check_levels($nick, $channel->channel, array('a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '+a', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+a ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+a ' . $nick);
             }
             // check if another param is specified
         }
         // !protect command
         if (commands::on_fantasy_cmd(&$ircdata, 'deprotect', core::$config->chanserv->nick) && ircd::$protect) {
             if (chanserv::check_levels($nick, $channel->channel, array('a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strtolower($ircdata[4]) == strtolower(core::$config->chanserv->nick)) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '-a', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-a ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-a ' . $nick);
             }
             // check if another param is specified
         }
         // !protect command
         if (commands::on_fantasy_cmd(&$ircdata, 'op', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('o', 'a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '+o', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+o ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+o ' . $nick);
             }
             // check if another param is specified
         }
         // !op command
         if (commands::on_fantasy_cmd(&$ircdata, 'deop', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('o', 'a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strtolower($ircdata[4]) == strtolower(core::$config->chanserv->nick)) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '-o', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-o ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-o ' . $nick);
             }
             // check if another param is specified
         }
         // !deop command
         if (commands::on_fantasy_cmd(&$ircdata, 'halfop', core::$config->chanserv->nick) && ircd::$halfop) {
             if (chanserv::check_levels($nick, $channel->channel, array('h', 'o', 'a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '+h', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+h ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+h ' . $nick);
             }
             // check if another param is specified
         }
         // !hop command
         if (commands::on_fantasy_cmd(&$ircdata, 'dehalfop', core::$config->chanserv->nick) && ircd::$halfop) {
             if (chanserv::check_levels($nick, $channel->channel, array('h', 'o', 'a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strtolower($ircdata[4]) == strtolower(core::$config->chanserv->nick)) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '-h', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-h ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-h ' . $nick);
             }
             // check if another param is specified
         }
         // !dehop command
         if (commands::on_fantasy_cmd(&$ircdata, 'voice', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('v', 'h', 'o', 'a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '+v', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+v ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+v ' . $nick);
             }
             // check if another param is specified
         }
         // !voice command
         if (commands::on_fantasy_cmd(&$ircdata, 'devoice', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('v', 'h', 'o', 'a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '-v', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-v ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-v ' . $nick);
             }
             // check if another param is specified
         }
         // !devoice command
         if (commands::on_fantasy_cmd(&$ircdata, 'topic', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('t', 'F')) === false) {
                 return false;
             }
             if (isset($ircdata[4])) {
                 $topicmask = chanserv::get_flags($chan, 't');
                 // get the topicmask
                 if ($topicmask != null) {
                     $new_topic = core::get_data_after(&$ircdata, 4);
                     $new_topic = str_replace(' *', ' ' . $new_topic, $topicmask);
                     $new_topic = str_replace('\\*', '*', $new_topic);
                     ircd::topic(core::$config->chanserv->nick, $channel->channel, $new_topic);
                     database::update('chans', array('topic' => $new_topic, 'topic_setter' => core::$config->chanserv->nick), array('channel', '=', $channel->channel));
                 } else {
                     $new_topic = trim(core::get_data_after(&$ircdata, 4));
                     ircd::topic(core::$config->chanserv->nick, $channel->channel, $new_topic);
                     database::update('chans', array('topic' => $new_topic, 'topic_setter' => core::$config->chanserv->nick), array('channel', '=', $channel->channel));
                 }
                 // if there isnt, just set it normally.
             }
             // make sure there is another mask x]
         }
         // !topic command
         if (commands::on_fantasy_cmd(&$ircdata, 'mode', core::$config->chanserv->nick) || commands::on_fantasy_cmd(&$ircdata, 'm', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('h', 'o', 'a', 'q', 'F')) === false) {
                 return false;
             }
             if (isset($ircdata[4])) {
                 $mode_queue = core::get_data_after(&$ircdata, 4);
                 // get the mode queue
                 if (!core::$nicks[$nick]['ircop']) {
                     $mode_queue[0] = str_replace('O', '', $mode_queue[0]);
                 }
                 // don't let them MODE +O if they're not an IRCop
                 ircd::mode(core::$config->chanserv->nick, $chan, $mode_queue);
                 // check if there are any other parameters in the !mode command
             }
             // are we even setting a mode?
         }
         // !mode command
         if (commands::on_fantasy_cmd(&$ircdata, 'kick', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('r', 'F')) === false) {
                 return false;
             }
             // ignore if the nick doesn't have access to perform this
             if (isset($ircdata[4])) {
                 if (chanserv::check_levels($nick, $channel->channel, array('o', 'F')) && chanserv::check_levels($nick, $channel->channel, array('o', 'F')) === false) {
                     return false;
                 }
                 // check if the user kicking, has the access to kick them. that doesn't make sense, but yeah.
                 if (isset($ircdata[5])) {
                     $reason = core::get_data_after(&$ircdata, 5);
                     ircd::kick(core::$config->chanserv->nick, $ircdata[4], $chan, '(' . $nick . ') ' . ($reason != '') ? $reason : 'No reason');
                     // kick them with the reason
                 } else {
                     ircd::kick(core::$config->chanserv->nick, $ircdata[4], $chan, $nick);
                     // kick them with no reason
                 }
             }
             // make sure a parameter is issued
         }
         // !kick command
         if (commands::on_fantasy_cmd(&$ircdata, 'kickban', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('r', 'F')) === false) {
                 return false;
             }
             // ignore if the nick doesn't have access to perform this
             if (isset($ircdata[4])) {
                 if (chanserv::check_levels($nick, $channel->channel, array('o', 'F')) && chanserv::check_levels($nick, $channel->channel, array('o', 'F')) === false) {
                     return false;
                 }
                 // check if the user kicking, has the access to kick them. that doesn't make sense, but yeah.
                 if ($user = core::search_nick($ircdata[4])) {
                     ircd::mode(core::$config->chanserv->nick, $chan, '+b *@' . $user['host']);
                     if (isset($ircdata[5])) {
                         $reason = core::get_data_after(&$ircdata, 5);
                         ircd::kick(core::$config->chanserv->nick, $ircdata[4], $chan, '(' . $nick . ') ' . ($reason != '') ? $reason : 'No reason');
                         // kick them with the reason
                     } else {
                         ircd::kick(core::$config->chanserv->nick, $ircdata[4], $chan, $nick);
                         // kick them with no reason
                     }
                     // check if there is a reason etc.
                 } else {
                     return false;
                 }
             }
             // make sure a parameter is issued
         }
         // !ban command
         if (commands::on_fantasy_cmd(&$ircdata, 'ban', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('r', 'F')) === false) {
                 return false;
             }
             // ignore if the nick doesn't have access to perform this
             if (isset($ircdata[4])) {
                 if (chanserv::check_levels($nick, $channel->channel, array('o', 'F')) && chanserv::check_levels($nick, $channel->channel, array('o', 'F')) === false) {
                     return false;
                 }
                 // check if the user kicking, has the access to kick them. that doesn't make sense, but yeah.
                 if (strpos($ircdata[4], '@') === false && ($user = core::search_nick($ircdata[4]))) {
                     ircd::mode(core::$config->chanserv->nick, $chan, '+b *@' . $user['host']);
                 } else {
                     ircd::mode(core::$config->chanserv->nick, $chan, '+b ' . $ircdata[4]);
                 }
                 // is the hostname in our cache? if not just set a ban on it lol.
             }
         }
         // !ban command
         if (commands::on_fantasy_cmd(&$ircdata, 'unban', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('r', 'F')) === false) {
                 return false;
             }
             if (isset($ircdata[4])) {
                 if (strpos($ircdata[4], '@') === false && ($user = core::search_nick($ircdata[4]))) {
                     ircd::mode(core::$config->chanserv->nick, $chan, '-b *@' . $user['host']);
                 } else {
                     ircd::mode(core::$config->chanserv->nick, $chan, '-b ' . $ircdata[4]);
                 }
                 // is the hostname in our cache? if not unban it..
             }
         }
         // !unban command
         if (commands::on_fantasy_cmd(&$ircdata, 'flags', core::$config->chanserv->nick) && isset(modules::$list['cs_flags'])) {
             $n_ircdata = $ircdata;
             unset($n_ircdata[0], $n_ircdata[1], $n_ircdata[2], $n_ircdata[3]);
             array_unshift($n_ircdata, $chan);
             // construct a new ircdata array
             cs_flags::flags_command($nick, $n_ircdata, true);
             // execute the flags command with the new data
             unset($n_ircdata);
             // get rid of this, isn't longer needed
         }
         // !flags command (experimental)
         if (commands::on_fantasy_cmd(&$ircdata, 'levels', core::$config->chanserv->nick) && isset(modules::$list['cs_levels'])) {
             $n_ircdata = $ircdata;
             unset($n_ircdata[0], $n_ircdata[1], $n_ircdata[2], $n_ircdata[3]);
             array_unshift($n_ircdata, $chan);
             // construct a new ircdata array
             cs_levels::levels_command($nick, $n_ircdata, true);
             // execute the flags command with the new data
             unset($n_ircdata);
             // get rid of this, isn't longer needed
         }
         // !levels command (experimental)
         if (commands::on_fantasy_cmd(&$ircdata, 'sync', core::$config->chanserv->nick) && isset(modules::$list['cs_levels'])) {
             cs_levels::on_create(core::$chans[$chan]['users'], $channel);
             // execute on_create, cause we just treat it as that
             // this is kinda a shortcut, but well worth it.
             ircd::notice(core::$config->chanserv->nick, $chan, '' . $nick . ' used SYNC');
         }
         // !sync command (experimental)
     }
     // only trigger on channel messages
 }
Beispiel #6
0
 public static function set_flag($nick, $chan, $flag, $param)
 {
     $mode = $flag[0];
     $r_flag = $flag[1];
     // get the real flag, eg. V, v and mode
     if (in_array($r_flag, str_split(self::$p_flags)) && $param == '' && $mode == '+') {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_FLAGS_NEEDS_PARAM, array('flag' => $flag));
         return false;
     }
     // are they issuing a flag, that HAS to have a parameter?
     // only if mode is + and parameter is empty.
     if ($r_flag == 'd') {
         $param_field = 'desc';
     }
     if ($r_flag == 'u') {
         $param_field = 'url';
     }
     if ($r_flag == 'e') {
         $param_field = 'email';
     }
     if ($r_flag == 'w') {
         $param_field = 'welcome';
     }
     if ($r_flag == 'm') {
         $param_field = 'modelock';
     }
     if ($r_flag == 't') {
         $param_field = 'topicmask';
     }
     // translate. some craq.
     if (in_array($r_flag, str_split(self::$p_flags)) && $mode == '+') {
         if ($r_flag == 'e' && services::valid_email($param) === false) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_FLAGS_INVALID_E, array('flag' => $flag));
             return false;
         }
         // is the email invalid?
         if ($r_flag == 't' && strpos($param, '*') === false) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_FLAGS_INVALID_T, array('flag' => $flag));
             return false;
         }
         // is the topicmask invalid?
         if ($r_flag == 'm') {
             $mode_string = explode(' ', $param);
             if (strstr($mode_string[0], 'r') || strstr($mode_string[0], 'q') || strstr($mode_string[0], 'a') || strstr($mode_string[0], 'o') || strstr($mode_string[0], 'h') || strstr($mode_string[0], 'v') || strstr($mode_string[0], 'b')) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_FLAGS_INVALID_M, array('flag' => $flag));
                 return false;
             }
         }
         // is the modelock invalid?
     }
     // check for invalid values
     if (chanserv::check_flags($chan, array($r_flag))) {
         $chan_flag_q = database::select('chans_flags', array('id', 'channel', 'flags'), array('channel', '=', $chan));
         if ($mode == '-') {
             if (strpos(self::$set[$target], '+') === false) {
                 self::$set[$target] .= '+';
             }
             // ok, no + ?
             $chan_flag = database::fetch($chan_flag_q);
             // get the flag record
             $new_chan_flags = str_replace($r_flag, '', $chan_flag->flags);
             if (in_array($r_flag, str_split(self::$p_flags))) {
                 database::update('chans_flags', array('flags' => $new_chan_flags, $param_field => $param), array('channel', '=', $chan));
                 // update the row with the new flags.
             } else {
                 database::update('chans_flags', array('flags' => $new_chan_flags), array('channel', '=', $chan));
                 // update the row with the new flags.
             }
             self::$set[$chan] .= $r_flag;
             // some magic :O
             return true;
         }
         if ($mode == '+') {
             if (!in_array($r_flag, str_split(self::$p_flags))) {
                 self::$already_set[$chan] .= $r_flag;
                 // some magic :O
                 return false;
             }
             if (strpos(self::$set[$target], '+') === false) {
                 self::$set[$target] .= '+';
             }
             // ok, no + ?
             $chan_flag = database::fetch($chan_flag_q);
             // get the flag record
             database::update('chans_flags', array($param_field => $param), array('channel', '=', $chan));
             // update the row with the new flags.
             self::$set[$chan] .= $r_flag;
             // some magic :O
             return true;
         }
         // the flag IS set, so now we check whether they are trying to -, or + it
         // if they are trying to - it, go ahead, error if they are trying to + it.
     } else {
         $chan_flag_q = database::select('chans_flags', array('id', 'channel', 'flags'), array('channel', '=', $chan));
         if ($mode == '+') {
             if (strpos(self::$set[$target], '+') === false) {
                 self::$set[$target] .= '+';
             }
             // ok, no + ?
             $chan_flag = database::fetch($chan_flag_q);
             // get the flag record
             $new_chan_flags = $chan_flag->flags . $r_flag;
             if (!in_array($r_flag, str_split(self::$p_flags))) {
                 database::update('chans_flags', array('flags' => $new_chan_flags), array('channel', '=', $chan));
                 // update the row with the new flags.
                 self::$set[$chan] .= $r_flag;
                 // some magic :O
                 return true;
             } else {
                 database::update('chans_flags', array('flags' => $new_chan_flags, $param_field => $param), array('channel', '=', $chan));
                 // update the row with the new flags.
                 self::$set[$chan] .= $r_flag;
                 // some magic :O
                 return true;
             }
         }
         // the flag ISNT set, so now we check whether they are trying to -, or + it
         // if they are trying to + it, go ahead, error if they are trying to _ it.
         if ($mode == '-') {
             self::$not_set[$chan] .= $r_flag;
             // some magic :O
             return false;
         }
     }
     // check if the flag is already set?
 }