Размер файла: 4.22Kb
- <?php
- error_reporting(7);
- function delTemporaryFiles ($directory)
- {
- $dir = opendir ($directory);
- while (( $file = readdir ($dir)))
- {
- if( is_file ($directory."/".$file))
- {
- $acc_time = fileatime ($directory."/".$file);
- $time = time();
- if (($time - $acc_time) > 24*60*60)
- {
- if ( unlink ($directory.'/'.$file))
- {
- echo ('Файлы успешно удалены');
- }
- }
- }
- else if ( is_dir ($directory."/".$file) && ($file != ".") && ($file != ".."))
- {
- delTemporaryFiles ($directory."/".$file);
- }
- }
- closedir ($dir);
- }
- require_once('nast.php');
- require_once('shapka.php');
- require_once('func.php');
- include('db.php');
- print $beginpage;
- include('rekl.php');
- $dirname=dirname($file);
- $basename=basename($file);
- $rand=rand(1,10);
- if($rand==10)
- {
- delTemporaryFiles('mp3nar');
-
- }
- if (!strstr("$file", "..") and file_exists($file) and substr($file,0,6)!='http://' and substr($file,0,6)!='ftp://')
- {
- $filename=translit(basename($file));
- $files=filesize($file);
- print "Файл: $filename($files байт)<br/>";
- print "Тип:".r($file).'<br/>';
- include('id.php');
- if(!@$act){
- if($str=='xhtml')
- print"
- <form action=\"nar.php?act=nar&file=$file&str=$str\" method=\"post\">
- Способ нарезки:<br/>
- <select name=\"way\">
- <option value=\"size\">по размеру</option>
- <option value=\"time\">по времени</option>
- </select><br/>
- Начать с (кб или сек.):<br/>
- <input type=\"text\" name=\"s\"/><br/>
- Закончить по (кб или сек.):<br/>
- <input type=\"text\" name=\"p\"/><br/>
- <input type=\"submit\" name=\"a\" value=\"Резать\"/>
- </form>";
- else
- {
- $r=rand(1,1000);
-
- print "Способ нарезки:<br/></small>
- <select name=\"way\">
- <option value=\"size\">по размеру</option>
- <option value=\"time\">по времени</option>
- </select><br/>";
- echo "<small>Начать с (кб или сек.):<br/></small>";
- echo "<input name=\"s$r\" type=\"text\" title=\"\" value=\"\" maxlength=\"12\"/><br/>";
- echo "<small>Закончить по (кб или сек.):<br/></small>";
- echo "<input name=\"p$r\" type=\"text\" title=\"\" value=\"\" maxlength=\"12\"/><br/>";
- echo "<anchor title=\"go\">Резать<go href=\"nar.php?act=nar&file=$file&str=$str\" method=\"post\">\n";
- echo "<postfield name=\"s\" value=\"$(s$r)\"/>\n";
- echo "<postfield name=\"p\" value=\"$(p$r)\"/>\n";
- echo "<postfield name=\"way\" value=\"$(way$r)\"/>\n";
- echo "</go></anchor><br/>\n<small>";
-
- }
- }else{
- $error = 0;
- $s=intval($s);
- $p=intval($p);
- if(!@isset($s)||@empty($s)){print "Вы не ввели число начала! <a href=\"nar.php?file=$file&str=$str\">Исправить!</a><br/>"; $error = 1;}
- if(!isset($p)||empty($p)){print "Вы не ввели число конца! <a href=\"nar.php?file=$file&str=$str\">Исправить!</a><br/>"; $error = 1;}
- if($error==0)
- {
- $randintval = "mp3nar/".mt_rand(10000000,99999999).'.'.r($file);
- if(copy($file,$randintval)){
- {
- $fp = fopen($randintval, "rb");
- $raz = filesize($randintval);
- $s = intval($s);
- $p = intval($p);
- if($way=="size"){
- $s = $s*1024;
- $p = $p*1024;
- if($s>$raz||$s<0){$s = 0;}
- if($p>$raz||$p<$s){$p = $raz;}}
- else{
- $id3 = new MP3_Id();
- $result = $id3->read($randintval);
- $result = $id3->study();
- $byterate = $id3->getTag('bitrate')/8;
- if(!$byterate)
- $byterate=64;
- $secbit = $raz/1024/$byterate;
- if($s>$secbit||$s<0){$s = 0;}
- if($p>$secbit||$p<$s){$p = $secbit;}
- $s = $s*$byterate*1024;
- $p = $p*$byterate*1024;}
- $p = $p-$s;
- fseek($fp, $s);
- $filefp = fread($fp, $p);
- fclose($fp);
- unlink($randintval);
- $fp = fopen($randintval, "xb");
- if(!fwrite($fp, $filefp) === FALSE){
- print "Файл успешно нарезан!<br/>
- <a href=\"$randintval\">Скачать</a><br/>";
- }}}}
- else
- print "Неверно указан файл<br/>";}}
- $t=explode('/',dirname($file));
- $t[0]='';
- require_once('online.php');
- print $razd."<a href=\"sd.php?sd=".substr(join('/',$t),1,150)."&str=$str\">Вернуться в папку ".transdir(join('/',$t))."</a><br/>";
- print '><a href="index.php?str='.$str.'">Выбрать раздел</a><br/>';
- print $endpage;
- ?>