本文整理汇总了PHP中Kwf_Setup类的典型用法代码示例。如果您正苦于以下问题:PHP Kwf_Setup类的具体用法?PHP Kwf_Setup怎么用?PHP Kwf_Setup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Kwf_Setup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!file_exists('bootstrap.php')) {
throw new \Exception("Run this script in the application root directory");
}
\Kwf_Setup::setUp();
if (file_exists('setup/initial/dump.sql')) {
unlink('setup/initial/dump.sql');
}
if (file_exists('setup/initial/uploads')) {
foreach (glob('setup/initial/uploads/*') as $f) {
unlink($f);
}
}
if ($input->getOption('include-initial-dump')) {
$output->writeln("checking for pending updates...");
$pendingUpdatesCount = \Kwf_Util_Update_Helper::countPendingUpdates();
if ($pendingUpdatesCount) {
throw new \Exception("{$pendingUpdatesCount} Updates have not been executed. Run update first.");
}
$output->writeln("creating database dump...");
$dump = DbDump::dump();
if (!file_exists('setup/initial')) {
mkdir('setup/initial', 0777, true);
$ignore = "";
if (file_exists('setup/.gitignore')) {
$ignore = file_get_contents('setup/.gitignore');
}
if (!preg_match('#^initial$#m', $ignore)) {
$ignore = rtrim($ignore);
if ($ignore) {
$ignore .= "\n";
}
$ignore .= "initial\n";
}
file_put_contents('setup/.gitignore', $ignore);
}
file_put_contents('setup/initial/dump.sql', $dump);
$output->writeln("copying uploads...");
if (!file_exists('setup/initial/uploads')) {
mkdir('setup/initial/uploads');
}
$model = \Kwf_Model_Abstract::getInstance('Kwf_Uploads_Model');
$select = new \Kwf_Model_Select();
$it = new \Kwf_Model_Iterator_Packages(new \Kwf_Model_Iterator_Rows($model, $select));
foreach ($it as $row) {
$fileSource = $row->getFileSource();
copy($fileSource, 'setup/initial/uploads/' . basename($fileSource));
}
}
$excludes = ExcludeFinder::findExcludes('.');
$excludeArgs = '';
foreach ($excludes as $i) {
$excludeArgs .= " -x " . escapeshellarg('./' . $i . '*');
}
$cmd = "zip deploy.zip . --quiet -r {$excludeArgs}";
$output->writeln("creating deploy.zip archive...");
$this->_systemCheckRet($cmd, $input, $output);
$output->writeln("deploy.zip successfully created.");
}
示例2: getUrl
/**
*
* @param string
* @param string
* @param string
* @param string
* @param int Kann gesetzt werden wenn wir in diesem web auf das bild nicht direkten zugriff haben
* sondern nur für ein anderes web die url generieren
*/
public static function getUrl($class, $id, $type, $filename, $time = null)
{
if ($filename instanceof Kwf_Uploads_Row) {
$filename = $filename->filename . '.' . $filename->extension;
}
if ($filename == '.') {
$filename = '';
}
//Replace Slashes and Backslashes with an underscore
//Otherwise we would get a wrong url
//e.g. $filename = foo/bar.png -> /media/FooModel/1/default/ab123/1234/foo/bar.png
$filename = str_replace('/', '_', $filename);
$filename = str_replace('\\', '_', $filename);
$checksumType = $type;
if (substr($type, 0, strlen(Kwf_Media::DONT_HASH_TYPE_PREFIX)) == Kwf_Media::DONT_HASH_TYPE_PREFIX) {
$checksumType = Kwf_Media::DONT_HASH_TYPE_PREFIX;
}
$class = rawurlencode($class);
$checksum = self::getChecksum($class, $id, $checksumType, rawurlencode($filename));
$prefix = Kwf_Setup::getBaseUrl();
if ($r = Kwf_Component_Data_Root::getInstance()) {
if ($r->filename) {
$prefix .= '/' . $r->filename;
}
}
if (is_null($time)) {
$cacheId = 'mtime-' . self::createCacheId($class, $id, $type);
$time = Kwf_Media_MemoryCache::getInstance()->load($cacheId);
if (!$time) {
$time = time();
Kwf_Media_MemoryCache::getInstance()->save($time, $cacheId);
}
}
return $prefix . '/media/' . $class . '/' . $id . '/' . $type . '/' . $checksum . '/' . $time . '/' . rawurlencode($filename);
}
示例3: output
public static function output()
{
$baseUrl = Kwf_Setup::getBaseUrl();
$contents = "User-agent: *\n" . "Disallow: {$baseUrl}/admin/\n";
$contents .= "Sitemap: http" . (isset($_SERVER['HTTPS']) ? 's' : '') . "://" . $_SERVER['HTTP_HOST'] . $baseUrl . "/sitemap.xml\n";
Kwf_Media_Output::output(array('contents' => $contents, 'mimeType' => 'text/plain'));
}
示例4: afterStart
public static function afterStart()
{
static $validatorsRegistered = false;
if (!$validatorsRegistered) {
if (isset($_SESSION['__KWF']['VALID'])) {
self::_processValidators();
}
//sessions timeout after 15-20 minutes of inactivity
//this is in addition to gc_maxlifetime (which isn't reliable enough)
$sessionTimeout = 20 * 60;
if (!isset($_SESSION['kwfTimeout'])) {
$_SESSION['kwfTimeout'] = time() + $sessionTimeout;
} else {
if ($_SESSION['kwfTimeout'] - time() < 0) {
$_SESSION = array();
$_SESSION['kwfTimeout'] = time() + $sessionTimeout;
Zend_Session::regenerateId();
} else {
if ($_SESSION['kwfTimeout'] - time() < $sessionTimeout - 5 * 60) {
//extend timeout every 5 minutes (not in every request for better performance)
$_SESSION['kwfTimeout'] = time() + $sessionTimeout;
}
}
}
if (!isset($_SESSION['__KWF']['VALID'])) {
Zend_Session::registerValidator(new Kwf_Session_Validator_HttpHost());
if (Kwf_Setup::getBaseUrl()) {
Zend_Session::registerValidator(new Kwf_Session_Validator_BasePath());
}
Zend_Session::registerValidator(new Kwf_Session_Validator_RemoteAddr());
}
$validatorsRegistered = true;
}
}
示例5: processInput
public function processInput($postData)
{
if (isset($postData['redirectAuth'])) {
$authMethods = Kwf_Registry::get('userModel')->getAuthMethods();
if (!isset($authMethods[$postData['redirectAuth']])) {
throw new Kwf_Exception_NotFound();
}
$auth = $authMethods[$postData['redirectAuth']];
if (!$auth instanceof Kwf_User_Auth_Interface_Redirect) {
throw new Kwf_Exception_NotFound();
}
$formValues = array();
foreach ($auth->getLoginRedirectFormOptions() as $option) {
if ($option['type'] == 'select') {
$formValues[$option['name']] = $postData[$option['name']];
}
}
$redirectBackUrl = Kwf_Setup::getBaseUrl() . '/';
$f = new Kwf_Filter_StrongRandom();
$state = 'activate-' . $postData['redirectAuth'] . '-' . $f->filter(null) . '-' . $postData['code'] . '-' . $redirectBackUrl;
//save state in namespace to validate it later
$ns = new Kwf_Session_Namespace('kwf-login-redirect');
$ns->state = $state;
$url = $auth->getLoginRedirectUrl($this->_getRedirectBackUrl(), $state, $formValues);
header("Location: " . $url);
exit;
}
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
\Kwf_Setup::setUp();
$dbConfig = \Kwf_Registry::get('dao')->getDbConfig();
$cacheTables = \Kwf_Util_ClearCache::getInstance()->getDbCacheTables();
$dumpCmd = "mysqldump";
$dumpCmd .= " --host=" . escapeshellarg($dbConfig['host']);
$dumpCmd .= " --user=" . escapeshellarg($dbConfig['username']);
$dumpCmd .= " --password=" . escapeshellarg($dbConfig['password']);
$cmd = $dumpCmd;
foreach ($cacheTables as $t) {
$cmd .= " --ignore-table=" . escapeshellarg($dbConfig['dbname'] . '.' . $t);
}
$cmd .= " {$dbConfig['dbname']}";
passthru($cmd, $ret);
if ($ret) {
return $ret;
}
foreach ($cacheTables as $t) {
$cmd = $dumpCmd;
$cmd .= " --no-data " . escapeshellarg($dbConfig['dbname']) . " " . escapeshellarg($t);
passthru($cmd, $ret);
if ($ret) {
return $ret;
}
}
return 0;
}
示例7: output
public static function output()
{
$baseUrl = Kwf_Setup::getBaseUrl();
$contents = "User-agent: *\n" . "Disallow: {$baseUrl}/admin/\n" . "Disallow: {$baseUrl}/kwf/util/kwc/render\n";
//used to load eg. lightbox content async, we don't want getting that indexed
$contents .= "Sitemap: http" . (isset($_SERVER['HTTPS']) ? 's' : '') . "://" . $_SERVER['HTTP_HOST'] . $baseUrl . "/sitemap.xml\n";
Kwf_Media_Output::output(array('contents' => $contents, 'mimeType' => 'text/plain'));
}
示例8: _clearCache
protected function _clearCache($options)
{
if (!Kwf_Setup::hasDb()) {
$this->_output("skipped: (no db configured)\n");
return;
}
Kwf_Component_Cache_Url_Abstract::getInstance()->clear();
}
示例9: render
public function render($ignoreCli = false)
{
if (!Kwf_Registry::get('config')->setupFinished) {
echo "<h1>" . Kwf_Config::getValue('application.name') . "</h1>\n";
echo "<a href=\"" . Kwf_Setup::getBaseUrl() . "/kwf/maintenance/setup\">[start setup]</a>\n";
exit;
}
parent::render($ignoreCli);
}
示例10: indexAction
public function indexAction()
{
Zend_Registry::set('db', false);
Kwf_Test_SeparateDb::setDbFromCookie();
// setzt es nur wenn es das cookie wirklich gibt
//FnF models setzen damit tests nicht in echte tabellen schreiben
Kwf_Component_Cache::setInstance(Kwf_Component_Cache::CACHE_BACKEND_FNF);
Kwf_Component_Cache_Memory::setInstance(new Kwf_Component_Cache_MemoryBlackHole());
/*
if (class_exists('APCIterator')) {
$prefix = Kwf_Cache::getUniquePrefix();
apc_delete_file(new APCIterator('user', '#^'.$prefix.'#'));
} else {
apc_clear_cache('user');
}
*/
Kwf_Component_Data_Root::setComponentClass($this->_getParam('root'));
Zend_Registry::set('testRootComponentClass', $this->_getParam('root'));
$root = Kwf_Component_Data_Root::getInstance();
$root->setFilename('kwf/kwctest/' . $this->_getParam('root'));
$url = $this->_getParam('url');
$urlParts = explode('/', $url);
if (is_array($urlParts) && $urlParts[0] == 'media') {
if (sizeof($urlParts) != 7) {
throw new Kwf_Exception_NotFound();
}
$class = $urlParts[1];
$id = $urlParts[2];
$type = $urlParts[3];
$checksum = $urlParts[4];
// time() wäre der 5er, wird aber nur wegen browsercache benötigt
$filename = $urlParts[6];
if ($checksum != Kwf_Media::getChecksum($class, $id, $type, $filename)) {
throw new Kwf_Exception_AccessDenied('Access to file not allowed.');
}
Kwf_Media_Output::output(Kwf_Media::getOutput($class, $id, $type));
}
if ($url == 'kwf/util/kwc/render') {
if (isset($_REQUEST['url'])) {
$_REQUEST['url'] = str_replace('/' . $root->filename, '', $_REQUEST['url']);
}
Kwf_Util_Component::dispatchRender();
}
$domain = 'http://' . Zend_Registry::get('config')->server->domain;
$data = $root->getPageByUrl($domain . Kwf_Setup::getBaseUrl() . '/' . $url, null);
if (!$data) {
throw new Kwf_Exception_NotFound();
}
$root->setCurrentPage($data);
$contentSender = Kwc_Abstract::getSetting($data->componentClass, 'contentSender');
$contentSender = new $contentSender($data);
$contentSender->sendContent(true);
Kwf_Benchmark::shutDown();
Kwf_Benchmark::output();
exit;
}
示例11: dispatch
public static function dispatch($logModel = 'Kwf_Util_PayPal_Ipn_LogModel')
{
$url = Kwf_Setup::getRequestPath();
if ($url != '/wirecard_confirm') {
return;
}
self::process($logModel);
echo 'OK';
exit;
}
示例12: _clearCache
protected function _clearCache($options)
{
$url = Kwf_Config::getValue('assetsCacheUrl') . '?web=' . Kwf_Config::getValue('application.id') . '§ion=' . Kwf_Setup::getConfigSection() . '&clear';
try {
$out = file_get_contents($url);
$this->_output("cleared: assetsServer [" . $out . "]\n");
} catch (Exception $e) {
$this->_output("cleared: assetsServer [ERROR] " . $e->getMessage() . "\n");
}
}
示例13: getSessionToken
public static function getSessionToken()
{
if (!Kwf_Setup::hasAuthedUser()) {
return null;
}
$ns = new Kwf_Session_Namespace('sessionToken');
if (!$ns->token) {
$ns->token = md5(microtime() . mt_rand());
}
return $ns->token;
}
示例14: __construct
public function __construct($config = array())
{
if (isset($config['prefix'])) {
$this->_prefix = $config['prefix'];
} else {
$this->_prefix = Zend_Registry::get('config')->application->id . '-' . Kwf_Setup::getConfigSection() . '-bench-';
}
if (isset($config['memcache'])) {
$this->_memcache = $config['memcache'];
}
}
示例15: dispatch
/**
* Proxy, der zB für cross-domain ajax requests verwendet werden kann
*
* @param string|array $hosts Erlaubte Hostnamen (RegExp erlaubt, ^ vorne und $ hinten werden autom. angefügt)
*/
public static function dispatch($hostnames)
{
if (Kwf_Setup::getRequestPath() === false) {
return;
}
if (!preg_match('#^/kwf/proxy/?$#i', Kwf_Setup::getRequestPath())) {
return;
}
if (is_string($hostnames)) {
$hostnames = array($hostnames);
}
$proxyUrl = $_REQUEST['proxyUrl'];
$proxyPostVars = $_POST;
$proxyGetVars = $_GET;
if (array_key_exists('proxyUrl', $proxyPostVars)) {
unset($proxyPostVars['proxyUrl']);
}
if (array_key_exists('proxyUrl', $proxyGetVars)) {
unset($proxyGetVars['proxyUrl']);
}
// host checking
$proxyHost = parse_url($proxyUrl, PHP_URL_HOST);
$matched = false;
foreach ($hostnames as $hostname) {
if (preg_match('/^' . $hostname . '$/i', $proxyHost)) {
$matched = true;
break;
}
}
if (!$matched) {
return;
}
// proxying
$http = new Zend_Http_Client($proxyUrl);
if (count($_POST)) {
$http->setMethod(Zend_Http_Client::POST);
} else {
$http->setMethod(Zend_Http_Client::GET);
}
if (count($_GET)) {
$http->setParameterGet($proxyGetVars);
}
if (count($_POST)) {
$http->setParameterPost($proxyPostVars);
}
$response = $http->request();
$headers = $response->getHeaders();
if ($headers && !empty($headers['Content-type'])) {
header("Content-Type: " . $headers['Content-type']);
}
echo $response->getBody();
exit;
}