-
Notifications
You must be signed in to change notification settings - Fork 1
/
7.1_old.php
159 lines (157 loc) · 4.74 KB
/
7.1_old.php
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
set_time_limit(0);
$server = "irc.freenode.org";
$nick = "etc-bot";
$channels = array( "#dchatt","#atxhack","#anonbottest","#wenetapls");
$port = 6667;
$lastused = array();
$connection = fsockopen("$server", $port);
fputs ($connection, "USER $nick $nick $nick $nick :$nick\n");//lulz
fputs ($connection, "NICK $nick\n");
foreach($channels as $channel)
{
fputs ($connection, "JOIN {$channel}\n");
fputs ($connection, "PRIVMSG {$channel} :Hello, i'm a bot, developed by Daniel, please read https://raw.githubusercontent.com/danieltroger/7.1/master/LICENSE before using me.\n");
}
while(1){
while($data = fgets($connection)){
echo $data;
flush();
$a1 = explode(' ', $data);
$a2 = explode(':', $a1[3]);
$a3 = explode('@', $a1[0]);
$a4 = explode('!', $a3[0]);
$a5 = explode(':', $a4[0]);
$a6 = explode(':', $data);
$onlyword = substr($a1[4], 0, -1);
$user = $a5[1];
$inchannel = $a1[2];
$firstword = $a1[4];
if($a1[0] == "PING"){
fputs($connection, "PONG ".$a1[1]."\n");
}
$args = NULL; for ($i = 4; $i < count($a1); $i++) {$args .= $a1[$i] . ' ';}
$all = substr($args, 0, -1);
$len = strlen($firstword) + 1;
$argsafterfirstword = substr($all,$len);
if(strpos(substr(strtolower($a1[3]),1),"!stether") !== false )
{
fputs($connection,"PRIVMSG {$inchannel} :{$user}: Add repo.natur-kultur.eu to your sources in cydia and install 7.1 semitether.\n");
}
if(strpos(substr(strtolower($a1[3]),1),"!define") !== false )
{
fputs($connection,"PRIVMSG {$inchannel} :{$user}: " . uddefine(str_replace("\r","",$a1[4]),"http://de.urbandictionary.com/define.php?term=") . "\n");
}
if(strpos(substr(strtolower($a1[3]),1),"!uurl") !== false )
{
$t = $a1[4];
if(isset($a1[5]))
{
$t .= " " . $a1[5];
}
$ruser = strtolower(str_replace("\n","",str_replace("\r","",$t)));
$uurl = url($ruser,ge("http://www.jailbreakqa.com/users/?q=" . urlencode($ruser)));
fputs($connection,"PRIVMSG {$inchannel} :{$user}: http://jailbreakqa.com" . $uurl . "\n");
}
if(strpos(substr(strtolower($a1[3]),1),"!karma") !== false )
{
print_r($lastused);
if(isset($lastused[$user]))
{
$aa = time()-$lastused[$user];
}
echo "aa = $aa\n";
if(($aa > 10) || (!isset($lastused[$user])))
{
echo "valid\n";
$lastused[$user] = time();
echo "setting timer...\n";
$t = $a1[4];
if(isset($a1[5]))
{
$t .= " " . $a1[5];
}
$ruser = strtolower(str_replace("\n","",str_replace("\r","",$t)));
$uurl = url($ruser,ge("http://www.jailbreakqa.com/users/?q=" . urlencode($ruser)));
if(!$uurl)
{
fputs($connection,"PRIVMSG {$inchannel} :{$user}: User not found.\n");
}
else
{
fputs($connection,"PRIVMSG {$inchannel} :{$user}: {$ruser} has " . karma($uurl) . " karma.\n");
}
echo "done with request\n";
}
}
if(strpos($data, $nick)!== false && ((strpos($data, 'thx')!== false) || (strpos($data, 'thank')!== false)|| (strpos($data, 'thanx')!== false))){
fputs($connection, "PRIVMSG {$inchannel} :{$user}: No problem!\n");
}
if(strpos(substr(strtolower($a1[3]),1),"!7.1") !== false )
{
fputs($connection,"PRIVMSG {$inchannel} :{$user}: iOS 7.1 tweaklist: http://goo.gl/5oxNkN\n");
}
}
}
function uddefine($term,$baseuri)
{
$dom = new DOMDocument();
@$dom->loadHTML(ge($baseuri. urlencode($term)));
$classname="meaning";
$finder = new DomXPath($dom);
$elements = $finder->query("//*[contains(@class, '$classname')]");
$text = str_replace("\r","",str_replace(".",". ",str_replace(":",": ",str_replace("\n","",$elements->item(0)->textContent))));
if(strlen($text) < 4)
{
return "Something went wrong, {$text}";
}
else
{return $text;}
}
function ge($url)
{
echo "curling $url...\n";
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_USERAGENT, "PHP55");
$response = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ));
$response = preg_split( '/([\r\n][\r\n]){2}/', curl_exec( $ch ),2);
curl_close( $ch );
echo "request complete.\n";
return $response[1];
}
function karma($userurl)
{
$dom = new DOMDocument();
@$dom->loadHTML(ge("http://www.jailbreakqa.com" . $userurl));
$div = $dom->getElementById('user-reputation');
return $div->textContent;
}
function url($user,$html)
{
$dom = new DOMDocument();
@$dom->loadHTML($html);
$opshit = "♦";
$a = $dom->getElementsByTagName('a');
for ($i =0; $i < $a->length; $i++) {
$elem = $a->item($i);
$cont = strtolower($elem->textContent);
$href = $elem->getAttribute("href");
if($cont == $user)
{
return $href;
}
elseif($cont == $user . " ". $opshit)
{
return $href;
}
elseif($cont == $user . " ". $opshit . $opshit)
{
return $href;
}
}
return false;
}
?>