本文整理汇总了PHP中HTMLWriter::charsetHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP HTMLWriter::charsetHeader方法的具体用法?PHP HTMLWriter::charsetHeader怎么用?PHP HTMLWriter::charsetHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLWriter
的用法示例。
在下文中一共展示了HTMLWriter::charsetHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCurrentQuota
public function getCurrentQuota($action, $httpVars, $fileVars)
{
$u = $this->getUsage($this->getWorkingPath());
HTMLWriter::charsetHeader("application/json");
print json_encode(array('USAGE' => $u, 'TOTAL' => $this->getAuthorized()));
return;
}
示例2: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
switch ($action) {
case "get_secure_token":
HTMLWriter::charsetHeader("text/plain");
print AuthService::generateSecureToken();
//exit(0);
break;
//------------------------------------
// CHANGE USER PASSWORD
//------------------------------------
//------------------------------------
// CHANGE USER PASSWORD
//------------------------------------
case "pass_change":
$userObject = AuthService::getLoggedUser();
if ($userObject == null || $userObject->getId() == "guest") {
header("Content-Type:text/plain");
print "SUCCESS";
break;
}
$oldPass = $httpVars["old_pass"];
$newPass = $httpVars["new_pass"];
$passSeed = $httpVars["pass_seed"];
if (strlen($newPass) < ConfService::getCoreConf("PASSWORD_MINLENGTH", "auth")) {
header("Content-Type:text/plain");
print "PASS_ERROR";
break;
}
if (AuthService::checkPassword($userObject->getId(), $oldPass, false, $passSeed)) {
AuthService::updatePassword($userObject->getId(), $newPass);
if ($userObject->getLock() == "pass_change") {
$userObject->removeLock();
$userObject->save("superuser");
}
} else {
header("Content-Type:text/plain");
print "PASS_ERROR";
break;
}
header("Content-Type:text/plain");
print "SUCCESS";
break;
default:
break;
}
return "";
}
示例3: switchActions
public function switchActions($actionName, $httpVars, $fileVars)
{
if ($actionName != "changes" || !isset($httpVars["seq_id"])) {
return false;
}
require_once AJXP_BIN_FOLDER . "/dibi.compact.php";
dibi::connect($this->sqlDriver);
HTMLWriter::charsetHeader('application/json', 'UTF-8');
$res = dibi::query("SELECT\n [seq] , [ajxp_changes].[repository_identifier] , [ajxp_changes].[node_id] , [type] , [source] , [target] , [ajxp_index].[bytesize], [ajxp_index].[md5], [ajxp_index].[mtime], [ajxp_index].[node_path]\n FROM [ajxp_changes]\n LEFT JOIN [ajxp_index]\n ON [ajxp_changes].[node_id] = [ajxp_index].[node_id]\n WHERE [ajxp_changes].[repository_identifier] = %s AND [seq] > %i\n ORDER BY [ajxp_changes].[node_id], [seq] ASC", $this->computeIdentifier(ConfService::getRepository()), AJXP_Utils::sanitize($httpVars["seq_id"], AJXP_SANITIZE_ALPHANUM));
echo '{"changes":[';
$previousNodeId = -1;
$previousRow = null;
$order = array("path" => 0, "content" => 1, "create" => 2, "delete" => 3);
$relocateAttrs = array("bytesize", "md5", "mtime", "node_path", "repository_identifier");
foreach ($res as $row) {
$row->node = array();
foreach ($relocateAttrs as $att) {
$row->node[$att] = $row->{$att};
unset($row->{$att});
}
if ($row->node_id == $previousNodeId) {
$previousRow->target = $row->target;
$previousRow->seq = $row->seq;
if ($order[$row->type] > $order[$previousRow->type]) {
$previousRow->type = $row->type;
}
} else {
if (isset($previousRow) && ($previousRow->source != $previousRow->target || $previousRow->type == "content")) {
echo json_encode($previousRow) . ",";
}
$previousRow = $row;
$previousNodeId = $row->node_id;
}
$lastSeq = $row->seq;
flush();
}
if (isset($previousRow) && ($previousRow->source != $previousRow->target || $previousRow->type == "content")) {
echo json_encode($previousRow);
}
if (isset($lastSeq)) {
echo '], "last_seq":' . $lastSeq . '}';
} else {
$lastSeq = dibi::query("SELECT MAX([seq]) FROM [ajxp_changes]")->fetchSingle();
if (empty($lastSeq)) {
$lastSeq = 1;
}
echo '], "last_seq":' . $lastSeq . '}';
}
}
示例4: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
switch ($action) {
case "get_js_source":
$jsName = AJXP_Utils::decodeSecureMagic($httpVars["object_name"]);
$jsType = $httpVars["object_type"];
// class or interface?
$fName = "class." . strtolower($jsName) . ".js";
if ($jsName == "Splitter") {
$fName = "splitter.js";
}
if (!defined("CLIENT_RESOURCES_FOLDER")) {
define("CLIENT_RESOURCES_FOLDER", AJXP_PLUGINS_FOLDER . "/gui.ajax/res");
}
// Locate the file class.ClassName.js
if ($jsType == "class") {
$searchLocations = array(CLIENT_RESOURCES_FOLDER . "/js/ajaxplorer", CLIENT_RESOURCES_FOLDER . "/js/lib", AJXP_INSTALL_PATH . "/plugins/");
} else {
if ($jsType == "interface") {
$searchLocations = array(CLIENT_RESOURCES_FOLDER . "/js/ajaxplorer/interfaces");
}
}
foreach ($searchLocations as $location) {
$dir_iterator = new RecursiveDirectoryIterator($location);
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
// could use CHILD_FIRST if you so wish
$break = false;
foreach ($iterator as $file) {
if (strtolower(basename($file->getPathname())) == $fName) {
HTMLWriter::charsetHeader("text/plain", "utf-8");
echo file_get_contents($file->getPathname());
$break = true;
break;
}
}
if ($break) {
break;
}
}
break;
}
}
示例5: handleTasks
public function handleTasks($action, $httpVars, $fileVars)
{
$tasks = AJXP_Utils::loadSerialFile($this->getDbFile(), false, "json");
switch ($action) {
case "scheduler_addTask":
if (isset($httpVars["task_id"])) {
foreach ($tasks as $index => $task) {
if ($task["task_id"] == $httpVars["task_id"]) {
$data = $task;
$theIndex = $index;
}
}
}
if (!isset($theIndex)) {
$data = array();
$data["task_id"] = substr(md5(time()), 0, 16);
}
$data["label"] = $httpVars["label"];
$data["schedule"] = $httpVars["schedule"];
$data["action_name"] = $httpVars["action_name"];
$data["repository_id"] = $httpVars["repository_id"];
$i = 1;
while (array_key_exists("repository_id_" . $i, $httpVars)) {
$data["repository_id"] .= "," . $httpVars["repository_id_" . $i];
$i++;
}
$data["user_id"] = $httpVars["user_id"];
$data["PARAMS"] = array();
if (!empty($httpVars["param_name"]) && !empty($httpVars["param_value"])) {
$data["PARAMS"][$httpVars["param_name"]] = $httpVars["param_value"];
}
foreach ($httpVars as $key => $value) {
if (preg_match('/^param_name_/', $key)) {
$paramIndex = str_replace("param_name_", "", $key);
if (preg_match('/ajxptype/', $paramIndex)) {
continue;
}
if (preg_match('/replication/', $paramIndex)) {
continue;
}
if (isset($httpVars["param_value_" . $paramIndex])) {
$data["PARAMS"][$value] = $httpVars["param_value_" . $paramIndex];
}
}
}
if (isset($theIndex)) {
$tasks[$theIndex] = $data;
} else {
$tasks[] = $data;
}
AJXP_Utils::saveSerialFile($this->getDbFile(), $tasks, true, false, "json");
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage("Successfully added/edited task", null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
break;
case "scheduler_removeTask":
$this->removeTask($httpVars["task_id"]);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage("Successfully removed task", null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
break;
case "scheduler_loadTask":
$found = false;
foreach ($tasks as $task) {
if ($task["task_id"] == $httpVars["task_id"]) {
$index = 0;
$found = true;
foreach ($task["PARAMS"] as $pName => $pValue) {
if ($index == 0) {
$task["param_name"] = $pName;
$task["param_value"] = $pValue;
} else {
$task["param_name_" . $index] = $pName;
$task["param_value_" . $index] = $pValue;
}
$index++;
}
unset($task["PARAMS"]);
if (strpos($task["repository_id"], ",") !== false) {
$ids = explode(",", $task["repository_id"]);
$task["repository_id"] = $ids[0];
for ($i = 1; $i < count($ids); $i++) {
$task["repository_id_" . $i] = $ids[$i];
}
}
break;
}
}
if ($found) {
HTMLWriter::charsetHeader("application/json");
echo json_encode($task);
}
break;
default:
break;
}
//var_dump($tasks);
}
示例6: switchAction
//.........这里部分代码省略.........
AJXP_XMLWriter::close();
break;
case "edit_role":
$roleId = SystemTextEncoding::magicDequote($httpVars["role_id"]);
$roleGroup = false;
$userObject = null;
$groupLabel = null;
if (strpos($roleId, "AJXP_GRP_") === 0) {
$groupPath = substr($roleId, strlen("AJXP_GRP_"));
$filteredGroupPath = AuthService::filterBaseGroup($groupPath);
$groups = AuthService::listChildrenGroups(AJXP_Utils::forwardSlashDirname($groupPath));
$key = "/" . basename($groupPath);
if (!array_key_exists($key, $groups)) {
throw new Exception("Cannot find group with this id!");
}
$roleId = "AJXP_GRP_" . $filteredGroupPath;
$groupLabel = $groups[$key];
$roleGroup = true;
}
if (strpos($roleId, "AJXP_USR_") === 0) {
$usrId = str_replace("AJXP_USR_/", "", $roleId);
$userObject = ConfService::getConfStorageImpl()->createUserObject($usrId);
if (!AuthService::canAdministrate($userObject)) {
throw new Exception("Cant find user!");
}
$role = $userObject->personalRole;
} else {
$role = AuthService::getRole($roleId, $roleGroup);
}
if ($role === false) {
throw new Exception("Cant find role! ");
}
if (isset($httpVars["format"]) && $httpVars["format"] == "json") {
HTMLWriter::charsetHeader("application/json");
$roleData = $role->getDataArray(true);
$allReps = ConfService::getRepositoriesList("all", false);
$repos = array();
if (!empty($userObject)) {
// USER
foreach ($allReps as $repositoryId => $repositoryObject) {
if (!AuthService::canAssign($repositoryObject, $userObject) || $repositoryObject->isTemplate || $repositoryObject->getAccessType() == "ajxp_conf" && !$userObject->isAdmin() || $repositoryObject->getUniqueUser() != null && $repositoryObject->getUniqueUser() != $userObject->getId()) {
continue;
}
$repos[$repositoryId] = SystemTextEncoding::toUTF8($repositoryObject->getDisplay());
}
} else {
foreach ($allReps as $repositoryId => $repositoryObject) {
if (!AuthService::canAdministrate($repositoryObject)) {
continue;
}
$repos[$repositoryId] = SystemTextEncoding::toUTF8($repositoryObject->getDisplay());
}
}
// Make sure it's utf8
$data = array("ROLE" => $roleData, "ALL" => array("REPOSITORIES" => $repos));
if (isset($userObject)) {
$data["USER"] = array();
$data["USER"]["LOCK"] = $userObject->getLock();
$data["USER"]["PROFILE"] = $userObject->getProfile();
$data["ALL"]["PROFILES"] = array("standard|Standard", "admin|Administrator", "shared|Shared", "guest|Guest");
$data["USER"]["ROLES"] = array_keys($userObject->getRoles());
$data["ALL"]["ROLES"] = array_keys(AuthService::getRolesList(array(), true));
if (isset($userObject->parentRole)) {
$data["PARENT_ROLE"] = $userObject->parentRole->getDataArray();
}
} else {
示例7: ajxpTableExists
public function ajxpTableExists($actionName, $httpVars, $fileVars)
{
$p = $this->sqlDriver;
if ($p["driver"] == "postgre") {
$tableQuery = "SELECT [tablename] FROM [pg_catalog].[pg_tables] WHERE [tablename] = %s";
} else {
if ($p["driver"] == "sqlite3" || $p["driver"] == "sqlite") {
$tableQuery = "SELECT [name] FROM [sqlite_master] WHERE type = \"table\" AND [name] = %s";
} else {
$tableQuery = "SHOW TABLES LIKE %s";
}
}
$tableName = AJXP_Utils::sanitize($httpVars["table_name"], AJXP_SANITIZE_ALPHANUM);
$tables = dibi::query($tableQuery, $tableName)->fetchPairs();
$exists = count($tables) && in_array($tableName, $tables);
HTMLWriter::charsetHeader("application/json");
echo json_encode(array("result" => $exists));
}
示例8: mailConsumeQueue
public function mailConsumeQueue($action, $httpVars, $fileVars)
{
if ($action === "consume_mail_queue") {
$verbose = $httpVars["verbose"];
$logInfo = function () {
};
if ($verbose) {
$logInfo = function ($str) {
fwrite(STDOUT, $str . "\n");
};
}
/** @var AjxpMailer $mailer */
$mailer = AJXP_PluginsService::getInstance()->getActivePluginsForType("mailer", true);
if (!dibi::isConnected()) {
dibi::connect($this->getDibiDriver());
}
if ($this->_dibiDriver["driver"] == "postgre") {
dibi::query("SET bytea_output=escape");
}
// Get the queue consumer lock and the time it was given
$time = $this->getConsumerLock();
try {
$querySQL = dibi::query("SELECT * FROM [ajxp_mail_queue] WHERE [date_event] <= %s", $time);
} catch (DibiException $e) {
throw new AJXP_Exception($e->getMessage());
}
//$querySQL->fetch();
//$resultsSQL = $querySQL->fetchAll();
$numRows = $querySQL->count();
$results = [];
HTMLWriter::charsetHeader("text/json");
if ($numRows == 0) {
$logInfo("Nothing to process");
$output = array("report" => "Sent 0 emails", "detail" => "");
echo json_encode($output);
return;
}
$logInfo("Processing " . $numRows . " rows.");
// We need to send one email :
// - per user
// - per email type (HTML or PLAIN)
while ($value = $querySQL->fetch()) {
// Retrieving user information
$recipient = $value['recipient'];
// Retrieving Email type information
$emailType = $value["html"] == 1 ? "html" : "plain";
// Retrieving notification information
/** @var AJXP_Notification $notification */
$notification = unserialize($value["notification_object"]);
$action = $notification->getAction();
$author = $notification->getAuthor();
$node = $notification->getNode();
try {
@$node->loadNodeInfo();
} catch (Exception $e) {
}
if ($node->isLeaf() && !$node->isRoot()) {
$dirName = $node->getParent()->getPath();
} else {
$dirName = $node->getPath();
if ($dirName === null) {
$dirName = '/';
}
}
$key = sprintf("%s|%s|%s", $action, $author, $dirName);
// Retrieving workspace information
if ($node->getRepository() != null) {
$workspace = $node->getRepository()->getDisplay();
} else {
$workspace = "Deleted Workspace";
}
$results[$emailType][$recipient][$workspace][$key][] = $notification;
}
$logInfo("Created digest array.");
$subject = ConfService::getMessages()["core.mailer.9"];
$success = 0;
$errors = [];
foreach ($results as $emailType => $recipients) {
$isHTML = $emailType == "html";
$i = 0;
foreach ($recipients as $recipient => $workspaces) {
$logInfo("Processed " . ++$i . " out of " . count($recipients) . " " . $emailType . " emails " . $recipient);
$body = $this->_buildDigest($workspaces, $emailType);
try {
$mailer->sendMail([$recipient], $subject, $body, null, null, $isHTML);
$success++;
} catch (Exception $e) {
$errors[] = "Failed to send email to " . $recipient . ": " . $e->getMessage();
}
}
}
// Clearing memory
unset($results);
try {
dibi::query('DELETE FROM [ajxp_mail_queue] WHERE [date_event] <= %s', $time);
} catch (DibiException $e) {
throw new AJXP_Exception($e->getMessage());
}
$output = array("report" => "Sent " . $success . " emails", "errors" => $errors);
echo json_encode($output);
//.........这里部分代码省略.........
示例9: publishPermissionsMask
/**
* @param string $actionName
* @param array $httpVars
* @param array $fileVars
*/
public function publishPermissionsMask($actionName, $httpVars, $fileVars)
{
$mask = array();
HTMLWriter::charsetHeader("application/json");
if (!AuthService::usersEnabled() || AuthService::getLoggedUser() == null) {
print json_encode($mask);
return;
}
$repoId = ConfService::getCurrentRepositoryId();
$role = AuthService::getLoggedUser()->mergedRole;
if ($role->hasMask($repoId)) {
$fullMask = $role->getMask($repoId);
foreach ($fullMask->flattenTree() as $path => $permission) {
// Do not show if "deny".
if ($permission->denies()) {
continue;
}
$mask[$path] = array("read" => $permission->canRead(), "write" => $permission->canWrite());
}
}
print json_encode($mask);
return;
}
示例10: switchAction
function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
if (preg_match('/MSIE 7/', $_SERVER['HTTP_USER_AGENT']) || preg_match('/MSIE 8/', $_SERVER['HTTP_USER_AGENT'])) {
// Force legacy theme for the moment
$this->pluginConf["GUI_THEME"] = "oxygen";
}
if (!defined("AJXP_THEME_FOLDER")) {
define("CLIENT_RESOURCES_FOLDER", AJXP_PLUGINS_FOLDER . "/gui.ajax/res");
define("AJXP_THEME_FOLDER", CLIENT_RESOURCES_FOLDER . "/themes/" . $this->pluginConf["GUI_THEME"]);
}
foreach ($httpVars as $getName => $getValue) {
${$getName} = AJXP_Utils::securePath($getValue);
}
if (isset($dir) && $action != "upload") {
$dir = SystemTextEncoding::fromUTF8($dir);
}
$mess = ConfService::getMessages();
switch ($action) {
//------------------------------------
// GET AN HTML TEMPLATE
//------------------------------------
case "get_template":
HTMLWriter::charsetHeader();
$folder = CLIENT_RESOURCES_FOLDER . "/html";
if (isset($httpVars["pluginName"])) {
$folder = AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/" . AJXP_Utils::securePath($httpVars["pluginName"]);
if (isset($httpVars["pluginPath"])) {
$folder .= "/" . AJXP_Utils::securePath($httpVars["pluginPath"]);
}
}
$crtTheme = $this->pluginConf["GUI_THEME"];
$thFolder = AJXP_THEME_FOLDER . "/html";
if (isset($template_name)) {
if (is_file($thFolder . "/" . $template_name)) {
include $thFolder . "/" . $template_name;
} else {
if (is_file($folder . "/" . $template_name)) {
include $folder . "/" . $template_name;
}
}
}
break;
//------------------------------------
// GET I18N MESSAGES
//------------------------------------
//------------------------------------
// GET I18N MESSAGES
//------------------------------------
case "get_i18n_messages":
$refresh = false;
if (isset($httpVars["lang"])) {
ConfService::setLanguage($httpVars["lang"]);
$refresh = true;
}
HTMLWriter::charsetHeader('text/javascript');
HTMLWriter::writeI18nMessagesClass(ConfService::getMessages($refresh));
break;
//------------------------------------
// SEND XML REGISTRY
//------------------------------------
//------------------------------------
// SEND XML REGISTRY
//------------------------------------
case "get_xml_registry":
$regDoc = AJXP_PluginsService::getXmlRegistry();
$changes = AJXP_Controller::filterActionsRegistry($regDoc);
if ($changes) {
AJXP_PluginsService::updateXmlRegistry($regDoc);
}
if (isset($_GET["xPath"])) {
$regPath = new DOMXPath($regDoc);
$nodes = $regPath->query($_GET["xPath"]);
AJXP_XMLWriter::header("ajxp_registry_part", array("xPath" => $_GET["xPath"]));
if ($nodes->length) {
print AJXP_XMLWriter::replaceAjxpXmlKeywords($regDoc->saveXML($nodes->item(0)));
}
AJXP_XMLWriter::close("ajxp_registry_part");
} else {
AJXP_Utils::safeIniSet("zlib.output_compression", "4096");
header('Content-Type: application/xml; charset=UTF-8');
print AJXP_XMLWriter::replaceAjxpXmlKeywords($regDoc->saveXML());
}
break;
//------------------------------------
// DISPLAY DOC
//------------------------------------
//------------------------------------
// DISPLAY DOC
//------------------------------------
case "display_doc":
HTMLWriter::charsetHeader();
echo HTMLWriter::getDocFile(AJXP_Utils::securePath(htmlentities($_GET["doc_file"])));
break;
//------------------------------------
// GET BOOT GUI
//------------------------------------
//------------------------------------
//.........这里部分代码省略.........
示例11: switchAction
public function switchAction($actionName, $httpVars, $fileVars)
{
$this->baseURL = rtrim($this->getFilteredOption("ETHERPAD_SERVER"), "/");
$this->apiKey = $this->getFilteredOption("ETHERPAD_APIKEY");
$userSelection = new UserSelection(ConfService::getRepository(), $httpVars);
if ($userSelection->isEmpty()) {
throw new Exception("Empty selection");
}
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(false)) {
return false;
}
$selectedNode = $userSelection->getUniqueNode();
$selectedNode->loadNodeInfo();
if (!$selectedNode->isLeaf()) {
throw new Exception("Cannot handle folders, please select a file!");
}
$nodeExtension = strtolower(pathinfo($selectedNode->getPath(), PATHINFO_EXTENSION));
// Determine pad ID
if ($nodeExtension == "pad") {
$padID = file_get_contents($selectedNode->getUrl());
} else {
// TRY TO LOAD PAD ID FROM NODE SHARED METADATA
$metadata = $selectedNode->retrieveMetadata("etherpad", AJXP_METADATA_ALLUSERS, AJXP_METADATA_SCOPE_GLOBAL, false);
if (isset($metadata["pad_id"])) {
$padID = $metadata["pad_id"];
} else {
$padID = AJXP_Utils::generateRandomString();
$selectedNode->setMetadata("etherpad", array("pad_id" => $padID), AJXP_METADATA_ALLUSERS, AJXP_METADATA_SCOPE_GLOBAL, false);
}
}
require_once "etherpad-client/etherpad-lite-client.php";
$client = new EtherpadLiteClient($this->apiKey, $this->baseURL . "/api");
$loggedUser = AuthService::getLoggedUser();
$userName = $loggedUser->getId();
$userLabel = $loggedUser->mergedRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, $userName);
$res = $client->createAuthorIfNotExistsFor($userName, $userLabel);
$authorID = $res->authorID;
$res2 = $client->createGroupIfNotExistsFor($loggedUser->getGroupPath());
$groupID = $res2->groupID;
$fullId = $groupID . "\$" . $padID;
if ($actionName == "etherpad_create") {
$resP = $client->listPads($groupID);
$currentContent = file_get_contents($selectedNode->getUrl());
if ($nodeExtension == "html" && strpos($currentContent, "<html>") === false) {
$currentContent = "<html><head></head><body>{$currentContent}</body></html>";
}
if (!in_array($fullId, $resP->padIDs)) {
$client->createGroupPad($groupID, $padID, null);
if ($nodeExtension == "html" && !empty($currentContent)) {
$client->setHTML($fullId, $currentContent);
} else {
if ($nodeExtension != "pad") {
$client->setText($fullId, $currentContent);
}
}
} else {
if ($nodeExtension != "pad") {
// If someone is already connected, do not override.
$existingAuthors = $client->listAuthorsOfPad($fullId);
if (!count($existingAuthors->authorIDs)) {
if ($nodeExtension == "html" && !empty($currentContent)) {
$client->setHTML($fullId, $currentContent);
} else {
$client->setText($fullId, $currentContent);
}
}
}
}
$res4 = $client->createSession($groupID, $authorID, time() + 14400);
$sessionID = $res4->sessionID;
setcookie('sessionID', $sessionID, null, "/");
$padID = $groupID . '$' . $padID;
$data = array("url" => $this->baseURL . "/p/" . $padID, "padID" => $padID, "sessionID" => $sessionID);
HTMLWriter::charsetHeader('application/json');
echo json_encode($data);
} else {
if ($actionName == "etherpad_save") {
$padID = $httpVars["pad_id"];
if ($nodeExtension == "html" || $nodeExtension == "pad") {
$res = $client->getHTML($padID);
$content = $res->html;
} else {
$res = $client->getText($padID);
$content = $res->text;
}
if ($nodeExtension == "pad") {
// Create a new file and save the content in it.
$origUrl = $selectedNode->getUrl();
$mess = ConfService::getMessages();
$dateStamp = date(" Y-m-d H:i", time());
$startUrl = preg_replace('"\\.pad$"', $dateStamp . '.html', $origUrl);
$newNode = new AJXP_Node($startUrl);
AJXP_Controller::applyHook("node.before_create", array($newNode, strlen($content)));
file_put_contents($newNode->getUrl(), $content);
AJXP_Controller::applyHook("node.change", array(null, $newNode));
} else {
AJXP_Controller::applyHook("node.before_change", array($selectedNode, strlen($content)));
file_put_contents($selectedNode->getUrl(), $content);
clearstatcache(true, $selectedNode->getUrl());
//.........这里部分代码省略.........
示例12: var_dump
$found = true;
break;
}
}
if (!$found) {
echo "\n\nNo change detected reflecting file deletion, this is not normal, exiting.";
var_dump($data);
exit;
}
} else {
echo "\n\nData not decoded as JSON, normal?";
var_dump($data);
exit;
}
echo "<script>window.scrollTo(0, 100000);</script>";
//echo "</pre>";
} else {
$host = $_SERVER["HTTP_HOST"];
$protocol = $_SERVER["HTTPS"] === "on" ? "https" : "http";
$path = dirname($_SERVER["REQUEST_URI"]);
HTMLWriter::charsetHeader();
require AJXP_TESTS_FOLDER . "/api_test.phtml";
}
} else {
$outputArray = array();
$testedParams = array();
$passed = true;
$passed = AJXP_Utils::runTests($outputArray, $testedParams);
AJXP_Utils::testResultsToTable($outputArray, $testedParams, true);
AJXP_Utils::testResultsToFile($outputArray, $testedParams);
}
示例13: render
/**
* @param array $data
* @param array $options
* @param ShareStore $shareStore
*/
public static function render($data, $options, $shareStore)
{
if (isset($data["SECURITY_MODIFIED"]) && $data["SECURITY_MODIFIED"] === true) {
self::renderError($data, "false");
return;
}
// create driver from $data
$className = $data["DRIVER"] . "AccessDriver";
$u = parse_url($_SERVER["REQUEST_URI"]);
$shortHash = pathinfo(basename($u["path"]), PATHINFO_FILENAME);
// Load language messages
$language = ConfService::getLanguage();
if (isset($_GET["lang"])) {
$language = basename($_GET["lang"]);
}
$messages = array();
if (is_file(dirname(__FILE__) . "/res/i18n/" . $language . ".php")) {
include dirname(__FILE__) . "/res/i18n/" . $language . ".php";
} else {
include dirname(__FILE__) . "/res/i18n/en.php";
}
if (isset($mess)) {
$messages = $mess;
}
$AJXP_LINK_HAS_PASSWORD = false;
$AJXP_LINK_BASENAME = SystemTextEncoding::toUTF8(basename($data["FILE_PATH"]));
AJXP_PluginsService::getInstance()->initActivePlugins();
ConfService::setLanguage($language);
$mess = ConfService::getMessages();
if ($shareStore->isShareExpired($shortHash, $data)) {
self::renderError(array(), $shortHash, $mess["share_center.165"]);
return;
}
$customs = array("title", "legend", "legend_pass", "background_attributes_1", "text_color", "background_color", "textshadow_color");
$images = array("button", "background_1");
$confs = $options;
$confs["CUSTOM_SHAREPAGE_BACKGROUND_ATTRIBUTES_1"] = "background-repeat:repeat;background-position:50% 50%;";
$confs["CUSTOM_SHAREPAGE_BACKGROUND_1"] = "plugins/action.share/res/hi-res/02.jpg";
$confs["CUSTOM_SHAREPAGE_TEXT_COLOR"] = "#ffffff";
$confs["CUSTOM_SHAREPAGE_TEXTSHADOW_COLOR"] = "rgba(0,0,0,5)";
foreach ($customs as $custom) {
$varName = "CUSTOM_SHAREPAGE_" . strtoupper($custom);
${$varName} = $confs[$varName];
}
$dlFolder = realpath(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"));
foreach ($images as $custom) {
$varName = "CUSTOM_SHAREPAGE_" . strtoupper($custom);
if (!empty($confs[$varName])) {
if (strpos($confs[$varName], "plugins/") === 0 && is_file(AJXP_INSTALL_PATH . "/" . $confs[$varName])) {
$realFile = AJXP_INSTALL_PATH . "/" . $confs[$varName];
copy($realFile, $dlFolder . "/binary-" . basename($realFile));
${$varName} = "binary-" . basename($realFile);
} else {
${$varName} = "binary-" . $confs[$varName];
if (is_file($dlFolder . "/binary-" . $confs[$varName])) {
continue;
}
$copiedImageName = $dlFolder . "/binary-" . $confs[$varName];
$imgFile = fopen($copiedImageName, "wb");
ConfService::getConfStorageImpl()->loadBinary(array(), $confs[$varName], $imgFile);
fclose($imgFile);
}
}
}
HTMLWriter::charsetHeader();
// Check password
if (strlen($data["PASSWORD"])) {
if (!isset($_POST['password']) || $_POST['password'] != $data["PASSWORD"]) {
$AJXP_LINK_HAS_PASSWORD = true;
$AJXP_LINK_WRONG_PASSWORD = isset($_POST['password']) && $_POST['password'] != $data["PASSWORD"];
include AJXP_INSTALL_PATH . "/plugins/action.share/res/public_links.php";
$res = '<div style="position: absolute;z-index: 10000; bottom: 0; right: 0; color: #666;font-family: HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size: 13px;text-align: right;padding: 6px; line-height: 20px;text-shadow: 0px 1px 0px white;" class="no_select_bg"><br>Build your own box with Pydio : <a style="color: #000000;" target="_blank" href="http://pyd.io/">http://pyd.io/</a><br/>Community - Free non supported version © C. du Jeu 2008-2014 </div>';
AJXP_Controller::applyHook("tpl.filter_html", array(&$res));
echo $res;
return;
}
} else {
if (!isset($_GET["dl"])) {
include AJXP_INSTALL_PATH . "/plugins/action.share/res/public_links.php";
$res = '<div style="position: absolute;z-index: 10000; bottom: 0; right: 0; color: #666;font-family: HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size: 13px;text-align: right;padding: 6px; line-height: 20px;text-shadow: 0px 1px 0px white;" class="no_select_bg"><br>Build your own box with Pydio : <a style="color: #000000;" target="_blank" href="http://pyd.io/">http://pyd.io/</a><br/>Community - Free non supported version © C. du Jeu 2008-2014 </div>';
AJXP_Controller::applyHook("tpl.filter_html", array(&$res));
echo $res;
return;
}
}
$filePath = AJXP_INSTALL_PATH . "/plugins/access." . $data["DRIVER"] . "/class." . $className . ".php";
if (!is_file($filePath)) {
die("Warning, cannot find driver for conf storage! ({$className}, {$filePath})");
}
require_once $filePath;
$driver = new $className($data["PLUGIN_ID"], $data["BASE_DIR"]);
$driver->loadManifest();
//$hash = md5(serialize($data));
$shareStore->incrementDownloadCounter($shortHash);
//AuthService::logUser($data["OWNER_ID"], "", true);
//.........这里部分代码省略.........
示例14: switchAction
//.........这里部分代码省略.........
$davData = array();
}
$davData["ACTIVE"] = $activate;
}
if (!empty($httpVars["webdav_pass"])) {
$password = $httpVars["webdav_pass"];
if (function_exists('mcrypt_encrypt')) {
$user = $userObject->getId();
$secret = defined("AJXP_SECRET_KEY") ? AJXP_SAFE_SECRET_KEY : "CDAFx¨op#";
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($user . $secret), $password, MCRYPT_MODE_ECB, $iv));
}
$davData["PASS"] = $password;
}
$userObject->setPref("AJXP_WEBDAV_DATA", $davData);
$userObject->save("user");
}
$davData = $userObject->getPref("AJXP_WEBDAV_DATA");
if (!empty($davData)) {
$webdavActive = isset($davData["ACTIVE"]) && $davData["ACTIVE"] === true;
$passSet = isset($davData["PASS"]);
}
$repoList = ConfService::getRepositoriesList();
$davRepos = array();
$loggedUser = AuthService::getLoggedUser();
foreach ($repoList as $repoIndex => $repoObject) {
$accessType = $repoObject->getAccessType();
$driver = AJXP_PluginsService::getInstance()->getPluginByTypeName("access", $accessType);
if (is_a($driver, "AjxpWebdavProvider") && ($loggedUser->canRead($repoIndex) || $loggedUser->canWrite($repoIndex))) {
$davRepos[$repoIndex] = $webdavBaseUrl . "" . ($repoObject->getSlug() == null ? $repoObject->getId() : $repoObject->getSlug());
}
}
$prefs = array("webdav_active" => $webdavActive, "password_set" => $passSet, "webdav_base_url" => $webdavBaseUrl, "webdav_repositories" => $davRepos);
HTMLWriter::charsetHeader("application/json");
print json_encode($prefs);
break;
case "get_user_template_logo":
$tplId = $httpVars["template_id"];
$iconFormat = $httpVars["icon_format"];
$repo = ConfService::getRepositoryById($tplId);
$logo = $repo->getOption("TPL_ICON_" . strtoupper($iconFormat));
if (isset($logo) && is_file(AJXP_DATA_PATH . "/plugins/core.conf/tpl_logos/" . $logo)) {
header("Content-Type: " . AJXP_Utils::getImageMimeType($logo) . "; name=\"" . $logo . "\"");
header("Content-Length: " . filesize(AJXP_DATA_PATH . "/plugins/core.conf/tpl_logos/" . $logo));
header('Pragma:');
header('Cache-Control: public');
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 10000) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5 * 24 * 3600) . " GMT");
readfile(AJXP_DATA_PATH . "/plugins/core.conf/tpl_logos/" . $logo);
} else {
$logo = "default_template_logo-" . ($iconFormat == "small" ? 16 : 22) . ".png";
header("Content-Type: " . AJXP_Utils::getImageMimeType($logo) . "; name=\"" . $logo . "\"");
header("Content-Length: " . filesize(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/core.conf/" . $logo));
header('Pragma:');
header('Cache-Control: public');
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 10000) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5 * 24 * 3600) . " GMT");
readfile(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/core.conf/" . $logo);
}
break;
case "get_user_templates_definition":
AJXP_XMLWriter::header("repository_templates");
$repositories = ConfService::getRepositoriesList();
$pServ = AJXP_PluginsService::getInstance();
foreach ($repositories as $repo) {
if (!$repo->isTemplate) {
示例15: extractExif
public function extractExif($actionName, $httpVars, $fileVars)
{
$repo = $this->accessDriver->repository;
$userSelection = new UserSelection($this->accessDriver->repository, $httpVars);
$repo->detectStreamWrapper(true);
$selectedNode = $userSelection->getUniqueNode();
$realFile = AJXP_MetaStreamWrapper::getRealFSReference($selectedNode->getUrl());
AJXP_Utils::safeIniSet('exif.encode_unicode', 'UTF-8');
$exifData = @exif_read_data($realFile, 0, TRUE);
if ($exifData === false || !is_array($exifData)) {
return;
}
if ($exifData !== false && isset($exifData["GPS"])) {
$exifData["COMPUTED_GPS"] = $this->convertGPSData($exifData);
}
$iptc = $this->extractIPTC($realFile);
if (count($iptc)) {
$exifData["IPTC"] = $iptc;
}
$excludeTags = array();
// array("componentsconfiguration", "filesource", "scenetype", "makernote", "datadump");
$format = "xml";
if (isset($httpVars["format"]) && $httpVars["format"] == "json") {
$format = "json";
}
$filteredData = array();
foreach ($exifData as $section => $data) {
$filteredData[$section] = array();
foreach ($data as $key => $value) {
if (is_array($value)) {
$value = implode(",", $value);
}
if (in_array(strtolower($key), $excludeTags)) {
continue;
}
if (strpos($key, "UndefinedTag:") === 0) {
continue;
}
$value = preg_replace('/[^[:print:]]/', '', $value);
$filteredData[$section][$key] = SystemTextEncoding::toUTF8($value);
}
}
if ($format == "xml") {
AJXP_XMLWriter::header("metadata", array("file" => $selectedNode->getPath(), "type" => "EXIF"));
foreach ($filteredData as $section => $data) {
print "<exifSection name='{$section}'>";
foreach ($data as $key => $value) {
print "<exifTag name=\"{$key}\">" . AJXP_Utils::xmlEntities($value) . "</exifTag>";
}
print "</exifSection>";
}
AJXP_XMLWriter::close("metadata");
} else {
HTMLWriter::charsetHeader("application/json");
echo json_encode($filteredData);
}
}