Leading music site. He parsit music from another site. Now stopped working. How it was: the mp3 file was parsed from a third-party site, the file was uploaded to a temporary folder with 777 permissions - tmp. Direct link from a third-party site was replaced with a direct link from my site. Now this is not happening
PROBLEM in what: The direct link from a third-party site is written to my database, it is not converted. The mp3 file is not uploaded. An error appeared in the logs - Cannot modify header information - headers already sent
The handler has the following form:
// пишем песню с парсера include ('simple_html_dom.php'); $html = file_get_html($linkmp3); if($html && is_object($html) && isset($html->nodes)){ foreach($html->find('a.download_link') as $link){ $file_link = $link[0]->href; $file_title = basename($link[0]->href); $file_title = str_ireplace('othersite.ru' , 'mysite.com', $file_title); // копируем в локальную папку chmod('tmp/'.$file_title, 0777); copy ( $file_link , 'tmp/'.$file_title); // собираем инфу на формирование тегов $mp3_tags = array(); $result = mysql_query("SELECT title FROM style WHERE id=" . (int)$style_id,$db); if ($result) { if(mysql_num_rows($result) > 0){ $row = mysql_fetch_array($result); $mp3_tags["genre"] = $row["title"]; } } $title_parts = explode(' - ', $title); $mp3_tags["artist"] = $title_parts[0]; $mp3_tags["title"] = $title_parts[1]; $mp3_tags["year"] = $year; $mp3_tags["album"] = date("Y, F"); $mp3_tags["comment"] = "http://mysite.com"; // заменяем теги replace_mp3_tags('tmp/'.$file_title, $mp3_tags); //die(); // переносим $new_path = 'plus/' . date("ymd") . '/' . $file_title; $new_rel_path = '../' . $new_path; // рекурсивно создает папки, если их нет if (!is_dir(dirname($new_rel_path))) { mkdir(dirname($new_rel_path), 0777, true); } rename("tmp/" . $file_title, $new_rel_path); // обновляем $linkmp3 = $preview = $new_path; if (isset($title)) { // если поля не пустые и такой песни нет - заносим новую песню в базу - в таблицу song_add $result = mysql_query("INSERT INTO song_add (title)VALUES ('$title')"); $new_song_result = mysql_query("SELECT max(id) AS new_id FROM song_add", $db); // запрос на поиск номера только что добавленной песни $new_song_row = mysql_fetch_array($new_song_result); // достаем строку $new_song_id = $new_song_row["new_id"]; // получаем номер только что добавленной песни // и вот теперь мы добавляем в таблицу files значение с нужной айди песни, тоесть: $result2 = mysql_query("INSERT INTO files (linkmp3,id) VALUES ('$linkmp3','$new_song_id')"); if ($result == 'true'){ echo "Песня успешно добавлена<br>"; if ($result2 == 'true'){echo "Ссылка к песне добавлена тоже";} } else {mysql_error();} } else {echo "Заполнены не все поля!<br>Песня НЕ добавлена";} $result = mysql_query("UPDATE parsed SET (is_processed = 1) WHERE id=" . $id); } } (I didn’t find how to place php code in BB tags)