causefx 8 gadi atpakaļ
vecāks
revīzija
ab6ae93612
4 mainītis faili ar 73 papildinājumiem un 7 dzēšanām
  1. 4 1
      ajax.php
  2. 30 2
      functions.php
  3. 39 0
      settings.php
  4. 0 4
      user.php

+ 4 - 1
ajax.php

@@ -105,7 +105,10 @@ switch ($_SERVER['REQUEST_METHOD']) {
             default: // Stuff that you need admin for
                 qualifyUser('admin', true);
                 switch ($action) {
-                    case 'check-url':
+                    case 'test-email':
+                        sendResult(sendTestEmail($_POST['emailto'], $_POST['emailsenderemail'], $_POST['emailhost'], $_POST['emailauth'], $_POST['emailusername'], $_POST['emailpassword'], $_POST['emailtype'], $_POST['emailport'], $_POST['emailsendername']), "flask", "E-Mail TEST", "SUCCESS", "ERROR");
+                        break;
+					case 'check-url':
                         sendResult(frameTest($_POST['checkurl']), "flask", $_POST['checkurl'], "IFRAME_CAN_BE_FRAMED", "IFRAME_CANNOT_BE_FRAMED");
                         break;
                     case 'upload-images':

+ 30 - 2
functions.php

@@ -3004,7 +3004,7 @@ function getPlatform($platform){
         "Dlna" => "dlna.png",
         "Windows Phone" => "wp.png",
         "Windows RT" => "win8.png",
-        "Kodi" => "koid.png",
+        "Kodi" => "kodi.png",
     );
     if (array_key_exists($platform, $allPlatforms)) {
         return $allPlatforms[$platform];
@@ -3323,6 +3323,34 @@ function sendEmail($email, $username = "Organizr User", $subject, $body, $cc = n
 
 }
 
+//EMAIL SHIT
+function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
+
+	$mail = new PHPMailer;
+	$mail->isSMTP();
+	$mail->Host = $host;
+	$mail->SMTPAuth = $auth;
+	$mail->Username = $username;
+	$mail->Password = $password;
+	$mail->SMTPSecure = $type;
+	$mail->Port = $port;
+	$mail->setFrom($from, $sendername);
+	$mail->addReplyTo($from, $sendername);
+	$mail->isHTML(true);
+	$mail->addAddress($to, "Organizr Admin");
+	$mail->Subject = "Organizr Test E-Mail";
+	$mail->Body    = "This was just a test!";
+	//$mail->send();
+	if(!$mail->send()) {
+		writeLog("error", "mail failed to send");
+		return false;
+	} else {
+		writeLog("success", "mail has been sent");
+		return true;
+	}
+
+}
+
 function libraryList(){
     $address = qualifyURL(PLEXURL);
 	$headers = array(
@@ -3628,7 +3656,7 @@ function getPlexPlaylists(){
 								$items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false,false);
 							}
 							if (count($items)) {
-								$className = str_replace(' ', '', $api['title']);
+								$className = preg_replace("/(\W)+/", "", $api['title']);
 								$output .= '<div id="playlist-'.$className.'" class="content-box box-shadow big-box"><h5 style="margin-bottom: -20px" class="text-center">'.$api['title'].'</h5><div class="recentHeader inbox-pagination '.$className.'"></div><br/><div class="recentItems" data-name="'.$className.'">'.implode('',$items).'</div></div>';
 							}							
 						}

+ 39 - 0
settings.php

@@ -1435,6 +1435,12 @@ echo buildSettings(
 						),
 					),
 					array(
+                        array(
+							'type' => 'button',
+							'labelTranslate' => 'TEST_EMAIL',
+							'id' => 'testEmail',
+							'icon' => 'flask',
+						),
 						array(
 							'type' => 'checkbox',
 							'labelTranslate' => 'SMTP_HOST_AUTH',
@@ -2757,6 +2763,38 @@ echo buildSettings(
             });
         </script>
         <script>
+            //TestEmail
+            function isUpperCase(str) {
+                return str === str.toUpperCase();
+            }
+            $('#smtpHostAuth_id').change(function() {
+                if($('#smtpHostAuth_id').attr("data-value") == "true"){
+                    $('#smtpHostAuth_id').attr("data-value", "false");
+                }else{
+                    $('#smtpHostAuth_id').attr("data-value", "true");
+                }
+            });
+            $('#testEmail').on('click', function () {
+                var password = '';
+                if(isUpperCase($('#smtpHostPassword_id').val())){
+                    password = '<?php echo SMTPHOSTPASSWORD; ?>';
+                }else{
+                    password = $('#smtpHostPassword_id').val();
+                }
+                console.log("starting");
+                ajax_request('POST', 'test-email', {
+                    emailto: '<?php echo $USER->email;?>',
+                    emailhost: $('#smtpHost_id').val(),
+                    emailport: $('#smtpHostPort_id').val(),
+                    emailusername: $('#smtpHostUsername_id').val(),
+                    emailpassword: password,
+                    emailsendername: $('#smtpHostSenderName_id').val(),
+                    emailsenderemail: $('#smtpHostSenderEmail_id').val(),
+                    emailtype: $('#smtpHostType_id').val(),
+                    emailauth: $('#smtpHostAuth_id').attr("data-value"),
+                });
+                console.log("ajax done");
+            });
             //Custom Themes            
             function changeColor(elementName, elementColor) {
                 var definedElement = document.getElementById(elementName);
@@ -3056,6 +3094,7 @@ echo buildSettings(
                     checkurl: $('#urlTestForm [name=url-test]').val(),
                 });
             });
+
             //Hide Icon box on load
             $( "div[class^='jFiler jFiler-theme-dragdropbox']" ).hide();
             //Set Some Scrollbars

+ 0 - 4
user.php

@@ -17,10 +17,6 @@
     // Lazyload settings
 	$databaseConfig = configLazy('config/config.php');
 
-	if (!DATABASE_LOCATION){
-		die(header("Refresh:0"));
-	}
-    
     if(file_exists('custom.css')) : define('CUSTOMCSS', 'true'); else : define('CUSTOMCSS', 'false'); endif; 
     $notifyExplode = explode("-", NOTIFYEFFECT);
     define('FAIL_LOG', 'loginLog.json');