-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
101 lines (89 loc) · 3.36 KB
/
index.php
File metadata and controls
101 lines (89 loc) · 3.36 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
<!DOCTYPE html>
<html>
<head>
<title>YouJay</title>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="http://unicorn-ui.com/buttons/css/buttons.css" rel="stylesheet" type="text/css">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<div id="header">
<img src="logo_small.png" alt="youjay" />
<p class="claim">Fai girare la tua musica!</p>
</div>
<div id="search">
<form action="index.php" method="post" class="form-wrapper cf">
<span class="input input--haruki">
<input class="input__field input__field--haruki" type="text" id="input-1" type="text" size="35" name="keyword" placeholder="cerca" required <?php
if(isset($_POST["keyword"])){
echo "echo value=\"";
echo $_POST['keyword'];
echo "\"";
}
?> /> <br> <input type="submit" value="cerca" class="button button-primary button-pill button-giant"/>
</span>
</form>
</div>
<p class="clear"></p>
<div id="risultato">
<?php
if(isset($_POST["keyword"])){
if($_POST["keyword"] == ""){
echo "Inserisci la chiave di ricerca...";
}elseif(isset($_POST["keyword"])){
$keyword=addslashes(strip_tags(preg_replace("/\s/i", "+", $_POST["keyword"])));
$url="https://www.youtube.com/results?safesearch=strict&search_query=" . $keyword;
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);
curl_close ($curl);
$arrayhtml=explode("\n", $result);
$arraytitle = preg_grep("/yt-lockup-content/", $arrayhtml);
$arrayimg = preg_grep("/yt-thumb video-thumb/", $arrayhtml);
$keys=(array_keys($arraytitle));
$keysimg=(array_keys($arrayimg));
$imax=6;
for($i=2; $i<=$imax; $i++){
$arraytitle[$keys[$i]];
$arrdata=explode("=", $arraytitle[$keys[$i]]);
$videoid=explode("\"", $arrdata[4]);
if(stristr($arraytitle[$keys[$i]], "full album")
|| stristr($arraytitle[$keys[$i]], "full concert")
|| stristr($arraytitle[$keys[$i]], "playlist")
|| stristr($arraytitle[$keys[$i]], "full show")
|| $videoid[0] == ""){
$imax++;
}else{
//print_r($arraytitle);
preg_match("/title\=(.*?)\"\s+/si", $arraytitle[$keys[$i]], $title);
preg_match("/((\w+):)(\w+)/i", $arraytitle[$keys[$i]], $time);
$arraythumb=$arrayimg[$keysimg[$i-2]];
preg_match("/\"\/\/(.*?)\.jpg/", $arraythumb, $thumb);
echo "<a href=\"add.php?id=" . $videoid[0] . "&title=" . str_ireplace("\"", "", $title[1]) . "\">
<img src=\"http://" . $thumb[1] . ".jpg\" alt=\"" . $title[1] . " class=\"anteprima\"/></a><br>";
echo "<span class=\"info\"> " . str_ireplace("\"", "", $title[1]) . " [";
echo $time[0];
echo "] <a href=\"add.php?id=" . $videoid[0] . "&title=" . str_ireplace("\"", "", $title[1]) . "\" class=\"button button-primary button-box button-small\"><i class=\"fa fa-plus\"></i></a></span><p class=\"clear spazio\"></p>\n";
}
}
}
}
$db = new SQLite3('youjay.db');
$query="SELECT * FROM playlist";
$results = $db->query($query);
$queryn="SELECT COUNT(id) FROM playlist;";
$row = $db->querySingle($queryn);
echo "<b>Playlist corrente</b> ( ". $row . " brani in totale):<br /><br />\n";
while ($roba = $results->fetchArray()){
if($roba['download'] == 'FALSE'){
print("<div class=\"grigino\">" . $roba['title'] . "</div>\n");
}else{
print($roba['title']."<br />\n");
}
}
echo $roba;
?>
</div><!-- fine risultato -->
</body>
</html>