ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/BBClone/trunk/lib/new_connect.php
Revision: 417
Committed: Wed Dec 21 11:27:14 2022 UTC (23 months, 1 week ago) by joku
File size: 3555 byte(s)
Log Message:
update Copyright 

File Contents

# Content
1 <?php
2 /* This file is part of BBClone (A PHP based Web Counter on Steroids)
3 *
4 * SVN FILE $Id$
5 *
6 * Copyright (C) 2001-2023, the BBClone Team (see doc/authors.txt for details)
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * See doc/copying.txt for details
19 */
20
21 /////////////////
22 // New Connect //
23 /////////////////
24
25 function bbc_get_extension($host, $addr) {
26 global $BBC_EXT_LOOKUP;
27
28 $ext = "";
29 if ($BBC_EXT_LOOKUP) {
30 // if plugin is defined, then try lookup via plugin
31 $ext = bbc_extension_plugin($host, $addr);
32 }
33
34 if ($ext) {
35 // plugin did find answer, so return it
36 return $ext;
37 }
38
39 // plugin did not find extention, try taking the last part of the hostname
40
41 $ext = strtolower(substr($host, (strrpos($host, ".") + 1)));
42 if (preg_match(":^[0-9]+$:", $ext)) {
43 return "ipv4";
44 } else if (strpos($host, ":") >0) {
45 return "ipv6";
46 } else if (strpos($host, ".") === false) {
47 return "unknown";
48 } else {
49 return $ext;
50 }
51 }
52
53
54 function bbc_update_connect($connect) {
55 global $BBC_LIB_PATH;
56
57 // Sanity check has already been made in mark_page.php
58 foreach (array("browser", "os", "robot") as $i) require($BBC_LIB_PATH.$i.".php");
59
60 $connect['visits'] = 1;
61
62 // Detecting robots, browsers and os
63 foreach (array("robot", "browser", "os") as $rule) {
64 reset($$rule);
65
66 //while (list(${$rule."_name"}, ${$rule."_elem"}) = each($$rule)) {
67 //reset(${$rule."_elem"}['rule']);
68 //fix for depreciated each() 5/2020
69
70 foreach($$rule as ${$rule."_name"} => ${$rule."_elem"}) {
71 reset(${$rule."_elem"}['rule']);
72
73
74 //while (list($pattern, $note) = each(${$rule."_elem"}['rule']))
75 //fix for depreciated each() 5/2020
76
77 foreach(${$rule."_elem"}['rule'] as $pattern => $note){
78 if (!preg_match('~'.$pattern.'~i', $connect['agent'], $regs)) continue;
79 $connect[$rule] = ${$rule."_name"};
80
81 if (preg_match(":\\\\[0-9]{1}:" ,$note)) {
82 $str = preg_replace(":\\\\([0-9]{1}):", "\$regs[\\1]", $note);
83
84 eval("\$str = \"$str\";");
85
86 $connect[$rule."_note"] = $str;
87 } else if (preg_match(":^text\:.*:", $note)) {
88 $connect[$rule."_note"] = substr($note, 5);
89 }
90 break 2;
91 }
92 }
93 if (!empty($connect['robot'])) break;
94 }
95 return $connect;
96 }
97
98 function bbc_update_access($connect) {
99 global $access;
100
101 // Assign an identification number to the new connection
102 $connect['id'] = isset($access['stat']['totalcount']) ? ($access['stat']['totalcount'] + 1) : 1;
103
104 // Recording the detected extension in the global statistics
105 $access['stat']['ext'][$connect['ext']] = !isset($access['stat']['ext'][$connect['ext']]) ? 1 :
106 ++$access['stat']['ext'][$connect['ext']];
107
108 foreach (array("robot", "browser", "os") as $type) {
109 if (($type == "robot") && (empty($connect[$type]))) continue;
110
111 if (isset($access['stat'][$type][$connect[$type]])) $access['stat'][$type][$connect[$type]]++;
112 else $access['stat'][$type][$connect[$type]] = 1;
113
114 if (($type == "robot") && (!empty($connect[$type]))) break;
115 }
116 return $connect;
117 }
118 ?>

Properties

Name Value
svn:keywords Id