Esempio n. 1
0
 public static function Initialize()
 {
     if (QApplication::$LanguageCode) {
         if (QApplication::$CountryCode) {
             $strCode = sprintf('%s_%s', QApplication::$LanguageCode, QApplication::$CountryCode);
             $strLanguageFiles = array(__QCUBED_CORE__ . '/i18n/' . QApplication::$LanguageCode . '.po', __QCUBED_CORE__ . '/i18n/' . $strCode . '.po', __QCUBED__ . '/i18n/' . QApplication::$LanguageCode . '.po', __QCUBED__ . '/i18n/' . $strCode . '.po');
         } else {
             $strCode = QApplication::$LanguageCode;
             $strLanguageFiles = array(__QCUBED_CORE__ . '/i18n/' . QApplication::$LanguageCode . '.po', __QCUBED__ . '/i18n/' . QApplication::$LanguageCode . '.po');
         }
         // Setup the LanguageFileObject cache mechanism
         $objCache = new QCache('i18n', $strCode, 'i18n', $strLanguageFiles);
         // If cached data exists and is valid, use it
         $strData = $objCache->GetData();
         if ($strData) {
             QApplication::$LanguageObject = unserialize($strData);
         } else {
             $objLanguage = new QI18n();
             foreach ($strLanguageFiles as $strLanguageFile) {
                 if (file_exists($strLanguageFile)) {
                     try {
                         $objLanguage->ParsePoData(file_get_contents($strLanguageFile));
                     } catch (QPoParserException $objExc) {
                         $objExc->setMessage('Invalid Language File: ' . $strLanguageFile . ': ' . $objExc->getMessage());
                         $objExc->IncrementOffset();
                         throw $objExc;
                     }
                 }
             }
             QApplication::$LanguageObject = $objLanguage;
             $objCache->SaveData(serialize($objLanguage));
         }
     }
 }
Esempio n. 2
0
 protected function btnClearCache_Click($strFormId, $strControlId, $strParameter)
 {
     $blnSuccess = QCache::ClearNamespace('qquery/person');
     if ($blnSuccess) {
         $strStatus = "successful";
     } else {
         $strStatus = "NOT successful - check your cache / namespace paths";
     }
     $this->lblMessage->Text = 'Clearing the query cache for the Person table was ' . $strStatus . '. Reload the page to see the effect - query will not be executed against the database. ';
 }
 public static function Load($strLanguageCode = null, $strCountryCode = null)
 {
     $objLanguageObject = null;
     if ($strLanguageCode) {
         if ($strCountryCode) {
             $strCode = sprintf('%s_%s', $strLanguageCode, $strCountryCode);
             $strLanguageFiles = array(__QCUBED_CORE__ . '/i18n/' . $strLanguageCode . '.po', __QCUBED_CORE__ . '/i18n/' . $strCode . '.po', __QI18N_PO_PATH__ . '/' . $strLanguageCode . '.po', __QI18N_PO_PATH__ . '/' . $strCode . '.po');
         } else {
             $strCode = $strLanguageCode;
             $strLanguageFiles = array(__QCUBED_CORE__ . '/i18n/' . $strLanguageCode . '.po', __QI18N_PO_PATH__ . '/' . $strLanguageCode . '.po');
         }
         // Setup the LanguageFileObject cache mechanism
         $objCache = new QCache('i18n.po', $strCode, 'i18n', $strLanguageFiles);
         // If cached data exists and is valid, use it
         $strData = $objCache->GetData();
         if ($strData) {
             $objLanguageObject = unserialize($strData);
             // Otherwise, reload all langauge files and update the cache
         } else {
             $objLanguage = new QTranslationPoParser();
             foreach ($strLanguageFiles as $strLanguageFile) {
                 if (file_exists($strLanguageFile)) {
                     try {
                         //print($strLanguageFile.'<BR>');
                         $objLanguage->ParsePoData(file_get_contents($strLanguageFile));
                     } catch (QPoParserException $objExc) {
                         $objExc->setMessage('Invalid Language File: ' . $strLanguageFile . ': ' . $objExc->getMessage());
                         $objExc->IncrementOffset();
                         throw $objExc;
                     }
                 }
             }
             $objLanguageObject = $objLanguage;
             $objCache->SaveData(serialize($objLanguage));
         }
     }
     return $objLanguageObject;
 }
 public static function QueryArrayCached(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null, $blnForceUpdate = false)
 {
     // Get the Database Object for this Class
     $objDatabase = DleMailLog::GetDatabase();
     $strQuery = DleMailLog::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
     $objCache = new QCache('qquery/dlemaillog', $strQuery);
     $cacheData = $objCache->GetData();
     if (!$cacheData || $blnForceUpdate) {
         $objDbResult = $objQueryBuilder->Database->Query($strQuery);
         $arrResult = DleMailLog::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
         $objCache->SaveData(serialize($arrResult));
     } else {
         $arrResult = unserialize($cacheData);
     }
     return $arrResult;
 }
 public static function QueryArrayCached(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null, $blnForceUpdate = false)
 {
     $strQuery = static::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
     $strTableName = static::GetTableName();
     $objCache = new QCache(sprintf('qquery/%s', $strTableName), $strQuery);
     $cacheData = $objCache->GetData();
     if (!$cacheData || $blnForceUpdate) {
         $objDbResult = $objQueryBuilder->Database->Query($strQuery);
         $arrResult = static::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNode, $objQueryBuilder->ColumnAliasArray);
         $objCache->SaveData(serialize($arrResult));
     } else {
         $arrResult = unserialize($cacheData);
     }
     return $arrResult;
 }
Esempio n. 6
0
 public static function Run($strClassName, $strNamespace = null)
 {
     QApplication::$EncodingType = 'UTF-8';
     $objWsdlCache = new QCache('soap', QApplication::$ScriptName, 'wsdl', QApplication::$ScriptFilename);
     $objDiscoCache = new QCache('soap', QApplication::$ScriptName, 'disco', QApplication::$ScriptFilename);
     $objClassWrapperCache = new QCache('soap', QApplication::$ScriptName, 'class.php', QApplication::$ScriptFilename);
     // Reflect through this QSoapService
     $strDisco = $objDiscoCache->GetData();
     if ($strDisco === false || !$strNamespace) {
         $objReflection = new ReflectionClass($strClassName);
     }
     // Figure Out Namespace
     if (!$strNamespace) {
         $objReflectionProperties = $objReflection->getStaticProperties();
         $strNamespace = $objReflectionProperties['DefaultNamespace'];
     }
     $strNamespace = trim($strNamespace);
     if (QString::LastCharacter($strNamespace) == '/') {
         $strNamespace = substr($strNamespace, 0, strlen($strNamespace) - 1);
     }
     // Check for Cached Disco
     if ($strDisco === false) {
         // Instantiate Service and Setup new Soap Methods
         $objService = new $strClassName($strClassName, $strNamespace);
         // Setup SOAP Methods
         try {
             $objService->SetupSoapMethods($objReflection);
         } catch (QCallerException $objExc) {
             $objExc->IncrementOffset();
             throw $objExc;
         }
         // Get Disco, Wsdl and Wrapper, and cache them!
         $objWsdlCache->SaveData($objService->GetWsdl());
         $objDiscoCache->SaveData($objService->GetDisco());
         $objClassWrapperCache->SaveData($objService->GetClassWrapper());
     }
     // Process Service Browse (e.g. if accessed via GET)
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         if (array_key_exists('QUERY_STRING', $_SERVER)) {
             switch (strtolower($_SERVER['QUERY_STRING'])) {
                 case 'disco':
                     header('Content-Type: text/xml');
                     _p('<?xml version="1.0" encoding="' . QApplication::$EncodingType . '"?>', false);
                     _p($objDiscoCache->GetData(), false);
                     return;
                 case 'wsdl':
                     header('Content-Type: text/xml');
                     _p('<?xml version="1.0" encoding="' . QApplication::$EncodingType . '"?>', false);
                     _p($objWsdlCache->GetData(), false);
                     return;
             }
         }
         printf('<link rel="alternate" type="text/xml" href="%s?disco"/><a href="%s?disco">Web Service Discovery File</a> &nbsp;|&nbsp; <a href="%s?wsdl">Web Service Description File (WSDL)</a>', QApplication::$ScriptName, QApplication::$ScriptName, QApplication::$ScriptName);
         return;
     }
     // Process Service Execution (e.g. accessed via a POST)
     $objService = new $strClassName($strClassName, $strNamespace);
     // Get the Request
     $strRequest = file_get_contents("php://input");
     // Create the Service Class Wrapper
     require $objClassWrapperCache->GetFilePath();
     // Use PHP 5.1+'s SoapServer class to handle the actual work
     $objService->objSoapServer = new SoapServer($objWsdlCache->GetFilePath());
     $objService->objSoapServer->setClass($strClassName . 'Wrapper', $strClassName, $strNamespace);
     $objService->objSoapServer->handle($strRequest);
 }
Esempio n. 7
0
 public function SaveData($mixData)
 {
     $mixResult = parent::SaveData(serialize($mixData));
     NarroUtils::RecursiveChmod(__CACHE__);
     return $mixResult;
 }
Esempio n. 8
0
        if (count($this->strCheckFilesArray)) {
            file_put_contents($this->GetFilePath() . '.hash', $this->GetCheckFilesHash());
        }
    }
    public function GetFilePath()
    {
        return sprintf('%s/%s/%s.%s', QCache::$CachePath, $this->strNamespace, $this->strKey, $this->strExtension);
    }
    protected function GetCheckFilesHash()
    {
        $intFoundFileCount = 0;
        $strData = '';
        foreach ($this->strCheckFilesArray as $strCheckFile) {
            if (file_exists($strCheckFile)) {
                $intFoundFileCount++;
                $strData .= filemtime($strCheckFile);
            }
        }
        if ($intFoundFileCount == 0) {
            return false;
        } else {
            return $intFoundFileCount . '_' . $strData;
        }
    }
    protected function GetCacheDirectory()
    {
        return sprintf('%s/%s', QCache::$CachePath, $this->strNamespace);
    }
}
QCache::$CachePath = __QCODO__ . '/cache';