From be0e7c8498c3f065c9dbdc1300b84d41b2aa6739 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 25 Jul 2019 14:29:54 +0200 Subject: lib/mysql.php: abort_iff_webspider() new - for now only logging the user agent --- buildmaster/build-list-links.php | 2 ++ buildmaster/build-list.php | 2 ++ buildmaster/build-log.php | 2 ++ buildmaster/build-slaves.php | 2 ++ buildmaster/deletion-links.php | 2 ++ buildmaster/dependencies.php | 2 ++ buildmaster/execution-times.php | 2 ++ buildmaster/log.php | 1 + buildmaster/mysql-issues.php | 2 ++ buildmaster/statistics.php | 2 ++ buildmaster/status.php | 2 ++ buildmaster/to-delete.php | 2 ++ lib/mysql.php | 12 ++++++++++++ packages/differences.php | 2 ++ 14 files changed, 37 insertions(+) diff --git a/buildmaster/build-list-links.php b/buildmaster/build-list-links.php index e707ba4..10304e4 100644 --- a/buildmaster/build-list-links.php +++ b/buildmaster/build-list-links.php @@ -2,6 +2,8 @@ require_once "../init.php"; require_once BASE . "/lib/mysql.php"; +abort_iff_webspider(); + $edges = ""; $knots = ""; $filter = "1"; diff --git a/buildmaster/build-list.php b/buildmaster/build-list.php index 2eaf08a..9da07bd 100644 --- a/buildmaster/build-list.php +++ b/buildmaster/build-list.php @@ -5,6 +5,8 @@ require_once BASE . "/lib/helper.php"; require_once BASE . "/lib/mysql.php"; require_once BASE . "/lib/style.php"; +abort_iff_webspider(); + $filter = " WHERE "; if (array_key_exists("invq", $_GET)) diff --git a/buildmaster/build-log.php b/buildmaster/build-log.php index e3fdaef..89655e4 100644 --- a/buildmaster/build-log.php +++ b/buildmaster/build-log.php @@ -5,6 +5,8 @@ require_once BASE . "/lib/http.php"; require_once BASE . "/lib/helper.php"; require_once BASE . "/lib/mysql.php"; +abort_iff_webspider(); + $extra_joins = ''; $filter = 'WHERE 1'; diff --git a/buildmaster/build-slaves.php b/buildmaster/build-slaves.php index 7a8a9f2..1285fb8 100644 --- a/buildmaster/build-slaves.php +++ b/buildmaster/build-slaves.php @@ -3,6 +3,8 @@ require_once "../init.php"; require_once BASE . "/lib/style.php"; require_once BASE . "/lib/mysql.php"; +abort_iff_webspider(); + $columns = array( "name" => array( "label" => "name", diff --git a/buildmaster/deletion-links.php b/buildmaster/deletion-links.php index 3a82c4e..f2e1644 100644 --- a/buildmaster/deletion-links.php +++ b/buildmaster/deletion-links.php @@ -3,6 +3,8 @@ require_once "../init.php"; require_once BASE . "/lib/helper.php"; require_once BASE . "/lib/mysql.php"; +abort_iff_webspider(); + $edges = ""; $knots = ""; diff --git a/buildmaster/dependencies.php b/buildmaster/dependencies.php index c513f2d..336a26f 100644 --- a/buildmaster/dependencies.php +++ b/buildmaster/dependencies.php @@ -2,6 +2,8 @@ require_once "../init.php"; require_once BASE . "/lib/mysql.php"; +abort_iff_webspider(); + $match = ""; function dependency_arch_join($name) { diff --git a/buildmaster/execution-times.php b/buildmaster/execution-times.php index 3ef4f2a..cbe1cd5 100644 --- a/buildmaster/execution-times.php +++ b/buildmaster/execution-times.php @@ -3,6 +3,8 @@ require_once '../init.php'; require_once BASE . '/lib/mysql.php'; +abort_iff_webspider(); + $result = mysql_run_query( 'SELECT' . ' UNIX_TIMESTAMP(`ssh_log`.`date`) AS `date`,' . diff --git a/buildmaster/log.php b/buildmaster/log.php index 6235b06..0653632 100644 --- a/buildmaster/log.php +++ b/buildmaster/log.php @@ -2,6 +2,7 @@ require_once "../init.php"; require_once BASE . "/lib/mysql.php"; +abort_iff_webspider(); $filter = ""; if (array_key_exists("show", $_GET) && diff --git a/buildmaster/mysql-issues.php b/buildmaster/mysql-issues.php index f84d9f5..f41ab8a 100644 --- a/buildmaster/mysql-issues.php +++ b/buildmaster/mysql-issues.php @@ -2,6 +2,8 @@ require_once "../init.php"; require_once BASE . "/lib/mysql.php"; +abort_iff_webspider(); + $ignore = ""; if (array_key_exists("ignore-haskell", $_GET)) diff --git a/buildmaster/statistics.php b/buildmaster/statistics.php index f867973..d16263b 100644 --- a/buildmaster/statistics.php +++ b/buildmaster/statistics.php @@ -2,6 +2,8 @@ require_once '../init.php'; require_once BASE . '/lib/mysql.php'; +abort_iff_webspider(); + if (array_key_exists('from', $_GET)) $min_time = 'from_base64("' . base64_encode('-' . $_GET['from']) . '")'; else diff --git a/buildmaster/status.php b/buildmaster/status.php index 05a4455..7dfbc48 100644 --- a/buildmaster/status.php +++ b/buildmaster/status.php @@ -4,6 +4,8 @@ include BASE . "/lib/mysql.php"; include BASE . "/lib/style.php"; include BASE . "/lib/helper.php"; +abort_iff_webspider(); + $result = mysql_run_query( "SELECT MAX(`package_sources`.`commit_time`) AS `last_commit`" . " FROM `package_sources`" diff --git a/buildmaster/to-delete.php b/buildmaster/to-delete.php index 8458c74..f287ce5 100644 --- a/buildmaster/to-delete.php +++ b/buildmaster/to-delete.php @@ -3,6 +3,8 @@ require_once "../init.php"; require_once BASE . "/lib/helper.php"; require_once BASE . "/lib/mysql.php"; +abort_iff_webspider(); + $result = mysql_run_query( "SELECT " . "`repositories`.`name` AS `repo`," . diff --git a/lib/mysql.php b/lib/mysql.php index ca683d8..7564a3d 100644 --- a/lib/mysql.php +++ b/lib/mysql.php @@ -98,3 +98,15 @@ function arch_filter_query($table) { $arch_filter .= ")"; return $arch_filter; } + +function abort_iff_webspider() { + if (($fp = fopen(BASE . '/user-agent-log', 'a')) !== false) { + flock($fp, LOCK_EX); + fwrite($fp, + date('Y-m-d H:i:s') . " " . + $_SERVER['HTTP_USER_AGENT'] . "\n" + ); + flock($fp, LOCK_UN); + fclose($fp); + } +} diff --git a/packages/differences.php b/packages/differences.php index 0673715..9dbb51c 100644 --- a/packages/differences.php +++ b/packages/differences.php @@ -6,6 +6,8 @@ require_once BASE . "/lib/helper.php"; require_once BASE . "/lib/style.php"; require_once BASE . "/lib/mysql.php"; +abort_iff_webspider(); + $uri_parts = explode('?', $_SERVER['REQUEST_URI'], 2); if (count($uri_parts) > 1) $options = $uri_parts[1]; -- cgit v1.2.3