ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/BBClone/trunk/lib/new_connect.php
Revision: 387
Committed: Mon May 11 12:29:05 2020 UTC (4 years, 6 months ago) by joku
File size: 3520 byte(s)
Log Message:
Here are some fixes for php 7.X from Steve, Thx

File Contents

# User Rev Content
1 joku 63 <?php
2     /* This file is part of BBClone (A PHP based Web Counter on Steroids)
3     *
4     * SVN FILE $Id$
5     *
6 joku 386 * Copyright (C) 2001-2020, the BBClone Team (see doc/authors.txt for details)
7 joku 63 *
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 joku 387 //while (list(${$rule."_name"}, ${$rule."_elem"}) = each($$rule)) {
67     //reset(${$rule."_elem"}['rule']);
68     //fix for depreciated each() 5/2020
69 joku 63
70 joku 387 foreach($$rule as ${$rule."_name"} => ${$rule."_elem"}) {
71    
72     //while (list($pattern, $note) = each(${$rule."_elem"}['rule']))
73     //fix for depreciated each() 5/2020
74    
75     foreach(${$rule."_elem"}['rule'] as $pattern => $note){
76 joku 63 if (!preg_match('~'.$pattern.'~i', $connect['agent'], $regs)) continue;
77     $connect[$rule] = ${$rule."_name"};
78    
79     if (preg_match(":\\\\[0-9]{1}:" ,$note)) {
80     $str = preg_replace(":\\\\([0-9]{1}):", "\$regs[\\1]", $note);
81    
82     eval("\$str = \"$str\";");
83    
84     $connect[$rule."_note"] = $str;
85     } else if (preg_match(":^text\:.*:", $note)) {
86     $connect[$rule."_note"] = substr($note, 5);
87     }
88     break 2;
89     }
90     }
91     if (!empty($connect['robot'])) break;
92     }
93     return $connect;
94     }
95    
96     function bbc_update_access($connect) {
97     global $access;
98    
99     // Assign an identification number to the new connection
100     $connect['id'] = isset($access['stat']['totalcount']) ? ($access['stat']['totalcount'] + 1) : 1;
101    
102     // Recording the detected extension in the global statistics
103     $access['stat']['ext'][$connect['ext']] = !isset($access['stat']['ext'][$connect['ext']]) ? 1 :
104     ++$access['stat']['ext'][$connect['ext']];
105    
106     foreach (array("robot", "browser", "os") as $type) {
107     if (($type == "robot") && (empty($connect[$type]))) continue;
108    
109     if (isset($access['stat'][$type][$connect[$type]])) $access['stat'][$type][$connect[$type]]++;
110     else $access['stat'][$type][$connect[$type]] = 1;
111    
112     if (($type == "robot") && (!empty($connect[$type]))) break;
113     }
114     return $connect;
115     }
116 joku 387 ?>

Properties

Name Value
svn:keywords Id