view print.php @ 380:0c7b301742bd

Oops^2.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 03 Dec 2013 21:09:48 +0200
parents 47e205b475ef
children 998a09b332f1
line wrap: on
line source

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

$pageCSS = "hardcopy.css";
cmLocaleInit();

//
// 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 "emails":
    //
    // Generic e-mail data dump
    //
    $sql = "SELECT * FROM attendees WHERE email 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 "<table class=\"votekeys\">\n";
      $index = 0;
      foreach ($res as $item)
      {
        if ($index == 0)
          echo "<tr>\n";
        
        // This funny code is to ensure that the cells are of uniform width
        printf("<td><span class=\"keyid\">%03d</span>&nbsp;:&nbsp;".
          "<span class=\"keycode\">%s</span></td>\n",
          $item["id"],
          str_repeat("&nbsp;", $keyLen - strlen($item["key"])).$item["key"]);
        
        if ($index++ >= 5)
        {
          echo "</tr>\n";
          $index = 0;
        }
      }
      if ($index > 0)
        echo "</tr>\n";

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

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

?>