summaryrefslogtreecommitdiff
path: root/lib/style.php
blob: a1d9b2b49ce3ad3d00255c1a469eba88993da959 (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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
<?php

if (isset($pkglist_sorts))
  return;

require_once BASE . "/lib/mysql.php";

function print_header($title, $subdir = "packages") {
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Arch Linux 32<?php
if (!empty($title))
  print " - " . $title;
?></title>
    <link rel="stylesheet" type="text/css" href="/static/archweb.css" media="screen, projection" />
    <link rel="icon" type="image/x-icon" href="/static/favicon.ico" />
    <link rel="shortcut icon" type="image/x-icon" href="/static/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="/static/flags/fam.47411010d402.css" media="screen, projection" />
  </head>
  <body class="">
    <div id="archnavbar" class="anb-<?php print $subdir; ?>">
      <div id="archnavbarlogo">
        <h1><a href="/" title="Return to the main page">Arch Linux</a></h1>
      </div>
      <div id="archnavbarmenu">
        <ul id="archnavbarlist">
          <li id="anb-home"><a href="https://www.archlinux32.org/">Home</a></li>
          <li id="anb-packages"><a href="https://www.archlinux32.org/packages">Packages</a></li>
          <li id="anb-forums"><a href="https://bbs.archlinux32.org/">Forums</a></li>
          <li id="anb-bugs"><a href="https://bugs.archlinux32.org/" title="Report and track bugs">Bugs</a></li>
          <li id="anb-mailing-list"><a href="https://lists.archlinux.org/listinfo/arch-ports">Mailing List</a></li>
          <li id="anb-download"><a href="https://www.archlinux32.org/download/" title="Get Arch Linux">Download</a></li>
          <li id="anb-arch-linux-official"><a href="https://www.archlinux.org/">Arch Linux Official</a></li>
        </ul>
      </div>
    </div>
    <div id="content">
<?php
  show_warning_on_offline_slave();
}

function print_footer() {
?>
      <div id="footer">
        <p>
          Copyright © 2002-2019 <a href="mailto:jvinet@zeroflux.org" title="Contact Judd Vinet">Judd Vinet</a> and <a href="mailto:aaron@archlinux.org" title="Contact Aaron Griffin">Aaron Griffin</a>.
          Copyright © 2018-2020 <a href="mailto:arch@eckner.net" title="Contact Erich Eckner">Erich Eckner</a>.
        </p>
        <p>
          The Arch Linux name and logo are recognized <a href="https://wiki.archlinux.org/index.php/DeveloperWiki:TrademarkPolicy" title="Arch Linux Trademark Policy">trademarks</a>. Some rights reserved.
        </p>
        <p>
          The registered trademark Linux® is used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a world-wide basis.
        </p>
      </div>
    </div>
    <script type="application/ld+json">
      {
        "@context": "http://schema.org",
        "@type": "WebSite",
        "url": "/",
        "potentialAction": {
          "@type": "SearchAction",
          "target": "/?q={search_term}",
          "query-input": "required name=search_term"
        }
      }
    </script>
  </body>
</html>
<?php
}

/**********************************************************************
 *                                                                    *
 * Functions for generating and diplaying listings of packages and    *
 * groups                                                             *
 *                                                                    *
 **********************************************************************/

$difflist_sorts = array(
  "name" => array(
    "title" => "name",
    "label" => "Name",
    "mysql" => "`pkgname`"
  ),
  "i486_version" => array(
    "title" => "i486 version",
    "label" => "i486 Version",
    "mysql" => "`i486_version`"
  ),
  "i686_version" => array(
    "title" => "i686 version",
    "label" => "i686 Version",
    "mysql" => "`i686_version`"
  ),
  "x86_64_version" => array(
    "title" => "x86_64 version",
    "label" => "x86_64 Version",
    "mysql" => "`x86_64_version`"
  ),
  "repo" => array(
    "title" => "repository",
    "label" => "Repository",
    "mysql" => "`repository`"
  ),
  "i486_last_moved" => array(
    "title" => "i486 last updated",
    "label" => "i486 Last Updated",
    "mysql" => "`i486_last_moved`"
  ),
  "i686_last_moved" => array(
    "title" => "i686 last updated",
    "label" => "i686 Last Updated",
    "mysql" => "`i686_last_moved`"
  )
);

$difflist_print_columns = array(
  'name' => array('$pkgname'),
  'i486_version' => array(
    '"<a href="/packages/i486/',
    '$repository',
    '"/',
    '$pkgname',
    '"/">',
    '$i486_font_pre',
    '$i486_version',
    '$i486_font_post',
    '"</a>'
  ),
  'i686_version' => array(
    '"<a href="/packages/i686/',
    '$repository',
    '"/',
    '$pkgname',
    '"/">',
    '$i686_font_pre',
    '$i686_version',
    '$i686_font_post',
    '"</a>'
  ),
  'x86_64_version' => array('$x86_64_version'),
  'repository' => array('$repository'),
  'i486_move_date' => array('$i486_move_date'),
  'i686_move_date' => array('$i686_move_date')
);

$grouplist_sorts = array(
  "arch" => array(
    "title" => "architecture",
    "label" => "Arch",
    "mysql" => "`architectures`.`name`"
  ),
  "groupname" => array(
    "title" => "group name",
    "label" => "Group Name",
    "mysql" => "`install_targets`.`name`"
  ),
  "count" => array(
    "title" => "package count",
    "label" => "Package Count",
    "mysql" => "`count`"
  ),
  "last_moved" => array(
    "title" => "last update",
    "label" => "Last Updated",
    "mysql" => "`last_moved`"
  )
);

$grouplist_print_columns = array(
  'arch' => array('$arch'),
  'group' => array(
    '"<a href="/groups/',
    '$arch',
    '"/',
    '$name',
    '"/" title="Group details for ',
    '$name',
    '"">',
    '$name',
    '"</a>'
  ),
  'move_date' => array('&move_date')
);

$pkglist_sorts = array(
  "arch" => array(
    "title" => "architecture",
    "label" => "Arch",
    "mysql" => "`architectures`.`name`"
  ),
  "repo" => array(
    "title" => "repository",
    "label" => "Repo",
    "mysql" => "CONCAT(`r_a`.`name`,\"/\",`repositories`.`name`)"
  ),
  "pkgname" => array(
    "title" => "package name",
    "label" => "Name",
    "mysql" => "`binary_packages`.`pkgname`"
  ),
  "pkgver" => array(
    "title" => "package version",
    "label" => "Version",
    "mysql" => mysql_query_package_version("binary_packages")
  ),
  "bugs" => array(
    "title" => "bug status",
    "label" => "Bugs",
    "mysql" => "NOT `binary_packages`.`has_issues`"
  ),
  "build_date" => array(
    "title" => "build date",
    "label" => "Build Date",
    "mysql" => "IFNULL(`build_assignments`.`return_date`,\"00-00-0000 00:00:00\")"
  ),
  "move_date" => array(
    "title" => "last update",
    "label" => "Last Updated",
    "mysql" => "IFNULL(`binary_packages_in_repositories`.`last_moved`,\"00-00-0000 00:00:00\")"
  ),
  "del" => array(
    "title" => "to be deleted",
    "label" => "Delete",
    "mysql" => "`binary_packages_in_repositories`.`is_to_be_deleted`"
  )
);

$pkglist_print_columns = array(
  'arch' => array('$arch'),
  'repo' => array('$repo'),
  'pkgname' => array(
    '"<a href="/packages/',
    '$repo',
    '"/',
    '$pkgname',
    '"/" title="View package details for ',
    '$pkgname',
    '"">',
    '$pkgname',
    '"</a>'
  ),
  'version' => array('$version'),
  'has_issues' => array(
    'has_issues' => array(
      0 => '"&nbsp',
      1 => '"has open bug reports'
    )
  ),
  'build_date' => array('&build_date'),
  'move_date' => array('&move_date'),
  'is_to_be_deleted' => array(
    'is_to_be_deleted' => array(
      0 => '"&nbsp;',
      1 => '"to be deleted'
    )
  )
);

function query_package_listing($filter, $limit, $float_columns, $count_only, $extract_order_by_from_get) {
  global $pkglist_sorts;

  $sort = '';
  if ($extract_order_by_from_get && array_key_exists('sort', $_GET)) {
    $criterium = $_GET['sort'];
    if (
      array_key_exists($criterium, $pkglist_sorts) &&
      array_key_exists('mysql', $pkglist_sorts[$criterium])
    )
      $sort = $pkglist_sorts[$criterium]['mysql'] . ',';
    elseif (substr($criterium, 0, 1) == '-') {
      $criterium = substr($criterium, 1);
      if (
        array_key_exists($criterium, $pkglist_sorts) &&
        array_key_exists('mysql', $pkglist_sorts[$criterium])
      )
      $sort = $pkglist_sorts[$criterium]['mysql'] . ' DESC,';
    }
  }

  if ($count_only)
    $columns = "COUNT(DISTINCT `binary_packages`.`id`)";
  else
    $columns =
      "DISTINCT " .
      "`binary_packages`.`pkgname`," .
      "`package_sources`.`pkgbase`," .
      "CONCAT(`r_a`.`name`,\"/\",`repositories`.`name`) AS `repo`," .
      "`architectures`.`name` AS `arch`," .
      mysql_query_package_version("binary_packages") .
      " AS `version`," .
      "IF(`binary_packages`.`has_issues`,1,0) AS `has_issues`," .
      "`build_assignments`.`return_date` AS `build_date`," .
      "`binary_packages_in_repositories`.`last_moved` AS `move_date`," .
      "IF(`binary_packages_in_repositories`.`is_to_be_deleted`,1,0) AS `is_to_be_deleted`";

  $result = mysql_run_query(
    "SELECT " .
    $columns .
    " FROM `binary_packages`" .
    mysql_join_binary_packages_architectures() .
    mysql_join_binary_packages_binary_packages_in_repositories() .
    mysql_join_binary_packages_in_repositories_repositories() .
    " AND `repositories`.`is_on_master_mirror`" .
    mysql_join_repositories_architectures("","r_a") .
    mysql_join_binary_packages_build_assignments() .
    mysql_join_build_assignments_package_sources() .
    $filter .
    " ORDER BY " .
    $sort .
    "`binary_packages`.`pkgname`,`repositories`.`stability`,`repositories`.`name`,`architectures`.`name`" .
    $limit
  );
  if ($count_only)
    return implode($result -> fetch_assoc());
  else {
    $return = array();
    while ($row = $result -> fetch_assoc()) {
      foreach ($float_columns as $float_column)
        $row[$float_column] = floatval($row[$float_column]);
      $return[] = $row;
    }
    return $return;
  }
}

function print_listing($list, $print_order_links, $list_content_type) {

  global $difflist_sorts;
  global $pkglist_sorts;
  global $grouplist_sorts;
  global $difflist_print_columns;
  global $pkglist_print_columns;
  global $grouplist_print_columns;

  switch ($list_content_type) {
    case 'diff':
      $columns = $difflist_sorts;
      $print_columns = $difflist_print_columns;
    break;
    case 'package':
      $columns = $pkglist_sorts;
      $print_columns = $pkglist_print_columns;
    break;
    case 'group':
      $columns = $grouplist_sorts;
      $print_columns = $grouplist_print_columns;
    break;
    default:
      throw_http_error(500,'Internal Server Error','invalit list type "' . $list_content_type . '"' . "\n");
      die();
  }

  print "        <table class=\"results\">\n";
  print "          <thead>\n";
  print "            <tr>\n";

  foreach ($columns as $get => $sort) {
    print "              <th>\n";
    if ($print_order_links) {
      print "                <a href=\"?";
      print
        substr(
          str_replace(
            "&sort=" . $_GET["sort"] . "&",
            "&",
            "&" . $_SERVER['QUERY_STRING'] . "&"
          ),
        1) . "sort=";
      if ($_GET["sort"] == $get)
        print "-";
      print $get . "\" title=\"Sort packages by " . $sort["title"] . "\">" . $sort["label"] . "</a>\n";
    } else
      print "                " . $sort["label"] . "\n";
    print "              </th>\n";
  }

  print "            </tr>\n";
  print "          </thead>\n";
  print "          <tbody>\n";
  $oddity = "odd";
  foreach ($list as $row) {
    print "            <tr class=\"" . $oddity . "\">\n";
    foreach ($print_columns as $print_column) {
      print "              <td>\n";
      print "                ";
      foreach ($print_column as $part_key => $part_val) {
        if (is_array($part_val))
          $part_val = $part_val[$row[$part_key]];
        switch (substr($part_val, 0, 1)) {
          case '&':
            if (empty($row[substr($part_val, 1)])) {
              print '&nbsp;';
              break;
            }
          case '$':
            print $row[substr($part_val, 1)];
            break;
          case '"':
            print substr($part_val, 1);
            break;
          default:
            throw_http_error(500, 'Internal Server Error', 'Unknown variable type "' . substr($part_val, 0, 1) . '"');
        }
      }
      print "\n";
      print "              </td>\n";
    }
    print "            </tr>\n";
    if ($oddity == "odd" )
      $oddity = "even";
    else
      $oddity = "odd";
  }
  print "          </tbody>\n";
  print "        </table>\n";
}