-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimgur.php
51 lines (48 loc) · 1.3 KB
/
imgur.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
<?php
include 'main.php';
writeHeader('Imgur Subreddit Viewer');
echo('<body style="background-color: #121211; color: #FFF"><center>');
if(empty($_GET)||$_GET["r"]=='')
$sub = 'earthporn';
else $sub = $_GET["r"];//'earthporn';
echo('<h1>'.$sub.'</h1>');
echo('<h4>click an image to download it<br />or mouseover for more details</h4>');
$url = 'http://imgur.com/r/'.$sub;
$str = file_get_contents($url);
$start = strpos($str,'posts')+7;
$stop = strrpos($str, "imagelist-loader");
$str = substr($str,$start,$stop-$start);
$ctr=0;
$tok = strtok($str, "<");
$links = array();
while ($tok !== false) {
if(strpos($tok, "i")==1) {
$links[$ctr] = substr($tok,8,5);
$ctr++;
$tok = strtok("<");
$tok = strtok("<");
$links[$ctr] = substr($tok,strrpos($tok,'title')+7);
$ctr++;
$tok = strtok("<");
$links[$ctr] = substr($tok,2);
$ctr++;
}
$tok = strtok("<");
}
$tempid = $links[0];
$temptitle = $links[1];
for($i=0;$i<sizeof($links)-1;$i++) {
if(($i+1)%3==1) {
$tempid=$links[$i];
}
else if(($i+1)%3==2) {
$temptitle=$links[$i];
}
else if(($i+1)%3==0) {
echo('<a href="http://imgur.com/download/'.$tempid.'/'.$temptitle.'"><img alt="" src="http://i.imgur.com/'.$tempid.'b.jpg" title="'.$temptitle.' ('.$links[$i].')" /></a>');
}
}
?>
</center>
</body>
</html>