Skip to content
Snippets Groups Projects
Commit 659a7666 authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

Add results page requiring login to view

parent 5acc5809
Branches
No related tags found
No related merge requests found
...@@ -2,14 +2,23 @@ ...@@ -2,14 +2,23 @@
ini_set('display_errors',true); ini_set('display_errors',true);
// Sample configuration file for the ucomm webforms project // Sample configuration file for the ucomm webforms project
set_include_path(dirname(__FILE__).'/lib/php/'.PATH_SEPARATOR.get_include_path()); set_include_path(dirname(__FILE__).'/lib/php/'.PATH_SEPARATOR.get_include_path());
/*
$con = mysql_connect("localhost","test","test"); $con = mysql_connect("localhost","test","test");
if (!$con){ if (!$con){
die('Could not connect: ' . mysql_error()); die('Could not connect: ' . mysql_error());
}else{ }else{
mysql_select_db("police_terrex11", $con); mysql_select_db("police_terrex11", $con);
} }
/**
* CREATE TABLE IF NOT EXISTS `registration` (
* `id` int(11) NOT NULL AUTO_INCREMENT,
* `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
* `name` varchar(255) NOT NULL,
* `email` varchar(255) NOT NULL,
* PRIMARY KEY (`id`)
* ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
*/ */
function myautoload($class) function myautoload($class)
{ {
$file = str_replace('_', '/', $class).'.php'; $file = str_replace('_', '/', $class).'.php';
......
<?php
if (file_exists(dirname(__FILE__).'/../../../config-police-terrex11.inc.php')) {
require_once dirname(__FILE__).'/../../../config-police-terrex11.inc.php';
} else {
require_once dirname(__FILE__).'/../../../config-police-terrex11.sample.php';
}
require_once 'UNL/Auth.php';
$cas_client = UNL_Auth::factory('SimpleCAS');
if (isset($_GET['login'])) {
$cas_client->login();
}
if (isset($_GET['logout'])) {
$cas_client->logout();
}
if ($cas_client->isLoggedIn() && in_array($cas_client->getUser(), array('bbenson2','erasmussen2'))) {
?>
You are logged in - <a href="?logout">Logout</a>
<br><br>
<table>
<?php
$result = mysql_query('SELECT * from registration');
if (!$result) {
die('Invalid query: ' . mysql_error());
}
while ($row = mysql_fetch_assoc($result)) {
echo '<tr><td style="padding-right:20px">'.$row['name'].'</td><td style="padding-right:20px">'.$row['email'].'</td><td>'.$row['time'].'</td></tr>';
}
?>
</table>
<?php } else if ($cas_client->isLoggedIn() && !in_array($cas_client->getUser(), array('bbenson2','erasmussen2'))) { ?>
You are not authorized
<?php } else { ?>
<a href="?login">Login</a>
<?php }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment