示例#1
0
 /**
  *	Activate a Script from the Script directory.
  */
 public function activateScript($sScriptName)
 {
     $sIdentifier = CoreUtilities::getScriptIdentifier($sScriptName);
     if ($sIdentifier == false) {
         return false;
     }
     println(" * Activated script '{$sScriptName}'");
     $this->aScripts[$sScriptName] = new $sIdentifier($this, $sScriptName);
     if ($this->iNetworksLoaded) {
         $this->triggerEvent("onConnect");
     }
     return true;
 }
示例#2
0
 /**
  *	This method returns an array of user criteria and channels,
  *	that is used to match users in the query.
  */
 private static function generateSearchCriteria($sQueryString)
 {
     $pInstance = Core::getCurrentInstance();
     $aChannels = array();
     $aCriteria = array("Nickname" => "%", "Username" => "%", "Hostname" => "%");
     # Determinate channel selector and query separator.
     if (preg_match('/^[\\s]{0,}(.*?)[\\s]{0,}\\:[\\s]{0,}(.*?)[\\s]{0,}$/', preg_quote($sQueryString), $aParts)) {
         $sQueryString = stripslashes($aParts[1]);
         $sCSelectorList = stripslashes($aParts[2]);
         $sPrefixes = $pInstance->getServerConfiguration("PREFIX");
         $sPrefix = substr($sPrefixes, strpos($sPrefixes, ")") + 1);
         $sChanTypes = preg_quote($pInstance->getServerConfiguration("CHANTYPES"));
         $sChannelPattern = "/^([\\^]{0,1})([{$sPrefix}]{0,})([{$sChanTypes}])(.*)\$/";
         foreach (explode(',', $sCSelectorList) as $sSelector) {
             $sSelector = trim($sSelector);
             $aSelector = explode(' ', $sSelector);
             $iSelectorCount = count($aSelector);
             $aChannelElements = array();
             foreach ($aSelector as $sChannel) {
                 if (preg_match($sChannelPattern, $sChannel, $aMatches)) {
                     $aChannelElements[] = (object) array("Channel" => $pInstance->getChannel("{$aMatches[3]}{$aMatches[4]}"), "Modes" => preg_split('//', CoreUtilities::modeCharToLetter($aMatches[2]), -1, PREG_SPLIT_NO_EMPTY), "Negation" => $aMatches[1] == "^");
                 }
             }
             $aChannels[] = $aChannelElements;
         }
     }
     # Username selector.
     if (preg_match('/^!(.*?)$/', $sQueryString, $aParts)) {
         $aCriteria = array("Nickname" => "%", "Username" => trim($aParts[1]), "Hostname" => "%");
     } elseif (preg_match('/^@(.*?)$/', $sQueryString, $aParts)) {
         $aCriteria = array("Nickname" => "%", "Username" => "%", "Hostname" => trim($aParts[1]));
     } elseif (preg_match('/^(.*?)!(.*?)@(.*?)$/', $sQueryString, $aParts)) {
         $aCriteria = array("Nickname" => trim($aParts[1]), "Username" => trim($aParts[2]), "Hostname" => trim($aParts[3]));
     } elseif (preg_match('/^(.*?)@(.*?)$/', $sQueryString, $aParts)) {
         $aCriteria = array("Nickname" => "%", "Username" => trim($aParts[1]), "Hostname" => trim($aParts[2]));
     } elseif (preg_match('/^(.*?)$/', $sQueryString, $aParts)) {
         $aCriteria = array("Nickname" => trim($aParts[1]), "Username" => "%", "Hostname" => "%");
     }
     return array($aChannels, $aCriteria);
 }
示例#3
0
 /**
  *	Alright, I'm cheating with the CTCP stuff.
  */
 public static function CTCP(CoreMaster $pInstance, MessageObject $pMessage)
 {
     $pMessage->Payload = substr($pMessage->Payload, 1, -1);
     $aCTCP = explode(' ', $pMessage->Payload, 2);
     if (empty($aCTCP[1])) {
         $aCTCP[1] = "";
     }
     switch ($aCTCP[0]) {
         case "VERSION":
             return $pInstance->Notice($pMessage->User->Nickname, chr(1) . "VERSION {$pInstance->pConfig->Network->version}" . chr(1));
         case "TIME":
             return $pInstance->Notice($pMessage->User->Nickname, chr(1) . "TIME " . date("d/m/Y H:i:s", time()) . chr(1));
         case "PING":
             return $pInstance->Notice($pMessage->User->Nickname, chr(1) . "PING {$aCTCP[1]}" . chr(1));
         case "UPTIME":
             $aDuration = CoreUtilities::Duration($pInstance->pSocket->pConfig->StartTime);
             $sString = "UPTIME {$aDuration['weeks']} weeks, {$aDuration['days']} days, {$aDuration['hours']} hours, {$aDuration['minutes']} minutes, {$aDuration['seconds']} seconds.";
             return $pInstance->Notice($pMessage->User->Nickname, chr(1) . $sString . chr(1));
         case "START":
             return $pInstance->Notice($pMessage->User->Nickname, chr(1) . "START " . date("d/m/Y H:i:s", time($pInstance->pSocket->pConfig->StartTime)) . chr(1));
     }
 }