view print.php @ 1096:bbc0a3d0b51e

Major renaming / refactor of site messages. Some that were previously modifiable from admin interface are now "hardcoded" in the configuration file. Having these settings made modifiable from there made no sense and just took space in the UI.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 27 Jan 2017 22:15:06 +0200
parents 48e16e856646
children ebb0afda63c5
line wrap: on
line source

<?php
//
// FAPWeb - Simple Web-based Demoparty Management System
// Data printout / hardcopy output module
// (C) Copyright 2012-2017 Tecnic Software productions (TNSP)
//
$sessionType = "admin";
require_once "mconfig.inc.php";
require_once "msite.inc.php";
require_once "msession.inc.php";

$pageCSS = "css/hardcopy.css";


//
// Check if we are allowed to execute
//
if (!stCheckHTTPS() || !stAdmSessionAuth(TRUE))
{
  stSetupCacheControl();
  stSessionEnd(SESS_ADMIN);
  stSetStatus(404, "Not Found");
  
  cmPrintPageHeader("Error");
  echo
    "<h1>Permission denied</h1>\n".
    "<p>You need to be logged in as administrator to access this data.</p>\n".
    "<p><a href=\"admin.php\">Click here for login form</a></p>\n";
  cmPrintPageFooter();
  exit;
}


//
// Initialize
//
stSetupCacheControl();

if (!stConnectSQLDB())
  die("Could not connect to SQL database.");

stReloadSettings();


//
// Handle request
//
switch (stGetRequestItem("type", "", TRUE))
{
  case "results":
    header("Content-Type: text/plain");
    echo stGetCompoResultsASCIIStr(FALSE, intval(stGetRequestItem("flags", RFLAG_NORMAL)));
    break;

  case "emails":
    //
    // Generic e-mail data dump
    //
    $sql = "SELECT * FROM attendees WHERE email IS NOT NULL AND email != '' ORDER BY regtime DESC";
    if (($res = stExecSQL($sql)) !== FALSE)
    {
      cmPrintPageHeader("E-mails");
      $out1 = array();
      $out2 = array();

      foreach ($res as $item)
      {
        $out1[] = $item["name"]." &lt;".$item["email"]."&gt;";
        $out2[] = $item["email"];
      }

      echo
        implode(", ", $out1)."<br /><hr /><br />\n".
        implode("<br />", $out1)."<br /><hr /><br />\n".
        implode(", ", $out2)."<br /><hr /><br />\n".
        implode("<br />", $out2)."<br /><hr />\n";

      cmPrintPageFooter();
    }
    break;

  case "votekeys":
    //
    // Print out votekeys as a table
    //
    $sql = "SELECT * FROM votekeys ORDER BY id ASC";
    if (($res = stExecSQL($sql)) !== FALSE)
    {
      cmPrintPageHeader("Votekeys");
      $keyLen = stGetSetting("userKeyLength");
      echo "<div class=\"votekeys\">\n";
      foreach ($res as $item)
      {
        // This funny code is to ensure that the cells are of uniform width
        printf("<div class=\"votekey\"><span class=\"keyid\">%03d</span>&nbsp;:&nbsp;".
          "<span class=\"keycode\">%s</span></div>\n",
          $item["id"],
          str_repeat("&nbsp;", $keyLen - strlen($item["key"])).$item["key"]);
      }

      echo "</div>\n";
      cmPrintPageFooter();
    }
    break;

  default:
    stSetStatus(404, "Not Found");
    break;
}

?>