Example #1
0
 function handleTranslationStatusChanged(stdClass $event)
 {
     if (!$this->changedTranslationMemories) {
         require_once 'inc/BackgroundProcess/UpdateChangedPages.php';
         register_shutdown_function(array($this, 'updateChangedPages'));
     }
     $tmid = $event->translationMemory->getRecord()->val('translation_memory_id');
     if (!isset($this->changedTranslationMemories[$tmid])) {
         if (class_exists('LiveCache')) {
             LiveCache::touchTranslationMemory($tmid);
         }
     }
     $this->changedTranslationMemories[$tmid][] = $event->translationRecord->val('string_id');
 }
Example #2
0
 function beforeSave($record)
 {
     if ($record->valueChanged('active')) {
         // The active flag has changed so we need to update the effective active
         // flag of this page and all its children
         $this->pouch['update_active'] = 1;
     }
     if ($record->valueChanged('locked')) {
         // The active flag has changed so we need to update the effective active
         // flag of this page and all its children
         $this->pouch['update_locked'] = 1;
     }
     if ($record->valueChanged('translation_memory_id')) {
         // The active flag has changed so we need to update the effective active
         // flag of this page and all its children
         $this->pouch['update_translation_memory_id'] = 1;
     }
     if ($record->valueChanged('auto_approve')) {
         // The active flag has changed so we need to update the effective active
         // flag of this page and all its children
         $this->pouch['update_auto_approve'] = 1;
     }
     if (class_exists('LiveCache')) {
         LiveCache::touchSite($record->val('website_id'));
     }
 }
Example #3
0
            foreach($_SERVER as $key=>$value) { 
                if (substr($key,0,5)=="HTTP_") { 
                    $key=str_replace(" ","-",ucwords(strtolower(str_replace("_"," ",substr($key,5))))); 
                    $out[$key]=$value; 
                } 
            } 
            return $out; 
        } 
    ');
}
require_once 'inc/LiveCache.php';
if (@$_GET['-action'] == 'swete_handle_request') {
    define('XATAFACE_NO_SESSION', 1);
    define('XATAFACE_DISABLE_AUTH', 1);
    error_log('[SWeTE Profiler][' . getmypid() . '] start time: ' . microtime());
    $liveCache = LiveCache::getCurrentPage();
    if (defined('SWETE_USE_HTML5_PARSER') and SWETE_USE_HTML5_PARSER) {
        $liveCache->useHtml5Parser = true;
    }
    if (defined('SWETE_USE_CONSERVATIVE_CACHING') and SWETE_USE_CONSERVATIVE_CACHING === 0) {
        $liveCache->useConservativeCaching = false;
    }
    if (intval(@$_SERVER['REDIRECT_NOSERVERCACHE']) === 1) {
        $liveCache->noServerCache = true;
    }
    if (defined('SWETE_DEFAULT_CACHE_TTL')) {
        $liveCache->defaultCacheTTL = SWETE_DEFAULT_CACHE_TTL;
    }
    if (strtolower(@$_SERVER['REQUEST_METHOD']) == 'get') {
        try {
            $liveCache->handleRequest();
Example #4
0
 function beforeSave($record)
 {
     //if base_path doesn't start with // then add it on
     $base_path = $record->val('base_path');
     $changedBasePath = false;
     if (strpos($base_path, '//') !== false) {
         $base_path = preg_replace('#//#', '/', $base_path);
         $changedBasePath = true;
     }
     if (substr($base_path, 0, 1) !== '/') {
         $base_path = '/' . $base_path;
         $changedBasePath = true;
     }
     if (!preg_match('/\\/$/', $base_path)) {
         $base_path .= '/';
         $changedBasePath = true;
     }
     if ($changedBasePath) {
         $record->setValue('base_path', $base_path);
     }
     if (class_exists('LiveCache')) {
         LiveCache::touchSite($record->val('website_id'));
     }
 }
Example #5
0
 function handle($params)
 {
     global $ORIG_POST, $ORIG_REQUEST, $ORIG_GET;
     $_GET = $ORIG_GET;
     $_POST = $ORIG_POST;
     $_REQUEST = $ORIG_REQUEST;
     @session_write_close();
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     //print_r($_SERVER);
     $url = implode('/', array_map('rawurlencode', explode('/', $_SERVER['REDIRECT_URL'])));
     $url = str_replace("%3A", ":", $url);
     if (isset($_SERVER['REQUEST_URI'])) {
         if (strpos($_SERVER['REQUEST_URI'], '?') !== false) {
             list($junk, $_SERVER['REDIRECT_QUERY_STRING']) = explode('?', $_SERVER['REQUEST_URI']);
         } else {
             $_SERVER['REDIRECT_QUERY_STRING'] = '';
         }
     }
     $sweteDirectives = array();
     if (@$_SERVER['REDIRECT_QUERY_STRING']) {
         $qstr = $_SERVER['REDIRECT_QUERY_STRING'];
         $parts = explode('&', $qstr);
         $qstrout = array();
         foreach ($parts as $pt) {
             if (preg_match('/^swete\\:/', $pt)) {
                 list($d1, $d2) = explode('=', $pt);
                 $sweteDirectives[urldecode($d1)] = urldecode($d2);
             } else {
                 $qstrout[] = $pt;
             }
         }
         $url .= '?' . implode('&', $qstrout);
     }
     $url = df_absolute_url($url);
     //echo "The URL: ".$url;
     //echo "$url";exit;
     $site = SweteSite::loadSiteByUrl($url);
     if (!$site and $url and $url[strlen($url) - 1] != '/') {
         $url .= '/';
         $site = SweteSite::loadSiteByUrl($url);
         if ($site) {
             header('Location: ' . $url);
             exit;
         }
     }
     if (!$site) {
         die("[ERROR] No site found");
     }
     $server = new ProxyServer();
     if (defined('SWETE_USE_HTML5_PARSER') and SWETE_USE_HTML5_PARSER) {
         $server->useHtml5Parser = true;
     }
     if (@$_POST['swete:input']) {
         if (@$_POST['swete:key'] and @$_POST['swete:salt']) {
             if (is_numeric($_POST['swete:salt'])) {
                 $salt = intval($_POST['swete:salt']);
                 if (abs($salt - time()) < 3600) {
                     $password = $site->getRecord()->val('webservice_secret_key');
                     if ($password) {
                         $key = sha1($_POST['swete:salt'] . $password);
                         //if ( $key === $_POST['swete:key'] ){
                         if (strcasecmp($key, $_POST['swete:key']) === 0) {
                             $server->inputContent = $_POST['swete:input'];
                             if (@$_POST['swete:content-type']) {
                                 $server->inputContentType = $_POST['swete:content-type'];
                             }
                         } else {
                             die("[ERROR] Incorrect Key");
                         }
                     } else {
                         die("[ERROR] No secret key set in the website settings.");
                     }
                 } else {
                     die("[ERROR] Invalid salt value");
                 }
             } else {
                 die("[ERROR] Invalid salt value.  Salt must be an integer");
             }
         } else {
             die("[ERROR] Both swete:key and swete:salt must be provided");
         }
     }
     //$server->buffer = true;
     $server->logTranslationMisses = true;
     $server->site = $site;
     if ($site->getRecord()->val('log_requests')) {
         if (isset($server->logger)) {
             $server->logger->requestLoggingEnabled = true;
         }
     } else {
         if (isset($server->logger)) {
             $server->logger->requestLoggingEnabled = false;
         }
     }
     if ($site->getRecord()->val('log_translation_misses')) {
         $server->logTranslationMisses = true;
         if (isset($server->logger)) {
             // If we are logging translation misses we also need to log requests
             $server->logger->requestLoggingEnabled = true;
         }
     } else {
         $server->logTranslationMisses = false;
     }
     $server->URL = $url;
     // Deal with live cache
     // The first time a page is requested, it won't yet have a livecache
     // descriptor, so we needed to wait until we had loaded the
     // site so we can calculate the unproxified url.
     // Then we will try to flush it again.
     $isPost = strtolower($server->SERVER['REQUEST_METHOD']) === 'post';
     if (class_exists('LiveCache')) {
         $server->liveCache = LiveCache::getCurrentPage();
         if (!$isPost and !isset($server->liveCache->unproxifiedUrl)) {
             $server->liveCache->unproxifiedUrl = $server->site->getProxyWriter()->unproxifyUrl($server->URL);
             $server->liveCache->logger = $server->logger;
             $server->liveCache->flush();
         }
     }
     //
     $server->handleRequest();
     //print_r($server->headerBuffer);
     //$site = SweteSite::loadSiteByUrl(
 }