本文整理汇总了PHP中MOXMAN类的典型用法代码示例。如果您正苦于以下问题:PHP MOXMAN类的具体用法?PHP MOXMAN怎么用?PHP MOXMAN使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MOXMAN类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Executes the command logic with the specified RPC parameters.
*
* @param Object $params Command parameters sent from client.
* @return Object Result object to be passed back to client.
*/
public function execute($params)
{
$paths = $params->paths;
$result = array();
foreach ($paths as $path) {
if ($this->hasPath($result, $path)) {
continue;
}
$file = MOXMAN::getFile($path);
$config = $file->getConfig();
if ($config->get('general.demo')) {
throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
}
if (!$file->exists()) {
throw new MOXMAN_Exception("Path doesn't exist: " . $file->getPublicPath(), MOXMAN_Exception::FILE_DOESNT_EXIST);
}
$parentFile = $file->getParentFile();
if (!$parentFile || !$parentFile->canWrite()) {
throw new MOXMAN_Exception("No write access to file: " . $file->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
}
$filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "delete");
if (!$filter->accept($file)) {
throw new MOXMAN_Exception("Invalid file name for: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
}
$result[] = $this->fileToJson($file);
if ($file->exists()) {
$args = $this->fireBeforeFileAction(MOXMAN_Vfs_FileActionEventArgs::DELETE, $file);
$result = array_merge($result, $this->filesToJson($args->getFileList()));
$file->delete(true);
$args = $this->fireFileAction(MOXMAN_Vfs_FileActionEventArgs::DELETE, $file);
$result = array_merge($result, $this->filesToJson($args->getFileList()));
}
}
return $result;
}
示例2: execute
/**
* Executes the command logic with the specified RPC parameters.
*
* @param Object $params Command parameters sent from client.
* @return Object Result object to be passed back to client.
*/
public function execute($params)
{
$paths = $params->paths;
$result = array();
foreach ($paths as $path) {
$file = MOXMAN::getFile($path);
$config = $file->getConfig();
if ($config->get('general.demo')) {
throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
}
if (!$file->exists()) {
throw new MOXMAN_Exception("Path doesn't exist: " . $file->getPublicPath(), MOXMAN_Exception::FILE_DOESNT_EXIST);
}
if (!$file->canWrite()) {
throw new MOXMAN_Exception("No write access to file: " . $file->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
}
$filter = MOXMAN_Vfs_BasicFileFilter::createFromConfig($config);
if ($filter->accept($file, $file->isFile()) !== MOXMAN_Vfs_BasicFileFilter::ACCEPTED) {
throw new MOXMAN_Exception("Invalid file name for: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
}
$result[] = $this->fileToJson($file);
if ($file->exists()) {
$file->delete(true);
$this->fireFileAction(MOXMAN_Core_FileActionEventArgs::DELETE, $file);
}
}
return $result;
}
示例3: authenticate
public function authenticate(MOXMAN_Auth_User $user)
{
$config = MOXMAN::getConfig();
if ($config->get('SymfonyAuthenticator.application_name') == '') {
die('You should define a SymfonyAuthenticator.application_name name in Moxiemanager config file.');
}
if ($config->get('SymfonyAuthenticator.application_env') == '') {
die('You should define a SymfonyAuthenticator.application_env in Moxiemanager config file.');
}
if ($config->get('SymfonyAuthenticator.project_configuration_path') == '') {
die('You should define a SymfonyAuthenticator.project_configuration_path in Moxiemanager config file.');
}
require_once $config->get('SymfonyAuthenticator.project_configuration_path');
$configuration = ProjectConfiguration::getApplicationConfiguration($config->get('SymfonyAuthenticator.application_name'), $config->get('SymfonyAuthenticator.application_env'), false);
$context = sfContext::createInstance($configuration);
// Is the user authenticated ?
if ($context->getUser()->isAuthenticated()) {
// Do we need a special role to access to the moxiemanager ?
if ($config->get('SymfonyAuthenticator.credential') != '') {
if ($context->getUser()->hasCredential($config->get('SymfonyAuthenticator.credential'))) {
return true;
} else {
return false;
}
}
return true;
}
return false;
}
示例4: processRequest
/**
* Process a request using the specified context.
*
* @param MOXMAN_Http_Context $httpContext Context instance to pass to use for the handler.
*/
public function processRequest(MOXMAN_Http_Context $httpContext)
{
$request = $httpContext->getRequest();
$response = $httpContext->getResponse();
try {
$config = MOXMAN::getConfig();
$allItems = $config->getAll();
$licenseKey = trim($config->get("general.license"));
$installed = !empty($allItems);
$response->disableCache();
$response->setHeader('Content-type', 'application/json');
if ($installed && !$config->get('filesystem.rootpath')) {
throw new MOXMAN_Exception("You must configure filesystem.rootpath.");
}
if ($request->getMethod() != 'POST') {
throw new MOXMAN_Exception("Not a HTTP post request.");
}
if ($installed && !preg_match('/^([0-9A-Z]{4}\\-){7}[0-9A-Z]{4}$/', $licenseKey)) {
throw new MOXMAN_Exception("Invalid license key specified in config.");
}
$authInfo = (object) array("token" => MOXMAN_Http_Csrf::createToken(MOXMAN::getConfig()->get('general.license')), "installed" => $installed, "loggedin" => MOXMAN::getAuthManager()->isAuthenticated(), "loginurl" => $config->get("authenticator.login_page", ""), "standalone" => MOXMAN::getAuthManager()->hasStandalone(), "overwrite_action" => $config->get("filesystem.overwrite_action", ""));
$args = new MOXMAN_Auth_AuthInfoEventArgs();
MOXMAN::getPluginManager()->get("core")->fire("AuthInfo", $args);
foreach ($args->getInfo() as $key => $value) {
$authInfo->{$key} = $value;
}
$response->sendJson($authInfo);
} catch (Exception $e) {
$response->sendJson((object) array("error" => array("code" => $e->getCode(), "message" => $e->getMessage())));
}
}
示例5: processRequest
/**
* Process a request using the specified context.
*
* @param MOXMAN_Http_Context $httpContext Context instance to pass to use for the handler.
*/
public function processRequest(MOXMAN_Http_Context $httpContext)
{
$request = $httpContext->getRequest();
$response = $httpContext->getResponse();
$response->disableCache();
$response->setHeader('Content-type', 'text/javascript');
// Set prefix if it's a tinymce language pack or not
$prefix = MOXMAN_ROOT . '/langs/moxman_';
if ($request->get("tinymce")) {
$prefix = MOXMAN_ROOT . '/langs/';
}
// Load TinyMCE specific pack if it exists
$langCode = preg_replace('/[^a-z_\\-]/i', '', $request->get('code'));
if ($langCode) {
$langFile = $prefix . $langCode . '.js';
if (file_exists($langFile)) {
$response->sendContent(file_get_contents($langFile));
return;
}
}
// Fallback to configured language pack
$langCode = MOXMAN::getConfig()->get("general.language");
if ($langCode) {
$langFile = $prefix . $langCode . '.js';
if (file_exists($langFile)) {
$response->sendContent(file_get_contents($langFile));
return;
}
}
}
示例6: addVideoMeta
private function addVideoMeta(MOXMAN_Vfs_IFile $file, $metaData)
{
$fileName = $file->getName();
$ext = strtolower(MOXMAN_Util_PathUtils::getExtension($fileName));
if (preg_match('/^(mp4|ogv|webm)$/', $ext)) {
$metaData->url_type = MOXMAN_Util_Mime::get($fileName);
$name = substr($fileName, 0, strlen($fileName) - strlen($ext));
// Alternative video formats
$altExt = array("mp4", "ogv", "webm");
foreach ($altExt as $altExt) {
if ($ext != $altExt) {
$altFile = MOXMAN::getFile($file->getParent(), $name . $altExt);
if ($altFile->exists()) {
$metaData->alt_url = $altFile->getUrl();
break;
}
}
}
// Alternative image format
$altFile = MOXMAN::getFile($file->getParent(), $name . "jpg");
if ($altFile->exists()) {
$metaData->alt_img = $altFile->getUrl();
}
}
}
示例7: execute
/**
* Executes the command logic with the specified RPC parameters.
*
* @param Object $params Command parameters sent from client.
* @return Object Result object to be passed back to client.
*/
public function execute($params)
{
$toPath = $params->to;
$ext = MOXMAN_Util_PathUtils::getExtension($toPath);
if ($ext !== 'zip') {
$toPath .= '.zip';
}
$toFile = MOXMAN::getFile($toPath);
$config = $toFile->getConfig();
if ($config->get('general.demo')) {
throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
}
if (!$toFile->canWrite()) {
throw new MOXMAN_Exception("No write access to file: " . $toFile->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
}
$zipWriter = new MOXMAN_Zip_ZipWriter(array("compressionLevel" => 5));
$filter = MOXMAN_Vfs_BasicFileFilter::createFromConfig($config);
$path = $params->path;
foreach ($params->names as $name) {
$fromFile = MOXMAN::getFile(MOXMAN_Util_PathUtils::combine($path, $name));
$this->addZipFiles($fromFile, $fromFile->getParent(), $filter, $zipWriter);
}
$stream = $toFile->open(MOXMAN_Vfs_IFileStream::WRITE);
if ($stream) {
$stream->write($zipWriter->toString());
$stream->close();
}
$this->fireFileAction(MOXMAN_Core_FileActionEventArgs::ADD, $toFile);
return $this->fileToJson($toFile);
}
示例8: execute
/**
* Executes the command logic with the specified RPC parameters.
*
* @param Object $params Command parameters sent from client.
* @return Object Result object to be passed back to client.
*/
public function execute($params)
{
$file = MOXMAN::getFile($params->path);
$config = $file->getConfig();
if ($config->get('general.demo')) {
throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
}
if (!$file->canWrite()) {
throw new MOXMAN_Exception("No write access to file: " . $file->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
}
if ($file->exists()) {
throw new MOXMAN_Exception("File already exist: " . $file->getPublicPath(), MOXMAN_Exception::FILE_EXISTS);
}
$filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "createdir");
if (!$filter->accept($file, false)) {
throw new MOXMAN_Exception("Invalid file name for: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
}
if (isset($params->template)) {
// TODO: Security audit this
$templateFile = MOXMAN::getFile($params->template);
if (!$templateFile->exists()) {
throw new MOXMAN_Exception("Template file doesn't exists: " . $file->getPublicPath(), MOXMAN_Exception::FILE_DOESNT_EXIST);
}
$args = $this->fireBeforeTargetFileAction(MOXMAN_Vfs_FileActionEventArgs::COPY, $templateFile, $file);
$file = $args->getTargetFile();
$templateFile->copyTo($file);
$this->fireTargetFileAction(MOXMAN_Vfs_FileActionEventArgs::COPY, $templateFile, $file);
} else {
$args = $this->fireBeforeFileAction(MOXMAN_Vfs_FileActionEventArgs::ADD, $file);
$file = $args->getFile();
$file->mkdir();
$this->fireFileAction(MOXMAN_Vfs_FileActionEventArgs::ADD, $file);
}
return $this->fileToJson($file, true);
}
示例9: authenticate
public function authenticate(MOXMAN_Auth_User $user)
{
$config = MOXMAN::getConfig();
$session = MOXMAN_Http_Context::getCurrent()->getSession();
// Check logged in key
$sessionValue = $session->get($config->get("SessionAuthenticator.logged_in_key"), false);
if (!$sessionValue || $sessionValue === "false") {
return false;
}
// Extend config with session prefixed sessions
$sessionConfig = array();
$configPrefix = $config->get("SessionAuthenticator.config_prefix");
if ($configPrefix) {
foreach ($_SESSION as $key => $value) {
if (strpos($key, $configPrefix) === 0) {
$sessionConfig[substr($key, strlen($configPrefix) + 1)] = $value;
}
}
}
// Extend the config with the session config
$config->extend($sessionConfig);
// Replace ${user} with all config items
$key = $config->get("SessionAuthenticator.user_key");
if ($key && isset($_SESSION[$key])) {
$config->replaceVariable("user", $session->get($key));
}
// The user is authenticated so let them though
return true;
}
示例10: authenticate
public function authenticate(MOXMAN_Auth_User $user)
{
$config = MOXMAN::getConfig();
$session = new CI_Session();
// Check logged in key
$sessionValue = $session->userdata($config->get("CodeIgniterAuthenticator.logged_in_key", "loggedin"));
if (!$sessionValue || $sessionValue === "false") {
return false;
}
// Extend config with session prefixed sessions
$sessionConfig = array();
$configPrefix = $config->get("CodeIgniterAuthenticator.config_prefix", "moxiemanager");
if ($configPrefix) {
$allData = $session->all_userdata();
foreach ($allData as $key => $value) {
if (strpos($key, $configPrefix) === 0) {
$sessionConfig[substr($key, strlen($configPrefix) + 1)] = $value;
}
}
}
// Extend the config with the session config
$config->extend($sessionConfig);
// Replace ${user} with all config items
$key = $config->get("CodeIgniterAuthenticator.user_key");
if ($key) {
$value = $session->userdata($key);
$config->replaceVariable("user", $value);
$user->setName($value);
}
return true;
}
示例11: execute
/**
* Executes the command logic with the specified RPC parameters.
*
* @param Object $params Command parameters sent from client.
* @return Object Result object to be passed back to client.
*/
public function execute($params)
{
$file = MOXMAN::getFile($params->path);
$config = $file->getConfig();
$resolution = $params->resolution;
if ($config->get('general.demo')) {
throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
}
$content = $this->getUrlContent($params->url, $config);
// Fire before file action add event
$args = $this->fireBeforeFileAction("add", $file, strlen($content));
$file = $args->getFile();
if (!$file->canWrite()) {
throw new MOXMAN_Exception("No write access to file: " . $file->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
}
$filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "upload");
if (!$filter->accept($file, true)) {
throw new MOXMAN_Exception("Invalid file name for: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
}
if ($resolution == "rename") {
$file = MOXMAN_Util_FileUtils::uniqueFile($file);
} else {
if ($resolution == "overwrite") {
MOXMAN::getPluginManager()->get("core")->deleteFile($file);
} else {
throw new MOXMAN_Exception("To file already exist: " . $file->getPublicPath(), MOXMAN_Exception::FILE_EXISTS);
}
}
$stream = $file->open(MOXMAN_Vfs_IFileStream::WRITE);
$stream->write($content);
$stream->close();
$args = new MOXMAN_Vfs_FileActionEventArgs("add", $file);
MOXMAN::getPluginManager()->get("core")->fire("FileAction", $args);
return parent::fileToJson($file, true);
}
示例12: execute
/**
* Executes the command logic with the specified RPC parameters.
*
* @param Object $params Command parameters sent from client.
* @return Object Result object to be passed back to client.
*/
public function execute($params)
{
if (isset($params->paths)) {
$result = array();
foreach ($params->paths as $path) {
$file = MOXMAN::getFile($path);
$fileInfo = $this->fileToJson($file, true);
$args = $this->fireCustomInfo(MOXMAN_Core_CustomInfoEventArgs::INSERT_TYPE, $file);
$fileInfo->info = (object) $args->getInfo();
if (isset($params->insert) && $params->insert) {
$this->fireFileAction(MOXMAN_Core_FileActionEventArgs::INSERT, $file);
}
$result[] = $fileInfo;
}
} else {
$file = MOXMAN::getFile($params->path);
$fileInfo = $this->fileToJson($file, true);
$args = $this->fireCustomInfo(MOXMAN_Core_CustomInfoEventArgs::INSERT_TYPE, $file);
$fileInfo->info = (object) $args->getInfo();
if (isset($params->insert) && $params->insert) {
$this->fireFileAction(MOXMAN_Core_FileActionEventArgs::INSERT, $file);
}
$result = $fileInfo;
}
return $result;
}
示例13: execute
/**
* Executes the command logic with the specified RPC parameters.
*
* @param Object $params Command parameters sent from client.
* @return Object Result object to be passed back to client.
*/
public function execute($params)
{
if (isset($params->path) && $params->path) {
return $this->getPublicConfig(MOXMAN::getFile($params->path));
}
return $this->getPublicConfig();
}
示例14: processRequest
/**
* Process a request using the specified context.
*
* @param MOXMAN_Http_Context $httpContext Context instance to pass to use for the handler.
*/
public function processRequest(MOXMAN_Http_Context $httpContext)
{
$request = $httpContext->getRequest();
$response = $httpContext->getResponse();
$path = $request->get("path");
$names = explode('/', $request->get("names", ""));
$zipName = $request->get("zipname", "files.zip");
if (count($names) === 1) {
$file = MOXMAN::getFile(MOXMAN_Util_PathUtils::combine($path, $names[0]));
$filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig(MOXMAN::getFile($path)->getConfig(), "download");
if (!$filter->accept($file)) {
throw new MOXMAN_Exception("Invalid file name for: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
}
if ($file->isFile()) {
$response->sendFile($file, true);
return;
}
}
// Download multiple files as zip
$zipWriter = new MOXMAN_Zip_ZipWriter(array("compressionLevel" => 0));
// Setup download headers
$response->disableCache();
$response->setHeader("Content-type", "application/octet-stream");
$response->setHeader("Content-Disposition", 'attachment; filename="' . $zipName . '"');
$filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig(MOXMAN::getFile($path)->getConfig(), "download");
// Combine files to zip
foreach ($names as $name) {
$fromFile = MOXMAN::getFile(MOXMAN_Util_PathUtils::combine($path, $name));
$this->addZipFiles($fromFile, $fromFile->getParent(), $filter, $zipWriter);
}
$response->sendContent($zipWriter->toString());
}
示例15: execute
/**
* Executes the command logic with the specified RPC parameters.
*
* @param Object $params Command parameters sent from client.
* @return Object Result object to be passed back to client.
*/
public function execute($params)
{
$file = MOXMAN::getFile($params->path);
$config = $file->getConfig();
if ($config->get('general.demo')) {
throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
}
if (!$file->canWrite()) {
throw new MOXMAN_Exception("No write access to file: " . $file->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
}
$filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "edit");
if ($filter->accept($file) !== MOXMAN_Vfs_CombinedFileFilter::ACCEPTED) {
throw new MOXMAN_Exception("Invalid file name for: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
}
if ($file->exists()) {
$file->delete(true);
}
// Write contents to file
$stream = $file->open(MOXMAN_Vfs_IFileStream::WRITE);
if ($stream) {
$stream->write($params->content);
$stream->close();
}
$this->fireFileAction(MOXMAN_Core_FileActionEventArgs::ADD, $file);
return $this->fileToJson($file);
}