droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 1 | <?php |
| 2 | /******************************************************************************* |
| 3 | * Copyright (c) 2008 Eclipse Foundation and others. |
| 4 | * All rights reserved. This program and the accompanying materials |
| 5 | * are made available under the terms of the Eclipse Public License v1.0 |
| 6 | * which accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Eclipse Foundation - Initial API and implementation |
Kit Lo | ddc3f12 | 2013-06-27 18:01:40 -0400 | [diff] [blame] | 11 | * Kit Lo (IBM) - [261739] Inconsistent use of language names |
| 12 | * Kit Lo (IBM) - [411832] Stats and Recent pages do not show Orion in project dropdown list |
syoshida@git.eclipse.org | cd63239 | 2015-11-12 23:10:41 +0900 | [diff] [blame] | 13 | * Satoru Yoshida - [221181] Search a specific string |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 14 | *******************************************************************************/ |
| 15 | include("global.php"); |
| 16 | |
| 17 | InitPage(""); |
| 18 | |
| 19 | global $User; |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 20 | global $dbh; |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 21 | |
| 22 | $pageTitle = "Babel - Recent Translations"; |
| 23 | $pageKeywords = ""; |
droy | addb32f | 2008-06-03 15:11:51 +0000 | [diff] [blame] | 24 | $incfile = "content/en_recent_html_list.php"; |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 25 | |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 26 | $PROJECT_VERSION = getHTTPParameter("project_version"); |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 27 | $PROJECT_ID = ""; |
| 28 | $VERSION = ""; |
| 29 | |
| 30 | if($PROJECT_VERSION != "") { |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 31 | $items = explode("|", $PROJECT_VERSION); |
| 32 | $PROJECT_ID = $items[0]; |
| 33 | $VERSION = $items[1]; |
| 34 | } |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 35 | $LANGUAGE_ID= getHTTPParameter("language_id"); |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 36 | if($LANGUAGE_ID == "") { |
| 37 | $LANGUAGE_ID = $_SESSION["language"]; |
| 38 | } |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 39 | |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 40 | $FUZZY = getHTTPParameter("fuzzy"); |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 41 | if($FUZZY == "" || $FUZZY != 1) { |
| 42 | $FUZZY = 0; |
| 43 | } |
| 44 | |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 45 | if($LANGUAGE_ID == "All") { |
| 46 | $LANGUAGE_ID = ""; |
| 47 | } |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 48 | $LIMIT = getHTTPParameter("limit"); |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 49 | if($LIMIT == "" || $LIMIT <= 0 || $LIMIT > 20000) { |
droy | b1e81bf | 2012-10-09 15:53:11 -0400 | [diff] [blame] | 50 | $LIMIT = 25; |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 51 | } |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 52 | $LAYOUT = getHTTPParameter("layout"); |
droy | addb32f | 2008-06-03 15:11:51 +0000 | [diff] [blame] | 53 | if($LAYOUT == "list" || $LAYOUT == "table") { |
| 54 | $incfile = "content/en_recent_html_" . $LAYOUT . ".php"; |
| 55 | } |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 56 | $FORMAT = getHTTPParameter("format"); |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 57 | if($FORMAT == "rss") { |
| 58 | $incfile = "content/en_recent_rss.php"; |
| 59 | } |
syoshida@git.eclipse.org | cd63239 | 2015-11-12 23:10:41 +0900 | [diff] [blame] | 60 | $s_value = getHTTPParameter("s_value"); |
| 61 | $s_value = trim($s_value); |
| 62 | if ($s_value !== '') { |
| 63 | $s_value_in_sql = $s_value . '%'; |
| 64 | } else { |
| 65 | $s_value_in_sql = ''; |
| 66 | } |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 67 | $USERID = getHTTPParameter("userid"); |
| 68 | $SUBMIT = getHTTPParameter("submit"); |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 69 | |
Kit Lo | 371a035 | 2013-07-07 11:03:04 -0400 | [diff] [blame] | 70 | $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"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 71 | $rs_p_list = mysqli_query($dbh, $sql); |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 72 | |
kitlo | 47df0c6 | 2009-01-22 15:16:18 +0000 | [diff] [blame] | 73 | $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"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 74 | $rs_l_list = mysqli_query($dbh, $sql); |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 75 | |
| 76 | $where = " t.is_active "; |
| 77 | |
| 78 | if($PROJECT_ID != "") { |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 79 | $where = addAndIfNotNull($where) . " f.project_id = "; |
| 80 | $where .= returnQuotedString(sqlSanitize($PROJECT_ID, $dbh)); |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 81 | } |
| 82 | if($LANGUAGE_ID != "") { |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 83 | $where = addAndIfNotNull($where) . " t.language_id = "; |
| 84 | $where .= returnQuotedString(sqlSanitize($LANGUAGE_ID, $dbh)); |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 85 | } |
| 86 | if($VERSION != "") { |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 87 | $where = addAndIfNotNull($where) . "f.version = "; |
| 88 | $where .= returnQuotedString(sqlSanitize($VERSION, $dbh)); |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 89 | } |
syoshida@git.eclipse.org | cd63239 | 2015-11-12 23:10:41 +0900 | [diff] [blame] | 90 | if($s_value_in_sql !== "") { |
| 91 | $where = addAndIfNotNull($where) . "s.value like "; |
| 92 | $where .= returnQuotedString(sqlSanitize($s_value_in_sql, $dbh)); |
| 93 | } |
droy | 8ad08be | 2008-11-12 19:49:33 +0000 | [diff] [blame] | 94 | if($USERID != "") { |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 95 | $where = addAndIfNotNull($where) . "u.userid = "; |
| 96 | $where .= sqlSanitize($USERID, $dbh); |
droy | 8ad08be | 2008-11-12 19:49:33 +0000 | [diff] [blame] | 97 | } |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 98 | if($FUZZY == 1) { |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 99 | $where = addAndIfNotNull($where) . "t.possibly_incorrect = 1 "; |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 100 | } |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 101 | |
| 102 | if($where != "") { |
| 103 | $where = " WHERE " . $where; |
| 104 | } |
| 105 | |
| 106 | |
| 107 | $sql = "SELECT |
droy | addb32f | 2008-06-03 15:11:51 +0000 | [diff] [blame] | 108 | s.name AS string_key, s.value as string_value, |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 109 | t.value as translation, |
| 110 | t.possibly_incorrect as fuzzy, |
droy | 35598f0 | 2008-06-03 15:16:48 +0000 | [diff] [blame] | 111 | IF(u.last_name <> '' AND u.first_name <> '', |
| 112 | CONCAT(CONCAT(first_name, ' '), u.last_name), |
droy | 8ad08be | 2008-11-12 19:49:33 +0000 | [diff] [blame] | 113 | IF(u.first_name <> '', u.first_name, u.last_name)) AS who, |
| 114 | u.userid, |
droy | ab4eaa1 | 2008-11-11 14:19:38 +0000 | [diff] [blame] | 115 | t.created_on, l.iso_code as language, |
droy | addb32f | 2008-06-03 15:11:51 +0000 | [diff] [blame] | 116 | f.project_id, f.version, f.name |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 117 | FROM |
| 118 | translations as t |
| 119 | LEFT JOIN strings as s on s.string_id = t.string_id |
| 120 | LEFT JOIN files as f on s.file_id = f.file_id |
droy | ab4eaa1 | 2008-11-11 14:19:38 +0000 | [diff] [blame] | 121 | LEFT JOIN users as u on u.userid = t.userid |
| 122 | LEFT JOIN languages as l on l.language_id = t.language_id |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 123 | $where |
| 124 | ORDER BY t.created_on desc |
| 125 | LIMIT $LIMIT"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 126 | $rs_p_stat = mysqli_query($dbh, $sql); |
atoulme | a4adf8e | 2009-01-27 19:01:35 +0000 | [diff] [blame] | 127 | global $addon; |
| 128 | $addon->callHook("head"); |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 129 | include($incfile); |
atoulme | a4adf8e | 2009-01-27 19:01:35 +0000 | [diff] [blame] | 130 | $addon->callHook("footer"); |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 131 | |
droy | 7fcffa7 | 2008-06-02 20:33:14 +0000 | [diff] [blame] | 132 | ?> |