<?php

if(@$_GET['source']==1)
{
    
show_source($_SERVER['SCRIPT_FILENAME']);
    die();
}

require_once(
'include.php');

if(!(isset(
$_POST['id']) && isset($_POST['pass']))) die();

if(isset(
$_POST['remember']) && $_POST['remember']=='1')
{
        
setcookie('hsnugrades_id'$_POST['id'], time()+30*24*3600);
        
setcookie('hsnugrades_pass'$_POST['pass'], time()+30*24*3600);
}
else
{
        
setcookie('hsnugrades_id'0time()-10);
        
setcookie('hsnugrades_pass'0time()-10);
}


$data = new HSNUData;
if(!
$data->login($_POST['id'], $_POST['pass'])) die($data->geterror());

switch(
$_POST['item'])
{
    case 
'list_year':
    case 
'list_all':
    case 
'list_spec':
        
$data->fetchlist($_POST['item']);
        if(isset(
$_POST['option']))
        {
            
$data->fetchlistitem($_POST['option']);
            
$data->printoutput();
        }
        else
        {
            
$opt $data->getoptions();
            
printformheader('');
            echo 
'<select name="option">' PHP_EOL;
            foreach(
$opt as $key => $val)
            {
                echo 
"<option value=\"$key\">$val</option>" PHP_EOL;
            }
            
printformfooter($_POST['id'], $_POST['pass'], $_POST['item']);
        }
        break;
    default:
        
$data->fetchdata($_POST['item']);
                
printqueryheader('');
        
$data->printoutput();
                
printqueryfooter();
}

?>