* @author DrX
 * @copyright 2008-2009 Alex Yu and DrX
 */
ignore_user_abort( TRUE );
set_time_limit(0);
require_once 'core.php';
$bots = array();
$access = xp_get("botconfig");
$config = xp_get("config");
$sizes = array('K' => 1.0/1024, 'M' => 1, 'G' => 1024, 'T' => 1048576);
foreach($access as $file) {
	if(function_exists("curl_init") && (stristr($file,"http://") || stristr($file,"ftp://") || stristr($file,"https://"))) {
		$ch = curl_init();
		curl_setopt_array($ch, array( CURLOPT_URL => $file, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => FALSE ));
		if(!($xdccList = curl_exec($ch))) {
			print("ERROR: Unable to fetch remote file {$file}
\n");
			print(curl_error($ch)."
\n");
			continue;
		}
	} else {
		if(!($xdccList = file_get_contents($file))) {
			print("ERROR: Unable to fetch file {$file}
\n");
			continue;
		}
	}
	$xdccList = str_replace( array( chr(2), chr(3), chr(16), chr(31), chr(13) ), "", $xdccList ); //remove irc formatting (or something <_<)
	if(preg_match("/\s+\*\*\s+(?:To|Pour)\s+(?:request|télécharger)\s+(?:a|un)\s+(?:file|fichier),\s+(?:type|tape)\s+\"\/msg\s+(.*?)\s+xdcc\s+send|get\s+#x\"\s+\*\*\s+\W/mi",$xdccList,$data['nick'])) {
		$bot = array();
		$match = $config['group'] ? ".*".str_replace( array("^",".","*","\\","+","?","\$"), array("\^","\.","\*","\\\\","\+","\?","\\\$"), $config['group'] ).".*" : ".*";
		eval("preg_match_all(\"/#(\\d+)\\s+\\d+x\\s+\\[.*?(\\d+\\.?\\d+?)(\\D)\\]\\s+(\\d+\\.\\d+\\.\\d+\\s+\\d+:\\d+\\s+)?(".$match.")\\W/mi\",\$xdccList,\$bot['packs']);");
		$bot['nick'] = $data['nick'][1];
		for($i=0;$i\n");
	}
}
$time = time();
xp_set("bots",$bots);
xp_set("time",$time);
?>