]> git.pld-linux.org Git - projects/buildlogs.git/blame - pld-buildlogs/scripts/addlog.php
- buildlogs2 separated from 1
[projects/buildlogs.git] / pld-buildlogs / scripts / addlog.php
CommitLineData
a7f1713c 1#!/usr/bin/php.cli
2<?php
8f0e31ba 3// $Revision: 1.1 $, $Date: 2008/10/22 09:22:15 $
a7f1713c 4/*
5$database = 'sqlite:/home/services/httpd/html/pld-buildlogs/db/buildlogs.db';
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);
8f0e31ba 12include('buildlogs2.inc');
a7f1713c 13
14if (!isset($argv[1])) {
15 die("Usage: $argv[0] full_path_to_the_log\n");
16}
8f0e31ba 17if (!preg_match("|^$root_directory/(.*)/(.*)/(.*)/(.*)\.bz2$|", $argv[1], $matches))
a7f1713c 18 exit(0);
19
8f0e31ba 20if (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
33try {
34 $dbh = new PDO("$database");
35} catch (PDOException $e) {
36 die ($e->getMessage());
37}
38$result = $dbh->query("SELECT log_id FROM logs WHERE dist = '$dist' AND arch = '$arch' AND name = '$name'"
39." AND id = '$id' LIMIT 1")->fetchAll();
40if (count($result) == 1) {
41 foreach ($result as $row) {
42 $query = "UPDATE logs SET ok = $ok, size = $size, mtime = $mtime WHERE log_id = $row[log_id]";
43 break;
44 }
45} else {
46 $query = "INSERT INTO logs(dist, arch, ok, name, size, mtime, id) "
47 . "VALUES('$dist', '$arch', $ok, '$name', $size, $mtime, '$id')";
48}
49$ile = $dbh->exec("$query");
50if ($ile != 1) {
51 print_r($dbh->errorInfo());
52}
53?>
This page took 0.098462 seconds and 4 git commands to generate.