| <?php |
| require_once("/home/data/httpd/eclipse-php-classes/system/dbconnection_workaround.class.php"); |
| #***************************************************************************** |
| # |
| # check_pmc.php |
| # |
| # Author: Karl Matthias |
| # Date: 2007-07-26 |
| # |
| # Description: take an email address and a project as parameters and return |
| # 1 or 0 if someone is a PMC member or not. This is leveraged by AJAX |
| # calls from the IPZilla templates. |
| # |
| # HISTORY: |
| # |
| #**************************************************************************** |
| |
| function globalDisplayErrorHandler($errno, $errmsg, $filename, $linenum, $vars) { |
| $errortype = array ( |
| E_ERROR => 'Error', |
| E_WARNING => 'Warning', |
| E_PARSE => 'Parsing Error', |
| E_NOTICE => 'Notice', |
| E_CORE_ERROR => 'Core Error', |
| E_CORE_WARNING => 'Core Warning', |
| E_COMPILE_ERROR => 'Compile Error', |
| E_COMPILE_WARNING => 'Compile Warning', |
| E_USER_ERROR => 'User Error', |
| E_USER_WARNING => 'User Warning', |
| E_USER_NOTICE => 'User Notice', |
| E_STRICT => 'Runtime Notice', |
| E_RECOVERABLE_ERROR => 'Catchable Fatal Error'); |
| switch($errno) { |
| case E_NOTICE: // discard NOTICEs |
| case E_STRICT: // discard RUNTIME notices for deprecated usages |
| return; |
| default: |
| echo "<p><table cellpadding=10 width=400 bgcolor=#ffcccc><tr><td><font size=+2>Trouble: </font>"; |
| echo "PHP $errortype[$errno]:<br>$errmsg<br>$filename ($linenum)"; |
| $mysql_error_func = 'mysql_error_check'; |
| if(function_exists($mysql_error_func)) { |
| $mysql_error_func(); |
| } |
| echo "</table></p>\n"; |
| } |
| } |
| |
| $old_error_handler = set_error_handler("globalDisplayErrorHandler"); |
| |
| if((!isset($_REQUEST['project'])) || (!isset($_REQUEST['email']))) { |
| echo "!project and email are required parameters"; |
| exit(1); |
| } |
| |
| $project = $_REQUEST['project']; |
| $email = $_REQUEST['email']; |
| |
| if(!preg_match('/^[a-zA-Z-\._0-9]+@[a-zA-Z-\._0-9]+\.[a-zA-Z]+$/', $email)) { |
| echo "!invalid email address: $email"; |
| exit(1); |
| } |
| |
| if(!preg_match('/^[a-z.-A-Z]*$/', $project)) { |
| echo "!invalid project name"; |
| exit(1); |
| } |
| |
| $project = substr($project, 0, strpos($project, '.')); |
| |
| $dbc = new FoundationDBConnectionRW(); |
| $dbh = $dbc->connect() or die("!can't connect to DB"); |
| |
| $result = mysql_query(" |
| SELECT count(1) AS is_pmc FROM People, PeopleProjects |
| WHERE ProjectID = '$project' |
| AND People.EMail = '$email' |
| AND Relation IN ('PM', 'PD') |
| AND InactiveDate IS NULL |
| AND People.PersonID = PeopleProjects.PersonID |
| ", $dbh); |
| |
| if(mysql_errno()) { |
| echo "!db error: " . mysql_error(); |
| exit(1); |
| } |
| |
| $row = mysql_fetch_assoc($result); |
| |
| if(mysql_errno()) { |
| echo "!db error: " . mysql_error(); |
| exit(1); |
| } |
| |
| if($row['is_pmc'] >= 1) { |
| echo "1"; |
| exit(0); |
| } |
| |
| echo "0"; |
| ?> |