本文整理汇总了PHP中SystemTextEncoding::fromUTF8方法的典型用法代码示例。如果您正苦于以下问题:PHP SystemTextEncoding::fromUTF8方法的具体用法?PHP SystemTextEncoding::fromUTF8怎么用?PHP SystemTextEncoding::fromUTF8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SystemTextEncoding
的用法示例。
在下文中一共展示了SystemTextEncoding::fromUTF8方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
public function preProcess($action, &$httpVars, &$fileVars)
{
if (!isset($httpVars["xhr_uploader"])) {
return false;
}
AJXP_Logger::debug("SimpleUpload::preProcess", $httpVars);
$headersCheck = isset($_SERVER['CONTENT_TYPE'], $_SERVER['CONTENT_LENGTH'], $_SERVER['HTTP_X_FILE_SIZE'], $_SERVER['HTTP_X_FILE_NAME']) && $_SERVER['CONTENT_TYPE'] === 'multipart/form-data' && $_SERVER['CONTENT_LENGTH'] === $_SERVER['HTTP_X_FILE_SIZE'];
$fileNameH = $_SERVER['HTTP_X_FILE_NAME'];
$fileSizeH = $_SERVER['HTTP_X_FILE_SIZE'];
if ($headersCheck) {
// create the object and assign property
$fileVars["userfile_0"] = array("input_upload" => true, "name" => SystemTextEncoding::fromUTF8(basename($fileNameH)), "size" => $fileSizeH);
} else {
exit("Warning, missing headers!");
}
}
示例2: preProcess
public function preProcess($action, &$httpVars, &$fileVars)
{
if (!isset($httpVars["input_stream"]) || isset($httpVars["force_post"])) {
return false;
}
$headersCheck = isset($_SERVER['CONTENT_LENGTH'], $_SERVER['HTTP_X_FILE_NAME']);
if (isset($_SERVER['HTTP_X_FILE_SIZE'])) {
if ($_SERVER['CONTENT_LENGTH'] != $_SERVER['HTTP_X_FILE_SIZE']) {
exit('Warning, wrong headers');
}
}
$fileNameH = $_SERVER['HTTP_X_FILE_NAME'];
$fileSizeH = $_SERVER['CONTENT_LENGTH'];
if (dirname($httpVars["dir"]) == "/" && basename($httpVars["dir"]) == $fileNameH) {
$httpVars["dir"] = "/";
}
$this->logDebug("SimpleUpload::preProcess", $httpVars);
if ($headersCheck) {
// create the object and assign property
$fileVars["userfile_0"] = array("input_upload" => true, "name" => SystemTextEncoding::fromUTF8(basename($fileNameH)), "size" => $fileSizeH);
} else {
exit("Warning, missing headers!");
}
}
示例3: preProcess
public function preProcess($action, &$httpVars, &$fileVars)
{
$repository = ConfService::getRepository();
$skipDecoding = false;
if ($repository->detectStreamWrapper(false)) {
$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
$streamData = $plugin->detectStreamWrapper(true);
if ($streamData["protocol"] == "ajxp.ftp" || $streamData["protocol"] == "ajxp.remotefs") {
AJXP_Logger::debug("Skip decoding");
$skipDecoding = true;
}
}
if (isset($fileVars["Filedata"])) {
self::$active = true;
AJXP_Logger::debug("Dir before base64", $httpVars);
$httpVars["dir"] = base64_decode(urldecode($httpVars["dir"]));
if (!$skipDecoding) {
$fileVars["Filedata"]["name"] = SystemTextEncoding::fromUTF8($fileVars["Filedata"]["name"]);
}
$fileVars["userfile_0"] = $fileVars["Filedata"];
unset($fileVars["Filedata"]);
AJXP_Logger::debug("Setting FlexProc active");
}
}
示例4: client
public function client($params, $purl)
{
//var_dump($params);
static $regexp = array('^added interface ip=(.*) bcast=(.*) nmask=(.*)$' => 'skip', 'Anonymous login successful' => 'skip', '^Domain=\\[(.*)\\] OS=\\[(.*)\\] Server=\\[(.*)\\]$' => 'skip', '^\\tSharename[ ]+Type[ ]+Comment$' => 'shares', '^\\t---------[ ]+----[ ]+-------$' => 'skip', '^\\tServer [ ]+Comment$' => 'servers', '^\\t---------[ ]+-------$' => 'skip', '^\\tWorkgroup[ ]+Master$' => 'workg', '^\\t(.*)[ ]+(Disk|IPC)[ ]+IPC.*$' => 'skip', '^\\tIPC\\\\$(.*)[ ]+IPC' => 'skip', '^\\t(.*)[ ]+(Disk)[ ]+(.*)$' => 'share', '^\\t(.*)[ ]+(Printer)[ ]+(.*)$' => 'skip', '([0-9]+) blocks of size ([0-9]+)\\. ([0-9]+) blocks available' => 'skip', 'Got a positive name query response from ' => 'skip', '^(session setup failed): (.*)$' => 'error', '^(.*): ERRSRV - ERRbadpw' => 'error', '^Error returning browse list: (.*)$' => 'error', '^tree connect failed: (.*)$' => 'error', '^(Connection to .* failed)$' => 'error', '^NT_STATUS_(.*) ' => 'error', '^NT_STATUS_(.*)\\$' => 'error', 'ERRDOS - ERRbadpath \\((.*).\\)' => 'error', 'cd (.*): (.*)$' => 'error', '^cd (.*): NT_STATUS_(.*)' => 'error', '^\\t(.*)$' => 'srvorwg', '^([0-9]+)[ ]+([0-9]+)[ ]+(.*)$' => 'skip', '^Job ([0-9]+) cancelled' => 'skip', '^[ ]+(.*)[ ]+([0-9]+)[ ]+(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[ ](Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[ ]+([0-9]+)[ ]+([0-9]{2}:[0-9]{2}:[0-9]{2})[ ]([0-9]{4})$' => 'files', '^message start: ERRSRV - (ERRmsgoff)' => 'error');
if (SMB4PHP_AUTHMODE == 'env') {
putenv("USER={$purl['user']}%{$purl['pass']}");
$auth = '';
} else {
//$purl['pass'] = preg_replace('/@/', '\@', $purl['pass']);
$auth = $purl['user'] != '' ? ' -U ' . escapeshellarg($purl['user'] . '__SEP__' . $purl['pass']) : '';
$auth = str_replace("__SEP__", "%", $auth);
//self::debug($auth);
}
if ($purl['domain'] != '') {
$auth .= ' -W ' . escapeshellarg($purl['domain']);
}
$port = $purl['port'] != 139 ? ' -p ' . escapeshellarg($purl['port']) : '';
$options = '-O ' . escapeshellarg(SMB4PHP_SMBOPTIONS);
//self::debug($auth);
self::debug("SMBCLIENT", " -N {$options} {$port} {$options} {$params} 2>/dev/null [auth data]");
//self::debug("I just ran an smbclient call");
//$output = popen (SMB4PHP_SMBCLIENT." -N {$options} {$port} {$options} {$params} 2>/dev/null {$auth}", 'r');
$info = array();
if (PHP_OS == "WIN32" || PHP_OS == "WINNT" || PHP_OS == "Windows") {
$params = ConvSmbParameterToWinOs($params);
}
$cmd = SMB4PHP_SMBCLIENT . " -N {$options} {$port} {$options} {$params} {$auth}";
$descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "rw"));
$env = null;
if (defined('AJXP_LOCALE') && stripos(PHP_OS, "win") === false) {
$env = array("LC_ALL" => AJXP_LOCALE);
}
$process = proc_open($cmd, $descriptorspec, $pipes, null, $env);
if (is_resource($process)) {
fclose($pipes[0]);
$error = stream_get_contents($pipes[2]);
fclose($pipes[2]);
if ($error != "") {
$error = strtolower($error);
// common error
if (strstr($error, "command not found") !== false) {
fclose($pipes[1]);
throw new Exception($error);
} else {
if (strstr($error, "domain") !== false && strstr($error, "os") !== false) {
self::debug("Smbclient alternate stream : " . $error);
} else {
AJXP_Logger::error(__CLASS__, "Smbclient error", $error);
}
}
}
$output = $pipes[1];
}
if (isset($output) && is_resource($output)) {
while ($line = fgets($output, 4096)) {
if (PHP_OS == "WIN32" || PHP_OS == "WINNT" || PHP_OS == "Windows") {
$line = SystemTextEncoding::fromUTF8($line);
}
list($tag, $regs, $i) = array('skip', array(), array());
reset($regexp);
foreach ($regexp as $r => $t) {
if (preg_match('/' . $r . '/', $line, $regs)) {
$tag = $t;
break;
}
}
switch ($tag) {
case 'skip':
continue;
case 'shares':
$mode = 'shares';
break;
case 'servers':
$mode = 'servers';
break;
case 'workg':
$mode = 'workgroups';
break;
case 'share':
list($name, $type) = array(trim(substr($line, 1, 15)), trim(strtolower(substr($line, 17, 10))));
$i = $type != 'disk' && preg_match('/^(.*) Disk/', $line, $regs) ? array(trim($regs[1]), 'disk') : array($name, 'disk');
break;
case 'srvorwg':
list($name, $master) = array(strtolower(trim(substr($line, 1, 21))), strtolower(trim(substr($line, 22))));
$i = $mode == 'servers' ? array($name, "server") : array($name, "workgroup", $master);
break;
case 'files':
list($attr, $name) = preg_match("/^(.*)[ ]+([D|A|H|S|R]+)\$/", trim($regs[1]), $regs2) ? array(trim($regs2[2]), trim($regs2[1])) : array('', trim($regs[1]));
list($his, $im) = array(explode(':', $regs[6]), 1 + strpos("JanFebMarAprMayJunJulAugSepOctNovDec", $regs[4]) / 3);
$i = $name != '.' && $name != '..' ? array($name, strpos($attr, 'D') === FALSE ? 'file' : 'folder', 'attr' => $attr, 'size' => intval($regs[2]), 'time' => mktime($his[0], $his[1], $his[2], $im, $regs[5], $regs[7])) : array();
break;
case 'error':
if (strstr($regs[1], "NO_SUCH_FILE") == 0) {
return "NOT_FOUND";
}
trigger_error($regs[1], E_USER_ERROR);
}
if ($i) {
switch ($i[1]) {
case 'file':
//.........这里部分代码省略.........
示例5: updateNodeIndex
/**
*
* Hooked to node.change, this will update the index
* if $oldNode = null => create node $newNode
* if $newNode = null => delete node $oldNode
* Else copy or move oldNode to newNode.
*
* @param AJXP_Node $oldNode
* @param AJXP_Node $newNode
* @param Boolean $copy
* @param bool $recursive
*/
public function updateNodeIndex($oldNode, $newNode = null, $copy = false, $recursive = false)
{
if ($oldNode == null) {
$this->loadIndex($newNode->getRepositoryId(), true, $newNode->getUser());
} else {
$this->loadIndex($oldNode->getRepositoryId(), true, $oldNode->getUser());
}
if ($oldNode != null && $copy == false) {
$oldDocId = $this->getIndexedDocumentId($oldNode);
if ($oldDocId != null) {
$this->currentType->deleteById($oldDocId);
$childrenHits = $this->getIndexedChildrenDocuments($newNode);
if ($childrenHits != null) {
$childrenHits = $childrenHits->getResults();
foreach ($childrenHits as $hit) {
$this->currentType->deleteById($hit->getId());
}
}
}
}
if ($newNode != null) {
// Make sure it does not already exists anyway
$newDocId = $this->getIndexedDocumentId($newNode);
if ($newDocId != null) {
try {
$this->currentType->deleteById($newDocId);
} catch (Elastica\Exception\NotFoundException $eEx) {
$this->logError(__FUNCTION__, "Trying to delete a non existing document");
}
$childrenHits = $this->getIndexedChildrenDocuments($newNode);
if ($childrenHits != null) {
$childrenHits = $childrenHits->getResults();
foreach ($childrenHits as $hit) {
try {
$this->currentType->deleteById($hit->getId());
} catch (Elastica\Exception\NotFoundException $eEx) {
$this->logError(__FUNCTION__, "Trying to delete a non existing document");
}
}
}
}
$this->createIndexedDocument($newNode);
if ($recursive && $oldNode == null && is_dir($newNode->getUrl())) {
$this->recursiveIndexation($newNode->getUrl());
}
}
if ($oldNode != null && $newNode != null && is_dir($newNode->getUrl())) {
// Copy / Move / Rename
// Get old node children docs, and update them manually, no need to scan real directory
$childrenHits = $this->getIndexedChildrenDocuments($oldNode);
if ($childrenHits != null) {
$childrenHits = $childrenHits->getResults();
foreach ($childrenHits as $hit) {
$oldChildURL = $this->currentType->getDocument($hit->getId())->get("node_url");
if ($copy == false) {
$this->currentType->deleteById($hit->getId());
}
$newChildURL = str_replace(SystemTextEncoding::toUTF8($oldNode->getUrl()), SystemTextEncoding::toUTF8($newNode->getUrl()), $oldChildURL);
$newChildURL = SystemTextEncoding::fromUTF8($newChildURL);
$this->createIndexedDocument(new AJXP_Node($newChildURL));
}
}
}
}
示例6: renameAction
function renameAction($actionName, $httpVars)
{
$filePath = SystemTextEncoding::fromUTF8($httpVars["file"]);
$newFilename = SystemTextEncoding::fromUTF8($httpVars["filename_new"]);
return $this->rename($filePath, $newFilename);
}
示例7: foreach
}
foreach ($_POST as $getName => $getValue) {
${$getName} = Utils::securePath($getValue);
}
$selection = new UserSelection();
$selection->initFromHttpVars();
if (isset($action) || isset($get_action)) {
$action = isset($get_action) ? $get_action : $action;
} else {
$action = "";
}
if (isset($dir) && $action != "upload") {
$dir = SystemTextEncoding::fromUTF8($dir);
}
if (isset($dest)) {
$dest = SystemTextEncoding::fromUTF8($dest);
}
//------------------------------------------------------------
// SPECIAL HANDLING FOR FANCY UPLOADER RIGHTS FOR THIS ACTION
//------------------------------------------------------------
if (AuthService::usersEnabled()) {
$loggedUser = AuthService::getLoggedUser();
if ($action == "upload" && ($loggedUser == null || !$loggedUser->canWrite(ConfService::getCurrentRootDirIndex() . "")) && isset($_FILES['Filedata'])) {
header('HTTP/1.0 ' . '410 Not authorized');
die('Error 410 Not authorized!');
}
}
// Look for the action in the "fixed" drivers : AjxpClient, Auth & Conf
$ajxpDriver = new AJXP_ClientDriver(ConfService::getRepository());
$ajxpDriver->applyIfExistsAndExit($action, array_merge($_GET, $_POST), $_FILES);
$authDriver = ConfService::getAuthDriverImpl();
示例8: switchAction
public function switchAction($action, $httpVars, $filesVars)
{
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(true)) {
return false;
}
$selection = new UserSelection($repository, $httpVars);
$selectedNode = $selection->getUniqueNode();
$selectedNodeUrl = $selectedNode->getUrl();
if ($action == "post_to_server") {
// Backward compat
if (strpos($httpVars["file"], "base64encoded:") !== 0) {
$legacyFilePath = AJXP_Utils::decodeSecureMagic(base64_decode($httpVars["file"]));
$selectedNode = new AJXP_Node($selection->currentBaseUrl() . $legacyFilePath);
$selectedNodeUrl = $selectedNode->getUrl();
}
$target = rtrim(base64_decode($httpVars["parent_url"]), '/') . "/plugins/editor.pixlr";
$tmp = AJXP_MetaStreamWrapper::getRealFSReference($selectedNodeUrl);
$tmp = SystemTextEncoding::fromUTF8($tmp);
$this->logInfo('Preview', 'Sending content of ' . $selectedNodeUrl . ' to Pixlr server.', array("files" => $selectedNodeUrl));
AJXP_Controller::applyHook("node.read", array($selectedNode));
$saveTarget = $target . "/fake_save_pixlr.php";
if ($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())) {
$saveTarget = $target . "/fake_save_pixlr_" . md5($httpVars["secure_token"]) . ".php";
}
$params = array("referrer" => "Pydio", "method" => "get", "loc" => ConfService::getLanguage(), "target" => $saveTarget, "exit" => $target . "/fake_close_pixlr.php", "title" => urlencode(basename($selectedNodeUrl)), "locktarget" => "false", "locktitle" => "true", "locktype" => "source");
require_once AJXP_BIN_FOLDER . "/http_class/http_class.php";
$arguments = array();
$httpClient = new http_class();
$httpClient->request_method = "POST";
$httpClient->GetRequestArguments("https://pixlr.com/editor/", $arguments);
$arguments["PostValues"] = $params;
$arguments["PostFiles"] = array("image" => array("FileName" => $tmp, "Content-Type" => "automatic/name"));
$err = $httpClient->Open($arguments);
if (empty($err)) {
$err = $httpClient->SendRequest($arguments);
if (empty($err)) {
$response = "";
while (true) {
$header = array();
$error = $httpClient->ReadReplyHeaders($header, 1000);
if ($error != "" || $header != null) {
break;
}
$response .= $header;
}
}
}
header("Location: {$header['location']}");
//$response");
} else {
if ($action == "retrieve_pixlr_image") {
$file = AJXP_Utils::decodeSecureMagic($httpVars["original_file"]);
$selectedNode = new AJXP_Node($selection->currentBaseUrl() . $file);
$selectedNode->loadNodeInfo();
$this->logInfo('Edit', 'Retrieving content of ' . $file . ' from Pixlr server.', array("files" => $file));
AJXP_Controller::applyHook("node.before_change", array(&$selectedNode));
$url = $httpVars["new_url"];
$urlParts = parse_url($url);
$query = $urlParts["query"];
if ($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())) {
$scriptName = basename($urlParts["path"]);
$token = str_replace(array("fake_save_pixlr_", ".php"), "", $scriptName);
if ($token != md5($httpVars["secure_token"])) {
throw new AJXP_Exception("Invalid Token, this could mean some security problem!");
}
}
$params = array();
parse_str($query, $params);
$image = $params['image'];
$headers = get_headers($image, 1);
$content_type = explode("/", $headers['Content-Type']);
if ($content_type[0] != "image") {
throw new AJXP_Exception("Invalid File Type");
}
$content_length = intval($headers["Content-Length"]);
if ($content_length != 0) {
AJXP_Controller::applyHook("node.before_change", array(&$selectedNode, $content_length));
}
$orig = fopen($image, "r");
$target = fopen($selectedNode->getUrl(), "w");
if (is_resource($orig) && is_resource($target)) {
while (!feof($orig)) {
fwrite($target, fread($orig, 4096));
}
fclose($orig);
fclose($target);
}
clearstatcache(true, $selectedNode->getUrl());
$selectedNode->loadNodeInfo(true);
AJXP_Controller::applyHook("node.change", array(&$selectedNode, &$selectedNode));
}
}
}
示例9: extractExif
public function extractExif($actionName, $httpVars, $fileVars)
{
$userSelection = new UserSelection();
$userSelection->initFromHttpVars($httpVars);
$repo = ConfService::getRepository();
$repo->detectStreamWrapper();
$wrapperData = $repo->streamData;
$urlBase = $wrapperData["protocol"] . "://" . $repo->getId();
$realFile = call_user_func(array($wrapperData["classname"], "getRealFSReference"), $urlBase . SystemTextEncoding::fromUTF8($httpVars["file"]));
ini_set('exif.encode_unicode', 'UTF-8');
$exifData = exif_read_data($realFile, 0, TRUE);
if ($exifData !== false && isset($exifData["GPS"])) {
$exifData["COMPUTED_GPS"] = $this->convertGPSData($exifData);
}
$excludeTags = array("componentsconfiguration", "filesource", "scenetype", "makernote");
AJXP_XMLWriter::header("metadata", array("file" => $httpVars["file"], "type" => "EXIF"));
foreach ($exifData as $section => $data) {
print "<exifSection name='{$section}'>";
foreach ($data as $key => $value) {
if (in_array(strtolower($key), $excludeTags)) {
continue;
}
if (!is_numeric($value)) {
$value = $this->string_format($value);
}
print "<exifTag name=\"{$key}\">" . $value . "</exifTag>";
}
print "</exifSection>";
}
AJXP_XMLWriter::close("metadata");
}
示例10: crossRepositoryCopy
function crossRepositoryCopy($httpVars)
{
ConfService::detectRepositoryStreams(true);
$mess = ConfService::getMessages();
$selection = new UserSelection();
$selection->initFromHttpVars($httpVars);
$files = $selection->getFiles();
$accessType = $this->repository->getAccessType();
$repositoryId = $this->repository->getId();
$origStreamURL = "ajxp.{$accessType}://{$repositoryId}";
$destRepoId = $httpVars["dest_repository_id"];
$destRepoObject = ConfService::getRepositoryById($destRepoId);
$destRepoAccess = $destRepoObject->getAccessType();
$destStreamURL = "ajxp.{$destRepoAccess}://{$destRepoId}";
// Check rights
if (AuthService::usersEnabled()) {
$loggedUser = AuthService::getLoggedUser();
if (!$loggedUser->canRead($repositoryId) || !$loggedUser->canWrite($destRepoId) || isset($httpVars["moving_files"]) && !$loggedUser->canWrite($repositoryId)) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess[364]);
AJXP_XMLWriter::close();
exit(1);
}
}
$messages = array();
foreach ($files as $file) {
$origFile = $origStreamURL . $file;
$destFile = $destStreamURL . SystemTextEncoding::fromUTF8($httpVars["dest"]) . "/" . basename($file);
$origHandler = fopen($origFile, "r");
$destHandler = fopen($destFile, "w");
if ($origHandler === false || $destHandler === false) {
$errorMessages[] = AJXP_XMLWriter::sendMessage(null, $mess[114] . " ({$origFile} to {$destFile})", false);
continue;
}
while (!feof($origHandler)) {
fwrite($destHandler, fread($origHandler, 4096));
}
fflush($destHandler);
fclose($origHandler);
fclose($destHandler);
$messages[] = $mess[34] . " " . SystemTextEncoding::toUTF8(basename($origFile)) . " " . (isset($httpVars["moving_files"]) ? $mess[74] : $mess[73]) . " " . SystemTextEncoding::toUTF8($destFile);
}
AJXP_XMLWriter::header();
if (count($errorMessages)) {
AJXP_XMLWriter::sendMessage(null, join("\n", $errorMessages), true);
}
AJXP_XMLWriter::sendMessage(join("\n", $messages), null, true);
AJXP_XMLWriter::close();
exit(0);
}
示例11: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
$repo = ConfService::getRepository();
if (!isset($this->actions[$action])) {
return;
}
parent::accessPreprocess($action, $httpVars, $fileVars);
$xmlBuffer = "";
foreach ($httpVars as $getName => $getValue) {
${$getName} = AJXP_Utils::securePath($getValue);
}
$selection = new UserSelection();
$selection->initFromHttpVars($httpVars);
if (isset($dir) && $action != "upload") {
$safeDir = $dir;
$dir = SystemTextEncoding::fromUTF8($dir);
}
// FILTER DIR PAGINATION ANCHOR
if (isset($dir) && strstr($dir, "%23") !== false) {
$parts = explode("%23", $dir);
$dir = $parts[0];
$page = $parts[1];
}
if (isset($dest)) {
$dest = SystemTextEncoding::fromUTF8($dest);
}
$mess = ConfService::getMessages();
switch ($action) {
//------------------------------------
// ONLINE EDIT
//------------------------------------
case "edit_record":
$isNew = false;
if (isset($record_is_new) && $record_is_new == "true") {
$isNew = true;
}
$tableName = $_POST["table_name"];
$pkName = $_POST["pk_name"];
$query = "";
$arrValues = array();
foreach ($_POST as $key => $value) {
if (substr($key, 0, strlen("ajxp_mysql_")) == "ajxp_mysql_") {
$newKey = substr($key, strlen("ajxp_mysql_"));
$arrValues[$newKey] = $value;
}
}
if ($isNew) {
$string = "";
$index = 0;
foreach ($arrValues as $k => $v) {
// CHECK IF AUTO KEY!!!
$string .= "'" . addslashes(SystemTextEncoding::fromUTF8($v)) . "'";
if ($index < count($arrValues) - 1) {
$string .= ",";
}
$index++;
}
$query = "INSERT INTO {$tableName} VALUES ({$string})";
} else {
$string = "";
$index = 0;
foreach ($arrValues as $k => $v) {
if ($k == $pkName) {
$pkValue = $v;
} else {
$string .= $k . "='" . addslashes(SystemTextEncoding::fromUTF8($v)) . "'";
if ($index < count($arrValues) - 1) {
$string .= ",";
}
}
$index++;
}
$query = "UPDATE {$tableName} SET {$string} WHERE {$pkName}='{$pkValue}'";
}
$link = $this->createDbLink();
$res = $this->execQuery($query);
$this->closeDbLink($link);
if (is_a($res, "AJXP_Exception")) {
$errorMessage = $res->messageId;
} else {
$logMessage = $query;
$reload_file_list = true;
}
break;
//------------------------------------
// CHANGE COLUMNS OR CREATE TABLE
//------------------------------------
//------------------------------------
// CHANGE COLUMNS OR CREATE TABLE
//------------------------------------
case "edit_table":
$link = $this->createDbLink();
if (isset($httpVars["current_table"])) {
if (isset($httpVars["delete_column"])) {
$query = "ALTER TABLE " . $httpVars["current_table"] . " DROP COLUMN " . $httpVars["delete_column"];
$res = $this->execQuery($query);
if (is_a($res, "AJXP_Exception")) {
$errorMessage = $res->messageId;
} else {
$logMessage = $query;
//.........这里部分代码省略.........
示例12: switchAction
public function switchAction($action, $httpVars, $filesVars)
{
if (!isset($this->actions[$action])) {
return false;
}
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(true)) {
return false;
}
$streamData = $repository->streamData;
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId();
if ($action == "post_to_server") {
$file = base64_decode($httpVars["file"]);
$file = SystemTextEncoding::magicDequote(AJXP_Utils::securePath($file));
$target = base64_decode($httpVars["parent_url"]) . "/plugins/editor.pixlr";
$tmp = call_user_func(array($streamData["classname"], "getRealFSReference"), $destStreamURL . $file);
$tmp = SystemTextEncoding::fromUTF8($tmp);
$fData = array("tmp_name" => $tmp, "name" => urlencode(basename($file)), "type" => "image/jpg");
//var_dump($fData);
$httpClient = new HttpClient("pixlr.com");
//$httpClient->setDebug(true);
$postData = array();
$httpClient->setHandleRedirects(false);
$params = array("referrer" => "AjaXplorer", "method" => "get", "loc" => ConfService::getLanguage(), "target" => $target . "/fake_save_pixlr.php", "exit" => $target . "/fake_close_pixlr.php", "title" => urlencode(basename($file)), "locktarget" => "false", "locktitle" => "true", "locktype" => "source");
$httpClient->postFile("/editor/", $params, "image", $fData);
$loc = $httpClient->getHeader("location");
header("Location:{$loc}");
} else {
if ($action == "retrieve_pixlr_image") {
$file = AJXP_Utils::decodeSecureMagic($httpVars["original_file"]);
$url = $httpVars["new_url"];
$urlParts = parse_url($url);
$query = $urlParts["query"];
$params = array();
$parameters = parse_str($query, $params);
$image = $params['image'];
/*
$type = $params['type'];
$state = $params['state'];
$filename = $params['title'];
*/
if (strpos($image, "pixlr.com") == 0) {
throw new AJXP_Exception("Invalid Referrer");
}
$headers = get_headers($image, 1);
$content_type = explode("/", $headers['Content-Type']);
if ($content_type[0] != "image") {
throw new AJXP_Exception("File Type");
}
$orig = fopen($image, "r");
$target = fopen($destStreamURL . $file, "w");
while (!feof($orig)) {
fwrite($target, fread($orig, 4096));
}
fclose($orig);
fclose($target);
header("Content-Type:text/plain");
print $mess[115];
}
}
return;
}
示例13: unifyChunks
public function unifyChunks($action, &$httpVars, &$fileVars)
{
$filename = SystemTextEncoding::fromUTF8($httpVars["name"]);
$tmpName = $fileVars["file"]["tmp_name"];
$chunk = $httpVars["chunk"];
$chunks = $httpVars["chunks"];
//error_log("currentChunk:".$chunk." chunks: ".$chunks);
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(false)) {
return false;
}
$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
$streamData = $plugin->detectStreamWrapper(true);
$dir = $httpVars["dir"];
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . $dir . "/";
//error_log("Directory: ".$dir);
// Clean the fileName for security reasons
//$filename = preg_replace('/[^\w\._]+/', '', $filename);
// Look for the content type header
if (isset($_SERVER["HTTP_CONTENT_TYPE"])) {
$contentType = $_SERVER["HTTP_CONTENT_TYPE"];
}
if (isset($_SERVER["CONTENT_TYPE"])) {
$contentType = $_SERVER["CONTENT_TYPE"];
}
// Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
if (strpos($contentType, "multipart") !== false) {
if (isset($tmpName) && is_uploaded_file($tmpName)) {
//error_log("tmpName: ".$tmpName);
// Open temp file
$out = fopen($destStreamURL . $filename, $chunk == 0 ? "wb" : "ab");
if ($out) {
// Read binary input stream and append it to temp file
$in = fopen($tmpName, "rb");
if ($in) {
while ($buff = fread($in, 4096)) {
fwrite($out, $buff);
}
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
}
fclose($in);
fclose($out);
@unlink($tmpName);
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
}
} else {
// Open temp file
$out = fopen($destStreamURL . $filename, $chunk == 0 ? "wb" : "ab");
if ($out) {
// Read binary input stream and append it to temp file
$in = fopen("php://input", "rb");
if ($in) {
while ($buff = fread($in, 4096)) {
fwrite($out, $buff);
}
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
}
fclose($in);
fclose($out);
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}
}
/* we apply the hook if we are uploading the last chunk */
if ($chunk == $chunks - 1) {
AJXP_Controller::applyHook("node.change", array(null, new AJXP_Node($destStreamURL . $filename), false));
}
// Return JSON-RPC response
die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');
}
示例14: getDisplay
/**
* @return String
*/
function getDisplay()
{
if (isset($this->displayStringId)) {
$mess = ConfService::getMessages();
if (isset($mess[$this->displayStringId])) {
return SystemTextEncoding::fromUTF8($mess[$this->displayStringId]);
}
}
return $this->display;
}
示例15: getDisplay
/**
* The label of this repository
* @return String
*/
public function getDisplay()
{
if (isset($this->displayStringId)) {
$mess = ConfService::getMessages();
if (isset($mess[$this->displayStringId])) {
return SystemTextEncoding::fromUTF8($mess[$this->displayStringId]);
}
}
return AJXP_VarsFilter::filter($this->display);
}