Explorar o código

added ping to splash
Fixed #658

causefx %!s(int64=8) %!d(string=hai) anos
pai
achega
256a0da635
Modificáronse 3 ficheiros con 17 adicións e 99 borrados
  1. 3 0
      .gitignore
  2. 0 96
      chatAJAX.php
  3. 14 3
      index.php

+ 3 - 0
.gitignore

@@ -67,3 +67,6 @@ config/users*.db
 config/users*.bak.db
 config/tmp/*
 images/cache/*
+backups/*
+backups/
+backups

+ 0 - 96
chatAJAX.php

@@ -1,96 +0,0 @@
-<?php
-
-define("CHATDB", "chat.db");
-
-if (!file_exists(CHATDB)) {
-    
-    try{
-        $db = new PDO('sqlite:'.CHATDB);
-
-        $sql ="
-          CREATE TABLE IF NOT EXISTS MESSAGES 
-          (ID INTEGER PRIMARY KEY AUTOINCREMENT,
-          USER TEXT NOT NULL,
-          EMAIL TEXT NOT NULL,
-          MESSAGE TEXT NOT NULL,
-          TIME TIMESTAMP NOT NULL DEFAULT((julianday('now') - 2440587.5)*86400.0))";
-
-        $ret = $db->exec($sql);
-        sleep(0.5);
-        $ret = $db->exec('PRAGMA journal_mode = wal;');
-        sleep(0.5);
-        
-
-        header("Refresh:0");
-    }
-    catch(PDOException $e){
-       die('Failed to execute query:'. $e->getMessage());
-    }
-
-   $db=null;
-    
-}elseif(file_exists(CHATDB)) {
-    
-   try{
-        $db = new PDO('sqlite:'.CHATDB);
-    }
-    catch(PDOException $e){
-        die('Failed to connect:'. $e->getMessage());
-    }
-}
-
-//check to see if the ajax call was to update db
-
-if (isset($_POST['text'])){
-
-    $msg=$_POST['text'];
-    $us=$_POST['user'];
-    $email=$_POST['email'];
-
-    $sql ="INSERT INTO MESSAGES (USER,MESSAGE,EMAIL) VALUES(?, ?, ?)";
-
-    try{
-        $ret = $db->prepare($sql);
-        $ret->execute([$us,$msg, $email]);
-    }
-    catch(PDOException $e){
-        console.log('Failed to update db:'. $e->getMessage());
-    }
-}else{
-    //the script will run for 20 seconds after the initial ajax call
-    $time=time()+20;
-
-    while(time()<$time){
-        if ($_POST['time']){
-            $prevtime=$_POST['time'];
-        }
-        else {
-            $prevtime=0;
-        }
-        //query to see if there are new messages
-
-        $sql ="SELECT TIME,USER,MESSAGE,EMAIL FROM MESSAGES WHERE TIME>? ORDER BY TIME ASC";
-
-        try{
-            $ret = $db->prepare($sql);
-            $ret->execute([$prevtime]);
-
-            $resarr = $ret->fetchAll(PDO::FETCH_ASSOC);
-
-            //if there are no new messages in the db, sleep for half a second and then run loop again
-            if (!$resarr)
-                sleep(0.5);
-            else{
-                echo json_encode($resarr);
-                break;
-            }
-        }
-        catch(PDOException $e){
-            console.log('Failed to get messages:'. $e->getMessage());
-        }
-    }
-}
-
-$db=null;
-
-?>

+ 14 - 3
index.php

@@ -267,6 +267,11 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 		<![endif]-->
 	</head>
 	<style>
+		#splashScreen ping span {
+		    margin-top: 0 !important;
+		    font-size: 10px;
+		    zoom: 2;
+		}
 		#weather .w-icon.right.pull-right {
 			font-size: 70px;
 		}
@@ -539,14 +544,14 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 													<span id="<?=$row['url'];?>s" class="badge badge-success" style="position: absolute;z-index: 100;right: 0px;"></span>
 													<img src="<?=$row['iconurl'];?>" style="height: 30px; width: 30px; margin-top: -2px;">
 													<?php if($row['ping'] == "true" && $row['ping_url']){ $allPings["image".$name] = $row['ping_url']; ?>
-														<ping id="ping-<?=$name;?>"></ping>
+														<ping class="ping-<?=$name;?>"></ping>
 													<?php }?>
 												</i>
 											<?php }else { ?>
 												<i class="fa <?=$row['icon'];?> fa-lg">
 													<span id="<?=$row['url'];?>s" class="badge badge-success" style="position: absolute;z-index: 100;right: 0px;"></span>
 													<?php if($row['ping'] == "true" && $row['ping_url']){ $allPings["icon".$name] = $row['ping_url']; ?>
-														<ping id="ping-<?=$name;?>"></ping>
+														<ping class="ping-<?=$name;?>"></ping>
 													<?php }?>
 												</i>
 											<?php } ?>
@@ -1062,8 +1067,14 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 													<i style="">
 														<img src="<?=$row['iconurl'];?>" style="height: 100px; margin-top: -10px;" class="">
 													</i>
+													<?php if($row['ping'] == "true" && $row['ping_url']){ $allPings["image".$name] = $row['ping_url']; ?>
+														<ping style="display: block" class="ping-<?=$name;?>"></ping>
+													<?php }?>
 												<?php else : ?>
 													<i style="padding-bottom: 8px" class="fa <?=$row['icon'];?> fa-sm"></i>
+													<?php if($row['ping'] == "true" && $row['ping_url']){ $allPings["icon".$name] = $row['ping_url']; ?>
+														<ping style="display: block" class="ping-<?=$name;?>"></ping>
+													<?php }?>
 												<?php endif; ?>
 											</center>
 										</div>
@@ -1688,7 +1699,7 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 					$name = str_replace(array(':', '\\', '/', '*'), 'x', $ping);
 					if(strpos($type, 'image') !== false){ $style = "margin-top:28px"; }else{ $style = ""; }?>
 					var  pingTab<?php echo $pingCount;?> = function() {
-						$("ping[id^='ping-<?php echo $name;?>']").load("ajax.php?a=get-ping&url=<?php echo $ping;?>&style=<?php echo $style;?>");
+						$("ping[class^='ping-<?php echo $name;?>']").load("ajax.php?a=get-ping&url=<?php echo $ping;?>&style=<?php echo $style;?>");
 					};
 					// Initial Loads
 					pingTab<?php echo $pingCount;?>();