function loadFromID($_userid) { $rValue = false; if ($_userid != "") { global $dbh; $_userid = sqlSanitize($_userid, $dbh); $sql = "SELECT *\r\n\t\t\t\tFROM \r\n\t\t\t\t\tusers \r\n\t\t\t\tWHERE userid = {$_userid}"; $result = mysql_query($sql, $dbh); if ($result && mysql_num_rows($result) > 0) { $rValue = true; $myrow = mysql_fetch_assoc($result); $this->userid = $myrow['userid']; $this->username = $myrow['username']; $this->first_name = $myrow['first_name']; $this->last_name = $myrow['last_name']; $this->email = $myrow['email']; $this->primary_language_id = $myrow['primary_language_id']; $this->is_committer = $myrow['is_committer']; $this->hours_per_week = $myrow['hours_per_week']; $this->updated_on = $myrow['updated_on']; $this->updated_at = $myrow['updated_at']; $this->created_on = $myrow['created_on']; $this->created_at = $myrow['created_at']; } else { $GLOBALS['g_ERRSTRS'][1] = mysql_error(); } } return $rValue; }
static function getFileID($_name, $_project_id, $_version) { $rValue = 0; if ($_name != "" && $_project_id != "" && $_version != "") { global $dbh; $sql = "SELECT file_id\n\t\t\t\tFROM \n\t\t\t\t\tfiles \n\t\t\t\tWHERE name = " . returnQuotedString(sqlSanitize($_name, $dbh)) . "\n\t\t\t\t\tAND project_id = " . returnQuotedString(sqlSanitize($_project_id, $dbh)) . "\t\n\t\t\t\t\tAND version = '" . sqlSanitize($_version, $dbh) . "'"; $result = mysql_query($sql, $dbh); if ($result && mysql_num_rows($result) > 0) { $myrow = mysql_fetch_assoc($result); $rValue = $myrow['file_id']; } } return $rValue; }
function authenticate($User, $email, $password) { global $dbh; $email = sqlSanitize($email, $dbh); $password = sqlSanitize($password, $dbh); // since MySQL ENCRYPT is not supported on windows we have to move encryption // from the database layer out to the application layer // https://bugs.eclipse.org/bugs/show_bug.cgi?id=242011 $hash_query = "SELECT users.password_hash FROM users WHERE email = '{$email}'"; $hash_result = mysql_query($hash_query, $dbh); if ($hash_result && mysql_num_rows($hash_result) > 0) { $hash_row = mysql_fetch_assoc($hash_result); $hash = $hash_row['password_hash']; # Handle crypt and sha-256 passwords # Bug 287844 if (preg_match("/{([^}]+)}\$/", $hash, $matches)) { $hash_method = $matches[0]; $salt = substr($hash, 0, 8); $pw = $salt . str_replace("=", "", base64_encode(mhash(MHASH_SHA256, $password . $salt))) . $hash_method; } else { $pw = crypt($password, $hash); } $sql = "SELECT *\n FROM users \n WHERE email = '{$email}' \n AND password_hash = '" . $pw . "'"; $result = mysql_query($sql, $dbh); if ($result && mysql_num_rows($result) > 0) { $rValue = true; $myrow = mysql_fetch_assoc($result); $User->userid = $myrow['userid']; $User->username = $myrow['username']; $User->first_name = $myrow['first_name']; $User->last_name = $myrow['last_name']; $User->email = $myrow['email']; $User->primary_language_id = $myrow['primary_language_id']; $User->is_committer = $myrow['is_committer']; $User->hours_per_week = $myrow['hours_per_week']; $User->updated_on = $myrow['updated_on']; $User->updated_at = $myrow['updated_at']; $User->created_on = $myrow['created_on']; $User->created_at = $myrow['created_at']; } else { // password failed $GLOBALS['g_ERRSTRS'][1] = mysql_error(); } } else { // username failed $GLOBALS['g_ERRSTRS'][1] = mysql_error(); } }
function create($_userid, $_remember) { global $dbh; $this->_userid = sqlSanitize($_userid, $dbh); $this->_gid = $this->guidNbr(); $this->_subnet = $this->getSubnet(); $this->_updated_at = getCURDATE(); $sql = "INSERT INTO sessions (\r\n\t\t\t\tid,\r\n\t\t\t\tuserid,\r\n\t\t\t\tgid,\r\n\t\t\t\tsubnet,\r\n\t\t\t\tupdated_at) VALUES (\r\n\t\t\t\tNULL,\r\n\t\t\t\t" . $this->_userid . ",\r\n\t\t\t\t" . returnQuotedString($this->_gid) . ",\r\n\t\t\t\t" . returnQuotedString($this->_subnet) . ",\r\n\t\t\t\tNOW())"; mysql_query($sql, $dbh); $cookieTime = 0; if ($_remember) { $cookieTime = time() + 3600 * 24 * 365; } setcookie(COOKIE_REMEMBER, $this->_gid, $cookieTime, "/"); $this->maintenance(); }
function authenticate($User, $email, $password) { global $dbh; $email = sqlSanitize($email, $dbh); $password = sqlSanitize($password, $dbh); // since MySQL ENCRYPT is not supported on windows we have to move encryption // from the database layer out to the application layer // https://bugs.eclipse.org/bugs/show_bug.cgi?id=242011 $hash_query = "SELECT users.password_hash FROM users WHERE email = '{$email}'"; $hash_result = mysql_query($hash_query, $dbh); if ($hash_result && mysql_num_rows($hash_result) > 0) { $hash_row = mysql_fetch_assoc($hash_result); $hash = $hash_row['password_hash']; $sql = "SELECT *\n FROM users \n WHERE email = '{$email}' \n AND password_hash = '" . crypt($password, $hash) . "'"; $result = mysql_query($sql, $dbh); if ($result && mysql_num_rows($result) > 0) { $rValue = true; $myrow = mysql_fetch_assoc($result); $User->userid = $myrow['userid']; $User->username = $myrow['username']; $User->first_name = $myrow['first_name']; $User->last_name = $myrow['last_name']; $User->email = $myrow['email']; $User->primary_language_id = $myrow['primary_language_id']; $User->is_committer = $myrow['is_committer']; $User->hours_per_week = $myrow['hours_per_week']; $User->updated_on = $myrow['updated_on']; $User->updated_at = $myrow['updated_at']; $User->created_on = $myrow['created_on']; $User->created_at = $myrow['created_at']; } else { // password failed $GLOBALS['g_ERRSTRS'][1] = mysql_error(); } } else { // username failed $GLOBALS['g_ERRSTRS'][1] = mysql_error(); } }
/** * add event log entry to the table * * @return String Error message (if any) */ function add() { $rValue = ""; global $User, $dbh; # remove anything after a space $has_space = strpos($this->action, ' '); if ($has_space !== FALSE && $has_space > 0) { $this->action = substr($this->action, 0, $has_space); } if ($this->table_name != "" && $this->key_name != "" && $this->key_value != "" && $this->action != "") { $sql = "INSERT INTO event_log SET\n\t\t\t\t\tevent_id = NULL,\n\t\t\t\t\ttable_name = " . returnQuotedString(sqlSanitize($this->table_name, $dbh)) . ",\n\t\t\t\t\tkey_name = " . returnQuotedString(sqlSanitize($this->key_name, $dbh)) . ",\n\t\t\t\t\tkey_value = " . returnQuotedString(sqlSanitize($this->key_value, $dbh)) . ",\n\t\t\t\t\taction = " . returnQuotedString(sqlSanitize($this->action, $dbh)) . ",\n\t\t\t\t\tuserid = " . sqlSanitize($User->userid, $dbh) . ",\n\t\t\t\t\tcreated_on = NOW()"; mysql_query($sql, $dbh); if (mysql_error() != "") { echo "An unknown database error has occurred while logging information. Please contact the System Administrator."; echo mysql_error(); $rValue = "MYSQL: " . mysql_error(); } } else { $rValue = "CRIT: Missing critical information for logging"; } return $rValue; }
mysql_query($sql, $dbh); } } } # Save the project/train association $sql = "DELETE FROM release_train_projects WHERE project_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)); mysql_query($sql, $dbh); $sql = "INSERT INTO release_train_projects SET project_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . ", version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)) . ", train_id = " . returnQuotedString(sqlSanitize($TRAIN_ID, $dbh)); mysql_query($sql, $dbh); $GLOBALS['g_ERRSTRS'][0] = "Map files saved."; } else { $GLOBALS['g_ERRSTRS'][0] = "Project, version and URL cannot be empty."; } } if ($SUBMIT == "delete") { $SUBMIT = "showfiles"; $sql = "DELETE FROM map_files WHERE \n\tproject_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . "\n\tAND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)) . "\n\tAND filename = " . returnQuotedString(sqlSanitize($FILENAME, $dbh)) . " LIMIT 1"; mysql_query($sql, $dbh); } $sql = "SELECT project_id FROM projects WHERE is_active = 1 ORDER BY project_id"; $rs_project_list = mysql_query($sql, $dbh); $sql = "SELECT pv.project_id, pv.version, count(m.is_active) AS map_count FROM project_versions as pv left join map_files as m on m.project_id = pv.project_id and m.version = pv.version WHERE pv.is_active = 1 and pv.version != 'unspecified' group by pv.project_id, pv.version ORDER BY pv.project_id ASC, pv.version DESC;"; $rs_version_list = mysql_query($sql, $dbh); $sql = "SELECT train_id FROM release_trains ORDER BY train_id ASC"; $rs_train_list = mysql_query($sql, $dbh); $sql = "SELECT train_id, project_id, version FROM release_train_projects ORDER BY project_id, version ASC"; $rs_train_project_list = mysql_query($sql, $dbh); global $addon; $addon->callHook("head"); include $incfile; $addon->callHook("footer");
<?php /******************************************************************************* * Copyright (c) 2009-2013 Eclipse Foundation, IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Eclipse Foundation - Initial API and implementation * Kit Lo (IBM) - Bug 299402, Extract properties files from Eclipse project update sites for translation * Kit Lo (IBM) - [402192] Extract project source files from Git repositories for translation *******************************************************************************/ require_once "cb_global.php"; $return = array(); $project_id = getHTTPParameter("project_id", "POST"); $version = getHTTPParameter("version", "POST"); $query = "SELECT m.project_id, m.version, r.train_id, m.location, m.filename FROM map_files m\n\tLEFT JOIN release_train_projects r ON m.project_id = r.project_id AND m.version = r.version\n\tWHERE m.is_active = 1 \n\tAND m.project_id = " . returnQuotedString(sqlSanitize($project_id, $dbh)) . "\n\tAND m.version = " . returnQuotedString(sqlSanitize($version, $dbh)); $res = mysql_query($query, $dbh); if (mysql_affected_rows($dbh) > 0) { while ($line = mysql_fetch_array($res, MYSQL_ASSOC)) { echo $line['location'] . "\n"; } } else { echo "No map files or update sites found for {$project_id} {$version}"; }
<?php /******************************************************************************* * Copyright (c) 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Kit Lo (IBM) - [402192] Extract project source files from Git repositories for translation *******************************************************************************/ require_once "cb_global.php"; $return = array(); $project_id = getHTTPParameter("project_id", "POST"); $version = getHTTPParameter("version", "POST"); $query = "SELECT m.project_id, m.version, r.train_id, m.location FROM project_source_locations m\n\tLEFT JOIN release_train_projects r ON m.project_id = r.project_id AND m.version = r.version\n\tWHERE m.project_id = " . returnQuotedString(sqlSanitize($project_id, $dbh)) . "\n\tAND m.version = " . returnQuotedString(sqlSanitize($version, $dbh)); $res = mysql_query($query, $dbh); if (mysql_affected_rows($dbh) > 0) { while ($line = mysql_fetch_array($res, MYSQL_ASSOC)) { echo $line['location'] . "\n"; } } else { echo "No project source locations found for {$project_id} {$version}"; }
$PROJECT_ID = $items[0]; $VERSION = $items[1]; } $LANGUAGE_ID = getHTTPParameter("language_id"); $SUBMIT = getHTTPParameter("submit"); $sql = "SELECT DISTINCT pv_m.project_id, pv_m.version FROM project_versions AS pv_m INNER JOIN map_files as m ON pv_m.project_id = m.project_id AND pv_m.version = m.version WHERE pv_m.is_active UNION SELECT DISTINCT pv_s.project_id, pv_s.version FROM project_versions AS pv_s INNER JOIN project_source_locations as s ON pv_s.project_id = s.project_id AND pv_s.version = s.version WHERE pv_s.is_active ORDER BY project_id ASC, version DESC"; $rs_p_list = mysql_query($sql, $dbh); $sql = "SELECT language_id, IF(locale <> '', CONCAT(CONCAT(CONCAT(name, ' ('), locale), ')'), name) as name FROM languages WHERE is_active AND iso_code != 'en' ORDER BY name"; $rs_l_list = mysql_query($sql, $dbh); $where = ""; if ($PROJECT_ID != "") { $where = addAndIfNotNull($where) . " p.project_id = "; $where .= returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)); } if ($LANGUAGE_ID != "") { $where = addAndIfNotNull($where) . " l.language_id = "; $where .= returnQuotedString(sqlSanitize($LANGUAGE_ID, $dbh)); } if ($VERSION != "") { $where = addAndIfNotNull($where) . "p.version = "; $where .= returnQuotedString(sqlSanitize($VERSION, $dbh)); } if ($where != "") { $where = " WHERE " . $where; } $sql = "SELECT p.project_id, p.version, l.name, l.locale, p.pct_complete FROM project_progress AS p INNER JOIN languages AS l ON l.language_id = p.language_id {$where} ORDER BY p.pct_complete DESC, p.project_id, p.version, l.name"; $rs_p_stat = mysql_query($sql, $dbh); global $addon; $addon->callHook("head"); include $incfile; $addon->callHook("footer");
/** * Sets a string as inactive * @author droy * @param Integer string_id * @return bool success status */ function deactivate($_string_id) { $rValue = 0; if ($_string_id > 0) { global $dbh; $sql = "UPDATE strings \n\t\t\t\t\tSET is_active = 0 WHERE string_id = " . sqlSanitize($_string_id, $dbh); $rValue = mysql_query($sql, $dbh); $Event = new EventLog("strings", "string_id", $_string_id, "DEACTIVATE"); $Event->add(); } return $rValue; }
$sql = "SELECT language_id, IF(locale <> '', CONCAT(CONCAT(CONCAT(name, ' ('), locale), ')'), name) as name FROM languages WHERE is_active AND iso_code != 'en' ORDER BY name"; $rs_l_list = mysql_query($sql, $dbh); $where = " t.is_active "; if ($PROJECT_ID != "") { $where = addAndIfNotNull($where) . " f.project_id = "; $where .= returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)); } if ($LANGUAGE_ID != "") { $where = addAndIfNotNull($where) . " t.language_id = "; $where .= returnQuotedString(sqlSanitize($LANGUAGE_ID, $dbh)); } if ($VERSION != "") { $where = addAndIfNotNull($where) . "f.version = "; $where .= returnQuotedString(sqlSanitize($VERSION, $dbh)); } if ($USERID != "") { $where = addAndIfNotNull($where) . "u.userid = "; $where .= sqlSanitize($USERID, $dbh); } if ($FUZZY == 1) { $where = addAndIfNotNull($where) . "t.possibly_incorrect = 1 "; } if ($where != "") { $where = " WHERE " . $where; } $sql = "SELECT \r\n s.name AS string_key, s.value as string_value, \r\n t.value as translation,\r\n t.possibly_incorrect as fuzzy, \r\n IF(u.last_name <> '' AND u.first_name <> '', \r\n \tCONCAT(CONCAT(first_name, ' '), u.last_name), \r\n \tIF(u.first_name <> '', u.first_name, u.last_name)) AS who,\r\n u.userid, \r\n t.created_on, l.iso_code as language,\r\n f.project_id, f.version, f.name\r\nFROM \r\n translations as t \r\n LEFT JOIN strings as s on s.string_id = t.string_id \r\n LEFT JOIN files as f on s.file_id = f.file_id \r\n LEFT JOIN users as u on u.userid = t.userid\r\n LEFT JOIN languages as l on l.language_id = t.language_id \r\n{$where}\r\nORDER BY t.created_on desc \r\nLIMIT {$LIMIT}"; $rs_p_stat = mysql_query($sql, $dbh); global $addon; $addon->callHook("head"); include $incfile; $addon->callHook("footer");
# Insert new plugin exclude patterns for this project version $list = explode("\n", $PATTERNS); foreach ($list as $pattern) { $pattern = str_replace("\r", "", $pattern); if (strlen($pattern) > 0) { if (strlen($pattern) > 26 && strcmp(substr($pattern, 0, 26), "No plugin exclude patterns") == 0) { } else { $sql = "INSERT INTO plugin_exclude_patterns VALUES (" . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . "," . returnQuotedString(sqlSanitize($VERSION, $dbh)) . "," . returnQuotedString(sqlSanitize($pattern, $dbh)) . ")"; mysql_query($sql, $dbh); } } } # Save the project/train association $sql = "DELETE FROM release_train_projects WHERE project_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)); mysql_query($sql, $dbh); $sql = "INSERT INTO release_train_projects SET project_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . ", version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)) . ", train_id = " . returnQuotedString(sqlSanitize($TRAIN_ID, $dbh)); mysql_query($sql, $dbh); $GLOBALS['g_ERRSTRS'][0] = "Project source locations saved."; } else { $GLOBALS['g_ERRSTRS'][0] = "Project, version and URL cannot be empty."; } } $sql = "SELECT project_id FROM projects WHERE is_active = 1 ORDER BY project_id"; $rs_project_list = mysql_query($sql, $dbh); $sql = "SELECT pv.project_id, pv.version, count(m.location) AS map_count FROM project_versions as pv left join project_source_locations as m on m.project_id = pv.project_id and m.version = pv.version WHERE pv.is_active = 1 and pv.version != 'unspecified' group by pv.project_id, pv.version ORDER BY pv.project_id ASC, pv.version DESC;"; $rs_version_list = mysql_query($sql, $dbh); $sql = "SELECT train_id FROM release_trains ORDER BY train_id ASC"; $rs_train_list = mysql_query($sql, $dbh); $sql = "SELECT train_id, project_id, version FROM release_train_projects ORDER BY project_id, version ASC"; $rs_train_project_list = mysql_query($sql, $dbh); global $addon;
<?php /******************************************************************************* * Copyright (c) 2010-2013 Eclipse Foundation, IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Eclipse Foundation - Initial API and implementation * Kit Lo (IBM) - Bug 299402, Extract properties files from Eclipse project update sites for translation * Kit Lo (IBM) - [402192] Extract project source files from Git repositories for translation *******************************************************************************/ require_once "cb_global.php"; $return = array(); $project_id = getHTTPParameter("project_id", "POST"); $version = getHTTPParameter("version", "POST"); $query = "SELECT pattern FROM plugin_exclude_patterns WHERE project_id = " . returnQuotedString(sqlSanitize($project_id, $dbh)) . " AND version = " . returnQuotedString(sqlSanitize($version, $dbh)); $res = mysql_query($query, $dbh); if (mysql_affected_rows($dbh) > 0) { while ($line = mysql_fetch_array($res, MYSQL_ASSOC)) { echo $line['pattern'] . "\n"; } } else { echo "No plugin exclude patterns found for {$project_id} {$version}"; }
<?php /******************************************************************************* * Copyright (c) 2010 Eclipse Foundation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Eclipse Foundation - Initial API and implementation * Kit Lo (IBM) - Bug 299402, Extract properties files from Eclipse project update sites for translation *******************************************************************************/ require_once "cb_global.php"; $return = array(); $project_id = getHTTPParameter("project_id", "POST"); $version = getHTTPParameter("version", "POST"); $query = "SELECT is_map_file FROM map_files WHERE project_id = " . returnQuotedString(sqlSanitize($project_id, $dbh)) . " AND version = " . returnQuotedString(sqlSanitize($version, $dbh)) . " LIMIT 1"; $res = mysql_query($query, $dbh); if (mysql_affected_rows($dbh) > 0) { while ($line = mysql_fetch_array($res, MYSQL_ASSOC)) { echo $line['is_map_file']; } } else { echo "No plugin exclude patterns found for {$project_id} {$version}."; }
$sql = "DELETE FROM release_train_projects WHERE project_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . " AND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)); mysql_query($sql, $dbh); $sql = "INSERT INTO release_train_projects SET project_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . ", version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)) . ", train_id = " . returnQuotedString(sqlSanitize($TRAIN_ID, $dbh)); mysql_query($sql, $dbh); } else { $GLOBALS['g_ERRSTRS'][0] = "Project, version and URL cannot be empty."; } } if ($SUBMIT == "delete") { $SUBMIT = "showfiles"; $sql = "DELETE FROM map_files WHERE \r\n\tproject_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . "\r\n\tAND version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)) . "\r\n\tAND filename = " . returnQuotedString(sqlSanitize($FILENAME, $dbh)) . " LIMIT 1"; mysql_query($sql, $dbh); } if ($SUBMIT == "showfiles") { $incfile = "content/en_map_files_show.php"; $sql = "SELECT m.project_id, m.version, r.train_id, m.location, m.filename FROM map_files m\r\n\tLEFT JOIN release_train_projects r ON m.project_id = r.project_id AND m.version = r.version\r\n\tWHERE m.is_active = 1 \r\n\tAND m.project_id = " . returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)) . "\r\n\tAND m.version = " . returnQuotedString(sqlSanitize($VERSION, $dbh)); $rs_map_file_list = mysql_query($sql, $dbh); include $incfile; } else { $sql = "SELECT project_id FROM projects WHERE is_active = 1 ORDER BY project_id"; $rs_project_list = mysql_query($sql, $dbh); $sql = "SELECT project_id, version FROM project_versions WHERE is_active = 1 and version != 'unspecified' ORDER BY project_id ASC, version DESC"; $rs_version_list = mysql_query($sql, $dbh); $sql = "SELECT DISTINCT train_id FROM release_train_projects ORDER BY train_id ASC"; $rs_train_list = mysql_query($sql, $dbh); $sql = "SELECT train_id, project_id, version FROM release_train_projects ORDER BY project_id, version ASC"; $rs_train_project_list = mysql_query($sql, $dbh); global $addon; $addon->callHook("head"); include $incfile; $addon->callHook("footer");