} if ($i_order_no >= 0) { $i_direction = isset($_GET['direction']) && $_GET['direction'] ? 'DESC' : ''; $i_order_addon = '&order=' . $i_order_no . '&direction=' . $i_direction; $i_sql_order_addon = ' ORDER BY ' . $i_tablefields[$i_order_no][2] . ' ' . $i_direction; } $i_column_names = array(); foreach ($i_columns as $val) { array_push($i_column_names, csvQuote($lngstr['page_reportsmanager']['fields']['name'][$val])); } $i_filecontent .= implode($i_delimiter, $i_column_names) . "\n"; $i_rSet1 = $g_db->Execute("SELECT " . $srv_settings['table_prefix'] . "results.resultid, " . $srv_settings['table_prefix'] . "results.result_datestart, " . $srv_settings['table_prefix'] . "results.id, " . $srv_settings['table_prefix'] . "users.username, " . $srv_settings['table_prefix'] . "users.user_firstname, " . $srv_settings['table_prefix'] . "users.user_lastname, " . $srv_settings['table_prefix'] . "results.testid, " . $srv_settings['table_prefix'] . "tests.test_name, " . $srv_settings['table_prefix'] . "tests.test_attempts, " . $srv_settings['table_prefix'] . "tests.test_result_showpdf, " . $srv_settings['table_prefix'] . "tests.rtemplateid, " . $srv_settings['table_prefix'] . "tests.test_reportgradecondition, " . $srv_settings['table_prefix'] . "tests.test_nexttestid, " . $srv_settings['table_prefix'] . "results.gscale_gradeid, " . $srv_settings['table_prefix'] . "results.result_timeexceeded, " . $srv_settings['table_prefix'] . "results.result_points, " . $srv_settings['table_prefix'] . "results.result_pointsmax, ((" . $srv_settings['table_prefix'] . "results.result_points * 100) / " . $srv_settings['table_prefix'] . "results.result_pointsmax) as result_score, " . $srv_settings['table_prefix'] . "results.gscaleid, " . $srv_settings['table_prefix'] . "gscales_grades.grade_name, " . $srv_settings['table_prefix'] . "gscales_grades.grade_description FROM " . $srv_settings['table_prefix'] . "results, " . $srv_settings['table_prefix'] . "users, " . $srv_settings['table_prefix'] . "tests, " . $srv_settings['table_prefix'] . "gscales_grades WHERE " . $i_sql_where_addon . "" . $srv_settings['table_prefix'] . "results.id=" . $srv_settings['table_prefix'] . "users.id AND " . $srv_settings['table_prefix'] . "results.testid=" . $srv_settings['table_prefix'] . "tests.testid AND " . $srv_settings['table_prefix'] . "results.gscaleid=" . $srv_settings['table_prefix'] . "gscales_grades.gscaleid AND " . $srv_settings['table_prefix'] . "results.gscale_gradeid=" . $srv_settings['table_prefix'] . "gscales_grades.gscale_gradeid" . $i_sql_order_addon); if (!$i_rSet1) { showDBError(__FILE__, 1); } else { while (!$i_rSet1->EOF) { $i_rSet1->fields['result_datestart_formatted'] = getDateLocal($lngstr['language']['date_format'], $i_rSet1->fields['result_datestart']); foreach ($i_columns as $i_column) { $i_filecontent .= csvQuote($i_rSet1->fields[$i_column]) . $i_delimiter; } $i_filecontent = substr($i_filecontent, 0, strlen($i_filecontent) - 1) . "\n"; $i_rSet1->MoveNext(); } $i_rSet1->Close(); } header('Pragma: private'); header('Cache-control: private, must-revalidate'); header('Content-Length: ' . strlen($i_filecontent)); header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename="' . $i_filename . '"'); echo $i_filecontent;
header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Description: File Transfer"); header("Content-Disposition: inline; filename=\"" . date("Y m d") . " Data.csv\";"); header("Content-Transfer-Encoding: binary"); header("Content-Type: application/csv"); $shirts = ""; $selectedShirts = json_decode($result['shirts']); for ($i = 0; $i < count($selectedShirts); $i++) { if ($i != 0) { $shirts .= ", "; } $shirts .= $allShirts[$selectedShirts[$i]]; } echo $result['id'] . "," . csvQuote($result['name']) . "," . csvQuote($result['position']) . "," . csvQuote($result['phone']) . "," . csvQuote($result['email']) . "," . csvQuote($result['preferredMethod']); } } if ($_MGM['path'][2] == "upload") { $uploadPath = "/tmp/itmembersupload.csv"; $input = fopen("php://input", "r"); if (file_exists($uploadPath)) { unlink($uploadPath); } $output = fopen($uploadPath, "w"); while ($data = fread($input, 1024)) { fwrite($output, $data); } fclose($output); fclose($input); $handle = fopen($uploadPath, "r");