protected function loadYubikeyUserAuthorization() { $usersConfig = ConfigManager::getConfig("Users", "Users"); $resultingConfig = ConfigManager::mergeConfigs($usersConfig->AuxConfig, $this->config->AuxConfig); $yubikeyUserAuthorization = new YubikeyUserAuthorization(Reg::get($usersConfig->Objects->UserManagement), $resultingConfig); $this->register($yubikeyUserAuthorization); }
/** * Get configs from DB and merge them with global config * * @param int $cacheMinutes */ public static function initDBConfig($cacheMinutes = null) { $sql = MySqlDbManager::getQueryObject(); $sql->exec("SELECT * FROM `" . Tbl::get("TBL_CONFIGS") . "`", $cacheMinutes); $dbConfig = static::parseDBRowsToConfig($sql->fetchRecords()); ConfigManager::setGlobalConfig(ConfigManager::mergeConfigs($dbConfig, ConfigManager::getGlobalConfig())); }
/** * Get configs from DB and merge them with global config * * @param int $cacheMinutes */ public static function initDBConfig(ConfigDBFilter $filter = null, $cacheMinutes = 0) { if ($filter == null) { $filter = new ConfigDBFilter(); $filter->setCommon(); } $sql = MySqlDbManager::getQueryObject(); $sql->exec($filter->getSQL(), $cacheMinutes); $dbConfig = static::parseDBRowsToConfig($sql->fetchRecords()); ConfigManager::setGlobalConfig(ConfigManager::mergeConfigs($dbConfig, ConfigManager::getGlobalConfig())); }
/** * Upload Image from POST * * @param array $file - Part of $_FILES like $_FILES['photo'] * @param string $fileName - Put image with this filename * @param Config $imageUploaderConfig * @throws RuntimeException * @throws InvalidArgumentException * @throws ImageException * @throws ImageUploaderException * @return Image */ public static function upload($file, $fileName = null, Config $imageUploaderConfig = null) { $imageUploaderConfig = ConfigManager::mergeConfigs($imageUploaderConfig, ConfigManager::getConfig("Image", "ImageUploader")->AuxConfig); $uploadDir = $imageUploaderConfig->uploadDir; if (empty($uploadDir)) { throw new RuntimeException("Unable to get any appropriate uploadDir!"); } if (!file_exists($uploadDir)) { throw new InvalidArgumentException("Upload directory {$uploadDir} doesn't exists."); } ensurePathLastSlash($uploadDir); if (!in_array($file["type"], $imageUploaderConfig->acceptedMimeTypes->toArray())) { throw new ImageException("Unsupported file uploaded!"); } // Check if we have enough memory to open this file as image $info = getimagesize($file['tmp_name']); if ($info != false && !Image::checkMemAvailbleForResize($info[0], $info[1])) { throw new ImageUploaderException("Not enough memory to open image", static::EXCEPTION_IMAGE_IS_BIG); } // Check if we are able to create image resource from this file. $image = new Image($file['tmp_name']); $format = null; if (isset($imageUploaderConfig->saveFormat) and $imageUploaderConfig->saveFormat != null) { $format = $imageUploaderConfig->saveFormat; } else { $format = $image->getType(); } if ($fileName === null) { $fileName = static::findNewFileName($uploadDir, $format); } $savePath = $uploadDir . $fileName; if (isset($imageUploaderConfig->minimumSize)) { $checkResult = $image->isSizeMeetRequirements($imageUploaderConfig->minimumSize->largeSideMinSize, $imageUploaderConfig->minimumSize->smallSideMinSize); if (!$checkResult) { throw new ImageUploaderException("Given image is smaller than specified minimum size.", static::EXCEPTION_IMAGE_IS_SMALL); } } switch ($format) { case Image::IMAGE_TYPE_JPEG: $image->writeJpeg($savePath); break; case Image::IMAGE_TYPE_PNG: $image->writePng($savePath); break; case Image::IMAGE_TYPE_GIF: $image->writeGif($savePath); break; } return $image; }
if (!empty($file['precompileCode'])) { $fileContents .= $file['precompileCode'] . "\n\n"; } $fileContents .= $content . "\n\n"; if (!empty($file['postcompileCode'])) { $fileContents .= $file['postcompileCode'] . "\n\n"; } } file_put_contents($classesCacheFilename, $fileContents); } } } // Request Parser HookManager::callHook("BeforeRequestParser"); HookManager::callHook("BeforeRequestParserStep2"); HookManager::callHook("RequestParser"); HookManager::callHook("AfterRequestParser"); HookManager::callHook("BeforeController"); HookManager::callHook("Controller"); HookManager::callHook("AfterController"); //$time = microtime(true); HookManager::callHook("BeforeOutput"); HookManager::callHook("Output"); HookManager::callHook("AfterOutput"); if (ConfigManager::getGlobalConfig()->Stingle->BootCompiler === true) { if (!file_exists($configCacheFilename) and !$isGetConfigFromCache) { file_put_contents($configCacheFilename, serialize(ConfigManager::mergeConfigs(ConfigManager::getGlobalConfig(), ConfigManager::getCache()))); } } //echo "out - " . (microtime(true) - $time) . "<br>"; // Finish
/** * Get config for given plugin * * @param string $packageName * @param string $pluginName */ public function getPluginConfig($packageName, $pluginName) { $pluginConfig = ConfigManager::getConfig($packageName, $pluginName); if (isset($this->customConfigs->{$packageName}) and isset($this->customConfigs->{$packageName}->{$pluginName})) { if (isset($this->forceCustomConfigs[$packageName]) and isset($this->forceCustomConfigs[$packageName][$pluginName]) and $this->forceCustomConfigs[$packageName][$pluginName] == true) { $pluginConfig = $this->customConfigs->{$packageName}->{$pluginName}; } else { $pluginConfig = ConfigManager::mergeConfigs($this->customConfigs->{$packageName}->{$pluginName}, $pluginConfig); } } return $pluginConfig; }