Guest User

Untitled

a guest
Apr 29th, 2012
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.08 KB | None | 0 0
  1. <?php
  2. if(!@session_id()){
  3. @session_start();
  4. }
  5.  
  6.  
  7. //print ("<pre>");
  8. //print_r ($_SERVER);
  9. //print ("</pre>");
  10. //<//////////////////////////////////////////////////////////////
  11. // //
  12. // //
  13. // //
  14. // //
  15. // Pickle Auto Playlist //
  16. // v 1.0.3 //
  17. // //
  18. // Available at http://www.pickleplayer.com //
  19. // Copyright 2002-2011 plaino //
  20. // //
  21. // //
  22. // USE AT YOUR OWN RISK //
  23. // //
  24. // //
  25. /////////////////////////////////////////////////////////////////
  26. // //
  27. // INSTALLATION: //
  28. // //
  29. /////////////////////////////////////////////////////////////////
  30. //
  31. // Upload autoplaylist.php to the folder that contains your media files.
  32. //
  33. // USE AT YOUR OWN RISK.
  34.  
  35. $pickleVersion = "1.0.3";
  36.  
  37. // --- playlistKind
  38. // Playlists can be either "xml" or "txt". XML playlists allow for
  39. // cover art images and if the getid3 library is available,
  40. // Artist and Title extraction from MP3 ID3 information.
  41. // ID3 extraction currently only works for MP3 files.
  42. // $playlistKind = "xml";
  43. // $playlistKind = "txt";
  44.  
  45. $playlistKind = "xml";
  46.  
  47. // --- defaultVisualExt
  48. // The default poster (cover art) image extension to search for:
  49. $defaultVisualExt = "jpg";
  50.  
  51. // --- media_types
  52. // The kinds of files to search for:
  53. $media_types = "mp4,m4a,m4p,aac,mp3";
  54.  
  55. // --- hide_keywords
  56. // Files containing these keywords will be ignored.
  57. $hide_keywords = "skin,pickle,config,customizer,source,plugin";
  58.  
  59. // --- httpOption
  60. // Allows you to run pickle in "https" mode;
  61. //$httpOption = "https";
  62. $httpOption = "http";
  63.  
  64. // --- hide_folders
  65. // A list of folder names to ignore.
  66. $hide_folders = "_notes,skins,getid3,_private,_private,_vti_bin,_vti_cnf,_vti_pvt,_vti_txt,cgi-bin";
  67.  
  68. // --- hide_files
  69. // A list of file names to ignore.
  70. $hide_files = "";
  71.  
  72. // --- findAllMedia
  73. // When set to "true", will recursively search through all subdirectoies.
  74. $findAllMedia = false;
  75.  
  76. // --- coverartBasename
  77. // IGNORE. NOT IMPLIMENTED.
  78. $coverartBasename = "coverart.jpg";
  79.  
  80. // --- getMyid3info
  81. // Requires the getid3 library.
  82. $getMyid3info = "no";
  83.  
  84. // --- quirksmode
  85. // If not using gthe getID3 library, sets titles using the filename, but only shows text "between the dots"
  86. // example: 01.MyTrack.mp3 would display as "MyTrack"
  87. // This allows for files to be manually sorted within the folder.
  88. $quirksmode = false;
  89.  
  90. // --- sortOrder
  91. // Sets the sort order for files.
  92. // NOTE: This option may or may not work depending on how your server and/or PHP is configured.
  93. // Options: "ASC", "DEC", "RND"
  94. //$sortOrder = "ASC";
  95. $sortOrder = "RND";
  96. //$sortOrder = "DEC";
  97.  
  98.  
  99. /////////////////////////////////////////////////////////////////
  100. // //
  101. // Do not edit anything below here unless //
  102. // you really know what you are doing! //
  103. // //
  104. /////////////////////////////////////////////////////////////////
  105. /////////////////////////////////////////////////////////////////
  106. /////////////////////////////////////////////////////////////////
  107. /////////////////////////////////////////////////////////////////
  108. /////////////////////////////////////////////////////////////////
  109.  
  110. define("newline", "\r\n");
  111. define("slash", "/");
  112.  
  113. /////////////////////////////////////////////////////////////
  114. /////////////////////////////////////////////////////////////
  115. /////////////////////////////////////////////////////////////
  116. //
  117. // security and request clean
  118. //
  119. /////////////////////////////////////////////////////////////
  120. /////////////////////////////////////////////////////////////
  121. /////////////////////////////////////////////////////////////
  122.  
  123.  
  124. // prevent certain extensions from being downloaded
  125. function secureFiles($fileName, $extCheck){
  126. $ext = explode('.',$fileName);
  127. $myExt = strtolower($ext[sizeof($ext)-1]);
  128. if(strtolower($myExt) != strtolower($extCheck)){
  129. return false;
  130. } else {
  131. return true;
  132. }
  133. if ((!ereg('\.\.', $fileName)) && (file_exists($fileName))) {
  134. return true;
  135. } else {
  136. return false;
  137. }
  138. }
  139.  
  140.  
  141. // strip hacker requests
  142. function striphack($string){
  143. $retval = $string;
  144. //*
  145. $retval = strip_tags(stripslashes(rawurldecode(utf8_decode($retval))));
  146. $retval = strip_tags($retval);
  147. $retval = str_replace("sscanf", "x", $retval);
  148. $retval = str_replace("printf", "x", $retval);
  149. $retval = str_replace("base64_decode", "x", $retval);
  150. $retval = str_replace("rawurldecode", "x", $retval);
  151. $retval = str_replace("urldecode", "x", $retval);
  152. $retval = str_replace("0;", "x", $retval);
  153. $retval = str_replace("%5C", "x", $retval);
  154. $retval = str_replace("\n", "x", $retval);
  155. $retval = str_replace("\r", "x", $retval);
  156. $retval = str_replace("\t", "x", $retval);
  157. $retval = str_replace("\\", "x", $retval);
  158. $retval = ereg_replace("\.+/", "x", $retval);
  159. $retval = ereg_replace("\.\.","x",$retval);
  160. $retval = ereg_replace("^[\/]+", "x", $retval);
  161. if (function_exists('escapeshellcmd')) {
  162. $retval = escapeshellarg($retval);
  163. $retval = escapeshellcmd ($retval);
  164. }
  165. //*/
  166. return $retval;
  167. }
  168.  
  169.  
  170. function secureArray($array_in){
  171. if(@is_array($array_in)){
  172. foreach ($array_in as $key => $value){
  173. $Atemp[striphack($key)] = striphack($value);
  174. }
  175. } else {
  176. $Atemp = $array_in;
  177. }
  178. return $array_in;
  179. }
  180.  
  181.  
  182.  
  183.  
  184. if ( @get_magic_quotes_gpc () ){
  185. function traverse ( &$arr ){
  186. if ( !is_array ( $arr ) ){
  187. return;
  188. }
  189. foreach ( $arr as $key => $val ){
  190. is_array ( $arr[$key] ) ? traverse ( $arr[$key] ) : ( $arr[$key] = stripslashes ( $arr[$key] ) );
  191. }
  192. }
  193. $gpc = array ( &$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
  194. traverse ( $gpc );
  195. }
  196.  
  197.  
  198. $_REQUEST = secureArray($_REQUEST);
  199. $_GET = secureArray($_GET);
  200. $_POST = secureArray($_POST);
  201. $_COOKIE = secureArray($_COOKIE);
  202.  
  203. // these get set after default settings below because getid3 and coverartbasename should be over-written by request
  204. //
  205. // see: (below)
  206. /*
  207. foreach($_REQUEST as $key => $value){
  208. if(in_array($key, $AcheckRequests)){
  209. $$key = $value;
  210. } else {
  211. unset($$_REQUEST[$key]);
  212. }
  213. }
  214. */
  215. $AcheckRequests = array();
  216. $AcheckRequests[] = "action";
  217. $AcheckRequests[] = "kind";
  218. $AcheckRequests[] = "dir";
  219.  
  220.  
  221.  
  222. /////////////////////////////////////////////////////////////
  223. /////////////////////////////////////////////////////////////
  224. /////////////////////////////////////////////////////////////
  225. //
  226. // FILE PATHS
  227. //
  228. /////////////////////////////////////////////////////////////
  229. /////////////////////////////////////////////////////////////
  230. /////////////////////////////////////////////////////////////
  231.  
  232. /*
  233. if(@ini_get('safe_mode')){
  234. print('<table width="46%" border="0" align="center" cellpadding="010" cellspacing="0" bgcolor="#FFFFCC">');
  235. print(' <tr>');
  236. print(' <td><p><b><font color="#CC0000" size="2" face="Arial, Helvetica, sans-serif">');
  237. print('ERROR</font></b><font size="2" face="Arial, Helvetica, sans-serif"><br>');
  238. print(' <br>');
  239. print(' PHP is running in <b>"Safe Mode"</b> which prevents');
  240. print(' pickle from performing <br>');
  241. print(' necessary functions such as');
  242. print(' automatically reading the contents of a directory." <br>');
  243. print(' <br>');
  244. print(' Check with your hosting provider to see if they can');
  245. print(' turn off <b>"Safe Mode"</b> for your account."</font></p></td>');
  246. print(' </tr>');
  247. print('</table>');
  248. }
  249. */
  250.  
  251. if(@ini_get('safe_mode')){
  252. print('<?xml version="1.0"?>');
  253. print('<playlist>');
  254. print(' <item>');
  255. print(' <filename>ERROR</filename>');
  256. print(' <title>1. ERROR</title>');
  257. print(' </item>');
  258. print(' <item>');
  259. print(' <filename>ERROR</filename>');
  260. print(' <title>2. PHP is running in "Safe Mode".</title>');
  261. print(' </item>');
  262. print(' <item>');
  263. print(' <filename>ERROR</filename>');
  264. print(' <title>3. Contact Server Admin to Correct.</title>');
  265. print(' </item>');
  266. print(' <item>');
  267. print(' <filename>ERROR</filename>');
  268. print(' <title>4. ------------------</title>');
  269. print(' </item>');
  270. print(' <item>');
  271. print(' <filename>ERROR</filename>');
  272. print(' <title>5. You can still use Rave,</title>');
  273. print(' </item>');
  274. print(' <item>');
  275. print(' <filename>ERROR</filename>');
  276. print(' <title>6. however all URLs must be</title>');
  277. print(' </item>');
  278. print(' <item>');
  279. print(' <filename>ERROR</filename>');
  280. print(' <title>7. entered manually.</title>');
  281. print(' </item>');
  282. print('</playlist>');
  283. exit;
  284. }
  285.  
  286.  
  287. //strstr( PHP_OS, "WIN") ? $osType = "win" : $osType = "unix";
  288.  
  289. /*
  290. if(!@getcwd ()){
  291. $pickle_PATH['physical'] = str_replace("\\", "/", dirname(__FILE__));
  292. } else {
  293. $pickle_PATH['physical'] = str_replace("\\", "/", getcwd ());
  294. }
  295. */
  296.  
  297. if(!@getcwd ()){
  298. $pickle_PATH['physical'] = dirname(__FILE__);
  299. } else {
  300. $pickle_PATH['physical'] = getcwd ();
  301. }
  302.  
  303.  
  304. if(!isset($_SERVER['SCRIPT_NAME'])){
  305. $_REQUEST = get_defined_vars();
  306. $_SERVER = $HTTP_SERVER_VARS;
  307. }
  308.  
  309.  
  310.  
  311.  
  312. $Apathtome = explode("/", $_SERVER['PHP_SELF']);
  313. $picklePhp = array_pop($Apathtome);
  314. //$pathtome = implode("/", $Apathtome);
  315. $pickle_PATH['www'] = $httpOption."://".$_SERVER['HTTP_HOST'].(implode("/", $Apathtome));
  316.  
  317. /*
  318. print ("<pre>");
  319. print_r ($Apathtome);
  320. print ("</pre>");
  321. print ("<br>");
  322. print $picklePhp;
  323. print ("<br>");
  324. exit;
  325. */
  326.  
  327.  
  328.  
  329. /////////////////////////////////////////////////////////////
  330. /////////////////////////////////////////////////////////////
  331. /////////////////////////////////////////////////////////////
  332. //
  333. // DEFAULT SETTINGS / SET CONFIGS
  334. //
  335. /////////////////////////////////////////////////////////////
  336. /////////////////////////////////////////////////////////////
  337. /////////////////////////////////////////////////////////////
  338.  
  339.  
  340.  
  341. foreach($_REQUEST as $key => $value){
  342. if(in_array($key, $AcheckRequests)){
  343. $$key = $value;
  344. } else {
  345. unset($$_REQUEST[$key]);
  346. }
  347. }
  348.  
  349.  
  350. if(isset($kind)){
  351. $playlistKind = $kind;
  352. $kind = null;
  353. }
  354.  
  355.  
  356. // Vars that should not be over-written by an external pickleConfigs.xml file:
  357. $hiderVars = Array("hide_folders", "hide_files");
  358.  
  359. $AdefaultVisual = explode(".", $coverartBasename);
  360. $defaultVisualBaseName = $AdefaultVisual[0];
  361. //$defaultVisualExt = $AdefaultVisual[1];
  362.  
  363. function setCoverartBasenameData(){
  364. global $AdefaultVisual, $defaultVisualBaseName, $defaultVisualExt, $coverartBasename;
  365. $AdefaultVisual = explode(".", $coverartBasename);
  366. $defaultVisualBaseName = $AdefaultVisual[0];
  367. $defaultVisualExt = $AdefaultVisual[1];
  368. }
  369.  
  370.  
  371. function file_get_as_string($file){
  372. $file = @file("$file");
  373. return !$file ? false : implode('', $file);
  374. }
  375.  
  376.  
  377.  
  378. // Thse vars need to be set after reading the config file.
  379. if(isset($coverartBasename) && $coverartBasename != ""){
  380. setCoverartBasenameData();
  381. }
  382.  
  383.  
  384. $pickle_PATH['physical'] = str_replace("\\", "/", $pickle_PATH['physical']);
  385. $pickle_PATH['physical'] = str_replace("//", "/", $pickle_PATH['physical']);
  386.  
  387.  
  388. /////////////////////////////////////////////////////////////
  389. /////////////////////////////////////////////////////////////
  390. /////////////////////////////////////////////////////////////
  391. //
  392. // DIRECTORY READING
  393. //
  394. /////////////////////////////////////////////////////////////
  395. /////////////////////////////////////////////////////////////
  396. /////////////////////////////////////////////////////////////
  397.  
  398. $Ahide_files = explode(",",$hide_files);
  399. $Ahide_folders = explode(",",$hide_folders);
  400. $Amedia_types = explode(",",$media_types);
  401. $Akeywords = explode(",",$hide_keywords);
  402.  
  403.  
  404. function checkKeyWords($Ahaystack, $needle){
  405. foreach($Ahaystack as $value){
  406. if(@stristr(strtolower($needle), strtolower($value))){
  407. return true;
  408. }
  409. }
  410. return false;
  411. }
  412.  
  413. function GetDirArrayRecursive($dir, $filter=false) {
  414. global $Amedia_types, $Ahide_files, $Ahide_folders, $Akeywords;
  415. if($filter){
  416. $Afilter = $filter;
  417. } else {
  418. $Afilter = $Amedia_types;
  419. }
  420. $Afiles = array ();
  421. if(!$dir || $dir == ""){
  422. $dir = ".";
  423. }
  424. $handle=@opendir($dir);
  425. //$d = dir($dir);
  426. if($dir){
  427. while (false !== ($entry = @readdir($handle))){
  428. //while (false !== ($entry = $d->read())) {
  429. if($entry!='.' && $entry!='..') {
  430. $entry = $dir.'/'.str_replace("\\", "/", $entry);
  431. $pathinfo = path_parts($entry);
  432. if(is_dir($entry)) {
  433. if(!checkKeyWords($Ahide_folders, $pathinfo['filename']) && !checkKeyWords($Akeywords, $pathinfo['filename'])){
  434. $Afiles = array_merge($Afiles, GetDirArrayRecursive($entry, $Afilter));
  435. }
  436. } else {
  437. if(in_array(strtolower($pathinfo['ext']), $Afilter)){
  438. if(!checkKeyWords($Ahide_files, $pathinfo['filename']) && !checkKeyWords($Akeywords, $pathinfo['filename'])){
  439. $Afiles[] = $entry;
  440. }
  441. }
  442. }
  443. }
  444. }
  445. @closedir($handle);
  446. //$d->close();
  447. }
  448. return $Afiles;
  449. }
  450.  
  451.  
  452. function GetDirArray($dir){
  453. global $Amedia_types, $Ahide_files, $Ahide_folders, $Akeywords;
  454. $Asee = array();
  455. $Aitems = array ();
  456. $Adirs = array ();
  457. $Afiles = array ();
  458. $handle=@opendir($dir);
  459. //$d = dir(utf8_encode($dir));
  460. if($dir){
  461. while (false !== ($entry = @readdir($handle))){
  462. //while (false !== ($entry = $d->read())) {
  463. if($entry != '.' && $entry != '..' && substr ($entry, 0, 1 ) != "..") {
  464. $entry = $dir.'/'.str_replace("\\", "/", $entry);
  465. $pathinfo = path_parts($entry);
  466. if(is_dir($entry)) {
  467. if(!checkKeyWords($Ahide_folders, $pathinfo['filename']) && !checkKeyWords($Akeywords, $pathinfo['filename'])){
  468. $Adirs[] = $entry;
  469. }
  470. } else {
  471. if(in_array(strtolower($pathinfo['ext']), $Amedia_types)){
  472. if(!checkKeyWords($Ahide_files, $pathinfo['filename']) && !checkKeyWords($Akeywords, $pathinfo['filename'])){
  473. $Afiles[] = $entry;
  474. }
  475. }
  476. }
  477. }
  478. }
  479. @closedir($handle);
  480. //$d->close();
  481. }
  482. $Aitems['dirs'] = $Adirs;
  483. $Aitems['files'] = $Afiles;
  484. return $Aitems;
  485. }
  486.  
  487.  
  488. function array_sort(&$array, $subkey="id", $sortOrder) {
  489.  
  490. if (count($array)){
  491. $temp_array[key($array)] = array_shift($array);
  492. }
  493.  
  494. foreach($array as $key => $val){
  495. $offset = 0;
  496. $found = false;
  497. foreach($temp_array as $tmp_key => $tmp_val){
  498. if(!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey])){
  499. $temp_array = array_merge( (array)array_slice($temp_array,0,$offset),
  500. array($key => $val),
  501. array_slice($temp_array,$offset)
  502. );
  503. $found = true;
  504. }
  505. $offset++;
  506. }
  507. if(!$found) {
  508. $temp_array = array_merge($temp_array, array($key => $val));
  509. }
  510. }
  511.  
  512. if ($sortOrder == "DEC"){
  513. $array = array_reverse($temp_array);
  514. } else if ($sortOrder == "ASC"){
  515. $array = $temp_array;
  516. } else if ($sortOrder == "RND"){
  517. $array = $temp_array;
  518. shuffle($array);
  519. }
  520. }
  521.  
  522.  
  523. function printArray($theArray, $exit=false){
  524. print "<pre>";
  525. print_r($theArray);
  526. print "</pre>";
  527. if($exit){
  528. exit;
  529. }
  530. }
  531.  
  532.  
  533. /////////////////////////////////////////////////////////////
  534. /////////////////////////////////////////////////////////////
  535. /////////////////////////////////////////////////////////////
  536. //
  537. // CONVERSION
  538. //
  539. /////////////////////////////////////////////////////////////
  540. /////////////////////////////////////////////////////////////
  541. /////////////////////////////////////////////////////////////
  542.  
  543.  
  544. function cleanForXML($theString){
  545.  
  546. $retval = str_replace("&", "&amp;", $theString);
  547. $retval = str_replace("<", "&lt;", $retval);
  548. $retval = str_replace(">", "&gt;", $retval);
  549. $retval = str_replace("'", "&apos;", $retval);
  550. $retval = str_replace('"', "&quot;", $retval);
  551.  
  552. return $retval;
  553. }
  554.  
  555.  
  556. /////////////////////////////////////////////////////////////
  557. /////////////////////////////////////////////////////////////
  558. /////////////////////////////////////////////////////////////
  559. //
  560. // XML Playlist
  561. //
  562. /////////////////////////////////////////////////////////////
  563. /////////////////////////////////////////////////////////////
  564. /////////////////////////////////////////////////////////////
  565.  
  566. function returnXMLkeys($AitemInfo){
  567. $retval = "";
  568. foreach($AitemInfo as $key => $val){
  569. $retval .= "<".$key.">".cleanForXML(trim($val))."</".$key.">".newline;
  570. }
  571. return $retval;
  572. }
  573.  
  574.  
  575.  
  576. function makePlaylist($theDir, $recursive=false){
  577. global $pickle_PATH, $pickleApp, $defaultVisualBaseName, $defaultVisualExt, $playlistKind, $sortOrder, $quirksmode, $Amedia_types;
  578.  
  579. $sPath = utf8_decode(rawurldecode($theDir));
  580. if($recursive){
  581. $AdirList['files'] = GetDirArrayRecursive($sPath);
  582. $AdirList['dirs'] = array();
  583. } else {
  584. $AdirList = GetDirArray($sPath);
  585. }
  586.  
  587. array_sort($AdirList['files'], 'filename', $sortOrder);
  588.  
  589. $retval = "";
  590.  
  591. if($playlistKind == "xml"){
  592. $playlistCoverart = cleanForXML(lookForVisual($sPath.slash.$defaultVisualBaseName.".".$defaultVisualExt));
  593. $tackImage = "";
  594. if($playlistCoverart){
  595. $tackImage = ' image="'.$playlistCoverart;
  596. }
  597. $retval = "<playlist$tackImage>".newline;
  598. } else {
  599. $retval = "";
  600. }
  601.  
  602. //////////////////////////////////////////////////////////////
  603. //////////////////////////////////////////////////////////////
  604. //////////////////////////////////////////////////////////////
  605. //////////////////////////////////////////////////////////////
  606. //////////////////////////////////////////////////////////////
  607. //////////////////////////////////////////////////////////////
  608.  
  609.  
  610. // Files
  611. $Afiles = array();
  612.  
  613. if(sizeof($AdirList['files']) > 0){
  614. for($i = 0; $i < sizeof($AdirList['files']); $i++){
  615.  
  616. $tempName = $AdirList['files'][$i];
  617. $path_info = path_parts($tempName);
  618.  
  619. // File URL
  620. $myFileURL = filepath2url($tempName);
  621.  
  622. if($playlistKind == "xml"){
  623.  
  624. $Aitem = array();
  625.  
  626. $Aitem['filename'] = $myFileURL;
  627. $Aitem['image'] = lookForVisual($path_info['basepath'].slash.$path_info['basename'].".".$defaultVisualExt);
  628.  
  629. if(in_array(strtolower($path_info['ext']), $Amedia_types)) {
  630. //if(strtolower($path_info['ext']) == "mp3"){
  631. $Aid3 = getID3info4me($tempName);
  632. } else {
  633. $Aid3 = array();
  634. }
  635.  
  636. // Basic ID3 info:
  637. if($quirksmode){
  638. $Aquirk = explode(".", $path_info['basename']);
  639. array_shift($Aquirk);
  640. $path_info['basename'] = implode($Aquirk);
  641. }
  642.  
  643. $Aitem['artist'] = @$Aid3['artist'];
  644. $Aitem['title'] = (@$Aid3['title'])? @$Aid3['title'] : $path_info['basename'];
  645.  
  646.  
  647. // Image
  648. $retval .= '<item>'.newline;
  649. $retval .= returnXMLkeys($Aitem);
  650. //$retval .= '<filekind>'.strtolower($path_info['ext']).'</filekind>'.newline;
  651. $retval .= "</item>".newline;
  652.  
  653. } else {
  654. $retval .= $myFileURL.newline;
  655. }
  656.  
  657.  
  658. }
  659. }
  660.  
  661. if($playlistKind == "xml"){
  662. $retval .= "</playlist>";
  663. }
  664.  
  665.  
  666. @clearstatcache();
  667. return $retval;
  668.  
  669. }
  670.  
  671. function path_parts($thePath) {
  672. $thePath = str_replace("\\", "/", $thePath);
  673. $filepathA = explode("/", $thePath);
  674. $filename = array_pop($filepathA);
  675. $filepathB = explode(".", $filename);
  676. $extension = array_pop($filepathB);
  677. $basename = implode(".", $filepathB);
  678. $basePath = join("/", $filepathA);
  679. $Aret = array();
  680. $Aret['filename'] = $filename;
  681. $Aret['ext'] = $extension;
  682. $Aret['basename'] = $basename;
  683. $Aret['basepath'] = $basePath;
  684. return $Aret;
  685. }
  686.  
  687. function getID3info4me($theFile_in){
  688. global $getMyid3info, $getID3;
  689. if($getMyid3info == "yes"){
  690. $info = $getID3->analyze(urldecode($theFile_in));
  691. getid3_lib::CopyTagsToComments($info);
  692. } else {
  693. $info = array();
  694. }
  695. $retval = array();
  696. if(sizeof($info)>0){
  697. if(isset($info['comments_html'])){
  698. $Atemp = @$info['comments_html'];
  699. foreach($Atemp as $key => $val){
  700. $retval[$key] = $val[0];
  701. }
  702. $retval['seconds']=(@$info['playtime_seconds']);
  703. }
  704. }
  705. return $retval;
  706. }
  707.  
  708. function lookForVisual($theFile){
  709. global $pickleApp,$defaultVisualBaseName, $defaultVisualExt, $pickle_PATH;
  710. $visualFound = "";
  711. if (@is_file($theFile)){
  712. $visualFound = filepath2url($theFile);
  713. }
  714. return $visualFound;
  715. }
  716.  
  717. function lookForInfo($theFile){
  718. global $pickleApp, $pickle_PATH;
  719. $retval = "";
  720. if(@is_file($theFile)){
  721. $retval = file_get_as_string($theFile);
  722. }
  723. return $retval;
  724. }
  725.  
  726.  
  727. function url2filepath($theURL){
  728. global $pickle_PATH;
  729. $pubPath = str_replace($pickle_PATH['www'], "", $theURL);
  730. $theFilepath = $pickle_PATH['physical'].$pubPath;
  731. $theFilepath = str_replace("//", "/", $theFilepath);
  732. return $theFilepath;
  733. }
  734.  
  735.  
  736. function filepath2url($theFilepath){
  737. global $pickle_PATH;
  738. $pubPath = str_replace($pickle_PATH['physical'], "", $theFilepath);
  739. $theFilepath = $pickle_PATH['www'].$pubPath;
  740. $theFilepath = str_replace("://", "__:__", $theFilepath);
  741. $theFilepath = str_replace("//", "/", $theFilepath);
  742. $theFilepath = str_replace("__:__", "://", $theFilepath);
  743. return $theFilepath;
  744. }
  745.  
  746. /////////////////////////////////////////////////////////////
  747. /////////////////////////////////////////////////////////////
  748. /////////////////////////////////////////////////////////////
  749. //
  750. // WRITE X-HTML
  751. //
  752. /////////////////////////////////////////////////////////////
  753. /////////////////////////////////////////////////////////////
  754. /////////////////////////////////////////////////////////////
  755.  
  756.  
  757. function printXML($theXML){
  758. $XMLlead = '<'.urldecode("%3F").'xml version="1.0" encoding="UTF-8" '.urldecode("%3F").'>';
  759. //*
  760. header("Pragma: public", false);
  761. header("Expires: Thu, 19 Nov 1981 08:52:00 GMT", false);
  762. header("Cache-Control: must-revalidate, post-check=0, pre-check=0", false);
  763. header("Cache-Control: no-store, no-cache, must-revalidate", false);
  764. header("Content-Type: text/xml");
  765. //*/
  766. print (utf8_encode($XMLlead.$theXML));
  767. exit;
  768. }
  769.  
  770. function printTEXT($theList){
  771.  
  772. header("Pragma: public", false);
  773. header("Expires: Thu, 19 Nov 1981 08:52:00 GMT", false);
  774. header("Cache-Control: must-revalidate, post-check=0, pre-check=0", false);
  775. header("Cache-Control: no-store, no-cache, must-revalidate", false);
  776. header("Content-Type: text/plain");
  777.  
  778. print (utf8_encode($theList));
  779. exit;
  780. }
  781.  
  782.  
  783.  
  784. /////////////////////////////////////////////////////////////
  785. /////////////////////////////////////////////////////////////
  786. /////////////////////////////////////////////////////////////
  787. //
  788. // ACTIONS
  789. //
  790. /////////////////////////////////////////////////////////////
  791. /////////////////////////////////////////////////////////////
  792. /////////////////////////////////////////////////////////////
  793.  
  794. if(!isset($action)){
  795. $action = "";
  796. }
  797.  
  798. if($action == "getVersion"){
  799. print "Pickle Auto Playlist Version: $pickleVersion";
  800. exit;
  801. } else if ($action == "dir"){
  802.  
  803. if($getMyid3info == "yes"){
  804. if(is_file('getid3.php')){
  805. require ('getid3.php');
  806. $getID3 = new getID3;
  807. } else if (is_file('getid3'.slash.'getid3.php')){
  808. require ('getid3'.slash.'getid3.php');
  809. $getID3 = new getID3;
  810. } else if (is_file(@$getid3libPath)){
  811. require (@$getid3libPath);
  812. $getID3 = new getID3;
  813. } else {
  814. $getMyid3info = "no";
  815. }
  816. }
  817.  
  818. $setDir = @$_REQUEST['dir'];
  819.  
  820. //if(!$setDir || substr ($setDir, 0, 2 ) == ".." || $setDir.substr(0,1) == "/" || $setDir.substr(0,1) == "\\"){
  821. if(!$setDir || substr ($setDir, 0, 2 ) == ".." || substr($setDir, 0, 1) == "/" || substr($setDir, 0, 1) == "\\"){
  822. $setDir = "";
  823. }
  824.  
  825. if($playlistKind == "xml"){
  826. header("Content-Type: text/xml; charset=utf-8", false);
  827. printXML(makePlaylist(url2filepath($setDir)));
  828. } else {
  829. header("Content-Type: text/plain; charset=utf-8", false);
  830. printTEXT(makePlaylist(url2filepath($setDir)));
  831. }
  832.  
  833. } else {
  834.  
  835. if($getMyid3info == "yes"){
  836. if(is_file('getid3.php')){
  837. require ('getid3.php');
  838. $getID3 = new getID3;
  839. } else if (is_file('getid3'.slash.'getid3.php')){
  840. require ('getid3'.slash.'getid3.php');
  841. $getID3 = new getID3;
  842. } else if (is_file(@$getid3libPath)){
  843. require (@$getid3libPath);
  844. $getID3 = new getID3;
  845. } else {
  846. $getMyid3info = "no";
  847. }
  848. }
  849.  
  850. $getall = false;
  851.  
  852. if($findAllMedia == "yes"){
  853. $getall = true;
  854. }
  855.  
  856. if($playlistKind == "xml"){
  857. header("Content-Type: text/xml; charset=utf-8", false);
  858. printXML(makePlaylist($pickle_PATH['physical'], $getall));
  859. } else {
  860. header("Content-Type: text/plain; charset=utf-8", false);
  861. printTEXT(makePlaylist($pickle_PATH['physical'], $getall));
  862. }
  863. }
  864. ?>
Advertisement
Add Comment
Please, Sign In to add comment