model.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * Klasse für den Datenzugriff
  4. */
  5. class Model {
  6. public static function getSourceBySourceID($sourceID) {
  7. return $GLOBALS['db']->getAllAssocCustom("sources", "ORDER BY `name` ASC", "id", $sourceID);
  8. }
  9. public static function getSeries() {
  10. return $GLOBALS['db']->getAllAssocCustom("series", "ORDER BY `name` ASC");
  11. }
  12. public static function getSeriesBySeriesID($seriesID) {
  13. return $GLOBALS['db']->getAllAssocCustom("series", "ORDER BY `name` ASC", "id", $seriesID);
  14. }
  15. public static function getMovies() {
  16. return $GLOBALS['db']->getAllAssocCustom("movies", "ORDER BY `name` ASC");
  17. }
  18. public static function getSeasonBySeasonID($seasonID) {
  19. return $GLOBALS['db']->getAllAssocCustom("series-seasons", "ORDER BY `number` ASC", "id", $seasonID);
  20. }
  21. public static function getSeasonsBySeriesID($seriesID) {
  22. return $GLOBALS['db']->getAllAssocCustom("series-seasons", "ORDER BY `number` ASC", "series-id", $seriesID);
  23. }
  24. public static function getEpisodesBySeasonID($seasonID) {
  25. return $GLOBALS['db']->getAllAssocCustom("series-episodes", "ORDER BY `number` ASC", "season-id", $seasonID);
  26. }
  27. public static function getEpisodeByID($episodeID) {
  28. return $GLOBALS['db']->getAllAssoc("series-episodes", "id", $episodeID);
  29. }
  30. public static function getAbsouluteVideoPathByEpisodeID($episodeID) {
  31. $episode = self::getEpisodeByID($episodeID);
  32. $season = self::getSeasonBySeasonID($episode[0]['season-id']);
  33. $series = self::getSeriesBySeriesID($season[0]['series-id']);
  34. $source = self::getSourceBySourceID($series[0]['source']);
  35. if($season[0]['number'] < 10) {
  36. return $source[0]['path'] . "/" . $series[0]['path'] . "/S0" . $season[0]['number'] . "/" . $episode[0]['path'];
  37. } else {
  38. return $source[0]['path'] . "/" . $series[0]['path'] . "/S" . $season[0]['number'] . "/" . $episode[0]['path'];
  39. }
  40. }
  41. public static function getUserIDByMail($userMail) {
  42. return $GLOBALS['db']->getAllAssoc("users", "mail", $userMail);
  43. }
  44. public static function getMovieByID($movieID) {
  45. return $GLOBALS['db']->getAllAssoc("movies", "id", $movieID);
  46. }
  47. public static function getAbsouluteVideoPathByMovieID($movieID) {
  48. $movie = self::getMovieByID($movieID);
  49. $source = self::getSourceBySourceID($movie[0]['source']);
  50. return $source[0]['path'] . "/" . $movie[0]['path'];
  51. }
  52. public static function encryptText($text) {
  53. return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $GLOBALS['conf']['encKey'], $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
  54. }
  55. public static function decryptText($text) {
  56. return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $GLOBALS['conf']['encKey'], base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
  57. }
  58. }
  59. ?>