本文整理汇总了PHP中SystemTextEncoding::fromPostedFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP SystemTextEncoding::fromPostedFileName方法的具体用法?PHP SystemTextEncoding::fromPostedFileName怎么用?PHP SystemTextEncoding::fromPostedFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SystemTextEncoding
的用法示例。
在下文中一共展示了SystemTextEncoding::fromPostedFileName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initFromArray
function initFromArray($array)
{
if (!is_array($array)) {
return;
}
if (isset($array[$this->varPrefix]) && $array[$this->varPrefix] != "") {
$this->files[] = Utils::securePath(SystemTextEncoding::fromPostedFileName($array[$this->varPrefix]));
$this->isUnique = true;
//return ;
}
if (isset($array[$this->varPrefix . "_0"])) {
$index = 0;
while (isset($array[$this->varPrefix . "_" . $index])) {
$this->files[] = Utils::securePath(SystemTextEncoding::fromPostedFileName($array[$this->varPrefix . "_" . $index]));
$index++;
}
$this->isUnique = false;
if (count($this->files) == 1) {
$this->isUnique = true;
}
//return ;
}
if (isset($array[$this->dirPrefix])) {
$this->dir = Utils::securePath($array[$this->dirPrefix]);
if ($test = $this->detectZip($this->dir)) {
$this->inZip = true;
$this->zipFile = $test[0];
$this->localZipPath = $test[1];
}
}
}
示例2: parseParameters
function parseParameters(&$repDef, &$options, $userId = null)
{
foreach ($repDef as $key => $value) {
$value = SystemTextEncoding::magicDequote($value);
if (strpos($key, "DRIVER_OPTION_") !== false && strpos($key, "DRIVER_OPTION_") == 0 && strpos($key, "ajxptype") === false) {
if (isset($repDef[$key . "_ajxptype"])) {
$type = $repDef[$key . "_ajxptype"];
if ($type == "boolean") {
$value = $value == "true" ? true : false;
} else {
if ($type == "integer") {
$value = intval($value);
} else {
if ($type == "password" && $userId != null) {
if (trim($value != "") && function_exists('mcrypt_encrypt')) {
// The initialisation vector is only required to avoid a warning, as ECB ignore IV
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
// We encode as base64 so if we need to store the result in a database, it can be stored in text column
$value = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($userId . "CDAFx¨op#"), $value, MCRYPT_MODE_ECB, $iv));
}
}
}
}
unset($repDef[$key . "_ajxptype"]);
}
$options[substr($key, strlen("DRIVER_OPTION_"))] = $value;
unset($repDef[$key]);
} else {
if ($key == "DISPLAY") {
$value = SystemTextEncoding::fromPostedFileName($value);
}
$repDef[$key] = $value;
}
}
}
示例3: uploadActions
public function uploadActions($action, $httpVars, $filesVars)
{
switch ($action) {
case "trigger_remote_copy":
if (!$this->hasFilesToCopy()) {
break;
}
$toCopy = $this->getFileNameToCopy();
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("next_to_remote", array(), "Copying file " . $toCopy . " to ftp server");
AJXP_XMLWriter::close();
exit(1);
break;
case "next_to_remote":
if (!$this->hasFilesToCopy()) {
break;
}
$fData = $this->getNextFileToCopy();
$nextFile = '';
if ($this->hasFilesToCopy()) {
$nextFile = $this->getFileNameToCopy();
}
$this->logDebug("Base64 : ", array("from" => $fData["destination"], "to" => base64_decode($fData['destination'])));
$destPath = $this->urlBase . base64_decode($fData['destination']) . "/" . $fData['name'];
//$destPath = AJXP_Utils::decodeSecureMagic($destPath);
// DO NOT "SANITIZE", THE URL IS ALREADY IN THE FORM ajxp.ftp://repoId/filename
$destPath = SystemTextEncoding::fromPostedFileName($destPath);
$node = new AJXP_Node($destPath);
$this->logDebug("Copying file to server", array("from" => $fData["tmp_name"], "to" => $destPath, "name" => $fData["name"]));
try {
AJXP_Controller::applyHook("node.before_create", array(&$node));
$fp = fopen($destPath, "w");
$fSource = fopen($fData["tmp_name"], "r");
while (!feof($fSource)) {
fwrite($fp, fread($fSource, 4096));
}
fclose($fSource);
$this->logDebug("Closing target : begin ftp copy");
// Make sur the script does not time out!
@set_time_limit(240);
fclose($fp);
$this->logDebug("FTP Upload : end of ftp copy");
@unlink($fData["tmp_name"]);
AJXP_Controller::applyHook("node.change", array(null, &$node));
} catch (Exception $e) {
$this->logDebug("Error during ftp copy", array($e->getMessage(), $e->getTrace()));
}
$this->logDebug("FTP Upload : shoud trigger next or reload nextFile={$nextFile}");
AJXP_XMLWriter::header();
if ($nextFile != '') {
AJXP_XMLWriter::triggerBgAction("next_to_remote", array(), "Copying file " . SystemTextEncoding::toUTF8($nextFile) . " to remote server");
} else {
AJXP_XMLWriter::triggerBgAction("reload_node", array(), "Upload done, reloading client.");
}
AJXP_XMLWriter::close();
exit(1);
break;
case "upload":
$rep_source = AJXP_Utils::securePath("/" . $httpVars['dir']);
$this->logDebug("Upload : rep_source ", array($rep_source));
$logMessage = "";
foreach ($filesVars as $boxName => $boxData) {
if (substr($boxName, 0, 9) != "userfile_") {
continue;
}
$this->logDebug("Upload : rep_source ", array($rep_source));
$err = AJXP_Utils::parseFileDataErrors($boxData);
if ($err != null) {
$errorCode = $err[0];
$errorMessage = $err[1];
break;
}
if (isset($httpVars["auto_rename"])) {
$destination = $this->urlBase . $rep_source;
$boxData["name"] = fsAccessDriver::autoRenameForDest($destination, $boxData["name"]);
}
$boxData["destination"] = base64_encode($rep_source);
$destCopy = AJXP_XMLWriter::replaceAjxpXmlKeywords($this->repository->getOption("TMP_UPLOAD"));
$this->logDebug("Upload : tmp upload folder", array($destCopy));
if (!is_dir($destCopy)) {
if (!@mkdir($destCopy)) {
$this->logDebug("Upload error : cannot create temporary folder", array($destCopy));
$errorCode = 413;
$errorMessage = "Warning, cannot create folder for temporary copy.";
break;
}
}
if (!$this->isWriteable($destCopy)) {
$this->logDebug("Upload error: cannot write into temporary folder");
$errorCode = 414;
$errorMessage = "Warning, cannot write into temporary folder.";
break;
}
$this->logDebug("Upload : tmp upload folder", array($destCopy));
if (isset($boxData["input_upload"])) {
try {
$destName = tempnam($destCopy, "");
$this->logDebug("Begining reading INPUT stream");
$input = fopen("php://input", "r");
$output = fopen($destName, "w");
//.........这里部分代码省略.........
示例4: switchAction
//.........这里部分代码省略.........
//------------------------------------
// UPLOAD
//------------------------------------
//------------------------------------
// UPLOAD
//------------------------------------
case "upload":
$repoData = array('base_url' => $this->urlBase, 'wrapper_name' => $this->wrapperClassName, 'chmod' => $this->repository->getOption('CHMOD_VALUE'), 'recycle' => $this->repository->getOption('RECYCLE_BIN'));
$this->logDebug("Upload Files Data", $fileVars);
$destination = $this->urlBase . AJXP_Utils::decodeSecureMagic($dir);
$this->logDebug("Upload inside", array("destination" => $this->addSlugToPath($destination)));
if (!$this->isWriteable($destination)) {
$errorCode = 412;
$errorMessage = "{$mess['38']} " . SystemTextEncoding::toUTF8($dir) . " {$mess['99']}.";
$this->logDebug("Upload error 412", array("destination" => $this->addSlugToPath($destination)));
return array("ERROR" => array("CODE" => $errorCode, "MESSAGE" => $errorMessage));
}
foreach ($fileVars as $boxName => $boxData) {
if (substr($boxName, 0, 9) != "userfile_") {
continue;
}
$err = AJXP_Utils::parseFileDataErrors($boxData);
if ($err != null) {
$errorCode = $err[0];
$errorMessage = $err[1];
break;
}
$userfile_name = $boxData["name"];
try {
$this->filterUserSelectionToHidden(array($userfile_name));
} catch (Exception $e) {
return array("ERROR" => array("CODE" => 411, "MESSAGE" => "Forbidden"));
}
$userfile_name = AJXP_Utils::sanitize(SystemTextEncoding::fromPostedFileName($userfile_name), AJXP_SANITIZE_FILENAME);
if (isset($httpVars["urlencoded_filename"])) {
$userfile_name = AJXP_Utils::sanitize(SystemTextEncoding::fromUTF8(urldecode($httpVars["urlencoded_filename"])), AJXP_SANITIZE_FILENAME);
}
$this->logDebug("User filename " . $userfile_name);
$userfile_name = substr($userfile_name, 0, ConfService::getCoreConf("NODENAME_MAX_LENGTH"));
if (isset($httpVars["auto_rename"])) {
$userfile_name = self::autoRenameForDest($destination, $userfile_name);
}
$already_existed = false;
try {
if (file_exists($destination . "/" . $userfile_name)) {
$already_existed = true;
AJXP_Controller::applyHook("node.before_change", array(new AJXP_Node($destination . "/" . $userfile_name), $boxData["size"]));
} else {
AJXP_Controller::applyHook("node.before_create", array(new AJXP_Node($destination . "/" . $userfile_name), $boxData["size"]));
}
AJXP_Controller::applyHook("node.before_change", array(new AJXP_Node($destination)));
} catch (Exception $e) {
$errorCode = 507;
$errorMessage = $e->getMessage();
break;
}
if (isset($boxData["input_upload"])) {
try {
$this->logDebug("Begining reading INPUT stream");
$input = fopen("php://input", "r");
$output = fopen("{$destination}/" . $userfile_name, "w");
$sizeRead = 0;
while ($sizeRead < intval($boxData["size"])) {
$chunk = fread($input, 4096);
$sizeRead += strlen($chunk);
fwrite($output, $chunk, strlen($chunk));
示例5: switchAction
function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
parent::accessPreprocess($action, $httpVars, $fileVars);
$selection = new UserSelection();
$dir = $httpVars["dir"] or "";
$dir = AJXP_Utils::securePath($dir);
if ($action != "upload") {
$dir = SystemTextEncoding::fromPostedFileName($dir);
}
$selection->initFromHttpVars($httpVars);
$mess = ConfService::getMessages();
$newArgs = RecycleBinManager::filterActions($action, $selection, $dir);
if (isset($newArgs["action"])) {
$action = $newArgs["action"];
}
if (isset($newArgs["dest"])) {
$httpVars["dest"] = SystemTextEncoding::toUTF8($newArgs["dest"]);
}
//Re-encode!
// FILTER DIR PAGINATION ANCHOR
$page = null;
if (isset($dir) && strstr($dir, "#") !== false) {
$parts = explode("#", $dir);
$dir = $parts[0];
$page = $parts[1];
}
$pendingSelection = "";
$logMessage = null;
$reloadContextNode = false;
switch ($action) {
//------------------------------------
// DOWNLOAD
//------------------------------------
case "download":
AJXP_Logger::logAction("Download", array("files" => $selection));
@set_error_handler(array("HTMLWriter", "javascriptErrorHandler"), E_ALL & ~E_NOTICE);
@register_shutdown_function("restore_error_handler");
$zip = false;
if ($selection->isUnique()) {
if (is_dir($this->urlBase . $selection->getUniqueFile())) {
$zip = true;
$base = basename($selection->getUniqueFile());
$dir .= "/" . dirname($selection->getUniqueFile());
}
} else {
$zip = true;
}
if ($zip) {
// Make a temp zip and send it as download
$loggedUser = AuthService::getLoggedUser();
$file = USERS_DIR . "/" . ($loggedUser ? $loggedUser->getId() : "shared") . "/" . time() . "tmpDownload.zip";
$zipFile = $this->makeZip($selection->getFiles(), $file, $dir);
if (!$zipFile) {
throw new AJXP_Exception("Error while compressing");
}
register_shutdown_function("unlink", $file);
$localName = ($base == "" ? "Files" : $base) . ".zip";
$this->readFile($file, "force-download", $localName, false, false, true);
} else {
$this->readFile($this->urlBase . $selection->getUniqueFile(), "force-download");
}
exit(0);
break;
case "compress":
// Make a temp zip and send it as download
$loggedUser = AuthService::getLoggedUser();
if (isset($httpVars["archive_name"])) {
$localName = AJXP_Utils::decodeSecureMagic($httpVars["archive_name"]);
} else {
$localName = (basename($dir) == "" ? "Files" : basename($dir)) . ".zip";
}
$file = USERS_DIR . "/" . ($loggedUser ? $loggedUser->getId() : "shared") . "/" . time() . "tmpCompression.zip";
$zipFile = $this->makeZip($selection->getFiles(), $file, $dir);
if (!$zipFile) {
throw new AJXP_Exception("Error while compressing file {$localName}");
}
register_shutdown_function("unlink", $file);
copy($file, $this->urlBase . $dir . "/" . str_replace(".zip", ".tmp", $localName));
@rename($this->urlBase . $dir . "/" . str_replace(".zip", ".tmp", $localName), $this->urlBase . $dir . "/" . $localName);
$reloadContextNode = true;
$pendingSelection = $localName;
break;
case "stat":
clearstatcache();
$stat = @stat($this->urlBase . AJXP_Utils::decodeSecureMagic($httpVars["file"]));
header("Content-type:application/json");
if (!$stat) {
print '{}';
} else {
print json_encode($stat);
}
exit(1);
break;
//------------------------------------
// ONLINE EDIT
//------------------------------------
//------------------------------------
//.........这里部分代码省略.........
示例6: getZipLocalPath
/**
* Warning, returns UTF8 encoded path
*
* @return String
*/
function getZipLocalPath($decode = false)
{
if ($decode) {
return SystemTextEncoding::fromPostedFileName($this->localZipPath);
} else {
return $this->localZipPath;
}
}