//Defaults
require_once 'change/db.php'; include_once '/w/web/eecs/etc/common/MyG.php'; MyG::dbconnect('dconetdb');
include("/w/web/eecs/etc/common/sanitize.php");
//Get vars. and sanitize
$id = isset($_GET['id']) ? $_GET['id'] : 0; $id = (int)$id;
$year = isset($_GET['year']) ? $_GET['year'] : 0; $year = (int)$year;
$cat = isset($_GET['cat']) ? $_GET['cat'] : ''; $cat = strip_tags(trim($cat));
$cat = sanitize($cat);
$showall = isset($_GET['showall']) ? $_GET['showall'] : ''; $showall = strip_tags(trim($showall));
$limit = "LIMIT 50"; if($showall == 'yes') { $limit = ''; }
//figure out date limit (2014-01-01) and adjust sql
$startdate = $startdate0 = date("Y");
$startdate = $startdate . "-01-01";
$lastyear = $startdate0 - 1;
//Get all recent news stories
$sql = "SELECT * FROM news ORDER BY date_entered DESC, news_id DESC LIMIT 50";
//Get news by id
if($id) { $sql = "SELECT * FROM news WHERE news_id = $id"; }
//Get news by year
if($year && $year>1998 && $year<=$startdate0)
{
$year = (int)$year; $enddate = $year + 1;
if($year < 1999 || $year > $startdate0) { $year = $startdate0; }
$startdate = $year . "-01-01";
$enddate = $enddate . "-01-01";
$sql = "SELECT * FROM news WHERE date_entered >= \"$startdate\" AND date_entered < \"$enddate\" ORDER BY date_entered DESC, news_id DESC";
}
if($year && ($year > $startdate0 || $year < 1999))
{
$location = "https://www.eecs.umich.edu/eecs/etc/news/eecsnews.html";
header("Location: $location"); exit;
}
//Get news by category
if($cat)
{
$string_ok = "";
$allowed = array("External","Research","News","Awards","Student","Alumni","Grad","Undergrad","Diversity","Class");
foreach($allowed as $member) { if($member == $cat) { $string_ok = "yes"; } }
if(!$string_ok)
{
$location = "https://www.eecs.umich.edu/eecs/etc/news/eecsnews.html";
header("Location: $location"); exit;
}
$sql = "SELECT * FROM news WHERE news_type = \"$cat\" ORDER BY date_entered DESC, news_id DESC $limit";
}
//Get Undergrad news
if($cat == "Undergrad")
{
$sql = "SELECT DISTINCT * FROM news " .
"RIGHT JOIN tags ON news.news_id=tags.news_id " .
"WHERE news_type = \"Student\" " .
"AND tags.tagname_id = 233 " .
"ORDER BY news.news_id DESC $limit";
$result = mysql_query($sql) or die (mysql_error());
}
//Get Grad news
if($cat == "Grad")
{
$sql = "SELECT DISTINCT * FROM news " .
"RIGHT JOIN tags ON news.news_id=tags.news_id " .
"WHERE news_type = \"Student\" " .
"AND tags.tagname_id = 234 " .
"ORDER BY news.news_id DESC $limit";
$result = mysql_query($sql) or die (mysql_error());
}
//Get Diversity news
if($cat == "Diversity")
{
$sql = "SELECT DISTINCT * FROM news " .
"RIGHT JOIN tags ON news.news_id=tags.news_id " .
"WHERE tags.tagname_id = 232 " .
"ORDER BY news.news_id DESC $limit";
$result = mysql_query($sql) or die (mysql_error());
}
//Determine Title
if($cat == "News") { $title = "EECS Department News"; }
elseif($cat == "External") { $title = "EECS in the News"; }
elseif($cat == "Awards") { $title = "EECS Faculty and Staff News"; }
elseif($cat == "Student") { $title = "EECS Student News"; }
elseif($cat == "Undergrad") { $title = "EECS Undergraduate Student News"; }
elseif($cat == "Grad") { $title = "EECS Graduate Student News"; }
elseif($cat == "Diversity") { $title = "EECS Diversity and Outreach News"; }
elseif($cat == "Class") { $title = "EECS Course Announcements"; }
elseif(!$cat) { $title = "EECS News"; }
else { $title = "$cat News"; }
if($year) { $title = "EECS News for $year"; }
if($id) { $title = "EECS News Story"; }
print "
\n";
print "$title |
\n";
print "\n";
include("get_records.php");
print " |
\n";
if(!$id && !$cat && !$year)
{
$thisyr = date("Y");
print "All EECS News for $thisyr |
\n";
}
if($cat && !$showall) { print "Show All |
\n"; }
print "
\n";
?>