/**
  *
  * @param string $addressString
  * @param string $fullInfo if FALSE there is latitude and longitude returned only
  * @return array
  */
 public function lookupGeoCode($addressString, $fullInfo = FALSE)
 {
     $request = "https://maps.googleapis.com/maps/api/geocode/json?address=" . rawurlencode($addressString) . "&key=";
     $result = array();
     $time = microtime(TRUE);
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $request);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_HEADER, false);
     $response = curl_exec($curl);
     curl_close($curl);
     $requestTime = microtime(TRUE) - $time;
     if ($requestTime > 2) {
         tx_rnbase_util_Logger::notice('Long request time for Google address lookup ', 'rn_base', array('uri' => $request, 'time' => $requestTime));
     }
     if ($response) {
         $response = json_decode($response, true);
         if ($response['status'] == 'OK') {
             if (!$fullInfo) {
                 $result = reset($response['results']);
                 $result = $result['geometry']['location'];
             } else {
                 $result = $response;
             }
         } elseif ($response['status'] == 'OVER_QUERY_LIMIT') {
             throw new Exception($response['error_message']);
         }
     }
     return $result;
 }
 /**
  * Validiert einen PLZ-String für ein Land.
  * @param tx_mklib_interface_IZipCountry $land
  * @param string $zip
  * @return boolean
  */
 public static function validate(tx_mklib_interface_IZipCountry $country, $zip)
 {
     $result = true;
     switch ($country->getZipRule()) {
         case 0:
             // no rule set
             $result = true;
             tx_rnbase::load('tx_rnbase_util_Logger');
             if (tx_rnbase_util_Logger::isNoticeEnabled()) {
                 tx_rnbase_util_Logger::notice('No zip rule for country defined.', 'mklib', array('zip' => $zip, 'getISO2' => $country->getISO2(), 'getZipLength' => $country->getZipLength(), 'getZipRule' => $country->getZipRule()));
             }
             break;
         case 1:
             // maximum length without gaps
             $result = self::validateMaxLengthWG($country, $zip);
             break;
         case 2:
             // maximum length numerical without gaps
             $result = self::validateMaxLengthNumWG($country, $zip);
             break;
         case 3:
             // exact length without gaps
             $result = self::validateLengthWG($country, $zip);
             break;
         case 4:
             // exact length numerical without gaps
             $result = self::validateLengthNumWG($country, $zip);
             break;
         case 5:
             // maximum length with gaps
             $result = self::validateMaxLength($country, $zip);
             break;
         case 6:
             // maximum length numerical with gaps
             $result = self::validateMaxLengthNum($country, $zip);
             break;
         case 7:
             // exact length with gaps
             $result = self::validateLength($country, $zip);
             break;
         case 8:
             // exact length numerical with gaps
             $result = self::validateLengthNum($country, $zip);
             break;
         case 9:
             // special rules
             $result = self::validateSpecial($country, $zip);
             break;
         default:
             $result = false;
             break;
     }
     return $result;
 }
 /**
  * Logs DB changes
  *
  * @TODO: t3users log nutzen, wenn installiert! tx_t3users_util_ServiceRegistry::getLoggingService();
  *
  * @param 	string 	$msg
  * @param 	string 	$tablename
  * @param 	string 	$where
  * @param 	mixed 	$values
  */
 private static function log($msg, $tablename, $where = false, $values = false)
 {
     if (!self::isLog($tablename)) {
         return false;
     }
     // else
     // daten sammeln
     $data = array();
     $data['fe_user'] = isset($GLOBALS['TSFE']->fe_user->user['uid']) ? $GLOBALS['TSFE']->fe_user->user['uid'] : 'none';
     $data['be_user'] = array_key_exists('BE_USER', $GLOBALS) && is_object($GLOBALS['BE_USER']) ? $GLOBALS['BE_USER']->user['uid'] : 'none';
     $data['tablename'] = $tablename;
     if ($where) {
         $data['where'] = $where;
     }
     if ($values) {
         $data['values'] = $values;
     }
     // backtrace Konfigurierbar machen?
     tx_rnbase::load('tx_mklib_util_Logger');
     $data['debug_backtrace'] = tx_mklib_util_Logger::getDebugBacktrace();
     // wurde auf hidden gesetzt?
     $disabled = tx_mklib_util_TCA::getEnableColumn($tablename, 'disabled', 'hidden');
     if ($values && isset($values[$disabled]) && $values[$disabled]) {
         $msg .= '->disabled';
     }
     // wurde gelöscht?
     $delete = tx_mklib_util_TCA::getEnableColumn($tablename, 'delete', 'deleted');
     if ($values && isset($values[$delete]) && $values[$delete]) {
         $msg .= '->delete';
     }
     // tabellenname ergänzen
     $msg .= '(' . $tablename . ')';
     tx_rnbase_util_Logger::notice($msg, 'mklib', $data);
     return true;
 }