Browse code

fix for IP - localhost

Jimako authored on 2024/04/14 11:36:32
Showing 1 changed files
... ...
@@ -15,12 +15,12 @@ if(!defined("_CHARSET")) exit( );
15 15
 	}
16 16
 	else {
17 17
 		$ip = $_SERVER['REMOTE_ADDR'];
18
-		if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4))
18
+		if (filter_var($ip, FILTER_VALIDATE_IP, array(FILTER_FLAG_IPV4, FILTER_FLAG_IPV6)))
19 19
 		{
20 20
 
21 21
 		} 
22 22
 		else {
23
-			$ip = 0;	
23
+			$ip = "0";	
24 24
 		}
25 25
 		
26 26
 		dbquery("INSERT INTO " . TABLEPREFIX . "fanfiction_online(online_uid, online_ip, online_timestamp)
Browse code

version 3.5.7

Jimako authored on 2024/04/08 12:21:57
Showing 1 changed files
... ...
@@ -5,7 +5,7 @@ if(!defined("_CHARSET")) exit( );
5 5
 	if(file_exists(_BASEDIR."blocks/online/{$language}.php")) include(_BASEDIR."blocks/online/{$language}.php");
6 6
 	else include(_BASEDIR."blocks/online/en.php");
7 7
 
8
-	$where = "online_uid=" . (USERUID ? USERUID : "0 AND online_ip = INET_ATON('" . $_SERVER['REMOTE_ADDR'] . "')");
8
+	$where = "online_uid=" . (USERUID ? USERUID : "0 AND online_ip = INET6_ATON('" . $_SERVER['REMOTE_ADDR'] . "')");
9 9
  
10 10
 	$result = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_online WHERE $where");
11 11
  
... ...
@@ -24,7 +24,7 @@ if(!defined("_CHARSET")) exit( );
24 24
 		}
25 25
 		
26 26
 		dbquery("INSERT INTO " . TABLEPREFIX . "fanfiction_online(online_uid, online_ip, online_timestamp)
27
-		 VALUES('" . (USERUID ? USERUID : 0) . "', INET_ATON('" . $ip . "'), '" . time() . "')");
27
+		 VALUES('" . (USERUID ? USERUID : 0) . "', INET6_ATON('" . $ip . "'), '" . time() . "')");
28 28
 	} 
29 29
  
30 30
 	$result = dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_online WHERE online_timestamp < ".(time()-60));
... ...
@@ -40,4 +40,4 @@ if(!defined("_CHARSET")) exit( );
40 40
 	$tpl->assignGlobal("onlinemembers", count($omlist) ? implode(", ", $omlist) : "");
41 41
 	$content = "<div id='who_online'><span class='label'>"._GUESTS.":</span> ".($guests ? $guests : 0)."<br />\n
42 42
 		<span class='label'>"._MEMBERS.":</span> ".(count($omlist) ? implode(", ", $omlist) : "")."</div>";
43
-?>
44 43
\ No newline at end of file
44
+?>
Browse code

3.5.6 efiction version

Jimako authored on 2024/03/09 16:09:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,43 @@
1
+<?php
2
+if(!defined("_CHARSET")) exit( );
3
+
4
+	global $dateformat, $tpl;
5
+	if(file_exists(_BASEDIR."blocks/online/{$language}.php")) include(_BASEDIR."blocks/online/{$language}.php");
6
+	else include(_BASEDIR."blocks/online/en.php");
7
+
8
+	$where = "online_uid=" . (USERUID ? USERUID : "0 AND online_ip = INET_ATON('" . $_SERVER['REMOTE_ADDR'] . "')");
9
+ 
10
+	$result = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_online WHERE $where");
11
+ 
12
+	if(dbnumrows($result) > 0) {
13
+		
14
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_online SET online_timestamp = '".time( )."' WHERE $where");
15
+	}
16
+	else {
17
+		$ip = $_SERVER['REMOTE_ADDR'];
18
+		if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4))
19
+		{
20
+
21
+		} 
22
+		else {
23
+			$ip = 0;	
24
+		}
25
+		
26
+		dbquery("INSERT INTO " . TABLEPREFIX . "fanfiction_online(online_uid, online_ip, online_timestamp)
27
+		 VALUES('" . (USERUID ? USERUID : 0) . "', INET_ATON('" . $ip . "'), '" . time() . "')");
28
+	} 
29
+ 
30
+	$result = dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_online WHERE online_timestamp < ".(time()-60));
31
+	$q1 = dbquery("SELECT COUNT(online_ip) FROM ".TABLEPREFIX."fanfiction_online WHERE online_uid = 0");
32
+ 
33
+	list($guests) = dbrow($q1);
34
+	$tpl->assignGlobal("guests", empty($guests) ? 0 : $guests);
35
+	$q2 = dbquery("SELECT o.online_uid, "._PENNAMEFIELD." as penname FROM ".TABLEPREFIX."fanfiction_online as o, "._AUTHORTABLE." WHERE o.online_uid = "._UIDFIELD." AND o.online_uid != 0");
36
+	$omlist = array( );
37
+	while($om = dbassoc($q2)) {
38
+		$omlist[] = "<a href='"._BASEDIR."viewuser.php?uid=".$om['online_uid']."'>".$om['penname']."</a>";
39
+	}
40
+	$tpl->assignGlobal("onlinemembers", count($omlist) ? implode(", ", $omlist) : "");
41
+	$content = "<div id='who_online'><span class='label'>"._GUESTS.":</span> ".($guests ? $guests : 0)."<br />\n
42
+		<span class='label'>"._MEMBERS.":</span> ".(count($omlist) ? implode(", ", $omlist) : "")."</div>";
43
+?>
0 44
\ No newline at end of file