Example #1
0
 public function getDatabaseVersions()
 {
     $dbs = array('GEOIP_COUNTRY_EDITION' => GEOIP_COUNTRY_EDITION, 'GEOIP_REGION_EDITION_REV0' => GEOIP_REGION_EDITION_REV0, 'GEOIP_CITY_EDITION_REV0' => GEOIP_CITY_EDITION_REV0, 'GEOIP_ORG_EDITION' => GEOIP_ORG_EDITION, 'GEOIP_ISP_EDITION' => GEOIP_ISP_EDITION, 'GEOIP_CITY_EDITION_REV1' => GEOIP_CITY_EDITION_REV1, 'GEOIP_REGION_EDITION_REV1' => GEOIP_REGION_EDITION_REV1, 'GEOIP_PROXY_EDITION' => GEOIP_PROXY_EDITION, 'GEOIP_ASNUM_EDITION' => GEOIP_ASNUM_EDITION, 'GEOIP_NETSPEED_EDITION' => GEOIP_NETSPEED_EDITION, 'GEOIP_DOMAIN_EDITION' => GEOIP_DOMAIN_EDITION);
     $res = array();
     foreach ($dbs as $name => $id) {
         if (!\geoip_db_avail($id)) {
             continue;
         }
         $info = \geoip_database_info($id);
         $x = explode(' ', $info);
         $res[] = array('name' => $name, 'file' => \geoip_db_filename($id), 'date' => $x[1], 'version' => $x[0]);
     }
     return $res;
 }
Example #2
0
function GeoIPavailable()
{
    if (!function_exists("geoip_db_filename")) {
        events('geoip_db_filename not available...');
        return;
    }
    $cst = array('GEOIP_COUNTRY_EDITION' => GEOIP_COUNTRY_EDITION, 'GEOIP_REGION_EDITION_REV0' => GEOIP_REGION_EDITION_REV0, 'GEOIP_CITY_EDITION_REV0' => GEOIP_CITY_EDITION_REV0, 'GEOIP_ORG_EDITION' => GEOIP_ORG_EDITION, 'GEOIP_ISP_EDITION' => GEOIP_ISP_EDITION, 'GEOIP_CITY_EDITION_REV1' => GEOIP_CITY_EDITION_REV1, 'GEOIP_REGION_EDITION_REV1' => GEOIP_REGION_EDITION_REV1, 'GEOIP_PROXY_EDITION' => GEOIP_PROXY_EDITION, 'GEOIP_ASNUM_EDITION' => GEOIP_ASNUM_EDITION, 'GEOIP_NETSPEED_EDITION' => GEOIP_NETSPEED_EDITION, 'GEOIP_DOMAIN_EDITION' => GEOIP_DOMAIN_EDITION);
    foreach ($cst as $k => $v) {
        events($k . ': ' . geoip_db_filename($v) . '  ' . (geoip_db_avail($v) ? 'Available' : ''));
    }
}
Example #3
0
 /**
  * Returns true if the PECL module that is installed can be successfully used
  * to get the location of an IP address.
  *
  * @return bool
  */
 public function isWorking()
 {
     // if no no location database is available, this implementation is not setup correctly
     if (!self::isLocationDatabaseAvailable()) {
         $dbDir = dirname(geoip_db_filename(GEOIP_COUNTRY_EDITION)) . '/';
         $quotedDir = "'{$dbDir}'";
         // check if the directory the PECL module is looking for exists
         if (!is_dir($dbDir)) {
             return Piwik::translate('UserCountry_PeclGeoIPNoDBDir', array($quotedDir, "'geoip.custom_directory'"));
         }
         // check if the user named the city database GeoLiteCity.dat
         if (file_exists($dbDir . 'GeoLiteCity.dat')) {
             return Piwik::translate('UserCountry_PeclGeoLiteError', array($quotedDir, "'GeoLiteCity.dat'", "'GeoIPCity.dat'"));
         }
         return Piwik::translate('UserCountry_CannotFindPeclGeoIPDb', array($quotedDir, "'GeoIP.dat'", "'GeoIPCity.dat'"));
     }
     return parent::isWorking();
 }
}
// Mode
$var = true;
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="set">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Parameter") . '</td><td>' . $langs->trans("Value") . '</td>';
print '<td align="right"><input type="submit" class="button" value="' . $langs->trans("Modify") . '"></td>';
print "</tr>\n";
$var = !$var;
print '<tr ' . $bc[$var] . '><td width=\\"50%\\">' . $langs->trans("PathToGeoIPMaxmindCountryDataFile") . '</td>';
print '<td colspan="2">';
if ($geointernal) {
    print 'Using geoip PHP internal functions. Value must be ' . geoip_db_filename(GEOIP_COUNTRY_EDITION) . ' or ' . geoip_db_filename(GEOIP_CITY_EDITION_REV1) . '<br>';
}
print '<input size="50" type="text" name="GEOIPMAXMIND_COUNTRY_DATAFILE" value="' . $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE . '">';
if ($geoip) {
    $version = $geoip->getVersion();
}
if ($version) {
    print '<br>' . $langs->trans("Version") . ': ' . $version;
}
print '</td></tr>';
print '</table>';
print "</form>\n";
print '<br>';
print $langs->trans("NoteOnPathLocation") . '<br>';
$url1 = 'http://www.maxmind.com/en/city?rId=awstats';
print $langs->trans("YouCanDownloadFreeDatFileTo", '<a href="' . $url1 . '" target="_blank">' . $url1 . '</a>');
Example #5
0
     error(sprintf($config['error']['toolong'], 'subject'));
 }
 if (!$mod && mb_strlen($post['body']) > $config['max_body']) {
     error($config['error']['toolong_body']);
 }
 if (mb_strlen($post['password']) > 20) {
     error(sprintf($config['error']['toolong'], 'password'));
 }
 wordfilters($post['body']);
 $post['body'] = escape_markup_modifiers($post['body']);
 if ($mod && isset($post['raw']) && $post['raw']) {
     $post['body'] .= "\n<tinyboard raw html>1</tinyboard>";
 }
 if ($config['country_flags']) {
     if (!geoip_db_avail(GEOIP_COUNTRY_EDITION)) {
         error('GeoIP not available: ' . geoip_db_filename(GEOIP_COUNTRY_EDITION));
     }
     if ($country_code = @geoip_country_code_by_name($_SERVER['REMOTE_ADDR'])) {
         if (!in_array(strtolower($country_code), array('eu', 'ap', 'o1', 'a1', 'a2'))) {
             $post['body'] .= "\n<tinyboard flag>" . strtolower($country_code) . "</tinyboard>" . "\n<tinyboard flag alt>" . @geoip_country_name_by_name($_SERVER['REMOTE_ADDR']) . "</tinyboard>";
         }
     }
 }
 if (mysql_version() >= 50503) {
     $post['body_nomarkup'] = $post['body'];
     // Assume we're using the utf8mb4 charset
 } else {
     // MySQL's `utf8` charset only supports up to 3-byte symbols
     // Remove anything >= 0x010000
     $chars = preg_split('//u', $post['body'], -1, PREG_SPLIT_NO_EMPTY);
     $post['body_nomarkup'] = '';
Example #6
0
 public function actionUsermap()
 {
     if (!function_exists('geoip_record_by_name')) {
         throw $this->responseException($this->responseError(new XenForo_Phrase('geoip_not_installed'), 503));
     } elseif (!geoip_db_avail(GEOIP_CITY_EDITION_REV0)) {
         throw $this->responseException($this->responseError(str_replace('{geoip_city_path}', geoip_db_filename(GEOIP_CITY_EDITION_REV0), new XenForo_Phrase('geoip_missing_database')), 503));
     }
     $sessionModel = $this->_getSessionModel();
     $bypassUserPrivacy = $this->_getUserModel()->canBypassUserPrivacy();
     $conditions = array('cutOff' => array('>', $sessionModel->getOnlineStatusTimeout()), 'getInvisible' => $bypassUserPrivacy, 'getUnconfirmed' => $bypassUserPrivacy, 'forceInclude' => $bypassUserPrivacy ? false : XenForo_Visitor::getUserId());
     $onlineUsers = $sessionModel->getSessionActivityRecords($conditions, array('perPage' => 5000, 'page' => 1, 'join' => XenForo_Model_Session::FETCH_USER, 'order' => 'view_date'));
     $users = $used_ip = $users_new = $users_added = $duplicate_location = array();
     $users_newest = array(0 => array(), 1 => array(), 3 => array());
     if (count($onlineUsers)) {
         foreach ($onlineUsers as $key => $user) {
             $user['ip'] = XenForo_Helper_Ip::convertIpBinaryToString($user['ip']);
             $onlineUsers[$key]['user_id'] = $user['user_id'] = intval($onlineUsers[$key]['user_id']);
             $users["{$user['user_id']}-{$user['ip']}"] = $user;
         }
     }
     $dataRegistryModel = $this->_getDataRegistryModel();
     $users_cached = $dataRegistryModel->get('userMap');
     if (count($users)) {
         foreach ($users as $key => $user) {
             if (isset($users_cached[$key])) {
                 // Read from cache
                 $type = substr($users_cached[$key], -1);
                 if ($type < 3) {
                     // Prioritize admins/mods and registered users
                     if ($user['is_staff']) {
                         $type = 3;
                     } elseif ($user['user_id']) {
                         $type = 0;
                     }
                 }
                 $users_new[$key] = substr($users_cached[$key], 0, -1) . $type;
             } else {
                 $user_location = @geoip_record_by_name($user['ip']);
                 if (!($user_location['longitude'] == 0 && $user_location['latitude'] == 0)) {
                     $type = $user['is_staff'] ? 3 : ($user['user_id'] ? 0 : ($user['robot_key'] ? 2 : 1));
                     if (!isset($used_ip[$user_location['longitude'] . ',' . $user_location['latitude']])) {
                         $string = $user_location['longitude'] . ',' . $user_location['latitude'] . ',' . $type;
                         if ($type < 2) {
                             $users_new = @array_merge(array($key => $string), $users_new);
                         } else {
                             $users_new[$key] = $string;
                         }
                         $used_ip[$user_location['longitude'] . ',' . $user_location['latitude']] = true;
                     } else {
                         $duplicate_location = @array_merge(array($key => $string), $users_new);
                     }
                 } else {
                     $duplicate_location = @array_merge(array($key => $string), $users_new);
                 }
             }
         }
     }
     $dataRegistryModel->set('userMap', @array_merge((array) $users_new, (array) $duplicate_location));
     foreach ($users_new as $key => $plot) {
         $type = substr($plot, -1);
         $users_newest[$type][] = substr($plot, 0, -2);
     }
     foreach ($users_newest as $key => $group) {
         $users_newest[$key] = @array_flip(@array_flip($users_newest[$key]));
     }
     $users_new = array();
     foreach (array(3, 0, 2, 1) as $type) {
         if (!empty($users_newest[$type])) {
             foreach ($users_newest[$type] as $plot) {
                 if (!isset($users_added[$plot])) {
                     $users_new[] = $plot . ',' . $type;
                     $users_added[$plot] = true;
                 }
             }
         }
     }
     $js_array = 'DigitalPointUserMap._UserMap.allPoints = new Array (';
     if (count($users_new)) {
         foreach ($users_new as $user) {
             $js_array .= "[{$user}],";
         }
         $js_array = substr($js_array, 0, -1) . ')';
     } else {
         $js_array .= ')';
     }
     $viewParams = array('js_array' => $js_array, 'user_location' => @geoip_record_by_name($_SERVER['REMOTE_ADDR']));
     return $this->responseView('DigitalPointUserMap_ViewPubic_UserMap_Index', 'usermap_index', $viewParams);
 }