public function indexAction()
 {
     $ok = false;
     foreach (Kwf_Config::getValueArray('debug.benchmarkCounterAccessIp') as $i) {
         if (substr($i, -1) == '*') {
             $i = substr($i, 0, -1);
             if (substr($_SERVER['REMOTE_ADDR'], 0, strlen($i)) == $i) {
                 $ok = true;
             }
         } else {
             if ($_SERVER['REMOTE_ADDR'] == $i) {
                 $ok = true;
             }
         }
     }
     if (!$ok) {
         throw new Kwf_Exception_AccessDenied();
     }
     $names = array('content-requests', 'asset-requests', 'media-requests', 'admin-requests', 'fullpage-hit', 'fullpage-miss', 'dbqueries', 'render-hit', 'render-miss', 'render-noviewcache', 'viewcache-mem', 'viewcache-db', 'viewcache-miss', 'viewcache-delete-page', 'viewcache-delete-component', 'viewcache-delete-master', 'viewcache-delete-partial', 'viewcache-delete-componentLink', 'viewcache-delete-fullPage');
     $out = array();
     $load = @file_get_contents('/proc/loadavg');
     $load = explode(' ', $load);
     $out['load'] = (double) $load[0];
     foreach ($names as $name) {
         $out[$name] = Kwf_Benchmark_Counter::getInstance()->getValue($name);
     }
     echo json_encode($out);
     exit;
 }
Пример #2
0
 public function __construct(array $config = null)
 {
     if (is_null($config)) {
         $config = Kwf_Config::getValueArray('database');
     }
     $this->_config = $config;
 }
Пример #3
0
 public function getContent($includeMaster)
 {
     if ($this->_data->getBaseProperty('preLogin')) {
         $ignore = false;
         foreach (Kwf_Config::getValueArray('preLoginIgnoreIp') as $i) {
             $ip = $_SERVER['REMOTE_ADDR'];
             if ($ip == $i) {
                 $ignore = true;
             }
             if (!$ignore && substr($i, -1) == '*') {
                 $i = substr($i, 0, -1);
                 if (substr($ip, 0, strlen($i)) == $i) {
                     $ignore = true;
                 }
             }
             if (!$ignore && substr($i, 0, 1) == '*') {
                 $i = substr($i, 1);
                 if (substr($ip, -strlen($i)) == $i) {
                     $ignore = true;
                 }
             }
         }
         Kwf_Setup::checkPreLogin($this->_data->getBaseProperty('preLoginUser'), $this->_data->getBaseProperty('preLoginPassword'));
     }
     $benchmarkEnabled = Kwf_Benchmark::isEnabled();
     if ($benchmarkEnabled) {
         $startTime = microtime(true);
     }
     $process = $this->_getProcessInputComponents($includeMaster);
     if ($benchmarkEnabled) {
         Kwf_Benchmark::subCheckpoint('getProcessInputComponents', microtime(true) - $startTime);
     }
     self::_callProcessInput($process);
     if ($benchmarkEnabled) {
         Kwf_Benchmark::checkpoint('processInput');
     }
     $ret = array();
     $hasDynamicParts = false;
     $ret['content'] = $this->_render($includeMaster, $hasDynamicParts);
     if ($benchmarkEnabled) {
         Kwf_Benchmark::checkpoint('render');
     }
     $ret['mimeType'] = 'text/html; charset=utf-8';
     if (!$includeMaster) {
         $assetsBox = $this->_data->getChildComponent('-assets');
         if ($assetsBox) {
             $ret['assets'] = $assetsBox->render(null, false, $hasDynamicParts);
         } else {
             $ret['assets'] = '';
         }
     }
     if (!$hasDynamicParts) {
         $ret['lifetime'] = 60 * 60;
     }
     self::_callPostProcessInput($process);
     if ($benchmarkEnabled) {
         Kwf_Benchmark::checkpoint('postProcessInput');
     }
     return $ret;
 }
Пример #4
0
 public static function createPackages()
 {
     $packages = array(self::getInstance('Frontend'), self::getInstance('Admin'));
     foreach (Kwf_Config::getValueArray('assets.packages') as $i) {
         $packages[] = self::getInstance($i);
     }
     return $packages;
 }
 public function __construct($config = array())
 {
     if (isset($config['pageCategories'])) {
         $this->_pageCategories = $config['pageCategories'];
     } else {
         $this->_pageCategories = Kwf_Config::getValueArray('kwc.pageCategories');
     }
     parent::__construct($config);
 }
Пример #6
0
 public static function getMetaTagsForData($data)
 {
     $ret = array();
     if (Kwf_Config::getValue('application.kwf.name') == 'Koala Framework') {
         $ret['generator'] = 'Koala Web Framework CMS';
     }
     if ($data->getPage()) {
         if (Kwc_Abstract::getFlag($data->getPage()->componentClass, 'metaTags')) {
             foreach ($data->getPage()->getComponent()->getMetaTags() as $name => $content) {
                 if (!isset($ret[$name])) {
                     $ret[$name] = '';
                 }
                 //TODO: for eg noindex,nofollow other separator
                 $ret[$name] .= ' ' . $content;
             }
         }
         if (Kwc_Abstract::getFlag($data->getPage()->componentClass, 'noIndex')) {
             if (isset($ret['robots'])) {
                 $ret['robots'] .= ',';
             } else {
                 $ret['robots'] = '';
             }
             $ret['robots'] .= 'noindex';
         }
     }
     foreach ($ret as &$i) {
         $i = trim($i);
     }
     unset($i);
     // verify-v1
     if (isset($_SERVER['HTTP_HOST'])) {
         $host = $_SERVER['HTTP_HOST'];
     } else {
         $host = Kwf_Config::getValue('server.domain');
     }
     $hostParts = explode('.', $host);
     if (count($hostParts) < 2) {
         $configDomain = $host;
     } else {
         $shortParts = array('com', 'co', 'gv', 'or');
         if (count($hostParts) > 2 & in_array($hostParts[count($hostParts) - 2], $shortParts)) {
             $hostParts[count($hostParts) - 2] = $hostParts[count($hostParts) - 3] . $hostParts[count($hostParts) - 2];
         }
         $configDomain = $hostParts[count($hostParts) - 2] . $hostParts[count($hostParts) - 1];
         // zB 'com'
     }
     $configVerify = Kwf_Config::getValueArray('verifyV1');
     if ($configVerify && isset($configVerify[$configDomain])) {
         $ret['verify-v1'] = $configVerify[$configDomain];
     }
     $configVerify = Kwf_Config::getValueArray('googleSiteVerification');
     if ($configVerify && isset($configVerify[$configDomain])) {
         $ret['google-site-verification'] = $configVerify[$configDomain];
     }
     return $ret;
 }
Пример #7
0
 /**
  * Returns if the current request would support https and ensureHttps() would redirect to https
  */
 public static function domainSupportsHttps($domain)
 {
     if (Kwf_Config::getValue('server.https')) {
         if ($domains = Kwf_Config::getValueArray('server.httpsDomains')) {
             if ($domains && !in_array($domain, $domains)) {
                 return false;
                 //current host is not in server.httpsDomains, don't use https
             }
         }
         return true;
     }
     return false;
 }
Пример #8
0
 public static function getGroups()
 {
     $groups = Kwf_Config::getValueArray('server.gearmanGroup');
     $ret = array_keys($groups);
     $noGroup = Kwf_Config::getValueArray('server.gearman');
     if ($noGroup && $noGroup['jobServers']) {
         $servers = array_values($noGroup['jobServers']);
         if ($servers[0]) {
             $ret[] = null;
             //no group
         }
     }
     return $ret;
 }
Пример #9
0
 private function _getAllPackages()
 {
     $packages = array();
     foreach (Kwf_Config::getValueArray('assets.packageFactories') as $i) {
         if (!$i) {
             continue;
         }
         if (!is_instance_of($i, 'Kwf_Assets_Package_FactoryInterface')) {
             throw new Kwf_Exception("'{$i}' doesn't implement Kwf_Assets_Package_FactoryInterface");
         }
         $packages = array_merge($packages, call_user_func(array($i, 'createPackages')));
     }
     return $packages;
 }
Пример #10
0
 public static function getAvailableLanguages($componentClass)
 {
     $ret = array();
     foreach (Kwf_Config::getValueArray('kwc.domains') as $d) {
         if (isset($d['language'])) {
             if (is_array($d['language'])) {
                 $ret = array_merge($ret, $d['language']);
             } else {
                 $ret[] = $d['language'];
             }
         }
     }
     $ret = array_unique($ret);
     return $ret;
 }
Пример #11
0
 public static function getAssetVariables($section = 'web')
 {
     static $assetVariables = array();
     if (!isset($assetVariables[$section])) {
         $assetVariables[$section] = Kwf_Config::getValueArray('assetVariables');
         if (file_exists('assetVariables.ini')) {
             $cfg = new Zend_Config_Ini('assetVariables.ini', $section);
             $assetVariables[$section] = array_merge($assetVariables[$section], $cfg->toArray());
         }
         foreach ($assetVariables[$section] as $k => $i) {
             //also support lowercase variables
             if (strtolower($k) != $k) {
                 $assetVariables[$section][strtolower($k)] = $i;
             }
         }
     }
     return $assetVariables[$section];
 }
Пример #12
0
 public static function allowSourceAccess()
 {
     $ok = false;
     foreach (Kwf_Config::getValueArray('debug.assets.sourceAccessIp') as $i) {
         if (!$i) {
             continue;
         }
         if (substr($i, -1) == '*') {
             $i = substr($i, 0, -1);
             if (substr($_SERVER['REMOTE_ADDR'], 0, strlen($i)) == $i) {
                 $ok = true;
             }
         } else {
             if ($_SERVER['REMOTE_ADDR'] == $i) {
                 $ok = true;
             }
         }
     }
     return $ok;
 }
Пример #13
0
 /**
  * Returns if the current request would support https and ensureHttps() would redirect to https
  */
 public static function domainSupportsHttps($domain)
 {
     if (Kwf_Config::getValue('server.https') === true) {
         if ($domains = Kwf_Config::getValueArray('server.httpsDomains')) {
             if ($domains && !in_array($domain, $domains)) {
                 foreach ($domains as $d) {
                     if (substr($d, 0, 2) == '*.') {
                         if (substr($d, 1) == substr($domain, strpos($domain, '.'))) {
                             return true;
                         }
                     }
                 }
                 return false;
                 //current host is not in server.httpsDomains, don't use https
             }
         }
         return true;
     }
     return false;
 }
Пример #14
0
 public function getSubroots()
 {
     $ret = Kwf_Config::getValueArray('fulltext.solr.subroots');
     if ($ret) {
         return $ret;
     }
     $ret = array();
     foreach (Kwc_Abstract::getComponentClasses() as $c) {
         if (Kwc_Abstract::getFlag($c, 'subroot')) {
             foreach (Kwf_Component_Data_Root::getInstance()->getComponentsByClass($c) as $sr) {
                 $ret[] = $sr->componentId;
             }
         }
     }
     if (!$ret) {
         $ret = array('');
     }
     //no subroots exist
     return $ret;
 }
 public function getContentsPacked()
 {
     if (!Kwf_Config::getValue('googleMapsApiKey') && !Kwf_Config::getValueArray('googleMapsApiKeys')) {
         throw new Kwf_Exception('googleMapsApiKey is required in config.ini');
     }
     if (Kwf_Config::getValue('googleMapsApiKey')) {
         $json = Kwf_Config::getValue('googleMapsApiKey');
         if (Kwf_Config::getValueArray('googleMapsApiKeys')) {
             throw new Kwf_Exception('Don\'t use googleMapsApiKeys and googleMapsApiKey together, remove googleMapsApiKeys');
         }
     } else {
         //legacy
         $json = Kwf_Config::getValueArray('googleMapsApiKeys');
     }
     $json = json_encode($json);
     $ret = "module.exports = {$json};";
     $ret = Kwf_SourceMaps_SourceMap::createEmptyMap($ret);
     $data = $ret->getMapContentsData();
     $data->{'_x_org_koala-framework_masterFiles'} = array('config.ini');
     return $ret;
 }
Пример #16
0
 public static function dispatch()
 {
     if (!isset($_SERVER['REDIRECT_URL'])) {
         return;
     }
     if (substr($_SERVER['REDIRECT_URL'], 0, 9) != '/kwf/pma/' && $_SERVER['REDIRECT_URL'] != '/kwf/pma') {
         return;
     }
     global $dbh, $last_sth, $last_sql, $reccount, $out_message, $SQLq, $SHOW_T;
     global $DB, $sqldr, $is_sht, $xurl;
     global $err_msg, $VERSION, $self;
     global $DBDEF;
     global $D, $BOM, $ex_isgz;
     global $ex_gz, $ex_tmpf;
     global $ex_gz, $ex_tmpf;
     global $LFILE, $insql_done;
     global $MAX_ROWS_PER_PAGE, $page, $is_limited_sql;
     $_SERVER['PHP_SELF'] = '/kwf/pma/';
     $config = Kwf_Registry::get('config');
     if (!$config->pma->enable) {
         throw new Kwf_Exception_NotFound();
     }
     if (!in_array($_SERVER['REMOTE_ADDR'], Kwf_Config::getValueArray('pma.restrictToIp'))) {
         throw new Kwf_Exception_AccessDenied();
     }
     $config = Kwf_Registry::get('dao')->getDbConfig();
     $DBDEF = array('user' => $config['username'], 'pwd' => $config['password'], 'db' => $config['dbname'], 'host' => $config['host'], 'port' => "", 'chset' => "utf8");
     $db = Kwf_Registry::get('db');
     $userModel = Kwf_Registry::get('userModel');
     $role = $userModel->getAuthedUserRole();
     if ($role != 'admin') {
         throw new Kwf_Exception_AccessDenied();
     }
     session_write_close();
     restore_error_handler();
     restore_exception_handler();
     include Kwf_Config::getValue('libraryPath') . '/phpminiadmin/1.8.120510/phpminiadmin.php';
     exit;
 }
Пример #17
0
 public function debugData()
 {
     $ret = '';
     $config = Kwf_Config::getValueArray('debug');
     if ($config['benchmark'] || $config['menu'] || !$config['error']['log'] || Kwf_Component_Data_Root::getInstance() && Kwf_Component_Data_Root::getInstance()->filename) {
         $indent = str_repeat(' ', 8);
         $ret .= "<script type=\"text/javascript\">\n";
         $kwf = 'Kwf';
         if ($uniquePrefix = Kwf_Config::getValue('application.uniquePrefix')) {
             $ret .= $indent . "if (typeof {$uniquePrefix} == 'undefined') {$uniquePrefix} = {};\n";
             $kwf = $uniquePrefix . '.' . $kwf;
         }
         $ret .= $indent . "if (typeof {$kwf} == 'undefined') {$kwf} = {};\n";
         $ret .= $indent . "{$kwf}.Debug = {};\n";
         $ret .= $indent . "{$kwf}.Debug.displayErrors = " . (!$config['error']['log'] ? 'true' : 'false') . ";\n";
         $ret .= $indent . "{$kwf}.Debug.benchmark = " . ($config['benchmark'] ? 'true' : 'false') . ";\n";
         if (Kwf_Component_Data_Root::getInstance() && Kwf_Component_Data_Root::getInstance()->filename) {
             $ret .= $indent . "{$kwf}.Debug.rootFilename = '/" . Kwf_Component_Data_Root::getInstance()->filename . "';\n";
         }
         $ret .= $indent . "</script>\n";
     }
     return $ret;
 }
Пример #18
0
 public function getSubroots()
 {
     $ret = Kwf_Config::getValueArray('fulltext.solr.subroots');
     if ($ret) {
         return $ret;
     }
     $ret = array();
     foreach (Kwc_Abstract::getComponentClasses() as $c) {
         if (Kwc_Abstract::getFlag($c, 'subroot')) {
             foreach (Kwf_Component_Data_Root::getInstance()->getComponentsBySameClass($c, array('ignoreVisible' => true)) as $sr) {
                 if (isset($sr->parent) && $sr->parent) {
                     //only keep highest level
                     unset($ret[$sr->parent->componentId]);
                 }
                 $ret[$sr->componentId] = $sr->componentId;
             }
         }
     }
     if (!$ret) {
         $ret = array('');
     }
     //no subroots exist
     return $ret;
 }
Пример #19
0
 public static function generateCode()
 {
     $preloadIncludePaths = array();
     $namespaces = (require VENDOR_PATH . '/composer/autoload_namespaces.php');
     $ret = array();
     foreach ($namespaces as $ns => $dirs) {
         $preloadIncludePaths = array_merge($preloadIncludePaths, $dirs);
     }
     $ret = "<?php\n";
     $ret .= "\$cwd = getcwd();\n";
     $preloadClasses = array('Kwf_Benchmark', 'Kwf_Loader', 'Kwf_Debug');
     $ret .= "if (!class_exists('Kwf_Loader', false)) {\n";
     $ret .= self::_generatePreloadClassesCode($preloadClasses, $preloadIncludePaths);
     $ret .= "}\n";
     $ret .= "Kwf_Benchmark::\$startTime = microtime(true);\n";
     $ret .= "\n";
     //override the default cache (/tmp) dir used by Zend_Cache_Backend to have the cache per web
     $ret .= "\$_SERVER['TMP'] = 'cache/zend';\n";
     //only replace configured value to avoid spoofing
     //required eg. behind load balancers
     if (Kwf_Config::getValueArray('server.replaceVars.remoteAddr')) {
         $a = Kwf_Config::getValueArray('server.replaceVars.remoteAddr');
         if (substr($a['if'], -2) == '.*') {
             $comparison = "substr(\$_SERVER['REMOTE_ADDR'], 0, " . (strlen($a['if']) - 1) . ") == '" . substr($a['if'], 0, -1) . "'";
         } else {
             $comparison = "\$_SERVER['REMOTE_ADDR'] == '{$a['if']}'";
         }
         $ret .= "\nif (isset(\$_SERVER['REMOTE_ADDR']) && {$comparison} && isset(\$_SERVER['{$a['replace']}'])) {\n";
         $ret .= "    \$_SERVER['REMOTE_ADDR'] = \$_SERVER['{$a['replace']}'];\n";
         if (isset($a['removeTrailing'])) {
             $ret .= "    if (substr(\$_SERVER['REMOTE_ADDR'], -" . strlen($a['removeTrailing']) . ") == '" . $a['removeTrailing'] . "') {\n";
             $ret .= "        \$_SERVER['REMOTE_ADDR'] = substr(\$_SERVER['REMOTE_ADDR'], 0, -" . strlen($a['removeTrailing']) . ");\n";
             $ret .= "    }\n";
         }
         $ret .= "}\n";
     }
     //try different values, if one spoofs this this is no security issue
     $ret .= "if (isset(\$_SERVER['HTTP_SSL_SESSION_ID'])) \$_SERVER['HTTPS'] = 'on';\n";
     $ret .= "if (isset(\$_SERVER['HTTP_SESSION_ID_TAG'])) \$_SERVER['HTTPS'] = 'on';\n";
     $ret .= "if (isset(\$_SERVER['HTTP_X_FORWARDED_PROTO']) && \$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {\n";
     $ret .= "    \$_SERVER['HTTPS'] = 'on';\n";
     $ret .= "}\n";
     if (VENDOR_PATH == '../vendor') {
         $kwfPath = '..';
     } else {
         $kwfPath = VENDOR_PATH . '/koala-framework/koala-framework';
     }
     $ret .= "if (!defined('KWF_PATH')) define('KWF_PATH', '{$kwfPath}');\n";
     $ret .= "if (!defined('VENDOR_PATH')) define('VENDOR_PATH', 'vendor');\n";
     $ip = array();
     foreach (include VENDOR_PATH . '/composer/include_paths.php' as $p) {
         if (VENDOR_PATH == '../vendor') {
             $cwd = getcwd();
             $cwd = substr($cwd, 0, strrpos($cwd, '/'));
             self::_verifyPathInParentPath($p, $cwd);
             $p = '../' . substr($p, strlen($cwd) + 1);
         } else {
             self::_verifyPathInParentPath($p, getcwd());
             $p = substr($p, strlen(getcwd()) + 1);
         }
         $ip[] = "'.\$cwd.'/" . $p;
     }
     $ip[] = '.';
     foreach (Kwf_Config::getValueArray('includepath') as $t => $p) {
         if ($p) {
             $ip[] = $p;
         }
     }
     $ip = array_unique($ip);
     $ret .= "Kwf_Loader::setIncludePath('" . implode(PATH_SEPARATOR, $ip) . "');\n";
     $ret .= "\n";
     $ret .= "\n";
     $ret .= "error_reporting(E_ALL & ~E_STRICT);\n";
     $ret .= "set_error_handler(array('Kwf_Debug', 'handleError'), E_ALL & ~E_STRICT);\n";
     $ret .= "set_exception_handler(array('Kwf_Debug', 'handleException'));\n";
     $ret .= "\n";
     $ret .= "\$requestUri = isset(\$_SERVER['REQUEST_URI']) ? \$_SERVER['REQUEST_URI'] : null;\n";
     if (Kwf_Setup::getBaseUrl()) {
         $ret .= "if (\$requestUri !== null) {\n";
         $ret .= "    if (substr(\$requestUri, 0, " . strlen(Kwf_Setup::getBaseUrl()) . ") != '" . Kwf_Setup::getBaseUrl() . "') {\n";
         $ret .= "        echo 'Invalid baseUrl, expected \\'" . Kwf_Setup::getBaseUrl() . "\\'';\n";
         $ret .= "        exit;\n";
         $ret .= "    }\n";
         $ret .= "    \$requestUri = substr(\$requestUri, " . strlen(Kwf_Setup::getBaseUrl()) . ");\n";
         $ret .= "}\n";
     }
     $ret .= "\n";
     if (Kwf_Config::getValue('debug.benchmark') || Kwf_Config::getValue('debug.benchmarklog')) {
         //vor registerAutoload aufrufen damit wir dort benchmarken können
         $ret .= "Kwf_Benchmark::enable();\n";
     } else {
         $ret .= "if (isset(\$_REQUEST['KWF_BENCHMARK'])) {\n";
         foreach (Kwf_Config::getValueArray('debug.benchmarkActivatorIp') as $activatorIp) {
             $ret .= "    if (\$_SERVER['REMOTE_ADDR'] == '{$activatorIp}') Kwf_Benchmark::enable();\n";
         }
         $ret .= "}\n";
     }
     $ret .= "Kwf_Loader::registerAutoload();\n";
     $ret .= "\n";
     $ret .= "//here to be as fast as possible (and have no session)\n";
     $ret .= "if (\$requestUri == '/kwf/json-progress-status'\n";
     $ret .= ") {\n";
     $ret .= "    Kwf_Util_ProgressBar_DispatchStatus::dispatch();\n";
     $ret .= "}\n";
     $ret .= "\n";
     $ret .= "//here to have less dependencies\n";
     $ret .= "if (\$requestUri == '/kwf/check-config'\n";
     $ret .= ") {\n";
     $ret .= "    Kwf_Util_Check_Config::dispatch();\n";
     $ret .= "}\n";
     $ret .= "if (PHP_SAPI == 'cli' && isset(\$_SERVER['argv'][1]) && \$_SERVER['argv'][1] == 'check-config') {\n";
     $ret .= "    Kwf_Util_Check_Config::dispatch();\n";
     $ret .= "}\n";
     $ret .= "\$ml = ini_get('memory_limit');\n";
     $ret .= "if (strtoupper(substr(\$ml, -1)) == 'M') {\n";
     $ret .= "    if ((int)substr(\$ml, 0, -1) < 128) {\n";
     $ret .= "        ini_set('memory_limit', '128M');\n";
     $ret .= "    }\n";
     $ret .= "}\n";
     if (Kwf_Config::getValue('debug.error.log')) {
         $ret .= "ini_set('display_errors', false);\n";
     }
     if (function_exists('mb_internal_encoding')) {
         $ret .= "mb_internal_encoding('UTF-8');\n";
     }
     if (PHP_VERSION_ID < 50600) {
         if (function_exists('iconv_set_encoding')) {
             $ret .= "iconv_set_encoding('internal_encoding', 'utf-8');\n";
         }
     } else {
         $ret .= "ini_set('default_charset', 'UTF-8');\n";
     }
     $ret .= "umask(000); //nicht 002 weil wwwrun und kwcms in unterschiedlichen gruppen\n";
     //this is *NOT* recommended but still works somehow
     $ret .= "if (get_magic_quotes_gpc()) Kwf_Util_UndoMagicQuotes::undoMagicQuotes();\n";
     if (Kwf_Config::getValue('debug.firephp') || Kwf_Config::getValue('debug.querylog')) {
         $ret .= "if (PHP_SAPI != 'cli') {\n";
         if (Kwf_Config::getValue('debug.firephp')) {
             $ret .= "    require_once '" . Kwf_Config::getValue('externLibraryPath.firephp') . "/FirePHPCore/FirePHP.class.php';\n";
             $ret .= "    FirePHP::init();\n";
             $ret .= "    ob_start();\n";
         }
         $ret .= "}\n";
     }
     $ret .= "register_shutdown_function(array('Kwf_Setup', 'shutDown'));\n";
     $ret .= "if (!class_exists('Kwf_Config', false)) {\n";
     $preloadClasses = array('Kwf_Config', 'Kwf_Cache_Simple', 'Kwf_Cache_SimpleStatic');
     $ret .= self::_generatePreloadClassesCode($preloadClasses, $preloadIncludePaths);
     $ret .= "    if (substr(\$requestUri, 0, 8) != '/assets/') {\n";
     $preloadClasses = array();
     $preloadClasses[] = 'Zend_Registry';
     $preloadClasses[] = 'Kwf_Registry';
     $preloadClasses[] = 'Kwf_Trl';
     $preloadClasses[] = 'Kwf_Util_SessionHandler';
     $preloadClasses[] = 'Kwf_Util_Memcache';
     $preloadClasses[] = 'Zend_Session';
     $preloadClasses[] = 'Kwf_Benchmark_Counter';
     $preloadClasses[] = 'Kwf_Benchmark_Counter_Apc';
     if (Kwf_Component_Data_Root::getComponentClass()) {
         //only load component related classes if it is a component web
         $preloadClasses[] = 'Kwf_Component_Data';
         $preloadClasses[] = 'Kwf_Component_Data_Root';
         $preloadClasses[] = 'Kwf_Component_Settings';
         $preloadClasses[] = 'Kwf_Component_Renderer_Abstract';
         $preloadClasses[] = 'Kwf_Component_Renderer';
         $preloadClasses[] = 'Kwf_Component_Cache';
         $preloadClasses[] = 'Kwf_Component_Cache_Mysql';
         $preloadClasses[] = 'Kwf_Component_Cache_Memory';
         $preloadClasses[] = 'Kwf_Component_Abstract_ContentSender_Abstract';
         $preloadClasses[] = 'Kwf_Component_Abstract_ContentSender_Default';
     }
     $ret .= self::_generatePreloadClassesCode($preloadClasses, $preloadIncludePaths);
     $ret .= "    } else {\n";
     $preloadClasses = array();
     $preloadClasses[] = 'Kwf_Assets_Loader';
     $preloadClasses[] = 'Kwf_Media_Output';
     $ret .= self::_generatePreloadClassesCode($preloadClasses, $preloadIncludePaths);
     $ret .= "    }\n";
     $ret .= "}\n";
     Kwf_Cache_Simple::$backend = null;
     //unset to re-calculate
     $ret .= "Kwf_Cache_Simple::\$backend = '" . Kwf_Cache_Simple::getBackend() . "';\n";
     if (Kwf_Config::getValue('server.memcache.host')) {
         $host = Kwf_Config::getValue('server.memcache.host');
         if ($host == '%webserverHostname%') {
             if (PHP_SAPI == 'cli') {
                 $host = Kwf_Util_Apc::callUtil('get-hostname', array(), array('returnBody' => true, 'skipCache' => true));
             } else {
                 $host = php_uname('n');
             }
         }
         $ret .= "Kwf_Cache_Simple::\$memcacheHost = '" . $host . "';\n";
         $ret .= "Kwf_Cache_Simple::\$memcachePort = '" . Kwf_Config::getValue('server.memcache.port') . "';\n";
     }
     $configSection = call_user_func(array(Kwf_Setup::$configClass, 'getDefaultConfigSection'));
     $ret .= "Kwf_Setup::\$configSection = '" . $configSection . "';\n";
     $ret .= "if (substr(\$requestUri, 0, 8) == '/assets/') {\n";
     $ret .= "    Kwf_Assets_Loader::load(\$requestUri);\n";
     $ret .= "}\n";
     if (Kwf_Config::getValue('debug.benchmarkCounter')) {
         //vor registerAutoload aufrufen damit wir dort benchmarken können
         $ret .= "Kwf_Benchmark::enableLog();\n";
     }
     $ret .= "Zend_Registry::setClassName('Kwf_Registry');\n";
     $ret .= "\$host = isset(\$_SERVER['HTTP_HOST']) ? \$_SERVER['HTTP_HOST'] : null;\n";
     $ret .= "session_name('SESSION_" . Kwf_Config::getValue('application.id') . "');\n";
     if (Kwf_Config::getValue('server.https') !== 'unknown') {
         $redirectHttpsCode = "    if (\$_SERVER['REQUEST_METHOD'] != 'GET') {\n";
         $redirectHttpsCode .= "        header('HTTP/1.1 400 Bad Request');\n";
         $redirectHttpsCode .= "        echo 'Invalid protocol, https required';\n";
         $redirectHttpsCode .= "        exit;\n";
         $redirectHttpsCode .= "    }\n";
         $redirectHttpsCode .= "    \$redirect = 'https://'.\$_SERVER['HTTP_HOST'].\$_SERVER['REQUEST_URI'];\n";
         $redirectHttpsCode .= "    header('Location: '.\$redirect, true, 301);\n";
         $redirectHttpsCode .= "    Kwf_Benchmark::shutDown();\n";
         $redirectHttpsCode .= "    exit;\n";
         $redirectHttpCode = str_replace('https', 'http', $redirectHttpsCode);
         $ret .= "if (PHP_SAPI != 'cli') {\n";
         if (!Kwf_Config::getValue('server.https')) {
             $ret .= "if (isset(\$_SERVER['HTTPS'])) {\n";
             $ret .= "    {$redirectHttpCode}";
             $ret .= "}\n";
         } else {
             if ($domains = Kwf_Config::getValueArray('server.httpsDomains')) {
                 $ret .= "\$domains = array(";
                 foreach ($domains as $d) {
                     $ret .= "'" . $d . "'=>true, ";
                 }
                 $ret .= ");\n";
                 $ret .= "\$supportsHttps = isset(\$_SERVER['HTTP_HOST']) && isset(\$domains[\$_SERVER['HTTP_HOST']]);\n";
                 $ret .= "if (\$supportsHttps != isset(\$_SERVER['HTTPS'])) {\n";
                 $ret .= "    if (\$supportsHttps) {\n";
                 $ret .= "        {$redirectHttpsCode}";
                 $ret .= "    } else {\n";
                 $ret .= "        {$redirectHttpCode}";
                 $ret .= "    }\n";
                 $ret .= "}\n";
             } else {
                 $ret .= "if (!isset(\$_SERVER['HTTPS'])) {\n";
                 $ret .= "{$redirectHttpsCode}";
                 $ret .= "}\n";
             }
         }
         $ret .= "}\n";
     }
     $ret .= "session_set_cookie_params(\n";
     $ret .= " 0,";
     //lifetime
     $ret .= " '" . Kwf_Setup::getBaseUrl() . "/',";
     //path
     $ret .= " null,";
     //domain
     $ret .= " isset(\$_SERVER['HTTPS']),";
     //secure
     $ret .= " true";
     //httponly
     $ret .= ");\n";
     $ret .= "\n";
     //store session data in memcache if avaliable
     if ((Kwf_COnfig::getValue('server.memcache.host') || Kwf_Config::getValue('aws.simpleCacheCluster')) && Kwf_Setup::hasDb()) {
         $ret .= "\nif (PHP_SAPI != 'cli') Kwf_Util_SessionHandler::init();\n";
     }
     //up here to have less dependencies or broken redirect
     $ret .= "\n";
     $ret .= "if (substr(\$requestUri, 0, 14) == '/kwf/util/apc/'\n";
     $ret .= ") {\n";
     $ret .= "    Kwf_Util_Apc::dispatchUtils();\n";
     $ret .= "}\n";
     // Falls redirectToDomain eingeschalten ist, umleiten
     if (Kwf_Config::getValue('server.redirectToDomain')) {
         $ret .= "if (\$host && substr(\$requestUri, 0, 17) != '/kwf/maintenance/' && substr(\$requestUri, 0, 8) != '/assets/') {\n";
         $ret .= "    \$redirect = false;\n";
         if ($domains = Kwf_Config::getValueArray('kwc.domains')) {
             $ret .= "    \$domainMatches = false;\n";
             foreach ($domains as $domain) {
                 $ret .= "    if ('{$domain['domain']}' == \$host) \$domainMatches = true;\n";
             }
             $ret .= "    if (!\$domainMatches) {\n";
             foreach ($domains as $domain) {
                 if (isset($domain['pattern'])) {
                     $ret .= "\n";
                     $ret .= "        //pattern\n";
                     $ret .= "        if (!\$domainMatches && preg_match('/{$domain['pattern']}/', \$host)) {\n";
                     $ret .= "            \$domainMatches = true;\n";
                     if (isset($domain['noRedirectPattern'])) {
                         $ret .= "\n";
                         $ret .= "            //noRedirectPattern\n";
                         $ret .= "            if (!preg_match('/{$domain['noRedirectPattern']}/', \$host)) {\n";
                         $ret .= "                \$redirect = '{$domain['domain']}';\n";
                         $ret .= "            }\n";
                     } else {
                         $ret .= "            \$redirect = '{$domain['domain']}';\n";
                     }
                     $ret .= "        }\n";
                 }
             }
             $ret .= "    }\n";
             $ret .= "    if (!\$domainMatches) {\n";
             $ret .= "        \$redirect = '" . Kwf_Config::getValue('server.domain') . "';\n";
             $ret .= "    }\n";
         } else {
             if (Kwf_Config::getValue('server.domain')) {
                 $ret .= "    if (\$host != '" . Kwf_Config::getValue('server.domain') . "') {\n";
                 if (Kwf_Config::getValue('server.noRedirectPattern')) {
                     $ret .= "        if (!preg_match('/" . Kwf_Config::getValue('server.noRedirectPattern') . "/', \$host)) {\n";
                     $ret .= "            \$redirect = '" . Kwf_Config::getValue('server.domain') . "';\n";
                     $ret .= "        }\n";
                 } else {
                     $ret .= "        \$redirect = '" . Kwf_Config::getValue('server.domain') . "';\n";
                 }
                 $ret .= "    }\n";
             }
         }
         $ret .= "    if (\$redirect) {\n";
         $ret .= "        \$target = Kwf_Model_Abstract::getInstance('Kwf_Util_Model_Redirects')\n";
         $ret .= "            ->findRedirectUrl('domainPath', \$host.\$_SERVER['REQUEST_URI']);\n";
         $ret .= "        if (!\$target) {\n";
         $ret .= "            \$target = Kwf_Model_Abstract::getInstance('Kwf_Util_Model_Redirects')\n";
         $ret .= "                ->findRedirectUrl('domain', \$host);\n";
         $ret .= "        }\n";
         $ret .= "        if (\$target) {\n";
         $ret .= "            header('Location: '.\$target, true, 301);\n";
         $ret .= "        } else {\n";
         $ret .= "            //redirect to main domain (server.domain)\n";
         $ret .= "            header('Location: http://'.\$redirect.\$_SERVER['REQUEST_URI'], true, 301);\n";
         $ret .= "        }\n";
         $ret .= "        exit;\n";
         $ret .= "    }\n";
         $ret .= "}\n";
     }
     if (Kwf_Config::getValue('preLogin')) {
         $ret .= "if (PHP_SAPI != 'cli' && Kwf_Setup::getRequestPath()!==false) {\n";
         $ret .= "    \$ignore = false;\n";
         foreach (Kwf_Config::getValueArray('preLoginIgnore') as $i) {
             $ret .= "    if (substr(\$_SERVER['REDIRECT_URL'], 0, " . strlen($i) . ") == '{$i}') \$ignore = true;\n";
         }
         foreach (Kwf_Config::getValueArray('preLoginIgnoreIp') as $i) {
             if (substr($i, -1) == '*') {
                 $i = substr($i, 0, -1);
                 $ret .= "    if (substr(\$_SERVER['REMOTE_ADDR'], 0, " . strlen($i) . ") == '{$i}') \$ignore = true;\n";
             } else {
                 if (substr($i, 0, 1) == '*') {
                     $i = substr($i, 1);
                     $ret .= "    if (substr(\$_SERVER['REMOTE_ADDR'], -" . strlen($i) . ") == '{$i}') \$ignore = true;\n";
                 } else {
                     $ret .= "    if (\$_SERVER['REMOTE_ADDR'] == '{$i}') \$ignore = true;\n";
                 }
             }
         }
         $ret .= "    if (!\$ignore && (empty(\$_SERVER['PHP_AUTH_USER'])\n";
         $ret .= "           || empty(\$_SERVER['PHP_AUTH_PW'])\n";
         $ret .= "            || \$_SERVER['PHP_AUTH_USER']!='" . Kwf_Config::getValue('preLoginUser') . "'\n";
         $ret .= "           || \$_SERVER['PHP_AUTH_PW']!='" . Kwf_Config::getValue('preLoginPassword') . "')\n";
         $ret .= "    ) {\n";
         $ret .= "        \$realm = 'Testserver';\n";
         $ret .= "        header('WWW-Authenticate: Basic realm=\"'.\$realm.'\"');\n";
         $ret .= "        throw new Kwf_Exception_AccessDenied();\n";
         $ret .= "    }\n";
         $ret .= "}\n";
     }
     if ($parameters = Kwf_Config::getValueArray('parameterToCookie')) {
         foreach ($parameters as $parameter) {
             $ret .= "if (isset(\$_GET['" . $parameter . "'])) setcookie('" . $parameter . "', \$_GET['" . $parameter . "'], 0, '/');\n";
         }
     }
     if ($tl = Kwf_Config::getValue('debug.timeLimit')) {
         $ret .= "set_time_limit({$tl});\n";
     }
     $ret .= "if (substr(\$requestUri, 0, 9) == '/kwf/pma/' || \$requestUri == '/kwf/pma') {\n";
     $ret .= "    Kwf_Util_Pma::dispatch();\n";
     $ret .= "}\n";
     $ret .= "if (isset(\$_GET['kwcPreview'])) {\n";
     $ret .= "    \$role = Kwf_Registry::get('userModel')->getAuthedUserRole();\n";
     $ret .= "    if (!Kwf_Registry::get('acl')->isAllowed(\$role, 'kwf_component_preview', 'view')) {\n";
     $ret .= "        header('Location: /admin/component/preview/redirect/?url='.urlencode(\$_SERVER['REQUEST_URI']));\n";
     $ret .= "        exit;\n";
     $ret .= "    }\n";
     $ret .= "    Kwf_Component_Data_Root::setShowInvisible(true);\n";
     $ret .= "}\n";
     return $ret;
 }
Пример #20
0
 public function getContents($language)
 {
     $json = json_encode(Kwf_Config::getValueArray('googleMapsApiKeys'));
     return "Ext2.namespace('Kwf.GoogleMap');Kwf.GoogleMap.apiKeys = {$json};";
 }
 public function getContents($language)
 {
     $json = json_encode(Kwf_Config::getValueArray('googleMapsApiKeys'));
     return "module.exports = {$json};";
 }
Пример #22
0
 private static function _getAllListeners()
 {
     Kwf_Events_ModelObserver::getInstance()->disable();
     $models = array();
     $subscribers = array();
     foreach (Kwc_Abstract::getComponentClasses() as $componentClass) {
         $subscribers = array_merge($subscribers, self::_getSubscribersFromComponent($componentClass));
     }
     if (Kwf_Component_Data_Root::getComponentClass()) {
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_ViewCache');
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_UrlCache');
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_ProcessInputCache');
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_PagesMeta');
     }
     foreach (Kwf_Model_Abstract::findAllInstances() as $m) {
         $subscribers = array_merge($subscribers, self::_getSubscribersFromModel($m));
     }
     foreach (Kwf_Config::getValueArray('eventSubscribers') as $subscriber) {
         if ($subscriber) {
             $subscriber = Kwf_Events_Subscriber::getInstance($subscriber);
             $subscribers[] = $subscriber;
         }
     }
     $ret = array();
     self::_addListenersFromSubscribers($ret, $subscribers);
     Kwf_Events_ModelObserver::getInstance()->enable();
     return $ret;
 }
Пример #23
0
 /**
  * @param Kwf_Model_Abstract|string wenn string: entweder aus config (models.modelName)
  *                                               oder Klassenname von Model
  * @return Kwf_Model_Interface
  **/
 public static function getInstance($modelName)
 {
     if (is_object($modelName)) {
         return $modelName;
     }
     static $config;
     if (!isset($config)) {
         $config = Kwf_Config::getValueArray('models');
     }
     if (array_key_exists($modelName, $config)) {
         if (!$config[$modelName]) {
             return null;
         }
         $modelName = $config[$modelName];
     }
     return Kwf_Model_Factory_ClassName::getModelInstance($modelName);
 }
Пример #24
0
 public function includeCode($position)
 {
     $data = $this->_getView()->component;
     $ret = '';
     if ($position == 'header') {
         $helper = new Kwf_View_Helper_DebugData();
         $ret .= $helper->debugData();
     }
     $flag = $position == 'header' ? 'hasHeaderIncludeCode' : 'hasFooterIncludeCode';
     $cmps = $data->getPage()->getRecursiveChildComponents(array('flags' => array($flag => true)));
     if (Kwc_Abstract::getFlag($data->componentClass, $flag)) {
         $cmps[] = $data;
     }
     $statisticsBoxUsed = false;
     $assetsBoxUsed = false;
     foreach ($cmps as $c) {
         $includeCode = $c->getComponent()->getIncludeCode($position);
         if (is_string($includeCode)) {
             $ret .= $includeCode;
         } else {
             if (is_object($includeCode) && $includeCode instanceof Kwf_Component_Data) {
                 $componentHelper = new Kwf_Component_View_Helper_Component();
                 $componentHelper->setRenderer($this->_getRenderer());
                 $componentHelper->setView($this->_getView());
                 $ret .= $componentHelper->component($includeCode);
                 if (is_instance_of($includeCode->componentClass, 'Kwc_Statistics_Analytics_Component') || is_instance_of($includeCode->componentClass, 'Kwc_Statistics_Piwik_Component')) {
                     $statisticsBoxUsed = true;
                 }
                 if (is_instance_of($includeCode->componentClass, 'Kwc_Box_Assets_Component')) {
                     $assetsBoxUsed = true;
                 }
             } else {
                 if (is_null($includeCode)) {
                 } else {
                     throw new Kwf_Exception("invalid getIncludeCode return type");
                 }
             }
         }
     }
     if ($position == 'header') {
         if ($v = Kwf_Config::getValue('kwc.favicon')) {
             $ret .= "<link rel=\"shortcut icon\" href=\"{$v}\" />\n";
         }
         if (!$assetsBoxUsed) {
             //add default assets if there was no box
             $a = new Kwf_View_Helper_Assets();
             $ret .= $a->assets(Kwf_Assets_Package_Default::getInstance('Frontend'), null);
         }
         $helper = new Kwf_Component_View_Helper_Dynamic();
         $helper->setRenderer($this->_getRenderer());
         $helper->setView($this->_getView());
         $ret .= $helper->dynamic('SessionToken');
     } else {
         if ($position == 'footer') {
             if (!$statisticsBoxUsed) {
                 //if there was no statistics box output default code
                 //box is required for eg. multidomains
                 $cfg = Kwf_Config::getValueArray('statistics');
                 if (isset($cfg['analytics']['code']) && $cfg['analytics']['code']) {
                     throw new Kwf_Exception('To support analytics add Kwc_Statistics_Analytics_Component as a box.');
                 }
                 if (isset($cfg['piwik']['id']) && $cfg['piwik']['id']) {
                     throw new Kwf_Exception('To support piwik add Kwc_Statistics_Piwik_Component as a box.');
                 }
             }
             //see http://nexxar.wordpress.com/2010/10/07/speeding-up-jquery-ready-on-ie/
             $ret .= "\n";
             $ret .= "<!--[if lt IE 9]>\n";
             $ret .= "<script type=\"text/javascript\">\n";
             $ret .= "    jQuery.ready();\n";
             $ret .= "</script>\n";
             $ret .= "<![endif]-->\n";
         }
     }
     return $ret;
 }
Пример #25
0
 protected function _getMetaTags()
 {
     $components = $this->_getMetaTagComponents();
     $ret = array();
     if (Kwf_Config::getValue('application.kwf.name') == 'Koala Framework') {
         $ret['generator'] = 'Koala Web Framework CMS';
     }
     foreach ($components as $component) {
         foreach ($component->getComponent()->getMetaTags() as $name => $content) {
             if (!isset($ret[$name])) {
                 $ret[$name] = '';
             }
             //TODO: bei zB noindex,nofollow anderes trennzeichen
             $ret[$name] .= ' ' . $content;
         }
     }
     foreach ($ret as &$i) {
         $i = trim($i);
     }
     if ($this->getData()->getPage()) {
         /*
                     $components = $this->getData()->getPage()->getRecursiveChildComponents(array(
                         'page' => false,
                         'limit' => 1,
                         'flags' => array('noIndex' => true)
                     ));*/
         if (Kwc_Abstract::getFlag($this->getData()->getPage()->componentClass, 'noIndex')) {
             if (isset($ret['robots'])) {
                 $ret['robots'] .= ',';
             } else {
                 $ret['robots'] = '';
             }
             $ret['robots'] .= 'noindex';
         }
     }
     // verify-v1
     if (isset($_SERVER['HTTP_HOST'])) {
         $host = $_SERVER['HTTP_HOST'];
     } else {
         $host = Kwf_Config::getValue('server.domain');
     }
     $hostParts = explode('.', $host);
     if (count($hostParts) < 2) {
         $configDomain = $host;
     } else {
         $shortParts = array('com', 'co', 'gv', 'or');
         if (count($hostParts) > 2 & in_array($hostParts[count($hostParts) - 2], $shortParts)) {
             $hostParts[count($hostParts) - 2] = $hostParts[count($hostParts) - 3] . $hostParts[count($hostParts) - 2];
         }
         $configDomain = $hostParts[count($hostParts) - 2] . $hostParts[count($hostParts) - 1];
         // zB 'com'
     }
     $configVerify = Kwf_Config::getValueArray('verifyV1');
     if ($configVerify && isset($configVerify[$configDomain])) {
         $ret['verify-v1'] = $configVerify[$configDomain];
     }
     $configVerify = Kwf_Config::getValueArray('googleSiteVerification');
     if ($configVerify && isset($configVerify[$configDomain])) {
         $ret['google-site-verification'] = $configVerify[$configDomain];
     }
     return $ret;
 }
Пример #26
0
 public static function getUpdatesForDir($classPrefix)
 {
     static $namespaces;
     if (!isset($namespaces)) {
         $namespaces = (include VENDOR_PATH . '/composer/autoload_namespaces.php');
     }
     $pos = strpos($classPrefix, '_');
     $ns1 = substr($classPrefix, 0, $pos + 1);
     $pos = strpos($classPrefix, '_', $pos + 1);
     if ($pos !== false) {
         $ns2 = substr($classPrefix, 0, $pos + 1);
     } else {
         $ns2 = $classPrefix;
     }
     if (isset($namespaces[$ns2])) {
         $dirs = $namespaces[$ns2];
     } else {
         if (isset($namespaces[$ns1])) {
             $dirs = $namespaces[$ns1];
         } else {
             $dirs = array();
         }
     }
     static $includePaths;
     if (!isset($includePaths)) {
         $includePaths = (include VENDOR_PATH . '/composer/include_paths.php');
         $includePaths = array_merge($includePaths, Kwf_Config::getValueArray('includepath'));
     }
     foreach ($includePaths as $i) {
         if (file_exists($i . '/' . str_replace('_', '/', $classPrefix))) {
             $dirs[] = $i;
         }
     }
     $ret = array();
     foreach ($dirs as $dir) {
         $path = $dir . '/' . str_replace('_', '/', $classPrefix);
         if (is_dir($path)) {
             foreach (new DirectoryIterator($path) as $i) {
                 if (!$i->isFile()) {
                     continue;
                 }
                 $f = $i->__toString();
                 $fileType = substr($f, -4);
                 if ($fileType != '.php' && $fileType != '.sql') {
                     continue;
                 }
                 $f = substr($f, 0, -4);
                 if (is_numeric($f)) {
                     throw new Kwf_Exception("Invalid update script name: " . $i->getPathname() . " Please use the new syntax.");
                 }
                 $className = $classPrefix . '_' . $f;
                 if ($className == 'Kwf_Update_Sql') {
                     continue;
                 }
                 $update = self::createUpdate($className, $i->getPathname());
                 if (!$update) {
                     continue;
                 }
                 $tags = $update->getTags();
                 if ($tags) {
                     if (array_intersect($tags, self::getUpdateTags()) != $tags) {
                         continue;
                     }
                 }
                 $ret[] = $update;
             }
         }
     }
     $ret = self::_sortUpdates($ret);
     return $ret;
 }
Пример #27
0
 public function getTypes()
 {
     $types = array();
     $simpleCacheBackend = Kwf_Cache_Simple::getBackend();
     if ($simpleCacheBackend == 'memcache' || $simpleCacheBackend == 'elastiCache') {
         $types[] = new Kwf_Util_ClearCache_Types_SimpleCache();
     }
     if (Kwf_Util_Apc::isAvailable()) {
         $types[] = new Kwf_Util_ClearCache_Types_ApcUser();
         $types[] = new Kwf_Util_ClearCache_Types_ApcOptcode();
     }
     foreach ($this->_getCacheDirs() as $d) {
         if ($d != 'config' && $d != 'assets' && $d != 'trl' && $d != 'view') {
             $types[] = new Kwf_Util_ClearCache_Types_Dir($d);
         }
     }
     foreach ($this->_getDbCacheTables() as $t) {
         if ($t == 'cache_component') {
             $types[] = new Kwf_Util_ClearCache_Types_TableComponentView();
         } else {
             if ($t == 'cache_component_includes') {
                 //never completely clear that table as it would break clearing fullPage cache
             } else {
                 if ($t == 'cache_users') {
                     //skip, needed during update
                 } else {
                     $types[] = new Kwf_Util_ClearCache_Types_Table($t);
                 }
             }
         }
     }
     if (Kwf_Config::getValue('assetsCacheUrl')) {
         $types[] = new Kwf_Util_ClearCache_Types_AssetsServer();
     }
     $types[] = new Kwf_Util_ClearCache_Types_Config();
     $types[] = new Kwf_Util_ClearCache_Types_Setup();
     $types[] = new Kwf_Util_ClearCache_Types_Assets();
     if (!Kwf_Config::getValue('clearCacheSkipProcessControl') && Kwf_Config::getValueArray('processControl')) {
         $types[] = new Kwf_Util_ClearCache_Types_ProcessControl();
     }
     return $types;
 }
Пример #28
0
 protected function makeRequest($url, $params, $ch = null)
 {
     if (!$ch) {
         $ch = curl_init();
     }
     $opts = self::$CURL_OPTS;
     $configProxy = Kwf_Config::getValueArray('http.proxy');
     if (isset($configProxy['host']) && $configProxy['host']) {
         $opts[CURLOPT_PROXY] = $configProxy['host'];
         $opts[CURLOPT_SSL_VERIFYPEER] = false;
     }
     if (isset($configProxy['port']) && $configProxy['port']) {
         $opts[CURLOPT_PROXYPORT] = $configProxy['port'];
     }
     if ($this->getFileUploadSupport()) {
         $opts[CURLOPT_POSTFIELDS] = $params;
     } else {
         $opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
     }
     $opts[CURLOPT_URL] = $url;
     // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
     // for 2 seconds if the server does not support this header.
     if (isset($opts[CURLOPT_HTTPHEADER])) {
         $existing_headers = $opts[CURLOPT_HTTPHEADER];
         $existing_headers[] = 'Expect:';
         $opts[CURLOPT_HTTPHEADER] = $existing_headers;
     } else {
         $opts[CURLOPT_HTTPHEADER] = array('Expect:');
     }
     curl_setopt_array($ch, $opts);
     $result = curl_exec($ch);
     if (curl_errno($ch) == 60) {
         // CURLE_SSL_CACERT
         self::errorLog('Invalid or no certificate authority found, ' . 'using bundled information');
         curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
         $result = curl_exec($ch);
     }
     // With dual stacked DNS responses, it's possible for a server to
     // have IPv6 enabled but not have IPv6 connectivity.  If this is
     // the case, curl will try IPv4 first and if that fails, then it will
     // fall back to IPv6 and the error EHOSTUNREACH is returned by the
     // operating system.
     if ($result === false && defined('CURLOPT_IPRESOLVE') && empty($opts[CURLOPT_IPRESOLVE])) {
         $matches = array();
         $regex = '/Failed to connect to ([^:].*): Network is unreachable/';
         if (preg_match($regex, curl_error($ch), $matches)) {
             if (strlen(@inet_pton($matches[1])) === 16) {
                 self::errorLog('Invalid IPv6 configuration on server, ' . 'Please disable or get native IPv6 on your server.');
                 self::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
                 curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
                 $result = curl_exec($ch);
             }
         }
     }
     if ($result === false) {
         $e = new FacebookApiException(array('error_code' => curl_errno($ch), 'error' => array('message' => curl_error($ch), 'type' => 'CurlException')));
         curl_close($ch);
         throw $e;
     }
     curl_close($ch);
     return $result;
 }
Пример #29
0
 public static function hasDb()
 {
     static $ret;
     if (isset($ret)) {
         return $ret;
     }
     $config = Kwf_Config::getValueArray('database');
     $ret = isset($config['web']) && $config['web'] !== false;
     return $ret;
 }
Пример #30
0
 public function getLanguages()
 {
     if (!isset($this->_languages)) {
         $langauges = Kwf_Config::getValueArray('languages');
         if ($langauges) {
             $this->_languages = array_keys($langauges);
         } else {
             $this->_languages = array($this->getWebCodeLanguage());
         }
     }
     return $this->_languages;
 }