]>
Commit | Line | Data |
---|---|---|
a7f1713c | 1 | #!/usr/bin/php.cli |
2 | <?php | |
9dcdc6b4 | 3 | // $Revision: 1.3 $, $Date: 2009/01/20 07:37:40 $ |
a7f1713c | 4 | /* |
9dcdc6b4 | 5 | $database = 'sqlite:/home/services/httpd/html/pld-buildlogs/db/buildlogs2.db'; |
a7f1713c | 6 | $root_directory = '/home/services/ftp/pub/pld-buildlogs'; |
7 | // $database and $root_directory are taken from buildlogs.inc . | |
8 | // parameter: argv[1] - full path to the log file. | |
9 | */ | |
10 | ||
11 | $result = array("FAIL" => 0, "OK" => 1); | |
f7b002e8 | 12 | include('buildlogs.inc'); |
a7f1713c | 13 | |
14 | if (!isset($argv[1])) { | |
15 | die("Usage: $argv[0] full_path_to_the_log\n"); | |
16 | } | |
8f0e31ba | 17 | if (!preg_match("|^$root_directory/(.*)/(.*)/(.*)/(.*)\.bz2$|", $argv[1], $matches)) |
a7f1713c | 18 | exit(0); |
19 | ||
8f0e31ba | 20 | if (preg_match("/^(.*),(.*)$/", $matches[4], $m2)) { |
21 | $name = $m2[1]; | |
22 | $id = $m2[2]; | |
23 | } else { | |
24 | $name = $matches[4]; | |
25 | $id = ""; | |
26 | } | |
a7f1713c | 27 | $dist = $matches[1]; |
28 | $arch = $matches[2]; | |
29 | $ok = $result[$matches[3]]; | |
a7f1713c | 30 | $size = filesize($argv[1]); |
31 | $mtime = filemtime($argv[1]); | |
32 | ||
5e447961 ER |
33 | #print "name $name, id $id, dist $dist, arch $arch, ok $ok, size, $size, mtime $mtime\n"; |
34 | ||
a7f1713c | 35 | try { |
36 | $dbh = new PDO("$database"); | |
37 | } catch (PDOException $e) { | |
38 | die ($e->getMessage()); | |
39 | } | |
40 | $result = $dbh->query("SELECT log_id FROM logs WHERE dist = '$dist' AND arch = '$arch' AND name = '$name'" | |
41 | ." AND id = '$id' LIMIT 1")->fetchAll(); | |
42 | if (count($result) == 1) { | |
43 | foreach ($result as $row) { | |
44 | $query = "UPDATE logs SET ok = $ok, size = $size, mtime = $mtime WHERE log_id = $row[log_id]"; | |
45 | break; | |
46 | } | |
47 | } else { | |
48 | $query = "INSERT INTO logs(dist, arch, ok, name, size, mtime, id) " | |
49 | . "VALUES('$dist', '$arch', $ok, '$name', $size, $mtime, '$id')"; | |
50 | } | |
51 | $ile = $dbh->exec("$query"); | |
52 | if ($ile != 1) { | |
53 | print_r($dbh->errorInfo()); | |
54 | } | |
55 | ?> |