"); pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!"); ?> '%s'", $LINUXTAG_AUTH['id'], $LINUXTAG_AUTH['project']); $sth = pg_exec($dbh, $query) or die ("Cannot execute query"); for ($nr=0; $nr < pg_NumRows ($sth); $nr++) { $row = pg_fetch_array($sth, $nr); if (strlen($LINUXTAG_AUTH["projects"]) > 0) { $LINUXTAG_AUTH["projects"] .= ", " . $row['project']; } else { $LINUXTAG_AUTH["projects"] = $row['project']; } } ####### This code is temporaly disabled ## update the last login timestamp #$query = sprintf("UPDATE person set lastlogin = current_timestamp where email = '%s'", # addslashes($LINUXTAG_AUTH['email'])); #pg_exec ($dbh, $query) or die ("Datenbank-Fehler"); } else { reauth(); } if (!is_supporter()) { $query = sprintf ("SELECT person FROM junction WHERE person = %d AND project = 'Supporter'", $LINUXTAG_AUTH['id']); $sth = pg_exec($dbh, $query) or die ("Cannot execute query"); if (pg_NumRows($sth) > 0) { $LINUXTAG_AUTH['supporter'] = 1; } else { $LINUXTAG_AUTH['supporter'] = 0; } } else { $LINUXTAG_AUTH['supporter'] = 1; } } ?> # Functions below will be included into all pages 1) { return false; } } // If not, we will try to find out the project of this user if (preg_match("/^[0-9]+$/", $id)) { $query = sprintf ("SELECT junction.project FROM junction,person " ."WHERE person = id AND id=%d", $id); } else { die ("ID needs to be numeric"); } $sth = pg_exec($dbh, $query) or die("Could not find user"); if (pg_NumRows($sth) == 0) { return false; } for ($nr=0; $nr < pg_NumRows ($sth); $nr++) { $row = pg_fetch_array($sth, $nr); if ($row['project'] == $LINUXTAG_AUTH["project"]) { return true; } } return false; } # Check whether a user is allowed to edit a particular workshop # function allowed_to_edit_workshop($oid) { global $LINUXTAG_AUTH, $dbh; if (!isset ($oid)) { echo ("

No workshop selected, uh?

"); return false; } if (is_admin ()) { $query = sprintf ("SELECT project FROM workshop WHERE oid = %d", $oid); $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!"); if (pg_NumRows ($sth) > 0) { $row = pg_fetch_array ($sth, 0); if ($row['project'] == $LINUXTAG_AUTH['project']) { return true; } } } $query = sprintf ("SELECT name,person FROM workshop,person WHERE person = id AND workshop.oid = %d", $oid); $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!"); if (pg_NumRows ($sth) > 0) { $row = pg_fetch_array ($sth, 0); if ($row['person'] == $LINUXTAG_AUTH['id']) { return true; } else { echo ("

Only the admin of a project or the speaker may edit workshop data.

"); return false; } } else { echo ("

No such workshop found.

"); return false; } return false; } # This function will return a list of users the given user is allowed to edit # function list_of_users($user) { global $dbh; $users = array(); // First, we check if the User is an admin $query = sprintf("SELECT admin,name,email,project FROM person WHERE name='%s'", addslashes($user)); $sth = pg_exec($dbh, $query) or die ("Cannot find this user"); if (pg_NumRows($sth) > 0) { $row = pg_fetch_array($sth, 0); } else { die ("User has disappeard"); } if ($row[0] <> 1) { // This user is only allowed to edit himself $users[0] = array($row[1], $row[2]); return $users; } else { // OK, this user is allowed to edit all persons from his project, so lets find this persons $query = sprintf("SELECT name,email FROM person WHERE project='%s' ORDER BY upper(name)", addslashes($row[3])); $sth = pg_exec($dbh, $query) or die ("Cannot find persons from project"); if (pg_NumRows($sth) > 0) { for ($x = 0; $x < pg_NumRows($sth); $x++) { $row = pg_fetch_array($sth, $x); $users[$x] = array($row[0], $row[1]); } } else { die ("Cannot find any users of this project"); } } return $users; } ?> 0) { $body = "LinuxTag Projects Management\n"; $body .= "\n\n"; $body .= "Account: " . $email . "\n"; $body .= "Password: " . $newpass . "\n"; $body .= "\nThe password may be changed within the system."; $body .= "\nSince this site does not use https, please don't use the same password\nsomewhere else.\n"; $body .= "\nYou are subscribed to the infomails.\nYou can change this using the web interface.\n"; $body .= "\nThis account is only valid for this years' LinuxTag.\n"; $body .= "\nThanks for your commitment.\n"; mail($email, "[LT Projects] New Password", $body, "From: joey@infodrom.org (LinuxTag Projects Management)"); } return true; } ?> "Permission", 2 => "IO", 3 => "SQL", 4 => "No Rows" ); # WARNING! # catch_error is not finished yet # This function is for reporting errors # $error_level is the kind of the error # $error_message is a message we can give to the user # $debugging_output is output we should log, for exampel a query which failed function catch_error($error_level, $debugging_output = '', $error_message = '') { global $errorlevel; // First we open a logfile $file = fopen("logfile.txt", "a") or die ("Cannot open logfile"); // Lock it flock($file, 2) or die ("Cannot lock logfile"); // Write a usefull message to this file fwrite($file, strftime("%Y-%m-%d %T") . ": " . $errorlevel[$error_level] . ": " . $debugging_output); echo "Error:
Sorry, we were unable to handle your request
"; if ($error_level == 1) { echo "Permission denied
"; } elseif (($error_level == 3) or ($error_level == 4)) { echo "Database problem
"; } echo $error_message . "
"; // Unlock it flock($file, 3); } $days = array( "" => array( "dinner" => "dinner-", "sleeping" => "sleeping-"), "" => array( "breakfast" => "breakfast-", "dinner" => "dinner-", "sleeping" => "sleeping-"), "" => array( "breakfast" => "breakfast-", "dinner" => "dinner-", "sleeping" => "sleeping-"), "" => array( "breakfast" => "breakfast-", "dinner" => "dinner-", "sleeping" => "sleeping-"), "" => array( "breakfast" => "breakfast-", "dinner" => "dinner-", "sleeping" => "sleeping-"), "" => array( "breakfast" => "breakfast-") ); ?> # Local variables: # mode: indented-text # mode: auto-fill # end: