functions.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <?php
  2. function registration_callback($username, $email, $userdir){
  3. global $data;
  4. $data = array($username, $email, $userdir);
  5. }
  6. function printArray($arrayName){
  7. $messageCount = count($arrayName);
  8. $i = 0;
  9. foreach ( $arrayName as $item ) :
  10. $i++;
  11. if($i < $messageCount) :
  12. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  13. elseif($i = $messageCount) :
  14. echo "<small class='text-uppercase'>" . $item . "</small>";
  15. endif;
  16. endforeach;
  17. }
  18. function write_ini_file($content, $path) {
  19. if (!$handle = fopen($path, 'w')) {
  20. return false;
  21. }
  22. $success = fwrite($handle, trim($content));
  23. fclose($handle);
  24. return $success;
  25. }
  26. function getTimezone(){
  27. $regions = array(
  28. 'Africa' => DateTimeZone::AFRICA,
  29. 'America' => DateTimeZone::AMERICA,
  30. 'Antarctica' => DateTimeZone::ANTARCTICA,
  31. 'Arctic' => DateTimeZone::ARCTIC,
  32. 'Asia' => DateTimeZone::ASIA,
  33. 'Atlantic' => DateTimeZone::ATLANTIC,
  34. 'Australia' => DateTimeZone::AUSTRALIA,
  35. 'Europe' => DateTimeZone::EUROPE,
  36. 'Indian' => DateTimeZone::INDIAN,
  37. 'Pacific' => DateTimeZone::PACIFIC
  38. );
  39. $timezones = array();
  40. foreach ($regions as $name => $mask) {
  41. $zones = DateTimeZone::listIdentifiers($mask);
  42. foreach($zones as $timezone) {
  43. $time = new DateTime(NULL, new DateTimeZone($timezone));
  44. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  45. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  46. }
  47. }
  48. print '<select name="timezone" id="timezone" class="form-control material" required>';
  49. foreach($timezones as $region => $list) {
  50. print '<optgroup label="' . $region . '">' . "\n";
  51. foreach($list as $timezone => $name) {
  52. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  53. }
  54. print '</optgroup>' . "\n";
  55. }
  56. print '</select>';
  57. }
  58. function explosion($string, $position){
  59. $getWord = explode("|", $string);
  60. return $getWord[$position];
  61. }
  62. function getServerPath() {
  63. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  64. $protocol = "https://";
  65. } else {
  66. $protocol = "http://";
  67. }
  68. return $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']);
  69. }
  70. function get_browser_name() {
  71. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  72. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  73. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  74. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  75. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  76. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  77. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  78. return 'Other';
  79. }
  80. function getPlexRecent($url, $port, $type, $token, $size, $header){
  81. $address = $url.":".$port;
  82. $api = simplexml_load_file($address."/library/recentlyAdded?X-Plex-Token=".$token);
  83. $i = 0;
  84. $gotPlex = '<div class="col-lg-'.$size.'"><h5 class="text-center">'.$header.'</h5><div id="carousel-'.$type.'" class="carousel slide box-shadow white-bg" data-ride="carousel"><div class="carousel-inner" role="listbox">';
  85. foreach($api AS $child) {
  86. if($child['type'] == $type){
  87. $i++;
  88. if($i == 1){ $active = "active"; }else{ $active = "";}
  89. $thumb = $child['thumb'];
  90. if($type == "movie"){
  91. $title = $child['title'];
  92. $summary = $child['summary'];
  93. }elseif($type == "season"){
  94. $title = $child['parentTitle'];
  95. $summary = $child['parentSummary'];
  96. }elseif($type == "album"){
  97. $title = $child['parentTitle'];
  98. $summary = $child['title'];
  99. }
  100. $gotPlex .= '<div class="item '.$active.'"><img class="carousel-image '.$type.'" src="image.php?img='.$address.$thumb.'"><div class="carousel-caption '.$type.'" style="overflow:auto"><h4>'.$title.'</h4><small><em>'.$summary.'</em></small></div></div>';
  101. }
  102. }
  103. $gotPlex .= '</div>';
  104. if ($i > 1){
  105. $gotPlex .= '<a class="left carousel-control '.$type.'" href="#carousel-'.$type.'" role="button" data-slide="prev"><span class="fa fa-chevron-left" aria-hidden="true"></span><span class="sr-only">Previous</span></a><a class="right carousel-control '.$type.'" href="#carousel-'.$type.'" role="button" data-slide="next"><span class="fa fa-chevron-right" aria-hidden="true"></span><span class="sr-only">Next</span></a>';
  106. }
  107. $gotPlex .= '</div>';
  108. $gotPlex .= '</div>';
  109. if ($i != 0){ return $gotPlex; }
  110. }
  111. function getPlexStreams($url, $port, $token, $size){
  112. $address = $url.":".$port;
  113. $api = simplexml_load_file($address."/status/sessions?X-Plex-Token=".$token);
  114. $i = 0;
  115. $gotPlex = '<div class="col-lg-'.$size.'">';
  116. $gotPlex .= '<div id="carousel-streams" class="carousel slide box-shadow white-bg" data-ride="carousel">';
  117. $gotPlex .= '<div class="carousel-inner" role="listbox">';
  118. foreach($api AS $child) {
  119. $type = $child['type'];
  120. $i++;
  121. if($i == 1){ $active = "active"; }else{ $active = "";}
  122. if($type == "movie"){
  123. $title = $child['title'];
  124. $summary = $child['summary'];
  125. $thumb = $child['thumb'];
  126. $image = "movie";
  127. }elseif($type == "episode"){
  128. $title = $child['grandparentTitle'];
  129. $summary = $child['summary'];
  130. $thumb = $child['parentThumb'];
  131. $image = "season";
  132. }elseif($type == "track"){
  133. $title = $child['grandparentTitle'] . " - " . $child['parentTitle'];
  134. $summary = $child['title'];
  135. $thumb = $child['thumb'];
  136. $image = "album";
  137. }
  138. $gotPlex .= '<div class="item '.$active.'">';
  139. $gotPlex .= "<img class='carousel-image $image' src='image.php?img=$address$thumb'>";
  140. $gotPlex .= '<div class="carousel-caption '. $image . '" style="overflow:auto">';
  141. $gotPlex .= '<h4>'.$title.'</h4>';
  142. $gotPlex .= '<small><em>'.$summary.'</em></small>';
  143. $gotPlex .= '</div>';
  144. $gotPlex .= '</div>';
  145. }
  146. $gotPlex .= '</div>';
  147. if ($i > 1){
  148. $gotPlex .= '<a class="left carousel-control streams" href="#carousel-streams" role="button" data-slide="prev">';
  149. $gotPlex .= '<span class="fa fa-chevron-left" aria-hidden="true"></span>';
  150. $gotPlex .= '<span class="sr-only">Previous</span>';
  151. $gotPlex .= '</a>';
  152. $gotPlex .= '<a class="right carousel-control streams" href="#carousel-streams" role="button" data-slide="next">';
  153. $gotPlex .= '<span class="fa fa-chevron-right" aria-hidden="true"></span>';
  154. $gotPlex .= '<span class="sr-only">Next</span>';
  155. $gotPlex .= '</a>';
  156. }
  157. $gotPlex .= '</div>';
  158. $gotPlex .= '</div>';
  159. if ($i != 0){ return $gotPlex; }
  160. }
  161. ?>