| <?php |
| require_once "/home/data/httpd/eclipse-php-classes/system/dbconnection_bugs_ro.class.php"; |
| |
| function count_loc( $data ) { |
| $count = substr_count( $data, "\n" ); |
| return $count; |
| } |
| |
| $dbc = new DBConnectionBugs(); |
| $dbh = $dbc->connect(); |
| |
| $sql_info = "SELECT bugs.bug_id as bug_id, |
| bugs.bug_status as bug_status, |
| bugs.resolution as bug_resolution, |
| bugs.target_milestone as bug_target_milestone, |
| attachments.filename as filename, |
| attachments.thedata as thedata, |
| profiles.login_name as attachment_login_name |
| FROM bugs, |
| attachments, |
| profiles |
| WHERE attachments.bug_id = bugs.bug_id |
| AND attachments.isobsolete = 0 |
| AND (bugs.bug_status = 'RESOLVED' |
| OR bugs.bug_status = 'CLOSED' |
| OR bugs.bug_status = 'VERIFIED') |
| AND bugs.resolution = 'FIXED' |
| AND attachments.submitter_id = profiles.userid |
| ORDER BY bugs.bug_id"; |
| |
| $rs = mysql_query($sql_info, $dbh); |
| |
| $output_file = "bjornquery.csv"; |
| |
| @ini_set('zlib.output_compression', 'Off'); |
| header('Pragma: public'); |
| header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT'); |
| header('Cache-Control: no-store, no-cache, must-revalidate'); |
| header('Cache-Control: pre-check=0, post-check=0, max-age=0'); |
| header('Content-Transfer-Encoding: none'); |
| // This should work for IE & Opera |
| header('Content-Type: application/octetstream; name="' . $output_file . '"'); |
| // This should work for the rest |
| header('Content-Type: application/octet-stream; name="' . $output_file . '"'); |
| header('Content-Disposition: inline; filename="' . $output_file . '"'); |
| |
| while( $myrow = mysql_fetch_assoc($rs) ) { |
| |
| echo $myrow['bug_id']; |
| echo ","; |
| echo $myrow['bug_status']; |
| echo ","; |
| echo $myrow['bug_resolution']; |
| echo ","; |
| echo $myrow['bug_target_milestone']; |
| echo ","; |
| echo $myrow['filename']; |
| echo ","; |
| echo $myrow['attachment_login_name']; |
| echo ","; |
| $count3 = count_loc($myrow['thedata']); |
| echo $count3; |
| echo "\n"; |
| } |
| |
| $dbc->disconnect(); |
| |
| $rs = null; |
| $dbh = null; |
| $dbc = null; |
| |
| exit(); |
| ?> |