Browse Source

Landing Page Testing plus small fixes

Added options for upcoming landing page, for now create a new tab called
homepage.php - Plex integration to start, more to come later.  Requires
SimpleXML to be installed.
Moved php functions to file called functions.
Fixed small error on error page
Added more translation strings
causefx 9 years ago
parent
commit
c088e5fa33
16 changed files with 801 additions and 249 deletions
  1. 1 0
      .gitignore
  2. 1 0
      check.php
  3. 2 2
      error.php
  4. 291 0
      functions.php
  5. 260 0
      homepage.php
  6. 23 0
      image.php
  7. 1 100
      index.php
  8. 13 1
      lang/de.ini
  9. 13 1
      lang/en.ini
  10. 13 1
      lang/es.ini
  11. 13 1
      lang/fr.ini
  12. 13 1
      lang/it.ini
  13. 13 1
      lang/nl.ini
  14. 13 1
      lang/pl.ini
  15. 115 139
      settings.php
  16. 16 1
      user.php

+ 1 - 0
.gitignore

@@ -50,6 +50,7 @@ Temporary Items
 # Organizr files
 # =========================
 databaseLocation.ini.php
+homepageSettings.ini.php
 loginLog.json
 custom.css
 _config.yml

+ 1 - 0
check.php

@@ -165,6 +165,7 @@ $folder = USER_HOME;
                 check("Zip");
                 check("openssl");
                 check("session");
+                check("simplexml");
                 checkFunction("MAIL");
                 checkFunction("fopen");
 

+ 2 - 2
error.php

@@ -131,7 +131,7 @@ endif;
         <title><?=$errorTitle;?></title>
 
         <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
-        <link rel="stylesheet" href="/bower_components/bower_components/Waves/dist/waves.min.css"> 
+        <link rel="stylesheet" href="/bower_components/Waves/dist/waves.min.css"> 
         <link rel="stylesheet" href="/css/style.css">
         
     </head>
@@ -160,7 +160,7 @@ endif;
                 
                                     <div class="big-box text-left">
                 
-                                        <center><img src="images/<?=$errorImage;?>.png" style="height: 200px;"></center>
+                                        <center><img src="/images/<?=$errorImage;?>.png" style="height: 200px;"></center>
                                         <h4 style="color: <?=$topbar;?>;" class="text-center"><?php echo $message;?></h4>
 
                                         <button style="background:<?=$topbar;?>;" onclick="goBack()" type="button" class="btn log-in btn-block btn-primary text-uppercase waves waves-effect waves-float"><text style="color:<?=$topbartext;?>;"><?php echo $language->translate("GO_BACK");?></text></button>					                                    

+ 291 - 0
functions.php

@@ -0,0 +1,291 @@
+<?php
+
+function registration_callback($username, $email, $userdir){
+    
+    global $data;
+    
+    $data = array($username, $email, $userdir);
+
+}
+
+function printArray($arrayName){
+    
+    $messageCount = count($arrayName);
+    
+    $i = 0;
+    
+    foreach ( $arrayName as $item ) :
+    
+        $i++; 
+    
+        if($i < $messageCount) :
+    
+            echo "<small class='text-uppercase'>" . $item . "</small> & ";
+    
+        elseif($i = $messageCount) :
+    
+            echo "<small class='text-uppercase'>" . $item . "</small>";
+    
+        endif;
+        
+    endforeach;
+    
+}
+
+function write_ini_file($content, $path) { 
+    
+    if (!$handle = fopen($path, 'w')) {
+        
+        return false; 
+    
+    }
+    
+    $success = fwrite($handle, trim($content));
+    
+    fclose($handle); 
+    
+    return $success; 
+
+}
+
+function getTimezone(){
+
+    $regions = array(
+        'Africa' => DateTimeZone::AFRICA,
+        'America' => DateTimeZone::AMERICA,
+        'Antarctica' => DateTimeZone::ANTARCTICA,
+        'Arctic' => DateTimeZone::ARCTIC,
+        'Asia' => DateTimeZone::ASIA,
+        'Atlantic' => DateTimeZone::ATLANTIC,
+        'Australia' => DateTimeZone::AUSTRALIA,
+        'Europe' => DateTimeZone::EUROPE,
+        'Indian' => DateTimeZone::INDIAN,
+        'Pacific' => DateTimeZone::PACIFIC
+    );
+    
+    $timezones = array();
+
+    foreach ($regions as $name => $mask) {
+        
+        $zones = DateTimeZone::listIdentifiers($mask);
+
+        foreach($zones as $timezone) {
+
+            $time = new DateTime(NULL, new DateTimeZone($timezone));
+
+            $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
+
+            $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
+
+        }
+        
+    }   
+    
+    print '<select name="timezone" id="timezone" class="form-control material" required>';
+    
+    foreach($timezones as $region => $list) {
+    
+        print '<optgroup label="' . $region . '">' . "\n";
+    
+        foreach($list as $timezone => $name) {
+            
+            print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
+    
+        }
+    
+        print '</optgroup>' . "\n";
+    
+    }
+    
+    print '</select>';
+    
+}
+
+function explosion($string, $position){
+    
+    $getWord = explode("|", $string);
+    return $getWord[$position];
+    
+}
+
+function getServerPath() {
+    
+    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { 
+        
+        $protocol = "https://"; 
+    
+    } else {  
+        
+        $protocol = "http://"; 
+    
+    }
+    
+    return $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']);
+      
+}
+
+function get_browser_name() {
+    
+    $user_agent = $_SERVER['HTTP_USER_AGENT'];
+    
+    if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
+    elseif (strpos($user_agent, 'Edge')) return 'Edge';
+    elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
+    elseif (strpos($user_agent, 'Safari')) return 'Safari';
+    elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
+    elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
+    
+    return 'Other';
+    
+}
+
+function getPlexRecent($url, $port, $type, $token, $size, $header){
+    
+    $address = $url.":".$port;
+    
+    $api = simplexml_load_file($address."/library/recentlyAdded?X-Plex-Token=".$token);
+    
+    $i = 0;
+    
+    $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">';
+        
+    foreach($api AS $child) {
+     
+        if($child['type'] == $type){
+            
+            $i++;
+            
+            if($i == 1){ $active = "active"; }else{ $active = "";}
+            
+            $thumb = $child['thumb'];
+            if($type == "movie"){ 
+                
+                $title = $child['title']; 
+                $summary = $child['summary'];
+            
+            }elseif($type == "season"){ 
+                
+                $title = $child['parentTitle'];
+                $summary = $child['parentSummary'];
+            
+            }elseif($type == "album"){
+                
+                $title = $child['parentTitle']; 
+                $summary = $child['title'];
+            
+            }
+            
+            
+            $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>';
+
+        }
+        
+    }
+    
+    $gotPlex .= '</div>';
+    
+    if ($i > 1){ 
+
+        $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>';
+        
+    }
+
+    $gotPlex .= '</div>';
+
+    $gotPlex .= '</div>';
+    
+    if ($i != 0){ return $gotPlex; }
+
+}
+
+function getPlexStreams($url, $port, $token, $size){
+    
+    $address = $url.":".$port;
+    
+    $api = simplexml_load_file($address."/status/sessions?X-Plex-Token=".$token);
+    
+    $i = 0;
+    
+    $gotPlex = '<div class="col-lg-'.$size.'">';
+    $gotPlex .= '<div id="carousel-streams" class="carousel slide box-shadow white-bg" data-ride="carousel">';
+    $gotPlex .= '<div class="carousel-inner" role="listbox">';
+        
+    foreach($api AS $child) {
+     
+        $type = $child['type'];
+            
+        $i++;
+
+        if($i == 1){ $active = "active"; }else{ $active = "";}
+
+        
+        if($type == "movie"){ 
+
+            $title = $child['title']; 
+            $summary = $child['summary'];
+            $thumb = $child['thumb'];
+            $image = "movie";
+
+        }elseif($type == "episode"){ 
+
+            $title = $child['grandparentTitle'];
+            $summary = $child['summary'];
+            $thumb = $child['parentThumb'];
+            $image = "season";
+
+
+        }elseif($type == "track"){
+
+            $title = $child['grandparentTitle'] . " - " . $child['parentTitle']; 
+            $summary = $child['title'];
+            $thumb = $child['thumb'];
+            $image = "album";
+
+        }
+
+        $gotPlex .= '<div class="item '.$active.'">';
+
+        $gotPlex .= "<img class='carousel-image $image' src='image.php?img=$address$thumb'>";
+
+        $gotPlex .= '<div class="carousel-caption '. $image . '" style="overflow:auto">';
+
+        $gotPlex .= '<h4>'.$title.'</h4>';
+
+        $gotPlex .= '<small><em>'.$summary.'</em></small>';
+
+        $gotPlex .= '</div>';
+
+        $gotPlex .= '</div>';
+
+        
+    }
+    
+    $gotPlex .= '</div>';
+    
+    if ($i > 1){ 
+
+        $gotPlex .= '<a class="left carousel-control streams" href="#carousel-streams" role="button" data-slide="prev">';
+
+        $gotPlex .= '<span class="fa fa-chevron-left" aria-hidden="true"></span>';
+        $gotPlex .= '<span class="sr-only">Previous</span>';
+
+        $gotPlex .= '</a>';
+
+        $gotPlex .= '<a class="right carousel-control streams" href="#carousel-streams" role="button" data-slide="next">';
+
+        $gotPlex .= '<span class="fa fa-chevron-right" aria-hidden="true"></span>';
+        $gotPlex .= '<span class="sr-only">Next</span>';
+
+        $gotPlex .= '</a>';
+        
+    }
+
+    $gotPlex .= '</div>';
+
+    $gotPlex .= '</div>';
+    
+    if ($i != 0){ return $gotPlex; }
+
+}
+
+?>

+ 260 - 0
homepage.php

@@ -0,0 +1,260 @@
+<?php
+
+$data = false;
+
+ini_set("display_errors", 1);
+ini_set("error_reporting", E_ALL | E_STRICT);
+
+require_once("user.php");
+require_once("translate.php");
+require_once("functions.php");
+$USER = new User("registration_callback");
+
+$dbfile = DATABASE_LOCATION  . constant('User::DATABASE_NAME') . ".db";
+
+$file_db = new PDO("sqlite:" . $dbfile);
+$file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+$dbOptions = $file_db->query('SELECT name FROM sqlite_master WHERE type="table" AND name="options"');
+
+$hasOptions = "No";
+
+foreach($dbOptions as $row) :
+
+    if (in_array("options", $row)) :
+    
+        $hasOptions = "Yes";
+    
+    endif;
+
+endforeach;
+
+if($hasOptions == "No") :
+
+    $title = "Organizr";
+    $topbar = "#333333"; 
+    $topbartext = "#66D9EF";
+    $bottombar = "#333333";
+    $sidebar = "#393939";
+    $hoverbg = "#AD80FD";
+    $activetabBG = "#F92671";
+    $activetabicon = "#FFFFFF";
+    $activetabtext = "#FFFFFF";
+    $inactiveicon = "#66D9EF";
+    $inactivetext = "#66D9EF";
+    $loading = "#66D9EF";
+    $hovertext = "#000000";
+
+endif;
+
+if($hasOptions == "Yes") :
+
+    $resulto = $file_db->query('SELECT * FROM options'); 
+                                    
+    foreach($resulto as $row) : 
+
+        $title = isset($row['title']) ? $row['title'] : "Organizr";
+        $topbartext = isset($row['topbartext']) ? $row['topbartext'] : "#66D9EF";
+        $topbar = isset($row['topbar']) ? $row['topbar'] : "#333333";
+        $bottombar = isset($row['bottombar']) ? $row['bottombar'] : "#333333";
+        $sidebar = isset($row['sidebar']) ? $row['sidebar'] : "#393939";
+        $hoverbg = isset($row['hoverbg']) ? $row['hoverbg'] : "#AD80FD";
+        $activetabBG = isset($row['activetabBG']) ? $row['activetabBG'] : "#F92671";
+        $activetabicon = isset($row['activetabicon']) ? $row['activetabicon'] : "#FFFFFF";
+        $activetabtext = isset($row['activetabtext']) ? $row['activetabtext'] : "#FFFFFF";
+        $inactiveicon = isset($row['inactiveicon']) ? $row['inactiveicon'] : "#66D9EF";
+        $inactivetext = isset($row['inactivetext']) ? $row['inactivetext'] : "#66D9EF";
+        $loading = isset($row['loading']) ? $row['loading'] : "#66D9EF";
+        $hovertext = isset($row['hovertext']) ? $row['hovertext'] : "#000000";
+
+    endforeach;
+
+endif;
+
+?>
+
+<!DOCTYPE html>
+
+<html lang="en" class="no-js">
+
+    <head>
+        
+        <meta charset="UTF-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1.0">
+        <meta http-equiv="X-UA-Compatible" content="IE=edge">
+        <meta name="msapplication-tap-highlight" content="no" />
+
+        <title>Settings</title>
+
+        <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
+        <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
+        <link rel="stylesheet" href="bower_components/mdi/css/materialdesignicons.min.css">
+        <link rel="stylesheet" href="bower_components/metisMenu/dist/metisMenu.min.css">
+        <link rel="stylesheet" href="bower_components/Waves/dist/waves.min.css"> 
+        <link rel="stylesheet" href="bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css"> 
+
+        <link rel="stylesheet" href="js/selects/cs-select.css">
+        <link rel="stylesheet" href="js/selects/cs-skin-elastic.css">
+        <link href="bower_components/iconpick/dist/css/fontawesome-iconpicker.min.css" rel="stylesheet">
+        <link rel="stylesheet" href="bower_components/google-material-color/dist/palette.css">
+        
+        <link rel="stylesheet" href="bower_components/sweetalert/dist/sweetalert.css">
+        <link rel="stylesheet" href="bower_components/smoke/dist/css/smoke.min.css">
+
+        <script src="js/menu/modernizr.custom.js"></script>
+        <script type="text/javascript" src="js/sha1.js"></script>
+        <script type="text/javascript" src="js/user.js"></script>
+        <link rel="stylesheet" href="bower_components/animate.css/animate.min.css">
+        <link rel="stylesheet" href="bower_components/DataTables/media/css/jquery.dataTables.css">
+        <link rel="stylesheet" href="bower_components/datatables-tabletools/css/dataTables.tableTools.css">
+        <link rel="stylesheet" href="bower_components/numbered/jquery.numberedtextarea.css">
+
+        <link rel="stylesheet" href="css/style.css">
+        <link href="css/jquery.filer.css" rel="stylesheet">
+	    <link href="css/jquery.filer-dragdropbox-theme.css" rel="stylesheet">
+
+        <!--[if lt IE 9]>
+        <script src="bower_components/html5shiv/dist/html5shiv.min.js"></script>
+        <script src="bower_components/respondJs/dest/respond.min.js"></script>
+        <![endif]-->
+        
+        <style>
+        
+            .carousel-image{
+                width: 100px !important;
+                height: 150px !important;
+                border-radius: 3px 0 0 3px;  
+            }.carousel-image.album{
+                width: 150px !important;
+                height: 150px !important;
+                border-radius: 3px 0 0 3px;  
+            }.carousel-control.album {
+                top: 5px !important;
+                width: 4% !important;
+            }.carousel-control {
+                top: 5px !important;
+                width: 4% !important;
+            }.carousel-caption.album {
+                position: absolute;
+                right: 4%;
+                top: 0px;
+                left: 160px;
+                z-index: 10;
+                bottom: 0px;
+                padding-top: 0px;
+                color: #fff;
+                text-align: left;
+            }.carousel-caption {
+                position: absolute;
+                right: 4%;
+                top: 0px;
+                left: 110px;
+                z-index: 10;
+                bottom: 0px;
+                padding-top: 0px;
+                color: #fff;
+                text-align: left;
+                padding-bottom: 2px !important;
+            }<?php if(CUSTOMCSS == "true") : 
+$template_file = "custom.css";
+$file_handle = fopen($template_file, "rb");
+echo fread($file_handle, filesize($template_file));
+fclose($file_handle);
+echo "\n";
+endif; ?>        
+        
+        </style>
+        
+    </head>
+
+    <body class="" style="padding: 0px;">
+
+        <div class="main-wrapper" style="position: initial;">
+            
+            <div id="content" class="container-fluid">
+            
+                <div class="row">
+
+                    <?php
+                    $plexSize = 0;
+                    if(PLEXRECENTMOVIE == "true"){ $plexSize++; }
+                    if(PLEXRECENTTV == "true"){ $plexSize++; }
+                    if(PLEXRECENTMUSIC == "true"){ $plexSize++; }
+                    if($plexSize >= 3){ $plexSize = 4; }elseif($plexSize == 2){ $plexSize = 6; }elseif($plexSize == 1){ $plexSize = 12; }
+
+                    if($plexSize > 0){ echo '<h2 class="text-center">' . $language->translate("RECENTLY_ADDED_TO_PLEX") . '</h2>'; }
+                    
+                    if(PLEXRECENTMOVIE == "true"){ echo getPlexRecent(PLEXURL, PLEXPORT, "movie", PLEXTOKEN, $plexSize, $language->translate("MOVIES")); }
+                    if(PLEXRECENTTV == "true"){ echo getPlexRecent(PLEXURL, PLEXPORT, "season", PLEXTOKEN, $plexSize, $language->translate("TV_SHOWS")); }
+                    if(PLEXRECENTMUSIC == "true"){ echo getPlexRecent(PLEXURL, PLEXPORT, "album", PLEXTOKEN, $plexSize, $language->translate("MUSIC")); }
+                    ?>
+
+                </div>
+                
+                <div class="row">
+                    <?php
+                    if(PLEXPLAYINGNOW == "true"){ echo '<h2 class="text-center">' . $language->translate("PLAYING_NOW_ON_PLEX") . '</h2>'; echo getPlexStreams(PLEXURL, PLEXPORT, PLEXTOKEN, 12); }
+                    ?>                                        
+                </div>
+
+            </div>    
+                
+        </div>
+        
+        <!--Scripts-->
+        <script src="bower_components/jquery/dist/jquery.min.js"></script>
+        <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
+        <script src="bower_components/metisMenu/dist/metisMenu.min.js"></script>
+        <script src="bower_components/Waves/dist/waves.min.js"></script>
+        <script src="bower_components/moment/min/moment.min.js"></script>
+        <script src="bower_components/jquery.nicescroll/jquery.nicescroll.min.js"></script>
+        <script src="bower_components/slimScroll/jquery.slimscroll.min.js"></script>
+        <script src="bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.js"></script>
+        <script src="bower_components/cta/dist/cta.min.js"></script>
+
+        <!--Menu-->
+        <script src="js/menu/classie.js"></script>
+        <script src="bower_components/iconpick/dist/js/fontawesome-iconpicker.js"></script>
+
+
+        <!--Selects-->
+        <script src="js/selects/selectFx.js"></script>
+        <script src="js/jscolor.js"></script>
+        
+        <script src="bower_components/sweetalert/dist/sweetalert.min.js"></script>
+
+        <script src="bower_components/smoke/dist/js/smoke.min.js"></script>
+        <script src="bower_components/numbered/jquery.numberedtextarea.js"></script>
+
+
+        <!--Notification-->
+        <script src="js/notifications/notificationFx.js"></script>
+
+        <script src="js/jqueri_ui_custom/jquery-ui.min.js"></script>
+        <script src="js/jquery.filer.min.js" type="text/javascript"></script>
+	    <script src="js/custom.js" type="text/javascript"></script>
+	    <script src="js/jquery.mousewheel.min.js" type="text/javascript"></script>
+        
+        <!--Data Tables-->
+        <script src="bower_components/DataTables/media/js/jquery.dataTables.js"></script>
+        <script src="bower_components/datatables.net-responsive/js/dataTables.responsive.js"></script>
+        <script src="bower_components/datatables-tabletools/js/dataTables.tableTools.js"></script>
+        
+        <script>
+        
+        $( document ).ready(function() {
+            
+            $(".carousel-caption").mCustomScrollbar({
+                theme:"inset-2",
+                scrollInertia: 300,
+                autoHideScrollbar: true,
+                autoExpandScrollbar: true
+            });
+            
+        });
+             
+        </script>
+
+    </body>
+
+</html>

+ 23 - 0
image.php

@@ -0,0 +1,23 @@
+<?php
+
+require_once("user.php");
+
+$image_url = $_GET['img'];
+
+$plexAddress = PLEXURL.':'.PLEXPORT;
+
+$addressPosition = strpos($image_url, $plexAddress);
+
+if($addressPosition !== false && $addressPosition == 0) {
+    
+	$image_src = $image_url . '?X-Plex-Token=' . PLEXTOKEN;
+    
+	header('Content-type: image/jpeg');
+    
+	readfile($image_src);
+    
+} else {
+    
+    echo "Bad Plex Image Url";	
+    
+}

+ 1 - 100
index.php

@@ -26,107 +26,8 @@ $hovertext = "#000000";
 $loadingIcon = "images/organizr.png";
 $baseURL = "";
 require_once("translate.php");
+require_once("functions.php");
 
-function registration_callback($username, $email, $userdir){
-    
-    global $data;
-    
-    $data = array($username, $email, $userdir);
-
-}
-
-function printArray($arrayName){
-    
-    $messageCount = count($arrayName);
-    
-    $i = 0;
-    
-    foreach ( $arrayName as $item ) :
-    
-        $i++; 
-    
-        if($i < $messageCount) :
-    
-            echo "<small class='text-uppercase'>" . $item . "</small> & ";
-    
-        elseif($i = $messageCount) :
-    
-            echo "<small class='text-uppercase'>" . $item . "</small>";
-    
-        endif;
-        
-    endforeach;
-    
-}
-
-function write_ini_file($content, $path) { 
-    
-    if (!$handle = fopen($path, 'w')) {
-        
-        return false; 
-    
-    }
-    
-    $success = fwrite($handle, trim($content));
-    
-    fclose($handle); 
-    
-    return $success; 
-
-}
-
-function getTimezone(){
-
-    $regions = array(
-        'Africa' => DateTimeZone::AFRICA,
-        'America' => DateTimeZone::AMERICA,
-        'Antarctica' => DateTimeZone::ANTARCTICA,
-        'Arctic' => DateTimeZone::ARCTIC,
-        'Asia' => DateTimeZone::ASIA,
-        'Atlantic' => DateTimeZone::ATLANTIC,
-        'Australia' => DateTimeZone::AUSTRALIA,
-        'Europe' => DateTimeZone::EUROPE,
-        'Indian' => DateTimeZone::INDIAN,
-        'Pacific' => DateTimeZone::PACIFIC
-    );
-    
-    $timezones = array();
-
-    foreach ($regions as $name => $mask) {
-        
-        $zones = DateTimeZone::listIdentifiers($mask);
-
-        foreach($zones as $timezone) {
-
-            $time = new DateTime(NULL, new DateTimeZone($timezone));
-
-            $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
-
-            $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
-
-        }
-        
-    }   
-    
-    print '<select name="timezone" id="timezone" class="form-control material" required>';
-    
-    foreach($timezones as $region => $list) {
-    
-        print '<optgroup label="' . $region . '">' . "\n";
-    
-        foreach($list as $timezone => $name) {
-            
-            print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
-    
-        }
-    
-        print '</optgroup>' . "\n";
-    
-    }
-    
-    print '</select>';
-    
-}
                 
 if(isset($_POST['action'])) :
 

+ 13 - 1
lang/de.ini

@@ -170,4 +170,16 @@ EDIT_CUSTOM_CSS = "Eigenes CSS"
 CUSTOM_COMPLETE = "EIGENES CSS GESPEICHERT!"
 SAVE_CSS = "CSS speichern"
 MENU = "Menu"
-GRAVATAR = "Gravatar"
+GRAVATAR = "Gravatar"
+PLEX_URL = "Plex URL"
+PLEX_PORT = "Plex Port"
+PLEX_TOKEN = "Plex Token"
+RECENT_MOVIES = "Recent Movies"
+RECENT_TV = "Recent TV"
+RECENT_MUSIC = "Recent Music"
+PLAYING_NOW = "Playing Now"
+PLAYING_NOW_ON_PLEX = "Playing Now on PLEX"
+RECENTLY_ADDED_TO_PLEX = "Recently Added to PLEX"
+MOVIES = "Movies"
+TV_SHOWS = "TV Shows"
+MUSIC = "Music"

+ 13 - 1
lang/en.ini

@@ -170,4 +170,16 @@ EDIT_CUSTOM_CSS = "Custom CSS"
 CUSTOM_COMPLETE = "CUSTOM CSS SAVED!"
 SAVE_CSS = "Save CSS"
 MENU = "Menu"
-GRAVATAR = "Gravatar"
+GRAVATAR = "Gravatar"
+PLEX_URL = "Plex URL"
+PLEX_PORT = "Plex Port"
+PLEX_TOKEN = "Plex Token"
+RECENT_MOVIES = "Recent Movies"
+RECENT_TV = "Recent TV"
+RECENT_MUSIC = "Recent Music"
+PLAYING_NOW = "Playing Now"
+PLAYING_NOW_ON_PLEX = "Playing Now on PLEX"
+RECENTLY_ADDED_TO_PLEX = "Recently Added to PLEX"
+MOVIES = "Movies"
+TV_SHOWS = "TV Shows"
+MUSIC = "Music"

+ 13 - 1
lang/es.ini

@@ -170,4 +170,16 @@ EDIT_CUSTOM_CSS = "Custom CSS"
 CUSTOM_COMPLETE = "CUSTOM CSS SAVED!"
 SAVE_CSS = "Save CSS"
 MENU = "Menu"
-GRAVATAR = "Gravatar"
+GRAVATAR = "Gravatar"
+PLEX_URL = "Plex URL"
+PLEX_PORT = "Plex Port"
+PLEX_TOKEN = "Plex Token"
+RECENT_MOVIES = "Recent Movies"
+RECENT_TV = "Recent TV"
+RECENT_MUSIC = "Recent Music"
+PLAYING_NOW = "Playing Now"
+PLAYING_NOW_ON_PLEX = "Playing Now on PLEX"
+RECENTLY_ADDED_TO_PLEX = "Recently Added to PLEX"
+MOVIES = "Movies"
+TV_SHOWS = "TV Shows"
+MUSIC = "Music"

+ 13 - 1
lang/fr.ini

@@ -170,4 +170,16 @@ EDIT_CUSTOM_CSS = "Custom CSS"
 CUSTOM_COMPLETE = "CUSTOM CSS SAVED!"
 SAVE_CSS = "Save CSS"
 MENU = "Menu"
-GRAVATAR = "Gravatar"
+GRAVATAR = "Gravatar"
+PLEX_URL = "Plex URL"
+PLEX_PORT = "Plex Port"
+PLEX_TOKEN = "Plex Token"
+RECENT_MOVIES = "Recent Movies"
+RECENT_TV = "Recent TV"
+RECENT_MUSIC = "Recent Music"
+PLAYING_NOW = "Playing Now"
+PLAYING_NOW_ON_PLEX = "Playing Now on PLEX"
+RECENTLY_ADDED_TO_PLEX = "Recently Added to PLEX"
+MOVIES = "Movies"
+TV_SHOWS = "TV Shows"
+MUSIC = "Music"

+ 13 - 1
lang/it.ini

@@ -170,4 +170,16 @@ EDIT_CUSTOM_CSS = "Custom CSS"
 CUSTOM_COMPLETE = "CUSTOM CSS SAVED!"
 SAVE_CSS = "Save CSS"
 MENU = "Menu"
-GRAVATAR = "Gravatar"
+GRAVATAR = "Gravatar"
+PLEX_URL = "Plex URL"
+PLEX_PORT = "Plex Port"
+PLEX_TOKEN = "Plex Token"
+RECENT_MOVIES = "Recent Movies"
+RECENT_TV = "Recent TV"
+RECENT_MUSIC = "Recent Music"
+PLAYING_NOW = "Playing Now"
+PLAYING_NOW_ON_PLEX = "Playing Now on PLEX"
+RECENTLY_ADDED_TO_PLEX = "Recently Added to PLEX"
+MOVIES = "Movies"
+TV_SHOWS = "TV Shows"
+MUSIC = "Music"

+ 13 - 1
lang/nl.ini

@@ -170,4 +170,16 @@ EDIT_CUSTOM_CSS = "Custom CSS"
 CUSTOM_COMPLETE = "CUSTOM CSS SAVED!"
 SAVE_CSS = "Save CSS"
 MENU = "Menu"
-GRAVATAR = "Gravatar"
+GRAVATAR = "Gravatar"
+PLEX_URL = "Plex URL"
+PLEX_PORT = "Plex Port"
+PLEX_TOKEN = "Plex Token"
+RECENT_MOVIES = "Recent Movies"
+RECENT_TV = "Recent TV"
+RECENT_MUSIC = "Recent Music"
+PLAYING_NOW = "Playing Now"
+PLAYING_NOW_ON_PLEX = "Playing Now on PLEX"
+RECENTLY_ADDED_TO_PLEX = "Recently Added to PLEX"
+MOVIES = "Movies"
+TV_SHOWS = "TV Shows"
+MUSIC = "Music"

+ 13 - 1
lang/pl.ini

@@ -170,4 +170,16 @@ EDIT_CUSTOM_CSS = "Własne CSS"
 CUSTOM_COMPLETE = "WŁASNE CSS ZAPISANE!"
 SAVE_CSS = "Zapisz CSS"
 MENU = "Menu"
-GRAVATAR = "Gravatar"
+GRAVATAR = "Gravatar"
+PLEX_URL = "Plex URL"
+PLEX_PORT = "Plex Port"
+PLEX_TOKEN = "Plex Token"
+RECENT_MOVIES = "Recent Movies"
+RECENT_TV = "Recent TV"
+RECENT_MUSIC = "Recent Music"
+PLAYING_NOW = "Playing Now"
+PLAYING_NOW_ON_PLEX = "Playing Now on PLEX"
+RECENTLY_ADDED_TO_PLEX = "Recently Added to PLEX"
+MOVIES = "Movies"
+TV_SHOWS = "TV Shows"
+MUSIC = "Music"

+ 115 - 139
settings.php

@@ -5,13 +5,8 @@ $data = false;
 ini_set("display_errors", 1);
 ini_set("error_reporting", E_ALL | E_STRICT);
 
-function registration_callback($username, $email, $userdir)
-{
-    global $data;
-    $data = array($username, $email, $userdir);
-}
-
 require_once("user.php");
+require_once("functions.php");
 $USER = new User("registration_callback");
 require_once("translate.php");
 
@@ -25,141 +20,9 @@ elseif($USER->authenticated && $USER->role !== "admin") :
 
 endif;
 
-function printArray($arrayName){
-    
-    $messageCount = count($arrayName);
-    
-    $i = 0;
-    
-    foreach ( $arrayName as $item ) :
-    
-        $i++; 
-    
-        if($i < $messageCount) :
-    
-            echo "<small class='text-uppercase'>" . $item . "</small> & ";
-    
-        elseif($i = $messageCount) :
-    
-            echo "<small class='text-uppercase'>" . $item . "</small>";
-    
-        endif;
-        
-    endforeach;
-    
-}
-
-function explosion($string, $position){
-    
-    $getWord = explode("|", $string);
-    return $getWord[$position];
-    
-}
-
-function write_ini_file($content, $path) { 
-    
-    if (!$handle = fopen($path, 'w')) {
-        
-        return false; 
-    
-    }
-    
-    $success = fwrite($handle, $content);
-    
-    fclose($handle); 
-    
-    return $success; 
-
-}
-
-function getServerPath() {
-    
-    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { 
-        
-        $protocol = "https://"; 
-    
-    } else {  
-        
-        $protocol = "http://"; 
-    
-    }
-    
-    return $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']);
-      
-}
-
-function get_browser_name() {
-    
-    $user_agent = $_SERVER['HTTP_USER_AGENT'];
-    
-    if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
-    elseif (strpos($user_agent, 'Edge')) return 'Edge';
-    elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
-    elseif (strpos($user_agent, 'Safari')) return 'Safari';
-    elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
-    elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
-    
-    return 'Other';
-    
-}
-
-function getTimezone(){
-
-    $regions = array(
-        'Africa' => DateTimeZone::AFRICA,
-        'America' => DateTimeZone::AMERICA,
-        'Antarctica' => DateTimeZone::ANTARCTICA,
-        'Arctic' => DateTimeZone::ARCTIC,
-        'Asia' => DateTimeZone::ASIA,
-        'Atlantic' => DateTimeZone::ATLANTIC,
-        'Australia' => DateTimeZone::AUSTRALIA,
-        'Europe' => DateTimeZone::EUROPE,
-        'Indian' => DateTimeZone::INDIAN,
-        'Pacific' => DateTimeZone::PACIFIC
-    );
-    
-    $timezones = array();
-
-    foreach ($regions as $name => $mask) {
-        
-        $zones = DateTimeZone::listIdentifiers($mask);
-
-        foreach($zones as $timezone) {
-
-            $time = new DateTime(NULL, new DateTimeZone($timezone));
-
-            $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
-
-            $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
-
-        }
-        
-    }   
-    
-    print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
-    
-    foreach($timezones as $region => $list) {
-    
-        print '<optgroup label="' . $region . '">' . "\n";
-    
-        foreach($list as $timezone => $name) {
-            
-            if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
-            
-            print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
-    
-        }
-    
-        print '</optgroup>' . "\n";
-    
-    }
-    
-    print '</select>';
-    
-}
-
 $dbfile = DATABASE_LOCATION  . constant('User::DATABASE_NAME') . ".db";
 $databaseLocation = "databaseLocation.ini.php";
+$homepageSettings = "homepageSettings.ini.php";
 $userdirpath = USER_HOME;
 $userdirpath = substr_replace($userdirpath, "", -1);
 
@@ -434,6 +297,28 @@ if($action == "createLocation") :
     echo "<script>window.parent.location.reload(true);</script>";
 
 endif;
+
+if($action == "homepageSettings") :
+
+    $homepageData = '; <?php die("Access denied"); ?>' . "\r\n";
+
+    foreach ($_POST as $postName => $postValue) {
+            
+        if($postName !== "action") :
+        
+            if(substr($postValue, -1) == "/") : $postValue = rtrim($postValue, "/"); endif;
+        
+            $homepageData .= $postName . " = \"" . $postValue . "\"\r\n";
+        
+        endif;
+        
+    }
+
+    write_ini_file($homepageData, $homepageSettings);
+
+    echo "<script>window.parent.location.reload(true);</script>";
+
+endif;
                 
 if(!isset($_POST['op'])) :
 
@@ -807,6 +692,12 @@ endif; ?>
                      
                                 </li>
                                 
+                                <li>
+                        
+                                    <a href="#homepageSettings" data-toggle="tab"><i class="fa fa-home yellow"></i></a>
+                     
+                                </li>
+                                
                                 <li>
                         
                                     <a href="#about" data-toggle="tab"><i class="fa fa-info red-orange"></i></a>
@@ -1396,6 +1287,91 @@ endif; ?>
 
                                 </div>
                                 
+                                <div class="tab-pane big-box  fade in" id="homepageSettings">
+                                    
+                                    <div class="row">
+                                        
+                                        <div class="col-lg-12">
+                                          
+                                            <div class="big-box">
+                                            
+                                                <form class="content-form" name="homepageSettings" id="homepageSettings" action="" method="POST">
+                        								    
+                                                    <input type="hidden" name="action" value="homepageSettings" />
+
+                                                    <div class="form-group">
+
+                                                        <input type="text" class="form-control material input-sm" name="plexURL" placeholder="<?php echo $language->translate("PLEX_URL");?>" autocorrect="off" autocapitalize="off" value="<?php echo PLEXURL;?>">
+                                                        <p class="help-text"><?php echo $language->translate("PLEX_URL");?></p>
+
+                                                    </div>
+
+                                                    <div class="form-group">
+
+                                                        <input type="text" class="form-control material input-sm" name="plexPort" placeholder="<?php echo $language->translate("PLEX_PORT");?>" autocorrect="off" autocapitalize="off" value="<?php echo PLEXPORT;?>">
+                                                        <p class="help-text"><?php echo $language->translate("PLEX_PORT");?></p>
+
+                                                    </div>
+
+                                                    <div class="form-group">
+
+                                                        <input type="text" class="form-control material input-sm" name="plexToken" placeholder="<?php echo $language->translate("PLEX_TOKEN");?>" autocorrect="off" autocapitalize="off" value="<?php echo PLEXTOKEN;?>">
+                                                        <p class="help-text"><?php echo $language->translate("PLEX_TOKEN");?></p>
+
+                                                    </div>
+                                                    
+                                                    <div class="content-form form-inline">
+                                                    
+                                                        <div class="form-group">
+                                                            <?php  if(PLEXRECENTMOVIE == "true") : $PLEXRECENTMOVIE = "checked"; else : $PLEXRECENTMOVIE = ""; endif;?>
+                                                            <input id="" class="switcher switcher-success" value="false" name="plexRecentMovie" type="hidden">
+                                                            <input id="plexRecentMovie" class="switcher switcher-success" value="true" name="plexRecentMovie" type="checkbox" <?php echo $PLEXRECENTMOVIE;?>>
+
+                                                            <label for="plexRecentMovie"></label><?php echo $language->translate("RECENT_MOVIES");?>
+
+                                                        </div>
+                                                        
+                                                        <div class="form-group">
+                                                            <?php  if(PLEXRECENTTV == "true") : $PLEXRECENTTV = "checked"; else : $PLEXRECENTTV = ""; endif;?>
+                                                            <input id="" class="switcher switcher-success" value="false" name="plexRecentTV" type="hidden">
+                                                            <input id="plexRecentTV" class="switcher switcher-success" value="true" name="plexRecentTV" type="checkbox" <?php echo $PLEXRECENTTV;?>>
+
+                                                            <label for="plexRecentTV"></label><?php echo $language->translate("RECENT_TV");?>
+
+                                                        </div>
+                                                        
+                                                        <div class="form-group">
+                                                            <?php  if(PLEXRECENTMUSIC == "true") : $PLEXRECENTMUSIC = "checked"; else : $PLEXRECENTMUSIC = ""; endif;?>
+                                                            <input id="" class="switcher switcher-success" value="false" name="plexRecentMusic" type="hidden">
+                                                            <input id="plexRecentMusic" class="switcher switcher-success" value="true" name="plexRecentMusic" type="checkbox" <?php echo $PLEXRECENTMUSIC;?>>
+
+                                                            <label for="plexRecentMusic"></label><?php echo $language->translate("RECENT_MUSIC");?>
+
+                                                        </div>
+                                                        
+                                                        <div class="form-group">
+                                                            <?php  if(PLEXPLAYINGNOW == "true") : $PLEXPLAYINGNOW = "checked"; else : $PLEXPLAYINGNOW = ""; endif;?>
+                                                            <input id="" class="switcher switcher-success" value="false" name="plexPlayingNow" type="hidden">
+                                                            <input id="plexPlayingNow" class="switcher switcher-success" value="true" name="plexPlayingNow" type="checkbox" <?php echo $PLEXPLAYINGNOW;?>>
+
+                                                            <label for="plexPlayingNow"></label><?php echo $language->translate("PLAYING_NOW");?>
+
+                                                        </div>
+                                                                                                                
+                                                    </div>
+                                                    
+                                                    <button type="submit" class="class='btn waves btn-labeled btn-success btn btn-sm pull-right text-uppercase waves-effect waves-float"><span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save</button>
+
+                                                </form>               
+                                          
+                                            </div>
+                                        
+                                        </div>
+                                      
+                                    </div>
+
+                                </div>
+                                
                                 <div class="tab-pane big-box  fade in" id="loginlog">
 
                                     <div class="table-responsive">

+ 16 - 1
user.php

@@ -7,10 +7,12 @@
 	 *	entry is assigned a new random token,  which is used in
 	 * salting subsequent password checks.
 	 */
+    
+    define('INSTALLEDVERSION', '1.10');
+
     $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
     define('USER_HOME', $databaseConfig['databaseLocation'] . '/users/');
     define('DATABASE_LOCATION', $databaseConfig['databaseLocation'] . '/');
-    define('INSTALLEDVERSION', '1.08');
     if(!empty($databaseConfig['timezone'])) : define('TIMEZONE', $databaseConfig['timezone']); else : define('TIMEZONE', 'America/Los_Angeles'); endif;
     if(!empty($databaseConfig['titleLogo'])) : define('TITLELOGO', $databaseConfig['titleLogo']); else : define('TITLELOGO', ''); endif;
     if(!empty($databaseConfig['loadingIcon'])) : define('LOADINGICON', $databaseConfig['loadingIcon']); else : define('LOADINGICON', ''); endif;
@@ -22,6 +24,19 @@
     if(!empty($databaseConfig['registerPassword'])) : define('REGISTERPASSWORD', $databaseConfig['registerPassword']); else : define('REGISTERPASSWORD', ''); endif;
     if(!empty($databaseConfig['gravatar'])) : define('GRAVATAR', $databaseConfig['gravatar']); else : define('GRAVATAR', 'true'); endif;
     if(!empty($databaseConfig['notifyEffect'])) : define('NOTIFYEFFECT', $databaseConfig['notifyEffect']); else : define('NOTIFYEFFECT', 'bar-slidetop'); endif;
+
+    if(!file_exists('homepageSettings.ini.php')){ touch('homepageSettings.ini.php'); }
+        
+    $homepageConfig = parse_ini_file('homepageSettings.ini.php', true);        
+    if(!empty($homepageConfig['plexURL'])) : define('PLEXURL', $homepageConfig['plexURL']); else : define('PLEXURL', ''); endif;
+    if(!empty($homepageConfig['plexPort'])) : define('PLEXPORT', $homepageConfig['plexPort']); else : define('PLEXPORT', ''); endif;
+    if(!empty($homepageConfig['plexToken'])) : define('PLEXTOKEN', $homepageConfig['plexToken']); else : define('PLEXTOKEN', ''); endif;
+    if(!empty($homepageConfig['plexRecentMovie'])) : define('PLEXRECENTMOVIE', $homepageConfig['plexRecentMovie']); else : define('PLEXRECENTMOVIE', 'false'); endif;
+    if(!empty($homepageConfig['plexRecentTV'])) : define('PLEXRECENTTV', $homepageConfig['plexRecentTV']); else : define('PLEXRECENTTV', 'false'); endif;
+    if(!empty($homepageConfig['plexRecentMusic'])) : define('PLEXRECENTMUSIC', $homepageConfig['plexRecentMusic']); else : define('PLEXRECENTMUSIC', 'false'); endif;
+    if(!empty($homepageConfig['plexPlayingNow'])) : define('PLEXPLAYINGNOW', $homepageConfig['plexPlayingNow']); else : define('PLEXPLAYINGNOW', 'false'); endif;
+
+    
     if(file_exists('custom.css')) : define('CUSTOMCSS', 'true'); else : define('CUSTOMCSS', 'false'); endif; 
     $notifyExplode = explode("-", NOTIFYEFFECT);
     define('FAIL_LOG', 'loginLog.json');