Notices'; session_start(); if ((isset($_SESSION['username']))){ $sess = ucfirst($_SESSION['username']); echo '
'; echo '
'; echo '
'; echo '
'; echo '
Upload Notice:'; echo ''; echo ""; echo "
"; echo '
'; } date_default_timezone_set('Asia/Kolkata'); function return_vals($dir){ $files = scandir($dir); $values = array(); foreach($files as $file){ if(is_file($dir.$file)){ if(($fname = pathinfo($file,PATHINFO_EXTENSION))=='pdf'){ $fpath = $dir.$file; $fname = pathinfo($file,PATHINFO_BASENAME); $ctime = filemtime($fpath); $tmpval = array($ctime => strtolower($file) ); $values = $values+$tmpval; } } } return $values; } function print_display($dir,$arr){ $cnt = 1; foreach($arr as $ctime => $file) { $fpath = $dir.$file; $fname = pathinfo($file,PATHINFO_BASENAME); $pos=strpos($fname, '.'); $fname=substr($fname, 0,$pos); echo ''; echo '

'.$cnt.'.

'.strtoupper($fname); echo ''; $cnt = $cnt+1; } } function group_by_mnth($values){ $prev = 0; $cnt = 1; foreach ($values as $ctime => $file) { $fname = pathinfo($file,PATHINFO_BASENAME); $pos=strpos($fname, '.'); $fname=substr($fname, 0,$pos); $curr = date("mY",$ctime); if($curr==$prev){ echo ''; echo '

'.$cnt.'.

'.strtoupper($fname); echo ''; } else{ echo '

'.date("M, Y",$ctime).'

'; echo ''; echo '

'.$cnt.'.

'.strtoupper($fname); echo ''; $prev = $curr; } $cnt = $cnt+1; } } function group_by_date($values){ $prev = 0; $cnt=1; foreach ($values as $ctime => $file) { $fname = pathinfo($file,PATHINFO_BASENAME); $pos=strpos($fname, '.'); $fname=substr($fname, 0,$pos); $curr = date("dmY",$ctime); //echo $curr; //echo $fname; if($curr==$prev){ echo ''; echo '

'.$cnt.'. '.strtoupper($fname).'

'; echo ''; } else{ echo ''; echo '

'.date("M j, Y",$ctime).'

'; echo ''; echo ''; echo '

'.$cnt.'. '.strtoupper($fname).'

'; echo ''; $prev = $curr; } $cnt = $cnt+1; } } $notpath='notices_upload/'; $trashpath='recbin/'; $archpath='archive/'; //Get values filename, creation time $dis = $_GET['display']; if($dis == 'archive'){ if(!(isset($_SESSION['username']))){ header('Location:display.php?sort=dtime&group=ddate&display=borad'); exit; } echo '
'; echo '

Edit '.ucfirst($dis).'

'; $path = $archpath; } elseif($dis=='trash'){ if(!(isset($_SESSION['username']))){ header('Location:display.php?sort=dtime&group=ddate&display=borad'); exit; } echo '
'; echo '

Edit '.ucfirst($dis).'

'; $path = $trashpath; } elseif($dis == 'board'){ $path = $notpath; if(isset($_SESSION['username'])){ echo '
'; echo '

Edit '.ucfirst($dis).'

'; } }else{ echo '

Invalid GET method

'; } $files = return_vals($path); $srt=$_GET['sort']; $grp=$_GET['group']; /* Display List of Notices. */ if($grp=='none'){ if($srt=='dtime'){ //echo 'by time'; krsort($files); echo 'Name

          

Time

          

'; echo 'Date

     

Month

'; if(sizeof($files)==0){ echo '

No Notices to Display

'; } echo '
'; echo ''; print_display($path, $files); } elseif($srt=='atime'){ //echo 'by time'; ksort($files); echo 'Name

          

Time

          

'; echo 'Date

     

Month

'; if(sizeof($files)==0){ echo '

No Notices to Display

'; } echo '
'; echo '
'; print_display($path, $files); } elseif($srt=='aname'){ natsort($files); echo 'Name

          

Time

          

'; echo 'Date

     

Month

'; if(sizeof($files)==0){ echo '

No Notices to Display

'; } echo '
'; echo '
'; print_display($path, $files); } elseif($srt=='dname'){ natsort($files); $files = array_reverse($files,false); echo 'Name

          

Time

          

'; echo 'Date

     

Month

'; if(sizeof($files)==0){ echo '

No Notices to Display

'; } echo '
'; echo '
'; print_display($path, $files); } } elseif ($grp=='adate') { echo 'Name

          

Time

          

'; echo 'Date

     

Month

     



'; ksort($files); if(sizeof($files)==0){ echo '

No Notices to Display

'; } else{ echo '
'; echo '
'; group_by_date($files); } } elseif ($grp=='ddate') { echo 'Name

          

Time

     

'; echo 'Date

     

Month

     



'; krsort($files); if(sizeof($files)==0){ echo '

No Notices to Display

'; }else{ echo '
'; echo '
'; group_by_date($files); } } elseif ($grp=='amnth') { echo 'Name

          

Time

     

'; echo 'Date

     

Month

     



'; ksort($files); if(sizeof($files)==0){ echo '

No Notices to Display

'; } else{ echo '
'; echo '
'; group_by_mnth($files); } } elseif ($grp=='dmnth') { echo 'Name

          

Time

     

'; echo 'Date

     

Month

     



'; krsort($files); if(sizeof($files)==0){ echo '

No Notices to Display in folder: '.$dis.'

'; } else{ echo '
'; echo '
'; group_by_mnth($files); } } else{ } echo '
'; echo '
'; ?>