-
Notifications
You must be signed in to change notification settings - Fork 0
/
listCrawls.php
62 lines (56 loc) · 1.54 KB
/
listCrawls.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
<?php
error_reporting(E_ERROR);
function readCrawlData($crawlDir) {
$data = [];
$data['crawlDir'] = $crawlDir;
$crawlData = file_get_contents($crawlDir . "DbSeoSpiderFileKey");
$lines = explode("\n",$crawlData);
foreach($lines as $line) {
$dat = explode("=",$line);
if (count($dat) > 1) {
$data[$dat[0]] = stripcslashes($dat[1]);
};
if (substr($line,0,1) == '#') {
$data['date'] = substr($line,1,strlen($line));
}
}
return $data;
}
function findDerbyDir($crawlDir) {
$str = '';
foreach(scandir($crawlDir) as $file) if (substr($file,0,8) == 'results_') $str = $crawlDir . $file . "/sql";
return $str;
}
echo("ScreamingFrog-Projectliste\n");
echo("----------------------------\n");
$id = $argv[1];
$frogDir = $_SERVER["HOME"] . '/.ScreamingFrogSEOSpider/ProjectInstanceData/';
$crawlList = scandir($frogDir);
$datList = [];
foreach($crawlList as $crawl) {
$crawlDir = $frogDir . $crawl . "/";
$datList[] = readCrawlData($crawlDir);
}
if ($id == "") {
$c = 0;
foreach($datList as $crawl) {
$c++;
echo($c . " " . $crawl["url"] . " - " . $crawl["date"] . "\n");
}
echo("----------------------------\n");
echo("Crawl-number: ");
$id = trim(fgets(STDIN));
}
if ($id != '') {
$c = 0;
foreach($datList as $crawl) {
$c++;
if ($c == $id) {
echo("Crawldaten:\n");
echo("URL: " . $crawl["url"] . "\n");
echo("Date: " . $crawl["date"] . "\n");
$derbyurl = findDerbyDir($crawl["crawlDir"]);
echo("Derby-Connection-String: jdbc:derby:" . $derbyurl . "\n");
}
}
}