-
Notifications
You must be signed in to change notification settings - Fork 0
/
getpics.php
110 lines (82 loc) · 2.04 KB
/
getpics.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
<?php
/**
* Main Program to read through the stuff
*
* Doc: missing
*
* @copyright (C) Mayflower GmbH for Vaillant Group
* @author Alex Aulbach <[email protected]> ({ssilk})
* @created 23.10.12
* @version $Id$
*
*/
if ($argc <= 2) {
die("Need 2 params: $argv[0] CONFIGFILE MODE\n");
}
// load config
include_once $argv[1];
$mode = $argv[2];
if (!in_array($mode, array('run', 'debug'))) {
die("Unknown mode '$mode'\n");
}
$level = 0;
if ($mode == 'debug') {
if (empty($argv[3])) {
$level = 1;
} else {
$level = $argv[3];
}
$debug = true;
} else {
$debug = false;
}
// config class is now globally available
$page = new page();
$page->purify();
if ($debug and $level == 1) {
echo "CONTENT: " . $page->content;
exit;
}
/////////////////////////////////////////////////////////
foreach (config::$filters as $name => $filters) {
echo "NAME: $name\n";
$content = $page->content;
foreach ($filters as $filtergroupname => $filtergroups) {
echo "FILTERGROUP $filtergroupname\n";
foreach ($filtergroups as $filtertype => $filter) {
echo "Filtertype: $filtertype $filter\n";
switch ($filtertype) {
case 'regex' :
$matches = array();
if (preg_match($filter, $content, $matches)) {
$content = $matches[1];
} else {
$content = 'not found';
}
}
}
}
}
if ($debug and $level == 2) {
echo "CONTENT: " . $content;
exit;
}
#var_export($found_pics);
class page {
public $content;
public function __construct($uri = null)
{
$this->load($uri);
}
public function load($uri = null)
{
if (empty($uri)) {
$uri = config::$baseUrl;
}
$this->content = file_get_contents($uri);
}
public function purify()
{
$this->content = preg_replace('!<script[^>]*?>.*?</script[^>]*?>!s', '', $this->content);
}
}