PKG Rosetta: Check-in [1cfcf52fef]

Codebase of pkg.deparis.io website, which helps you find concordance between Gnu/Linux or BSD packages name.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Initial commit, proof of something, which may become great
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:1cfcf52fefdd56dee64c6ee95d2fdbba7f555d90
User & Date: milouse 2016-03-08 14:51:11
Context
2016-03-08
15:07
Fix various little glitches. Long time I didn't code in php check-in: 2112ae4b63 user: milouse tags: trunk
14:51
Initial commit, proof of something, which may become great check-in: 1cfcf52fef user: milouse tags: trunk
13:52
initial empty check-in check-in: b1e151a6b2 user: root tags: trunk
Changes

Added data.csv.





>
>
1
2
archlinux,debian,ubuntu,centos,fedora
apache,apache2,apache2,httpd,httpd

Added index.php.





































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
<!DOCTYPE html>
<meta charset="utf-8">
<title>PKG Rosetta</title>

<h1>PKG Rosetta</h1>

<form action="search.php" method="get">
  <fieldset>
    <label for="query_field">
      Looking for
    </label>
    <input type="text" name="q" id="query_field">

    <br>

    <label for="output_field">
      Output format
    </label>
    <select name="f">
      <option value="html" selected>HTML</option>
      <option value="json">Json</option>
      <option value="txt">Plain text</option>
    </select>

    <br>

    <input type="submit"> <input type="reset">
  </fieldset>
</form>

<?php if (!empty($content)){ ?>
  <h2>Results</h2>
  <?php echo $content; ?>
<?php } ?>

Added search.php.



















































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
<?php
$distros_name = array('Archlinux', 'Debian', 'Ubuntu', 'CentOS', 'Fedora');

function print_plain_text($data){
  $content = '';
  for($i = 0; $i < sizeof($data); $i++){
    $content .= $distros_name[$i] . ': ' . $data[$i] . "\n";
  }
  $content .= "\n";
  return $content;
}

function print_json($data){
  $json_array = array();
  for($i = 0; $i < sizeof($data); $i++){
    $json_array[$distros_name[$i]] = $data[$i];
  }
  return json_encode($json_array) . "\n";
}

function print_html($data){
  $content = '<table><thead><tr>';
  foreach ($distros_name as $dn){
    $content .= '<th>' . $dn . '</th>';
  }
  $content .= '</tr></thead><tbody><tr>';
  foreach ($data as $d){
    $content .= '<td>' . $d . '</td>';
  }
  $content .= '</tr></tbody></table>';
  return $content;
}

$result = '';
if (!empty($_GET['q'])){
  $result = system(escapeshellcmd('grep ' . escapeshellarg($_GET['q']) . ' data.csv'));
}

$possible_formats = array('txt', 'json', 'html');
$output_format = 'html';
if (!empty($_GET['f']) && in_array($_GET['f'], $possible_formats)) {
  $output_format = $_GET['f'];
}

$content = '';
if (!empty($result)){
  $lines = str_getcsv($result, "\n");
  foreach($lines as $l){
    $line = str_getcsv($l, ',');

    switch($output_format){
      case 'txt':
        $content .= print_plain_text($line);
        break;
      case 'json':
        $content .= print_json($line);
        break;
      case 'html':
        $content .= print_html($line);
        break;
      default:
        $content .= 'Something went wrong...';
    }
  }
}

if ($output_format != 'html') {
  echo $content;

} else {
  require_once 'index.php';
}
?>