Advertisement
Guest User

Untitled

a guest
Sep 24th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <?php
  2. //class for interacting with files
  3. //
  4. error_reporting(E_ALL);
  5. ini_set('display_errors', -1);
  6.  
  7. class Files {
  8.  
  9. function __construct() {
  10.  
  11. include('mysql.php');
  12. include('Net/SSH2.php');
  13. include('general.php');
  14.  
  15. $this->database =Database::getInstance();
  16. $this->db = $this->database->getConnection();
  17.  
  18. $this->host =getSetting('remote_host', $db);
  19. $this->ssh = new Net_SSH2($this->host);
  20.  
  21.  
  22. }
  23.  
  24. public function listFiles($type, $location) {
  25. // gets a list of files remotely or locally and returns an array of them
  26.  
  27. $remove =array('.', '..', '.present', ' '); //Files and directories to ignore in the array
  28.  
  29.  
  30. switch($type) {
  31. case "1":
  32. //get movies
  33.  
  34.  
  35. if($location =='1')
  36. {
  37. //local
  38. $movie_dir =getSetting('local_movie_dir');
  39. $movies = array_diff(scandir($movie_dir), $remove);
  40.  
  41. return $movies;
  42.  
  43. }
  44. elseif($location =='2')
  45. {
  46. //remote
  47. $movie_dir =getSetting('remote_movie_dir');
  48.  
  49. }
  50. else
  51. {
  52. //Invalid param
  53. return "Invalid paramater for location";
  54. }
  55.  
  56. break;
  57. case "2":
  58. //tv Shows
  59.  
  60. if($location =='1')
  61. {
  62. //local
  63. $tv_dir =getSetting('local_tv_dir');
  64. $tv =array_diff(scandir($tv_dir), $remove);
  65.  
  66. return $tv;
  67.  
  68. }
  69. elseif($location =='2')
  70. {
  71. //remote
  72. $tv_dir =getSetting('remote_tv_dir');
  73.  
  74. }
  75. else
  76. {
  77. //Invalid param
  78. return "Invalid paramater for location";
  79. }
  80.  
  81. break;
  82. }
  83. }
  84.  
  85. }
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement