summaryrefslogtreecommitdiff
path: root/index.php
blob: 08871c825fde421e45431bfb4e8c10e3901db61c (plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php

/**
 * Copyright 2009-2017 Christoph Brill <egore911@gmail.com>
 *
 * 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:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * 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';

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");
} else {
    $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 (isset($_GET['highlight_names'])) {
    setcookie('stored_users', $highlight_names, time()+2592000);
}

$colors = array('#009900', '#CC3300', '#330099', '#FF6600', '#CC33CC', '#66CCCC', '#FF0066', '#9900FF', '#00FFCC', '#6600FF');

echo '<!DOCTYPE html>
<html lang="en">
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">  <title>'.$title.'</title>
  <link rel="shortcut icon" href="favicon.ico" />
  <script src="js/jquery.min.js"></script>
  <link rel="stylesheet" href="css/bootstrap.min.css">
  <script src="js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="css/bootstrap-datepicker3.min.css">
  <script src="js/bootstrap-datepicker.min.js"></script>
  <style type="text/css">
body { padding-top: 60px; }
#setupdiv {position: absolute; top: 8.6em; right: 2em; width: 18em; background-color:white; border:solid 1px gray; padding: 10px;}
html { position: relative; min-height: 100%; }
body { margin-bottom: 60px; }
.footer { position: absolute; bottom: 0; width: 100%; height: 45px; background-color: #f5f5f5; }
div.checkbox { margin-left: 10px; }
ul#usernames li > span { margin-left: 10px; }
ul#usernames li > span > a, a.inherit { color: inherit; }
a.inherit:hover { text-decoration: none; }
.time, .username { font-weight: bold; }
div.container-fluid span a { overflow-wrap: break-word; }
  </style>'.PHP_EOL;

if (isset($date)) {
    echo '  <script type="text/javascript" src="js/script.js"></script>
  </script>'.PHP_EOL;
}

echo ' </head>
 <body>
  <nav class="navbar navbar-default navbar-fixed-top">
   <div class="container-fluid">
    <div class="navbar-header">
     <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
      <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
     </button>
     <a class="navbar-brand" href="index.php">Home</a>
    </div>
    <div id="navbar" class="collapse navbar-collapse">
     <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 '      </ul>
      <div class="navbar-form navbar-right">
       <input id="channel" name="channel" type="hidden" value="' . $channel . '" style="display: none; visibility: hidden;"/>
       <input id="highlight_names" name="highlight_names" type="hidden" value="'.$highlight_names.'" style="display: none; visibility: hidden;"/>
       <div class="input-group date">
        <input type="text" class="form-control" id="date" name="date" value="'.(isset($date) ? $date : date('Y-m-d')).'" style="width: 100px;">
        <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
       </div>
      </div>'.PHP_EOL;
if (isset($date)) {
    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>
        <ul class="dropdown-menu">
         <li><div class="checkbox"><label><input type="checkbox" name="show_joins" value="true"'.($show_joins ? ' checked="checked"' : '').' onchange="this.form.submit();">Joins/Disconnects</label></div></li>
         <li><div class="checkbox"><label><input type="checkbox" name="show_irssi" value="true"'.($show_irssi ? ' checked="checked"' : '').' onchange="this.form.submit();">IRSSI</label></div></li>
         <li><div class="checkbox"><label><input type="checkbox" name="show_html" value="true"'.($show_html ? ' checked="checked"' : '').' onchange="this.form.submit();">Linkify HTML</label></div></li>
        </ul>
       </li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
       <li class="dropdown">
        <a class="dropdown-toggle" data-toggle="dropdown" href="#"><span id="users_label">Users</span>
        <span class="caret"></span></a>
        <ul class="dropdown-menu" id="usernames">
        </ul>
       </li>
      </ul>'.PHP_EOL;
}
echo '     </form>
    </div>
   </div>
  </nav>
  <div class="container-fluid">'.PHP_EOL;

if (!isset($date)) {
    require_once('overview.php');
} else {
    require_once('details.php');
}

echo '  </div>
  <footer class="footer">
   <div class="container-fluid">
    <span class="text-muted"><a href="mailto:egore911%20-%20at%20%21%20egore911%20/%20de">Christoph Brill</a> © 2007-'.date('Y').'<a href="https://play.google.com/store/apps/details?id=de.egore911.drilog"><img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" height="45" /></a></span>
   </div>
  </footer>
 </body>
 <script type="text/javascript">
  $(\'.input-group.date\').datepicker({ format: \'yyyy-mm-dd\', autoclose: true, todayHighlight: true, endDate: \'+1d\' }).on(\'changeDate\', function(e) {
        this.parentElement.parentElement.submit();
    });
    addStyleForUsers();
 </script>
</html>'.PHP_EOL;