summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorChristoph Brill <egore911@gmail.com>2017-02-18 22:45:20 +0100
committerChristoph Brill <egore911@gmail.com>2017-02-18 22:47:49 +0100
commitc7e616af1ba1c20e48eed10b07a08be062839d78 (patch)
treed7b2ca6dce2aa0c0f7ad5c73c34d9606b80ad575 /index.php
parent06b60c83bdfa714e631bbc066172420c0b8c85b3 (diff)
Relicense to MIT
Also fix a couple of phpcs warnings
Diffstat (limited to 'index.php')
-rwxr-xr-xindex.php103
1 files changed, 62 insertions, 41 deletions
diff --git a/index.php b/index.php
index 5f85f3c..3a7a02a 100755
--- a/index.php
+++ b/index.php
@@ -1,42 +1,55 @@
<?php
/**
- * index.php - Part of the dri-devel IRC logging facilities
+ * Copyright 2009-2017 Christoph Brill <egore911@gmail.com>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * Copyright (C) 2009-2012 Christoph Brill <egore911@egore911.de>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @category Web
+ * @package DRI\HTML
+ * @author Christoph Brill <egore911@gmail.com>
+ * @copyright 2012-2017 Christoph Brill <egore911@gmail.com>
+ * @license MIT https://opensource.org/licenses/MIT
+ * @link https://people.freedesktop.org/~cbrill/
*/
-require_once('common.inc.php');
+require_once 'common.inc.php';
if (isset($date)) {
- $title = 'IRC Logs of #'.$channel.' on irc.freenode.net for '.$date;
- $oneday = new DateInterval("P1D");
- $prevday = date_sub(date_create_from_format("Y-m-d", $date), $oneday)->format("Y-m-d");
- $nextday = date_add(date_create_from_format("Y-m-d", $date), $oneday)->format("Y-m-d");
-
+ $title = 'IRC Logs of #'.$channel.' on irc.freenode.net for '.$date;
+ $oneday = new DateInterval("P1D");
+ $prevday = date_sub(date_create_from_format("Y-m-d", $date), $oneday)->format("Y-m-d");
+ $nextday = date_add(date_create_from_format("Y-m-d", $date), $oneday)->format("Y-m-d");
} else {
- $title = 'DRI IRC log overview';
+ $title = 'DRI IRC log overview';
}
$show_html = !isset($_GET['channel']) || (isset($_GET['show_html']) && $_GET['show_html'] == 'true');
$show_joins = isset($_GET['show_joins']) && $_GET['show_joins'] == 'true';
$show_irssi = isset($_GET['show_irssi']) && $_GET['show_irssi'] == 'true';
$highlight_names = isset($_GET['highlight_names']) ? $_GET['highlight_names'] : (isset($_COOKIE['stored_users']) ? $_COOKIE['stored_users'] : '');
if ($highlight_names == '') {
- $users = array();
+ $users = array();
} else {
- $users = explode(';', $highlight_names);
+ $users = explode(';', $highlight_names);
}
if (isset($_GET['highlight_names'])) {
- setcookie('stored_users', $highlight_names, time()+2592000);
+ setcookie('stored_users', $highlight_names, time()+2592000);
}
$colors = array('#009900', '#CC3300', '#330099', '#FF6600', '#CC33CC', '#66CCCC', '#FF0066', '#9900FF', '#00FFCC', '#6600FF');
@@ -68,22 +81,22 @@ div.container-fluid span a { overflow-wrap: break-word; }
</style>'.PHP_EOL;
if (!isset($_SERVER['HTTP_DNT']) || $_SERVER['HTTP_DNT'] != 1) {
- include_once("analyticstracking.php");
+ include_once "analyticstracking.php";
}
if (isset($date)) {
- echo ' <script type="text/javascript" src="js/core-min.js"></script>
+ echo ' <script type="text/javascript" src="js/core-min.js"></script>
<script type="text/javascript" src="js/sha1-min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
</script>'.PHP_EOL;
- if (count($users) > 0) {
- echo ' <style type="text/css">'.PHP_EOL;
- foreach ($users as $user) {
- echo ' span.user_'.$user.' { '.get_color($user).'; }'.PHP_EOL;
+ if (count($users) > 0) {
+ echo ' <style type="text/css">'.PHP_EOL;
+ foreach ($users as $user) {
+ echo ' span.user_'.$user.' { '.get_color($user).'; }'.PHP_EOL;
+ }
+ echo ' </style>'.PHP_EOL;
}
- echo ' </style>'.PHP_EOL;
- }
}
echo ' </head>
@@ -103,7 +116,7 @@ echo ' </head>
<form method="get" action="" id="mainform" name="mainform">
<ul class="nav navbar-nav">'.PHP_EOL;
foreach ($channels as $channel_) {
- echo ' <li'.($channel_ == $channel ? ' class="active"' : '').'><a href="#" onclick="$(\'#channel\').val(\''.$channel_.'\'); $(\'#mainform\').submit(); return false;">'.$channel_.'</a></li>'.PHP_EOL;
+ echo ' <li'.($channel_ == $channel ? ' class="active"' : '').'><a href="#" onclick="$(\'#channel\').val(\''.$channel_.'\'); $(\'#mainform\').submit(); return false;">'.$channel_.'</a></li>'.PHP_EOL;
}
echo ' </ul>
<div class="navbar-form navbar-right">
@@ -115,7 +128,7 @@ echo ' </ul>
</div>
</div>'.PHP_EOL;
if (isset($date)) {
-echo ' <ul class="nav navbar-nav navbar-right">
+ echo ' <ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Options
<span class="caret"></span></a>
@@ -131,10 +144,10 @@ echo ' <ul class="nav navbar-nav navbar-right">
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><span id="users_label">Users'.(count($users) > 0 ? ' ('.count($users).')' : '').'</span>
<span class="caret"></span></a>
<ul class="dropdown-menu" id="usernames">'.PHP_EOL;
-foreach ($users as $user) {
- echo ' <li id="user_'.$user.'"><span class="checkbox user_'.$user.'"><a href="javascript:addUser(\''.$user.'\');">'.$user.'</a></span></li>'.PHP_EOL;
-}
-echo ' </ul>
+ foreach ($users as $user) {
+ echo ' <li id="user_'.$user.'"><span class="checkbox user_'.$user.'"><a href="javascript:addUser(\''.$user.'\');">'.$user.'</a></span></li>'.PHP_EOL;
+ }
+ echo ' </ul>
</li>
</ul>'.PHP_EOL;
}
@@ -144,18 +157,26 @@ echo ' </form>
</nav>
<div class="container-fluid">'.PHP_EOL;
-function get_color($user) {
- global $users;
- $isUser = array_search($user, $users);
- if ($isUser !== false) {
- return 'color: #'.substr(sha1($user), 0, 6);
- }
+/**
+ * Get the CSS representing the color matching for the given user_error
+ *
+ * @param string $user the username
+ * @return string the CSS representing the color
+ */
+function get_color($user)
+{
+ global $users;
+ $isUser = array_search($user, $users);
+ if ($isUser !== false) {
+ return 'color: #'.substr(sha1($user), 0, 6);
+ }
+ return '';
}
if (!isset($date)) {
- require_once('overview.php');
+ require_once('overview.php');
} else {
- require_once('details.php');
+ require_once('details.php');
}
echo ' </div>