-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.php
More file actions
79 lines (69 loc) · 1.88 KB
/
Copy pathstart.php
File metadata and controls
79 lines (69 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* wLeaf
*
* IRC / ZNC administration bot
*
* @author Werring <thomwerring@gmail.com>
* @copyright Copyright © 2010, Thom Werring
* @version 2.1.0
*/
define("CONNECTED", true);
define("DISCONNECTED", false);
define("DEBUG",false);
//error_reporting(0);
/**
* Auto loads classfiles
*/
function __autoload($class_name) {
$class = strtolower(implode("/",explode("_",$class_name)). ".php");
require_once $class;
}
Irc_Format::log("Starting wLeaf v2.1.0");
Irc_Format::log("database","INIT");
$sql = new Database_Mysql();
$sql->clear("IrcUserData");
$sql->clear("InternalAdressList");
Irc_Format::log("configuration","INIT");
$config = new WleafConfig();
Irc_Format::log("irc connection","INIT");
$socket = new Irc_Socket();
Irc_Format::log("Internal Adress List", "INIT");
$ial = new Irc_Channel_IAL($config->getConf('network'));
/**
* IRC startup
*
* sends user, nick and password lines
*/
$socket->write("USER ".$config->getConf("ident")." ".$config->getConf("ident")." ".$config->getConf("server")." :".$config->getConf("realname"));
$socket->write("PASS ".$config->getConf("password"));
$socket->write("NICK ".$config->getConf("nick"));
while(Irc_Socket::$connected){
$time = time();
/**
* DEBUG only run for ~ 120 seconds
*/
if(($time-120)>$config->getConf("startupTime") && DEBUG){
$socket->write("QUIT");
sleep(1);
$socket->close("Closing connection after 2 minutes of testing");
}
$socket->readline();
/**
* incomming lines
*
* Prevends double handling of lines and handling empty lines
*/
$data = Irc_Socket::$line . $time;
if($time === $data || strlen($time)===strlen($data) || $lastLine === $data){
continue;
}
$lastLine = $data;
/**
* Event handler
*/
Irc_Channel_IAL::handle();
Irc_Handle::handle();
Znc_Module::cronjobDeleteAccounts();
}
?>