Пример #1
0
 function music_upload($file_name, &$space_left)
 {
     global $database, $url, $user;
     // SET KEY VARIABLES
     $file_maxsize = $user->level_info['level_music_maxsize'];
     $file_exts = explode(",", str_replace(" ", "", strtolower($user->level_info['level_music_exts'])));
     $file_types = explode(",", str_replace(" ", "", strtolower($user->level_info['level_music_mimes'])));
     $new_music = new se_upload();
     $new_music->new_upload($file_name, $file_maxsize, $file_exts, $file_types);
     // CHECK SPACE LEFT
     if ($new_music->file_size > $space_left) {
         $new_music->is_error = 4000087;
     } else {
         $space_left = $space_left - $file_filesize;
     }
     if (!$new_music->is_error) {
         // GENERATE TITLE
         $myId3 = new ID3($file_dest);
         if ($myId3->getInfo()) {
             $id3_artist = trim($myId3->getArtist());
             $id3_title = trim($myId3->getTitle());
             if ($id3_artist && $id3_title) {
                 $music_title = $id3_artist . ' - ' . $id3_title;
             }
         }
         if (!trim($music_title)) {
             $music_title = $new_music->file_name;
         }
         $music_title = security(censor($music_title));
         // INSERT ROW INTO MUSIC TABLE
         $time = time();
         $track_num = $database->database_fetch_array($database->database_query("SELECT music_track_num as track FROM se_music WHERE music_user_id = '{$this->user_id}' ORDER BY music_track_num DESC LIMIT 1"));
         $track_num = $track_num['track'] + 1;
         $database->database_query("\r\n        INSERT INTO se_music\r\n        (\r\n          music_user_id,\r\n          music_track_num,\r\n          music_date,\r\n          music_title,\r\n          music_ext,\r\n          music_filesize\r\n        )\r\n        VALUES\r\n        (\r\n          '{$this->user_id}',\r\n          '{$track_num}',\r\n          '{$time}',\r\n          '{$music_title}',\r\n          '{$new_music->file_ext}',\r\n          '{$new_music->file_size}'\r\n        )\r\n      ");
         $music_id = $database->database_insert_id();
         // MOVE UPLOADED FILE
         $file_dest = $url->url_userdir($user->user_info[user_id]) . $music_id . "." . $new_music->file_ext;
         $new_music->upload_file($file_dest);
     }
     // RETURN AND DELETE FROM DATABASE IF ERROR
     if ($new_music->is_error) {
         if ($music_id) {
             $database->database_query("DELETE FROM se_music WHERE music_id='{$music_id}' && music_user_id='{$this->user_id}'");
         }
         if ($file_dest) {
             @unlink($file_dest);
         }
         return array('is_error' => $new_music->is_error);
     }
     // RETURN FILE STATS
     return array('music_id' => $music_id, 'music_ext' => $new_music->file_ext, 'music_filesize' => $new_music->file_size, 'music_title' => $music_title);
 }
Пример #2
0
function printXML($arr)
{
    foreach ($arr as $key => $val) {
        if (is_array($val)) {
            $folder_title = substr($key, $omit_folder_chars);
            ksort($val);
            printXML($val);
        } else {
            $file = $val;
            if (substr($file, -3) == 'mp3' || substr($file, -3) == 'MP3') {
                $file_title = substr($file, 0, strlen($file) - 4);
                // ID3v1 and ID3v2  tags parser
                $nome_arq = $file;
                $myId3 = new ID3($nome_arq);
                if ($myId3->getInfo()) {
                    $f_title = $myId3->getTitle();
                    $f_artist = $myId3->getArtist();
                }
                if (!$myId3->getArtist()) {
                    $id3 = new MP3_Id();
                    $result = $id3->read($file);
                    $f_title = $id3->getTag('name');
                    $f_artist = $id3->getTag('artists');
                }
                if ($f_artist == '0' && $f_title == '0') {
                    $arr_names = explode('/', strrev($nome_arq));
                    $substr = substr($arr_names[0], 4, strlen($arr_names[0]));
                    $arr_names_last = explode('_', strrev($substr));
                    $f_artist = '';
                    $f_title = strrev($substr);
                }
                if ($f_artist == '0') {
                    $f_artist = '';
                }
                $f_id = str_replace("/", "", $file_title);
                $f_id = str_replace(".", "", $f_id);
                $f_id = str_replace(">", "", $f_id);
                $f_id = str_replace("<", "", $f_id);
                $f_id = str_replace("=", "", $f_id);
                $f_id = str_replace("(", "", $f_id);
                $f_id = str_replace(")", "", $f_id);
                $f_id = str_replace("\"", "", $f_id);
                if ($sEncoding = mb_detect_encoding($f_title, 'auto', true) != 'UTF-8') {
                    $f_title = mb_convert_encoding($f_title, 'UTF-8', $sEncoding);
                }
                if ($sEncoding = mb_detect_encoding($f_artist, 'auto', true) != 'UTF-8') {
                    $f_artist = mb_convert_encoding($f_artist, 'UTF-8', $sEncoding);
                }
                $f_title = conv($f_title);
                $f_artist = conv($f_artist);
                if (substr($f_title, 0, 4) == 'ÿþ') {
                    $f_title = substr($f_title, 4);
                }
                if (substr($f_artist, 0, 4) == 'ÿþ') {
                    $f_artist = substr($f_artist, 4);
                }
                $f_title = str_replace(">", "", $f_title);
                $f_title = str_replace("<", "", $f_title);
                $f_artist = str_replace(">", "", $f_artist);
                $f_artist = str_replace("<", "", $f_artist);
                $f_id = encoding($f_id);
                $path = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
                $path = dirname($path);
                $defaul_dir = substr($val, 0, strrpos($val, '/'));
                $file_name_ = substr(strrchr($val, '/'), 1);
                $url_dec = rawurlencode($file_name_);
                $val = $defaul_dir . '/' . $url_dec;
                $file = $val;
                $file = 'http://' . $path . '/' . $file;
                // Writing in XML
                print '
   <song id="' . $f_id . '"  title="' . $f_title . '" artist="' . $f_artist . '"  src="' . $file . '" />';
            }
        }
    }
}