view print.php @ 820:e213dca6354d

Add filename as ref variable argument to stSetFileEntryFilename().
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 24 Nov 2014 22:31:47 +0200
parents b42b23073209
children ffacd904fd1f
line wrap: on
line source

<?
//
// FAPWeb - Simple Web-based Demoparty Management System
// Data printout / hardcopy output module
// (C) Copyright 2012-2014 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 "<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;
}

?>