Пример #1
0
 /**
  * @param     $itemID
  * @param int $retry
  * @return APIItemV2
  */
 public static function getItemById($itemID, $retry = 3)
 {
     $cache = CacheHandler::getInstance('item_gw2api');
     $cacheKey = $itemID . "::" . substr(md5($itemID), 0, 10);
     $ttl = 86400;
     if (!($API_JSON = $cache->get($cacheKey))) {
         for ($i = 0; $i < $retry; $i++) {
             try {
                 $curl_item = CurlRequest::newInstance(getAppConfig('gw2spidy.gw2api_url') . "/v1/item_details.json?item_id={$itemID}")->exec();
                 $API_JSON = $curl_item->getResponseBody();
                 $cache->set($cacheKey, $API_JSON, MEMCACHE_COMPRESSED, $ttl);
                 return self::getSingleItemByJSON($API_JSON);
             } catch (\Exception $e) {
                 // - supress and short sleep
                 usleep(0.2 * 1000 * 1000);
                 // 0.2s
             }
         }
         $ttl = 60;
         $cache->set($cacheKey, null, MEMCACHE_COMPRESSED, $ttl);
         return null;
     } else {
         return self::getSingleItemByJSON($API_JSON);
     }
 }
Пример #2
0
 protected static function getDefaultHeaders()
 {
     $headers = array("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Encoding: deflate", "Connection: keep-alive", "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1");
     // use configured language but fallback to en
     $headers[] = "Accept-Language: " . getAppConfig('request-language') . ",en;q=0.5";
     return $headers;
 }
Пример #3
0
 public static function getRecipeById($dataId)
 {
     $cache = CacheHandler::getInstance('recipe_gw2api');
     $cacheKey = $dataId . "::" . substr(md5($dataId), 0, 10);
     $ttl = 86400;
     if (!($API_JSON = $cache->get($cacheKey))) {
         try {
             $curl_item = CurlRequest::newInstance(getAppConfig('gw2spidy.gw2api_url') . "/v1/recipe_details.json?recipe_id={$dataId}")->exec();
             $API_JSON = $curl_item->getResponseBody();
             $cache->set($cacheKey, $API_JSON, MEMCACHE_COMPRESSED, $ttl);
         } catch (\Exception $e) {
             $ttl = 600;
             $cache->set($cacheKey, null, MEMCACHE_COMPRESSED, $ttl);
             return null;
         }
     }
     return APIRecipe::getRecipeByJSON($API_JSON);
 }
 *  this is to avoid any memory problems (propel keeps a lot of stuff in memory)
 */
$run = 0;
$max = 100;
while ($run < $max) {
    sleep(4);
    $slot = $slotManager->getAvailableSlot();
    if (!$slot) {
        $sleep = $slotManager->getSlotsPerSecond() * 2;
        logg("no slots, sleeping [{$sleep}] ... \n");
        usleep($sleep * 1000 * 1000);
        continue;
    }
    logg("got slot, begin ...");
    $workload = array();
    for ($i = 0; $i < getAppConfig("gw2spidy.items-per-request"); $i++) {
        if ($queueItem = $queueManager->next()) {
            $workload[] = $queueItem;
        }
    }
    /*
     * if we have no items
     *  sleep for a bit before trying again
     */
    if (!$workload) {
        // return the slot
        $slot->release();
        logg("no items, sleeping [60] ... \n");
        sleep(60);
        $run++;
        continue;
Пример #5
0
 /**
  * if $dbname is false, the pdo will be returned without databse
  * if $dbname is "" the database name from config will be used
  * else the $dbname is used and if any instance exist with the name, it will be overwritten
  * To get old stored instance, the $dbname must be ""
  */
 public static function &getNamedInstance($name = "default", $dbname = "", $dbuser = "", $dbpass = "", $sqlserver = "mysql", $host = "localhost")
 {
     static $arrPDOName = array();
     if (!isset($arrPDOName[$name]) && $dbname !== "") {
         if (isset(self::$pdo[$dbname])) {
             $arrPDOName[$name] = $dbname;
             self::$pdo[$dbname]->name = $name;
             return self::$pdo[$dbname];
         }
     }
     if (isset($arrPDOName[$name])) {
         if (isset(self::$pdo[$arrPDOName[$name]])) {
             return self::$pdo[$arrPDOName[$name]];
         } else {
             trace("unexpected PDO instance requested");
         }
     }
     if ($dbname === "") {
         if ($name == "client") {
             if (function_exists("getDynamicDatabase") && getDynamicDatabase()) {
                 $dbname = getDynamicDatabase();
             } else {
                 $dbname = getAppConfig("DATABASE_NAME");
             }
         } else {
             $dbname = getAppConfig("DATABASE_NAME");
         }
     }
     if (isset(self::$pdo[$dbname])) {
         $arrPDOName[$name] = $dbname;
         return self::$pdo[$dbname];
     }
     if ($dbuser === "") {
         $dbuser = getAppConfig("DATABASE_USER");
     }
     if ($dbpass === "") {
         $dbpass = function_exists("getAppConfig") ? getAppConfig("DATABASE_PASSWORD") : "";
     }
     self::$pdo[$dbname] = new ClsNaanalPDO($host, $dbuser, $dbpass, $dbname, $sqlserver);
     self::$pdo[$dbname]->name = $name;
     $arrPDOName[$name] = $dbname;
     self::$instanceCount++;
     return self::$pdo[$dbname];
 }
Пример #6
0
//Quick and dirty discipline name to ID translation.
$disciplines = array('Huntsman' => 1, 'Artificer' => 2, 'Weaponsmith' => 3, 'Armorsmith' => 4, 'Leatherworker' => 5, 'Tailor' => 6, 'Jeweler' => 7, 'Chef' => 8);
//Gather all recipes by recipe_id
$curl = CurlRequest::newInstance(getAppConfig('gw2spidy.gw2api_url') . "/v1/recipes.json")->exec();
$data = json_decode($curl->getResponseBody(), true);
$multi_curl = EpiCurl::getInstance();
$recipe_curls = array();
$recipe_count = count($data['recipes']);
$error_values = array();
$i = 0;
$ii = 0;
foreach (array_chunk($data['recipes'], 1000) as $recipes) {
    //Add all curl requests to the EpiCurl instance.
    foreach ($recipes as $recipe_id) {
        $i++;
        $ch = curl_init(getAppConfig('gw2spidy.gw2api_url') . "/v1/recipe_details.json?recipe_id={$recipe_id}");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $recipe_curls[$recipe_id] = $multi_curl->addCurl($ch);
        echo "[{$i} / {$recipe_count}]: {$recipe_id}\n";
    }
    foreach ($recipes as $recipe_id) {
        $ii++;
        try {
            echo "[{$ii} / {$recipe_count}] ";
            $recipe_details = json_decode($recipe_curls[$recipe_id]->data, true);
            $created_item = ItemQuery::create()->findPK($recipe_details['output_item_id']);
            if (!$created_item) {
                throw new NoResultItemException("no result [[ {$recipe_details['output_item_id']} ]]");
            }
            echo $created_item->getName() . "\n";
            //If a recipe has multiple disciplines, treat each one like a separate recipe to be inserted.
Пример #7
0
    if (is_null($env)) {
        $env = new \Igorw\Silex\Env(__DIR__ . "/config/cnf");
    }
    return $env;
}
/**
 * @return \Igorw\Silex\Config
 */
function getAppConfig($key = null)
{
    static $cnf = null;
    if (is_null($cnf)) {
        $cnf = new \Igorw\Silex\Config(getAppEnv());
    }
    if (!is_null($key)) {
        return $cnf->getConfig($key);
    }
    return $cnf;
}
// Include the main Propel script
require_once __DIR__ . '/vendor/propel/runtime/lib/Propel.php';
// Initialize Propel with the runtime configuration
$propelcnf = (array) getAppConfig('propel');
$propelcnf['classmap'] = (include __DIR__ . '/config/classmap-gw2spidy-conf.php');
Propel::setConfiguration($propelcnf);
Propel::initialize();
// set newrelic_background_job if on CLI and newrelic is enabled
if (function_exists('newrelic_background_job') && php_sapi_name() == 'cli') {
    newrelic_background_job(true);
}
require_once __DIR__ . '/vendor/simple_html_dom/simple_html_dom.php';
Пример #8
0
 public function getTheme()
 {
     static $theme = null;
     if (is_null($theme)) {
         $theme = $this->getConfigVar("theme");
         if ($theme === true) {
             $theme = getAppConfig("theme");
         }
     }
     return $theme;
 }
Пример #9
0
 /**
  * Returns the salt that was originally used to encode the password.
  *
  * This can return null if the password was not encoded using a salt.
  *
  * @return string The salt
  */
 public function getSalt()
 {
     return getAppConfig('password-salt');
 }
Пример #10
0
 protected function getGoldToGem()
 {
     $coins = 100000000;
     $data = $this->getApiData(getAppConfig('gw2spidy.gw2api_url') . "/v2/commerce/exchange/coins?quantity={$coins}");
     return $data['coins_per_gem'];
 }
Пример #11
0
 public function getListingsByIds(array $ids)
 {
     $ids = array_map('urlencode', $ids);
     return $this->getApiData(getAppConfig("gw2spidy.gw2api_url") . "/v2/commerce/listings?ids=" . implode(",", $ids) . "");
 }
Пример #12
0
/**
 * @return \Igorw\Silex\Config
 */
function getAppConfig($key = null)
{
    static $cnf = null;
    if (is_null($cnf)) {
        $cnf = new Igorw\Silex\Config(getAppEnv());
    }
    if (!is_null($key)) {
        return $cnf->getConfig($key);
    }
    return $cnf;
}
// Include the main Propel script
require_once __DIR__ . '/vendor/propel/runtime/lib/Propel.php';
// Initialize Propel with the runtime configuration
$propelcnf = (array) getAppConfig('propel');
$propelcnf['classmap'] = (include __DIR__ . '/config/classmap-gw2spidy-conf.php');
Propel::setConfiguration($propelcnf);
Propel::initialize();
// initiate the application, check config to enable debug / sql logging when needed
$app = new Silex\Application();
// register config provider
$app->register(new Igorw\Silex\ConfigServiceProvider(getAppConfig()));
$app->register(new TMG\Services\ServicesProvider());
$app->register(new Rafal\MemcacheServiceProvider\MemcacheServiceProvider());
// setup dev mode related stuff based on config
isset($app['sql_logging']) && $app['sql_logging'] && $app->enableSQLLogging();
// register providers
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());
Пример #13
0
<?php

use GW2Spidy\NewQueue\RequestSlotManager;
require dirname(__FILE__) . '/../autoload.php';
RequestSlotManager::getInstance()->setup();
$count = getAppConfig("gw2spidy.request-slots.count");
$cooldown = getAppConfig("gw2spidy.request-slots.cooldown");
/**
 * 100 slots with 10 sec cooldown gives us :
 *     100 requests / 10 seconds = 10 requests / sec
 * this is excluding the time it takes to handle the slots
 */
$max = $count / $cooldown;
$maxH = $max * 60 * 60;
echo "set up slot manager (count={$count}, cooldown={$cooldown}, max-requests per seconds={$max} / per hour={$maxH})\n";
Пример #14
0
<?php

use GW2Spidy\Dataset\DatasetManager;
use GW2Spidy\Util\CacheHandler;
require dirname(__FILE__) . '/../autoload.php';
// memcache is completely purged this way
if (array_intersect(array('-m', '--all'), $argv)) {
    CacheHandler::getInstance("purge")->purge();
    echo "cleared memcache \n";
}
if (array_intersect(array('-d', '--all'), $argv)) {
    DatasetManager::getInstance()->purgeCache();
    echo "cleared dataset \n";
}
if (array_intersect(array('-a', '--all'), $argv) && function_exists('apc_clear_cache') && ($host = getAppConfig("apc_clear_cache_host"))) {
    apc_clear_cache();
    apc_clear_cache('user');
    apc_clear_cache('opcode');
    $hash = md5(uniqid());
    $targetDir = dirname(dirname(__FILE__)) . "/webroot/tmp";
    $target = "{$targetDir}/{$hash}.php";
    if (!is_dir($targetDir)) {
        mkdir($targetDir);
    }
    copy(dirname(__FILE__) . "/clear_apc_cache.php", $target);
    $url = "http://{$host}/tmp/{$hash}.php";
    $result = json_decode(file_get_contents($url), true);
    if (isset($result['success']) && $result['success']) {
        echo "cleared apc \n";
    } else {
        echo "failed to clear apc \n";
Пример #15
0
 public function isMemcachedEnabled()
 {
     return \getAppConfig('memcached_enabled');
 }
Пример #16
0
 protected function getTimeout()
 {
     return getAppConfig("gw2spidy.request-slots.cooldown");
 }
Пример #17
0
 public static function getDefaultDatabase()
 {
     return getAppConfig("DATABASE_NAME");
 }
Пример #18
0
function getWebAuth()
{
    list($appInfo, $clientIdentifier, $userLocale) = getAppConfig();
    $redirectUri = getUrl("dropbox-auth-finish");
    $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
    return new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore, $userLocale);
}
Пример #19
0
$pageSize = 200;
$curl = CurlRequest::newInstance(getAppConfig('gw2spidy.gw2api_url') . "/v2/items?page=0&page_size={$pageSize}")->exec();
if ($curl->getInfo("http_code") != 200) {
    print "Failed curl request. Returned Status was {$curl->getInfo("http_code")}.\n";
    print "Returned body: {$curl->getResponseBody()}\n";
    exit(1);
}
processApiData($curl->getResponseBody(), 0);
$numberOfPages = intval($curl->getResponseHeaders("X-Page-Total"));
$multi_curl = EpiCurl::getInstance();
$item_curls = array();
$itemSubTypes = array();
//Add all curl requests to the EpiCurl instance.
for ($page = 1; $page < $numberOfPages; $page++) {
    echo "REQUESTING [{$page} / {$numberOfPages}]\n";
    $ch = curl_init(getAppConfig('gw2spidy.gw2api_url') . "/v2/items?page={$page}&page_size={$pageSize}");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $item_curls[$page] = $multi_curl->addCurl($ch);
}
for ($page = 1; $page < $numberOfPages; $page++) {
    echo "PROCESSING [{$page} / {$numberOfPages}]:\n";
    $API_JSON = $item_curls[$page]->data;
    if ($item_curls[$page]->code != 200) {
        print "Failed curl request. Returned Status was {$item_curls[$page]}->code}.\n";
        print "Returned body: {$API_JSON}\n";
        exit(1);
    }
    processApiData($API_JSON, $page * $pageSize);
}
Propel::enableInstancePooling();
exit(0);
Пример #20
0
 /**
  * process a single tick,
  *  adding it to the different lines and cleaning up / aggregating old data
  *
  * @param  DateTime    $date
  * @param  int         $rate
  */
 protected function processTick(DateTime $date, $rate)
 {
     $ts = $date->getTimestamp();
     $tsHr = self::tsHour($ts);
     // get the previous tick
     end($this->noMvAvg);
     $prevTs = key($this->noMvAvg);
     // add to noMvAvg
     $this->tsByHour[$tsHr][] = $ts;
     $this->noMvAvg[$ts] = array($ts * 1000, $rate);
     // add to past 24 hours
     $this->past24Hours[$ts] = $rate;
     /*
      * we process the gap between the previous tick and our tick
      * since everything before the previous tick has already been processed!
      */
     if ($prevTs) {
         /*
          * remove ticks from the past24Hours cache if they're older then 24 hours
          *  but younger then what the previous tick should have already removed
          */
         $thresMin = self::tsHour($prevTs - self::TS_ONE_DAY);
         $thresMax = self::tsHour($ts - self::TS_ONE_DAY);
         while ($thresMin < $thresMax) {
             $thisTsHour = self::tsHour($thresMin);
             $thisHour = array();
             if (isset($this->tsByHour[$thisTsHour])) {
                 foreach (array_unique($this->tsByHour[$thisTsHour]) as $tickTs) {
                     unset($this->past24Hours[$tickTs]);
                 }
             }
             $thresMin += self::TS_ONE_HOUR;
         }
         /*
          * aggregate ticks older then 24 hours into 1 tick per hour (averaged out for that hour)
          *  this is done to reduce the size of the the dataset we have in memory
          *  however since we're now also cleaning up our dataset in the database we can disable this
          */
         if (getAppConfig('gw2spidy.aggregate_ticks_on_request')) {
             $thresMin = self::tsHour($prevTs - $this->hourlyThreshold);
             $thresMax = self::tsHour($ts - $this->hourlyThreshold);
             while ($thresMin < $thresMax) {
                 $thisTsHour = self::tsHour($thresMin);
                 $thisHour = array();
                 if (isset($this->tsByHour[$thisTsHour])) {
                     // (re)calculate the average of this ticks hour
                     $hourNoMvAvg = array();
                     $hourDailyMvAvg = array();
                     foreach ($this->tsByHour[$thisTsHour] as $tickTs) {
                         $hourNoMvAvg[] = $this->noMvAvg[$tickTs][1];
                         $hourDailyMvAvg[] = $this->dailyMvAvg[$tickTs][1];
                     }
                     $this->hourlyNoMvAvg[$thisTsHour] = array_sum($hourNoMvAvg) / count($hourNoMvAvg);
                     $this->hourlyDailyMvAvg[$thisTsHour] = array_sum($hourDailyMvAvg) / count($hourDailyMvAvg);
                     // remove old ticks
                     foreach (array_unique($this->tsByHour[$thisTsHour]) as $tickTs) {
                         unset($this->noMvAvg[$tickTs]);
                         unset($this->dailyMvAvg[$tickTs]);
                     }
                     // insert hourly ticks
                     $this->noMvAvg[$thisTsHour] = array($thisTsHour * 1000, $this->hourlyNoMvAvg[$thisTsHour]);
                     $this->dailyMvAvg[$thisTsHour] = array($thisTsHour * 1000, $this->hourlyDailyMvAvg[$thisTsHour]);
                     $this->noMvAvg[$thisTsHour] = array($thisTsHour * 1000, $this->hourlyNoMvAvg[$thisTsHour]);
                     $this->tsByHour[$thisTsHour] = array($thisTsHour);
                 }
                 $thresMin += self::TS_ONE_HOUR;
             }
         }
     }
     // calculate new daily mv avg tick
     if (count($this->past24Hours)) {
         $dailyMvAvg = array_sum($this->past24Hours) / count($this->past24Hours);
         $this->dailyMvAvg[$ts] = array($ts * 1000, $dailyMvAvg);
     }
 }
Пример #21
0
function isApplicationInstalled()
{
    if(!file_exists("config.php")) 
    {
        return false;
    }
    if(!file_exists("ClsConfig.php")) return false;
    require_once("ClsConfig.php");
    if(!class_exists("ClsConfig")) return false;
    foreach(ClsConfig::$CONFIG_VAR as $variable=>$arrInfo)
    {
        if(ClsConfig::$DATABASE_CONFIG_TYPE=="variable")
        {
            if(ClsNaanalConfigGen::getVarIndex($variable)==-1)
            {
                return false;
            }
        }
        else
        {
            if(ClsNaanalConfigGen::getDefineKeyIndex($variable)==-1)
            {
                return false;
            }
        }
    }
    /**
     * The application var must have some value other than default value
     */
    if(ClsConfig::$CONFIG_MANDATORY_VAR)
    foreach(ClsConfig::$CONFIG_MANDATORY_VAR as $applicationVar)
    {
        if(ClsConfig::$DATABASE_CONFIG_TYPE=="variable")
        {
            $dataIndex=ClsNaanalConfigGen::getVarIndex($applicationVar);
        }
        else
        {
            $dataIndex=ClsNaanalConfigGen::getDefineValueIndex($applicationVar);
        }
        if(is_null($dataIndex) || $dataIndex==-1) 
        {
            return false;
        }
        $data=ClsNaanalConfigGen::extractValue($dataIndex);
        if(ClsConfig::$CONFIG_VAR[$applicationVar]["data"]===$data)
        {
            return false;
        }
        $configdata=ClsConfig::$CONFIG_VAR[$applicationVar]["data"];
    }
    $type=getAppConfig("DATABASE_CONFIG_TYPE");
    if($type=="constant")
    {
        include_once("config.php");
        $arrVar=get_defined_constants();
    }
    else
    {
        include("config.php");
        $arrVar=get_defined_vars();
    }
    /*$arrConfigVar=getAppConfig("CONFIG_VAR");
    if($arrConfigVar)
    foreach($arrConfigVar as $var)
    {
        $tmpvar=ClsConfig::$CONFIG_VAR_MAP[$var];
        if(!isset($arrVar[$tmpvar]))
        {
            return false;
        }
    }*/
    return true;
}
Пример #22
0
 function __construct($controlpanel, $encryptURL = false, $ipFilterControlpanel = null, $homepage = false)
 {
     $autoSession = getConfigVar("AUTO_SESSION");
     if (isset($_REQUEST["webservice"])) {
         if ($_REQUEST["webservice"] == "getchallenge") {
             session_start();
         } else {
             if (isset($_REQUEST["accessKey"])) {
                 $sql = "select * from webservice where accessKey='{$_REQUEST["accessKey"]}'";
                 $pdo = connectPDO(getAppConfig("DATABASE_HOST"), getAppConfig("DATABASE_USER"), getAppConfig("DATABASE_PASSWORD"), getAppConfig("DATABASE_NAME"), getAppConfig("DATABASE_SERVER"));
                 //ClsNaanalPDO::getNamedInstance();
                 try {
                     $statement = $pdo->query($sql);
                     $arr = $statement->fetchAll(PDO::FETCH_ASSOC);
                     $_SESSION = unserialize(base64_decode($arr[0]["session_object"]));
                     if ($arr[0]["logged"]) {
                         $arrData = array();
                         $arrData["error"] = "You already logged.";
                         die(json_encode($arrData));
                     }
                 } catch (Exception $e) {
                     die($e);
                 }
             } else {
                 if (isset($_REQUEST["sessionName"])) {
                     $sql = "select * from webservice where session='{$_REQUEST["sessionName"]}'";
                     $pdo = connectPDO(getAppConfig("DATABASE_HOST"), getAppConfig("DATABASE_USER"), getAppConfig("DATABASE_PASSWORD"), getAppConfig("DATABASE_NAME"), getAppConfig("DATABASE_SERVER"));
                     //ClsNaanalPDO::getNamedInstance();
                     try {
                         $statement = $pdo->query($sql);
                         $arr = $statement->fetchAll(PDO::FETCH_ASSOC);
                         $_SESSION = unserialize(base64_decode($arr[0]["session_object"]));
                     } catch (Exception $e) {
                         die($e);
                     }
                 }
             }
         }
     } else {
         if (!($autoSession === false)) {
             session_start();
         }
     }
     if (isset($_REQUEST["webservice"])) {
         if (isset($_POST["element"])) {
             $arr = json_decode($_POST["element"]);
             foreach ($arr as $pk => $pv) {
                 if ($_REQUEST["webservice"] == "getchallenge") {
                     if ($pk == "webservice" || $pk == "loginname") {
                         continue;
                     }
                 } else {
                     if ($_REQUEST["webservice"] == "getchallenge") {
                         if ($pk == "webservice" || $pk == "accessKey" || $pk == "loginname") {
                             continue;
                         }
                     } else {
                         if ($pk == "element" || $pk == "webservice" || $pk == "sessionName" || $pk == "elementType") {
                             continue;
                         }
                     }
                 }
                 $_POST[$pk] = $pv;
             }
         } else {
             if (isset($_GET["element"])) {
                 $arr = json_decode($_POST["element"]);
                 foreach ($arr as $pk => $pv) {
                     if ($_REQUEST["webservice"] == "getchallenge") {
                         if ($pk == "webservice" || $pk == "loginname") {
                             continue;
                         }
                     } else {
                         if ($_REQUEST["webservice"] == "getchallenge") {
                             if ($pk == "webservice" || $pk == "accessKey" || $pk == "loginname") {
                                 continue;
                             }
                         } else {
                             if ($pk == "element" || $pk == "webservice" || $pk == "sessionName" || $pk == "elementType") {
                                 continue;
                             }
                         }
                     }
                     $_GET[$pk] = $pv;
                 }
             }
         }
     }
     if ($homepage === false) {
         $homepage = getIndexPage();
     }
     parent::__construct($controlpanel, $homepage);
     if (get_magic_quotes_gpc()) {
         if (isset($_REQUEST)) {
             $_REQUEST = $this->sanitize($_REQUEST, false);
         }
         if (isset($_GET)) {
             $_GET = $this->sanitize($_GET, false);
         }
         if (isset($_POST)) {
             $_POST = $this->sanitize($_POST, false);
         }
         if (isset($_COOKIE)) {
             $_COOKIE = $this->sanitize($_COOKIE, false);
         }
         if (isset(ClsConfig::$AUTO_SESSION) && ClsConfig::$AUTO_SESSION !== false) {
             if (isset($_SESSION)) {
                 $_SESSION = $this->sanitize($_SESSION, false);
             }
         }
         if (isset($_FILES)) {
             $_FILES = $this->sanitize($_FILES, false);
         }
         if (isset($_SERVER)) {
             $_SERVER = $this->sanitize($_SERVER, false);
         }
     } else {
         if (isset($_REQUEST)) {
             $_REQUEST = $this->sanitize($_REQUEST, true);
         }
         if (isset($_GET)) {
             $_GET = $this->sanitize($_GET, true);
         }
         if (isset($_POST)) {
             $_POST = $this->sanitize($_POST, true);
         }
         if (isset($_COOKIE)) {
             $_COOKIE = $this->sanitize($_COOKIE, true);
         }
         if (class_exists("ClsConfig") && isset(ClsConfig::$AUTO_SESSION) && ClsConfig::$AUTO_SESSION !== false) {
             if (isset($_SESSION)) {
                 $_SESSION = $this->sanitize($_SESSION, true);
             }
         }
         if (isset($_FILES)) {
             $_FILES = $this->sanitize($_FILES, true);
         }
         if (isset($_SERVER)) {
             $_SERVER = $this->sanitize($_SERVER, false);
         }
     }
     if (isset($_SERVER["PATH_INFO"]) && !empty($_SERVER["PATH_INFO"])) {
         $arrServerPathInfo = pathinfo($_SERVER["PATH_INFO"]);
         $arrPathInfo = explode("/", $_SERVER["PATH_INFO"]);
         array_shift($arrPathInfo);
         if (!empty($arrPathInfo)) {
             $_REQUEST["page"] = array_shift($arrPathInfo);
             $_GET["page"] = $_REQUEST["page"];
         }
         if (!empty($arrPathInfo)) {
             $_REQUEST["action"] = array_shift($arrPathInfo);
             $_GET["action"] = $_REQUEST["action"];
         }
         if (isset($arrServerPathInfo["extension"])) {
             $arPth = pathinfo($_SERVER["SCRIPT_NAME"]);
             //trace($arPth["dirname"]);
             $pth = implode("/", $arrPathInfo);
             header("Location:http://{$_SERVER["SERVER_NAME"]}{$arPth["dirname"]}/{$pth}");
             exit;
         }
         if (!empty($arrPathInfo)) {
             $_REQUEST["switch"] = array_shift($arrPathInfo);
             $_GET["switch"] = $_REQUEST["switch"];
         }
         while (!empty($arrPathInfo)) {
             $_REQUEST["AUIEO_ACTION_PARAM_DATA"][] = array_shift($arrPathInfo);
             $_GET["AUIEO_ACTION_PARAM_DATA"][] = $_REQUEST["AUIEO_ACTION_PARAM_DATA"];
         }
     }
     $autoSession = getConfigVar("AUTO_SESSION");
     if (!($autoSession === false)) {
         $this->objNaanalSession = ClsNaanalSession::getInstance();
     }
     $this->objNaanalRequest = ClsNaanalRequest::getInstance();
     $this->objNaanalPost = ClsNaanalPost::getInstance();
     $this->objNaanalGet = ClsNaanalGet::getInstance();
     $this->files = $_FILES;
     $this->page = $this->objNaanalRequest->getModule();
     $this->module = $this->objNaanalRequest->getModule();
     $this->action = $this->objNaanalRequest->getAction();
     $this->switch = $this->objNaanalRequest->getSwitch();
     if (class_exists("ClsConfig")) {
         $this->fldUserID = isset(ClsConfig::$FLD_USERID) ? ClsConfig::$FLD_USERID : "userid";
         $this->fldUser = isset(ClsConfig::$FLD_USER) ? ClsConfig::$FLD_USER : "******";
         $this->fldPassword = isset(ClsConfig::$FLD_PASSWORD) ? ClsConfig::$FLD_PASSWORD : "******";
     }
     $this->encryptURL = $encryptURL;
     if ($this->encryptURL && isset($_REQUEST["@page"])) {
         $shld = new URLShield(true, true);
         $shld->expose();
     }
 }
Пример #23
0
function getLangVar($_AUIEO_FIELD_NAME,$_AUIEO_FIELD_MODULE=false)
{
    static $arrData=array();
    //trace($_AUIEO_FIELD_NAME);
    //$_AUIEO_FIELD_NAME=  substr($_AUIEO_FIELD_NAME, strpos($_AUIEO_FIELD_NAME, "AUIEO_LANG"));
    if(isset($arrData[$_AUIEO_FIELD_NAME])) return $arrData[$_AUIEO_FIELD_NAME];
    
    $language=getAppConfig("LANGUAGE");
    
    if(!$language) $language ="default";
    
    //if($arraData($_AUIEO_FIELD_NAME)=="")
    if(file_exists("lang/{$language}/common.php")) include "lang/{$language}/common.php"; //trace($incfile);
    
    if(!empty($_AUIEO_FIELD_MODULE) && file_exists("modules/{$_AUIEO_FIELD_MODULE}/lang/{$language}/common.php")) include "modules/{$_AUIEO_FIELD_MODULE}/lang/{$language}/common.php";

    if(isset($$_AUIEO_FIELD_NAME))
    {
        $arrData[$_AUIEO_FIELD_NAME]=$$_AUIEO_FIELD_NAME;
    }
    else
    {
        $arrData[$_AUIEO_FIELD_NAME]="";
    }
    return $arrData[$_AUIEO_FIELD_NAME];
}