session_start();
include ($link."course.php");
$_SESSION['loginmessage']=1;
$_SESSION['mode']='';
if($_SESSION['cn']!='')
{
$_SESSION['loginmessage']=2;
$_SESSION['user']='';
$_SESSION['status']='';
$_SESSION['firstname']='';
$_SESSION['lastname']='';
$_SESSION['id']='';
$_SESSION['sectionname']='';
$_SESSION['groupname']='';
$_SESSION['studentcourse']='';
$_SESSION['power']='';
$looking=0;
$passfile = fopen("./oscerfolio/grades/control.csv", "rb");
if($passfile)
{
flock($passfile,LOCK_SH);
while (!feof($passfile)&&$looking==0)
{
$line_of_text = fgets($passfile);
$parts = explode(',', $line_of_text);
$username=$parts[0];
if($_SESSION['cn']==$username)
{
$_SESSION['user']=$_SESSION['cn'];
$_SESSION['lastname']=$parts[2];
$_SESSION['firstname']=$parts[3];
$_SESSION['status']=$parts[4];
$_SESSION['group']=trim($parts[5]);
$_SESSION['power']=1;
if($_SESSION['status']=='admin') $_SESSION['power']=4;
if($_SESSION['status']=='grad') $_SESSION['power']=3;
if($_SESSION['status']=='ta') $_SESSION['power']=2;
$_SESSION['studentcourse']=$_SESSION['course'];
$looking=1;
$firstname=$_SESSION['lastname'];
$lastname=$_SESSION['firstname'];
$_SESSION['id']=$parts[1];
$status=$_SESSION['status'];
$power = $_SESSION['power'] ;
$_SESSION['partners'][0]=0;
}
}
flock($passfile,LOCK_UN);
fclose($passfile);
}
if($looking==0)
{
$passfile = fopen("./oscerfolio/grades/oscerroster.csv", "rb");
if($passfile)
{
flock($passfile,LOCK_SH);
while (!feof($passfile)&&$looking==0)
{
$line_of_text = fgets($passfile);
$parts = explode(',', $line_of_text);
$username=$parts[0];
if($_SESSION['cn']==$username)
{
$_SESSION['user']=$_SESSION['cn'];
$_SESSION['lastname']=$parts[2];
$_SESSION['firstname']=$parts[3];
$_SESSION['status']=trim($parts[4]);
$_SESSION['group']=trim($parts[5]);
$_SESSION['groupnumber']=trim($parts[5]);
$_SESSION['power']=1;
if($_SESSION['status']=='admin') $_SESSION['power']=4;
if($_SESSION['status']=='grad') $_SESSION['power']=3;
if($_SESSION['status']=='ta') $_SESSION['power']=2;
$_SESSION['studentcourse']=$_SESSION['course'];
$looking=1;
$firstname=$_SESSION['lastname'];
$lastname=$_SESSION['firstname'];
$id=0;
$status=$_SESSION['status'];
$sectionnumber=$status;
$power = $_SESSION['power'] ;
$id=$parts[2];
$_SESSION['id']=$parts[1];
$status=$parts[4];
$sectionnumber=$parts[4];
$groupnumber=$_SESSION['groupnumber'];
}
}
flock($passfile,LOCK_UN);
fclose($passfile);
}
}
}
$_SESSION['partners'][0]=0;
if($_SESSION['group']>0)
{
$_SESSION['partners'][0]=0;
$passfile = fopen("./oscerfolio/grades/oscerroster.csv", "rb");
if($passfile)
{
flock($passfile,LOCK_SH);
while (!feof($passfile))
{
$line_of_text = fgets($passfile);
$parts = explode(',', $line_of_text);
if($_SESSION['status']==$parts[4]&&intval($_SESSION['group'])==trim($parts[5]))
{
$_SESSION['partners'][0]++;
$_SESSION['partners'][$_SESSION['partners'][0]]=$parts[0];
$_SESSION['partnersfirst'][$_SESSION['partners'][0]]=$parts[3];
$_SESSION['partnerslast'][$_SESSION['partners'][0]]=$parts[2];
}
}
}
}
if($_POST['gone']) {
$_SESSION['status']='';
$_SESSION['firstname']='';
$_SESSION['lastname']='';
$_SESSION['id']='';
$_SESSION['studentcourse']='';
$_SESSION['power']=0;
$_SESSION['login']='';
session_destroy();
$status='';
$firstname='';
$lastname='';
}
?>
//datecheck(1,1);
//echo 'The quiz starts: '.date('l F j Y \a\t h:i A',$quizstart+3600).'
The quiz ends: '.date('l jS \of F Y \a\t h:i A',$quizend);
function authorizesections()
{
global $sectionname;
global $sectionauth;
global $numsec;
$sectionfile = fopen('sections.csv', "w");
flock($sectionfile,LOCK_SH);
for ($i=1;$i<=30;$i++)
{ $string = sprintf("%s,%d\r\n",$sectionname[$i],$sectionauth[$i]);
fwrite($sectionfile,$string);
}
flock($sectionfile,LOCK_UN);
fclose($sectionfile);
return;
}
function checksection($sec)
{
global $sectionname;
global $sectionauth;
global $numsec;
$authorize=2;
$sectionfile = fopen('sections.csv', "rb");
flock($sectionfile,LOCK_SH);
$numsec=0;
while (!feof($sectionfile) )
{
$line_of_text = fgets($sectionfile);
$parts = explode(',', $line_of_text);
$numsec++;
$sectionname[$numsec]= $parts[0];
$sectionauth[$numsec]= $parts[1];
if($sec==$sectionname[$numsec])
{
$authorize=$sectionauth[$numsec];}
}
flock($sectionfile,LOCK_UN);
fclose($sectionfile);
return $authorize;
}
?>