1
wishcraft
doing au.labs.coop or marrickiville.au.labs.coop or new-york.us.labs.coop all with places.labs.coop

This is done with the System Preloader places.php

<?php
/**
 * System Preloads
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright   The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 * @author          Cointin Maxime (AKA Kraven30)
 * @author          Andricq Nicolas (AKA MusS)
 * @version         $Id: core.php 12537 2014-05-19 14:19:33Z beckmi $
 */

// defined('XOOPS_ROOT_PATH') || die('XOOPS root path not defined');

if (!function_exists("getBaseDomain")) {
    
/**
     * getBaseDomain
     *
     * @param string $url
     * @return string|unknown
     */
    
function getBaseDomain($url)
    {

        static 
$fallout$stratauris$classes;

        if (empty(
$classes))
        {
            if (empty(
$stratauris)) {
                
$stratauris cleanWhitespaces(file(XOOPS_ROOT_PATH  DIRECTORY_SEPARATOR .  "data" DIRECTORY_SEPARATOR "stratas.diz"));
                
shuffle($stratauris); shuffle($stratauris); shuffle($stratauris); shuffle($stratauris);
            }
            
shuffle($stratauris);
            
$attempts 0;
            while(empty(
$classes) || $attempts <= (count($stratauris) * 1.65))
            {
                
$attempts++;
                
$classes array_keys(unserialize(getURIData($stratauris[mt_rand(0count($stratauris)-1)] ."/v1/strata/serial.api"120120)));
            }
        }
        if (empty(
$fallout))
        {
            if (empty(
$stratauris)) {
                
$stratauris cleanWhitespaces(file(XOOPS_ROOT_PATH  DIRECTORY_SEPARATOR .  "data" DIRECTORY_SEPARATOR "stratas.diz"));
                
shuffle($stratauris); shuffle($stratauris); shuffle($stratauris); shuffle($stratauris);
            }
            
shuffle($stratauris);
            
$attempts 0;
            while(empty(
$fallout) || $attempts <= (count($stratauris) * 1.65))
            {
                
$attempts++;
                
$fallout array_keys(unserialize(getURIData($stratauris[mt_rand(0count($stratauris)-1)] ."/v1/fallout/serial.api"120120)));
            }
        }

        
// Get Full Hostname
        
$url strtolower($url);
        
$hostname parse_url($urlPHP_URL_HOST);
        if (!
filter_var($hostnameFILTER_VALIDATE_IPFILTER_FLAG_IPV6 || FILTER_FLAG_IPV4) === false)
            return 
$hostname;

            
// break up domain, reverse
            
$elements explode('.'$hostname);
            
$elements array_reverse($elements);

            
// Returns Base Domain
            
if (in_array($elements[0], $classes))
                return 
$elements[1] . '.' $elements[0];
                elseif (
in_array($elements[0], $fallout) && in_array($elements[1], $classes))
                return 
$elements[2] . '.' $elements[1] . '.' $elements[0];
                elseif (
in_array($elements[0], $fallout))
                return  
$elements[1] . '.' $elements[0];
                else
                    return  
$elements[1] . '.' $elements[0];
    }
}


if (!
function_exists("getURIData")) {

    
/* function getURIData()
     *
     *     cURL Routine
     * @author         Simon Roberts (Chronolabs) simon@labs.coop
     *
     * @return         float()
     */
    
function getURIData($uri ''$timeout 65$connectout 65$post_data = array())
    {
        
addTimeLimit($timeout+$connectout);
        if (!
function_exists("curl_init"))
        {
            return 
file_get_contents($uri);
        }
        if (!
$btt curl_init($uri)) {
            return 
false;
        }
        
curl_setopt($bttCURLOPT_HEADER0);
        
curl_setopt($bttCURLOPT_POST, (count($posts)==0?false:true));
        if (
count($posts)!=0)
            
curl_setopt($bttCURLOPT_POSTFIELDShttp_build_query($post_data));
            
curl_setopt($bttCURLOPT_CONNECTTIMEOUT$connectout);
            
curl_setopt($bttCURLOPT_TIMEOUT$timeout);
            
curl_setopt($bttCURLOPT_RETURNTRANSFERtrue);
            
curl_setopt($bttCURLOPT_VERBOSEfalse);
            
curl_setopt($bttCURLOPT_SSL_VERIFYHOSTfalse);
            
curl_setopt($bttCURLOPT_SSL_VERIFYPEERfalse);
            
$data curl_exec($btt);
            
curl_close($btt);
            return 
$data;
    }
}


if (!
function_exists("addTimeLimit")) {
    
/**
     *
     * @param array $array
     */
    
function addTimeLimit($seconds 30)
    {
        static 
$timelimit 30;
        
$timelimit .+ $seconds;
        
set_time_limit($timelimit);
    }
}


if (!
function_exists("cleanWhitespaces")) {
    
/**
     *
     * @param array $array
     */
    
function cleanWhitespaces($array = array())
    {
        foreach(
$array as $key => $value)
        {
            if (
is_array($value))
                
$array[$key] = cleanWhitespaces($value);
                else {
                    
$array[$key] = trim(str_replace(array("n""r""t"), ""$value));
                }
        }
        return 
$array;
    }
}


if (!
function_exists("writeRawFile")) {
    
/**
     *
     * @param string $file
     * @param string $data
     */
    
function writeRawFile($file ''$data '')
    {
        
$lineBreak "n";
        if (
substr(PHP_OS03) == 'WIN') {
            
$lineBreak "rn";
        }
        if (!
is_dir(dirname($file)))
            if (
strpos(' '.$fileENTITIES_CACHE))
                
mkdirSecure(dirname($file), 0777true);
                else
                    
mkdir(dirname($file), 0777true);
                    elseif (
strpos(' '.$fileENTITIES_CACHE) && !file_exists(ENTITIES_CACHE DIRECTORY_SEPARATOR '.htaccess'))
                    
writeRawFile(ENTITIES_CACHE DIRECTORY_SEPARATOR '.htaccess'"<Files ~ "^.*$">ntdeny from alln</Files>");
                    if (
is_file($file))
                        
unlink($file);
                        
$data str_replace("n"$lineBreak$data);
                        
$ff fopen($file'w');
                        
fwrite($ff$datastrlen($data));
                        
fclose($ff);
    }
}
/**
 * Class SystemCorePreload
 */
class SystemPlacesPreload extends XoopsPreloadItem
{
    
/**
     * @param $args
     */
    
function eventCoreIncludeCommonEnd($args)
    {
        if (empty(
$stratauris)) {
            
$placesuris cleanWhitespaces(file(XOOPS_ROOT_PATH  DIRECTORY_SEPARATOR .  "data" DIRECTORY_SEPARATOR "places.diz"));
            
shuffle($placesuris); shuffle($placesuris); shuffle($placesuris); shuffle($placesuris);
        }
        
shuffle($stratauris);
        
xoops_load("XoopsCache");
        if (!isset(
$_SESSION['countries']) || empty($_SESSION['countries']))
        {
            if (!
$countries XoopsCache::read("places_api_countries"))
                
XoopsCache::write("places_api_countries"$countries json_decode(getURIData($placesuris[mt_rand(0count($placesuris)-1)] . '/v1/list/list/json.api'220220), true), 3600 *24 28 2.3);
            if (isset(
$countries['countries']) && !empty($countries['countries']))
            {
                
$_SESSION['countries'] = $countries['countries'];
                
$_SESSION['tlds'] = array();
                foreach(
$countries['countries'] as $country => $values)
                    if (!empty(
$values['TLD']))
                        
$_SESSION['tlds'][str_replace("."""$values['TLD'])] = $values;
            }
        }
        
        
define("XOOPS_HOSTNAME"getBaseDomain(XOOPS_URL));
        
$parts explode(":"str_replace(XOOPS_PROT""XOOPS_URL));
        
$hostname $parts[0];
        if (
$hostname != XOOPS_HOSTNAME)
        {
            
$parts explode("."str_replace(".".XOOPS_HOSTNAME""$hostname));
            
$tld $parts[count($parts)-1];
            unset(
$parts[count($parts)-1]);
            
$place $parts[count($parts)-1];
            if (!isset(
$_SESSION['keys']['places']['tlds'][$tld]) || empty($_SESSION['keys']['places']['tlds'][$tld]))
            {
                
$_SESSION['keys']['places']['tlds'][$tld] = $_SESSION['tlds'][$tld]['key']; 
            } 
            if (isset(
$_SESSION['tlds'][$tld]['key']))
            {
                
define('XOOPS_COUNTRY_KEY'$_SESSION['tlds'][$tld]['key']);
                
define('XOOPS_COUNTRY_NAME'$_SESSION['tlds'][$tld]['Country']);
                
define('XOOPS_COUNTRY_SUBDOMAIN'$tld);
            }
            if (
defined("XOOPS_COUNTRY_KEY") && !empty($place) > 0)
            {
                if (!isset(
$_SESSION['keys']['places']['place'][$place]) && empty($_SESSION['keys']['places']['place'][$place]))
                {
                    
$plae json_decode(getURIData($placesuris[mt_rand(0count($placesuris)-1)] . '/v1/'.XOOPS_COUNTRY_NAME.'/'.str_replace('-'' '$place). '/json.api'220220), true);
                    if (!empty(
$plae))
                        
$_SESSION['keys']['places']['place'][$place]['location'] = $plae;
                    if (!
$nearby XoopsCache::read($key "nearby_places_" XOOPS_COUNTRY_SUBDOMAIN "_" .$place))
                        
XoopsCache::write($key$nearby json_decode(getURIData($placesuris[mt_rand(0count($placesuris)-1)] . '/v1/key/'.$plae['place']['key'].'/' XOOPS_RADIUS_KMS '/json.api'220220), true), 3600 24 mt_rand(1.2343.765));
                    if (!empty(
$nearby['results']['nearby']))
                        
$_SESSION['keys']['places']['place'][$place]['nearby'] = $nearby['results']['nearby'];
                }
                if (isset(
$_SESSION['keys']['places']['place'][$place]) && !empty($_SESSION['keys']['places']['place'][$place]))
                {
                    
define('XOOPS_PLACE_KEY'$_SESSION['keys']['places']['place'][$place]['location']['place']['key']);
                    
define('XOOPS_PLACE_NAME'$_SESSION['keys']['places']['place'][$place]['location']['place']['RegionName']);
                    
define('XOOPS_PLACE_SUBDOMAIN'strtolower(str_replace(" ""-"$_SESSION['keys']['places']['place'][$place]['location']['place']['RegionName'])));
                    
$nearbysubs $nearbykeys $nearbynames = array();
                    if (!empty(
$_SESSION['keys']['places']['place'][$place]['nearby']))
                        foreach(
$_SESSION['keys']['places']['place'][$place]['nearby']['places'] as $country => $values)
                            foreach(
$values as $key => $place)
                            {
                                
$nearbykeys[$key] = $key;
                                
$nearbysubs[$key] = strtolower(str_replace(" ""-"$place['RegionName']));
                                
$nearbynames[$key] = $place['RegionName'];
                            }
                    
define('XOOPS_NEARBY_KEYS'implode(','$nearbykeys));
                    
define('XOOPS_NEARBY_NAMES'implode(','$nearbynames));
                    
define('XOOPS_NEARBY_SUBDOMAINS'implode(','$nearbysubs));
                }
            }        
        }
    }
}


You also have to adjust the mainfile.php line 43:

// XOOPS Virtual Path (URL)
    // Virtual path to your main XOOPS directory WITHOUT trailing slash
    // Example: define('XOOPS_URL', 'http://alluringwhores.com:8080');
    
define('XOOPS_URL'XOOPS_PROT.$_SERVER["HTTP_HOST"]);


You can then alter your theme.html from your theme where evere the <title/> tag is called to something like:-

<title><{if defined('XOOPS_PLACE_NAME') }><{$smarty.const.XOOPS_PLACE_NAME}> :: <{/if}><{if $xoops_pagetitle !=''}><{$xoops_pagetitle}> :: <{/if}><{$xoops_sitename}><{if defined('XOOPS_COUNTRY_NAME') }> ::: <{$smarty.const.XOOPS_COUNTRY_NAME}><{/if}></title>


And make various alterations around the system due to the accurate places data.

Login

Who's Online

202 user(s) are online (116 user(s) are browsing Support Forums)


Members: 0


Guests: 202


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits