소스 검색

Fix Emby URL for newer versions
Code cleanup
Add sponsorship

causefx 7 년 전
부모
커밋
9027ca1774
4개의 변경된 파일190개의 추가작업 그리고 61개의 파일을 삭제
  1. 1 1
      api/functions/homepage-connect-functions.php
  2. 54 53
      api/functions/log-functions.php
  3. 36 7
      api/pages/settings.php
  4. 99 0
      js/functions.js

+ 1 - 1
api/functions/homepage-connect-functions.php

@@ -185,7 +185,7 @@ function resolveEmbyItem($itemDetails)
 	$embyItem['user'] = ($GLOBALS['homepageShowStreamNames'] && qualifyRequest($GLOBALS['homepageShowStreamNamesAuth'])) ? @(string)$itemDetails['UserName'] : "";
 	$embyItem['userThumb'] = '';
 	$embyItem['userAddress'] = (isset($itemDetails['RemoteEndPoint']) ? $itemDetails['RemoteEndPoint'] : "x.x.x.x");
-	$embyItem['address'] = $GLOBALS['embyTabURL'] ? rtrim($GLOBALS['embyTabURL'], '/') . "/web/itemdetails.html?id=" . $embyItem['uid'] : "https://app.emby.media/itemdetails.html?id=" . $embyItem['uid'] . "&serverId=" . $embyItem['id'];
+	$embyItem['address'] = $GLOBALS['embyTabURL'] ? rtrim($GLOBALS['embyTabURL'], '/') . "/web/#!/itemdetails.html?id=" . $embyItem['uid'] : "https://app.emby.media/itemdetails.html?id=" . $embyItem['uid'] . "&serverId=" . $embyItem['id'];
 	$embyItem['nowPlayingOriginalImage'] = 'api/?v1/image&source=emby&type=' . $embyItem['nowPlayingImageType'] . '&img=' . $embyItem['nowPlayingThumb'] . '&height=' . $nowPlayingHeight . '&width=' . $nowPlayingWidth . '&key=' . $embyItem['nowPlayingKey'] . '$' . randString();
 	$embyItem['originalImage'] = 'api/?v1/image&source=emby&type=' . $embyItem['imageType'] . '&img=' . $embyItem['thumb'] . '&height=' . $height . '&width=' . $width . '&key=' . $embyItem['key'] . '$' . randString();
 	$embyItem['openTab'] = $GLOBALS['embyTabURL'] && $GLOBALS['embyTabName'] ? true : false;

+ 54 - 53
api/functions/log-functions.php

@@ -1,58 +1,59 @@
 <?php
-
 function writeLoginLog($username, $authType)
 {
-    if (file_exists($GLOBALS['organizrLoginLog'])) {
-        $getLog = str_replace("\r\ndate", "date", file_get_contents($GLOBALS['organizrLoginLog']));
-        $gotLog = json_decode($getLog, true);
-    }
-    $logEntryFirst = array('logType' => 'login_log', 'auth' => array(array('date' => date("Y-m-d H:i:s"), 'utc_date' => $GLOBALS['currentTime'], 'username' => $username, 'ip' => userIP(), 'auth_type' => $authType)));
-    $logEntry = array('date' => date("Y-m-d H:i:s"), 'utc_date' => $GLOBALS['currentTime'], 'username' => $username, 'ip' => userIP(), 'auth_type' => $authType);
-    if (isset($gotLog)) {
-        array_push($gotLog["auth"], $logEntry);
-        $writeFailLog = str_replace("date", "\r\ndate", json_encode($gotLog));
-    } else {
-        $writeFailLog = str_replace("date", "\r\ndate", json_encode($logEntryFirst));
-    }
-    file_put_contents($GLOBALS['organizrLoginLog'], $writeFailLog);
-};
-function writeLog($type='error', $message, $username=null)
-{
-    $username = ($username) ? $username : $GLOBALS['organizrUser']['username'];
-    if (file_exists($GLOBALS['organizrLog'])) {
-        $getLog = str_replace("\r\ndate", "date", file_get_contents($GLOBALS['organizrLog']));
-        $gotLog = json_decode($getLog, true);
-    }
-    $logEntryFirst = array('logType' => 'organizr_log', 'log_items' => array(array('date' => date("Y-m-d H:i:s"), 'utc_date' => $GLOBALS['currentTime'], 'type' => $type, 'username' => $username, 'ip' => userIP(), 'message' => $message)));
-    $logEntry = array('date' => date("Y-m-d H:i:s"), 'utc_date' => $GLOBALS['currentTime'], 'type' => $type, 'username' => $username, 'ip' => userIP(), 'message' => $message);
-    if (isset($gotLog)) {
-        array_push($gotLog["log_items"], $logEntry);
-        $writeFailLog = str_replace("date", "\r\ndate", json_encode($gotLog));
-    } else {
-        $writeFailLog = str_replace("date", "\r\ndate", json_encode($logEntryFirst));
-    }
-    file_put_contents($GLOBALS['organizrLog'], $writeFailLog);
-};
-function getLog($type, $reverse=true)
+	if (file_exists($GLOBALS['organizrLoginLog'])) {
+		$getLog = str_replace("\r\ndate", "date", file_get_contents($GLOBALS['organizrLoginLog']));
+		$gotLog = json_decode($getLog, true);
+	}
+	$logEntryFirst = array('logType' => 'login_log', 'auth' => array(array('date' => date("Y-m-d H:i:s"), 'utc_date' => $GLOBALS['currentTime'], 'username' => $username, 'ip' => userIP(), 'auth_type' => $authType)));
+	$logEntry = array('date' => date("Y-m-d H:i:s"), 'utc_date' => $GLOBALS['currentTime'], 'username' => $username, 'ip' => userIP(), 'auth_type' => $authType);
+	if (isset($gotLog)) {
+		array_push($gotLog["auth"], $logEntry);
+		$writeFailLog = str_replace("date", "\r\ndate", json_encode($gotLog));
+	} else {
+		$writeFailLog = str_replace("date", "\r\ndate", json_encode($logEntryFirst));
+	}
+	file_put_contents($GLOBALS['organizrLoginLog'], $writeFailLog);
+}
+
+function writeLog($type = 'error', $message, $username = null)
 {
-    switch ($type) {
-        case 'login':
-        case 'loginLog':
-            $file = $GLOBALS['organizrLoginLog'];
-            $parent = 'auth';
-            break;
-        case 'org':
-        case 'organizrLog':
-            $file = $GLOBALS['organizrLog'];
-            $parent = 'log_items';
-            // no break
-        default:
-            break;
-    }
-    if (!file_exists($file)) {
-        return false;
-    }
-    $getLog = str_replace("\r\ndate", "date", file_get_contents($file));
-    $gotLog = json_decode($getLog, true);
-    return ($reverse) ? array_reverse($gotLog[$parent]) : $gotLog[$parent];
+	$username = ($username) ? $username : $GLOBALS['organizrUser']['username'];
+	if (file_exists($GLOBALS['organizrLog'])) {
+		$getLog = str_replace("\r\ndate", "date", file_get_contents($GLOBALS['organizrLog']));
+		$gotLog = json_decode($getLog, true);
+	}
+	$logEntryFirst = array('logType' => 'organizr_log', 'log_items' => array(array('date' => date("Y-m-d H:i:s"), 'utc_date' => $GLOBALS['currentTime'], 'type' => $type, 'username' => $username, 'ip' => userIP(), 'message' => $message)));
+	$logEntry = array('date' => date("Y-m-d H:i:s"), 'utc_date' => $GLOBALS['currentTime'], 'type' => $type, 'username' => $username, 'ip' => userIP(), 'message' => $message);
+	if (isset($gotLog)) {
+		array_push($gotLog["log_items"], $logEntry);
+		$writeFailLog = str_replace("date", "\r\ndate", json_encode($gotLog));
+	} else {
+		$writeFailLog = str_replace("date", "\r\ndate", json_encode($logEntryFirst));
+	}
+	file_put_contents($GLOBALS['organizrLog'], $writeFailLog);
 }
+
+function getLog($type, $reverse = true)
+{
+	switch ($type) {
+		case 'login':
+		case 'loginLog':
+			$file = $GLOBALS['organizrLoginLog'];
+			$parent = 'auth';
+			break;
+		case 'org':
+		case 'organizrLog':
+			$file = $GLOBALS['organizrLog'];
+			$parent = 'log_items';
+		// no break
+		default:
+			break;
+	}
+	if (!file_exists($file)) {
+		return false;
+	}
+	$getLog = str_replace("\r\ndate", "date", file_get_contents($file));
+	$gotLog = json_decode($getLog, true);
+	return ($reverse) ? array_reverse($gotLog[$parent]) : $gotLog[$parent];
+}

+ 36 - 7
api/pages/settings.php

@@ -5,6 +5,7 @@ if (file_exists('config' . DIRECTORY_SEPARATOR . 'config.php')) {
     (function() {
         updateCheck();
         authDebugCheck();
+        sponsorLoad();
         [].slice.call(document.querySelectorAll(\'.sttabs\')).forEach(function(el) {
             new CBPFWTabs(el);
         });
@@ -193,6 +194,11 @@ if (file_exists('config' . DIRECTORY_SEPARATOR . 'config.php')) {
     											<li><a href="https://github.com/causefx/organizr" target="_blank"><i class="mdi mdi-github-box mdi-24px"></i></a></li>
     										</ul>
     									</div>
+    									<div class="well bg-org">
+                                            <h4 lang="en">Want to help translate?</h4>
+                                            <p lang="en">Head on over to POEditor and help us translate Organizr into your language</p>
+                                            <button class="fcbtn btn btn-primary btn-outline btn-1b"><a href="https://poeditor.com/join/project/T6l68hksTE" target="_blank" lang="en">I Want to Help</a></button>
+                                        </div>
     								</div>
                                     <div class="col-lg-6 col-sm-12 col-md-6">
                                         <div class="white-box bg-org">
@@ -209,15 +215,38 @@ if (file_exists('config' . DIRECTORY_SEPARATOR . 'config.php')) {
 
                                             </ul>
                                         </div>
-                                    </div>
-                                    <div class="col-lg-6 col-sm-12 col-md-6">
-                                        <div class="well bg-org">
-                                            <h4 lang="en">Want to help translate?</h4>
-                                            <p lang="en">Head on over to POEditor and help us translate Organizr into your language</p>
-                                            <button class="fcbtn btn btn-primary btn-outline btn-1b"><a href="https://poeditor.com/join/project/T6l68hksTE" target="_blank" lang="en">I Want to Help</a></button>
-                                        </div>
                                     </div>
     							</div>
+    							
+    							
+    							<div class="row">
+	                            	
+	                                <div class="col-lg-12">
+							            <div class="panel panel-default">
+											
+											<div class="panel-heading bg-org p-t-10 p-b-10">
+												<span class="pull-left m-t-5"><span lang="en">Sponsors</span></span>
+												
+										
+												<div class="clearfix"></div>
+											</div>
+									
+							                <div class="panel-wrapper p-b-0 collapse in bg-org">
+												
+							                	<div id="sponsorList" class="owl-carousel owl-theme sponsor-items">
+							                	
+											        
+
+							        			</div>
+							        			<div id="sponsorListModals"></div>
+											
+										
+							                </div>
+							            </div>
+							        </div>
+    							
+    							</div>
+
                                 <div class="clearfix"></div>
                             </div>
                             <div role="tabpanel" class="tab-pane fade" id="settings-settings-donate">

+ 99 - 0
js/functions.js

@@ -2249,6 +2249,100 @@ function updateCheck(){
 		console.error("Organizr Function: Github Connection Failed");
 	});
 }
+function sponsorLoad(){
+    sponsorsJSON().success(function(data) {
+        var json = JSON.parse(data);
+        /*for (var a in reverseObject(json)){
+            var latest = a;
+            break;
+        }
+        if(latest !== currentVersion){
+            console.log('Update Function: Update to '+latest+' is available');
+            message(window.lang.translate('Update Available'),latest+' '+window.lang.translate('is available, goto')+' <a href="javascript:void(0)" onclick="tabActions(event,\'Settings\',0);$(\'#update-button\').click()"><span lang="en">Update Tab</span></a>',activeInfo.settings.notifications.position,'#FFF','update','60000');
+        }*/
+        $('#sponsorList').html(buildSponsor(json));
+        $('#sponsorListModals').html(buildSponsorModal(json));
+        $('.sponsor-items').owlCarousel({
+            nav:false,
+            autoplay:true,
+            dots:false,
+            margin:10,
+            autoWidth:true,
+            items:4
+        });
+    }).fail(function(xhr) {
+        console.error("Organizr Function: Github Connection Failed");
+    });
+}
+function sponsorAbout(id,array){
+    var coupon = (array.coupon == null) ? false : true;
+    var couponAbout = (array.coupon_about == null) ? false : true;
+    var extraInfo = (coupon && couponAbout) ? `
+        <br><span class="label label-rouded label-info pull-right">`+array.coupon+`</span>
+        <br><span class="mail-desc">`+array.coupon_about+`</span>
+    ` : '';
+    return `
+        <!--  modal content -->
+        <div id="sponsor-`+id+`-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel-`+id+`" aria-hidden="true" style="display: none;">
+            <div class="modal-dialog">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+                        <h4 class="modal-title" id="mySmallModalLabel-`+id+`">`+array.company_name+`</h4> </div>
+                    <div class="modal-body">
+                        <div class="row">
+                            <div class="col-md-12">
+                                <div class="comment-center p-t-10">
+                                    <div class="comment-body b-none">
+                                        <div class="user-img"> <img src="`+array.logo+`" alt="user" class="img-circle"> </div>
+                                        <div class="mail-contnet">
+                                            <h5><a href="`+array.website+`" target="_blank">`+array.company_name+`</a></h5> 
+                                            `+array.about+extraInfo+`
+                                         </div>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <!-- /.modal-content -->
+            </div>
+            <!-- /.modal-dialog -->
+        </div>
+        <!-- /.modal -->
+    `;
+}
+function buildSponsor(array){
+    var sponsors = '';
+    $.each(array, function(i,v) {
+        var sponsorAboutModal = (v.about) ? 'data-toggle="modal" data-target="#sponsor-'+i+'-modal"' : '';
+        sponsors += `
+            <!-- /.usercard -->
+            <div class="item lazyload recent-sponsor mouse imageSource mouse" `+sponsorAboutModal+` data-src="`+v.logo+`">
+                <span class="elip recent-title">`+v.company_name+`</span>
+            </div>
+            <!-- /.usercard-->
+        `;
+
+    });
+    sponsors += `
+        <!-- /.usercard -->
+        <div class="item lazyload recent-sponsor mouse imageSource mouse" onclick="window.open('https://www.patreon.com/bePatron?c=1320444&rid=2874514', '_blank')" data-src="plugins/images/sponsor.png">
+            <span class="elip recent-title" lang="en">Become Sponsor</span>
+        </div>
+        <!-- /.usercard-->
+    `;
+    return sponsors;
+}
+function buildSponsorModal(array){
+    var sponsors = '';
+    $.each(array, function(i,v) {
+        var sponsorAboutModal = (v.about) ? sponsorAbout(i,v) : '';
+        sponsors += sponsorAboutModal;
+
+    });
+    return sponsors;
+}
 function updateBar(){
 	return `
 	<div class="white-box m-0">
@@ -2368,6 +2462,11 @@ function githubVersions() {
 		url: "https://raw.githubusercontent.com/causefx/Organizr/"+activeInfo.branch+"/js/version.json",
 	});
 }
+function sponsorsJSON() {
+    return $.ajax({
+        url: "https://raw.githubusercontent.com/causefx/Organizr/"+activeInfo.branch+"/js/sponsors.json",
+    });
+}
 function marketplaceJSON(type) {
     return $.ajax({
         url: "https://raw.githubusercontent.com/causefx/Organizr/v2-"+type+"/"+type+".json",