-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport.php
60 lines (42 loc) · 1.25 KB
/
export.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require_once(dirname(__FILE__). '/inc/common.php');
if (!isset($_GET['start']) && !isset($_GET['end'] )) {
die();
}
$start = mysql_escape_string($_GET['start']);
$end = mysql_escape_string($_GET['end']);
if (!is_numeric($start) && !is_numeric($end)) {
die();
}
$conditions = array();
if (!isset($_GET['all'])) {
$conditions['verified'] = 1;
}
$conditions['start'] = $start;
if ($end) {
$conditions['end'] = $end;
}
$seeds = get_seeds($conditions);
$lastsid = 0;
if ($seeds) {
$last = $seeds[0];
$last_sid = $last->sid;
}
$sql = "UPDATE global SET value = '$last_sid' WHERE name = 'last_export_start'";
@mysql_query($sql);
// open stdout
$handle = fopen("php://output", "w");
$list = array();
$today = date('n/j/Y');
$list[] = "Date Added" . "@@@" . "Site Group" . "@@@" . "Seed URL" . "@@@" . "Frequency" . "@@@" . "Scope" . "@@@" . "Notes";
foreach ($seeds as $seed) {
$line = $today . "@@@" . $seed->category . "@@@" . $seed->url . "@@@" . $seed->frequency . "@@@" . $seed->scope . "@@@" . "seed ID: " . $seed->sid;
$list[] = $line;
}
// output headers
header("Content-type: text/csv");
header('Content-Disposition: attachment; filename="seeds_' . $today . '.csv"');
foreach ($list as $line) {
fputcsv($handle, split('@@@', $line));
}
?>