-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstaff.php
155 lines (153 loc) · 5.97 KB
/
staff.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
session_start();
require_once("libs/user.php");
require_once("libs/track.php");
require_once("libs/database.php");
require_once("libs/identica.lib.php");
switch($_GET['a']) {
case 'login':
if(!$_SESSION['online']) {
if(isset($_POST['name'])) {
$user = new User(null, null, $_POST['name']);
if($user->getValue('password') == md5($_POST['pwd'])) {
// set user online
$_SESSION['online'] = true;
$_SESSION['id'] = $user->getValue('id');
} else {
// register
//echo $user->getValue('password')." != ".md5($_POST['pwd']);
include("templates/staffheader.php");
include("templates/register.php");
}
}
}
break;
case 'register':
if(!$_SESSION['online']) {
if(strlen($_POST['name'])>2) {
if(strlen($_POST['pwd'])>2) {
if($_POST['pwd'] == $_POST['pwd2']) {
$user = new User(array(
'name' => $_POST['name'],
'password' => md5($_POST['pwd']),
'timejoined' => time(),
'lasttimeon' => 0
));
if($user->submitToDatabase()) {
echo '<div class="stripe"><p>Welcome! '.$_POST['name'].'</p></div>';
}
} else {
$alert = "Sorry, password and repeatition aren't equal.";
}
} else {
$alert = "Sorry, your password is too short.";
}
} else {
$alert = "Sorry, your name is too short.";
include("templates/staffheader.php");
include("templates/register.php");
}
}
break;
case 'logout':
$_SESSION = array();
$alert = "logged out";
}
// continue if user is online
if($_SESSION['online']) {
$user = new User(null, $_SESSION['id']);
$user->seen();
switch($_GET['a']) {
case 'addmore':
include("templates/staffheader.php");
include("templates/staff_menu.php");
include("templates/addmore.php");
break;
case 'edit':
case 'addtrack':
require_once("parseplaylist.php");
if(isset($_POST["moretracks"]) and $_POST["moretracks"]>0) {
$tracks = array();
for($i=0; $i<$_POST["moretracks"]; $i++)
$tracks[] = array("tracknum" => $i+1);
}
if($_GET['a']=='edit') {
$db = new Database();
$_POST['q'] = str_replace("'",".",$_POST['q']);
$_POST['q'] = str_replace("(",".",$_POST['q']);
$_POST['q'] = str_replace(")",".",$_POST['q']);
$tracks = $db->queryArrays("SELECT * FROM track WHERE album REGEXP '".$_POST["q"]."'");
}
elseif(isset($_POST["playlistjam"]) && $_POST["playlistjam"]!="jamendoid")
$tracks = parsejamendo($_POST["playlistjam"]);
elseif(isset($_POST["playlistpod"]) && $_POST["playlistpod"]!="podcast")
$tracks = parsepod($_POST["playlistpod"]);
elseif(isset($_POST["playlistm3u"]) && $_POST["playlistm3u"]!="m3u")
$tracks = parsem3u($_POST["playlistm3u"]);
elseif(isset($_POST["playlistpls"]) && $_POST["playlistpls"]!="pls")
$tracks = parsepls($_POST["playlistpls"]);
elseif(isset($_POST["playlistxspf"]) && $_POST["playlistxspf"]!="xspf")
$tracks = parsexspf($_POST["playlistxspf"]);
$question = mt_rand(0,10).(mt_rand(0,1)?'+':'-').mt_rand(0,10);
include("templates/staffheader.php");
include("templates/staff_menu.php");
include("templates/addtrack.php");
break;
case 'add':
eval("\$correct = ".$_POST['answer']."==".$_POST['question'].";");
if($correct) {
$success = true;
$successnum = 0;
$num = count($_POST['tracknum']);
for($i=0; $i<$num; $i++) {
$t = new Track(
array(
'title' => $_POST['title'][$i],
'artist' => $_POST['artist'][$i],
'album' => $_POST['album'][$i],
'genre' => $_POST['genre'][$i],
'url' => $_POST['url'][$i],
'cover' => $_POST['cover'][$i],
'via' => $_POST['website'][$i],
'adder' => $_SESSION['id'],
'duration' => $_POST['length'][$i],
'timeadded' => time()
)
);
$stdb = $t->submitToDatabase();
if($stdb>0)
$successnum += 1;
}
if($successnum < $num) {
$alert = "Some tracks couldn't be added. Were they already there?";
} elseif($successnum == $num) {
/*try {
$identica = new Identica('musiconradio', 'musicon123');
$identica->updateStatus("New Album: ".$t->getValue('artist')." - ".$t->getValue('album')." http://music.on.lc #freemusic");
} catch(exception $e) {}*/
$alert = "You successfully added $successnum new tracks!";
} else {
$alert = "Unsuccessful! Only $successnum tracks added.";
}
} else $alert = "Unsuccessful! Wrong answer to antibot question. (".$_POST['answer']."==".$_POST['question'].")";
include("templates/staffheader.php");
include("templates/staff_menu.php");
include("templates/staff.php");
break;
case 'explore':
$db = new Database();
include("templates/explorer_header.php");
include("templates/staff_menu.php");
include("templates/explorer.php");
break;
default:
include("templates/staffheader.php");
include("templates/staff_menu.php");
include("templates/staff.php");
}
} else {
include("templates/staffheader.php");
include("templates/login.php");
}
include("templates/footer.php");
?>