本文整理汇总了PHP中MOXMAN类的典型用法代码示例。如果您正苦于以下问题:PHP MOXMAN类的具体用法?PHP MOXMAN怎么用?PHP MOXMAN使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MOXMAN类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:41,代码来源:DeleteCommand.php
示例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;
}
开发者ID:buildshop,项目名称:bs-common,代码行数:34,代码来源:DeleteCommand.php
示例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;
}
开发者ID:shainmcalindon,项目名称:boothsgardenstudios,代码行数:29,代码来源:Plugin.php
示例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())));
}
}
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:36,代码来源:AuthHandler.php
示例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;
}
}
}
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:35,代码来源:LanguageHandler.php
示例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();
}
}
}
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:25,代码来源:FileInfoCommand.php
示例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);
}
开发者ID:buildshop,项目名称:bs-common,代码行数:36,代码来源:ZipCommand.php
示例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);
}
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:41,代码来源:CreateDirectoryCommand.php
示例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;
}
开发者ID:tremor-od,项目名称:pizza.loc,代码行数:29,代码来源:Plugin.php
示例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;
}
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:31,代码来源:Plugin.php
示例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);
}
开发者ID:robbie778,项目名称:dolphin.pro,代码行数:41,代码来源:ImportFromUrlCommand.php
示例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;
}
开发者ID:GHarutyunyan,项目名称:cms,代码行数:32,代码来源:FileInfoCommand.php
示例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();
}
开发者ID:tremor-od,项目名称:pizza.loc,代码行数:13,代码来源:GetConfigCommand.php
示例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());
}
开发者ID:newton27,项目名称:dolphin.pro,代码行数:37,代码来源:DownloadHandler.php
示例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);
}
开发者ID:vidalweb,项目名称:MoxieManager,代码行数:32,代码来源:PutFileContentsCommand.php
示例16: api
/**
* Wrap Moxiemanager's api.php in a controller action.
*
* @return void
*/
public function api()
{
try {
$pluginPath = Plugin::path('CkTools');
define('MOXMAN_CLASSES', $pluginPath . 'src/Lib/moxiemanager/classes');
define('MOXMAN_PLUGINS', $pluginPath . 'src/Lib/moxiemanager/plugins');
define('MOXMAN_ROOT', $pluginPath . 'src/Lib/moxiemanager');
define('MOXMAN_API_FILE', __FILE__);
$appConfig = Configure::read('CkTools.moxiemanager');
Configure::load('CkTools.moxiemanager');
$moxieManagerConfig = Configure::read('moxiemanager');
if (is_array($appConfig)) {
$moxieManagerConfig = Hash::merge($moxieManagerConfig, $appConfig);
}
$GLOBALS['moxieManagerConfig'] = $moxieManagerConfig;
require_once MOXMAN_CLASSES . '/MOXMAN.php';
$context = \MOXMAN_Http_Context::getCurrent();
$pluginManager = \MOXMAN::getPluginManager();
foreach ($pluginManager->getAll() as $plugin) {
if ($plugin instanceof \MOXMAN_Http_IHandler) {
$plugin->processRequest($context);
}
}
} catch (Exception $e) {
\MOXMAN_Exception::printException($e);
}
return $this->render(false, false);
}
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:33,代码来源:MoxiemanagerController.php
示例17: add
/**
* Adds a plugin instance by name to the manager.
*
* @param string $name Name of the plugin to add.
* @param MOXMAN_IPlugin $plugin Plugin instance to add.
*/
public function add($name, MOXMAN_IPlugin $plugin)
{
if ($plugin instanceof MOXMAN_Auth_IAuthenticator) {
MOXMAN::getAuthManager()->add($name, $plugin);
}
$this->plugins[$name] = $plugin;
$this->unInitialized[] = $name;
}
开发者ID:GHarutyunyan,项目名称:cms,代码行数:14,代码来源:PluginManager.php
示例18: 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);
$url = parse_url($params->url);
$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("To file already exist: " . $file->getPublicPath(), MOXMAN_Exception::FILE_EXISTS);
}
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);
}
$port = "";
if (isset($url["port"])) {
$port = ":" . $url["port"];
}
$query = "";
if (isset($url["query"])) {
$query = "?" . $url["query"];
}
$path = $url["path"] . $query;
$host = $url["scheme"] . "://" . $url["host"] . $port;
$httpClient = new MOXMAN_Http_HttpClient($host);
$request = $httpClient->createRequest($path);
$response = $request->send();
// Handle redirects
$location = $response->getHeader("location");
if ($location) {
$httpClient->close();
$httpClient = new MOXMAN_Http_HttpClient($location);
$request = $httpClient->createRequest($location);
$response = $request->send();
}
// Read file into ram
// TODO: This should not happen if we know the file size
$content = "";
while (($chunk = $response->read()) != "") {
$content .= $chunk;
}
$httpClient->close();
// Fire before file action add event
$args = $this->fireBeforeFileAction("add", $file, strlen($content));
$file = $args->getFile();
$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);
}
开发者ID:newton27,项目名称:dolphin.pro,代码行数:62,代码来源:ImportFromUrlCommand.php
示例19: startSession
public static function startSession()
{
$sessionName = MOXMAN::getConfig()->get("SessionAuthenticator.session_name");
if ($sessionName) {
@session_name($sessionName);
}
if (session_id() == '') {
@session_start();
}
}
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:10,代码来源:Plugin.php
示例20: onFileAction
public function onFileAction(MOXMAN_Vfs_FileActionEventArgs $args)
{
switch ($args->getAction()) {
case MOXMAN_Vfs_FileActionEventArgs::DELETE:
case MOXMAN_Vfs_FileActionEventArgs::COPY:
case MOXMAN_Vfs_FileActionEventArgs::ADD:
MOXMAN::getUserStorage()->put("quota.size", max(0, $this->currentSize));
break;
}
}
开发者ID:newton27,项目名称:dolphin.pro,代码行数:10,代码来源:Plugin.php
注:本文中的MOXMAN类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论