View Single Post
  #1 (permalink)  
Old 2006-05-26, 06:32 AM
camelota camelota is offline
Junior Member
 
Join Date: May 2006
Posts: 1
camelota is on a distinguished road
Default script convert the mp3

Hello all,
Need your help, i have a music script, i have admin interface i link the music from another site and somebody download an mp3 the script upload songs to my site automaticaly at the end script remove from site, when 100 people download from site not work because to many download and the script can`t stand, i put here code of download.php, help me pls to fix it , to see example go here http://www.reteauabaicului.net/manele/index.php and go in one album and download one song, i repeat don`t have mp3`s in my site
Code:
<?php
/*
+--------------------------------------------------------------------------
|   Opial Version 1.0
|   =============================================
|   by Opial.com
|   (c) 2006 - 2010 Opial, LLC.
|                               
|   =============================================
|                                                       
+---------------------------------------------------------------------------
|
|   Opial.com and its products are Copyright protected.
|    
+--------------------------------------------------------------------------
*/
$parts = split('[[:space:]]+', trim(php_uname()));
$PATH_SEP = (isset($parts[0]) && $parts[0] == "Windows") ? "\\" : $PATH_SEP = "/";
if ($PATH_SEP == "\\")
{
    require_once "lib\paths.php";
}
else 
{
    require_once "lib/paths.php";
}
require_once 'common.php';
/**/
$id = @$_REQUEST['id'];
if (empty($id))
{
    header("Content-type: text/plain\n\r");
    echo "Link broken";
    exit();
}

/* update stats */
$download = new Downloads();
$download->songId = $id;
$download->find(true);
if (empty($download->id))
{
    $download->downloadsCount = 1;    
    $download->todayDownloadsCount = 1;
    $download->downloadDT     = date('Y-m-d H:i:s');
    $download->insert();
}
else
{
    $download->downloadsCount = $download->downloadsCount + 1;
    $download->todayDownloadsCount = $download->todayDownloadsCount + 1;
    $download->downloadDT     = date('Y-m-d H:i:s');
    $download->update();
}
$song = new Song();
$song->get($id);
if (!empty($song->fileName))
{
    $source = $song->getDir(true) . "artist_" . $song->artistId . "/" . $song->fileName;
}
else
{
    $source = $song->url;
}
header('Content-type: application/octet-stream');
if (!empty($song->fileName)) 
{
    header('Content-Disposition: filename=' . str_replace(" ", "_", $song->fileName));
    header('Content-Length: ' . $song->fileSize);
}
else 
{
    $filesize = remote_filesize($source);
    header('Content-Disposition: filename=' . str_replace(" ", "_", basename($song->title)) . ".mp3");        
    if ($filesize != "unknown")
    {
        header('Content-Length: ' . $filesize);
    }
}
$cd = new CurrentDownloads();
$cd->songId = $song->id;
$cd->insert();
$fh = fopen($source, "rb");
fpassthru($fh);
fclose($fh);
/* delete current upload */
$cd->delete();
exit();
?>
Reply With Quote