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; }
/** * 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; }
/** * Get string object from name of a value * * @param Integer $_file_id * @param String $_name * @return String String object */ function getStringFromName($_file_id, $_name) { $rValue = new String(); if ($_file_id > 0 && $_name != "") { global $dbh; # Bug 236454 - string token needs to be case sensitive $sql = "SELECT *\r\n\t\t\t\tFROM \r\n\t\t\t\t\tstrings\r\n\t\t\t\tWHERE file_id = " . sqlSanitize($_file_id, $dbh) . "\r\n\t\t\t\t\tAND name = BINARY " . returnQuotedString(sqlSanitize($_name, $dbh)); $result = mysql_query($sql, $dbh); if ($result && mysql_num_rows($result) > 0) { $myrow = mysql_fetch_assoc($result); $String = new String(); $String->string_id = $myrow['string_id']; $String->file_id = $myrow['file_id']; $String->name = $myrow['name']; $String->value = $myrow['value']; $String->userid = $myrow['userid']; $String->created_on = $myrow['created_on']; $String->is_active = $myrow['is_active']; $rValue = $String; } } 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");
function maintenance() { # Delete sessions older than 14 days # and sessions where the same subnet,user has different gids global $dbh; $sql = "DELETE FROM sessions \r\n\t\t\t\tWHERE updated_at < DATE_SUB(NOW(), INTERVAL 14 DAY) \r\n\t\t\t\t\tOR (userid = " . $this->_userid . "\r\n\t\t\t\t\t\tAND subnet = " . returnQuotedString($this->getSubnet()) . "\r\n\t\t\t\t\t\tAND gid <> " . returnQuotedString($this->_gid) . ")"; mysql_query($sql, $dbh); }
<?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");
# 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");