-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
executable file
·130 lines (116 loc) · 3.58 KB
/
index.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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
// Set up lots of localization to handle Unicode
header('Content-type: text/html; charset=UTF-8');
$locale = 'en_US.UTF-8';
setlocale(LC_ALL, $locale);
putenv('LC_ALL='.$locale);
?>
<html>
<head>
<title>KSSE: KEXP Song Search Engine</title>
<meta property="og:site_name" content="KSSE: KEXP Song Search Engine"/>
<meta property="og:title" content="KSSE: KEXP Song Search Engine">
<meta property="og:image" content="sitepreview.png">
<meta property="og:description" content="Discover new music by seeing what else KEXP plays near when they play your favorite songs and artists.">
<link rel="icon" href="http://5tephen.com/img/cheeseplane.gif" type="image/gif"/>
<link rel="me" href="https://twitter.com/geluso" />
<link rel="me" href="https://github.com/geluso" />
<link rel="me" href="https://facebook.com/5TEPHENoCOM" />
<!-- Bootstrap -->
<link href="http://5tephen.com/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="http://5tephen.com/css/style.css" />
<link rel="stylesheet" href="http://5tephen.com/css/bootstrap-overrides.css" />
<link rel="stylesheet" href="style.css" />
<?php
$artist = $_GET["artist"];
$song = $_GET["song"];
$neighbors = $_GET["neighbors"];
$original = $_GET["original"];
$comments = $_GET["comments"];
$command = "python proximity.py";
if ($artist) {
$run = true;
$artist = urldecode($artist);
$command .= " --artist \"$artist\"";
}
if ($song) {
$run = true;
$song = urldecode($song);
$command .= " --song \"$song\"";
}
if ($neighbors != "") {
$command .= " --neighbors 2";
} else {
// expand the default limit if neighbors is zero.
// it's less expensive when not searching for neighbors.
$command .= " --neighbors 0";
}
if ($original != "") {
$command .= " --original $original";
}
if ($comments != "") {
$command .= " --comments $comments";
}
?>
</head>
<body>
<div class="item text-center container-fluid">
<h1 class="title">
<a href="http://5tephen.com/ksse/">
KSSE: KEXP Song Search Engine
</a>
</h1>
<form action="index.php" method="GET">
<label>
Artist:
<input name="artist" value="<?=htmlspecialchars($artist)?>"></input>
</label>
<label>
Song:
<input name="song" value="<?=htmlspecialchars($song)?>"></input>
</label>
<label>
<?php
if ($neighbors) {
?>
<input name="neighbors" type="checkbox" value="True" checked></input>
<?php
} else {
?>
<input name="neighbors" type="checkbox" value="True"></input>
<?php
}
?>
neighboring songs
</label>
<label>
<?php
if ($comments) {
?>
<input name="comments" type="checkbox" value="True" checked></input>
<?php
} else {
?>
<input name="comments" type="checkbox" value="True"></input>
<?php
}
?>
DJ comments
</label>
<button type="submit">search</button>
</form>
</div>
<div class="item container-fluid">
<?php
if ($run) {
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
file_put_contents("logs/log_url.txt", "$url\n", FILE_APPEND | LOCK_EX);
file_put_contents("logs/log_python.txt", "$command\n", FILE_APPEND | LOCK_EX);
include("results.php");
} else {
include("instructions.html");
}
?>
</div>
</body>
</html>