Phalcon Framework 3.4.5

PDOException: SQLSTATE[HY000] [2002] Connection timed out

/home/finduslocal/public_html/config/services.php (178)
#0PDO->__construct(mysql:host=10.11.1.20;port=3308;dbname=findus_prod2;charset=utf8, findus_prod, URr=zyaZubbKYll>B>FaxYhNx, Array([3] => 2))
#1Phalcon\Db\Adapter\Pdo->connect(Array([host] => 10.11.1.20, [username] => findus_prod, [port] => 3308, [password] => URr=zyaZubbKYll>B>FaxYhNx, [dbname] => findus_prod2, [charset] => utf8, [options] => Array()))
#2Phalcon\Db\Adapter\Pdo->__construct(Array([host] => 10.11.1.20, [username] => findus_prod, [port] => 3308, [password] => URr=zyaZubbKYll>B>FaxYhNx, [dbname] => findus_prod2, [charset] => utf8, [options] => Array()))
/home/finduslocal/public_html/config/services.php (178)
<?php
/**
 * Created by Novnik Ltd.
 * User: artdevue - services.php
 * Date: 25.02.17
 * Time: 15:39
 * Project: phalcon-blank
 */
 
/**
 * Services are globally registered in this file
 */
 
use Phalcon\Cache\Backend\File;
use Phalcon\Cache\Frontend\Output;
use Phalcon\Mvc\Router,
    Phalcon\Mvc\Router\Group as RouterGroup,
    Phalcon\Mvc\Url as UrlResolver,
    Phalcon\DI\FactoryDefault,
    Phalcon\Mvc\View,
    Phalcon\Security,
    Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter,
    Phalcon\Flash\Direct as Flash,
    Phalcon\Crypt,
    Phalcon\Mvc\View\Engine\Volt,
    Phalcon\Mvc\Model\Metadata\Files as MetaDataAdapter,
    Phalcon\Session\Adapter\Files as SessionAdapter;
use Phalcon\Mvc\Router\Annotations as RouterAnnotations;
use Phalcon\Mvc\Model\Transaction\Manager as TransactionManager;
 
 
/**
 * The FactoryDefault Dependency Injector automatically register
 * the right services providing a full stack framework
 */
$di = new FactoryDefault();
 
/**
 * Registering a router
 */
$di['router'] = function () use ($config)
{
 
    //$router = new Router(false);
    // Use the annotations router. We're passing false as we don't want the router to add its default patterns
    $router = new RouterAnnotations(false);
 
//    $router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI);
    $router->removeExtraSlashes(true);
 
    if (!$config->debug)
    {
        $router->setDefaultModule($config->default_module);
        $router->setDefaults(['controller' => 'index', 'action' => 'route404']);
    }
 
    // Get explode uri
    $url_array = explode("/", $_SERVER['REQUEST_URI']);
    $module    = $config->default_module;
 
    $_SERVER['REQUEST_URI'] = str_replace("///","/",$_SERVER['REQUEST_URI']);
    $_SERVER['REQUEST_URI'] = str_replace("//","/",$_SERVER['REQUEST_URI']);
 
    $prefix_lang = '';
    $config->lang_active = $config->default_lang;
 
    // If multilanguage is allowed
    if ($config->multilang)
    {
        $langkey             =
            strlen($_SERVER['REQUEST_URI']) == 2 ? $_SERVER['REQUEST_URI'] : substr($_SERVER['REQUEST_URI'], 1, 2);
 
        if (in_array($langkey, array_keys($config->languages->toArray())) && $langkey != $config->default_lang)
        {
            $prefix_lang         = '/' . $langkey;
            $config->lang_active = $langkey;
        }
    }
 
    // Connecting routes for modules
    foreach ($config->modules as $key => $modul)
    {
        if (file_exists($modul->dir . 'config/routes.php'))
        {
            // Create a group with a backend module and controller
            $route = new RouterGroup([
                "module" => $key
            ]);
 
            // All the routes start with $prefix_router
            if (!empty($modul->prefix_router))
            {
                $route->setPrefix($prefix_lang . "/" . $modul->prefix_router);
                //$route->setPrefix("/" . $modul->prefix_router);
            } else
            {
                if (strlen($prefix_lang) > 1)
                {
                    $route->setPrefix($prefix_lang);
                }
 
            }
 
            // Hostname restriction
            if (!empty($modul->host_name))
            {
                $route->setHostName($modul->host_name);
            }
 
            $home_slesh = '';
 
            if ($key == $config->default_module && $_SERVER['REQUEST_URI'] == '/' )
            {
                $home_slesh = '/';
            }
 
            require $modul->dir . 'config/routes.php';
 
            // Add the group to the router
            $router->mount($route);
        }
 
        if (count($url_array) >= 2 && $url_array[1] == $modul->prefix_router)
        {
            $module = $key;
        }
    }
 
    if (!$config->debug)
    {
        $router->notFound([
            "module"     => $module,
            "controller" => "base",
            "action"     => "route404"
        ]);
    }
 
    return $router;
};
$di->set('cookies', function () {
    $cookies = new Phalcon\Http\Response\Cookies();
    $cookies->useEncryption(false);
    return $cookies;
}, true);
 
/**
 * Register the global configuration as config
 */
$di->set('config', $config);
 
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di->set('url', function () use ($config)
{
    $url = new UrlResolver();
    $url->setBaseUri('/');  // here
    return $url;
});
 
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di->set('Entrust', function () use ($config)
{
    return new Library\Entrust\Entrust();
});
 
//$di->set('eventsManager', 'Phalcon\Events\Manager', true);
$di->set('assets', 'Phalcon\Assets\Manager', true);
 
/**
 * Database connection is created based in the parameters defined in the configuration file
 */
$di['db'] = function () use ($config)
{
    return new DbAdapter([
        'host'     => $config->database->host,
        'username' => $config->database->username,
        'port' => $config->database->port,
        'password' => $config->database->password,
        'dbname'   => $config->database->dbname,
        'charset'  => $config->database->charset,
        'options' => [
            #PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
            #PDO::ATTR_PERSISTENT => true
//            1002 => "SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))"
        ]
    ]);
};
$di->set(
    'dispatcher',
    function () {
        // Create an event manager
        $eventsManager = new \Phalcon\Events\Manager();
 
        // Attach a listener for type 'dispatch'
        $eventsManager->attach(
            'dispatch',
            function (\Phalcon\Events\Event $event, $dispatcher) {
            }
        );
 
        $dispatcher = new \Phalcon\Mvc\Dispatcher();
 
        // Bind the eventsManager to the view component
        $dispatcher->setEventsManager($eventsManager);
 
        return $dispatcher;
    },
    true
);
/**
 * If the configuration specify the use of metadata adapter use it or use memory otherwise
 */
$di['modelsMetadata'] = function () use ($config)
{
    return new MetaDataAdapter([
        'metaDataDir' => $config->application->cacheDir . 'metaData/'
    ]);
};
 
/**
 * Crypt service
 */
$di->set('crypt', function () use ($config)
{
    $crypt = new \Phalcon\Crypt();
    $crypt->setKey($config->application->cryptSalt);
 
    return $crypt;
});
 
/**
 * Start the session the first time some component request the session service
 */
$di->set('session', function () use ($config)
{
    $session = new SessionAdapter([
        'uniqueId' => $config->prefix_session
    ]);
    $session->start();
 
    return $session;
});
 
/**
 * Flash service with custom CSS classes
 */
$di->set('flash', function ()
{
    return new Flash([
        'error'   => 'alert alert-danger notification-error',
        'success' => 'alert alert-success',
        'notice'  => 'alert alert-info',
        'warning' => 'alert alert-warning',
    ]);
});
 
$di->set(
    "flashSession",
    function () {
        return new Phalcon\Flash\Session([
            'error'   => 'alert alert-danger notification-error',
            'success' => 'alert alert-success',
            'notice'  => 'alert alert-info',
            'warning' => 'alert alert-warning',
        ]);
    }
);
 
/**
 * This component aids the developer in common security tasks such as password
 * hashing and Cross-Site Request Forgery protection (CSRF).
 */
$di->set('security', function ()
{
    $security = new Security();
 
    //Set the password hashing factor to 12 rounds
    $security->setWorkFactor(12);
 
    return $security;
}, true);
 
/**
 * Registering a Auth component
 */
$di->setShared('auth', '\Library\Auth\Auth');
$di->setShared('slug', '\Library\Slug');
$di->setShared('tag', '\Library\Tag');
$di->setShared(
    'transactions',
    function () {
        return new TransactionManager();
    }
);
/**
 * Register View
 */
$di['view'] = function () use ($config)
{
 
    $view = new View();
    $view->setViewsDir($config->application->viewsDir);
 
    $view->registerEngines([
        '.volt'  => function ($view, $di) use ($config)
        {
 
            $volt = new Volt($view, $di);
 
            $volt->setOptions([
                'compiledPath'      => $config->application->cacheDir . 'volt/',
                'compiledSeparator' => '_'
            ]);
 
            return $volt;
        },
        '.phtml' => 'Phalcon\Mvc\View\Engine\Php',
        '.php'   => 'Phalcon\Mvc\View\Engine\Php'
    ]);
 
    return $view;
};
/**
 * View cache
 */
//$di['viewCache'] = function ()
//{
//
//    //Cache data for one day by default
//    $frontCache = new Output([
//        "lifetime" => 2592000
//    ]);
//
//    /*return new \Phalcon\Cache\Backend\Apc($frontCache, array(
//        "prefix" => "cache-"
//    ));*/
//
//    return new File($frontCache, [
//        "cacheDir" => PROJECT_PATH . "cache/views/",
//        "prefix"   => "cache-"
//    ]);
//};
 
/**
 *  Setup mail system
 */
$di->set('mail', function ()
{
    $mail_setting    = include PROJECT_PATH . 'config/mail.php';
    $mail            = new \PHPMailer\PHPMailer\PHPMailer(true);
    $mail->SMTPDebug = $mail_setting->get('SMTPDebug');   // Enable verbose debug output
    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host       = $mail_setting->get('Host');       // Specify main and backup SMTP servers
    $mail->SMTPAuth   = $mail_setting->get('SMTPAuth');   // Enable SMTP authentication
    $mail->Username   = $mail_setting->get('Username');   // SMTP username
    $mail->Password   = $mail_setting->get('Password');   // SMTP password
    $mail->SMTPSecure = $mail_setting->get('SMTPSecure'); // Enable TLS encryption, `ssl` also accepted
    $mail->Port       = $mail_setting->get('Port');
    $mail->setFrom($mail_setting->setFrom->get('email'), $mail_setting->setFrom->get('name'));
 
    return $mail;
});
 
/**
 * Register Helpers Service
 */
if (!$di->has('helpers'))
{
    $di->setShared('helpers', 'Library\Helpers');
}
if (!$di->has('carbon'))
{
    $di->set('carbon', function () use ($config)
    {
        return new \Carbon\Carbon();
    });
}
if (!$di->has('e'))
{
    $di->set('e', function () use ($config)
    {
        return new \Phalcon\Escaper();
    });
}
if (!$di->has('random'))
{
    $di->set('random', function () use ($config)
    {
        return new \Phalcon\Security\Random();
    });
}
if (!$di->has('parse_rss'))
{
    $di->set('parse_rss', function () use ($config)
    {
        return new \Novnik\ParseRss\ParseRss([
            'file_log' => 'Runtime/parse-rss.log',
            'timezone' => 'US/Eastern'
        ]);
    });
}
 
if (!$di->has('sitemapCache'))
{
    $di->set('sitemapCache', function () use ($config)
    {
        //Cache data for one day by default
        $frontCache = new Phalcon\Cache\Frontend\Output(["lifetime" => 2592000]);
 
        //Memcached connection settings
        return new Phalcon\Cache\Backend\File($frontCache, [
            "cacheDir" => "../cache/sitemap/",
            "prefix"   => ""
        ]);
    });
}
 
 
if (!$di->has('frontCache'))
{
    $di->set('frontCache', function () use ($config)
    {
        //Cache data for one day by default
        $frontCache = new Phalcon\Cache\Frontend\Output(["lifetime" => 2592000]);
 
        //Memcached connection settings
        return new Phalcon\Cache\Backend\File($frontCache, [
            "cacheDir" => "../cache/front/",
            "prefix"   => "front-"
        ]);
    });
}
 
/**
 * Register Translation Service
 */
if (!$di->has('trans'))
{
    $di->setShared('trans', function ()
    {
        $trans = new \Library\Trans();
 
        return $trans->get();
    });
}
/**
 * Register Other
 */
if (!$di->has('trans'))
{
    $di->setShared('trans', function ()
    {
//        $trans = new \Library\Trans();
//
//        return $trans->get();
    });
}
 
// Register Subscription
/**
 * Registering a Codes library
 */
$di->setShared('codes', 'Library\Codes');
 
// Models cache service Register
$di->set('modelsCache', function ()
{
    // By default, the cache data is stored one day
    $frontCache = new \Phalcon\Cache\Frontend\Data([
        "lifetime" => 86400
    ]);
 
    return new File($frontCache, [
        "cacheDir" => PROJECT_PATH . "cache/model/",
        "prefix"   => "cache-"
    ]);
});
 
$di->set('userCache', function ()
{
    $frontCache = new \Phalcon\Cache\Frontend\Output([
        "lifetime" => 86400
    ]);
 
    return new File($frontCache, [
        "cacheDir" => PROJECT_PATH . "cache/model/",
        "prefix" => "user-"
    ]);
});
 
 
if (!$di->has('imailapi'))
{
    $di->setShared('imailapi', 'Library\ImailApi\ImailApi');
}
 
if (!$di->has('appAuth'))
{
    $di->setShared('appAuth', '\App\Auth\Auth');
}
 
if (!$di->has('locationServices'))
{
    $di->setShared('locationServices', '\App\Service\LocationServices');
}
 
/**
 * Register PHP Time Ago
 */
if (!$di->has('timeAgo'))
{
    $di->setShared('timeAgo', 'Westsworld\TimeAgo');
 
    /*$di->setShared('timeAgo', function ()
    {
        return new \Westsworld\TimeAgo();
    });*/
}
#3Closure->{closure}()
#4Phalcon\Di\Service->resolve(null, Object(Phalcon\Di\FactoryDefault))
#5Phalcon\Di->get(db, null)
#6Phalcon\Di->getShared(db)
#7Phalcon\Mvc\Model\Manager->_getConnection(Object(Apps\Commons\Models\Users: 58), null)
#8Phalcon\Mvc\Model\Manager->getReadConnection(Object(Apps\Commons\Models\Users: 58))
#9Phalcon\Mvc\Model->getReadConnection()
#10Phalcon\Mvc\Model\Query->getReadConnection(Object(Apps\Commons\Models\Users: 58), Array([models] => Array([0] => Apps\Commons\Models\Users), [tables] => Array([0] => users), [columns] => Array([apps\Commons\Models\Users] => Array([type] => object, [model] => Apps\Commons\Models\Users, [column] => users, [balias] => apps\Commons\Models\Users)), [limit] => Array([number] => Array([type] => placeholder, [value] => :APL0))), Array([APL0] => 1), Array([APL0] => 1))
#11Phalcon\Mvc\Model\Query->_executeSelect(Array([models] => Array([0] => Apps\Commons\Models\Users), [tables] => Array([0] => users), [columns] => Array([apps\Commons\Models\Users] => Array([type] => object, [model] => Apps\Commons\Models\Users, [column] => users, [balias] => apps\Commons\Models\Users)), [limit] => Array([number] => Array([type] => placeholder, [value] => :APL0))), Array([APL0] => 1), Array([APL0] => 1))
#12Phalcon\Mvc\Model\Query->execute()
#13Phalcon\Mvc\Model::findFirst(null)
/home/finduslocal/public_html/library/Auth/Auth.php (329)
<?php namespace App\Auth;
 
/**
 * Created by PhpStorm.
 * User: AtrDevue - Auth.php
 * Date: 20.07.16
 * Time: 13:54
 * Project: novnikv2
 */
 
use Apps\Commons\Models\RememberTokens;
use Apps\Commons\Models\SuccessLogins;
use Apps\Commons\Models\Users;
use Phalcon\Mvc\User\Component,
    Phalcon\Exception;
 
/**
 * App\Auth\Auth
 *
 * Manages Authentication/Identity Management in Novnikv2
 */
class Auth extends Component
{
    /**
     * @var Users
     */
    protected $user;
 
    /**
     * Checks the user credentials
     *
     * @param      $email
     * @param      $password
     * @param bool $remember
     * @param      $client_type
     *
     * @return bool|string
     */
    public function check($email, $password, $remember = false)
    {
        // Check user on the basis of
        $user = Users::findFirstByEmail($email);
 
        // Check the user
        if (!$user)
        {
            throw new Exception('No user in the system');
        }
 
        // Check the correct password
        if (!$this->security->checkHash($password, $user->password))
        {
            throw new Exception('You entered the wrong password');
        }
 
        // Check if the user was flagged
        $this->checkUserFlags($user);
 
        // Register the successful login
        $this->saveSuccessLogin($user);
 
        // Check if the remember me was selected
        if ($remember)
        {
            $this->createRememberEnviroment($user);
        }
 
        $this->session->set('auth-identity', [
            'id' => $user->id,
            'name' => $user->getFullName()
        ]);
 
        return true;
    }
 
    /**
     * @param      $username
     * @param      $password
     * @param      $client_type
     * @param bool $remember
     *
     * @return bool
     * @throws Exception
     */
    public function checkUsername($username, $password, $client_type, $remember = false)
    {
        // Finds whether a variable is an array
        if (!is_array($client_type))
        {
            $client_type = [$client_type];
        }
 
        // Check user on the basis of
        $user = Users::findFirst([
            'conditions' => 'username = :username: AND client_type IN ({clientType:array})',
            'bind' => [
                'username' => $username,
                'clientType' => $client_type,
            ]
        ]);
 
        // Check the correct password
        if (!$user || !$this->security->checkHash($password, $user->password))
        {
            throw new Exception('No user in the system or the correct password');
        }
 
        // Check if the user was flagged
        $this->checkUserFlags($user);
 
        // Register the successful login
        $this->saveSuccessLogin($user);
 
        // Check if the remember me was selected
        if ($remember)
        {
            $this->createRememberEnviroment($user);
        }
 
        $this->session->set('auth-identity', [
            'id' => $user->id,
            'name' => $user->getFullName()
        ]);
 
        return true;
    }
 
    /**
     * Checks if the user is banned/inactive
     *
     * @param Users $user
     *
     * @throws bool|string
     */
    public function checkUserFlags(Users $user)
    {
        if ($user->status <> 0)
        {
            throw new Exception('The user is inactive');
        }
 
        if ($user->banned <> 0)
        {
            throw new Exception('Your account has been suspended by administration');
        }
    }
 
    /**
     * Returns the current identity
     *
     * @return array
     */
    public function getIdentity()
    {
        return $this->session->get('auth-identity');
    }
 
    /**
     * Returns the current identity
     *
     * @return string
     */
    public function getName()
    {
        $identity = $this->session->get('auth-identity');
 
        return $identity['name'];
    }
 
    /**
     * Creates the remember me environment settings the related cookies and generating tokens
     *
     * @param Users $user
     *
     * @return bool
     * @throws Exception
     */
    public function saveSuccessLogin($user)
    {
        //return true;
 
        $successLogin = new SuccessLogins();
        $successLogin->usersId = $user->id;
        $successLogin->time = time();
        $successLogin->ipAddress = $this->request->getClientAddress();
        $successLogin->userAgent = $this->request->getUserAgent();
        if (!$successLogin->save())
        {
            $messages = $successLogin->getMessages();
            throw new Exception($messages[0]);
        }
    }
 
    /**
     * Creates the remember me environment settings the related cookies and generating tokens
     *
     * @param Users $user
     *
     * @throws \Exception
     * @return null|void
     */
    public function createRememberEnviroment(Users $user)
    {
        $token = $this->getToken($user);
 
        $remember = RememberTokens::findFirst([
            'token = :token:',
            'bind' => [
                'token' => $token,
            ]
        ]);
 
        if (!$remember)
        {
            $remember = new RememberTokens();
            $remember->usersId = $user->id;
            $remember->token = $token;
            $remember->userAgent = $this->request->getUserAgent();
            if (!$remember->save())
            {
                throw new \Exception;
            }
        }
 
        if (!$remember)
        {
            return null;
        }
 
        $expire = time() + 86400 * 8;
        $this->cookies->set('user', $user->id, $expire, '/', null, null, true);
        $this->cookies->set('token', $token, $expire, '/', null, null, true);
    }
 
    /**
     * Check if the session has a remember me cookie
     *
     * @return boolean
     */
    public function hasRememberMe()
    {
        return $this->cookies->has('user');
    }
 
    /**
     * Generates a pseudo random token key to be used as input’s name in a CSRF check
     *
     * @param Users $user
     *
     * @return string
     */
    protected function getToken(Users $user)
    {
        $userAgent = $this->request->getUserAgent();
        $token = md5($user->email . $userAgent);
 
        return $token;
    }
 
    /**
     * Auths the user by his/her id
     *
     * @param int        $id
     * @param bool|false $remember
     *
     * @return bool
     * @throws Exception
     * @throws \Exception
     */
    public function authUserById($id, $remember = false)
    {
        $user = Users::findFirst($id);
        if ($user == false)
        {
            throw new Exception('The user does not exist');
        }
 
        $this->checkUserFlags($user);
 
        $this->saveSuccessLogin($user);
 
        if ($remember)
        {
            $this->createRememberEnviroment($user);
        }
 
        $this->session->set('auth-identity', [
            'id' => $user->id,
            'name' => $user->getFullName()
        ]);
 
        return true;
    }
 
    /**
     * Logs on using the information in the coookies
     *
     * @return Users|bool
     * @throws Exception
     */
    public function getUser()
    {
//        if (null !== $this->user)
//        {
//            return $this->user;
//        }
 
        /**
         * @var Users $user
         */
 
        $identity = $this->session->get('auth-identity');
//        $identity['id'] = 139280;
        if (is_array($identity) and isset($identity['id']))
        {
            if (!$user = Users::findFirst($identity['id']))
            {
                throw new Exception('The user does not exist');
            }
 
            $this->user = $user;
 
            return $user;
        }
 
        $userId = $this->cookies->get('user')->getValue('int');
        $cookieToken = $this->cookies->get('token')->getValue();
 
        if ($user = Users::findFirst($userId))
        {
            $token = $this->getToken($user);
 
            if ($cookieToken == $token)
            {
                $remember = RememberTokens::findFirst([
                    'usersId = ?0 AND token = ?1',
                    'bind' => [$user->id, $token]
                ]);
 
                if ($remember)
                {
                    //Check if the cookie has not expired
                    if ((time() - (86400 * 8)) < $remember->createdAt)
                    {
                        //Check if the user was flagged
                        $this->checkUserFlags($user);
 
                        //Register identity
                        $this->session->set('auth-identity', [
                            'id' => $user->id,
                            'name' => $user->getFullName()
                        ]);
 
                        //Register the successful login
                        $this->saveSuccessLogin($user);
 
                        $this->user = $user;
 
                        return $user;
                    }
                }
            }
        }
 
        $this->removeCookie();
 
        return false;
    }
 
    /**
     * Removes the user identity information from session
     */
    public function remove()
    {
        if ($this->user)
        {
            $userAgent = $this->request->getUserAgent();
            $token = md5($this->user->email . $userAgent);
 
            $remember = RememberTokens::findFirst([
                'token = ?0',
                'bind' => [$token]
            ]);
 
            if ($remember)
            {
                $remember->delete();
            }
        }
 
        $this->removeCookie();
 
        $this->session->remove('auth-identity');
    }
 
    /**
     * Check if a cookie is defined in the bag or exists in the _COOKIE superglobal
     */
    protected function removeCookie()
    {
        $this->cookies->get('user')->delete();
        $this->cookies->get('token')->delete();
    }
}
#14App\Auth\Auth->getUser()
/home/finduslocal/public_html/apps/frontend/controllers/BaseController.php (51)
<?php
namespace  Apps\Frontend\Controllers;
 
use Apps\Commons\Models\GeodataGeocity;
use Library\Tag;
use Phalcon\Dispatcher;
use Phalcon\Events\Event;
use Phalcon\Mvc\Controller;
 
 
class BaseController extends Controller
{
    /**
     * @var object $geocity
     */
    public $geocity;
 
    /**
     * @var string $local_header_name
     */
    public $local_header_name;
 
    /**
     * Model User
     *
     * @var object $user
     */
    public $user;
 
    /**
     * @var int $user_id
     */
    public $user_id = 0;
 
    /**
     * Triggered before executing the controller/action method. At this point the dispatcher has been initialized
     * the controller and know if the action exist.
     *
     * @param Dispatcher $dispatcher
     *
     * @Triggered on Listeners/Controllers
     */
    public function beforeExecuteRoute(Dispatcher $dispatcher)
    {
        $this->view->setPartialsDir(PROJECT_PATH. 'apps/commons/views/');
        $this->view->setLayoutsDir(PROJECT_PATH. 'apps/frontend/views/');
 
        $this->response->setHeader("X-Frame-Options", "DENY");
 
        // This is executed before every found action
        $this->user = $this->appAuth->getUser();
 
        if (!empty($this->user))
        {
            $this->user_id = $this->user->id;
        }
 
        $ip = $this->request->getClientAddress();
 
        $userLocation = $this->locationServices->getIpLocation($ip);
 
        $city    = $this->config->default->get('city');
        $country = $this->config->default->get('country');
 
        if($this->request->has('loccity') || $this->session->has('location')){
 
            if($this->request->has('loccity')){
                $this->session->remove("location");
                $searchByCity = $this->request->get('loccity');
            }else{
                $searchByCity = $this->session->get('location')['city_url'];
            }
            $searchCity = $this->locationServices->getCityViaSearch($searchByCity);
 
            if($searchCity){
                $this->geocity = $searchCity;
            }
        }
 
        if(!$this->geocity){
            if (!empty($userLocation) && !empty($userLocation['country']) && strtoupper($userLocation['country']) == $country && !empty($userLocation['region']))
            {
                $this->geocity = GeodataGeocity::findFirst([
                    'conditions' => 'city = :loc_city: AND region=:loc_region: AND country = :loc_country:',
                    'bind'       => ['loc_city' => $userLocation['city'], 'loc_region'=>$userLocation['region'], 'loc_country' => $country]
                ]);
            }
        }
 
        if (!$this->geocity)
        {
            $this->geocity = GeodataGeocity::findFirst([
                'conditions' => 'city = :city: AND country = :country:',
                'bind'       => compact('city', 'country')
            ]);
        }
    }
 
 
    /**
     * Allow to globally initialize the controller in the request
     *
     * @Triggered on Controllers
     */
    public function initialize()
    {
        $this->assets->collection('header');
        $this->assets->collection('js-header');
        $this->assets->collection('footer');
 
        Tag::setTitle($this->config->get('site-name'));
        Tag::setTitleSeparator(", ");
 
        $this->view->setLayout('profile-layout');
 
        $this->view->setVars([
                'geocity' => $this->geocity,
                'user'    => $this->user,
                'user_id' => $this->user_id
            ]
        );
    }
 
    /**
     * Triggered after executing the controller/action method. As operation cannot be stopped, only use this event
     * to make clean up after execute the action
     *
     * @param $dispatcher
     *
     * @Triggered on Listeners/Controllers
     */
    public function afterExecuteRoute($dispatcher)
    {
        $this->view->setVars([
                'local_header_name' => $this->local_header_name,
            ]
        );
    }
 
    protected function _curl_fetch($url)
    {
        $crl = curl_init();
 
        curl_setopt($crl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)');
        curl_setopt($crl, CURLOPT_URL, $url);
        curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 3);
 
        $ret = curl_exec($crl);
        curl_close($crl);
 
        return $ret;
    }
 
}
#15Apps\Frontend\Controllers\BaseController->beforeExecuteRoute(Object(Phalcon\Mvc\Dispatcher))
/home/finduslocal/public_html/apps/frontend/controllers/IndexController.php (37)
<?php
 
namespace  Apps\Frontend\Controllers;
 
 
use App\Service\GoogleCaptcha;
use Apps\Commons\Models\Categories;
use Apps\Commons\Models\CategoriesToplevel;
use Apps\Commons\Models\CategoryKeyword;
use Apps\Commons\Models\Content;
use Apps\Commons\Models\FranchiseBystate;
use Apps\Commons\Models\GeodataGeocity;
use Apps\Commons\Models\GeodataUsstates;
use Apps\Commons\Models\OrderItems;
use Apps\Commons\Models\RemovedBusinesses;
use Apps\Frontend\Forms\ContactUs;
use Phalcon\Mvc\View;
use Phalcon\Dispatcher;
use Phalcon\Paginator\Adapter\Model;
 
class IndexController extends BaseController
{
    public function beforeExecuteRoute(Dispatcher $dispatcher)
    {
 
        $this->view->setLayout('profile-layout');
 
        if (!in_array($dispatcher->getActionName(), ['summary', 'job_opportunities', 'people'])):
            $this->assets->collection('header')
                ->addCss('/css/profile-ful.css', false);
            $this->assets->collection('header')
                ->addJs('/javascript/alljs.js', false, true, ['defer' => ''])
                ->addJs('/tooltipjs/jquery.betterTooltip.js', false, true, ['defer' => '']);
 
        endif;
 
        return parent::beforeExecuteRoute($dispatcher);
 
    }
 
    public function initialize()
    {
        $this->view->setLayout('profile-layout');
        $this->view->robots = 'true';
        return parent::initialize(); // TODO: Change the autogenerated stub
 
    }
 
    public function cronJobsAction() {
        $this->view->disable();
        $request = $this->request->get();
        $flag = isset($request['flag'])?$request['flag']:'';
 
        if (empty($flag)) die('No flag provided');
        var_dump($flag);
    }
 
    /**
     * Redirect depending on the city
     */
    public function indexAction()
    {
 
        return $this->response->redirect([
            'for'      => "frontent.region.city",
            'region'   => strtolower($this->geocity->region),
            'city_url' => $this->geocity->url_id
        ]);
 
    }
 
    /**
     * @param string $alphabet
     */
    public function franchisesAction($alphabet = null)
    {
        $states = GeodataUsstates::find([
            'order' => 'statetitle'
        ]);
 
        $this->assets->collection('header')
            ->addCss('/css/slide.css', false);
 
        $categories = Categories::find([
            'conditions' => 'parent_id = "0" AND status = "1"',
            'group'      => 'url_id',
            'order'      => 'name, sort_order'
        ]);
 
        /*$companies = Content::find([
            'columns'    => 'company, URLid',
            'conditions' => 'state = :state: AND city = :city: AND company LIKE :company: AND active = "1"',
            'bind'       => [
                'state'   => $this->geocity->region,
                'city'    => $this->geocity->city,
                'company' => $alphabet . '%'
            ],
            'order'      => 'company'
        ]);*/
 
        $franchise_bystate = null;
        if (!empty($alphabet)) {
            $franchise_bystate = FranchiseBystate::find([
                'conditions' => 'state = :state: AND company LIKE :company:',
                'bind'       => ['state' => $this->geocity->region, 'company' => $alphabet . '%'],
                'orderBy'    => 'company,'
            ]);
        }
 
        $this->assets->collection('header')
            ->addCss('/css/profile_business-ful.css', false);
 
        $this->view->setVars(compact('states', 'categories', 'franchise_bystate', 'alphabet'));
    }
 
 
    public function _showShoppingCategory($page)
    {
 
        $_cat         = CategoriesToplevel::findFirstByUrlId('shopping');
        $category_ids = explode(',', $_cat->mapped_rootcats);
        $category_ids = array_merge($category_ids, explode(',', $_cat->mapped_subcats));
 
        $contents = Content::find([
            'conditions' => 'state = :state: AND category_id IN ({category_ids:array}) AND active = "1"',
            "bind"       => [
                'state'        => $this->geocity->region,
                'category_ids' => $category_ids
            ]
        ]);
 
        // Create a Model paginator, show config rows by page starting from $page
        $paginator = new Model(
            [
                "data"  => $contents,
                "limit" => $this->config->default->get('companies_per_page'),
                "page"  => $page,
            ]
        );
 
        // Get the paginated results
        $pages = $paginator->getPaginate();
 
        $local_header_name =
            sprintf('Local %s in %s (%s)', 'shopping', $this->geocity->HasGeodataUsstates->statetitle,
                $this->geocity->region);
 
        $this->tag->appendTitle($local_header_name);
        $_pager_url   = [];
        $_pager_url[] = 'shopping';
 
        $pager_url                     = implode('/', $_pager_url);
        $this->view->pages             = $pages;
        $this->view->city              = null;
        $this->view->region            = null;
        $this->view->pager_url         = $pager_url;
        $this->view->local_header_name = $local_header_name;
 
        $this->helpers::addMetaTag('description',
            "Shopping In Your Local Area Or State will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
 
        $this->helpers::addMetaTag('keywords', "Shopping,company,reviews,directions,local,business hours");
        $this->helpers::addMetaTag('revisit-after', '1 days');
        $this->helpers::addMetaTag('rating', 'general');
        $this->helpers::addMetaTag('og:title', "Shopping  In Your Local Area Or State");
        $this->helpers::addMetaTag('og:type', 'website');
        $this->helpers::addMetaTag('og:url', BASE_URL .$this->router->getRewriteUri());
        $this->helpers::addMetaTag('og:site_name', 'Find Us Local');
        $this->helpers::addMetaTag('og:description',
            "Shopping In Your Local Area Or State will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
        $this->helpers::addMetaTag('og:image', 'https://www.finduslocal.com/static/v3images/finduslocal-logo-mobile-min.png');
//        $this->helpers::addMetaTag('robots', 'noindex,noarchive,nosnippet,follow');
 
        return $this->view->pick("index/shopping_listing");
    }
 
    /**
     * Output category page
     *
     * @param string $category
     */
    public function categoryAction($category, $page = null)
    {
        $category = $this->filter->sanitize($category, 'string');
 
        // Remove duplicate pages
        if ($page == 1 OR $page == "0")
        {
            return $this->response->redirect([
                'for'      => "frontent.index.category",
                'category' => $category
            ]);
        }
 
        if (is_null($page))
        {
            $page = 1;
        }
 
        if ($category == 'shopping')
        {
            return $this->_showShoppingCategory($page);
        }
 
        // Get Category
        $categoryObject   = Categories::findFirstByUrl_id($category);
        $category_ids     = [];
        $categoriesObject = null;
        $show_categories  = true;
 
        $radius = $this->request->get('radius', 'int', 50); //mill
 
        if ($categoryObject)
        {
            $category_ids = [$categoryObject->id];
 
            if ($categoryObject->parent_id == 0)
            {
                $categoriesObject = Categories::findByParent_id($categoryObject->id);
 
                foreach ($categoriesObject as $co):
                    array_push($category_ids, $co->id);
                endforeach;
            }
 
            $lat = $this->geocity->latitude;
            $lon = $this->geocity->longitude;
 
            $angle_radius = $radius / 111; // Every lat|lon degree° is ~ 69.40Mill
 
            //Fetch the list of companies
            $contents = Content::find([
                'conditions' => 'state = :state: AND category_id IN ({category_ids:array}) AND active = "1" AND lat BETWEEN :min_lat: AND :max_lat: AND lng BETWEEN :min_lon: AND :max_lon:',
                "bind"       => [
                    'state' => $this->geocity->region,
                    'category_ids' => $category_ids,
                    'min_lat'      => $lat - $angle_radius,
                    'max_lat'      => $lat + $angle_radius,
                    'min_lon'      => $lon - $angle_radius,
                    'max_lon'      => $lon + $angle_radius
                ]
            ]);
 
        } else
        {
 
            $categoryObject  = new Categories();
            $show_categories = false;
 
            $lat = $this->geocity->latitude;
            $lon = $this->geocity->longitude;
 
            $angle_radius = $radius / 111; // Every lat|lon degree° is ~ 69Mill
 
            //Fetch the list of companies
            $contents = Content::find([
                'conditions' => 'state = :state: AND URLid = :category: AND active = "1" AND lat BETWEEN :min_lat: AND :max_lat: AND lng BETWEEN :min_lon: AND :max_lon:',
                "bind"       => [
                    'state' => $this->geocity->region,
                    'category' => $category,
                    'min_lat'      => $lat - $angle_radius,
                    'max_lat'      => $lat + $angle_radius,
                    'min_lon'      => $lon - $angle_radius,
                    'max_lon'      => $lon + $angle_radius
                ]
            ]);
 
            if (!empty($contents))
            {
                $first_elm              = $contents->getFirst();
                $categoryObject->name   = !empty($first_elm) ? $first_elm->company : null;
                $categoryObject->url_id = $category;
            }
 
            $category_ids_array = [];
            foreach ($contents as $content)
            {
                $category_ids_array[$content->category_id] = $content->category_id;
            }
 
            if (!empty($category_ids_array))
            {
                $categoryObject->Keywords = CategoryKeyword::find([
                    'conditions' => 'category_id IN ({categoryids:array})',
                    'bind'       => ['categoryids' => array_keys($category_ids_array)],
                    'limit'      => 70,
                    'order'      => 'RAND()'
                ]);
            }
        }
 
 
        if ($contents->count() > 0)
        {
            // Get states
            $states = GeodataUsstates::find([
                'group' => 'statecode',
                'order' => 'statetitle'
            ]);
            /*$state_code_array = [];
            foreach ($contents as $content)
            {
                $state_code_array[$content->state] = $content->state;
            }
 
            if (!empty($state_code_array))
            {
                $states = GeodataUsstates::find([
                    'conditions' => 'statecode = ({statecode:array})',
                    "bind"       => ['statecode' => array_keys($state_code_array)],
                    'group'      => 'statecode',
                    'order'      => 'statetitle'
                ]);
            }*/
 
 
            // Create a Model paginator, show config rows by page starting from $page
            $paginator = new Model(
                [
                    "data"  => $contents,
                    "limit" => $this->config->default->get('companies_per_page'),
                    "page"  => $page,
                ]
            );
 
            // Get the paginated results
            $pages = $paginator->getPaginate();
 
            $this->local_header_name =
                sprintf('Local %s in %s (%s)', $categoryObject->name, $this->geocity->HasGeodataUsstates->statetitle,
                    $this->geocity->region);
 
            $this->tag->appendTitle("$categoryObject->name  In Your Local Area Or State");
 
            //Return variables to model
            $this->view->setVars(compact('pages', 'categoryObject', 'categoriesObject'));
 
            $navURL = trim($this->router->getRewriteUri(), '/');
 
            if ($page > 1) {
                $navURL = rtrim($navURL, "/$page");
            }
 
            $this->view->navURL          = $navURL;
            $this->view->stateSet        = null;
            $this->view->radius          = $radius;
            $this->view->categorySet     = $categoryObject;
            $this->view->citySet         = null;
            $this->view->states          = $states;
            $this->view->show_categories = $show_categories;
            $this->helpers::addMetaTag('description',
                "$categoryObject->name In Your Local Area Or State will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
 
            $this->helpers::addMetaTag('keywords',
                "$categoryObject->name,company,reviews,directions,local,business hours");
            $this->helpers::addMetaTag('revisit-after', '1 days');
            $this->helpers::addMetaTag('rating', 'general');
            $this->helpers::addMetaTag('og:title', "$categoryObject->name  In Your Local Area Or State");
            $this->helpers::addMetaTag('og:type', 'website');
            $this->helpers::addMetaTag('og:url', BASE_URL .$this->router->getRewriteUri());
            $this->helpers::addMetaTag('og:site_name', 'Find Us Local');
            $this->helpers::addMetaTag('og:description',
                "$categoryObject->name In Your Local Area Or State will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
            $this->helpers::addMetaTag('og:image', 'https://www.finduslocal.com/static/v3images/finduslocal-logo-mobile-min.png');
//            $this->helpers::addMetaTag('robots', 'noindex,noarchive,nosnippet,follow');
 
            return $this->view->pick("index/categories_listing");
        }
        /*
                //$content_searchfields = ContentSearchfields::find()
 
                // Check is content url
                $is_content = false;
 
                $contents = Content::find([
                    'conditions' => 'state = :state: AND URLid = :category: AND active = "1"',
                    "bind"       => ['state' => $this->geocity->region, 'category' => $category]
                ]);
 
                if ($contents->count() > 0)
                {
                    // Get first record of $contents
                    $first_company = $contents->getFirst();
 
                    // Get company of another state
                    $states = Content::find([
                        'conditions' => 'URLid = :category:',
                        "bind"       => ['category' => $category],
                        'group'      => 'state',
                        'order'      => 'state'
                    ]);
 
                    $states_array = [];
                    foreach ($states as $state)
                    {
                        $url_id = $state->HasState->url_id;
 
                        $count = Content::count([
                            'conditions' => 'URLid = :category: AND state = :state:',
                            "bind"       => ['category' => $category, 'state' => $state->state],
                        ]);
 
                        $states_array[$url_id] = [
                            'count' => $count,
                            'name'  => sprintf('%s (%s)', $state->HasState->statetitle, $state->state),
                            'url'   => $this->url->get([
                                'for'      => 'frontent.index.two_url',
                                'category' => $first_company->URLid,
                                'url'      => $url_id
                            ])
                        ];
                    }
 
                    $show_bottom_header = true;
 
                    // Create a Model paginator, show config rows by page starting from $page
                    $paginator = new Model(
                        [
                            "data"  => $contents,
                            "limit" => $this->config->default->get('companies_per_page'),
                            "page"  => $page,
                        ]
                    );
 
                    // Get the paginated results
                    $pages = $paginator->getPaginate();
 
                    $this->local_header_name = sprintf('Local %s in Your Local Area Or State', $first_company->company);
 
                    $this->tag->appendTitle($this->local_header_name);
 
                    //Return variables to model
                    $this->view->setVars(compact('first_company', 'pages', 'show_bottom_header', 'states_array'));
 
                    $this->helpers::addMetaTag('description',
                        "$categoryObject In Your Local Area Or State will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
 
                    $this->helpers::addMetaTag('keywords', "$categoryObject,company,reviews,directions,local,business hours");
                    $this->helpers::addMetaTag('revisit-after', '1 days');
                    $this->helpers::addMetaTag('rating', 'general');
                    $this->helpers::addMetaTag('og:title', "$categoryObject  In Your Local Area Or State");
                    $this->helpers::addMetaTag('og:type', 'website');
                    $this->helpers::addMetaTag('og:url', $this->router->getRewriteUri());
                    $this->helpers::addMetaTag('og:site_name', 'Find Us Local');
                    $this->helpers::addMetaTag('og:description', "$categoryObject->name In Your Local Area Or State will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
                    $this->helpers::addMetaTag('og:image', '//res.finduslocal.com/v3images/finduslocal-logo.png');
                    $this->helpers::addMetaTag('robots', 'noindex,noarchive,nosnippet,follow');
 
                    return $this->view->pick("index/company_listing");
 
                }
 
 
                return $this->response->redirect(['for' => 'home'], false, 404);
        */
    }
 
    /**
     * @param string $category
     * @param string $url
     * @param null   $page
     *
     * @return \Phalcon\Mvc\View
     */
    public function _showShoppingCategoryWithRegion($region, $page)
    {
        if ($geodata_us_state = GeodataUsstates::findFirstByUrl_id($region))
        {
 
        } else
        {
            return $this->dispatcher->forward(array(
                "controller" => "index",
                "action" => "page404"
            ));
        }
 
        $_cat         = CategoriesToplevel::findFirstByUrlId('shopping');
        $category_ids = explode(',', $_cat->mapped_rootcats);
        $category_ids = array_merge($category_ids, explode(',', $_cat->mapped_subcats));
 
        $contents = Content::find([
            'conditions' => 'state = :state: AND category_id IN ({category_ids:array}) AND active = "1"',
            "bind"       => [
                'state'        => $geodata_us_state->statecode,
                'category_ids' => $category_ids
            ]
        ]);
 
        // Create a Model paginator, show config rows by page starting from $page
        $paginator = new Model(
            [
                "data"  => $contents,
                "limit" => $this->config->default->get('companies_per_page'),
                "page"  => $page,
            ]
        );
 
        // Get the paginated results
        $pages = $paginator->getPaginate();
 
//        $local_header_name = sprintf('Local %s in %s (%s)', 'shopping', $geodata_geocity->HasGeodataUsstates->statetitle, $geodata_geocity->region);
        $local_header_name = sprintf('Local %s in %s (%s)', 'shopping',"", "");
 
        $this->tag->appendTitle($local_header_name);
        $_pager_url   = [];
        $_pager_url[] = 'shopping';
        if ($geodata_us_state)
        {
            $_pager_url[] = $geodata_us_state->url_id;
        }
 
        $pager_url                     = implode('/', $_pager_url);
        $this->view->pages             = $pages;
        $this->view->city              = null;
        $this->view->region            = $geodata_us_state;
        $this->view->pager_url         = $pager_url;
        $this->view->local_header_name = $local_header_name;
 
        $this->helpers::addMetaTag('description',
            "Shopping In  $geodata_us_state->statetitle ($geodata_us_state->statecode) will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
 
        $this->helpers::addMetaTag('keywords',
            "Shopping,company,reviews,directions,$geodata_us_state->statetitle,$geodata_us_state->statecode,local,business hours");
        $this->helpers::addMetaTag('revisit-after', '1 days');
        $this->helpers::addMetaTag('rating', 'general');
        $this->helpers::addMetaTag('og:title',
            "Shopping In  $geodata_us_state->statetitle ($geodata_us_state->statecode)");
        $this->helpers::addMetaTag('og:type', 'website');
        $this->helpers::addMetaTag('og:url', BASE_URL .$this->router->getRewriteUri());
        $this->helpers::addMetaTag('og:site_name', 'Find Us Local');
        $this->helpers::addMetaTag('og:description',
            "Shopping In  $geodata_us_state->statetitle ($geodata_us_state->statecode) will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
        $this->helpers::addMetaTag('og:image', 'https://www.finduslocal.com/static/v3images/finduslocal-logo-mobile-min.png');
//        $this->helpers::addMetaTag('robots', 'noindex,noarchive,nosnippet,follow');
 
        return $this->view->pick("index/shopping_listing");
    }
 
    /**
     * @param string $category
     * @param string $url
     * @param null   $page
     *
     * @return \Phalcon\Mvc\View
     */
    public function two_urlAction($category, $url, $page = null)
    {
 
        $caregory_url = $this->filter->sanitize($category, 'string');
        $url          = $this->filter->sanitize($url, 'string');
        // Remove duplicate pages
        if ($page == 1 OR $page == "0")
        {
            return $this->response->redirect([
                'for'      => "frontent.index.two_url",
                'category' => $caregory_url,
                'url'      => $url
            ]);
        }
 
        if (is_null($page))
        {
            $page = 1;
        }
 
        if ($caregory_url == 'shopping')
        {
            return $this->_showShoppingCategoryWithRegion($url, $page);
        }
// else
//        {
//            return $this->_showCategoryWithRegion($category, $url, $page);
//        }
 
 
        $category       = Categories::findFirstByUrl_id($caregory_url);
        $name_company   = false;
        $categoryObject = null;
 
        $geodata_us_state = GeodataUsstates::findFirstByUrl_id($url);
        $category_ids     = [];
 
        if (!$category)
        {
            $category        = new Categories();
            $show_categories = false;
 
            //Fetch the list of companies
            $contents = Content::find([
                'conditions' => 'state = :state: AND URLid = :category: AND active = "1"',
                "bind"       => ['state' => $geodata_us_state->statecode, 'category' => $caregory_url]
            ]);
 
            if (!empty($contents))
            {
                $name_company = true;
 
                $first_elm = $contents->getFirst();
                $category->name = $first_elm->company;
                $category->url_id = $caregory_url;
 
                $category_ids_array = [];
                foreach ($contents as $content)
                {
                    $category_ids_array[$content->category_id] = $content->category_id;
                }
 
                if (!empty($category_ids_array))
                {
                    $category_ids = array_keys($category_ids_array);
                    $category->Keywords = CategoryKeyword::find([
                        'conditions' => 'category_id IN ({categoryids:array})',
                        'bind' => ['categoryids' => array_keys($category_ids_array)],
                        'limit' => 70,
                        'order' => 'RAND()'
                    ]);
                }
            }
        }
        else {
            $category_ids = [$category->id];
            if ($category->parent_id == 0)
            {
                $parent_categories = Categories::findByParent_id($category->id);
 
                foreach ($parent_categories as $item)
                {
                    array_push($category_ids, $item->id);
                }
            }
 
            if (!empty($geodata_us_state))
            {
                $contents = Content::find([
                    'conditions' => 'state = :state:  AND category_id IN ({category_ids:array}) AND active = "1"',
                    "bind"       => [
                        'state'        => $geodata_us_state->statecode,
                        'category_ids' => $category_ids
                    ]
                ]);
            }
        }
 
        if (!empty($contents))
        {
            // Get first record of $contents
            $first_company = $contents->getFirst();
 
            // Get company of another cites
            $cites = Content::find([
                'conditions' => 'state = :state:  AND category_id IN ({category_ids:array}) AND active = "1"',
                "bind"       => ['category_ids' => $category_ids, 'state' => $geodata_us_state->statecode],
                'group'      => 'city',
                'order'      => 'city'
            ]);
 
            $cites_array = [];
            foreach ($cites as $city)
            {
                $first_letter = $city->city{0};
                $url_id       = $city->HasCity->url_id;
 
                if (empty($cites_array[$first_letter]))
                {
                    $cites_array[$first_letter] = [];
                }
 
                $count = Content::count([
                    'conditions' => 'category_id IN ({category_ids:array}) AND active = "1" AND state = :state: AND city = :city:',
                    "bind"       => [
                        'category_ids' => $category_ids,
                        'state'        => $geodata_us_state->statecode,
                        'city'         => $city->city
                    ]
                ]);
 
                $cites_array[$first_letter][$url_id] = [
                    'count' => $count,
                    'name'  => $city->city,
                    'url'   => $this->url->get([
                        'for'   => 'frontent.index.three_url',
                        'url_1' => $category->url_id,
                        'url_2' => $geodata_us_state->url_id,
                        'url_3' => $url_id
                    ])
                ];
            }
 
            // Create a Model paginator, show config rows by page starting from $page
            $paginator = new Model(
                [
                    "data"  => $contents,
                    "limit" => $this->config->default->get('companies_per_page'),
                    "page"  => $page,
                ]
            );
 
            // Get the paginated results
            $pages = $paginator->getPaginate();
 
            if (!empty($first_company))
            {
                $show_bottom_header = true;
 
                $this->local_header_name =
                    "Local $category->name In  $geodata_us_state->statetitle ($geodata_us_state->statecode)";
            }
 
            $this->tag->appendTitle("$category->name In  $geodata_us_state->statetitle ($geodata_us_state->statecode)");
 
            //Return variables to model
            $this->view->setVars(compact('first_company', 'pages', 'show_bottom_header', 'cites_array',
                'geodata_us_state', 'url'));
 
            $navURL = trim($this->router->getRewriteUri(), '/');
 
            if ($page > 1) {
                $navURL = rtrim($navURL, "/$page");
            }
 
            $this->view->navURL      = $navURL;
            $this->view->stateSet    = $geodata_us_state;
            $this->view->categorySet = $category;
            $this->view->citySet     = null;
 
            $this->helpers::addMetaTag('description',
                "$category->name In  $geodata_us_state->statetitle ($geodata_us_state->statecode) will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
 
            $this->helpers::addMetaTag('keywords',
                "$category->name,company,reviews,directions,$geodata_us_state->statetitle,$geodata_us_state->statecode,local,business hours");
            $this->helpers::addMetaTag('revisit-after', '1 days');
            $this->helpers::addMetaTag('rating', 'general');
            $this->helpers::addMetaTag('og:title',
                "$category->name In  $geodata_us_state->statetitle ($geodata_us_state->statecode)");
            $this->helpers::addMetaTag('og:type', 'website');
            $this->helpers::addMetaTag('og:url', BASE_URL .$this->router->getRewriteUri());
            $this->helpers::addMetaTag('og:site_name', 'Find Us Local');
            $this->helpers::addMetaTag('og:description',
                "$category->name In  $geodata_us_state->statetitle ($geodata_us_state->statecode) will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
            $this->helpers::addMetaTag('og:image', 'https://www.finduslocal.com/static/v3images/finduslocal-logo-mobile-min.png');
//            $this->helpers::addMetaTag('robots', 'noindex,noarchive,nosnippet,follow');
 
            return $this->view->pick("index/cites_listing");
        }
 
        return $this->dispatcher->forward(array(
            "controller" => "index",
            "action" => "page404"
        ));
    }
 
 
    /**
     * @param string $region
     * @param string $city
     * @param null   $page
     *
     * @return \Phalcon\Mvc\View
     */
    protected function _showShoppingCategoryWithRegionAndCity($region, $city, $page)
    {
 
        if ($geodata_us_state = GeodataUsstates::findFirstByUrl_id($region))
        {
            $geodata_geocity = GeodataGeocity::findFirst([
                'conditions' => 'region = :region: AND url_id = :url:',
                "bind"       => ['region' => $geodata_us_state->statecode, 'url' => $city]
            ]);
 
            if (!$geodata_geocity)
            {
                return $this->dispatcher->forward(array(
                    "controller" => "index",
                    "action" => "page404"
                ));
            }
        } else
        {
            return $this->dispatcher->forward(array(
                "controller" => "index",
                "action" => "page404"
            ));
        }
 
        $_cat         = CategoriesToplevel::findFirstByUrlId('shopping');
        $category_ids = explode(',', $_cat->mapped_rootcats);
        $category_ids = array_merge($category_ids, explode(',', $_cat->mapped_subcats));
 
        $contents = Content::find([
            'conditions' => 'state = :state: AND city=:city: AND category_id IN ({category_ids:array}) AND active = "1"',
            "bind"       => [
                'state'        => $geodata_geocity->region,
                'city'         => $geodata_geocity->city,
                'category_ids' => $category_ids
            ]
        ]);
 
        // Create a Model paginator, show config rows by page starting from $page
        $paginator = new Model(
            [
                "data"  => $contents,
                "limit" => $this->config->default->get('companies_per_page'),
                "page"  => $page,
            ]
        );
 
        // Get the paginated results
        $pages = $paginator->getPaginate();
 
        $local_header_name =
            sprintf('Local %s in %s (%s)', 'shopping', $geodata_geocity->HasGeodataUsstates->statetitle,
                $geodata_geocity->region);
 
        $this->tag->appendTitle($local_header_name);
 
        $_pager_url   = [];
        $_pager_url[] = 'shopping';
        $_pager_url[] = $geodata_us_state->url_id;
        $_pager_url[] = $geodata_geocity->url_id;
 
        $pager_url                     = implode('/', $_pager_url);
        $this->view->pages             = $pages;
        $this->view->city              = $geodata_geocity;
        $this->view->region            = $geodata_us_state;
        $this->view->pager_url         = $pager_url;
        $this->view->local_header_name = $local_header_name;
 
        $this->helpers::addMetaTag('description',
            "Shopping In $geodata_geocity->city, $geodata_us_state->statetitle ($geodata_geocity->region) will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
 
        $this->helpers::addMetaTag('keywords',
            "Shopping,company,reviews,directions,$geodata_us_state->statetitle,$geodata_geocity->region,$geodata_geocity->city,local,business hours");
        $this->helpers::addMetaTag('revisit-after', '1 days');
        $this->helpers::addMetaTag('rating', 'general');
        $this->helpers::addMetaTag('og:title',
            "Shopping In $geodata_geocity->city, $geodata_us_state->statetitle ($geodata_geocity->region)");
        $this->helpers::addMetaTag('og:type', 'website');
        $this->helpers::addMetaTag('og:url', BASE_URL .$this->router->getRewriteUri());
        $this->helpers::addMetaTag('og:site_name', 'Find Us Local');
        $this->helpers::addMetaTag('og:description',
            "Shopping In $geodata_geocity->city, $geodata_us_state->statetitle ($geodata_geocity->region) will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
        $this->helpers::addMetaTag('og:image', 'https://www.finduslocal.com/static/v3images/finduslocal-logo-mobile-min.png');
//        $this->helpers::addMetaTag('robots', 'noindex,noarchive,nosnippet,follow');
 
        return $this->view->pick("index/shopping_listing");
 
    }
 
    /**
     * @param string $category
     * @param string $region
     * @param string $city
     * @param null   $page
     *
     * @return \Phalcon\Mvc\View
     */
    protected function _showCategoryWithRegionAndCity($category, $region, $city, $page)
    {
//var_dump($page);die;
        if ($geodata_us_state = GeodataUsstates::findFirstByUrl_id($region))
        {
            $geodata_geocity = GeodataGeocity::findFirst([
                'conditions' => 'region = :region: AND url_id = :url:',
                "bind"       => ['region' => $geodata_us_state->statecode, 'url' => $city]
            ]);
 
            if (!$geodata_geocity)
            {
                return $this->dispatcher->forward(array(
                    "controller" => "index",
                    "action" => "page404"
                ));
            }
        } else
        {
            return $this->dispatcher->forward(array(
                "controller" => "index",
                "action" => "page404"
            ));
        }
 
 
        $category_ids = [$category->id];
 
        $parent_categories = null;
 
        if ($category->parent_id == 0)
        {
            $parent_categories = Categories::findByParent_id($category->id);
 
            foreach ($parent_categories as $item)
            {
                array_push($category_ids, $item->id);
            }
        }
 
        $lat = $geodata_geocity->latitude;
        $lon = $geodata_geocity->longitude;
        $radius = $this->request->get('radius', 'int', 50); //mill
 
        $angle_radius = $radius / 111; // Every lat|lon degree° is ~ 69Mill
 
        //Fetch the list of companies by state, city and categories
        $contents = Content::find([
            'conditions' => 'state = :state: AND city=:city: AND category_id IN ({category_ids:array}) AND active = "1" AND lat BETWEEN :min_lat: AND :max_lat: AND lng BETWEEN :min_lon: AND :max_lon:',
            "bind"       => [
                'state'        => $geodata_geocity->region,
                'city'         => $geodata_geocity->city,
                'category_ids' => $category_ids,
                'min_lat'      => $lat - $angle_radius,
                'max_lat'      => $lat + $angle_radius,
                'min_lon'      => $lon - $angle_radius,
                'max_lon'      => $lon + $angle_radius
            ]
        ]);
 
        // Create a Model paginator, show config rows by page starting from $page
        $paginator = new Model(
            [
                "data"  => $contents,
                "limit" => $this->config->default->get('companies_per_page'),
                "page"  => $page,
            ]
        );
 
        // Get the paginated results
        $pages = $paginator->getPaginate();
 
        $local_header_name =
            "$category->name In $geodata_geocity->city, $geodata_us_state->statetitle ($geodata_geocity->region)";
 
        $navURL = trim($this->router->getRewriteUri(), '/');
 
        if ($page > 1) {
            $navURL = rtrim($navURL, "/$page");
        }
 
        $this->tag->appendTitle($local_header_name);
        $this->view->navURL           = $navURL;
        $this->view->radius           = $radius;
        $this->view->stateSet         = $geodata_us_state;
        $this->view->categorySet      = $category;
        $this->view->citySet          = $geodata_geocity;
        $this->view->pages            = $pages;
        $this->view->categoryObject   = $category;
        $this->view->categoriesObject = $parent_categories;
 
        $this->helpers::addMetaTag('description',
            "$category->name In $geodata_geocity->city, $geodata_us_state->statetitle ($geodata_geocity->region) will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
 
        $this->helpers::addMetaTag('keywords',
            "$category->name,company,reviews,directions,$geodata_us_state->statetitle,$geodata_geocity->region,$geodata_geocity->city,local,business hours");
        $this->helpers::addMetaTag('revisit-after', '1 days');
        $this->helpers::addMetaTag('rating', 'general');
        $this->helpers::addMetaTag('og:title',
            "$category->name In $geodata_geocity->city, $geodata_us_state->statetitle ($geodata_geocity->region)");
        $this->helpers::addMetaTag('og:type', 'website');
        $this->helpers::addMetaTag('og:url', BASE_URL .$this->router->getRewriteUri());
        $this->helpers::addMetaTag('og:site_name', 'Find Us Local');
        $this->helpers::addMetaTag('og:description',
            "$category->name In $geodata_geocity->city, $geodata_us_state->statetitle ($geodata_geocity->region) will keep their profiles up to date so you can easily get their Phone Numbers, Address, Reviews, or Business Hours");
        $this->helpers::addMetaTag('og:image', 'https://www.finduslocal.com/static/v3images/finduslocal-logo-mobile-min.png');
//        $this->helpers::addMetaTag('robots', 'noindex,noarchive,nosnippet,follow');
 
        return $this->view->pick("index/categories_listing");
    }
 
    /**
     * @param string $category
     * @param string $region
     * @param string $city
     * @param null   $page
     *
     * @return \Phalcon\Mvc\View
     */
    protected function _showCategoryWithRegion($category, $region, $page)
    {
 
        if ($geodata_us_state = GeodataUsstates::findFirstByUrl_id($region))
        {
        } else
        {
            return $this->dispatcher->forward(array(
                "controller" => "index",
                "action" => "page404"
            ));
        }
 
        $category_ids = [$category->id];
 
        $parent_categories = null;
 
        if ($category->parent_id == 0)
        {
            $parent_categories = Categories::findByParent_id($category->id);
 
            foreach ($parent_categories as $item)
            {
                array_push($category_ids, $item->id);
            }
        }
 
 
        //Fetch the list of companies by state, city and categories
        $contents = Content::find([
            'conditions' => 'state = :state: AND category_id IN ({category_ids:array}) AND active = "1"',
            "bind"       => [
                'state'        => $geodata_us_state->statecode,
                'category_ids' => $category_ids
            ]
        ]);
 
        // Create a Model paginator, show config rows by page starting from $page
        $paginator = new Model(
            [
                "data"  => $contents,
                "limit" => $this->config->default->get('companies_per_page'),
                "page"  => $page,
            ]
        );
 
        // Get the paginated results
        $pages = $paginator->getPaginate();
 
        if ($category == 'shopping')
        {
            $local_header_name =
                sprintf('Local %s in %s', 'shopping', $geodata_us_state->statetitle);
        } else
        {
            $local_header_name =
                sprintf('Local %s in %s', $category->name, $geodata_us_state->statetitle);
        }
        $this->tag->appendTitle($local_header_name);
 
 
        $this->view->navURL           = ltrim($this->router->getRewriteUri(), '/');
        $this->view->stateSet         = $geodata_us_state;
        $this->view->categorySet      = $category;
        $this->view->pages            = $pages;
        $this->view->categoryObject   = $category;
        $this->view->categoriesObject = $parent_categories;
 
        return $this->view->pick("index/categories_listing");
    }
 
    /**
     * @param string $url_1
     * @param string $url_2
     * @param string $url_3
     * @param null   $page
     *
     * @return \Phalcon\Mvc\View
     */
    public function three_urlAction($url_1, $url_2, $url_3, $page = null)
    {
//        var_dump($url_1);
//        var_dump($url_2);
//        var_dump($url_3);
//        die;
        // Remove duplicate pages
        if ($page == 1 OR $page == "0")
        {
            return $this->response->redirect([
                'for'   => "rontent.index.three_url",
                'url_1' => $url_1,
                'url_2' => $url_2,
                'url_3' => $url_3
            ]);
        }
 
        if (is_null($page))
        {
            $page = 1;
        }
 
        if ($url_1 == 'shopping')
        {
            return $this->_showShoppingCategoryWithRegionAndCity($url_2, $url_3, $page);
        }
 
        $categories = Categories::findFirstByUrl_id($url_1);
        if ($categories)
        {
            return $this->_showCategoryWithRegionAndCity($categories, $url_2, $url_3, $page);
        }
 
 
        // If $category is state
        if ($geodata_us_state = GeodataUsstates::findFirstByUrl_id($url_2))
        {
            $geodata_geocity = GeodataGeocity::findFirst([
                'conditions' => 'region = :region: AND url_id = :url:',
                "bind"       => ['region' => $geodata_us_state->statecode, 'url' => $url_3]
            ]);
 
            if ($geodata_geocity)
            {
                $lat = $geodata_geocity->latitude;
                $lon = $geodata_geocity->longitude;
                $radius = $this->request->get('radius', 'int', 5); //mill
 
                /*$angle_radius = $radius / 111; // Every lat|lon degree° is ~ 111Km
                $min_lat = $lat - $angle_radius;
                $max_lat = $lat + $angle_radius;
                $min_lon = $lon - $angle_radius;
                $max_lon = $lon + $angle_radius;*/
 
                $contents = Content::find([
                    'conditions' => 'state = :state: AND city = :city: AND URLid = :url:',
                    "bind"       => [
                        'state' => $geodata_us_state->statecode,
                        'city'  => $geodata_geocity->city,
                        'url'   => $url_1,
 
                    ]
                ]);
 
 
                // Get first record of $contents
                $first_company = $contents->getFirst();
 
                // Create a Model paginator, show config rows by page starting from $page
                $paginator = new Model(
                    [
                        "data"  => $contents,
                        "limit" => $this->config->default->get('companies_per_page'),
                        "page"  => $page,
                    ]
                );
 
                // Get the paginated results
                $pages = $paginator->getPaginate();
 
                if (!empty($first_company))
                {
                    $show_bottom_header = true;
 
                    $this->local_header_name =
                        sprintf('Local %s in %s of state %s (%s)', $first_company->company, $geodata_geocity->city,
                            $geodata_us_state->statetitle, $geodata_us_state->statecode);
                }
 
                $this->tag->appendTitle($this->local_header_name);
 
                //Return variables to model
                $this->view->setVars(compact('first_company', 'pages', 'show_bottom_header', 'geodata_us_state',
                    'geodata_geocity', 'url_1', 'url_2', 'url_3'));
 
                return $this->view->pick("index/city_listing");
            }
        }
 
        return $this->dispatcher->forward(array(
            "controller" => "index",
            "action" => "page404"
        ));
 
    }
 
    /**
     * Show owner (people) page
     *
     * @param string $category
     * @param string $region
     * @param string $city
     * @param string $owner
     */
    public function peopleAction($category, $region, $city, $owner,$company,$street=null)
    {
 
        $cities_mapping_array = $this->cities_mapping_array();
 
        $mapped_city = isset($cities_mapping_array[$city]) ? $cities_mapping_array[$city] : null;
 
        $is_mapped_city = false;
        if ($mapped_city) {
            $city = $mapped_city;
            $is_mapped_city = true;
        }
 
        $type             = 'people';
        $geodata_usstates = GeodataUsstates::findFirstByUrl_id($region);
        if (!empty($geodata_usstates))
        {
            $geodata_geocity = GeodataGeocity::findFirst([
                'conditions' => 'region = :region: AND url_id = :url:',
                "bind"       => ['region' => $geodata_usstates->statecode, 'url' => $city]
            ]);
 
            $categories = Categories::findFirstByUrl_id($category);
 
            if (!empty($geodata_geocity) && !empty($categories) && !empty($street))
            {
                $content = Content::findFirst([
                    'conditions' => 'state = :state: AND URLid = :url: AND city = :city: AND address_URLid = :street:',
                    'bind'       => [
                        'state' => $geodata_usstates->statecode,
                        'url'   => $company,
                        'city'  => $geodata_geocity->city,
                        'street' => $street,
                    ]
                ]);
 
                if (!$content && $is_mapped_city) {
                    $content = Content::findFirst([
                        'conditions' => 'state = :state: AND URLid = :url: AND address_URLid = :street:',
                        'bind'       => [
                            'state' => $geodata_usstates->statecode,
                            'url'   => $company,
                            'street' => $street,
                        ]
                    ]);
                }
 
                if (!empty($content) AND $content->isOwner() AND $content->getOwnerNameUrl() == $owner)
                {
                    $this->assets->collection('header')
                        ->addCss('/css/profile_business-ful.css', false);
 
                    $this->tag->appendTitle(sprintf('%s %s in %s, %s %s',
                        $content->getOwnerName(), $categories->name, $content->city, $content->state, $content->zip));
 
                    $featured_businesses = Content::find([
                        'conditions' => 'state = :state: AND featured = "1" AND city = :city:',
                        'bind'       => ['state' => $geodata_usstates->statecode, 'city' => $geodata_geocity->city],
                        'order'      => 'RAND()',
                        'limit'      => 4
                    ]);
 
                   /* var_dump($content->address_URLid);
                    var_dump(BASE_URL.$content->full_url."_".$content->address_URLid);
                    die;*/
                    
                    /*$this->assets->collection('header')
                        ->addJs('/review_systemajax/reviewsystem.js', false)
                        ->addJs('/javascript/alljs.js', false)
                        ->addJs('https://gdc.indeed.com/ads/apiresults.js', false, false)
                        ->addJs('/tooltipjs/jquery.betterTooltip.js', false);*/
                    $this->assets->collection('header')
//                        ->addJs('/review_systemajax/reviewsystem.js', false)
//                        ->addJs('/javascript/alljs.js', false)
                        ->addJs('/review_systemajax/reviewsystem.js', false, true, ['defer' => ''])
                        ->addJs('/javascript/alljs.js', false, true, ['defer' => ''])
                        ->addJs('https://gdc.indeed.com/ads/apiresults.js', false, false, ['defer' => ''])
                        ->addJs('/tooltipjs/jquery.betterTooltip.js', false, false, ['defer' => '']);
//                        ->addJs('https://gdc.indeed.com/ads/apiresults.js', false, false)
//                        ->addJs('/tooltipjs/jquery.betterTooltip.js', false);
 
                    $reviewcontainer = true;
 
                    $this->view->wallpaperbox =
                        $this->_getWallpaperBox($geodata_usstates->statecode, $geodata_geocity->city);
 
                    $remove_business = RemovedBusinesses::findFirst([
                        'conditions' => 'content_id = :content_id: AND parentcategory_id = :parentcategory_id: AND confirmed = :confirmed:',
                        'bind' => ['content_id' => $content->id, 'parentcategory_id' => $content->parentcategory_id, 'confirmed' => 1]
                    ]);
 
                    $return = $this->view->pick("index/profile/people");
 
                    if ($remove_business) {
                        $reviewcontainer = false;
                        $return = $this->view->pick("index/profile/profile_removed");
                    }
 
                    $canonical = BASE_URL.$content->full_url;
 
                    if (!empty($content->address_URLid)) {
                        $canonical .= "_".$content->address_URLid;
                    }
 
                    $meta_tags[] = '<link rel="canonical" href="'.$canonical.'/" />';
 
                    $meta_tags   = implode("\n", $meta_tags);
 
                    $paid = false;
 
                    $this->view->META_TAGS = $meta_tags;
 
                    $this->view->setVars(compact('content', 'categories', 'geodata_geocity', 'geodata_usstates',
                        'this_url', 'featured_businesses', 'type', 'reviewcontainer', 'paid'));
 
                    return $return;
                }
            }
        }
 
        return $this->dispatcher->forward(array(
            "controller" => "index",
            "action" => "page404"
        ));
 
    }
 
    /**
     * @param string      $category
     * @param string      $region
     * @param string      $city
     * @param string      $company
     * @param string      $street
     * @param string|null $type
     */
    public function summaryAction($category, $region, $city, $company, $street = null, $type = null, $phone = null)
    {
 
        $cities_mapping_array = $this->cities_mapping_array();
 
        $mapped_city = isset($cities_mapping_array[$city]) ? $cities_mapping_array[$city] : null;
 
        $is_mapped_city = false;
        if ($mapped_city) {
            $city = $mapped_city;
            $is_mapped_city = true;
        }
 
        if (!$type)
        {
            $type = $this->dispatcher->getParam('type', null, null);
        }
 
        if (!$street)
        {
            $street = $this->dispatcher->getParam('street', null, null);
        }
        $phone = $this->dispatcher->getParam('phone', null, null);
 
        $geodata_usstates = GeodataUsstates::findFirstByUrl_id($region);
//var_dump('$geodata_usstates: ');echo "<pre>";print_r($geodata_usstates->toArray());die;
        if ($geodata_usstates)
        {
            $geodata_geocity = GeodataGeocity::findFirst([
                'conditions' => 'region = :region: AND url_id = :url:',
                "bind"       => ['region' => $geodata_usstates->statecode, 'url' => $city]
            ]);
 
 
            $categories = Categories::findFirstByUrl_id($category);
//var_dump('($geodata_geocity && $categories): ');var_dump(($geodata_geocity && $categories));die;
            if ($geodata_geocity && $categories)
            {
 
                if ($street)
                {
                    $content = Content::findFirst([
                        'conditions' => 'state = :state: AND URLid = :url: AND address_URLid = :street: AND city = :city:',
//                        'columns' => 'id,content_id',
                        'bind'       => [
                            'state'  => $geodata_usstates->statecode,
                            'url'    => $company,
                            'street' => $street,
                            'city'   => $geodata_geocity->city
                        ]
                    ]);
                } else
                {
                    $content = Content::findFirst([
                        'conditions' => 'state = :state: AND URLid = :url: AND city = :city:',
//                        'columns' => 'id,content_id',
                        'bind'       => [
                            'state' => $geodata_usstates->statecode,
                            'url'   => $company,
                            'city'  => $geodata_geocity->city
                        ]
                    ]);
                }
 
                if (!$content && $is_mapped_city) {
                    $content = Content::findFirst([
                        'conditions' => 'state = :state: AND URLid = :url:',
//                        'columns' => 'id,content_id',
                        'bind'       => [
                            'state' => $geodata_usstates->statecode,
                            'url'   => $company,
                        ]
                    ]);
                }
//                var_dump($geodata_usstates->statecode);
//                var_dump($geodata_geocity->city);
//                var_dump($company);
//                die;
//var_dump('$content: ');
                if ($content)
                {
//                    var_dump($content->id);die;
                    $this->assets->collection('header')
                        ->addCss('/css/profile_business-ful.css', false);
 
                    $featured_businesses = Content::find([
                        'conditions' => 'category_id = :category_id: AND plan_id != 0 AND areacode = :areacode:',
                        'bind'       => ['category_id' => $categories->id, 'areacode' => $geodata_geocity->areaCode],
                        'order'      => 'RAND()',
                        'limit'      => 4
                    ]);
                    $this->assets->collection('header')
//                        ->addJs('/review_systemajax/reviewsystem.js', false)
//                        ->addJs('/javascript/alljs.js', false)
                        ->addJs('/review_systemajax/reviewsystem.js', false, true, ['defer' => ''])
                        ->addJs('/javascript/alljs.js', false, true, ['defer' => ''])
                        ->addJs('https://gdc.indeed.com/ads/apiresults.js', false, false, ['defer' => ''])
                        ->addJs('/tooltipjs/jquery.betterTooltip.js', false, false, ['defer' => '']);
//                        ->addJs('https://gdc.indeed.com/ads/apiresults.js', false, false)
//                        ->addJs('/tooltipjs/jquery.betterTooltip.js', false);
 
                    $hasState = $content->HasState;
                    $hasCity = $content->HasCity;
                    $this->view->setVar('hasState',$hasState);
                    $this->view->setVar('hasCity',$hasCity);
 
                    $remove_business = RemovedBusinesses::findFirst([
                        'conditions' => 'content_id = :content_id: AND parentcategory_id = :parentcategory_id: AND confirmed = :confirmed:',
                        'bind' => ['content_id' => $content->id, 'parentcategory_id' => $content->parentcategory_id, 'confirmed' => 1]
                    ]);
 
                    if (empty($content->meta_keywords))
                    {
                        // Taqueria El Chino,New Rochelle,New York, NY, 10801,Restaurants and Cafes, hours, directions, phone number, reviews
                        $content->meta_keywords = sprintf('%s, %s, %s, %s, %s, %s, hours, directions, phone number, reviews', $content->company, $content->city, $hasState->statetitle, $content->state, $content->zip, $categories->name);
                        $content->meta_keywords = str_replace(',,', ',', $content->meta_keywords);
                        switch ($type)
                        {
                            case 'social':
                                // Taqueria El Chino facebook page, social,reputation,Taqueria El Chino,New Rochelle,New York, NY, 10801,
                                $content->meta_keywords = sprintf('%s facebook page, social,reputation,,%s,%s,%s,%s, %s,', $content->company, $content->company, $content->city, $hasState->statetitle, $content->state, $content->zip);
                                break;
                            case 'reports':
                                // traffic,social media, followers,Taqueria El Chino,New Rochelle,New York, NY, 10801,
                                $content->meta_keywords = sprintf('traffic,social media, followers,%s,%s,%s, %s, %s,', $content->company, $content->city, $hasState->statetitle, $content->state, $content->zip);
                                break;
                            case 'directions':
                                // directions,Taqueria El Chino,New Rochelle,New York, NY, 10801,
                                $content->meta_keywords = sprintf('directions,%s,%s,%s, %s, %s,', $content->company, $content->city, $hasState->statetitle, $content->state, $content->zip);
                                break;
                            case 'reviews':
                                // reviews,feedback,Taqueria El Chino,New Rochelle,New York, NY, 10801,,customer service
                                $content->meta_keywords = sprintf('reviews,feedback,%s,%s,%s, %s, %s,,customer service', $content->company, $content->city, $hasState->statetitle, $content->state, $content->zip);
                                break;
                            case 'job':
                                // jobs,job opportunities,Taqueria El Chino,jobs in New Rochelle,New York, NY, 10801,,New Rochelle jobs,
                                $content->meta_keywords = sprintf('jobs,job opportunities,%s,jobs in %s,%s, %s, %s,,%s jobs,', $content->company, $content->city, $hasState->statetitle, $content->state, $content->zip, $content->city);
                                break;
                            case 'phone':
                                // "phone,{$keywordAdd1} call, phone number, {$company},{$city},{$statetitle}, {$state}, {$zip},{$addmetaaddress}, dial{$keywordAdd2}")
                                $content->meta_keywords = sprintf('%s,phone, call, phone number, %s,%s,%s, %s, %s, dial', $phone, $content->company, $content->city, $hasState->statetitle, $content->state, $content->zip, $content->city);
                                break;
                        }
                    }
                    if (empty($content->meta_title))
                    {
                        $content->meta_title = sprintf('%s in %s, %s %s Directions and Hours and Reviews', $content->company, $content->city, $content->state, $content->zip);
 
                        switch ($type)
                        {
                            case 'social':
                                // Taqueria El Chino in New Rochelle, NY Facebook Google Plus Twitter Social Media
                                $content->meta_title = sprintf('%s in %s, %s Facebook Google Plus Twitter Social Media', $content->company, $content->city, $content->state);
                                break;
                            case 'reports':
                                // Social Media for Taqueria El Chino in New Rochelle, NY. Number of Facebook Fans, Twitter Followers For Taqueria El Chino
                                $content->meta_title = sprintf('Social Media for %s in %s, %s. Number of Facebook Fans, Twitter Followers For %s', $content->company, $content->city, $content->state, $content->company);
                                break;
                            case 'directions':
                                // Taqueria El Chino in New Rochelle, NY 10801 Directions
                                $content->meta_title = sprintf('%s in %s, %s %s Directions', $content->company, $content->city, $content->state, $content->zip);
                                break;
                            case 'reviews':
                                // Reviews for Taqueria El Chino in New Rochelle, NY. Reputation of Taqueria El Chino.
                                $content->meta_title = sprintf('Reviews for %s in %s, %s. Reputation of %s.', $content->company, $content->city, $content->state, $content->company);
                                break;
                            case 'job':
                                // Find Job Opportunities and Jobs in New Rochelle, NY - Taqueria El Chino
                                $content->meta_title = sprintf('Find Job Opportunities and Jobs in %s, %s - %s', $content->city, $content->state, $content->company);
                                break;
                            case 'phone':
                                // 914-636-2197 Phone Number For Taqueria El Chino in New Rochelle, NY 10801
                                $content->meta_title = sprintf('%s Phone Number For %s in %s, %s %s', $phone, $content->company, $content->city, $content->state, $content->zip);
                                break;
                        }
                    }
                    $this->tag->setTitle($content->meta_title);
 
                    if (empty($content->meta_description))
                    {
                        $content->meta_description = sprintf('Get %s phone number in %s, %s %s %s, %s Reviews', $content->company, $content->city, $content->state, $content->zip, $categories->name, $content->company);
 
                        switch ($type)
                        {
                            case 'social':
                                // Get Social Facebook, Twitter, Google Plus feeds for Taqueria El Chino in New Rochelle, NY. View the social reputation of Taqueria El Chino.
                                $content->meta_description = sprintf('Get Social Facebook, Twitter, Google Plus feeds for %s phone number in %s, %s. View the social reputation of ', $content->company, $content->city, $content->state, $content->company);
                                break;
                            case 'reports':
                                // Get Get Social Media Stats for Taqueria El Chino in New Rochelle, NY. View Facebook Likes and Twitter Followers for Taqueria El Chino
                                $content->meta_description = sprintf('Get Get Social Media Stats for %s in %s, %s. View Facebook Likes and Twitter Followers for %s', $content->company, $content->city, $content->state, $content->company);
                                break;
                            case 'directions':
                                // Get Directions to Taqueria El Chino in New Rochelle, NY.
                                $content->meta_description = sprintf('Get Directions to %s in %s, %s.', $content->company, $content->city, $content->state);
                                break;
                            case 'reviews':
                                // Get Taqueria El Chino Reviews in New Rochelle, NY. View Reputation and Feedback for Taqueria El Chino
                                $content->meta_description = sprintf('Get %s Reviews in %s, %s. View Reputation and Feedback for %s', $content->company, $content->city, $content->state, $content->company);
                                break;
                            case 'job':
                                // Get Taqueria El Chino Jobs in New Rochelle, NY. Job Opportunities for Taqueria El Chino
                                $content->meta_description = sprintf('Get %s Jobs in %s, %s. Job Opportunities for %s', $content->company, $content->city, $content->state, $content->company);
                                break;
                            case 'phone':
                                // Get the phone number 914-636-2197 for Taqueria El Chino in New Rochelle, NY.
                                $content->meta_description = sprintf('Get the phone number %s for %s in %s, %s.', $phone, $content->company, $content->city, $content->state);
                                break;
                        }
                    }
 
                    $bulk = $content->getUserBulkProfiles();
 
                    if ($bulk AND $bulk->is_a_phrase == "1")
                    {
                        $this->view->URL_region   = $region;
                        $this->view->URL_city     = $city;
                        $this->view->URL_category = $category;
 
                        $this->view->setVars(compact('content', 'categories', 'geodata_geocity', 'geodata_usstates',
                            'this_url', 'featured_businesses', 'type', 'bulk'));
 
                        $meta_tags   = [];
                        $meta_tags[] = '<meta name="description" content="' . $content->meta_description . '">';
                        $meta_tags[] = '<meta name="keywords" content="' . $content->meta_keywords . '"/>';
                        $meta_tags[] = '<meta name="revisit-after" content="1 days"/>';
                        $meta_tags[] = '<meta name="rating" content="general"/>';
                        $meta_tags[] = '<meta property="fb:app_id" content="1384347465125895" />';
                        $meta_tags[] = '<meta property="og:title" content="' . $content->meta_title . '" />';
                        $meta_tags[] = '<meta property="og:type" content="business.business" />';
                        $meta_tags[] =
                            '<meta property="og:url" content="' . BASE_URL . $this->router->getRewriteUri() . '" />';
                        $meta_tags[] = '<meta property="og:site_name" content="Find Us Local" />';
                        $meta_tags[] = '<meta property="og:description" content="' . $content->meta_description . '"/>';
                        $meta_tags[] =
                            '<meta property="og:image" content="//www.finduslocal.com/googlecache/' . $content->parentcategory_id . '/' . $content->category_id . '/' . $content->content_id . '.jpg"/>';
                        $meta_tags   = implode("\n", $meta_tags);
 
                        $this->view->META_TAGS = $meta_tags;
 
                        return $this->view->pick("index/profile/profile_phrase");
 
                    }
                    else
                    {
                        $meta_tags   = [];
                        $meta_tags[] = '<meta name="description" content="' . $content->meta_description . '">';
                        $meta_tags[] = '<meta name="keywords" content="' . $content->meta_keywords . '"/>';
                        $meta_tags[] = '<meta name="revisit-after" content="1 days"/>';
                        $meta_tags[] = '<meta name="rating" content="general"/>';
                        $meta_tags[] = '<meta property="fb:app_id" content="1384347465125895" />';
                        $meta_tags[] = '<meta property="og:title" content="' . $content->meta_title . '" />';
                        $meta_tags[] = '<meta property="og:type" content="business.business" />';
                        $meta_tags[] = '<meta property="og:url" content="' . BASE_URL . $this->router->getRewriteUri() . '" />';
                        $meta_tags[] = '<meta property="og:site_name" content="Find Us Local" />';
                        $meta_tags[] = '<meta property="og:description" content="' . $content->meta_description . '"/>';
                        $meta_tags[] =
                            '<meta property="og:image" content="//www.finduslocal.com/googlecache/' . $content->parentcategory_id . '/' . $content->category_id . '/' . $content->content_id . '.jpg"/>';
                        $meta_tags[] =
                            '<meta property="business:contact_data:street_address" content="' . $content->address . '" />';
                        $meta_tags[] =
                            '<meta property="business:contact_data:locality" content="' . $content->city . '"/>';
                        $meta_tags[] =
                            '<meta property="business:contact_data:region" content="' . $content->state . '"/>';
                        $meta_tags[] =
                            '<meta property="business:contact_data:postal_code" content="' . $content->zip . '" />';
                        $meta_tags[] = '<meta property="business:contact_data:country_name" content="US"/>';
                        $meta_tags[] = '<meta property="place:location:latitude" content="' . $content->lat . '" />';
                        $meta_tags[] = '<meta property="place:location:longitude" content="' . $content->lng . '" />';
//                        var_dump($type);
//                        var_dump(BASE_URL . $this->router->getRewriteUri());
//                        var_dump(preg_replace("/test$/", "", "test test test jfjojmom test"));die;
//                        var_dump(trim(BASE_URL . $this->router->getRewriteUri(), "$type/"));
                        //adding canonical link
                        /*if (empty($type)) {
                            $canonical = BASE_URL . $this->router->getRewriteUri();
                        } elseif ($type === "job") {
                            $canonical = str_replace("jobs/job-opportunities/", "", BASE_URL . $this->router->getRewriteUri());
                        } elseif ($type === "phone") {
                            $canonical = str_replace("$type/".trim($content->phone_view_link)."/", "", BASE_URL . $this->router->getRewriteUri());
                        } else {
                            $canonical = preg_replace("/$type\/$/", "", BASE_URL . $this->router->getRewriteUri());
                        }*/
 
                        $canonical = BASE_URL.$content->full_url;
 
                        if (!empty($content->address_URLid)) {
                            $canonical .= "_".$content->address_URLid;
                        }
//                        var_dump($canonical);die;
//                        $canonical = preg_replace("/$type\/$/", "", BASE_URL . $this->router->getRewriteUri());
                        $meta_tags[] = '<link rel="canonical" href="'.$canonical.'/" />';
                        /*if ($type === 'directions' || $type === 'reviews') {
//                            $meta_tags[] = '<link rel="canonical" href="'.rtrim(BASE_URL . $this->router->getRewriteUri(), $type.'/').'" />';
//                            dd(preg_replace("/$type\/$/", "", "http://dev.finduslocal.com/child-care-service/california/los-angeles/treasure-moments_3716-west-59th-st/directions/"));
                            $canonical = preg_replace("/$type\/$/", "", BASE_URL . $this->router->getRewriteUri());
                            $meta_tags[] = '<link rel="canonical" href="'.$canonical.'" />';
 
                            /*$substring = 'reviews/';
                            $str = "http://dev.finduslocal.com/child-care-service/california/los-angeles/treasure-moments_3716-west-59th-st/reviews/";
                            if (substr($str,-strlen($substring))===$substring) $str = substr($str, 0, strlen($str)-strlen($substring));
                            var_dump($str);die;*/
//                        }*/
 
                        $meta_tags   = implode("\n", $meta_tags);
 
                        $this->view->META_TAGS = $meta_tags;
 
                        $reviewcontainer = true;
 
                        $this->view->wallpaperbox =
                            $this->_getWallpaperBox($geodata_usstates->statecode, $geodata_geocity->city);
 
                        $this->view->jobsIndeed = $this->_getJob($categories->name, $geodata_geocity->postalCode);
 
//echo "<pre>";print_r($content->toArray());die;
 
                        //getting the status of user if paid or not
 
                        $paid = false;
 
                        $order_items = OrderItems::findFirst([
                            'conditions' => 'content_id = :content_id:',
//                        'columns' => 'id,content_id',
                            'bind'       => [
                                'content_id' => $content->id,
                            ]
                        ]);
 
                        if ($order_items) {
                            $order_id = $order_items->order_id;
 
                            $con = $this->getDI()->get('db');
                            $con->connect();
 
                            $sql2 = "SELECT s.pmt_src, s.an_subscr_id, s.PP_PROFILEID FROM subscriptions s JOIN order_items oi ON s.order_id = oi.order_id JOIN content c ON c.id = oi.content_id where c.id = ".$content->id." AND oi.order_id = $order_id";
 
                            $result2 = $con->query($sql2);
                            $result2->setFetchMode(\Phalcon\Db::FETCH_ASSOC);
                            $subscription = $result2->fetchAll($result2);
 
 
 
                            if (count($subscription)) {
                                $subscription = $subscription[0];
 
                                if ($subscription['pmt_src'] === 'authnet' && !empty($subscription['an_subscr_id'])) {
                                    $paid = true;
                                } else if ($subscription['pmt_src'] === 'paypal' && !empty($subscription['PP_PROFILEID'])) {
                                    $paid = true;
                                } else {
                                    $paid = false;
                                }
 
                            }
                        }
 
                        //$count_contents = $count_contents[0]['content_count'];
                        //getting the status of user if paid or not
                        $return = $this->view->pick("index/profile/profile_summary");
 
                        if ($remove_business) {
                            $reviewcontainer = false;
                            $return = $this->view->pick("index/profile/profile_removed");
                        }
 
                        $this->view->setVars(compact('content', 'categories', 'geodata_geocity', 'geodata_usstates',
                            'this_url', 'featured_businesses', 'type', 'reviewcontainer', 'paid'));
 
                        return $return;
                    }
                }
            }
        }
 
        return $this->dispatcher->forward(array(
            "controller" => "index",
            "action" => "page404"
        ));
    }
 
    /**
     * @param $category_name
     * @param $zip
     *
     * @return array|string
     */
    protected function _getJob($category_name, $zip)
    {
        $jobsCodeHTML = [];
        $jobs_url     =
            "https://api.indeed.com/ads/apisearch?publisher=252009367554079&format=json&q=" . urlencode($category_name) . "&l=" . $zip . "&sort=&radius=&st=&jt=&start=&limit=5&fromage=&filter=&latlong=1&co=us&chnl=&userip=" . $_SERVER['REMOTE_ADDR'] . "&useragent=" . urlencode($_SERVER['HTTP_USER_AGENT']) . "&v=2";
 
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $jobs_url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 2);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
 
        $result    = curl_exec($ch);
        $jobsArray = json_decode($result, true);
        if ($jobsArray)
        {
            foreach ($jobsArray['results'] as $job)
            {
                $jobsCodeHTML [] =
                    "<div id=\"job-entry\"><strong><span style=\"color:#000055;font-size:14px;\">{$job['company']}</span></strong><div style=\"padding-left:15px;font-size:12px;\"><strong>{$job['jobtitle']}</strong> in <strong>{$job['formattedLocation']}</strong><br>{$job['snippet']}<a href=\"{$job['url']}\" target=_blank rel=\"nofollow\">View Job and Apply</a></div><hr></div>";
            }
        }
        curl_close($ch);
        $jobsCodeHTML = implode("\n", $jobsCodeHTML);
 
        return $jobsCodeHTML;
    }
 
    /**
     * @return Response|\Phalcon\Http\ResponseInterface
     */
    public function removeAction()
    {
        $parentcategory_id = $this->dispatcher->getParam('parentcategory_id', 'int', null);
        $content_id        = $this->dispatcher->getParam('content_id', 'int', null);
        if (!$parentcategory_id OR !$content_id)
        {
            return $this->response->redirect('');
        }
        $confirmkey = $this->dispatcher->getParam('confirmkey', 'int', null);
        if ($confirmkey)
        {
            $removedb = RemovedBusinesses::findFirst([
                'parentcategory_id=:pid: AND content_id=:cid: AND confirmkey=:key: AND confirmed=0',
                'bind' => ['pid' => $parentcategory_id, 'cid' => $content_id, 'key' => $confirmkey]
            ]);
            if (!$removedb)
            {
                return $this->response->redirect('');
            }
            $removedb->confirmed = 1;
            if ($removedb->save())
            {
                die('Thank you - business profile has been removed');
            }
 
            return $this->response->redirect('');
 
        } else
        {
            if ($this->request->isPost())
            {
                $email  = $this->request->getPost('email', 'email', null);
                $reason = $this->request->getPost('reason', null, null);
                if ($email AND $reason)
                {
 
                    $removedb                    = new RemovedBusinesses();
                    $removedb->parentcategory_id = $parentcategory_id;
                    $removedb->content_id        = $content_id;
                    $removedb->ip_address        = $_SERVER['REMOTE_ADDR'];
                    $removedb->reason            = $reason;
                    $removedb->email             = $email;
                    $removedb->confirmed         = 0;
                    $removedb->confirmkey        = random_int(1111111, 9999999);
                    $remove_url                  =
                        BASE_URL . $this->router->getRewriteUri() . $removedb->confirmkey;
                    if ($removedb->save())
                    {
                        $mail = $this->mail;
                        $mail->addAddress($removedb->email);
                        $mail->isHTML(true);                                  // Set email format to HTML
                        $mail->Subject = 'FindUsLocal.com - Business Profile Removal Request';
                        $mail->Body    =
                            $this->view->getPartial('mail/html/removed_business', compact('remove_url'));
                        $mail->send();
                        die('Confirmation Email Has Been Sent!');
                    }
                }
            }
        }
 
 
    }
 
    /**
     * @param string $category
     * @param string $region
     * @param string $city
     * @param string $company
     * @param string $street
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface|\Phalcon\Mvc\View
     */
    public function job_opportunitiesAction($category, $region, $city, $company, $street = null)
    {
        return $this->summaryAction($category, $region, $city, $company, $street, 'job');
    }
 
    /**
     * @param string $category
     * @param null   $input_2
     * @param null   $input_3
     * @param null   $input_4
     *
     * @return View
     */
    public function profileAction($category, $input_2 = null, $input_3 = null, $input_4 = null)
    {
 
        //Get the state based on the users location (if outside of US or if State is null set default to NY)
        $userLocation = $this->locationServices->getIpLocation($this->request->getClientAddress());
 
        if (!is_object($userLocation))
        {
            $userLocation = json_decode($userLocation);
        }
 
        if (empty($userLocation->region) || empty($userLocation))
        {
            $userLocation->region = "NY";
        }
 
        $this->assets->collection('header')
            ->addCss('/css/profile_business-ful.css', false);
 
        //Category/currentpage
        if ($category && is_numeric($input_2) || $category && $input_2 == null)
        {
 
            $currentState = $this->locationServices->getStateViaCode($userLocation->region);
 
            //Get the ID for the category so we can add to the profile conditions below
            $categoryObject = $this->tag->getCategoryIdViaUrl($category);
 
            //Ensure input2 is set
            if (!$input_2 || $input_2 == null)
            {
                $input_2 = 1;
            }
 
            //Get the state based on the users location (if outside of US or if State is null set default to NY)
            $states = $this->locationServices->getStates();
 
            //Set the ofset for the pagination
            if ($input_2 == 1)
            {
                $offset = 0;
            } else
            {
                $offset = $input_2 * 10;
            }
 
            //Fetch the list of companies
            $profileModel = Content::find([
                'conditions' => 'state = ?1 AND category_id = ?2',
                "limit"      => 10,
                "offset"     => $offset,
                "bind"       => [
                    1 => $currentState->statecode,
                    2 => $categoryObject->id
                ]
            ]);
 
            $profileCount = Content::count([
                'conditions' => 'state = ?1 AND category_id = ?2',
                "bind"       => [
                    1 => $currentState->statecode,
                    2 => $categoryObject->id
                ]
            ]);
 
            //Return variables to model
            $this->view->setVars([
                "currentPage"        => $input_2,
                "stateSet"           => false,
                "page_url"           => $category,
                "companies"          => $profileModel,
                "resultsCount"       => $profileCount,
                "states"             => $states,
                "currentState"       => $currentState,
                "category"           => Categories::findFirst("url_id = '$category'"),
                "show_bottom_header" => true
            ]);
 
            $this->view->pick("index/category_listing");
 
        } //Category/State/CurrentPage
        else if ($category && is_string($input_2) && $input_3 == null || $category && is_string($input_2) && is_numeric($input_3))
        {
 
            //Get the ID for the category so we can add to the profile conditions below
            $categoryObject = $this->tag->getCategoryIdViaUrl($category);
 
            //Ensure input3 is set
            if (!$input_3 || $input_3 == null || $input_3 == "")
            {
                $input_3 = 1;
            }
 
            $states = $this->locationServices->getStates();
 
            $currentState = $this->locationServices->getStateViaUrl($input_2);
 
            if ($input_3 == 1)
            {
                $offset = 0;
            } else
            {
                $offset = $input_3 * 10;
            }
 
            //Fetch the list of companies
            $profileModel = Content::find([
                'conditions' => 'state = ?1 AND category_id = ?2',
                "limit"      => 10,
                "offset"     => $offset,
                "bind"       => [
                    1 => $currentState->statecode,
                    2 => $categoryObject->id
                ]
            ]);
 
            $profileCount = Content::count([
                'conditions' => 'state = ?1 AND category_id = ?2',
                "bind"       => [
                    1 => $currentState->statecode,
                    2 => $categoryObject->id
                ]
            ]);
 
            //Return variables to model
            $this->view->setVars([
                "currentPage"        => $input_3,
                "page_url"           => $category . "/" . $currentState->url_id,
                "stateSet"           => true,
                "companies"          => $profileModel,
                "resultsCount"       => $profileCount,
                "states"             => $states,
                "currentState"       => $currentState,
                "category"           => Categories::findFirst("url_id = '$category'"),
                "show_bottom_header" => true
            ]);
 
 
            $this->view->pick("index/category_listing");
 
        } else if ($category && is_string($input_2) && is_string($input_3) && is_string($input_4))
        {
            $this->view->pick("index/profile/profile_summary");
        }
 
    }
 
    /**
     * @return View
     */
    public function sitemapAction()
    {
        $states = GeodataUsstates::find([
            'order' => 'statecode'
        ]);
        $this->view->setVars(compact('states'));
    }
 
    /**
     * @param      $one_sign
     * @param null $page
     *
     * @return Response|\Phalcon\Http\ResponseInterface
     */
    public function sitemap_one_signAction($one_sign, $page = null)
    {
        // Remove duplicate pages
        if ($page == 1):
            return $this->response->redirect([
                'for'      => "frontend.sitemap_one_sign",
                'one_sign' => $one_sign
            ]);
        endif;
 
        if (is_null($page)):
            $page = 1;
        endif;
 
        $count_contents = 2089030; /* Content::count([
 
            'conditions' => 'company LIKE :company:',
            'bind'       => ['company' => $one_sign . '%']
        ]);*/
 
        $contents = Content::find([
            'conditions' => 'company LIKE :company: AND active = "1"',
            'bind'       => ['company' => $one_sign . '%'],
            'limit'      => $this->config->default->get('sitemap_per_page'),
            'offset'     => $page == 1 ? 0 : $page * $this->config->default->get('sitemap_per_page') - $this->config->default->get('sitemap_per_page')
        ]);
 
        $pages = $this->_pagination($contents, $count_contents, $page);
 
        //Return variables to model
        $this->view->setVars(compact('pages', 'one_sign', 'count_contents'));
 
    }
 
    /**
     * Get sitemap via state code
     *
     * @param      $state
     * @param null $page
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
     */
    public function sitemap_stateAction($state, $page = null)
    {
 
        // Remove duplicate pages
        if ($page == 1):
            return $this->response->redirect([
                'for'   => "frontend.sitemap_state",
                'state' => $state
            ]);
        endif;
 
        if (is_null($page)):
            $page = 1;
        endif;
 
        $contents = Content::find([
            'conditions' => 'state = :state: AND active = "1"',
            "bind"       => ['state' => $state],
            'limit'      => $this->config->default->get('sitemap_per_page'),
            'offset'     => $page == 1 ? 0 : $page * $this->config->default->get('sitemap_per_page') - $this->config->default->get('sitemap_per_page')
        ]);
 
        $limit = $this->config->default->get('sitemap_per_page');
        $offset = $page == 1 ? 0 : $page * $this->config->default->get('sitemap_per_page') - $this->config->default->get('sitemap_per_page');
 
        $con = $this->getDI()->get('db');
        $con->connect();
 
/*        $count_contents = Content::count([
            'conditions' => 'state = :state: AND active = "1"',
            "bind"       => ['state' => $state],
        ]);*/
 
 
/*        $sql = "SELECT * FROM content use index (state_active_indices) WHERE state = '$state' AND active = '1' LIMIT $limit OFFSET $offset";
 
        $result = $con->query($sql);
        $result->setFetchMode(\Phalcon\Db::FETCH_ASSOC);
        $contents2 = $result->fetchAll($result);*/
 
        $sql2 = "SELECT COUNT(*) content_count FROM content use index (state_active_indices) WHERE state = '$state' AND active = '1' LIMIT $limit OFFSET $offset";
 
        $result2 = $con->query($sql2);
        $result2->setFetchMode(\Phalcon\Db::FETCH_ASSOC);
        $count_contents = $result2->fetchAll($result2);
        $count_contents = $count_contents[0]['content_count'];
 
//        echo "<pre>";print_r($contents2);print_r($contents);die;
 
 
        $pages = $this->_pagination($contents, $count_contents, $page);
        //Return variables to model
        $this->view->setVars(compact('contents', 'state', 'pages'));
    }
 
    /**
     * @param $model
     * @param $number
     */
    public function sitemap_xmlAction()
    {
        $this->view->setRenderLevel(
            View::LEVEL_ACTION_VIEW
        );
        $this->response->setHeader('Content-Type', 'text/xml');
 
        $key_cache = 'sitemap-state-all';
 
        if ($this->frontCache->exists($key_cache))
        {
            $states = unserialize($this->frontCache->get($key_cache));
        } else
        {
            $states = GeodataUsstates::find([
                'order' => 'statecode'
            ]);
 
            /*if (!file_exists($key_cache) && !is_dir($key_cache)) {
                mkdir($key_cache, 0777, true);
            }*/
 
            $this->frontCache->save($key_cache, serialize($states));
        }
        $this->view->setVars(compact('states'));
    }
 
    /**
     * @param string $state
     */
    public function sitemap_state_xmlAction($state)
    {
 
        $this->response->setHeader('Content-Type', 'text/xml');
 
        $this->view->disable();
 
        $key_state = 'state-' . $state;
 
//        $xml = '';
 
        if ($this->sitemapCache->exists($key_state))
        {
            $xml = $this->sitemapCache->get($key_state);
        } else
        {
            $key_cache = 'sitemap-state-' . strtolower($state) . '-count';
 
            if ($this->frontCache->exists($key_cache))
            {
                $count_contents = $this->frontCache->get($key_cache);
            } else
            {
                $count_contents = Content::count([
                    'conditions' => 'state = :state: AND active = "1"',
                    "bind"       => ['state' => $state]
                ]);
 
                $this->frontCache->save($key_cache, $count_contents);
            }
 
            if ($count_contents > 0)
            {
                $count_contents = ceil($count_contents/$this->config->default->get('sitemap_per_page'));
            }
 
            $xml = $this->view->getPartial('sitemap/sitemap_state_xml', compact('state', 'count_contents'));
 
            $this->sitemapCache->save($key_state, $xml);
        }
 
        echo $xml;
 
    }
 
    public function sitemap_state_page_xmlAction($state, $page)
    {
 
        $this->view->disable();
        $this->response->setHeader('Content-Type', 'text/xml');
 
        $key_state = $state . '/page-' . $page;
 
        if (!is_dir(PROJECT_PATH . '/cache/sitemap/'  . $state))
        {
            mkdir(PROJECT_PATH . '/cache/sitemap/'  . $state, 0755, true);
        }
 
        $xml = '';
 
        if ($this->sitemapCache->exists($key_state))
        {
            $xml = $this->sitemapCache->get($key_state);
        } else {
//            var_dump($state);
//            var_dump($page);
//            var_dump($this->config->default->get('sitemap_per_page'));
            $contents = Content::find([
                'conditions' => 'state = :state: AND active = "1"',
                "bind"       => ['state' => $state],
                'limit'      => $this->config->default->get('sitemap_per_page'),
                'offset'     => $page == 1 ? 0 : $page * $this->config->default->get('sitemap_per_page') - $this->config->default->get('sitemap_per_page')
            ]);
//            echo $contents->getSql();die;
 
//foreach ($contents as $content) {
//    var_dump($content->full_url);
//}
//die;
            $geodata_usstates = GeodataUsstates::findFirstByStatecode($state);
 
            $xml = $this->view->getPartial('sitemap/sitemap_state_page_xml', compact('contents', 'geodata_usstates'));
 
            $this->sitemapCache->save($key_state, $xml);
        }
 
        echo $xml;
 
    }
 
    /**
     * @param $model
     * @param $number
     */
    public function sitemap_xml_modelAction($model, $number)
    {
 
        $this->view->setRenderLevel(
            View::LEVEL_ACTION_VIEW
        );
        $this->response->setHeader('Content-Type', 'text/xml');
    }
 
    /**
     * Retrn contact page
     *
     * @link /contactus
     */
    public function contactusAction()
    {
//        var_dump(123);die;
        /*header_remove("X-Frame-Options");
        header_remove("X-Powered-By");
        header_remove("X-Content-Type-Options");
        $this->response->setHeader("X-Frame-Options", "DENY");
        header('X-Frame-Options: DENY');
        header('X-Frame-Options: GOFORIT') ;*/
 
        if ($this->request->isPost()) {
//            var_dump($this->request->isPost());die;
            try {
                $g_recaptcha_response = $this->request->getPost('g-recaptcha-response', null, null);
 
                if (!$g_recaptcha_response OR !GoogleCaptcha::checkCaptcha($g_recaptcha_response)) {
                    $this->flashSession->error('Captcha is invalid');
                    goto end;
                }
 
                $post_data = $this->request->getPost();
                if ($this->security->checkToken()) {
                    $mail = $this->mail;
                $mail->addAddress('[email protected]', 'FindUsLocal');
//                    $mail->addAddress('[email protected]', 'Zeeshan Faiz');
                    $mail->isHTML(true);                                  // Set email format to HTML
                    $mail->Subject = empty($post_data['subject'])?'Contact Us - FindUsLocal':$post_data['subject'];
                    $mail->Body    = $this->view->getPartial('mail/html/contact_us', compact('post_data'));
                    $mail->AltBody = $this->view->getPartial('mail/txt/contact_us', compact('post_data'));
                    $mail->send();
                    $this->flashSession->success('We have received your message, we wll contact you shortly.');
 
                    return $this->response->redirect([
                        'for' => 'frontend.index.contactus.action'
                    ]);
 
                } else {
                    $this->flashSession->error('CSRF validation failed');
                }
            } catch (\Exception $ex) {
                $this->flashSession->error('Something went wrong. '.$ex->getMessage());
            }
 
        }
 
        end:
        $contact_us_form = new ContactUs();
        $recaptcha = \App\Service\GoogleCaptcha::getKey();
        $this->view->setVars(compact('contact_us_form', 'recaptcha'));
    }
 
    /**
     * Return Terms of Use page
     *
     * @link /tos
     */
    public function tosAction()
    {
 
    }
 
    /**
     * Return Privacy page
     *
     * @link /privacy
     */
    public function disclaimerAction()
    {
 
    }
 
    /**
     * Return Privacy page
     *
     * @link /privacy
     */
    public function privacyAction()
    {
 
    }
 
    /**
     * Get custom pagination
     *
     * @param object $contents
     * @param int    $count_contents
     * @param int    $page
     *
     * @return \stdClass
     */
    private function _pagination($contents, $count_contents, $page)
    {
        $pages                     = new \stdClass();
        $pages->items              = $contents;
        $pages->count_items        = count($contents);
        $pages->total_items        = $count_contents;
        $pages->current            = $page;
        $pages->total_pages        = (int)($count_contents / $this->config->default->get('sitemap_per_page'));
        $pages->companies_per_page = $this->config->default->get('sitemap_per_page');
        $pages->before             = $page == 1 ? 1 : $page - 1;
        $pages->next               = $page >= $pages->total_pages ? $pages->total_pages : $page + 1;
 
        return $pages;
    }
 
 
    /**
     * Get Wallpaper Box
     *
     * @param string $region (state)
     * @param string $city
     *
     * @return \stdClass or false
     */
    protected function _getWallpaperBox($region, $city)
    {
        $data                        = [];
        $data["CA"]["Los Angeles"]   = [
            "https://images.hdbackgroundpictures.com/t51b36e0d5186b86083.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_los-angeles.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_439203_los-angeles-hotels-millennium-biltmore-hotel-los-angeles-gallery.html"
        ];
        $data["TX"]["Dallas"]        = [
            "https://images.hdbackgroundpictures.com/t51ba77b61234790932.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_dallas.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_546742_dallas-at-dawn-texas-city-dallas-lights-texas-free-hd.html"
        ];
        $data["MA"]["Boston"]        = [
            "https://images.hdbackgroundpictures.com/t51b3dc3e8d3b981089.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_boston.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_191870_dance-parties-and-boston-s.html"
        ];
        $data["FL"]["Miami"]         = [
            "https://images.hdbackgroundpictures.com/t518bd04d0bcd097224.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_miami.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_442105_miami-city-at-night-florida-usa-globe-wallpapers.html"
        ];
        $data["IL"]["Chicago"]       = [
            "https://images.hdbackgroundpictures.com/t51b5b18a7604d20518.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_chicago.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_25819_chicago-boat-tour-illinois.html"
        ];
        $data["NY"]["New York"]      = [
            "https://images.hdbackgroundpictures.com/t51d77fe33462719215.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_new-york.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_558172_top-of-the-rock-new-york-city-sightseeing-usa-landscape.html"
        ];
        $data["GA"]["Atlanta"]       = [
            "https://images.hdbackgroundpictures.com/t518bd4dddd93485258.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_atlanta.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_56489_coast-night-scene-atlanta.html"
        ];
        $data["OR"]["Portland"]      = [
            "https://images.hdbackgroundpictures.com/t51b3dc4614ee886508.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_portland.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_442103_portland-city-oregon-united-states-usa-pictures.html"
        ];
        $data["PA"]["Philadelphia"]  = [
            "https://images.hdbackgroundpictures.com/t528ab0233810491645.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_Philiadelphia-skyline.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_568192_philadelphia-skyline-pennsylvania-united-states-usa-pictures.html"
        ];
        $data["CO"]["Denver"]        = [
            "https://images.hdbackgroundpictures.com/t518c5899b85ce46641.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_denver.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_58825_downtown-denver-night-united.html"
        ];
        $data["DC"]["Washington"]    = [
            "https://images.hdbackgroundpictures.com/t51b5e682702f861530.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_washington-dc.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_469614_neoclassical-architecture-white-house-washington-dc.html"
        ];
        $data["WA"]["Seattle"]       = [
            "https://images.hdbackgroundpictures.com/t517e17e540d5c91513.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_seattle.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_11875_etats-unis-seattle-seattle-001.html"
        ];
        $data["AZ"]["Phoenix"]       = [
            "https://images.hdbackgroundpictures.com/t51b2c4fcd618399070.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_phoenix.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_568320_phoenix-downtown-united-states-usa-pictures.html"
        ];
        $data["MO"]["St Louis"]      = [
            "https://images.hdbackgroundpictures.com/t51936dce12ef091254.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_St-Louis.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_99360_st-louis-arch-cities-hd.html"
        ];
        $data["FL"]["Tampa Bay"]     = [
            "https://images.hdbackgroundpictures.com/t51b1a2ac815a413339.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_Tampa-Bay.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_412199_water-and-skyline-tampa-bay-cities-city-lights-night-nite.html"
        ];
        $data["TX"]["Houston"]       = [
            "https://images.hdbackgroundpictures.com/t5284183c6909641258.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_houston.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_561943_twitter-houston-texans-texas-us-hd-high-definition-mobile.html"
        ];
        $data["CA"]["San Francisco"] = [
            "https://images.hdbackgroundpictures.com/t51889c63b645728598.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_san-francisco.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_55792_bay-bridge-san-francisco.html"
        ];
        $data["CA"]["San Diego"]     = [
            "https://images.hdbackgroundpictures.com/t519f3d147b3f192357.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_san-diego.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_203715_san-diego-city-night-light.html"
        ];
        $data["TX"]["San Antonio"]   = [
            "https://images.hdbackgroundpictures.com/t51a9662db369680925.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_san-antonio.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_339074_san-antonio-texas-usa.html"
        ];
        $data["MI"]["Detroit"]       = [
            "https://images.hdbackgroundpictures.com/t51b1a2b0432a319908.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_detroit.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_412205_detroit-cities-at-night-wallpapers-1024x768-pixel-city-hd.html"
        ];
        $data["NV"]["Las Vegas"]     = [
            "https://images.hdbackgroundpictures.com/t51b21fccae0c353424.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_las-vegas.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_320916_man-made-las-vegas-wallpaper.html"
        ];
        $data["OH"]["Cincinnati"]    = [
            "https://images.hdbackgroundpictures.com/t528ac4c97245712429.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_cincinnati.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_568996_cincinnati-kentucky-evening-wallpapers-is.html"
        ];
        $data["HI"]["Honolulu"]      = [
            "https://images.hdbackgroundpictures.com/t51a433289c7cb60340.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_honolulu_1.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_24135_honolulu-hawaii.html"
        ];
        $data["WI"]["Milwaukee"]     = [
            "https://images.hdbackgroundpictures.com/t528aca16dddaf84182.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_milwaukee.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_568895_unique-and-fun-things-to-do-in-milwaukee-wi-the-itinerary.html"
        ];
        $data["MD"]["Baltimore"]     = [
            "https://images.hdbackgroundpictures.com/t528acd122099150036.jpg",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_baltimore.html",
            "https://www.hdbackgroundpictures.com/pics/wallpapershd_568747_file-baltimore-inner-harbor-from-federal-hill-jpg-wikimedia-commons.html"
        ];
 
        if (array_key_exists($region, $data) AND array_key_exists($city, $data[$region]))
        {
 
            $phrases   = [];
            $phrases[] = "Download Free Background Pictures of {$city}, {$region}";
            $phrases[] = "Download Free Wallpaper Pics of {$city}, {$region}";
            $phrases[] = "Get Amazing {$city}, {$region} Background Pictures Free";
 
 
            $box                = new \stdClass();
            $box->phrase        = $phrases[array_rand($phrases)];
            $box->imageURL      = $data[$region][$city][2];
            $box->thumbImageURL = $data[$region][$city][0];
            $box->city          = $city;
            $box->region        = $region;
            $box->wpPage        = $data[$region][$city][1];
 
            return $box;
        }
 
        return false;
    }
 
    public function page404Action()
    {
 
        $this->view->setTemplateBefore("index");
 
        $this->response->setStatusCode(404, 'Not found');
 
        $this->assets->collection('header')
            ->addCss('/css/animate.css', false)
            ->addCss('/css/vegas.css', false)
            ->addCss('/css/error404.css', false);
 
        /*$this->assets->collection('header')
            ->addJs('/review_systemajax/reviewsystem.js', false)
            ->addJs('/javascript/alljs.js', false)
            ->addJs('https://gdc.indeed.com/ads/apiresults.js', false, false)
            ->addJs('/tooltipjs/jquery.betterTooltip.js', false);*/
    }
 
    //TODO: Remove this method since its only for debugging purpose
    public function listCitiesAction()
    {
        $this->view->disable();
 
        $request = $this->request->get();
        $chunk_length = isset($request['chunk_length'])?$request['chunk_length']:10;
        $array_number = isset($request['number'])?$request['number']:0;
//        echo "<h1>List of Cities</h1>";
 
        $con = $this->getDI()->get('db');
        $con->connect();
 
        /*$sql = "SELECT DISTINCT city FROM content WHERE city != ''";
 
        $result = $con->query($sql);
        $result->setFetchMode(\Phalcon\Db::FETCH_ASSOC);
        $content_cities = array_column($result->fetchAll($result), 'city');
        $content_cities = array_map('trim', $content_cities);
        sort($content_cities);
 
        $sql2 = "SELECT distinct city FROM geodata_geocity where city != ''";
 
        $result2 = $con->query($sql2);
        $result2->setFetchMode(\Phalcon\Db::FETCH_ASSOC);
        $geodata_cities = array_column($result2->fetchAll($result2), 'city');
        $geodata_cities = array_map('trim', $geodata_cities);
        sort($geodata_cities);
        $missing_content_cities = array_diff($content_cities, $geodata_cities);
        $missing_geodata_cities = array_diff($geodata_cities, $content_cities);
 
//        echo "<pre>";print_r($missing_content_cities);
        $html = "<style>
                table, th, td {
                  border: 1px solid black;
                }
                </style>";
        $content_cities_count = count($content_cities);
        $geodata_cities_count = count($geodata_cities);
        $missing_content_cities_count = count($missing_content_cities);
        $missing_geodata_cities_count = count($missing_geodata_cities);
        $html .= "<table><thead><tr><th>Content Cities - $content_cities_count</th><th>Geo Data Cities - $geodata_cities_count</th><th>Missing Content Cities - $missing_content_cities_count</th><th>Missing GeoData Cities - $missing_geodata_cities_count</th></tr></thead>
                <tbody><tr>";
 
        //content cities
        $html .= "<td><ul>";
        foreach ($content_cities as $key => $content_city) {
            $count = $key +1;
            $html .= "<li>$count. $content_city</li>";
        }
        $html .= "</ul></td>";
 
        //content cities
        $html .= "<td><ul>";
        foreach ($geodata_cities as $k => $geodata_city) {
            $count = $k +1;
            $html .= "<li>$count. $geodata_city</li>";
        }
        $html .= "</ul></td>";
 
        //content cities
        $html .= "<td><ul>";
        foreach ($missing_content_cities as $j => $missing_content_city) {
            $count = $j +1;
            $html .= "<li>$count. $missing_content_city</li>";
        }
        $html .= "</ul></td>";
 
 
        //content cities
        $html .= "<td><ul>";
        foreach ($missing_geodata_cities as $m => $missing_geodata_city) {
            $count = $m +1;
            $html .= "<li>$count. $missing_geodata_city</li>";
        }
        $html .= "</ul></td>";
 
        $html .= "</tr>
                </tbody>
            </table>";
 
        $html .="+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
        $missing_content_cities_list = array_map(function($item){
            $item = strtolower(preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '-', $item)));
            return '"'.$item.'"';
        }, $missing_content_cities);
        $missing_content_cities_list = array_flip($missing_content_cities_list);
 
        $missing_content_cities_list = array_map(function(){
            return '"new-york",';
        }, $missing_content_cities_list);*/
 
//        echo $html;
//        $missing_content_cities_list = implode(',', $missing_content_cities_list);
//        echo $missing_content_cities_list;
//        echo "<pre>";print_r($missing_content_cities_list);
 
        $cities_mapping_array = $this->cities_mapping_array();
//        $cities_mapping_array2 = $cities_mapping_array;
 
        $array_chunk = array_chunk($cities_mapping_array, $chunk_length, true);
 
        $mapped_cities = $this->map_city($array_chunk[$array_number]);
//        $mapped_cities = $this->map_city(["aluva" => "new-york", "annandale-nsw-australia" => "new-york", "ahmedabad" => "new-york"]);
//echo count($cities_mapping_array);echo "<br>";
//        echo "<pre>";print_r(array_splice($cities_mapping_array, 0, 2027/2));
        echo "<pre>";print_r($mapped_cities);
//        echo "<pre>";print_r(array_chunk($cities_mapping_array, 10, true));
 
//        echo "<pre>";print_r($cities_mapping_array2);
    }
 
    public function map_city($cities_mapping_array) {
        $con = $this->getDI()->get('db');
        $con->connect();
        foreach ($cities_mapping_array as $key => $city) {
//            $key = 'annandale-nsw-australia';
            $sql = "SELECT count(*) total_count FROM findus_prod4.geodata_geocity WHERE url_id = '".$key."'";
//            echo "<br>$sql</br>";
            $result = $con->query($sql);
            $result->setFetchMode(\Phalcon\Db::FETCH_ASSOC);
            $geo_city_result = $result->fetchAll($result);
            $geo_city_count = $geo_city_result[0]['total_count'];
 
            if (empty($geo_city_count)) {
                $key_array = explode("-", $key);
 
                $key_found = false;
//var_dump($key_array);
                if (count($key_array) > 1) {
                    foreach ($key_array as $k => $ke) {
                        $sql2 = "SELECT count(*) total_count FROM findus_prod4.geodata_geocity WHERE url_id = '".$ke."'";
//                        echo "<br>$sql2</br>";
                        $result2 = $con->query($sql2);
                        $result2->setFetchMode(\Phalcon\Db::FETCH_ASSOC);
                        $geo_city_result2 = $result2->fetchAll($result2);
                        $geo_city_count2 = $geo_city_result2[0]['total_count'];
                        if (!empty($geo_city_count2)) {
                            $cities_mapping_array[$key] = $ke;
                            $key_found = true;
                            break;
                        }
                    }
                }
 
 
                if (!$key_found) {
                    foreach ($key_array as $i => $k) {
                        $sql3 = "SELECT DISTINCT state FROM findus_prod4.content WHERE city Like '%".$k."%' AND state != ''";
//                        echo "<br>$sql3</br>";
                        $result3 = $con->query($sql3);
                        $result3->setFetchMode(\Phalcon\Db::FETCH_ASSOC);
                        $geo_states = array_column($result3->fetchAll($result3), 'state');
 
//                        var_dump('state');
                        foreach ($geo_states as $geo_state) {
                            $sql4 = "SELECT DISTINCT url_id FROM findus_prod4.geodata_geocity WHERE city != '' AND region = '".$geo_state."'";
//                            echo "<br>$sql4</br>";
                            $result4 = $con->query($sql4);
                            $result4->setFetchMode(\Phalcon\Db::FETCH_ASSOC);
//                        echo "<pre>";print_r($result4->fetchAll($result4));
                            $city_url_result = array_column($result4->fetchAll($result4), 'url_id');
//                            echo "<pre>";print_r($city_url_result);
                            if (count($city_url_result)) {
                                $city_url = $city_url_result[0];
                                if (!empty($city_url)) {
                                    $cities_mapping_array[$key] = $city_url;
                                    $key_found = true; break;
                                }
                            }
 
                            if ($key_found) break;
                        }
 
                        if ($key_found) break;
                    }
 
                }
            }
        }
        return $cities_mapping_array;
    }
 
    public function cities_mapping_array() {
        return  [
            "318-chicago" => "chicago",
            "suite-12-246" => "new-york",
            "-" => "columbia",
            "--usa" => "arroyo-grande",
            "---------------" => "alachua",
            "-----------------" => "alachua",
            "1-855-838-9393" => "new-york",
            "107-brandon-way" => "brandon",
            "11214" => "accord",
            "1130-n-westfield-st-oshkosh-54902" => "westfield",
            "11325-kelly-rd" => "kelly",
            "1242-state-ave-85-marysville" => "marysville",
            "1333-w-mcdermott-dr-allen" => "allen",
            "14900-miles-cleveland" => "miles",
            "1604-spring-hill-road-vienna" => "spring",
            "1627-west-5th-street-brooklyn" => "west",
            "185-beacon-hill-boulevard" => "beacon",
            "20-island-avenue-miami-beach" => "island",
            "2001-south-meridian-avenue" => "meridian",
            "2292-woodale-dr" => "ada",
            "23347-golden-springs-dr-diamond-bar" => "golden",
            "2619-rockefeller-rd-wickliffe" => "wickliffe",
            "289-jonesboro-rd-mcdonough" => "jonesboro",
            "300-west-7th-street" => "ahoskie",
            "36-east-reed-ave-alexandria-va-22305" => "reed",
            "4003-s-medford-dr-lufkin" => "medford",
            "4156664175" => "acampo",
            "445-karangahape-road-newton-auckland--new-zealand" => "newton",
            "519a-front-st-lynden" => "lynden",
            "6th-of-october-city" => "accord",
            "70-74-brunswick-st-stockton-on-tees-uk" => "brunswick",
            "7171-bay-dr" => "bay",
            "721-n-b-st-sacramento" => "sacramento",
            "773-guilford-street-brattleboro" => "guilford",
            "8" => "aguila",
            "8310-a-old-courthouse-road-tysons-corner-22182-3872" => "abingdon",
            "903-poplar-st--denver-colorado-80220" => "poplar",
            "96002" => "acampo",
            "a-baltimore" => "baltimore",
            "ab" => "adak",
            "ambala-cantt" => "accord",
            "anaheim-ca" => "anaheim",
            "asad" => "acampo",
            "azle-texas" => "azle",
            "aarhus-n" => "adak",
            "aaron-slack" => "aaron",
            "abbotsford-bc" => "abbotsford",
            "abilene-texas" => "abilene",
            "abraham" => "alamo",
            "acharya-vihar" => "abbott",
            "acorn" => "aguila",
            "acton-ma" => "acton",
            "adamsville-tennessee" => "adamsville",
            "adelaide" => "acampo",
            "agadir" => "new-york",
            "agoncillo" => "accoville",
            "agoura-hills-los-angeles" => "los-angeles",
            "aguadilla" => "aguas-buenas",
            "ahmedabad" => "acton",
            "ahwatukee" => "aguila",
            "airdrie" => "new-york",
            "ajax" => "abell",
            "albertville-al" => "albertville",
            "albuquerque-nm" => "albuquerque",
            "alden-manor" => "alden",
            "aldgate-east" => "abell",
            "alfreton" => "abell",
            "algood" => "aaron",
            "alhambraca" => "alhambra",
            "alliston" => "abell",
            "almonte" => "abell",
            "aloma" => "acampo",
            "alphretta" => "abbeville",
            "altamonte-spring" => "spring",
            "altamonte-springs-fl" => "springs",
            "altrincham" => "abell",
            "aluva" => "new-york",
            "amuwo-odofin" => "abingdon",
            "anaheim-hills" => "anaheim",
            "ancaster" => "acampo",
            "andhra-pradesh" => "ackley",
            "anglet" => "abell",
            "angmering" => "abell",
            "annandale-nsw-australia" => "annandale",
            "appleby" => "abbott",
            "aquone" => "aberdeen",
            "arbutus" => "abell",
            "arecibo" => "aguas-buenas",
            "arietta-ny" => "aguila",
            "arizona" => "aguila",
            "arizona-az" => "aguila",
            "arlington" => "new-york",
            "arlington-tx" => "arlington",
            "arlington-texas" => "arlington",
            "artesia-cerritos" => "artesia",
            "arusha" => "abington",
            "ashwaubenon" => "abbotsford",
            "aspen-usa" => "aspen",
            "atascocita" => "abbott",
            "atlanta-ga" => "atlanta",
            "atlanta-united-states" => "york",
            "attadale" => "abington",
            "auburn-nh" => "auburn",
            "auckland" => "abingdon",
            "aucland" => "abingdon",
            "augusta-ga" => "augusta",
            "austin-us" => "austin",
            "austin-tx" => "austin",
            "austin-texas" => "austin",
            "austintx" => "austin",
            "austin" => "austin",
            "ave" => "adak",
            "ave-maria" => "adak",
            "azalea-park" => "azalea",
            "belize-city" => "alachua",
            "brimfild" => "abington",
            "broadgate" => "abell",
            "burleigh-town" => "abbot",
            "businessclosed" => "abbot",
            "baker-hill" => "baker",
            "bakers-summit" => "summit",
            "balbriggan" => "abell",
            "balcones-heights" => "abbott",
            "baldwnisville" => "accord",
            "ballantyne" => "aberdeen",
            "baltimore-city" => "baltimore",
            "baltimore-maryland" => "baltimore",
            "baltimore-sw184" => "baltimore",
            "baltimore-usa" => "baltimore",
            "bandung" => "aaron",
            "bandung-jawa-barat" => "aaron",
            "bangalore" => "abbeville",
            "bangkok" => "accord",
            "baramulla-india" => "adak",
            "barbados" => "abbeville",
            "barcelona" => "absecon",
            "barge" => "acton",
            "barnsley" => "new-york",
            "baron-rouge" => "abbott",
            "barrie" => "acampo",
            "barrie-ontario" => "ontario",
            "baton-rogue" => "aguila",
            "baulkham-hills" => "hills",
            "bay-harbor-islands" => "bay",
            "bay-hill" => "bay",
            "bayamon" => "aguas-buenas",
            "bayside-ny" => "bayside",
            "beaver-river-ns" => "beaver",
            "beckenham" => "abell",
            "bedford-heights" => "bedford",
            "beehive-plumbing-west-valley" => "west-valley",
            "beirut" => "abington",
            "bekasi-indonesia" => "accord",
            "belle-harbor" => "belle",
            "belle-view" => "belle",
            "bellevu-ne" => "ackley",
            "ben-bouaza" => "adak",
            "bend-or" => "bend",
            "benfleet" => "abell",
            "bengaluru" => "ada",
            "benicia-ca" => "benicia",
            "benton-benton" => "benton",
            "berkeley-usa" => "berkeley",
            "berkeley" => "berkeley",
            "bermuda-run" => "acampo",
            "berton" => "adona",
            "bethlehem-pa" => "bethlehem",
            "beverley" => "abell",
            "beverly-hills-ca" => "beverly-hills",
            "beverly-hills-california" => "beverly-hills",
            "bevery-hills" => "beverly-hills",
            "bhopal" => "abell",
            "bhopal-mp-india" => "abell",
            "bhubaneswar" => "abbeville",
            "bignhamton" => "accord",
            "billingham" => "abell",
            "bilston-west-midlands" => "west",
            "bird-in-hand" => "new-york",
            "birkenhead" => "abell",
            "birkirkara" => "abell",
            "birmingham-al" => "birmingham",
            "birome" => " ",
            "bishop-california" => "bishop",
            "bishops-stortford" => "abell",
            "black-mountain-s" => "black-mountain",
            "blackheath-london-uk" => "london",
            "blaine-mn" => "blaine",
            "bloomfield-towns" => "bloomfield",
            "bloomfield-township" => "bloomfield",
            "blue-ash" => "blue",
            "bluffdale" => "alpine",
            "bodmin" => "abell",
            "boggs" => "acton",
            "boiseid" => "new-york",
            "bolney" => "abell",
            "bolton-on" => "bolton",
            "bondi" => "abington",
            "bonetraill" => "abercrombie",
            "bonnie-doone" => "bonnie",
            "borehamwood" => "abell",
            "boronia" => "acampo",
            "boston-usa" => "boston",
            "bostonma" => "york",
            "boucherville" => "abell",
            "bournemouth" => "abell",
            "bowmanville" => "abell",
            "boyaman" => "aguas-buenas",
            "boynton-beach-fl" => "boynton-beach",
            "braden-river" => "braden",
            "brandon-manitoba" => "brandon",
            "branson-west" => "branson",
            "brantford" => "abell",
            "brasilia--df-brazil" => "brazil",
            "bray" => "ackley",
            "brentwood-tn" => "brentwood",
            "briarcliff" => "accord",
            "bridge-street-walsall" => "street",
            "bridgend" => "abell",
            "bridgwater" => "abell",
            "brightlingsea" => "abell",
            "brighton-and-hove" => "brighton",
            "brilliant-al" => "brilliant",
            "british-columbia" => "columbia",
            "bronx-ny" => "bronx",
            "brookklyn" => "brooklyn",
            "brooklyn-heights" => "brooklyn",
            "brooklyn-usa" => "brooklyn",
            "brooklyn-ny" => "brooklyn",
            "brooklynny" => "brooklyn",
            "brooklynyork" => "brooklyn",
            "brookpark" => "brook-park",
            "brookyln" => "brooklyn",
            "brossard" => "abell",
            "brossard-qc-canada" => "canada",
            "brough" => "abingdon",
            "brown-deer" => "deer",
            "brownstown-charter-township" => "brownstown",
            "bruce-township" => "bruce",
            "bryce-canyon-city" => "bryce-canyon",
            "bryce-canyon-city-84764" => "bryce-canyon",
            "bucharest" => "aaron",
            "buckingham-pa" => "buckingham",
            "buckinghamshire" => "buckingham",
            "budapest" => "abell",
            "buffalo-usa" => "buffalo",
            "bundall" => "abbot",
            "burb" => "acampo",
            "burleigh-heads" => "abbot",
            "burlington-on" => "burlington",
            "burlington-on-l7p-1b6" => "burlington",
            "burlington-on-l7m-0j4" => "burlington",
            "burlington-vt" => "burlington",
            "burnaby" => "burna",
            "burnaby-bc" => "burna",
            "burnaby-british-columbia-canada" => "burna",
            "bursa" => "aaronsburg",
            "burton-on-trent" => "burton",
            "bury-st-edmunds" => "edmunds",
            "business" => "alachua",
            "business-closed" => "alachua",
            "buy-abortion-pill-mtp-kit-cheap-price-usa" => "price",
            "byron-bay" => "byron",
            "ca" => "adak",
            "chilliwack-bc" => "abell",
            "closed" => "alachua",
            "cabo-san-lucas-baja-california-sur" => "lucas",
            "cajon" => "acampo",
            "caledon-east" => "abingdon",
            "calfornia" => "abell",
            "calgary" => "abbeville",
            "calgary-ab" => "abbeville",
            "calgary-ab-canada" => "canada",
            "calgary-alberta" => "alberta",
            "calgory" => "abell",
            "california-united-state" => "california",
            "californiacompton" => "california",
            "caloundra" => "abbot",
            "camarillo-united-states" => "camarillo",
            "camp-springs" => "camp",
            "campton-hills" => "campton",
            "canarsie" => "accord",
            "canary-wharf" => "abell",
            "canmore" => "abell",
            "cantley" => "abell",
            "cape-coral-centr" => "cape-coral",
            "cape-coral-united-states" => "cape-coral",
            "cape-fear" => "alachua",
            "cape-saint-clair" => "alachua",
            "cardiff-ave-davenport" => "cardiff",
            "carl-fisher" => "fisher",
            "carmel-by-the-sea" => "carmel-by-the-sea",
            "carrabassett-valley" => "carrabassett-vly",
            "carroll-nh" => "carroll",
            "cary-nc" => "cary",
            "cary-nc-27513" => "cary",
            "casas-adobes" => "aguila",
            "castle-hills" => "castle",
            "catano" => "aguas-buenas",
            "catawbarock-hill-sc" => "catawba",
            "cedar-hills" => "cedar-hill",
            "celebration" => "alachua",
            "centennial" => "centennial",
            "centennial-co" => "centennial",
            "century-city" => "century",
            "century-city-ca-usa" => "century",
            "championsgate" => "champions-gate",
            "chania" => "new-york",
            "charleston-29418" => "charleston",
            "charleston-sc" => "charleston",
            "charlotte-nc" => "charlotte",
            "charlottenlund" => "charlotte",
            "charlottetown" => "charlotte",
            "charlston" => "charlson",
            "charter-twp-of-clinton" => "clinton",
            "chatswood" => "abington",
            "chattanooga-usa" => "chattanooga",
            "chemainus" => "abell",
            "chennai" => "abingdon",
            "chernihiv" => "acampo",
            "cherry-grove-bea" => "cherry-grove",
            "cherry-hills-vil" => "cherry-hills-vlg",
            "chesham" => "abell",
            "chester-depot" => "chester",
            "chevy-chase-md" => "chevy-chase",
            "chicago-il" => "chicago",
            "chilliwack" => "abell",
            "chipping-norton" => "norton",
            "chisinau" => "abell",
            "chislehurst" => "abell",
            "christopher-lynch" => "christopher",
            "christow" => "abell",
            "cima" => "acampo",
            "cincinnati" => "cincinnati",
            "cincinnati-oh" => "cincinnati",
            "city" => "abbeville",
            "city-of-orange" => "orange",
            "civic-center" => "center",
            "clapham" => "abell",
            "clarens" => "abington",
            "clarksville-md" => "clarksville",
            "claymont-usa" => "claymont",
            "clayton-brown" => "clayton",
            "clayton-lake" => "clayton",
            "clear-lake-shore" => "clear-lake-shrs",
            "clearwater-usa" => "clearwater",
            "cleckheaton" => "abell",
            "cleethorpes" => "abell",
            "clerkenwell" => "abell",
            "cleveland-height" => "cleveland",
            "cleveland-heights" => "cleveland",
            "cleveland-ohio" => "cleveland",
            "clevelandoh" => "cleveland",
            "clevevland" => "cleveland",
            "clinton-township-michigan" => "clinton",
            "clinton-village" => "clinton",
            "clitheroe-lancashire" => "abell",
            "club-wholesale-swansboro" => "swansboro",
            "coalinga-california-united-state" => "coalinga",
            "coast-guard-isla" => "acampo",
            "cochin" => "abercrombie",
            "cockeysville-md" => "cockeysville",
            "coeur-dalene" => "aberdeen",
            "coeur-dalene-id" => "aberdeen",
            "coimbatore" => "adak",
            "coldspriing" => "abbott",
            "cole" => "acampo",
            "college-heights" => "adona",
            "collingwood" => "abbeville",
            "colombo" => "new-york",
            "colonial-park" => "park",
            "colorado" => "aguila",
            "columbia-29210" => "columbia",
            "commerce-charter-township" => "commerce",
            "conception-bay-south" => "conception",
            "concord-township" => "concord",
            "convignton" => "abbeville",
            "convington" => "abbeville",
            "coolangatta" => "new-york",
            "coolum-beach" => "beach",
            "coppell-tx" => "coppell",
            "coquitlam" => "abell",
            "coquitlambc" => "new-york",
            "coram-ny" => "coram",
            "corby" => "abell",
            "coriander-ln" => "abbeville",
            "corona-ca" => "corona",
            "corona-del-mar-ca" => "corona",
            "cortlandt" => "accord",
            "coste" => "abbott",
            "cottonwood-heights" => "cottonwood",
            "coulsdon" => "abell",
            "cowan-heights" => "cowan",
            "cronulla" => "new-york",
            "crosse" => "adona",
            "crows-nest" => "acampo",
            "crows-nest-nsw" => "acampo",
            "cucamonga" => "acampo",
            "cumming-ga" => "cumming",
            "cutler-bay" => "cutler",
            "delete" => "abingdon",
            "dorval" => "abell",
            "dunblane-perthshire-fk15-0hg" => "abell",
            "dyer-usa" => "dyer",
            "daisy-lane-vale" => "daisy",
            "dalbury-lees" => "abell",
            "dallas-texas" => "dallas",
            "dallas-tx" => "dallas",
            "dallas" => "dallas",
            "dandenong-north" => "north",
            "dania-beach" => "dania",
            "daniel-island-sc" => "daniel",
            "darfork" => "aaron",
            "dartford" => "abell",
            "davi" => "abbeville",
            "dayton-oh" => "dayton",
            "daytona-beach-shores" => "daytona-beach",
            "de-pere-wi" => "adak",
            "deleon-spring" => "spring",
            "demossville" => "aaron",
            "dearborn-mi" => "dearborn",
            "decatur-il" => "decatur",
            "dehradun" => "new-york",
            "del-city" => "adak",
            "dells" => "acme",
            "denver-united-states" => "denver",
            "denver-co" => "denver",
            "denver-colorado" => "denver",
            "denville-usa" => "denville",
            "depok" => "aaronsburg",
            "deptford-township" => "deptford",
            "derbyshire" => "abell",
            "desert-hills" => "hills",
            "detroit-beach" => "detroit",
            "detroit-mi" => "detroit",
            "dhaka" => "abington",
            "dickenson" => "abbott",
            "digby" => "accord",
            "dinslaken" => "acton",
            "district-of-columbia" => "columbia",
            "dobbs-ferry-ny" => "dobbs-ferry",
            "dodgertown" => "acampo",
            "doha" => "abbeville",
            "doha-qatar" => "abbeville",
            "don-mills" => "mills",
            "donelson" => "adams",
            "doral-fl" => "doral",
            "doug-cheever" => "adak",
            "downington" => "aaronsburg",
            "doylestown-pa" => "york",
            "dual-actions-of-super-avana-your-bedroom" => "acton",
            "dubai" => "ackley",
            "duillier-switzerland" => "abington",
            "duluth-mn" => "duluth",
            "dundalk-sparrows" => "dundalk",
            "dunkel" => "dundalk",
            "dunwoody-ga" => "dunwoody",
            "e-alton" => "alton",
            "e-providence" => "providence",
            "ealing" => "abbeville",
            "east-grand-rapids" => "abbeville",
            "east-gwillimbury-on" => "abbeville",
            "east-harling" => "abbeville",
            "east-hills" => "hills",
            "east-norriton" => "abbeville",
            "east-perth" => "perth",
            "east-sussex" => "sussex",
            "east-white-plain" => "white",
            "east-york" => "york",
            "eastbourne" => "abell",
            "eastvale" => "acampo",
            "eau-gallie" => "adak",
            "edison-jersey-us" => "edison",
            "edmonton-ab" => "edison",
            "edom" => "acampo",
            "edwardsburg-mi" => "edwardsburg",
            "egremont" => "abington",
            "el-monte-ca" => "adak",
            "eldersville" => "aaronsburg",
            "elgin-usa" => "elgin",
            "eliot-massachusetts" => "eliot",
            "elk-grove-villag" => "elk-grove-village",
            "ellen-wayne" => "wayne",
            "ellerslie" => "new-york",
            "elmhurst-il" => "elmhurst",
            "emlyn" => "aaron",
            "encino" => "encino",
            "encino-ca" => "encino",
            "englishtown-nj" => "englishtown",
            "epperstone" => "abell",
            "erial" => "acampo",
            "escondido-usa" => "escondido",
            "essen" => "abercrombie",
            "etobicoke" => "abell",
            "etwall-derby" => "derby",
            "evanston-il" => "evanston",
            "everettville" => "accoville",
            "eversley" => "abell",
            "ewing-township" => "ewing",
            "fl" => "abbeville",
            "fort-salonga" => "adak",
            "fairfax-va" => "fairfax",
            "fairfield-ct" => "fairfield",
            "fairmont-wv" => "fairmont",
            "fairview-park" => "fairview",
            "fairvilla" => "alachua",
            "falkirk" => "abell",
            "falls-chruch" => "falls",
            "fargo-nd" => "fargo",
            "fargond" => "fargo",
            "farmingdale-nj" => "farmingdale",
            "farmington-hills-mi" => "farmington-hills",
            "farmington-hls" => "farmington-hills",
            "farnhamguildford-surrey" => "farnham",
            "feasterville" => "feasterville-trevose",
            "feasterville-tre" => "feasterville-trevose",
            "feasterville-pa" => "feasterville-trevose",
            "feasterville-trevose" => "feasterville-trevose",
            "fig-garden-villa" => "garden",
            "filey" => "abell",
            "find-local-business" => "alachua",
            "finkenbrueck" => "alachua",
            "flat-rock-mi-usa" => "flat",
            "flint-township" => "flint",
            "florencewi" => "florence",
            "flushing-ny" => "flushing",
            "folkeston" => "abell",
            "fontana-on-geneva-lake" => "fontana",
            "forbing" => "abbeville",
            "forney-tx-usa" => "forney",
            "fort-buchanan" => "buchanan",
            "fort-erie" => "erie",
            "fort-myres" => "fort-myers",
            "fort-smith-ar" => "fort-smith",
            "fort-st-john" => "adak",
            "fort-wayne-in" => "fort-wayne",
            "fort-worth-tx" => "fort-worth",
            "fort-worthtx" => "fort-worth",
            "fountain-valley-ca" => "fountain-valley",
            "fox-point" => "fox",
            "francisco-peralta-san-jos" => "francisco",
            "franklin-us" => "franklin",
            "fredricksburg" => "aberdeen",
            "freehold-township" => "freehold",
            "fremont-usa" => "fremont",
            "fremont-ca" => "fremont",
            "fremontca" => "fremont",
            "fribourg" => "abington",
            "frisco-tx" => "frisco",
            "frome-somerset" => "somerset",
            "ft-lauderdale" => "lauderdale",
            "ft-myers" => "fort-myers",
            "ft-pierce" => "fort-pierce",
            "ft-worth" => "fort-worth",
            "ft-collins" => "fort-collins",
            "ft-millindian-land" => "adona",
            "ft-washington" => "fort-washington",
            "ft-wright" => "fort-wright",
            "fuget" => "aaron",
            "fujairah" => "accord",
            "fujioka" => "new-york",
            "fulham" => "abell",
            "fuquay-varina" => "new-york",
            "ga" => "adak",
            "gables" => "alachua",
            "gainsborough" => "abell",
            "gaithersburg-usa" => "gaithersburg",
            "gapland" => "abell",
            "garden-city-park" => "garden-city",
            "garden-city-id" => "garden-city",
            "garden-ridge" => "garden",
            "gardena-united-states" => "gardena",
            "gardena-ca-usa" => "gardena",
            "garnet-valley" => "garnet",
            "gatineau" => "abell",
            "gatwick-surrey" => "surrey",
            "gdask" => "new-york",
            "geneva-il" => "geneva",
            "george-school" => "george",
            "george-town" => "george",
            "germany" => "ada",
            "ghaziabad" => "ada",
            "gillingham" => "abell",
            "gilman-hot-sprin" => "gilman-hot-spgs",
            "glasgow-lanarkshire" => "glasgow",
            "glasgow" => "glasgow",
            "glasgow-united-kingdom" => "glasgow",
            "glasgowglasgow" => "glasgow",
            "glendale-california" => "glendale",
            "glenhayes" => "accoville",
            "glenorchytasmania" => "new-york",
            "glenview-nas" => "glenview",
            "glenview-il" => "glenview",
            "gloucester-courthouse" => "gloucester",
            "gloucester-road" => "gloucester",
            "glynco" => "abbeville",
            "godalming" => "abell",
            "gold-canyon" => "canyon",
            "gold-coast" => "aguila",
            "goose-creek-usa" => "goose-creek",
            "goose-creek-sc" => "goose-creek",
            "gorum" => "abbeville",
            "governors-island" => "island",
            "gowen-city" => "gowen",
            "grand-bend" => "bend",
            "grand-haven-mi" => "haven",
            "grand-praire" => "grand-prairie",
            "grand-rapid" => "grand-rapids",
            "grand-rapids-mi" => "grand-rapids",
            "grande-prairie-county-no-1" => "grand-prairie",
            "grange" => "adona",
            "grange-park" => "park",
            "grant-township" => "grant",
            "grass-valley-ca" => "grass-valley",
            "great-yarmouth" => "yarmouth",
            "green-brook-nj" => "green-brook",
            "greenbelt" => "new-york",
            "greenfield-townships" => "greenfield",
            "greenwich-ct" => "greenwich",
            "greenwood-village-co" => "greenwood-vlg",
            "griffith-in" => "griffith",
            "groom-creek" => "groom",
            "grosse-pointe-farms" => "grosse-pointe",
            "grosse-pointe-park" => "grosse-pointe",
            "grosse-pointe-woods" => "grosse-pointe",
            "guaruj---sp" => "new-york",
            "guildford" => "abell",
            "gujranwala" => "alachua",
            "gurgaon" => "alachua",
            "gurgaon-haryana-india" => "alachua",
            "gurugram" => "new-york",
            "gira" => "abbeville",
            "houston-usa" => "houston",
            "habra" => "acampo",
            "hackensack-nj" => "hackensack",
            "hackney" => "abell",
            "hagatna" => "abell",
            "hailsham" => "abell",
            "halcyon" => "acampo",
            "halifax-ns-canada" => "halifax",
            "halifex" => "halifax",
            "haltom-city-tx" => "abbot",
            "hamburgny" => "new-york",
            "hamilton-on" => "hamilton",
            "hamilton-township" => "hamilton",
            "hamilton-jersey" => "hamilton",
            "hammonton-nj" => "hammonton",
            "hamstead" => "acworth",
            "handag-qormi" => "abell",
            "handsom" => "abingdon",
            "hanoi" => "accord",
            "hanover-township" => "hanover",
            "hanover-md" => "hanover",
            "hanover-pa" => "hanover",
            "harlandale" => "abbot",
            "harlow" => "abell",
            "harpurhey" => "abell",
            "harrison-hot-springs" => "harrison",
            "harrow" => "abell",
            "hartlepool" => "abell",
            "hassocks" => "abell",
            "hasting" => "alachua",
            "hastings-on-huds" => "hastings",
            "hatfield-broad-oak" => "hatfield",
            "hays-ks" => "hays",
            "haywards-heath" => "heath",
            "hazle-township" => "abbeville",
            "heathfield" => "abell",
            "heights" => "abbeville",
            "helmond" => "new-york",
            "hempstead-village" => "hempstead",
            "henderson-usa" => "henderson",
            "henderson-nv" => "henderson",
            "henrico-united-states" => "henrico",
            "henryton" => "abell",
            "herford" => "acampo",
            "hernado" => "alachua",
            "hertfordshire" => "hertford",
            "hertfordshirehp2-7dw-uk" => "hertford",
            "hervey-bay" => "bay",
            "hesle" => "abell",
            "hialeah-gardens" => "hialeah",
            "hiawatha-ia" => "hiawatha",
            "hickory-creek" => "hickory",
            "high-peak" => "peak",
            "high-river" => "river",
            "high-wycombe" => "wycombe",
            "high-point" => "new-york",
            "highland-village" => "highland",
            "highland-mi" => "highland",
            "highland-oh" => "highland",
            "highlandpark" => "highland-park",
            "highlands-ranchcousa" => "highlands-ranch",
            "hillcrest" => "adamant",
            "hillsboro-or" => "hillsboro",
            "hillside-manor" => "hillside",
            "hilton-head" => "hilton",
            "hilton-head-isla" => "hilton",
            "hoffman-estate" => "hoffman",
            "hollywood-fl" => "hollywood",
            "hollywood-florida-usa" => "hollywood",
            "holywood" => "hollywood",
            "hook" => "abington",
            "hoora" => "accord",
            "hoover" => "abbeville",
            "hope-island" => "hope",
            "horsholm" => "abington",
            "hounslow" => "abell",
            "hounslow-uk" => "abell",
            "houston-tx" => "houston",
            "houston-tx-usa" => "houston",
            "houston-texas" => "houston",
            "houstontx" => "houston",
            "hove" => "abell",
            "howell-twp" => "howell",
            "howey-in-the-hills" => "howey-in-the-hills",
            "huangyan-taizhou" => "accord",
            "huber" => "abbeville",
            "huddersfield-west-yorkshire" => "west",
            "humacao" => "aguas-buenas",
            "huntingdon-valle" => "huntingdon",
            "huntingdon-cambridgeshire-pe29-7db" => "huntingdon",
            "hyderabad" => "ackley",
            "idaho-falls-id" => "idaho-falls",
            "ilfeld" => "abiquiu",
            "ilford" => "acampo",
            "ilkeston" => "abell",
            "illinois" => "abingdon",
            "iloilo-city" => "abbeville",
            "imperial-beach-ca" => "imperial-beach",
            "indian-harbor-be" => "indian",
            "indian-harbour-beach" => "indian",
            "indian-land" => "indian",
            "indian-river-sho" => "indian",
            "indianapolis--in" => "indianapolis",
            "indianapolisin" => "indianapolis",
            "indinapolis" => "indianapolis",
            "ingatestone" => "abell",
            "ingleburn" => "abington",
            "ingonish-beach" => "beach",
            "inlet-beach" => "inlet",
            "ira-township" => "ira",
            "irvine-ca" => "irvine",
            "irwindaleca" => "irvine",
            "islamabad" => "accord",
            "island-york" => "island",
            "islington" => "abell",
            "itasca-il" => "itasca",
            "ithaca-college" => "ithaca",
            "ivyland" => "aaronsburg",
            "ivyton" => "aaron",
            "izmir" => "abbeville",
            "izoro" => "abbott",
            "jhon" => "abbott",
            "jacksonville-bea" => "jacksonville",
            "jaco" => "abingdon",
            "jacobs" => "aaron",
            "jacsonville" => "acworth",
            "jaipur" => "abbeville",
            "jakarta" => "accord",
            "james-island" => "island",
            "jefferson-county" => "jefferson",
            "jefferson-hills" => "jefferson",
            "jeffersonvlle" => "jefferson",
            "jersey-city-nj" => "jersey-city",
            "jersey-village" => "jersey",
            "johannesburg-south-africa" => "johannesburg",
            "john-decesare" => "adona",
            "john-knutson" => "adona",
            "johns-creek" => "adona",
            "joliet-il" => "joliet",
            "jolla" => "acampo",
            "jonesborough-usa" => "jonesborough",
            "juliet" => "abbeville",
            "juneau-town-milwaukee" => "juneau",
            "jurupa-valley" => "valley",
            "kailua-kona" => "new-york",
            "kellyville-ridge-nsw" => "kellyville",
            "kettlebridge" => "abell",
            "ks-city" => "kansas-city",
            "kakinada" => "new-york",
            "kalamunda-western-australia" => "western",
            "kalistell" => "absarokee",
            "kamloops" => "abell",
            "kampala" => "abell",
            "kanata" => "abell",
            "kansas-city-mo" => "kansas-city",
            "karachi" => "abbeville",
            "katesbridge" => "abell",
            "kathmandu" => "new-york",
            "katy-tx" => "katy",
            "katytx" => "katy",
            "kaunas" => "abell",
            "keller-tx-usa" => "keller",
            "kelowna" => "abell",
            "kelowna-bc-canada" => "canada",
            "kelownabc" => "new-york",
            "keltys" => "abbott",
            "kempster" => "abbotsford",
            "kentuck" => "aberdeen",
            "kidderminster" => "abell",
            "kigali" => "accoville",
            "kimberlin-height" => "adrian",
            "kingsport-tn" => "kingsport",
            "kingswinford" => "abell",
            "kirkland" => "new-york",
            "kitchener" => "abell",
            "kitchener-on" => "abell",
            "knoxville-tn" => "knoxville",
            "kochi" => "new-york",
            "kohala-coast" => "aiea",
            "kolkata" => "abbeville",
            "kollam" => "new-york",
            "kuala-lumpur" => "aiea",
            "kyiv" => "abbot",
            "l7g-0l5" => "abell",
            "land-o-lakes" => "new-york",
            "lanse" => "new-york",
            "la-canada" => "canada",
            "la-fox" => "fox",
            "la-quinta-ca" => "apo",
            "la-salle-co" => "apo",
            "la-salle-il" => "apo",
            "lacamp" => "abbeville",
            "ladue" => "adrian",
            "lady-lake-32159" => "lake",
            "lagrange-park" => "lagrange",
            "lagrange-ga" => "lagrange",
            "laguna-hills-ca" => "laguna",
            "lake-balboa" => "lake",
            "lake-bluff-usa" => "lake-bluff",
            "lake-mcconaughy-ne" => "lake",
            "lake-ridge" => "lake",
            "lake-st-louis" => "lake-st-louis",
            "lake-success" => "lake",
            "lake-sucess" => "lake",
            "lake-tapps" => "lake",
            "lakeridge" => "abingdon",
            "lakeville-mn-55044" => "lakeville",
            "lakeway-78734" => "lakeway",
            "lakewood-center" => "lakewood",
            "lakewood-ranch" => "lakewood",
            "lakewood-ca" => "lakewood",
            "lambert-lake" => "lambert",
            "lancasterpennsylvania" => "lancaster",
            "land-o-lakes-usa" => "adak",
            "langley-bc" => "langley",
            "langley-bc-v2y-1h3" => "langley",
            "langleybc-canada" => "langley",
            "lansdale-pa" => "lansdale",
            "lansing-charter-township" => "lansing",
            "larnaca" => "acampo",
            "las-colinas" => "Irving",
            "las-vagas" => "las-vegas",
            "las-vega" => "las-vegas",
            "las-vegas-na" => "las-vegas",
            "las-vegas-nv" => "las-vegas",
            "las-vegas-nevada" => "las-vegas",
            "las-vegasnv" => "las-vegas",
            "lasalle" => "abell",
            "lasalle-quebec-canada" => "canada",
            "laval" => "abell",
            "laval-quebec" => "abell",
            "lavergne" => "adams",
            "laverton-north" => "north",
            "lawrence-township" => "lawrence",
            "lawrenceville-nj" => "lawrence",
            "laxmi-nagar-delhi" => "delhi",
            "le-mont" => "adak",
            "leclaire" => "le-claire",
            "leclaire-ia" => "le-claire",
            "league-city-tx" => "league-city",
            "leander-tx" => "leander",
            "leduc" => "abell",
            "lees-summit" => "new-york",
            "leewood" => "accoville",
            "leffert-blvd-richmond-hill" => "richmond",
            "leicestershire" => "leicester",
            "leichhardt" => "abington",
            "leigh-on-sea" => "leigh",
            "lemoore-naval-ai" => "lemoore",
            "leon-junction" => "leon",
            "leon-springs" => "leon",
            "lesce" => "new-york",
            "levis-quebec" => "abell",
            "lewisville-tx" => "lewisville",
            "lexington-kentucky" => "lexington",
            "liberty-township" => "liberty",
            "lincholnshire" => "abell",
            "lincoln-universi" => "lincoln",
            "lincoln-ne" => "lincoln",
            "lincolnne" => "lincoln",
            "lincolnia" => "lincoln",
            "lindau-deutschland" => "new-york",
            "lindfield" => "abell",
            "line" => "abbeville",
            "lingo" => "adak",
            "lisbon-me" => "lisbon",
            "liscombe-mills" => "mills",
            "little-egg-harbor-township" => "harbor",
            "little-egg-harbor-nj" => "harbor",
            "littlehampton" => "abell",
            "littleport" => "ackley",
            "littleton-0" => "littleton",
            "liverpool-united-kingdom" => "liverpool",
            "lloydminster-ab" => "abell",
            "locke-mills" => "locke",
            "lodi-07644" => "lodi",
            "london-w1g-9pg" => "london",
            "london" => "london",
            "london-borehamwood-hertfordshire" => "london",
            "london-greater-london" => "london",
            "long-beach-ca" => "long-beach",
            "long-beachca" => "long-beach",
            "long-branch-nj" => "long-branch",
            "long-island-city" => "long-island-city",
            "long-island-maine" => "long-island-city",
            "longueuil" => "abell",
            "longueuil-qc" => "abell",
            "los-alomitos" => "los-alamitos",
            "los-an" => "los-angeles",
            "los-angeles-usa" => "los-angeles",
            "los-angeles" => "los-angeles",
            "los-angeles-ca" => "los-angeles",
            "los-angeles-ca-usa" => "los-angeles",
            "los-angeles-california" => "los-angeles",
            "los-angelesca" => "los-angeles",
            "los-ranchos-albuquerque" => "albuquerque",
            "los-ranchos-de-albuquerque" => "albuquerque",
            "louis" => "louisville",
            "louisaville" => "louisville",
            "louisville-usa" => "louisville",
            "lubbock-tx" => "lubbock",
            "ludgate-hill" => "hill",
            "ludhiana" => "abell",
            "luton" => "abell",
            "lutterworth" => "abell",
            "lynd-mn" => "lynd",
            "lyon-township" => "lyon",
            "malaysia" => "ackley",
            "missouri" => "ackley",
            "mn" => "adak",
            "macedonia-oh" => "macedonia",
            "mackay-qld" => "mackay",
            "macomb" => "new-york",
            "madeira" => "alachua",
            "madisonvillela" => "madisonville",
            "maidenhead" => "maidens",
            "maidstone" => "abell",
            "maidstone-kent-united-kingdom" => "kent",
            "maikailoa" => "aiea",
            "main-beach" => "beach",
            "makati-city" => "abington",
            "mal-pais-cobano-costa-rica" => "costa",
            "mall-of-america-bloomington" => "bloomington",
            "mallorytown" => "abell",
            "manalapan-township" => "manalapan",
            "manasota" => "alachua",
            "manassas-usa" => "manassas",
            "manati" => "aguas-buenas",
            "mandurah" => "abell",
            "mangolia" => "abbott",
            "mangrove-lane-hertford" => "lane",
            "manhattan-ny" => "manhattan",
            "manhatten" => "manhattan",
            "manitoba" => "accord",
            "manly-nsw" => "manly",
            "manton-lane" => "manton",
            "mantua-township" => "mantua",
            "maple-ridge" => "maple",
            "maplegrove" => "new-york",
            "mc-condy" => "adak",
            "mc-connell-a-f-b" => "connell",
            "mcadenville" => "aberdeen",
            "mcallent" => "abbott",
            "mccordsville" => "acton",
            "mcfarland" => "abbotsford",
            "mcgraw" => "accord",
            "mckees-rocks" => "aaronsburg",
            "mckittrick" => "adrian",
            "mcmurray" => "aaronsburg",
            "mckinney-tx" => "mckinney",
            "meadows-place" => "meadows",
            "mechanicsville-va" => "mechanicsville",
            "melbourne-vic" => "melbourne",
            "melksham-wiltshire" => "abell",
            "menands" => "accord",
            "mentor-on-the-lake" => "mentor",
            "merceville" => "absecon",
            "merritt-island-fl" => "merritt-island",
            "mesa-az" => "mesa",
            "mexico-city" => "mexico",
            "mexico-city-cp" => "mexico",
            "miami-gardens" => "miami",
            "miami-lakes" => "miami",
            "miami-usa" => "miami",
            "miami-fl" => "miami",
            "miami-fl-usa" => "miami",
            "miami-florida" => "miami",
            "miamifl" => "miami",
            "miamiflorida" => "miami",
            "micco" => "alachua",
            "michelle-bruns" => "abbotsford",
            "mid-missouri" => "abbeville",
            "middle-hope" => "hope",
            "middle-town" => "acampo",
            "middleberge" => "middleburg",
            "middleburg-heights" => "middleburg",
            "milford-charter-twp" => "milford",
            "millstone-township" => "millstone",
            "milton-keynes" => "milton",
            "milton-qld" => "milton",
            "mine-hill-nj" => "hill",
            "minehead" => "abell",
            "minneapolis" => "minneapolis",
            "minneapolis-mn" => "minneapolis",
            "minnepolis" => "minneapolis",
            "minnetrista" => "ada",
            "mint-hill-nc-usa" => "hill",
            "mirada" => "acampo",
            "miramar-fl" => "miramar",
            "miramarflfl" => "miramar",
            "mississauga" => "abbeville",
            "mississauga-on" => "abbeville",
            "mississauga-on-l4w-4j4" => "abbeville",
            "mobjack" => "abingdon",
            "moffat-beach" => "moffat",
            "mohali" => "alachua",
            "mohonk-lake" => "lake",
            "moline-il" => "moline",
            "mombasa" => "acampo",
            "mona-vale" => "mona",
            "monarch-bay" => "monarch",
            "monarch-beach" => "monarch",
            "montana" => "montana-city",
            "montavilla" => "montana-city",
            "montford" => "montana-city",
            "montreal-qc-canada" => "montreal",
            "montreal-quebec" => "montreal",
            "montreal-quebec-canada" => "montreal",
            "montral" => "montreal",
            "mooloolaba" => "abell",
            "moon-township" => "moon",
            "moon-twp" => "moon",
            "moorooka" => "abbot",
            "moreland-hills" => "moreland",
            "morris-plais" => "morris",
            "mount-elgin" => "elgin",
            "mount-holly-nj" => "mount-holly",
            "mount-pleasant-nc" => "mount-pleasant",
            "mount-pritchard" => "adak",
            "mount-tom" => "tom",
            "mountain-view-ca" => "mountain-view",
            "mt-sinai-ny-11766" => "mount-sinai",
            "mt-airy" => "mount-airy",
            "mt-dora" => "mount-dora",
            "mt-dorafl" => "mount-dora",
            "mt-julie" => "mount-juliet",
            "mt-juliet" => "mount-juliet",
            "mt-kisco" => "mount-kisco",
            "mt-orab" => "mount-orab",
            "mt-pleasant" => "mount-pleasant",
            "mumbai" => "adak",
            "murphysboro-il" => "murphysboro",
            "muskegon-usa" => "muskegon",
            "mustang-ridge" => "mustang",
            "my-repair-services" => "abbeville",
            "mymensingh" => "new-york",
            "myrtle-beach-sc" => "myrtle-beach",
            "n-charleston" => "new-york",
            "n-myrtle-beach" => "myrtle-beach",
            "na" => "adak",
            "na-dallas-na-united-states" => "dallas",
            "nc" => "adak",
            "new-south-whales" => "adak",
            "new-york" => "new-york",
            "nj" => "abell",
            "north-rocks" => "north",
            "northen" => "abingdon",
            "nsw" => "acampo",
            "nw-edmonton" => "edmonton",
            "ny" => "new-york",
            "ny-10019" => "new-york",
            "ny-city" => "new-york",
            "nagpur" => "new-york",
            "nairobi" => "acton",
            "nanaimo" => "abell",
            "nanton" => "abell",
            "narre-warren" => "warren",
            "narre-warren-north" => "warren",
            "nasvhille" => "adams",
            "national-harbor" => "harbor",
            "navi-mumbai" => "ackley",
            "naxera" => "abingdon",
            "nayarit" => "adrian",
            "neemuch" => "new-york",
            "negotino" => "abington",
            "nelson-bay" => "nelson",
            "nepi" => "abingdon",
            "neptune-township" => "neptune",
            "nerang" => "new-york",
            "neutral-bay" => "bay",
            "new-delhi" => "delhi",
            "new-delhi-110092" => "delhi",
            "new-fairview" => "fairview",
            "new-jersey-city" => "jersey",
            "new-malden" => "malden",
            "new-manila-quezon-city" => "manila",
            "new-port-richey-fl" => "new-port-richey",
            "new-river-stage" => "new-river",
            "new-westminster" => "westminster",
            "new-york-city" => "new-york",
            "new-york-city-usa" => "new-york",
            "new-york-city-ny" => "new-york",
            "new-york-ny" => "new-york",
            "new-york-ny-usa" => "new-york",
            "new-zealand" => "adak",
            "new-jersey" => "jersey",
            "new-jersy" => "adak",
            "newark-united-states" => "newark",
            "newbridge-gardens" => "abell",
            "newcastle-upon-tyne" => "newcastle",
            "newmarket-on" => "newmarket",
            "newton-center-02459" => "newton-center",
            "newton-nj" => "newton",
            "newtown-nsw" => "newtown",
            "niarada" => "absarokee",
            "nibley" => "alpine",
            "niddrie" => "new-york",
            "ningbo" => "bear",
            "no-dartmouth" => "dartmouth",
            "noida" => "acampo",
            "noosaville" => "abell",
            "norderstedt" => "abingdon",
            "norhtfield" => "absecon",
            "north--york" => "north",
            "north-attleborough" => "north",
            "north-bay-village" => "north-bay-vlg",
            "north-bethesda-md" => "north-bethesda",
            "north-brunswick-township" => "north-brunswick",
            "north-carolina" => "carolina",
            "north-chesterfield" => "north",
            "north-coral-spri" => "north",
            "north-edwards" => "north",
            "north-kansas-city" => "kansas-city",
            "north-keizer" => "keizer",
            "north-little-rock-ar" => "north-little-rock",
            "north-manly-nsw" => "manly",
            "north-melbourne" => "melbourne",
            "north-memphis" => "memphis",
            "north-miami-beac" => "north-miami-bch",
            "north-naples" => "naples",
            "north-ogden" => "ogden",
            "north-omaha" => "omaha",
            "north-plain-field" => "north-plainfield",
            "north-raleigh" => "raleigh",
            "north-richland" => "richland",
            "north-richland-h" => "north-richland-hills",
            "north-staten-island" => "staten-island",
            "north-vancouver" => "vancouver",
            "north-vancouver-bc" => "vancouver",
            "north-versaillespa" => "north",
            "north-west-houston" => "north",
            "north-woodmere" => "woodmere",
            "north-yor" => "new-york",
            "north-york" => "new-york",
            "north-yorktoronto-ontario" => "new-york",
            "northampton-ma" => "northampton",
            "northlaketx" => "northlake",
            "northwest" => "adona",
            "northwest-raleigh" => "raleigh",
            "norton-shores" => "norton",
            "nowthen" => "ada",
            "nutter-fort" => "accoville",
            "nutter-fort-ston" => "accoville",
            "ofallon" => "abingdon",
            "on" => "adak",
            "onerahi" => "abell",
            "o-fallon" => "new-york",
            "oakbrook-terrace-il" => "abingdon",
            "oakland-park-fl" => "oakland",
            "oakland-township" => "oakland",
            "oakland-ca" => "oakland",
            "oakville-ontario-m5x-1c7" => "oakville",
            "observatory" => "aaronsburg",
            "ocean-pines" => "ocean",
            "ocean-township" => "ocean",
            "ocho-rios" => "alachua",
            "octavia" => "abie",
            "ohoi" => "aberdeen",
            "ojus" => "alachua",
            "oklahoma" => "abington",
            "old-alresford" => "adak",
            "old-bridge-township" => "adak",
            "old-landing" => "landing",
            "old-tappan-nj" => "tappan",
            "oldbury" => "abell",
            "oldsmar-fl" => "oldsmar",
            "olmsted-twp" => "olmsted",
            "omaha-ne" => "omaha",
            "omaham" => "abie",
            "ompton-nottinghamshire" => "adona",
            "ontario-toronto-canada" => "ontario",
            "ontario-ca" => "ontario",
            "ontario-canada" => "ontario",
            "ontarioca" => "new-york",
            "opa-locka" => "new-york",
            "orange-park" => "new-york",
            "oregon-city-or" => "oregon-city",
            "oretech" => "adair-village",
            "orlanda" => "orlando",
            "orlando-32819" => "orlando",
            "orlando-fl" => "orlando",
            "orlando-florida" => "orlando",
            "orlo-vista" => "orlando",
            "oro-medonte" => "adak",
            "orpington" => "abell",
            "osborne-park" => "osborne",
            "oshawa" => "abell",
            "other" => "acton",
            "other-than-usa-city" => "acton",
            "ottawa-on" => "ottawa",
            "ottawa-on-k1r-7x6" => "ottawa",
            "ottawa-ontario" => "ottawa",
            "ottawa-wv" => "ottawa",
            "overland-park-ks" => "overland",
            "oxenford-qld" => "abbot",
            "oxford-united-states" => "oxford",
            "oxfordshire" => "abell",
            "oxley" => "abbeville",
            "pa" => "adak",
            "please-delete-this-listing" => "acampo",
            "pacific-palisade" => "pacific",
            "paddington" => "abbot",
            "palisade-815-26-united-states" => "palisade",
            "palm-beach-gardens" => "new-york",
            "palma" => "acampo",
            "palmeto-bay" => "bay",
            "palos-verdes-est" => "palos-verdes-peninsula",
            "palos-verdes-estates" => "palos-verdes-peninsula",
            "panchkula" => "adak",
            "paoli-pa" => "paoli",
            "park-blackpool" => "park",
            "park-city-utah" => "park-city",
            "park-ridge-auto-services" => "park",
            "park-row" => "park",
            "parkersburg-wv" => "parkersburg",
            "parkvillemd" => "parkville",
            "parma-heights" => "parma",
            "parma-ohio" => "parma",
            "pasedena" => "abell",
            "pathumwan-bangkok" => "accord",
            "patterson-lakes" => "patterson",
            "peachtree" => "abbeville",
            "peachtree-corners" => "abbeville",
            "pegram-tn" => "pegram",
            "pembroke-park" => "pembroke",
            "pembroke-pines-usa" => "pembroke-pines",
            "pembroke-pines-fl" => "pembroke-pines",
            "pembroke-pinesflorida" => "pembroke-pines",
            "pembroke-township" => "pembroke",
            "pembroke-nh" => "pembroke",
            "pennsauken-township" => "pennsauken",
            "pennsylvania" => "pennsylvania-furnace",
            "penrod" => "aaron",
            "pensacola-beach" => "pensacola",
            "pensacola-fl" => "pensacola",
            "peoria-us" => "peoria",
            "pepper-pike" => "pike",
            "performance-mobility" => "agate",
            "perth-western-australia-australia" => "perth",
            "petaling-jaya" => "acton",
            "petersfield" => "abell",
            "petra" => "abingdon",
            "phang-nga" => "afton",
            "phillips-ranch" => "phillips",
            "phoenix-az" => "phoenix",
            "pierrefonds" => "abell",
            "pikes-peak-moving--storage-company" => "peak",
            "pine-keyfl" => "pine",
            "piney-point-village" => "point",
            "pinner" => "abell",
            "piscataway-township" => "piscataway",
            "pl" => "adak",
            "place-fusterie-9-11-ch-1204-geneva-switzerland" => "geneva",
            "plano-usa" => "plano",
            "platte-woods" => "platte",
            "pleasant" => "abbeville",
            "pleasant-hill-ia" => "hill",
            "please-select-a-city" => "acampo",
            "plettenberg-bay" => "bay",
            "plum-springs" => "plum",
            "plymouth-devon" => "plymouth",
            "point-pleasant-boro" => "point",
            "point-richmond" => "point",
            "ponce" => "alachua",
            "ponte-vedra-beac" => "alachua",
            "ponte-verda-beach" => "verda",
            "pontypridd" => "abell",
            "port-coquitlam" => "adak",
            "port-oconnor" => "adak",
            "port-st-lucie" => "new-york",
            "portage-wi" => "portage",
            "porte" => "acampo",
            "portland-or" => "portland",
            "portland-oregon" => "portland",
            "portlouis" => "abbeville",
            "portsmouth-uk" => "portsmouth",
            "potomac-shores" => "potomac",
            "potters-bar" => "abell",
            "poway-ca" => "poway",
            "powhatan-va" => "powhatan",
            "prattvile" => "abbeville",
            "prescot" => "adona",
            "preston-professional-plaza-1003-high-house-road-cary-nc-27513" => "preston",
            "princeton-la" => "princeton",
            "promenade" => "aberdeen",
            "pryor-creek" => "pryor",
            "pryse" => "aaron",
            "pt-charlotte" => "charlotte",
            "puente" => "acampo",
            "puerto-galera" => "accord",
            "pulborough" => "abell",
            "pune" => "aaron",
            "punta-cana" => "cana",
            "purley" => "abell",
            "puslinchon" => "new-york",
            "qc" => "abell",
            "quail-heights" => "quail",
            "quakers-hill" => "hill",
            "quebec" => "abell",
            "queens" => "abell",
            "queensland" => "abbot",
            "quezon-city" => "abington",
            "quinta" => "acampo",
            "qubec" => "new-york",
            "raleigh-nc" => "raleigh",
            "raleighnorth-carolina" => "carolina",
            "ramon" => "acampo",
            "ramsgate" => "abell",
            "rancho-cucamonga-usa" => "acampo",
            "rancho-mission-viejo" => "mission",
            "rancho-santa-mar" => "santa",
            "randwick" => "new-york",
            "ras-khaimah" => "abbeville",
            "rawalpindi" => "adak",
            "raynes-park" => "park",
            "red-deer" => "deer",
            "red-lake" => "lake",
            "redford-charter-twp" => "redford",
            "redhill" => "abell",
            "redstar" => "accoville",
            "redwood-city" => "new-york",
            "regency" => "abingdon",
            "reigate" => "abell",
            "reno" => "new-york",
            "renton-usa" => "renton",
            "research-triangle-park" => "triangle",
            "reykjavk" => "new-york",
            "richmond-heights-mo-us" => "richmond-heights",
            "richmond-hill-toronto" => "richmond-hill",
            "richmond-ca" => "richmond",
            "rishikesh" => "new-york",
            "ritterhude" => "abell",
            "river-heights" => "river",
            "river-vale-nj" => "river-vale",
            "riverside-ca-usa" => "riverside",
            "rivire-rouge-qc" => "aguila",
            "road-shreveport" => "shreveport",
            "road-town" => "abbeville",
            "roanoke-va" => "roanoke",
            "robinson-township" => "robinson",
            "rochelle-parknorth-jersey" => "rochelle",
            "rochelle-il" => "rochelle",
            "rochesterny" => "new-york",
            "rockerville" => "aberdeen",
            "rockford-il" => "rockford",
            "rockland-m-p-c" => "rockland",
            "rockville-center" => "rockville",
            "rocky-view" => "rocky",
            "rogers-ar" => "rogers",
            "rolling-hills-estates" => "hills",
            "rome-italy" => "rome",
            "roosevelt-island" => "roosevelt",
            "roosevelt-roads" => "roosevelt",
            "rotherham" => "abell",
            "rowling-meadows" => "meadows",
            "royal-york" => "royal",
            "russian-river" => "river",
            "rutland-town" => "rutland",
            "s-ozone-park" => "ozone",
            "s-rapids" => "apo",
            "s-zone-park" => "park",
            "se-smyrna" => "smyrna",
            "seattle-wausa" => "seattle",
            "sw-canton" => "canton",
            "sacramento-usa" => "sacramento",
            "sacramento-ca" => "sacramento",
            "saddle-brook-nj" => "brook",
            "saginaw-mi" => "saginaw",
            "saheed-nagar-bhubaneswar-odisha-india-751007" => "abbeville",
            "saint-charles" => "new-york",
            "saint-clair-shor" => "adak",
            "saint-jude" => "adak",
            "saint-louis-park" => "park",
            "saint-lucas" => "lucas",
            "saint-patrick" => "patrick",
            "saint-paul-mn" => "paul",
            "saint-pertersburg" => "adak",
            "saint-pete-beach" => "beach",
            "saint-simons-isl" => "adak",
            "saint-hubert" => "hubert",
            "saint-jean-sur-richelieu" => "jean",
            "saintaugustine" => "new-york",
            "saldee" => "aaron",
            "salem-township" => "salem",
            "salem-or" => "salem",
            "salisbury--qld" => "salisbury",
            "salisbury-28144" => "salisbury",
            "salt-lake" => "lake",
            "san-antonio-tx" => "san-antonio",
            "san-antonio-united-states" => "san-antonio",
            "san-buenaventura" => "adak",
            "san-diego-ca" => "san-diego",
            "san-diego-united-states" => "san-diego",
            "san-diego" => "san-diego",
            "san-fernando-valley" => "san-fernando",
            "san-francisco-ca" => "san-francisco",
            "san-francisco-ca-usa" => "san-francisco",
            "san-jose--costa-rica" => "san-jose",
            "san-juan-capistrano-orange-county-ca" => "san-juan-capistrano",
            "san-juan-del-sur" => "san-juan",
            "san-juan" => "san-juan",
            "san-juan-batangas" => "san-juan",
            "san-marcos-ca" => "san-marcos",
            "san-tan-valley" => "valley",
            "san-fransisco" => "san-francisco",
            "san-marcos-california" => "san-marcos",
            "sanfrancisco" => "san-francisco",
            "sand-diego" => "san-diego",
            "sandy-utah" => "sandy",
            "santa-ana-height" => "santa-ana",
            "santa-catarina-pinula" => "santa",
            "santa-clara-usa" => "santa-clara",
            "santa-clara-ca" => "santa-clara",
            "santa-rita" => "santa-rita-park",
            "santa-rosa-beachfl" => "santa-rosa",
            "santa-rosaca" => "santa-rosa",
            "santa-susana" => "santa",
            "sarasota-fl" => "sarasota",
            "sarnia-ontario" => "ontario",
            "saskatoon" => "abell",
            "sawbridgeworth" => "abell",
            "sawmill" => "aguila",
            "sayulita" => "adrian",
            "scarborough-on" => "scarborough",
            "scarborough-ontario" => "scarborough",
            "schereville" => "acton",
            "scofield" => "alpine",
            "scotsdale-usa" => "aguila",
            "scottsdal" => "aguila",
            "seabrook" => "new-york",
            "seagrove-beach" => "seagrove",
            "seattle-usa" => "seattle",
            "seattle-wa" => "seattle",
            "secunderabad" => "ackley",
            "sedro-woolley" => "new-york",
            "sefalosha" => "abbotsford",
            "select-a-city" => "acampo",
            "select-state" => "acampo",
            "service-providers" => "alachua",
            "serving-area" => "abingdon",
            "seven-hills" => "hills",
            "sewalls-point" => "new-york",
            "shaker-heights" => "aberdeen",
            "shanonville" => "sharon",
            "sharonville" => "sharon",
            "shaumburg" => "abingdon",
            "shawnee-on" => "shawnee",
            "shelby-charter" => "shelby",
            "shelby-charter-township" => "shelby",
            "shelby-township" => "shelby",
            "shelby-township-mi" => "shelby",
            "shelbyville-40065" => "shelbyville",
            "shenzhen" => "abell",
            "shepard" => "acton",
            "sheppard-air-force-base" => "force",
            "sherwood-park" => "sherwood",
            "shildon" => "abell",
            "shimla" => "new-york",
            "shopiere" => "abbotsford",
            "sialkot" => "abbeville",
            "sialkot-pakistan" => "abbeville",
            "sias" => "abington",
            "siesta-key" => "alachua",
            "signal-mountain-tn" => "signal-mountain",
            "simsbury-ct" => "simsbury",
            "singapore" => "acampo",
            "singer-island" => "singer",
            "sipson-road-middlesex-united-kingdom" => "middlesex",
            "sisli" => "accord",
            "skellefte" => "new-york",
            "skipton" => "abell",
            "sliema" => "abell",
            "slough" => "acampo",
            "small-point" => "point",
            "smithfield-market" => "smithfield",
            "smiths-falls" => "smiths",
            "smyrna-ga" => "smyrna",
            "soddy-daisy" => "new-york",
            "sofia" => "abington",
            "solingen" => "abell",
            "sondika" => "acme",
            "sonnette" => "absarokee",
            "soudersburg" => "aaronsburg",
            "south-burnsville" => "burnsville",
            "south-central-wichita" => "central",
            "south-chesterfield" => "chesterfield",
            "south-coast-metro" => "adak",
            "south-county" => "adak",
            "south-euclid" => "euclid",
            "south-farmingdal" => "adak",
            "south-gate-plaza" => "gate",
            "south-ogden" => "ogden",
            "south-richmond-hill" => "richmond",
            "south-san-franci" => "san-francisco",
            "south-tampa" => "tampa",
            "south-waterford" => "waterford",
            "south-weber" => "adak",
            "south-westport" => "westport",
            "south-williamspo" => "adak",
            "southampton-pa" => "southampton",
            "southbank" => "accord",
            "southend" => "abell",
            "southhampton" => "abell",
            "southwest-ranches" => "southwest",
            "sparta-township" => "sparta",
            "speaks" => "abbott",
            "speight" => "aaron",
            "spokane-valley-wa" => "spokane",
            "spokane-wa" => "spokane",
            "spring-creek-nv" => "spring",
            "spring-hill-fl" => "spring",
            "spring-valley-la" => "spring",
            "spring-s" => "spring",
            "springfield-gard" => "springfield",
            "springfield-township" => "springfield",
            "springfield-usa" => "springfield",
            "springfield" => "springfield",
            "springfieldva" => "springfield",
            "spruce-grove" => "spruce",
            "sprucegrove" => "abell",
            "squamish" => "abell",
            "squamish-bc" => "abell",
            "squirrel" => "aberdeen",
            "st--george" => "st-george",
            "st-augustine-beach" => "st-augustine",
            "st-clair-shoresmi" => "st-clair-shores",
            "st-george-84770" => "st-george",
            "st-ives" => "apo",
            "st-joseph-mn" => "st-joseph",
            "st-leonards-on-sea" => "apo",
            "st-louis-mo" => "ast-louispo",
            "st-sun-prairie" => "sun-prairie",
            "st-sun-prairie-wi" => "sun-prairie",
            "st-albans" => "saint-albans",
            "st-albert" => "albert-city",
            "st-ann" => "new-york",
            "st-anns" => "apo",
            "st-augustine" => "st-augustine",
            "st-catharines" => "apo",
            "st-charles" => "saint-charles",
            "st-charles--mo" => "saint-charles",
            "st-clair-shores" => "saint-clair-shores",
            "st-cloud" => "saint-cloud",
            "st-george" => "saint-george",
            "st-helena" => "saint-helena",
            "st-ignace" => "saint-ignace",
            "st-james" => "saint-james",
            "st-johns" => "saint-johnsbury",
            "st-joseph" => "saint-joseph",
            "st-louiis" => "saint-louis",
            "st-louis" => "saint-louis",
            "st-louis-park" => "saint-louis",
            "st-louismo" => "saint-louis",
            "st-marys" => "saint-marys",
            "st-paul" => "saint-paul",
            "st-pete-beach" => "st-pete-beach",
            "st-peter" => "saint-peters",
            "st-peters" => "saint-peters",
            "st-petersburg" => "saint-petersburg",
            "st-robert" => "saint-robert",
            "st-simons-island" => "saint-simons-island",
            "st-thomas-ontario" => "saint-thomas",
            "stgeorge" => "saint-george",
            "stlouis" => "saint-louis",
            "stpeters" => "saint-peters",
            "stpetersburg" => "saint-petersburg",
            "sta-ana" => "adak",
            "stafford-sterner" => "stafford",
            "stafford-va" => "stafford",
            "stamford" => "stamford",
            "stamford-ct" => "stamford",
            "stanford-le-hope" => "stanford",
            "stanford-ca" => "stanford",
            "stanmore" => "abell",
            "stanstead-abbotts-hertfordshire" => "abell",
            "state" => "adona",
            "ste-therese" => "adak",
            "steamboat-spring" => "spring",
            "sterling-heights-mi" => "sterling",
            "stirrat" => "accoville",
            "stockbridge-united-states" => "stockbridge",
            "stockton-ca" => "stockton",
            "stoke-prior" => "abell",
            "stoney-creek" => "aaron",
            "stratford-upon-avon" => "stratford",
            "streamsong" => "alachua",
            "street-nr-100-456823" => "street",
            "stuart-fl" => "stuart",
            "suburban" => "absecon",
            "sugar-land-tx-77498" => "aguila",
            "sugarland" => "abbott",
            "suite" => "acampo",
            "suite-1-burlington" => "burlington",
            "suite-203-san-jose" => "acampo",
            "suite-c-morrisville" => "morrisville",
            "sun-city-85351-3597" => "sun",
            "sunny-isles" => "acampo",
            "sunny-isles-beach" => "beach",
            "sunny-isles-beach-fl" => "beach",
            "sunnyland" => "abingdon",
            "sunset-hills" => "sunset",
            "surat" => "absecon",
            "surbiton" => "abell",
            "surprise-az" => "surprise",
            "surrey-british-columbia" => "surrey",
            "surrey-bc" => "surrey",
            "sussex-wi" => "sussex",
            "sutton-coldfield" => "sutton",
            "sydney-domestic-airport" => "sydney",
            "sydney" => "new-york",
            "sydney-melbourne" => "sydney",
            "toowong-qld" => "abbot",
            "tacoma-wa" => "tacoma",
            "tagelswangen" => "absecon",
            "taichung--taiwan" => "",
            "takua-pa" => "afton",
            "talbert" => "aaron",
            "talisay" => "abington",
            "tamarac-fl" => "tamarac",
            "tamarindo" => "ackley",
            "tampa-33609" => "tampa",
            "tampa-bay" => "tampa",
            "tampa-fl" => "tampa",
            "tampamelbourne" => "tampa",
            "taylosrville" => "new-york",
            "tea-tree-gully" => "tea",
            "tel-aviv-israel" => "adak",
            "temeculaca" => "new-york",
            "temescal-valley" => "valley",
            "teneriffe" => "abbot",
            "terrace" => "acampo",
            "tewantin" => "abbot",
            "texas" => "abell",
            "thamel-kathmandu-nepal" => "new-york",
            "the-ponds" => "adak",
            "the-san-diego" => "san-diego",
            "thorndale" => "new-york",
            "thornhill" => "abell",
            "thunder-bay" => "bay",
            "tibberton" => "abell",
            "tiburon" => "acampo",
            "tijuana" => "abingdon",
            "timonium-md" => "timonium",
            "tockwith" => "accord",
            "tokyo" => "accord",
            "tom-river" => "tom",
            "toongabbie-nsw" => "abington",
            "toowoomba" => "abbot",
            "topeka-ks" => "topeka",
            "torch" => "aberdeen",
            "toronto-on" => "toronto",
            "toronto-on-m4m-1k4" => "toronto",
            "toronto-ontario" => "toronto",
            "toronto-ontario-m8z5w3" => "toronto",
            "torontoon" => "toronto",
            "torrance-usa" => "torrance",
            "tortola" => "acampo",
            "town--country" => "new-york",
            "town-of-brookfield" => "brookfield",
            "town-and-country" => "abbeville",
            "township" => "abingdon",
            "township-of" => "abingdon",
            "tracy-ca-95304" => "tracy",
            "traralgon" => "acworth",
            "treasure-beach" => "beach",
            "trevose" => "aaronsburg",
            "tripler-army-medical-ctr" => "aiea",
            "trophy-club" => "abbott",
            "truro-cornwall" => "truro",
            "tucson-az" => "tucson",
            "tujunga-ca" => "tujunga",
            "tukwilawa" => "new-york",
            "tullamarine" => "acworth",
            "tulsa-ok" => "tulsa",
            "tunbridge-wells" => "tunbridge",
            "turnsville" => "absecon",
            "tuscon" => "aguila",
            "tuttle-ok" => "tuttle",
            "tweedbank-galashiels" => "abell",
            "twin-branch" => "branch",
            "tysons-corner" => "abingdon",
            "uk" => "adak",
            "usa" => "adak",
            "usa-dayton" => "dayton",
            "usa-fremont" => "fremont",
            "usa-losangels" => "adak",
            "uintah" => "alpine",
            "ulaanbaatar" => "abell",
            "ultimo" => "bolling-afb",
            "uncle-sam" => "abbeville",
            "union-park" => "union",
            "united-states" => "united",
            "university-heights" => "university",
            "uplands" => "abell",
            "upper-chichester" => "chichester",
            "upper-hutt" => "adak",
            "upper-manhattan" => "manhattan",
            "upperkirkgate" => "abell",
            "uptown" => "aaronsburg",
            "urbana-il" => "urbana",
            "utah" => "abingdon",
            "v7p-3r4-north-vancouver-bc" => "vancouver",
            "vadodara" => "new-york",
            "valletta" => "abell",
            "van-alstyne-tx" => "van",
            "vancouver-bc" => "vancouver",
            "vancouver-peninsula" => "vancouver",
            "vancouver-bc-v5r-5l3" => "vancouver",
            "vancouver-british-columbia" => "vancouver",
            "vancouverbc" => "vancouver",
            "varna-bulgaria" => "varna",
            "varsity-lakes" => "abbot",
            "varsity-lakes-4226" => "abbot",
            "vaughan-on" => "vaughan",
            "venice-beach" => "venice",
            "venice-fl" => "venice",
            "ventura-county" => "ventura",
            "vernon-township" => "vernon",
            "victoria-bay" => "victoria",
            "victoria-bc-v8t-4h7-canada" => "victoria",
            "victoria-bc-canada" => "victoria",
            "vietnam" => "accord",
            "village-of-lakewood" => "village",
            "village-of-palm-springs" => "village",
            "ville-st-laurent" => "adak",
            "vineyard" => "abington",
            "vistancia" => "aguila",
            "voorhees-township" => "voorhees",
            "voorhees-township-nj" => "voorhees",
            "w-hartford" => "hartford",
            "w-mifflin-fin" => "mifflin",
            "waterloo-nsw" => "waterloo",
            "worsley" => "abbeville",
            "wailea" => "aiea",
            "wake-island" => "wake",
            "walla-wallawa" => "acampo",
            "walnut-ridge-ar" => "walnut-ridge",
            "walsh-lane" => "walsh",
            "waltham-abbey" => "waltham",
            "walton-hills" => "walton",
            "wangara" => "abington",
            "wantage" => "absecon",
            "wappingers-falls-ny" => "falls",
            "warangal" => "accord",
            "warman" => "abell",
            "warwickshire" => "abell",
            "washington-dc" => "washington",
            "washington-township" => "washington",
            "washington-ut" => "washington",
            "washington-va" => "washington",
            "washingtondc" => "washington",
            "waterdown" => "abell",
            "waterford-township" => "waterford",
            "waterloo-on" => "waterloo",
            "waterton-park" => "park",
            "watertown-wi" => "watertown",
            "wausau-54401" => "wausau",
            "wauwatosa-wi" => "wauwatosa",
            "wayne-avenue" => "wayne",
            "webster-ny" => "webster",
            "welasco" => "abbeville",
            "weldon-spring" => "weldon",
            "weldon-springs" => "weldon",
            "welham-green" => "green",
            "wellington-fl" => "wellington",
            "wembley" => "abell",
            "west-belton" => "belton",
            "west-bloomfield-township" => "west-bloomfield",
            "west-boca-raton" => "boca-raton",
            "west-bountiful" => "bountiful",
            "west-brandywine" => "brandywine",
            "west-bromwich" => "west",
            "west-cheser" => "west",
            "west-county" => "west",
            "west-danby" => "danby",
            "west-deptford" => "deptford",
            "west-deptford-township" => "deptford",
            "west-drayton" => "drayton",
            "west-end-queensland" => "west",
            "west-hempstead-new-york" => "west-hempstead",
            "west-jordan-ut" => "west-jordan",
            "west-lake" => "west",
            "west-lake-hills" => "west",
            "west-lonsdale" => "west",
            "west-los-angeles" => "los-angeles",
            "west-lynn" => "lynn",
            "west-malling" => "west",
            "west-menlo-park" => "menlo-park",
            "west-milwauke-wisconsin" => "milwaukee",
            "west-milwaukee" => "milwaukee",
            "west-sacramento-ca" => "west-sacramento",
            "west-saint-paul" => "saint-paul",
            "west-seattle" => "seattle",
            "west-st-paul" => "saint-paul",
            "west-sussex" => "sussex",
            "west-tower-west-palm-beach" => "west-palm-beach",
            "west-united-states" => "west",
            "west-valley-city" => "west-valley",
            "west-valley-city-ut" => "west-valley",
            "west-vancouver" => "vancouver",
            "west-yorkshire" => "yorkshire",
            "west-yorkshire-leeds" => "yorkshire",
            "westcliff-on-sea" => "agate",
            "westhampton-beac" => "westhampton",
            "westhaven" => "west-haven",
            "westminister" => "acampo",
            "westport" => "west-portsmouth",
            "whalan" => "ada",
            "whistler-bc" => "abell",
            "whitby-on" => "abell",
            "white-center" => "white",
            "white-city-oregon" => "white",
            "white-plains-united-states" => "white-plains",
            "white-plains" => "white-plains",
            "whitefish-bay" => "whitefish",
            "whitethorne" => "abingdon",
            "whitmore-lake-michigan" => "whitmore",
            "whittier-ca" => "whittier",
            "whon" => "abbott",
            "wichita-falls-tx" => "wichita",
            "wigan" => "abell",
            "wilkes-barre" => "new-york",
            "willemstad" => "abell",
            "willmington" => "aberdeen",
            "willoughby-hills" => "willoughby",
            "wilmette-il" => "wilmette",
            "wilmington-united-states" => "wilmington",
            "wilmington-de" => "wilmington",
            "windcrest" => "abbott",
            "windsor-on" => "windsor",
            "windy-hill" => "hill",
            "winnipeg" => "aaron",
            "winnipeg-mb" => "aaron",
            "winston-building" => "winston",
            "winston-salem" => "new-york",
            "winter-garden-a-hreffirefighter-4-hire-lawn-care-servicehttpwwwlawnca" => "winter-garden",
            "winter-garden-34787" => "winter-garden",
            "winter-garden-fl" => "winter-garden",
            "wirral" => "abell",
            "wisconsin" => "abbotsford",
            "woburn-ma" => "woburn",
            "woburn-ma-01801" => "woburn",
            "woking" => "abell",
            "wolverhampton" => "abell",
            "wood-dale" => "new-york",
            "woodbridge-township" => "woodbridge",
            "woodfin" => "aberdeen",
            "woodland-hills-united-states" => "woodland",
            "woodrow-drive" => "woodrow",
            "woodrum" => "abingdon",
            "woolwich-twp" => "woolwich",
            "worcester-ma" => "worcester",
            "worcestershire" => "abell",
            "worthington-ohio" => "worthington",
            "wyandanch-ny" => "wyandanch",
            "wyoming-mi" => "wyoming",
            "yeerongpilly" => "abbot",
            "yelverton" => "abington",
            "yeovil-somerset" => "somerset",
            "yishun" => "new-york",
            "yonkers-ny" => "yonkers",
            "yonkersny" => "new-york",
            "yuyao" => "new-york",
            "zamudio" => "acme",
            "zegrab" => "new-york",
            "zephyrhills-fl" => "zephyrhills",
            "zirakpur" => "accord",
            "zrich" => "new-york",
            "adsdsafdsfsdfsd" => "aberdeen",
            "alaska" => "adak",
            "albans" => "abbeville",
            "asdawd" => "acampo",
            "asdf" => "acampo",
            "asdfasdf" => "acampo",
            "asdfsdfdsfgdfg" => "alachua",
            "austin-usa" => "austin",
            "balbacua" => "abell",
            "buenavista" => "abie",
            "cabuyap" => "acampo",
            "califormnia" => "california",
            "canning-vale-wa" => "vale",
            "chandigarh" => "adak",
            "chicago-il-60623" => "chicago",
            "cho" => "adak",
            "church-virginia" => "virginia",
            "cogon" => "abbott",
            "connecticut" => "aaronsburg",
            "coral-fables" => "coral",
            "cree-way-antelope" => "antelope",
            "dallas-usa" => "dallas",
            "dasdas" => "alachua",
            "delhi-india" => "delhi",
            "dkon" => "alachua",
            "drst" => "acampo",
            "dsadsad" => "accord",
            "dsfgsdfg" => "abbotsford",
            "el-fraile" => "adak",
            "faridabad" => "aberdeen",
            "fct" => "new-york",
            "gaineville" => "abingdon",
            "gauteng" => "accord",
            "georgia" => "abbeville",
            "hainseport" => "absecon",
            "hawaii" => "acampo",
            "hawaiian-gardens-ca" => "acampo",
            "hefei" => "abington",
            "houstan" => "abbott",
            "hyderabad-andhra-pradesh" => "ackley",
            "iami-beach" => "beach",
            "insulation-contractorpest-control" => "new-york",
            "istanbul" => "alachua",
            "jacksonvilla" => "jacksonville",
            "jacksonville-fl" => "jacksonville",
            "jacksonvillefl" => "jacksonville",
            "jgjggdjjg" => "abell",
            "jhhj" => "abbeville",
            "jjjjjj" => "acampo",
            "kampala-uganda" => "abell",
            "karnataka" => "ada",
            "kerhonkson-ny" => "kerhonkson",
            "klang" => "accord",
            "kochikerala" => "new-york",
            "lahore" => "abell",
            "linyi" => "aberdeen",
            "madurai" => "absecon",
            "mt-vernon" => "new-york",
            "napa-vally" => "napa",
            "new--york" => "",
            "new-jerssy" => "adak",
            "new-work" => "adak",
            "newyork" => "acampo",
            "none" => "alachua",
            "norwich-norfolk" => "norwich",
            "oly" => "adak",
            "oowoomba" => "abbot",
            "pigty" => "adona",
            "pretoria" => "aaronsburg",
            "qunees" => "accord",
            "ramat-gan" => "achille",
            "rio-janeiro" => "rio",
            "sdfsdrf" => "acampo",
            "sdfgdhdfhfgh" => "alachua",
            "san" => "adak",
            "sanfranscio" => "san-francisco",
            "santa-rosa-ca" => "santa",
            "scsavdvfsb" => "aberdeen",
            "sdfs" => "acampo",
            "service-area" => "alachua",
            "spring-valley-ny" => "spring",
            "sriganganagar" => "new-york",
            "svegas" => "abbeville",
            "svsdv" => "aguila",
            "tampa" => "new-york",
            "tehran" => "new-york",
            "topnotchmoversinc" => "alachua",
            "toranto" => "new-york",
            "tttt" => "abell",
            "unit-209-4656-westwinds-dr-ne-calgary-t3j-3z5" => "adak",
            "united-kingdom" => "united",
            "west-cester" => "west",
            "westervill" => "abie",
            "wilimington" => "bear",
            "wuajsks" => "alachua",
            "yukmuyth" => "abell",
            "zhengzhou" => "abell",
            "-colcord" => "colcord",
        ];
 
    }
 
}
#16Apps\Frontend\Controllers\IndexController->beforeExecuteRoute(Object(Phalcon\Mvc\Dispatcher))
#17Phalcon\Dispatcher->dispatch()
#18Phalcon\Mvc\Application->handle()
/home/finduslocal/public_html/public/index.php (85)
<?php
/**
 * Ceated by Novnik Ltd.
 * User: artdevue - index.php
 * Date: 25.02.17
 * Time: 15:46
 * Project: phalcon-blank
 */
 
//header("Cache-Control: max-age=2592000");
 
define('PHALCONSTART', microtime(true));
define('PROJECT_PATH', dirname(dirname(__FILE__)) . '/');
 
use Phalcon\Mvc\Application,
    Phalcon\Loader;
 
//date_default_timezone_set('Europe/Dublin');
date_default_timezone_set('America/Los_Angeles');
 
 
    require_once PROJECT_PATH . 'apps/bootstrap.php';
 
    //debug
    if ($config->debug)
    {
        $debug = new \Phalcon\Debug();
        $debug->listen();
    } else
    {
       error_reporting(E_ALL);
    }
//error_reporting(0);
 
    $loader = new Loader();
 
    $loader->registerNamespaces([
        'Apps\Commons\Models' => PROJECT_PATH . 'apps/commons/models/',
        'Library'             => PROJECT_PATH . 'library/'
    ]);
 
    $loader->registerClasses([
        'Apps\Commons\AbstractModule' => PROJECT_PATH . 'apps/commons/AbstractModule.php',
    ]);
 
    $loader->register();
 
    /**
     * Include services
     */
    require PROJECT_PATH . 'config/services.php';
    require PROJECT_PATH . 'config/repos.php';
 
    /**
     * Handle the request
     */
    $application = new Application();
 
    /**
     * Assign the DI
     *
     * @var Phalcon\DI\FactoryDefault $di
     */
    $application->setDI($di);
    //$application->useImplicitView(false);
 
    /**
     * Register application modules
     */
    $modules = [];
 
    foreach ($config->modules as $index => $modul)
    {
        $modules[$index] = [
            'className' => $modul->className,
            'path'      => $modul->dir . 'Module.php'
        ];
    }
 
    $application->registerModules($modules);
    //echo $application->handle()->getContent();
 
    require PROJECT_PATH . 'config/function.php';
 
    $response = $application->handle();
    $response->send();
KeyValue
_url/new-and-used-car-dealers/district-of-columbia/washington/gold-motors/phone/202-526-3434/
KeyValue
REDIRECT_HTTPSon
REDIRECT_UNIQUE_IDXksH6TrvwBXpUfIxGnvqBwAAADA
REDIRECT_SSL_TLS_SNIwww.finduslocal.com
REDIRECT_STATUS200
HTTPSon
UNIQUE_IDXksH6TrvwBXpUfIxGnvqBwAAADA
SSL_TLS_SNIwww.finduslocal.com
SSL_SERVER_S_DN_CN*.finduslocal.com
SSL_SERVER_I_DN_CGB
SSL_SERVER_I_DN_STGreater Manchester
SSL_SERVER_I_DN_LSalford
SSL_SERVER_I_DN_OSectigo Limited
SSL_SERVER_I_DN_CNSectigo RSA Domain Validation Secure Server CA
SSL_SERVER_SAN_DNS_0*.finduslocal.com
SSL_SERVER_SAN_DNS_1finduslocal.com
SSL_VERSION_INTERFACEmod_ssl/2.4.41
SSL_VERSION_LIBRARYOpenSSL/1.1.1d
SSL_PROTOCOLTLSv1.3
SSL_SECURE_RENEGfalse
SSL_COMPRESS_METHODNULL
SSL_CIPHERTLS_AES_128_GCM_SHA256
SSL_CIPHER_EXPORTfalse
SSL_CIPHER_USEKEYSIZE128
SSL_CIPHER_ALGKEYSIZE128
SSL_CLIENT_VERIFYNONE
SSL_SERVER_M_VERSION3
SSL_SERVER_M_SERIALFCACE06F6878D94193A29C32A087A0FA
SSL_SERVER_V_STARTFeb 17 00:00:00 2020 GMT
SSL_SERVER_V_ENDFeb 16 23:59:59 2022 GMT
SSL_SERVER_S_DNCN=*.finduslocal.com
SSL_SERVER_I_DNCN=Sectigo RSA Domain Validation Secure Server CA,O=Sectigo Limited,L=Salford,ST=Greater Manchester,C=GB
SSL_SERVER_A_KEYrsaEncryption
SSL_SERVER_A_SIGsha256WithRSAEncryption
SSL_SESSION_IDa2416eb772bf4070fc92a7da3117cc99334df5e7e64517c9a3bd2dd322546652
SSL_SESSION_RESUMEDInitial
HTTP_HOSTwww.finduslocal.com
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip
HTTP_CF_IPCOUNTRYUS
HTTP_X_FORWARDED_FOR35.170.75.58
HTTP_CF_RAY566ae913dd40cf00-IAD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_USER_AGENTCCBot/2.0 (https://commoncrawl.org/faq/)
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_LANGUAGEen-US,en;q=0.5
HTTP_CF_CONNECTING_IP35.170.75.58
HTTP_CDN_LOOPcloudflare
PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
SERVER_SIGNATURE
SERVER_SOFTWAREApache/2.4.41 (codeit) OpenSSL/1.1.1d
SERVER_NAMEwww.finduslocal.com
SERVER_ADDR38.109.143.104
SERVER_PORT443
REMOTE_ADDR35.170.75.58
DOCUMENT_ROOT/home/finduslocal/public_html/public
REQUEST_SCHEMEhttps
CONTEXT_PREFIX
CONTEXT_DOCUMENT_ROOT/home/finduslocal/public_html/public
SERVER_ADMIN[email protected]
SCRIPT_FILENAME/home/finduslocal/public_html/public/index.php
REMOTE_PORT60166
REDIRECT_URL/new-and-used-car-dealers/district-of-columbia/washington/gold-motors/phone/202-526-3434/
REDIRECT_QUERY_STRING_url=/new-and-used-car-dealers/district-of-columbia/washington/gold-motors/phone/202-526-3434/
GATEWAY_INTERFACECGI/1.1
SERVER_PROTOCOLHTTP/1.1
REQUEST_METHODGET
QUERY_STRING_url=/new-and-used-car-dealers/district-of-columbia/washington/gold-motors/phone/202-526-3434/
REQUEST_URI/new-and-used-car-dealers/district-of-columbia/washington/gold-motors/phone/202-526-3434/
SCRIPT_NAME/index.php
PHP_SELF/index.php
REQUEST_TIME_FLOAT1581975529.678
REQUEST_TIME1581975529
#Path
0/home/finduslocal/public_html/public/index.php
1/home/finduslocal/public_html/apps/bootstrap.php
2/home/finduslocal/public_html/vendor/autoload.php
3/home/finduslocal/public_html/vendor/composer/autoload_real.php
4/home/finduslocal/public_html/vendor/composer/ClassLoader.php
5/home/finduslocal/public_html/vendor/composer/autoload_static.php
6/home/finduslocal/public_html/vendor/symfony/polyfill-mbstring/bootstrap.php
7/home/finduslocal/public_html/vendor/symfony/polyfill-ctype/bootstrap.php
8/home/finduslocal/public_html/vendor/symfony/polyfill-php72/bootstrap.php
9/home/finduslocal/public_html/vendor/symfony/polyfill-php72/Php72.php
10/home/finduslocal/public_html/vendor/symfony/var-dumper/Resources/functions/dump.php
11/home/finduslocal/public_html/vendor/snowair/phalcon-debugbar/src/Debug.php
12/home/finduslocal/public_html/vendor/novnik-extensions-/phalcon-parse-rss/src/ParseRss.php
13/home/finduslocal/public_html/config/config.php
14/home/finduslocal/public_html/config/services.php
15/home/finduslocal/public_html/config/repos.php
16/home/finduslocal/public_html/config/function.php
17/home/finduslocal/public_html/apps/frontend/config/routes.php
18/home/finduslocal/public_html/apps/api/config/routes.php
19/home/finduslocal/public_html/apps/members/config/routes.php
20/home/finduslocal/public_html/apps/profile/config/routes.php
21/home/finduslocal/public_html/apps/oauth/config/routes.php
22/home/finduslocal/public_html/apps/frontend/Module.php
23/home/finduslocal/public_html/apps/commons/AbstractModule.php
24/home/finduslocal/public_html/apps/frontend/config/config.php
25/home/finduslocal/public_html/apps/frontend/controllers/IndexController.php
26/home/finduslocal/public_html/apps/frontend/controllers/BaseController.php
27/home/finduslocal/public_html/library/Auth/Auth.php
28/home/finduslocal/public_html/apps/commons/models/Users.php
Memory
Usage2097152