Просмотр файла zagrcent/nar.php

Размер файла: 4.22Kb
  1. <?php
  2. error_reporting(7);
  3. function delTemporaryFiles ($directory)
  4. {
  5. $dir = opendir ($directory);
  6. while (( $file = readdir ($dir)))
  7. {
  8. if( is_file ($directory."/".$file))
  9. {
  10. $acc_time = fileatime ($directory."/".$file);
  11. $time = time();
  12. if (($time - $acc_time) > 24*60*60)
  13. {
  14. if ( unlink ($directory.'/'.$file))
  15. {
  16. echo ('Файлы успешно удалены');
  17. }
  18. }
  19. }
  20. else if ( is_dir ($directory."/".$file) && ($file != ".") && ($file != ".."))
  21. {
  22. delTemporaryFiles ($directory."/".$file);
  23. }
  24. }
  25. closedir ($dir);
  26. }
  27. require_once('nast.php');
  28. require_once('shapka.php');
  29. require_once('func.php');
  30. include('db.php');
  31. print $beginpage;
  32. include('rekl.php');
  33. $dirname=dirname($file);
  34. $basename=basename($file);
  35. $rand=rand(1,10);
  36. if($rand==10)
  37. {
  38. delTemporaryFiles('mp3nar');
  39. }
  40. if (!strstr("$file", "..") and file_exists($file) and substr($file,0,6)!='http://' and substr($file,0,6)!='ftp://')
  41. {
  42. $filename=translit(basename($file));
  43. $files=filesize($file);
  44. print "Файл: $filename($files байт)<br/>";
  45. print "Тип:".r($file).'<br/>';
  46. include('id.php');
  47. if(!@$act){
  48. if($str=='xhtml')
  49. print"
  50. <form action=\"nar.php?act=nar&amp;file=$file&amp;str=$str\" method=\"post\">
  51. Способ нарезки:<br/>
  52. <select name=\"way\">
  53. <option value=\"size\">по размеру</option>
  54. <option value=\"time\">по времени</option>
  55. </select><br/>
  56. Начать с (кб или сек.):<br/>
  57. <input type=\"text\" name=\"s\"/><br/>
  58. Закончить по (кб или сек.):<br/>
  59. <input type=\"text\" name=\"p\"/><br/>
  60. <input type=\"submit\" name=\"a\" value=\"Резать\"/>
  61. </form>";
  62. else
  63. {
  64. $r=rand(1,1000);
  65.  
  66. print "Способ нарезки:<br/></small>
  67. <select name=\"way\">
  68. <option value=\"size\">по размеру</option>
  69. <option value=\"time\">по времени</option>
  70. </select><br/>";
  71. echo "<small>Начать с (кб или сек.):<br/></small>";
  72. echo "<input name=\"s$r\" type=\"text\" title=\"\" value=\"\" maxlength=\"12\"/><br/>";
  73. echo "<small>Закончить по (кб или сек.):<br/></small>";
  74. echo "<input name=\"p$r\" type=\"text\" title=\"\" value=\"\" maxlength=\"12\"/><br/>";
  75. echo "<anchor title=\"go\">Резать<go href=\"nar.php?act=nar&amp;file=$file&amp;str=$str\" method=\"post\">\n";
  76. echo "<postfield name=\"s\" value=\"$(s$r)\"/>\n";
  77. echo "<postfield name=\"p\" value=\"$(p$r)\"/>\n";
  78. echo "<postfield name=\"way\" value=\"$(way$r)\"/>\n";
  79. echo "</go></anchor><br/>\n<small>";
  80.  
  81. }
  82. }else{
  83. $error = 0;
  84. $s=intval($s);
  85. $p=intval($p);
  86. if(!@isset($s)||@empty($s)){print "Вы не ввели число начала! <a href=\"nar.php?file=$file&amp;str=$str\">Исправить!</a><br/>"; $error = 1;}
  87. if(!isset($p)||empty($p)){print "Вы не ввели число конца! <a href=\"nar.php?file=$file&amp;str=$str\">Исправить!</a><br/>"; $error = 1;}
  88. if($error==0)
  89. {
  90. $randintval = "mp3nar/".mt_rand(10000000,99999999).'.'.r($file);
  91. if(copy($file,$randintval)){
  92. {
  93. $fp = fopen($randintval, "rb");
  94. $raz = filesize($randintval);
  95. $s = intval($s);
  96. $p = intval($p);
  97. if($way=="size"){
  98. $s = $s*1024;
  99. $p = $p*1024;
  100. if($s>$raz||$s<0){$s = 0;}
  101. if($p>$raz||$p<$s){$p = $raz;}}
  102. else{
  103. $id3 = new MP3_Id();
  104. $result = $id3->read($randintval);
  105. $result = $id3->study();
  106. $byterate = $id3->getTag('bitrate')/8;
  107. if(!$byterate)
  108. $byterate=64;
  109. $secbit = $raz/1024/$byterate;
  110. if($s>$secbit||$s<0){$s = 0;}
  111. if($p>$secbit||$p<$s){$p = $secbit;}
  112. $s = $s*$byterate*1024;
  113. $p = $p*$byterate*1024;}
  114. $p = $p-$s;
  115. fseek($fp, $s);
  116. $filefp = fread($fp, $p);
  117. fclose($fp);
  118. unlink($randintval);
  119. $fp = fopen($randintval, "xb");
  120. if(!fwrite($fp, $filefp) === FALSE){
  121. print "Файл успешно нарезан!<br/>
  122. <a href=\"$randintval\">Скачать</a><br/>";
  123. }}}}
  124. else
  125. print "Неверно указан файл<br/>";}}
  126. $t=explode('/',dirname($file));
  127. $t[0]='';
  128. require_once('online.php');
  129. print $razd."<a href=\"sd.php?sd=".substr(join('/',$t),1,150)."&amp;str=$str\">Вернуться в папку ".transdir(join('/',$t))."</a><br/>";
  130. print '&gt;<a href="index.php?str='.$str.'">Выбрать раздел</a><br/>';
  131. print $endpage;
  132. ?>