-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmincsv.php
More file actions
executable file
·117 lines (93 loc) · 3.32 KB
/
Copy pathadmincsv.php
File metadata and controls
executable file
·117 lines (93 loc) · 3.32 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
if ($_POST)
{
$conn = mysqli_connect("localhost","root","","researchdb");
$myFile = "research.xml";
$fh = fopen($myFile, 'w') or die("can't open file");
$rss_txt="";
$rss_txt .= '<?xml version="1.0" encoding="utf-8"?>';
$rss_txt .= '<research>';
$query = "SELECT s.id, g.grade,s.guid,s.datevisited FROM `session` as s join grade as g on s.`gradeid` = g.id;";
$result =$conn->query($query);
while($values_query = $result->fetch_assoc())
{
$rss_txt .='<session>';
$rss_txt .= '<sessionid>' .$values_query['guid']. '</sessionid>';
$rss_txt .= '<timestamp>' .$values_query['datevisited']. '</timestamp>';
$rss_txt .= '<grade>';
$rss_txt .= '<name>' .$values_query['grade']. '</name>';
$rss_txt .= '<queryterms>';
$sessionid =$values_query['id'];
$query2 = "select * from `sessionsearch` where `sessionid`='$sessionid'";
$result2=$conn->query($query2);
while($values_query2 = $result2->fetch_assoc())
{
$rss_txt .= "<query>";
$rss_txt .= '<searchterm>' .$values_query2['userquery']. '</searchterm>';
$rss_txt .= '<trigger>' .$values_query2['trigger']. '</trigger>';
$rss_txt .= '<usedsuggestion>' .$values_query2['issuggestion']. '</usedsuggestion>';
$rss_txt .= '<timestamp>' .$values_query2['timesearched']. '</timestamp>';
$rss_txt .="<clickedlinks>";
$searchid = $values_query2['id'];
$query3 = "select * from `searchlinks` where `searchid` = '$searchid'";
$result3 =$conn->query($query3);
while($values_query3 = $result3->fetch_assoc())
{
$rss_txt .="<clickedlink>";
$rss_txt .="<url>".$values_query3['linkclicked']."</url>";
$rss_txt .="<timestamp>".$values_query3['timeclicked']."</timestamp>";
$rss_txt .="</clickedlink>";
}
$rss_txt .= "</clickedlinks>";
$rss_txt .= "</query>";
}
$rss_txt .= '</queryterms>';
$rss_txt .= '</grade>';
$rss_txt .='</session>';
}
$rss_txt .= '</research>';
fwrite($fh, $rss_txt);
fclose($fh);
// header('Content-Type: application/xml');
// tell the browser we want to save it instead of displaying it
// header('Content-Disposition: attachment; filename="'.$myFile.'";');
// make php send the generated csv lines to the browser
$g = true;
}
?>
<html>
<header>
<style type="text/css">
body
{
//background: #F2F2F2;
//background-image: url("img4.jpg");
}
.title
{
font-size : 18px;
}
.news
{
margin-left : 10px;
}
</style>
</header>
<body>
<form action="" method="POST">
<center>
<label>Click to generate XML file from database</label>
<input hidden="hidden" name="do" value="1"/>
<input type="submit" value="GENERATE">
<br/>
<br/>
<?PHP
if (isset($g))
echo "<a target='_blank' href='$myFile'>Click me to view / download generated file</a>";
?>
</center>
<br/>
<br/>
</form>
</body>
</html>