Esempio n. 1
0
 public function getGeo($ip = '')
 {
     if ($this->geo !== null) {
         return $this->geo;
     }
     if (!file_exists(JPATH_LIBRARIES . '/geoip/geoip.php')) {
         return false;
     }
     require_once JPATH_LIBRARIES . '/geoip/geoip.php';
     $geo = new GeoIp($ip);
     $this->geo = $geo->get();
     return $this->geo;
 }
Esempio n. 2
0
 public function testGetRecord1()
 {
     $res = GeoIp::getRecord('www.google.com');
     // NOTE this may not always hold true
     $this->assertEquals($res['country_name'], 'United States');
     $this->assertEquals($res['region'], 'CA');
     $this->assertEquals($res['city'], 'Mountain View');
 }
Esempio n. 3
0
 function getCity()
 {
     $default = 'Екатеринбург';
     if ($res = Cookie::get('city')) {
         return $res;
         //Закоментить для отладки
     }
     include_once 'core/lib/GeoIp.class.php';
     $res = GeoIp::getCity();
     if (!$res) {
         $res = $default;
     }
     Cookie::set('city', $res);
     return $res;
 }
Esempio n. 4
0
            // Display the notices
            echo '<div class="error notice is-dismissible">';
            foreach ($this->admin_notices as $notice) {
                echo "<p>{$notice}</p>";
            }
            echo '</div>';
        }
    }
    /**
     * As a favor to users, let's match some common synonyms
     * 
     * @since 1.1.0
     * @return string label
     */
    private function match_label_synonyms($label)
    {
        if ('country' == $label) {
            $label = 'countrycode';
        }
        if ('state' == $label) {
            $label = 'region';
        }
        if ('zipcode' == $label || 'zip' == $label) {
            $label = 'postalcode';
        }
        return $label;
    }
}
// Register the GeoIP instance
GeoIp::init();
Esempio n. 5
0
 function actCouponPDF()
 {
     global $ST, $get;
     $id = $get->getInt('id');
     $rs = $ST->select("SELECT * FROM sc_shop_item WHERE id={$id}");
     if ($rs->next()) {
         $data = array('img' => '', 'num' => $get->get('num'), 'pass' => $get->get('pass'), 'name' => $rs->get('name'), 'html' => $rs->get('html'), 'html2' => $rs->get('html2'), 'html3' => $rs->get('html3'));
         //			$addr="Югозападный район, Ул. Онуфриева";
         $addr = $rs->get('address');
         if ($addr) {
             $img_path = "tmp/" . md5($addr) . ".png";
             if (!file_exists($img_path)) {
                 $m = GeoIp::getYMap2($addr);
                 if ($m) {
                     file_put_contents($img_path, $m);
                     $data['img'] = $img_path;
                 }
             } else {
                 $data['img'] = $img_path;
             }
         }
         include "shared/php/mPDF/mpdf.php";
         //			$str = "<strong>Привет</strong>";
         $tpl = 'coupon.tpl.php';
         if ($data['pass']) {
             $tpl = 'coupon_uni.tpl.php';
         }
         $str = $this->render($data, dirname(__FILE__) . "/rep/{$tpl}");
         //		$mpdf = new mPDF('UTF-8','A4','','',10,10,0,10,0,0);
         $mpdf = new mPDF('UTF-8', 'A4', '', '');
         @$mpdf->WriteHTML(iconv('windows-1251', 'utf-8', $str));
         @$mpdf->Output();
     } else {
         echo 'Не найдено!';
     }
 }
Esempio n. 6
0
<?php

namespace cd;

$session->requireSuperAdmin();
switch ($this->owner) {
    case 'version':
        echo "<h1>GeoIP database versions</h1>";
        foreach (GeoIp::getDatabaseVersions() as $d) {
            echo '<h2>' . $d['name'] . ' ' . $d['version'] . '</h2>';
            echo 'Date: ' . $d['date'] . ' (' . ago($d['date']) . ')<br/>';
            echo $d['file'] . '<br/>';
            echo '<br/>';
        }
        echo '&raquo; ' . ahref('a/geoip/query', 'Query GeoIP database');
        break;
    case 'query':
        function queryHandler($p)
        {
            echo '<h2>Result for ' . $p['ip'] . '</h2>';
            d(GeoIP::getRecord($p['ip']));
            echo 'Time zone: ' . GeoIP::getTimezone($p['ip']) . '<br/>';
        }
        echo '<h1>Query GeoIP database</h1>';
        $x = new XhtmlForm();
        $x->addInput('ip', 'IP');
        $x->addSubmit('Lookup');
        $x->setHandler('queryHandler');
        echo $x->render();
        break;
    default: