function get_playlist($playlist_url) { $code_length = 7; $playlist_code = substr($playlist_url, strrpos($playlist_url, '/') - $code_length, $code_length); $playlist_name = substr($playlist_url, strrpos($playlist_url, '/') + 1); $ch = curl_init(); # cURL configuration to get XML playlist curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'accept-language' => 'es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3')); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_URL, 'http://goear.com/playerplaylist/' . $playlist_code); curl_setopt($ch, CURLOPT_BUFFERSIZE, 1024); curl_setopt($ch, CURLOPT_NOPROGRESS, FALSE); file_put_contents($playlist_code . '.xml', preg_replace('/^.*?(?:HTTP *?\\/ *?\\d+\\.\\d+ +?\\d{3}.*?\\r\\n\\r\\n)+(.*)$/is', '\\1', curl_exec($ch))); curl_close($ch); mkdir('Songs/' . $playlist_name, 0777); $playlist_file = fopen($playlist_code . '.xml', "r") or die("Unable to open file!"); # Read XML with playlist while (!feof($playlist_file)) { $line = fgets($playlist_file); $tracks = substr_count($line, 'target='); $offset = 0; while ($tracks > 0) { $initpos = strpos($line, 'target="', $offset) + 8; get_song(substr($line, $initpos, strpos($line, '"', $initpos + 1) - $initpos), '/' . $playlist_name . '/'); $offset = $initpos + 1; $tracks = $tracks - 1; } } fclose($playlist_file); unlink($playlist_code . '.xml'); }
function view_contestants_song_picks($contestant_id) { $contestant_query = "SELECT * FROM year_end_contestants WHERE id = " . $contestant_id; $contestant_result = mysql_query($contestant_query); if (!$contestant_result) { die('No results in database.'); } else { $contestant = mysql_fetch_assoc($contestant_result); } $song_vote_query = "SELECT * FROM year_end_song_votes WHERE ip_address = \"" . $contestant['ip_address'] . "\""; $song_vote_result = mysql_query($song_vote_query); if (mysql_num_rows($song_vote_result) == 0) { die('No song results in database.'); } else { $song_votes = mysql_fetch_assoc($song_vote_result); } if ($contestant['contest'] == 'yes') { echo "<h3 class=\"center\">" . ucwords($contestant['name']) . "'s Top 20 Songs</h3>"; echo "<ul>"; for ($i = 1; $i <= 20; $i++) { $song = get_song($song_votes['song' . $i]); if ($song) { echo "<li>" . $song['artist'] . " - " . $song['title'] . "</li>"; } else { echo "<li><b>WRITE IN:</b> " . $song_votes['song' . $i] . "</li>"; } } echo "</ul>"; } else { echo "<div class=\"center\"><strong>This contestant does not wish to participate in the contest</strong></div>"; } }
$links = get_links_on_page('http://zaycev.net/m3_top/2.html'); echo " links"; //print_r($links); //print_r($_SERVER); //echo "</pre>"; $j == 0; foreach ($links as $link) { $j++; if ($j > 7) { break; } $file = str_replace('/', '_', $link); //echo "<p>link ".$link."<p> file ".$file; if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/zaycev/pages/' . $file)) { $c = file_get_contents('http://zaycev.net' . $link); $data = get_song($c); //echo "<pre> data "; //print_r($data); //echo "</pre>"; //echo "<p> c ".$c; $name = iconv("utf-8", "windows-1251", $data['name'] . '.mp3'); //echo "<p>name ".$name; if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/zaycev/song/' . $name)) { if (copy($data['link'], $_SERVER['DOCUMENT_ROOT'] . '/zaycev/song/' . $name)) { file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/zaycev/pages/' . $file, $c); } } } } function get_links_on_page($url) {
if (!isset($_GET['id'])) { die("Must specify id for this action"); } $albumId = intval($_GET['id']); $songId = -1; $artistId = -1; $artist_error = ""; $title = ""; $title_error = ""; $duration = ""; $duration_error = ""; $track_number = ""; $track_number_error = ""; if ($_GET['action'] == "editsong" && isset($_GET['songId'])) { $songId = intval($_GET['songId']); $details = get_song($songId, $albumId); $title = $details['title']; $duration = $details['duration']; $track_number = $details['track_number']; $artistId = $details['artistId']; } $origArtistId = $artistId; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $artistId = intval($_POST['artistid']); $title = sanitize_input($_POST['title']); $duration = doubleval($_POST['duration']); $track_number = intval($_POST['track_number']); $albumId = intval($_POST['albumId']); if (isset($_POST['songId'])) { $songId = intval($_POST['songId']); }