session_start();
/*
* If the user tried to login but failed send him ack to the login page
*/
if (isset($_SESSION['submitLogin']) && ! (isset($_SESSION['loggedIn']) && ($_SESSION['loggedIn'] == true)) ) {
//
header("Location: Login.php");
}
?>
//
// Debug variable
//
$debug = TRUE;
/*
* Use syslog
*/
define_syslog_variables();
/*
* Open the log using the LOG_USER facility
*/
$r_log = openlog("CNL", LOG_CONS | LOG_PID, LOG_USER);
//
if (! $r_log) {
//
if ($debug) {
//
print_start();
//
echo "" . basename($_SERVER['PHP_SELF']) . ": Opening log facility [failure]
";
//
print_end();
//
flush();
}
/*
* End
*/
exit();
}
else {
//
if ($debug) {
//
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Opening log facility [success]");
//
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Array \$_GET is an " . print_r($_GET, true));
//
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Array \$_SESSION is an " . print_r($_SESSION, true));
//
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Array \$_POST is an " . print_r($_POST, true));
//
foreach ($_GET as $key => $value) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Variable \$_GET[" . $key . "] is " . $_GET[$value]);
}
//
foreach ($_SESSION as $key => $value) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Variable \$_SESSION[" . $key . "] is " . $_SESSION[$value]);
}
//
foreach ($_POST as $key => $value) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Variable \$_POST[" . $key . "] is " . $_POST[$value]);
}
}
//
$orderby="StartDate, Title";
//
if (isset($_GET['type'])) {
//
if ($_GET['type'] == 1) {
$orderby = "Type";
}
}
else {
if ($debug) {
syslog(LOG_WARNING, basename($_SERVER['PHP_SELF']) . ": Variable 'type' is not set ordering publications by date and title");
}
}
//
@ $db = mysql_connect( "localhost", "cnlweb", "cnlweb" ) or die("Error:could not connect to database!");
//
mysql_select_db( "cnl2" );
//
$query = "SELECT distinct * FROM Members";
//
// $validId;
/*
* Either use $_GET['userId'] if set by login or $_SESSION['$userName'] given by user
*/
if (! empty($_GET['showUser'])) {
//
if ($_GET['showUser'] != -1) {
//
if ($debug) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Testing if \$_GET[showUser] is empty ('1' means 'true'): " . empty($_GET['showUser']));
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Using \$_GET[showUser] for user ID");
}
//
$validId = $_GET['showUser'];
//
$query .= " WHERE ID=" . $_GET['showUser'];
}
else {
//
if (! empty($_SESSION['userName'])) {
//
if ($debug) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Testing if \$_SESSION[userName] is empty ('1' means 'true'): " . empty($_SESSION['userName']));
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Using \$_SESSION[userName] for user ID");
}
//
$validId = $_SESSION['userName'];
//
$query .= " WHERE Username='" . $_SESSION['userName'] . "'";
}
else {
if ($debug) {
syslog(LOG_WARNING, basename($_SERVER['PHP_SELF']) . ": Condition not handled in code");
}
}
}
}
else {
//
if (! empty($_SESSION['userId'])) {
//
if ($debug) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Testing if \$_SESSION[userId] is empty ('1' means 'true'): " . empty($_SESSION['userId']));
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Using \$_SESSION[userId] for user ID");
}
//
$validId = $_SESSION['userId'];
//
$query .= " WHERE ID='" . $_SESSION['userId'] . "'";
}
else {
if ($debug) {
syslog(LOG_WARNING, basename($_SERVER['PHP_SELF']) . ": Condition not handled in code");
}
}
}
//
if ($debug) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Valid user ID is " . $validId);
}
//
if ($debug) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL query is " . $query);
}
//
$result = mysql_query($query) or die(mysql_error($db));
/*
* Get a row
*/
$records = mysql_num_rows($result);
//
if ($debug) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL search found " . $records . " records for user " . $_SESSION['$userName']);
}
//
// If exactly one member was found (as should be the normal case)
//
if ($records == 1) {
//
$record = mysql_fetch_array($result);
//
if ($debug) {
if (is_array($record)) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL search returns a record of " . count($record) . " fields");
}
else {
syslog(LOG_ERR, basename($_SERVER['PHP_SELF']) . "SQL search did not return a record of fields");
}
}
//
if ($debug) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL search found record for CNL member " . $record["FirstName"] . " " . $record["LastName"]);
}
/*
* If set during login the MySQL user ID should match the one found by the MySQL query
*/
if (isset($_GET['showUser'])) {
if ($_GET['showUser'] != $record["ID"]) {
if (is_array($record)) {
syslog(LOG_WARNING, basename($_SERVER['PHP_SELF']) . ": Multiple ID values found for user " . $_SESSION['$Username']);
}
else {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Variable \$_GET['showUser'] is " . $_GET['showUser']);
}
}
}
/*
* Update user ID (values match)
*/
$_SESSION['userId'] = $_GET['showUser'];
if ($debug) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Variable \$_SESSION['userId'] is set to " . $_SESSION['userId']);
}
//
echo "";
//
echo " | ";
//
echo "";
//
if ($_SESSION['lang'] == 0) {
echo "First Name: " . $record["FirstName"] . " ";
echo "Last Name: " . $record["LastName"] . " ";
echo "Date Of Birth: " . $record["DateOfBirth"] . " ";
echo "Email: " . $record["Email"] . " ";
echo "Tel. : " . $record["Tel"] . " ";
echo "Fax: " . $record["Fax"] . " ";
echo "Address: " . $record["Postal"] . " ";
echo "Office: " . $record["OfficeNo"] . " ";
echo "Membership: " . $record["Type"] . " ";
echo "Research Interests: " . $record["ResearchInterests"] . " ";
echo "Short CV: " . "" . $record["CVShortEnURL"] . "" . " ";
echo "Full CV: " . "" . $record["CVLongEnURL"] . "" . " ";
echo "Home page: " . "" . $record["HomePageURL"] . "" . " ";
echo "General Information: " . $record["UserInfo"] . " ";
}
//
if ($_SESSION['lang'] == 1) {
echo "?iiia: " . $record["FirstNameGr"] . " ";
echo "A??eaoi: " . $record["LastNameGr"] . " ";
echo "Ci/i?a AYiicoco: " . $record["DateOfBirth"] . " ";
echo "Email: " . $record["Email"] . " ";
echo "Oce. : " . $record["Tel"] . " ";
echo "Fax: " . $record["Fax"] . " ";
echo "Aeayeoioc: " . $record["PostalGr"] . " ";
echo "Anaoa?i: " . $record["OfficeNo"] . " ";
echo "Eaeuocoa: " . $record["Type"] . " ";
echo "AnaoicoeeU AiaeaoYniioa: " . $record["ResearchInterestsGr"] . " ";
echo "Oyioiii Aeianaoeeu Ocia?uia: " . "" . $record["CVShortGrURL"] . "" . " ";
echo "?e?nao Aeianaoeeu Ocia?uia: " . "" . $record["CVLongGrURL"] . "" . " ";
echo "Home page: " . "" . $record["HomePageURL"] . "" . " ";
echo "AaieeYo ?ecnioin?ao: " . $record["UserInfoGr"] . " ";
}
//
echo " | ";
//
echo "
";
/*
* Register user Id with session
*/
if (empty($_SESSION['userId'])) {
//
if ($r_log) {
syslog(LOG_ERR, basename($_SERVER['PHP_SELF']) . ": Variable \$_SESSION['userId'] is not set or is empty");
}
//
exit();
}
else {
/*
* Get qualifications
*/
//
// $query = "SELECT * FROM Qualifications WHERE MemberID = " . $validId . " ORDER BY QualificationDate DESC";
//
$query = "SELECT * FROM Qualifications WHERE MemberID = " . $_SESSION['userId'] . " ORDER BY QualificationDate DESC";
//
if ($r_log) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL query is " . $query);
}
//
$result = mysql_query($query) or die(mysql_error($db));
//
if ($r_log) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL search found " . mysql_num_rows($result) . " records for qualifications");
}
// If there are results
if (mysql_num_rows( $result ) > 0) {
//
echo "";
//
echo "";
//
if ($_SESSION['lang'] == 0)
echo "Qualifications:";
//
if ($_SESSION['lang'] == 1)
echo "?niouioa:";
//
while ($record = mysql_fetch_array($result)) {
if ($_SESSION['lang'] == 0) {
echo "Date: " . $record["QualificationDate"] . " ";
echo "Type: " . $record["QualificationType"] . " ";
echo "Degree Title: " . $record["Degree_Title"] . " ";
echo "Thesis Title: " . $record["Thesis_Title"] . " ";
echo "Institution: " . $record["Institution"] . " ";
// echo "Link: " . $record["Link"] . " ";
echo "Link: " . "" . $record["QualificationLink"] . "" . " ";
}
if ($_SESSION['lang'] == 1) {
echo "Cianiici?a: " . $record["QualificationDate"] . " ";
echo "Oy?io: " . $record["QualificationType"] . " ";
echo "O?oeio ?oo??io: " . $record["Degree_Title"] . " ";
echo "O?oeio Anaao?ao: " . $record["Thesis_Title"] . " ";
echo "?anoia: " . $record["Institution"] . " ";
// echo "Oyiaaoiio: " . $record["Link"] . " ";
echo "Link: " . "" . $record["QualificationLink"] . "" . " ";
}
echo " ";
} // while
//
echo "
";
//
echo " | ";
//
echo "
";
}
/*
* Get awards
*/
//
$query = "SELECT * FROM Awards WHERE MemberID=" . $_SESSION['userId'] . " ORDER BY AwardDate DESC";
//
if ($r_log) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL query is " . $query);
}
//
$result = mysql_query($query) or die(mysql_error($db));
//
if ($r_log) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL search found " . mysql_num_rows($result) . " records for awards");
}
//
// If there are results
//
if (mysql_num_rows( $result ) > 0) {
//
echo "";
//
echo "";
//
if ($_SESSION['lang'] == 0)
echo "Awards:";
if ($_SESSION['lang'] == 1)
echo "Anaaa?a:";
//
while ($record = mysql_fetch_array($result)) { // For each Award
if ($_SESSION['lang'] == 0) {
echo "Date: " . $record["AwardDate"] . " ";
echo "Description: " . $record["AwardDescprition"] . " ";
}
if ($_SESSION['lang'] == 1) {
echo "Cianiici?a: " . $record["AwardDate"] . " ";
echo "?aneanao?: " . $record["AwardDescpritionGr"] . " ";
}
echo " ";
} // while
//
echo "
";
//
echo " | ";
//
echo "
";
} // if (mysql_num_rows( $result ) > 0)
//
$query = "SELECT * FROM Publications, PublicationAuthor WHERE PublicationAuthor.MemberID = " . $_SESSION['userId'] . " AND PublicationAuthor.Type = 'CNL' AND PublicationAuthor.PublicationID = Publications.PublicationID ORDER BY PublicationDate DESC";
//
if ($r_log) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL query is " . $query);
}
//
$result = mysql_query($query) or die(mysql_error($db));
//
if ($r_log) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL search found " . mysql_num_rows($result) . " records for publications");
}
//
// If there are results
//
if (mysql_num_rows( $result ) > 0) {
//
$records = mysql_num_rows($result);
//
// $record = mysql_fetch_array($result);
echo "";
echo "";
//
if ($_SESSION['lang'] == 0)
echo "Publications:";
if ($_SESSION['lang'] == 1)
echo "Aciioeayoaeo:";
// For each publication
while ($record = mysql_fetch_array($result)) {
//
if ($debug) {
//
if (is_array($record)) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL query result is an array with " . count($record) . " elements(s)");
}
else {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . "SQL query result is not an array");
}
}
if ($_SESSION['lang'] == 0) {
echo "Date: " . $record["PublicationDate"] . " ";
// echo "Type: " . $record["Type"] . " ";
echo "Title: " . $record["PublicationTitle"] . " ";
echo "Description: " . "In " . $record["PublicationDescription"] . "." . " ";
echo "Abstract: " . $record["PublicationAbstract"] . " ";
// echo "Link: " . $record["Link"] . " ";
echo "Link: " . "" . $record["PublicationLink"] . "" . " ";
}
if ($_SESSION['lang'] == 1) {
echo "Cianiici?a: " . $record["PublicationDate"] . " ";
// echo "Oy?io: " . $record["Type"] . " ";
echo "T?oeio: " . $record["PublicationTitle"] . " ";
echo "?aneanao?: " . "Ooi " . $record["PublicationDescription"] . "." . " ";
echo "?an?ecoc: " . $record["PublicationAbstract"] . " ";
// echo "Oyiaaoiio: " . $record["Link"] . " ";
echo "Link: " . "" . $record["PublicationLink"] . "" . " ";
}
//
echo " ";
} // while
//
echo "
";
//
echo " | ";
//
echo "
";
}
} // else
//
mysql_close($db);
}
/*
* Not exactly one member exists
*/
else {
//
if ($debug) {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL search found " . $record . " users");
}
/*
* If no users were found
*/
if ($records == 0) {
if ($_SESSION['lang'] == 0) {
echo "No relative record found in the CNL database
";
}
if ($_SESSION['lang'] == 1) {
echo "Aai anYecea o?aoee? aaanao? ooci aUoc aaaiiYiui oio CNL
";
}
} // if
/*
* If more than one users were found
*/
if ($records > 1) {
//
if ($debug) {
// For each user
while ($record = mysql_fetch_array($result)) {
//
if (is_array($record)) {
//
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": MySQL query result is an array with " . count($record) . " elements(s)");
//
foreach ($record as $key=>$value) {
// syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . ": Value of field " . $key . " is " . $record[$value]);
}
}
else {
syslog(LOG_INFO, basename($_SERVER['PHP_SELF']) . "SQL query result is not an array");
}
} // while
} // if
} // if
} // else
} // else
?>
if (isset($_SESSION['loggedIn']) && ($_SESSION['loggedIn'] == true)) {
if ($_SESSION['lang'] == 0) {
echo "