<?php
// Common vars
$arev="1.0-7";
$workingdir = getcwd();
$indexvar = basename($workingdir);
$archive=get_archive();
?>
<html>

<head>
  <title>Atomicorp</title>
  <meta name="description" content="Atomicorp archive" />
  <meta name="keywords" content="RPM archive Cool things for redhat centos cloudlinux fedora debian windows spamassassin qmail-scanner mysql security clustering high-performance troubleshooting security mod_security ossec ossim openvas mariadb openvas" />
  <meta name="robots" content="index, follow" />
  <link rel="shortcut icon" href="http://atomicorp.com/images/channels/favicon.ico" />
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <style type="text/css">
    @import "https://atomicorp.com/images/channels/atomicorp_2019.css";
  </style>
</head>

<body>
  <div id="container">
    <div id="header">
      <div id="header_top">
        <div id="header_logo"></div>

        </div>

        <div id="header_bottom">
          <div id="header_bl"></div>
          <div id="header_bm"></div>
          <div id="header_br"></div>
        </div>
    </div>

    <div id="content">
      <table border='0' cellpadding='0' cellspacing='0' width="100%">
        <tr>
          <td class="ch_tl"></td>
          <td class="ch_m"></td>
          <td class="ch_tr"></td>
        </tr>
        <tr>
          <td colspan="3" bgcolor="#ffffff">
            <div id="content_main">
              <h1>Atomic Workload Protection OSSEC Archives : </h1>
                <table border='0' cellpadding='2' cellspacing='0' width='940'>
                  <?php
                    $z=1;
                    foreach ($archive["dir"] AS $k=>$v) {
                      if ($v=="pgui_v") { continue; }
                      if ($z%2==0) {$bgc="#eeeeee";} else {$bgc="#ffffff";}
                      echo "<tr bgcolor='".$bgc."'>".
                        "<td><a href='".$v["name"]."' class='arc_a'>".$v["name"]."/</a></td>".
                        "<td width='150'>".$v["mtime"]."</td>".
                        "</tr>\n";
                      $z++;
                    }
                    foreach ($archive["file"] AS $k=>$v) {
                      if ($z%2==0) {$bgc="#eeeeee";} else {$bgc="#ffffff";}
                      echo "<tr bgcolor='".$bgc."'>".
                        "<td><a href='".$v["name"]."' class='arc_a'>".$v["name"]."</a></td>".
                        "<td>".$v["mtime"]."</td>".
                        "</tr>\n";
                      $z++;
                    }
                  ?>
                </table>
                <br><br>

                <h1>Configuration for the Atomic Enterprise OSSEC Archive</h1>
                            <p>
                              <b>About</b>
                              <br><br>

                              <ul>
                                <li>[channels/ossec-hub-repo] - Stable free access OSSEC rpm and debian packages.</li>
                                <li>[installers] - Repository for installer packages for Windows and Linux OSSEC agents.</li>
                                <li>[tests] - Respository for File Integrity Management unit tests.</li>
                                <li>[docs] - Support documentation materials. </li>
                              </ul>
                              <br><br>

                              <h1>Additonal Materials</h1>
                              <p>
                                Please see the Atomicorp Wiki (<a href="https://wiki.atomicorp.com">https://wiki.atomicorp.com</a>) for instructions.
                              </p>
                              <br><br><br>
                              <center>Copyright &copy; 2020 Atomicorp, Inc.</center>
                            </p>
            </div>
          </td>
        </tr>
        <tr>
          <td class="ch_bl"></td>
          <td class="ch_m"></td>
          <td class="ch_br"></td>
        </tr>
    </div>
    </div>
    </body>

    <?php
    function get_archive() {
    $ret=array(
    "dir"	=>array(),
    "file"	=>array()
    );
    $dirs=array();
    $files=array();

    if ($handle=opendir(".")) {
    while (false!==($file=readdir($handle))){
      if (!preg_match("/^index.*/",$file) && $file!=".htaccess" && $file!="." && $file==!preg_match("/conf$|^\.pa-z]|php$|^rpc.*/",$file)) {
        if (is_dir($file)) {
          if ($file!="pgui_v") {
            $dirs[]=$file;
          }
        }
        else {
          $files[]=$file;
        }
      }
    }
    closedir($handle);

    if (count($dirs)!=0) {
      sort($dirs);
      foreach ($dirs AS $d) {
        $ret["dir"][]=array(
          "name"	=> $d,
          "size"	=> round(filesize($d)/1024),
          "mtime"	=> date("M d Y H:i:s",filemtime($d))
        );
      }
    }

    if (count($files)!=0) {
      sort($files);
      foreach ($files AS $f) {
        $ret["file"][]=array(
          "name"	=> $f,
          "size"	=> round(filesize($f)/1024),
          "mtime"	=> date("M d Y H:i:s",filemtime($f))
        );
      }
    }
    }
    return $ret;
    }
    ?>
    </html>
