Location: PHPKode > scripts > XXXpROH4x0r > xxxproh4x0r-2-0/proxy_design/ImplementsBotFunction.php
<?php

/**
 * Class implements function
 * 
 * @Package BOT IRC => Real Subject
 * @Name XXXpROH4x0r
 * @Author cobra90nj <cobra90nj[at]gmail[dot]com>
 * @License http://www.gnu.org/licenses/gpl-3.0.html GNU Public License
 * @Version 2.0
 */

include_once('ConfigIrcBot.php');

class ImplementsFunction {
				
	function __construct() 
	{
	}
	
	/**
	 * Function for connect to irc
	 * 
	 * @param Array $ParamsConnect Object configure param
	 * @return String $OpenSocket Socket open to server irc
	 */
	function ConnectToIrc($ParamsConnect) 
	{
		if (!($OpenSocket = @fsockopen($ParamsConnect[1], $ParamsConnect[3]))) {
			echo '1Mp0551B1L3 4pRir3 L4 C0NN35510n3!';
			die();
		}
		else {
			$Header  = "NICK {$ParamsConnect[0]}\r\n";
			$Header .= "USER {$ParamsConnect[0]} 127.0.0.1 {$ParamsConnect[1]} : {$ParamsConnect[0]}\r\n";
			$Header .= "IDENTIFY {$ParamsConnect[4]}\r\n";
			$Header .= "JOIN {$ParamsConnect[2]}\n\n";
		}
		fwrite($OpenSocket, $Header);
		
		return $OpenSocket;
	}
	
	/**
	 * Function for setting on operator
	 * 
	 * @param String $Name Nome of operator
	 * @param String $Password Password of operator
	 * @return True if the Operatos is exists
	 */
	function MakeAnOp($Name, $Password) 
	{
		$Name     = trim($Name);
		$Password = trim($Password);
		$FileOpen = file('./opnick', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
		
		for ($Nint = 0; isset($FileOpen[$Nint]); $Nint++) {
			$OpExplode[] = explode(' ', $FileOpen[$Nint]);
			
			if ($Name === $OpExplode[$Nint][0] && $Password === $OpExplode[$Nint][1]) {
				return true;
			}
		}
		
		return false;
	}
	
	/**
	 * Function for log the chatt
	 * 
	 * @param String $TextChannel All response of server irc
	 * @return false if is not matching
	 */
	function LogChannel($TextChannel) 
	{
		if (preg_match('~^:(.*)!([A-Za-z0-9]+)@(.*):([A-Za-z0-9èòàù[:punct:]+ ]+)~', $TextChannel, $MatchText)) {
			
			$Fp = fopen('./logchannel', 'a');
			
			flock($Fp, LOCK_EX);
			fwrite($Fp, "$MatchText[2]: $MatchText[4] \n");
			flock($Fp, LOCK_UN);
			fclose($Fp); 
		}
		
		return false;
	}
	
	/**
	 * Function for shorting a url
	 * 
	 * @param String $Url Url have need short
	 * @return A Url short
	 */
	function MakeTinyUrl($Url)
	{
		$Url = trim($Url);
		
		if (!($OpenSocket = @fsockopen('www.tinyurl.com', 80))) {
			return '1Mp0551B1L3 4pRir3 L4 C0NN35510n3!';
		}
		else {
			$Header  = "GET /api-create.php?url=$Url HTTP/1.0\r\n";
			$Header .= "Host: tinyurl.com\r\n";
			$Header .= "Connection: Close\r\n\r\n";
		}
		fwrite($OpenSocket, $Header);
		
		while (!feof($OpenSocket)) {
			$Response .= fgets($OpenSocket, 128);
		}
		fclose($OpenSocket);
		preg_match('~(http\S+)~', $Response, $UrlMatch);
		
		return $UrlMatch[1];
	}
	
}
Return current item: XXXpROH4x0r