function get_bug_id_from_artas_id($t_artas_id) { # ATR or ACP if (substr($t_artas_id, 0, 3) == "ATR") { $t_cstm_field = 55; $t_artas_id = str_replace("ATR", "", $t_artas_id); } else { if (substr($t_artas_id, 0, 3) == "ACP") { $t_cstm_field = 56; $t_artas_id = str_replace("ACP", "", $t_artas_id); } else { return "null"; } } list($t_artas_id_number, $t_version) = split("-", $t_artas_id); $t_version = str_replace("_", " ", $t_version); $t_custom_table = db_get_table('mantis_custom_field_string_table'); $t_bug_table = db_get_table('mantis_bug_table'); $query = 'SELECT bug_id FROM ' . $t_custom_table . ',' . $t_bug_table . ' WHERE ' . $t_custom_table . '.bug_id = ' . $t_bug_table . '.id and field_id = ' . $t_cstm_field . ' AND value = ' . $t_artas_id_number . ' and version = "' . $t_version . '"'; $result = db_query_bound($query, null); $rows = array(); $i = 0; while ($row = db_fetch_array($result)) { $rows[] = $row['bug_id']; $i++; } if ($i == 1) { return $rows[0]; } else { return "null"; } }
function displayResultsCore($query, $fields) { $result = db_query_bound($query); $nbRows = 0; while ($row = db_fetch_array($result)) { $nbRows++; $t_bug = bug_get($row['id']); print "<tr> \n"; print '<td><a href="' . string_get_bug_view_url($row['id']) . '">' . bug_format_id($row['id']) . '</a></td>'; //print "<td> ".string_get_bug_view_url( ))." </td>\n"; print "<td> " . string_display_line(get_enum_element('status', $t_bug->status)) . " </td>\n"; print "<td> " . category_get_row($t_bug->category_id)['name'] . " </td>\n"; print "<td> " . $t_bug->summary . " </td>\n"; print "<td> " . user_get_field($t_bug->reporter_id, 'username') . " </td>\n"; if ($t_bug->handler_id != null) { print "<td> " . user_get_field($t_bug->handler_id, 'username') . " </td>\n"; } if (sizeof($fields) > 0) { for ($i = 0; $i < sizeof($fields); $i++) { print "<td> " . $row[$fields[$i]] . " </td>\n"; } } print "</tr>\n"; } return $nbRows; }
function renderIssues($status) { $content = array(); $t_project_id = helper_get_current_project(); $t_bug_table = db_get_table('mantis_bug_table'); $t_user_id = auth_get_current_user_id(); $specific_where = helper_project_specific_where($t_project_id, $t_user_id); if ($this->severity) { $severityCond = '= ' . $this->severity; } else { $severityCond = '> -1'; } $query = "SELECT *\n\t\t\tFROM {$t_bug_table}\n\t\t\tWHERE {$specific_where}\n\t\t\tAND status = {$status}\n\t\t\tAND severity {$severityCond}\n\t\t\tORDER BY last_updated DESC\n\t\t\tLIMIT 20"; $result = db_query_bound($query); $category_count = db_num_rows($result); for ($i = 0; $i < $category_count; $i++) { $row = db_fetch_array($result); //pre_var_dump($row); $content[] = '<div class="portlet ui-helper-clearfix" id="' . $row['id'] . '"> <div class="portlet-header">' . string_get_bug_view_link($row['id']) . ': ' . $row['summary'] . '</div> <div class="portlet-content">' . ($row['reporter_id'] ? 'Reporter: ' . user_get_name($row['reporter_id']) . BR : '') . ($row['handler_id'] ? 'Assigned: ' . user_get_name($row['handler_id']) . BR : '') . '</div></div>'; } if ($row) { //pre_var_dump(array_keys($row)); } return $content; }
function faq_count_query($p_project_id) { global $g_mantis_faq_table; $query = "SELECT COUNT(*)\n\t\t\t\tFROM {$g_mantis_faq_table}\n\t\t\t\tWHERE project_id='{$p_project_id}' OR project_id='0000000'"; $result = db_query_bound($query); return db_result($result, 0, 0); }
function helper_table_row_count($p_table) { $t_table = $p_table; $query = "SELECT COUNT(*) FROM {$t_table}"; $result = db_query_bound($query); $t_users = db_result($result); return $t_users; }
/** * Fetches given query. * * @param string $query * @param array $params * @return array */ public function fetch($query, array $params = []) { $result = db_query_bound($query, $params); if (0 == db_num_rows($result)) { return []; } return $result->GetArray(); }
/** * @author Lennard Bredenkamp, BFE * NOT USED AT THE MOMENT (loadRelations is used to load multiple relations instead) * get single tts_relation object from DB * @param $p_bug_id * @param $tts_exec_id * @return TTSrelation object */ static function loadRelation($p_bug_id, $tts_exec_id) { $t_project_table = plugin_table('project', 'TTSintegr'); $its_id = $p_bug_id; $t_query = "SELECT * FROM {$t_project_table} WHERE its_id=" . db_param() . " AND tts_exec_id=" . db_param(); $t_result = db_query_bound($t_query, array($its_id, $tts_exec_id)); $t_row = db_fetch_array($t_result); $t_relation = new TTSrelation($t_row['its_id'], $t_row['tts_exec_id'], $t_row['tts_tproject_id']); return $t_relation; }
function add_format($p_customer_name, $p_assembly_number, $p_revision, $p_format, $p_format_example, $new_customer, $new_assembly) { $p_assembly_id = add_assembly($p_assembly_number, $p_revision, $p_customer_name, $new_customer, $new_assembly); global $g_mantis_serials_format; if ($new_assembly == 'true') { $query = "INSERT\n\t\t\t\t\tINTO {$g_mantis_serials_format}\n\t\t\t\t\t( format_id, assembly_id, format, format_example )\n\t\t\t\t\tVALUES\n\t\t\t\t\t( null, '{$p_assembly_id}', '{$p_format}', '{$p_format_example}' )"; return db_query_bound($query); } else { $query = "UPDATE {$g_mantis_serials_format}\n\t\t\t\t\tSET format='{$p_format}', format_example='{$p_format_example}'\n\t\t\t\t\tWHERE assembly_id='{$p_assembly_id}'"; return db_query_bound($query); } }
/** * Created by PhpStorm. * User: wb-liuyuguang * Date: 14-7-31 * Time: 下午1:30 */ function get_project_package_list($p_package_id) { $t_acra_prj_table = plugin_table("project"); $query = "SELECT * FROM {$t_acra_prj_table} WHERE `project_id` = {$p_package_id} LIMIT 0, 1"; $result = db_query_bound($query); $result = db_fetch_array($result); if ($result === false) { return; } $packages = $result['packages']; return handle_project_package_list($packages); }
function profile_exists($p_platform, $p_os, $p_os_build) { $t_user_profile_table = db_get_table('mantis_user_profile_table'); $query_where = 'platform = ' . db_param() . ' and os = ' . db_param() . ' and os_build = ' . db_param(); $query = "SELECT *\n\t\t\t\t FROM {$t_user_profile_table}\n\t\t\t\t WHERE {$query_where}\n\t\t\t\t ORDER BY platform, os, os_build LIMIT 0,1"; $result = db_query_bound($query, array($p_platform, $p_os, $p_os_build)); $result = db_fetch_array($result); if ($result === false) { return false; } return $result['id']; }
function bug_get_attachments($p_bug_id) { $c_bug_id = db_prepare_int($p_bug_id); $t_bug_file_table = db_get_table('mantis_bug_file_table'); $query = "SELECT id, title, diskfile, filename, filesize, file_type, date_added, user_id\n FROM {$t_bug_file_table}\n WHERE bug_id=" . db_param() . "\n ORDER BY date_added"; $db_result = db_query_bound($query, array($c_bug_id)); $num_files = db_num_rows($db_result); $t_result = array(); for ($i = 0; $i < $num_files; $i++) { $t_result[] = db_fetch_array($db_result); } return $t_result; }
function getAcraIssueList() { $t_acra_issue_table = plugin_table("issue"); $query = "SELECT * FROM {$t_acra_issue_table} WHERE `custom_data` REGEXP 'url' ORDER BY `id` DESC"; $result = db_query_bound($query); $list = array(); while (true) { $row = db_fetch_array($result); if ($row === false) { break; } $list[] = $row; } return $list; }
function getAcraIssueList($page_num, $total_count) { global $acra_id; $acra_id = $_GET['acra_hash']; $t_acra_issue_table = plugin_table("issue"); $where = getFilterQueryString(); $query = "SELECT * FROM {$t_acra_issue_table} WHERE `report_fingerprint`='" . $acra_id . "'" . $where . buildOrderString() . buildPageQueryString($page_num, $total_count); $result = db_query_bound($query); $list = array(); while (true) { $row = db_fetch_array($result); if ($row === false) { break; } $list[] = $row; } return $list; }
public function create() { $t_issue_ext_table = plugin_table("issue"); # Insert the rest of the data $query = "INSERT INTO {$t_issue_ext_table}\n\t\t\t\t\t ( project_id , issue_id, report_id, report_fingerprint,\n file_path, phone_model, phone_build, phone_brand,\n product_name, total_mem_size, available_mem_size, custom_data,\n initial_configuration, crash_configuration, display, user_comment,\n dumpsys_meminfo, dropbox, eventslog, radiolog,\n is_silent, device_id, installation_id, user_email,\n device_features, environment, settings_system, settings_secure,\n shared_preferences, android_version,app_version, crash_date,\n report_date, install_date\n\t\t\t\t\t )\n\t\t\t\t\t VALUES\n\t\t\t\t\t ( " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t " . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ",\n\t\t\t\t\t " . 'now()' . ',' . db_param() . ')'; $t_display_errors = config_get_global('display_errors'); $t_on_error_handler = $t_display_errors[E_USER_ERROR]; $t_display_errors[E_USER_ERROR] = "none"; config_set_global('display_errors', $t_display_errors); $t_result = db_query_bound($query, array($this->project_id, $this->issue_id, $this->report_id, $this->report_fingerprint, $this->file_path, $this->phone_model, $this->phone_build, $this->phone_brand, $this->product_name, $this->total_mem_size, $this->available_mem_size, $this->custom_data, $this->initial_configuration, $this->crash_configuration, $this->display, $this->user_comment, $this->dumpsys_meminfo, $this->dropbox, $this->eventslog, $this->radiolog, $this->is_silent, $this->device_id, $this->installation_id, $this->user_email, $this->device_features, $this->environment, $this->settings_system, $this->settings_secure, $this->shared_preferences, $this->android_version, $this->app_version, $this->crash_date . $this->report_date, $this->install_date)); $t_display_errors[E_USER_ERROR] = $t_on_error_handler; config_set_global('display_errors', $t_display_errors); if ($t_result === false) { return false; } $this->id = db_insert_id($t_issue_ext_table); return true; }
/** * updates DB with new value * @param int $backlog * @throw exception on failure */ public function setBacklog($backlog) { $old_backlog = NULL; $query = "SELECT value FROM codev_config_table WHERE config_id = " . db_param(); $result = db_query_bound($query, array(IssueMantisPluginHelper::id_customField_backlog)); $row = db_fetch_array($result); if ($row) { $backlogCustomField = $row['value']; } else { $backlogCustomField = 0; } // TODO should be done only once... $query = "SELECT name FROM mantis_custom_field_table WHERE id = " . db_param(); $result = db_query_bound($query, array($backlogCustomField)); $row = db_fetch_array($result); if ($row) { $field_name = $row['name']; } else { $field_name = "Backlog (BL)"; } // check if backlog already defined for this issue $query = "SELECT value FROM `mantis_custom_field_string_table` WHERE bug_id=" . db_param() . " AND field_id = " . db_param(); $result = db_query_bound($query, array($this->id, $backlogCustomField)); $row = db_fetch_array($result); if ($row) { $old_backlog = $row['value']; $query2 = "UPDATE mantis_custom_field_string_table SET value = " . db_param() . " WHERE bug_id=" . db_param() . " AND field_id = " . db_param(); $result2 = db_query_bound($query2, array($backlog, $this->id, $backlogCustomField)); } else { $old_backlog = ''; $query2 = "INSERT INTO mantis_custom_field_string_table (`field_id`, `bug_id`, `value`) VALUES (" . db_param() . ", " . db_param() . ", " . db_param() . ")"; $result2 = db_query_bound($query2, array($backlogCustomField, $this->id, $backlog)); } // Add to history if ("{$old_backlog}" != "{$backlog}") { $userid = current_user_get_field('id'); $now = time(); $query = "INSERT INTO mantis_bug_history_table (`user_id`, `bug_id`, `field_name`, `old_value`, `new_value`, `type`, `date_modified`) " . "VALUES (" . db_param() . "," . db_param() . "," . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ")"; $result = db_query_bound($query, array($userid, $this->id, $field_name, $old_backlog, $backlog, 0, $now)); } // no need to update lastUpdated field }
function getList($where, $what) { if (strlen($where) > 0) { $where = "WHERE `report_fingerprint`='" . $_GET['acra_hash'] . "' AND " . $where; } else { $where = "WHERE `report_fingerprint`='" . $_GET['acra_hash'] . "'"; } $t_acra_issue_table = plugin_table("issue"); $query = "SELECT `{$what}` FROM {$t_acra_issue_table} {$where} GROUP BY `{$what}`"; $result = db_query_bound($query); $list = array(); while (true) { $row = db_fetch_array($result); if ($row === false) { break; } $list[] = $row[$what]; } return $list; }
/** * Retrieves the data based on current filter * @param int $p_page page to display; defaults to 1, use null for all pages * @param int $p_limit number of records per page, defaults to 25 * @return array containing list of changesets and number of records */ function find($p_page = 1, $p_limit = 25) { list($t_filters, $t_filter_params) = Source_Twomap('Source_Process_FilterOption', $this->filters); list($t_query_tail, $t_order, $t_params) = Source_Process_Filters($t_filters, $t_filter_params); $t_count_query = "SELECT COUNT(c.id) {$t_query_tail}"; $t_full_query = "SELECT DISTINCT( c.id ), c.* {$t_query_tail} {$t_order}"; $t_count = db_result(db_query_bound($t_count_query, $t_params)); if (is_null($p_page)) { $t_result = db_query_bound($t_full_query, $t_params); } else { $t_result = db_query_bound($t_full_query, $t_params, $p_limit, ($p_page - 1) * $p_limit); } $t_changesets = array(); while ($t_row = db_fetch_array($t_result)) { $t_changeset = new SourceChangeset($t_row['repo_id'], $t_row['revision'], $t_row['branch'], $t_row['timestamp'], $t_row['author'], $t_row['message'], $t_row['user_id']); $t_changeset->id = $t_row['id']; $t_changesets[] = $t_changeset; } return array($t_changesets, $t_count); }
public function cache($p_bugs) { if (count($p_bugs) < 1) { return; } $t_bug_table = plugin_table('bug', 'Source'); $t_bug_ids = array(); foreach ($p_bugs as $t_bug) { $t_bug_ids[] = $t_bug->id; } $t_bug_ids = implode(',', $t_bug_ids); $t_query = "SELECT * FROM {$t_bug_table} WHERE bug_id IN ( {$t_bug_ids} )"; $t_result = db_query_bound($t_query); while ($t_row = db_fetch_array($t_result)) { if (isset($this->changeset_cache[$t_row['bug_id']])) { $this->changeset_cache[$t_row['bug_id']]++; } else { $this->changeset_cache[$t_row['bug_id']] = 1; } } }
function print_users_in_group_option_list($usergroup_id) { if (plugin_config_get('assign_to_groups', '') == 1 && plugin_config_get('assign_group_threshold', '') <= user_get_access_level(auth_get_current_user_id())) { $show_groups = 1; } else { $show_groups = 0; } $t_table_users = plugin_table('users'); $t_user_table = db_get_table('mantis_user_table'); $query = "SELECT * FROM ("; $query .= " SELECT u.id, u.username, u.realname, ug.group_user_id"; $query .= " FROM {$t_user_table} AS u"; $query .= " LEFT JOIN {$t_table_users} AS ug ON (u.id=ug.user)"; //if( plugin_config_get('assign_to_groups', '') == 0 || plugin_config_get('assign_group_threshold','') > user_get_access_level( auth_get_current_user_id() ) ) if ($show_groups == 0) { $query .= " WHERE u.username NOT LIKE " . db_param(); } $query .= ") AS t1 WHERE group_user_id=" . db_param() . " OR group_user_id IS NULL ORDER BY username ASC"; if ($show_groups == 0) { $result = db_query_bound($query, array(plugin_config_get('group_prefix') . '%', (int) $usergroup_id)); } else { $result = db_query_bound($query, array((int) $usergroup_id)); } $count = db_num_rows($result); for ($i = 0; $i < $count; $i++) { $row = db_fetch_array($result); if ($row['id'] == $usergroup_id) { continue; //usergroup must not be nested with itself } echo '<option value="' . $row['id'] . '" '; if (!is_null($row['group_user_id'])) { echo 'selected="selected"'; } else { echo ''; } echo '>' . $row['username'] . '</option>'; } }
function getBugsInfoJSONPResponse($bugsString) { $t_bug_table = db_get_table('mantis_bug_table'); $t_statuses = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string')); $statuses = ''; foreach ($t_statuses as $t_state => $t_label) { $statuses .= '"' . $t_label . '": "' . get_status_color($t_state) . '", '; } $bugs_list = array_unique(str_split($bugsString, 7)); $bugs_list = "'" . implode("', '", $bugs_list) . "'"; $query = "SELECT id, status, summary\r\n\t\t\t FROM `" . $t_bug_table . "`\r\n\t\t\t WHERE id IN (" . $bugs_list . ")\r\n\t\t\t ORDER BY FIELD(id, " . $bugs_list . ")"; $results = db_query_bound($query); if ($results) { $json = ''; while ($row = db_fetch_array($results)) { $id = $row['id']; $statusId = $row['status']; $summary = $row['summary']; $json .= '"' . $id . '": { "status": "' . $t_statuses[$statusId] . '", "summary": "' . htmlspecialchars($summary) . '" }, '; } } header("Content-Type: application/javascript; charset=utf-8"); echo 'bugtrackerConnection_callback( { "offset": "' . $_REQUEST['offset'] . '", "length": "' . $_REQUEST['length'] . '", "statuses": { ' . substr($statuses, 0, -2) . ' }, "bugsInfo" : { ' . substr($json, 0, -2) . ' } } );'; }
* @uses print_api.php */ /** @ignore */ define('PLUGINS_DISABLED', true); require_once 'core.php'; require_api('access_api.php'); require_api('authentication_api.php'); require_api('config_api.php'); require_api('database_api.php'); require_api('form_api.php'); require_api('gpc_api.php'); require_api('print_api.php'); form_security_validate('manage_plugin_update'); auth_reauthenticate(); access_ensure_global_level(config_get('manage_plugin_threshold')); $t_plugin_table = db_get_table('plugin'); $t_query = "SELECT basename FROM {$t_plugin_table}"; $t_result = db_query_bound($t_query); while ($t_row = db_fetch_array($t_result)) { $t_basename = $t_row['basename']; $f_change = gpc_get_bool('change_' . $t_basename, 0); if (!$f_change) { continue; } $f_priority = gpc_get_int('priority_' . $t_basename, 3); $f_protected = gpc_get_bool('protected_' . $t_basename, 0); $t_query = "UPDATE {$t_plugin_table} SET priority=" . db_param() . ', protected=' . db_param() . ' WHERE basename=' . db_param(); db_query_bound($t_query, array($f_priority, $f_protected, $t_basename)); } form_security_purge('manage_plugin_update'); print_successful_redirect('manage_plugin_page.php');
form_security_validate( 'manage_user_prune' ); auth_reauthenticate(); access_ensure_global_level( config_get( 'manage_user_threshold' ) ); $t_user_table = db_get_table( 'user' ); # Delete the users who have never logged in and are older than 1 week $days_old = (int)7 * SECONDS_PER_DAY; $query = "SELECT id, access_level FROM $t_user_table WHERE ( login_count = 0 ) AND ( date_created = last_visit ) AND " . db_helper_compare_days( 0, "date_created", "> $days_old" ); $result = db_query_bound($query, Array( db_now() ) ); if ( !$result ) { trigger_error( ERROR_GENERIC, ERROR ); } $count = db_num_rows( $result ); if ( $count > 0 ) { helper_ensure_confirmed( lang_get( 'confirm_account_pruning' ), lang_get( 'prune_accounts_button' ) ); } for ($i=0; $i < $count; $i++) { $row = db_fetch_array( $result ); # Don't prune accounts with a higher global access level than the current user
function cfdef_prepare_list_distinct_values($p_field_def) { $t_custom_field_table = db_get_table('custom_field'); $query = "SELECT possible_values\n\t\t\t FROM {$t_custom_field_table}\n\t\t\t WHERE id=" . db_param(); $result = db_query_bound($query, array($p_field_def['id'])); $t_row_count = db_num_rows($result); if (0 == $t_row_count) { return false; } $row = db_fetch_array($result); $t_possible_values = custom_field_prepare_possible_values($row['possible_values']); $t_values_arr = explode('|', $t_possible_values); $t_return_arr = array(); foreach ($t_values_arr as $t_option) { array_push($t_return_arr, $t_option); } return $t_return_arr; }
/** * Prints the preview of a text file attachment. * @param array $p_attachment An attachment arrray from within the array returned by the file_get_visible_attachments() function */ function print_bug_attachment_preview_text($p_attachment) { if (!$p_attachment['exists']) { return; } echo "\n<pre class=\"bug-attachment-preview-text\">"; switch (config_get('file_upload_method')) { case DISK: if (file_exists($p_attachment['diskfile'])) { $t_content = file_get_contents($p_attachment['diskfile']); } break; case FTP: if (file_exists($p_attachment['diskfile'])) { $t_content = file_get_contents($p_attachment['diskfile']); } else { $t_ftp = file_ftp_connect(); file_ftp_get($t_ftp, $p_attachment['diskfile'], $p_attachment['diskfile']); file_ftp_disconnect($t_ftp); if (file_exists($p_attachment['diskfile'])) { $t_content = file_get_contents($p_attachment['diskfile']); } } break; default: $t_bug_file_table = db_get_table('bug_file'); $c_attachment_id = db_prepare_int($p_attachment['id']); $t_query = "SELECT * FROM {$t_bug_file_table} WHERE id=" . db_param(); $t_result = db_query_bound($t_query, array($c_attachment_id)); $t_row = db_fetch_array($t_result); $t_content = $t_row['content']; } echo htmlspecialchars($t_content); echo '</pre>'; }
/** * Retrieve a list of changes to a bug of the same type as the * given revision ID. * @param int $p_rev_id Revision ID * @return array|null Array of Revision rows */ function bug_revision_like( $p_rev_id ) { $t_bug_rev_table = db_get_table( 'bug_revision' ); $t_query = "SELECT bug_id, bugnote_id, type FROM $t_bug_rev_table WHERE id=" . db_param(); $t_result = db_query_bound( $t_query, array( $p_rev_id ) ); if ( db_num_rows( $t_result ) < 1 ) { trigger_error( ERROR_BUG_REVISION_NOT_FOUND, ERROR ); } $t_row = db_fetch_array( $t_result ); $t_bug_id = $t_row['bug_id']; $t_bugnote_id = $t_row['bugnote_id']; $t_type = $t_row['type']; $t_params = array( $t_bug_id ); $t_query = "SELECT * FROM $t_bug_rev_table WHERE bug_id=" . db_param(); if ( REV_ANY < $t_type ) { $t_query .= ' AND type=' . db_param(); $t_params[] = $t_type; } if ( $t_bugnote_id > 0 ) { $t_query .= ' AND bugnote_id=' . db_param(); $t_params[] = $t_bugnote_id; } else { $t_query .= ' AND bugnote_id=0'; } $t_query .= ' ORDER BY timestamp ASC'; $t_result = db_query_bound( $t_query, $t_params ); $t_revisions = array(); while( $t_row = db_fetch_array( $t_result ) ) { $t_revisions[$t_row['id']] = $t_row; } return $t_revisions; }
/** * retrieves and returns access matrix for a user from cache or caching if required. * @param int $p_user_id integer representing user id * @return array returns an array of projects->accesslevel for the given user * @access private */ function access_cache_matrix_user($p_user_id) { global $g_cache_access_matrix, $g_cache_access_matrix_user_ids; if (!in_array((int) $p_user_id, $g_cache_access_matrix_user_ids)) { $t_project_user_list_table = db_get_table('project_user_list'); $t_query = "SELECT project_id, access_level\n\t\t\t\t\t FROM {$t_project_user_list_table}\n\t\t\t\t\t WHERE user_id=" . db_param(); $t_result = db_query_bound($t_query, array((int) $p_user_id)); # make sure we always have an array to return $g_cache_access_matrix[(int) $p_user_id] = array(); while ($t_row = db_fetch_array($t_result)) { $g_cache_access_matrix[(int) $p_user_id][(int) $t_row['project_id']] = (int) $t_row['access_level']; } $g_cache_access_matrix_user_ids[] = (int) $p_user_id; } return $g_cache_access_matrix[(int) $p_user_id]; }
/** * return the last inserted id for a specific database table * @param string $p_table a valid database table name * @return int last successful insert id */ function db_insert_id($p_table = null, $p_field = "id") { global $g_db; if (isset($p_table) && db_is_pgsql()) { $query = "SELECT currval('" . $p_table . "_" . $p_field . "_seq')"; $result = db_query_bound($query); return db_result($result); } if (db_is_mssql()) { $query = "SELECT IDENT_CURRENT('{$p_table}')"; $result = db_query_bound($query); return db_result($result); } return $g_db->Insert_ID(); }
function print_bug_attachments_list($p_bug_id) { $t_attachments = file_get_visible_attachments($p_bug_id); $t_attachments_count = count($t_attachments); $i = 0; $image_previewed = false; foreach ($t_attachments as $t_attachment) { $t_file_display_name = string_display_line($t_attachment['display_name']); $t_filesize = number_format($t_attachment['size']); $t_date_added = date(config_get('normal_date_format'), $t_attachment['date_added']); if ($image_previewed) { $image_previewed = false; echo '<br />'; } if ($t_attachment['can_download']) { $t_href_start = '<a href="' . string_attribute($t_attachment['download_url']) . '">'; $t_href_end = '</a>'; $t_href_clicket = " [<a href=\"file_download.php?file_id={$t_attachment['id']}&type=bug\" target=\"_blank\">^</a>]"; } else { $t_href_start = ''; $t_href_end = ''; $t_href_clicket = ''; } if (!$t_attachment['exists']) { print_file_icon($t_file_display_name); echo ' <span class="strike">' . $t_file_display_name . '</span>' . lang_get('word_separator') . '(' . lang_get('attachment_missing') . ')'; } else { echo $t_href_start; print_file_icon($t_file_display_name); echo $t_href_end . ' ' . $t_href_start . $t_file_display_name . $t_href_end . $t_href_clicket . ' (' . $t_filesize . ' ' . lang_get('bytes') . ') ' . '<span class="italic">' . $t_date_added . '</span>'; } if ($t_attachment['can_delete']) { echo ' ['; print_link('bug_file_delete.php?file_id=' . $t_attachment['id'] . form_security_param('bug_file_delete'), lang_get('delete_link'), false, 'small'); echo ']'; } if ($t_attachment['exists']) { if (FTP == config_get('file_upload_method') && $t_attachment['exists']) { echo ' (' . lang_get('cached') . ')'; } if ($t_attachment['preview'] && $t_attachment['type'] == 'text') { $c_id = db_prepare_int($t_attachment['id']); $t_bug_file_table = db_get_table('mantis_bug_file_table'); echo "<script type=\"text/javascript\" language=\"JavaScript\">\n<!--\nfunction swap_content( span ) {\ndisplayType = ( document.getElementById( span ).style.display == 'none' ) ? '' : 'none';\ndocument.getElementById( span ).style.display = displayType;\n}\n\n -->\n </script>"; echo " <span id=\"hideSection_{$c_id}\">[<a class=\"small\" href='#' id='attmlink_" . $c_id . "' onclick='swap_content(\"hideSection_" . $c_id . "\");swap_content(\"showSection_" . $c_id . "\");return false;'>" . lang_get('show_content') . "</a>]</span>"; echo " <span style='display:none' id=\"showSection_{$c_id}\">[<a class=\"small\" href='#' id='attmlink_" . $c_id . "' onclick='swap_content(\"hideSection_" . $c_id . "\");swap_content(\"showSection_" . $c_id . "\");return false;'>" . lang_get('hide_content') . "</a>]"; echo "<pre>"; /** @todo Refactor into a method that gets contents for download / preview. */ switch (config_get('file_upload_method')) { case DISK: if ($t_attachment['exists']) { $v_content = file_get_contents($t_attachment['diskfile']); } break; case FTP: if (file_exists($t_attachment['exists'])) { file_get_contents($t_attachment['diskfile']); } else { $ftp = file_ftp_connect(); file_ftp_get($ftp, $t_attachment['diskfile'], $t_attachment['diskfile']); file_ftp_disconnect($ftp); $v_content = file_get_contents($t_attachment['diskfile']); } break; default: $query = "SELECT *\n\t \t\t\t\t\tFROM {$t_bug_file_table}\n\t\t\t\t \t\t\tWHERE id=" . db_param(); $result = db_query_bound($query, array($c_id)); $row = db_fetch_array($result); $v_content = $row['content']; } echo htmlspecialchars($v_content); echo "</pre></span>\n"; } if ($t_attachment['can_download'] && $t_attachment['preview'] && $t_attachment['type'] == 'image') { $t_preview_style = 'border: 0;'; $t_max_width = config_get('preview_max_width'); if ($t_max_width > 0) { $t_preview_style .= ' max-width:' . $t_max_width . 'px;'; } $t_max_height = config_get('preview_max_height'); if ($t_max_height > 0) { $t_preview_style .= ' max-height:' . $t_max_height . 'px;'; } $t_preview_style = 'style="' . $t_preview_style . '"'; $t_title = file_get_field($t_attachment['id'], 'title'); $t_image_url = $t_attachment['download_url'] . '&show_inline=1' . form_security_param('file_show_inline'); echo "\n<br />{$t_href_start}<img alt=\"{$t_title}\" {$t_preview_style} src=\"{$t_image_url}\" />{$t_href_end}"; $image_previewed = true; } } if ($i != $t_attachments_count - 1) { echo "<br />\n"; $i++; } } }
/** * delete all preferences for a project for all users (part of deleting the project) * returns true if the prefs were successfully deleted * * It is far more efficient to delete them all in one query than to * call user_pref_delete() for each one and the code is short so that's * what we do * @param $p_project_id * @return true */ function user_pref_delete_project( $p_project_id ) { $c_project_id = db_prepare_int( $p_project_id ); $t_user_pref_table = db_get_table( 'user_pref' ); $query = 'DELETE FROM ' . $t_user_pref_table . ' WHERE project_id=' . db_param(); db_query_bound( $query, Array( $c_project_id ) ); # db_query errors on failure so: return true; }
require_api('html_api.php'); require_api('lang_api.php'); require_api('print_api.php'); require_api('string_api.php'); require_api('utility_api.php'); # Check if project documentation feature is enabled. if (OFF == config_get('enable_project_documentation') || !file_is_uploading_enabled() || !file_allow_project_upload()) { access_denied(); } $f_file_id = gpc_get_int('file_id'); $c_file_id = db_prepare_int($f_file_id); $t_project_id = file_get_field($f_file_id, 'project_id', 'project'); access_ensure_project_level(config_get('upload_project_file_threshold'), $t_project_id); $t_proj_file_table = db_get_table('project_file'); $query = "SELECT *\n\t\tFROM {$t_proj_file_table}\n\t\tWHERE id=" . db_param(); $result = db_query_bound($query, array($c_file_id)); $row = db_fetch_array($result); extract($row, EXTR_PREFIX_ALL, 'v'); $v_title = string_attribute($v_title); $v_description = string_textarea($v_description); $t_max_file_size = (int) min(ini_get_number('upload_max_filesize'), ini_get_number('post_max_size'), config_get('max_file_size')); html_page_top(); ?> <br /> <div> <form method="post" enctype="multipart/form-data" action="proj_doc_update.php"> <?php echo form_security_field('proj_doc_update'); ?> <table class="width75" cellspacing="1">