Beispiel #1
0
 /**
  * @private
  * See http://www.php.net/manual/en/function.strip-tags.php#93567
  */
 private static function array_strip_tags(&$params)
 {
     $tags = cfg_getd('requestparam', 'tagstostrip', false);
     if (!$tags) {
         return;
     }
     $size = sizeof($tags);
     $keys = array_keys($tags);
     $paramsize = sizeof($params);
     $paramkeys = array_keys($params);
     for ($j = 0; $j < $paramsize; $j++) {
         for ($i = 0; $i < $size; $i++) {
             $tag = $tags[$keys[$i]];
             if (is_string($params[$paramkeys[$j]])) {
                 if (stripos($params[$paramkeys[$j]], $tag) !== false) {
                     $params[$paramkeys[$j]] = preg_replace('#</?' . $tag . '[^>]*>#is', '', $params[$paramkeys[$j]]);
                 }
             } elseif (is_array($params[$paramkeys[$j]])) {
                 Args::array_strip_tags($params[$paramkeys[$j]]);
             }
         }
     }
 }
Beispiel #2
0
/**
 * @internal Used to add some new/unknown strings to the translation system
 */
function translation_add_unknown_strings($unknown_constants)
{
    global $CONFIG;
    if ($CONFIG['translation']['sync']['datasource']) {
        $ds = model_datasource($CONFIG['translation']['sync']['datasource']);
        $ds->ExecuteSql("CREATE TABLE IF NOT EXISTS wdf_unknown_strings (\n\t\t\tterm VARCHAR(150) NOT NULL,\n\t\t\tlast_hit DATETIME NOT NULL,\n\t\t\thits INT DEFAULT 0,\n\t\t\tdefault_val TEXT,\n\t\t\tPRIMARY KEY (term))");
        $now = $ds->Driver->Now();
        $sql1 = "INSERT OR IGNORE INTO wdf_unknown_strings(term,last_hit,hits,default_val)VALUES(?,{$now},0,?);";
        $sql2 = "UPDATE wdf_unknown_strings SET last_hit={$now}, hits=hits+1 WHERE term=?;";
        foreach ($unknown_constants as $uc) {
            $def = cfg_getd('translation', 'default_strings', $uc, '');
            $ds->Execute($sql1, array($uc, $def));
            $ds->Execute($sql2, $uc);
        }
    } else {
        log_debug("Unknown text constants: " . render_var(array_values($unknown_constants)));
    }
}
Beispiel #3
0
function register_less_variable($name, $value)
{
    global $CONFIG;
    $vars = cfg_getd('resources_less_variables', array());
    $vars[$name] = $value;
    cfg_set('resources_less_variables', $vars);
}
 /**
  * @override
  */
 function WdfRenderAsRoot()
 {
     execute_hooks(HOOK_PRE_RENDER, array($this));
     $init_data = $this->wdf_settings;
     $init_data['request_id'] = request_id();
     $init_data['site_root'] = cfg_get('system', 'url_root');
     if (cfg_getd('system', 'attach_session_to_ajax', false)) {
         $init_data['session_id'] = session_id();
         $init_data['session_name'] = session_name();
     }
     if (isDevOrBeta()) {
         $init_data['log_to_console'] = true;
     }
     if ($GLOBALS['CONFIG']['system']['ajax_debug_argument']) {
         $init_data['log_to_server'] = $GLOBALS['CONFIG']['system']['ajax_debug_argument'];
     }
     $this->set("wdf_init", "wdf.init(" . json_encode($init_data) . ");");
     $this->set("docready", $this->docready);
     $this->set("plaindocready", $this->plaindocready);
     return parent::WdfRenderAsRoot();
 }
 /**
  * @internal Compiles a LESS file to CSS and delivers that to the browser
  * @attribute[RequestParam('file','string')]
  */
 function CompileLess($file)
 {
     $vars = cfg_getd('resources_less_variables', array());
     $file_key = md5($file . serialize($vars));
     $less = resFile(basename($file), true);
     $css = sys_get_temp_dir() . '/' . $file_key . '.css';
     $cacheFile = sys_get_temp_dir() . '/' . $file_key . '.cache';
     header('Content-Type: text/css');
     if (file_exists($css) && file_exists($cacheFile)) {
         $cache = unserialize(file_get_contents($cacheFile));
     } else {
         $cache = $less;
     }
     require_once __DIR__ . '/lessphp/lessc.inc.php';
     $compiler = new \lessc();
     $compiler->setVariables($vars);
     $newCache = $compiler->cachedCompile($cache);
     if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
         file_put_contents($cacheFile, serialize($newCache));
         file_put_contents($css, $newCache['compiled']);
     }
     WdfResource::ValidatedCacheResponse($less);
     readfile($css);
     die;
 }