<?php
if (class_exists('RVSGL') === false) {
class RVSGL extends SGL
{
/**
*
* @param <int> $mode; 0 is look up by php only,
* 1 is look up by js only,
* 2 look up by have php and js
* @return array
*/
public static function loadAllRegionList($regionType, $lookupMode=0)
{
$aPHPFile = glob(SGL_DAT_DIR . "/ary.{$regionType}.*.php");
$aPHP = array();
foreach ($aPHPFile as $file) {
if (preg_match("#ary\.{$regionType}\.(.*?)\.php#", $file, $aMatch)) {
$aPHP[] = $aMatch[1];
}
}
$aJsFile = glob(SGL_DAT_DIR . "/ary.{$regionType}.*.js");
$aJs = array();
foreach ($aJsFile as $file) {
if (preg_match("#ary\.{$regionType}\.(.*?)\.js#", $file, $aMatch)) {
$aJs[] = $aMatch[1];
}
}
$aRes = array();
if ($lookupMode == 0) {
$aRes = $aPHP;
} else if ($lookupMode == 1) {
$aRes = $aJs;
} else if ($lookupMode == 2) {
$aRes = array_intersect($aPHP, $aJs);
}
return $aRes;
}
public static function getRegionStringnameTpl()
{
//Short Countries EN
return "{dataType}\t{lang}\t{regionType}";
}
public static function getJotformSpecialOpt($specialOpt)
{
$aOpts = preg_split("#\t#", $specialOpt);
$aDefOpts = preg_split("#\t#", RVSGL::getRegionStringnameTpl());
if (count($aOpts) === count($aDefOpts)) {
$dataType = $aOpts[0];
$lang = $aOpts[1];
$regionType = $aOpts[2];
} else {
$dataType = null;
$lang = $aOpts[0];
$regionType = $aOpts[1];
}
$regionType = RvsLibs_String::strtolower($regionType);
$lang = RvsLibs_String::strtolower($lang);
if ($regionType === 'states' && $lang === 'us') {
$lang = 'en';
}
$aRegion = RVSGL::loadPHPRegionByLang($regionType, $lang);
return RVSGL::getArrRegion($aRegion, $dataType);
}
public static function loadPHPRegionByLang($regionType, $lang)
{
$file = SGL_DAT_DIR . "/ary.{$regionType}.{$lang}.php";
if (file_exists($file) === true) {
$data = join('', file($file));
$varName = '$' . $regionType;
if (preg_match('#(\$\w+)#si', $data, $aMatch)) {
$varName = $aMatch[1];
}
try {
require $file;
eval("\$aRes = $varName;");
} catch (Exception $e) {
$aRes = array();
}
return $aRes;
} else {
return array();
}
}
public static function getArrRegion($aRegion, $dataType=null)
{
$aRes = array();
if (strtolower($dataType) == "short") {
foreach ($aRegion as $k => $v) {
array_push($aRes, $k);
}
} else {
foreach ($aRegion as $v) {
array_push($aRes, $v);
}
}
return $aRes;
}
public static function loadJsRegionByLang($regionType, $lang)
{
if (file_exists(SGL_DAT_DIR . "/ary.{$regionType}.{$lang}.js") === true) {
$aFile = file(SGL_DAT_DIR . "/ary.{$regionType}.{$lang}.js");
return preg_replace("#\n| {4}|\t#si",' ', join('', $aFile)) . "\n";
} else {
return false;
}
}
public static function jstranslate($key, $filter = false, $aParams = array(), $output = null, $lang = null)
{
$msg = SGL_Output::translate($key, $filter, $aParams, $output, $lang);
return htmlspecialchars($msg);
}
}
}
?>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez