$sqlSort .= "prio DESC, ddn ASC, duedate ASC, ow ASC"; } elseif ($listData['sorting'] == 2) { $sqlSort .= "ddn ASC, duedate ASC, prio DESC, ow ASC"; } else { $sqlSort .= "ow ASC"; } $data = array(); $q = $db->dq("SELECT *, duedate IS NULL AS ddn FROM {mytinytodo_todos} WHERE list_id = ? {$sqlSort}", array($listId)); while ($r = $q->fetch_assoc($q)) { $data[] = $r; } $format = _get('format'); if ($format == 'ical') { printICal($listData, $data); } else { printCSV($listData, $data); } function printCSV($listData, $data) { $s = "Completed,Priority,Task,Contact,Date,Type,Notes,Tags,Due,DateCreated,DateCompleted\n"; foreach ($data as $r) { $types = str_replace('{', '', $r['c_types']); $types = str_replace('"', '', $types); $types = str_replace(',', ' ', $types); $s .= ($r['compl'] ? '1' : '0') . ',' . $r['prio'] . ',' . escape_csv($r['title']) . ',' . escape_csv($r['c_contact']) . ',' . $r['c_date'] . ',' . $types . ',' . escape_csv($r['note']) . ',' . escape_csv($r['tags']) . ',' . $r['duedate'] . ',' . date('Y-m-d H:i:s O', $r['d_created']) . ',' . ($r['d_completed'] ? date('Y-m-d H:i:s O', $r['d_completed']) : '') . "\n"; } header('Content-type: text/csv; charset=utf-8'); header('Content-disposition: attachment; filename=list_' . $listData['id'] . '.csv'); print $s; } function escape_csv($v)
{ global $csv; global $max; for ($i = 0; $i < $max; $i++) { echo "User " . ($i + 1) . ": " . $csv[$i][0] . "<br/>"; } } $correct = false; if (!$userid || !$passw) { echo "Please enter both User ID and password."; } elseif ($userid == "admin") { for ($i = 0; $i < $max; $i++) { if ($csv[$i][0] == "admin" && $csv[$i][1] == $passw) { echo "Welcome admin! Here are the users of your system:<br/><br/>"; //print_r($csv); printCSV(); $correct = true; break; } } if ($correct == false) { echo "Incorrect admin password. Access denied."; } } else { $found = false; for ($i = 0; $i < $max; $i++) { if ($csv[$i][0] == $userid) { if ($csv[$i][1] == $passw) { echo "Welcome " . $userid; } else { echo "Incorrect password for user: "******". Please go back and try again";