本文整理汇总了PHP中thebuggenie\core\framework\Settings::getUploadsLocalpath方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::getUploadsLocalpath方法的具体用法?PHP Settings::getUploadsLocalpath怎么用?PHP Settings::getUploadsLocalpath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thebuggenie\core\framework\Settings
的用法示例。
在下文中一共展示了Settings::getUploadsLocalpath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleUpload
/**
* Handles an uploaded file, stores it to the correct folder, adds an entry
* to the database and returns a \thebuggenie\core\entities\File object
*
* @param string $key The request parameter the file was sent as
*
* @return \thebuggenie\core\entities\File The File object
*/
public function handleUpload($key)
{
$apc_exists = self::CanGetUploadStatus();
if ($apc_exists && !array_key_exists($this->getParameter('APC_UPLOAD_PROGRESS'), $_SESSION['__upload_status'])) {
$_SESSION['__upload_status'][$this->getParameter('APC_UPLOAD_PROGRESS')] = array('id' => $this->getParameter('APC_UPLOAD_PROGRESS'), 'finished' => false, 'percent' => 0, 'total' => 0, 'complete' => 0);
}
try {
if ($this->getUploadedFile($key) !== null) {
$thefile = $this->getUploadedFile($key);
if (Settings::isUploadsEnabled()) {
Logging::log('Uploads enabled');
if ($thefile['error'] == UPLOAD_ERR_OK) {
Logging::log('No upload errors');
if (filesize($thefile['tmp_name']) > Settings::getUploadsEffectiveMaxSize(true)) {
throw new \Exception(Context::getI18n()->__('You cannot upload files bigger than %max_size MB', array('%max_size' => Settings::getUploadsEffectiveMaxSize())));
}
Logging::log('Upload filesize ok');
$extension = mb_substr(basename($thefile['name']), mb_strrpos(basename($thefile['name']), '.'));
if ($extension == '') {
Logging::log('OOps, could not determine upload filetype', 'main', Logging::LEVEL_WARNING_RISK);
//throw new \Exception(Context::getI18n()->__('Could not determine filetype'));
} else {
Logging::log('Checking uploaded file extension');
$extension = mb_substr($extension, 1);
$upload_extensions = Settings::getUploadsExtensionsList();
if (Settings::getUploadsRestrictionMode() == 'blacklist') {
Logging::log('... using blacklist');
foreach ($upload_extensions as $an_ext) {
if (mb_strtolower(trim($extension)) == mb_strtolower(trim($an_ext))) {
Logging::log('Upload extension not ok');
throw new \Exception(Context::getI18n()->__('This filetype is not allowed'));
}
}
Logging::log('Upload extension ok');
} else {
Logging::log('... using whitelist');
$is_ok = false;
foreach ($upload_extensions as $an_ext) {
if (mb_strtolower(trim($extension)) == mb_strtolower(trim($an_ext))) {
Logging::log('Upload extension ok');
$is_ok = true;
break;
}
}
if (!$is_ok) {
Logging::log('Upload extension not ok');
throw new \Exception(Context::getI18n()->__('This filetype is not allowed'));
}
}
/*if (in_array(mb_strtolower(trim($extension)), array('php', 'asp')))
{
Logging::log('Upload extension is php or asp');
throw new \Exception(Context::getI18n()->__('This filetype is not allowed'));
}*/
}
if (is_uploaded_file($thefile['tmp_name'])) {
Logging::log('Uploaded file is uploaded');
$new_filename = Context::getUser()->getID() . '_' . NOW . '_' . basename($thefile['name']);
if (Settings::getUploadStorage() == 'files') {
$files_dir = Settings::getUploadsLocalpath();
$filename = $files_dir . $new_filename;
} else {
$filename = $thefile['tmp_name'];
}
Logging::log('Moving uploaded file to ' . $filename);
if (Settings::getUploadStorage() == 'files' && !move_uploaded_file($thefile['tmp_name'], $filename)) {
Logging::log('Moving uploaded file failed!');
throw new \Exception(Context::getI18n()->__('An error occured when saving the file'));
} else {
Logging::log('Upload complete and ok, storing upload status and returning filename ' . $new_filename);
$content_type = File::getMimeType($filename);
$file = new File();
$file->setRealFilename($new_filename);
$file->setOriginalFilename(basename($thefile['name']));
$file->setContentType($content_type);
$file->setDescription($this->getParameter($key . '_description'));
$file->setUploadedBy(Context::getUser());
if (Settings::getUploadStorage() == 'database') {
$file->setContent(file_get_contents($filename));
}
$file->save();
if ($apc_exists) {
$_SESSION['__upload_status'][$this->getParameter('APC_UPLOAD_PROGRESS')] = array('id' => $this->getParameter('APC_UPLOAD_PROGRESS'), 'finished' => true, 'percent' => 100, 'total' => 0, 'complete' => 0, 'file_id' => $file->getID());
}
return $file;
}
} else {
Logging::log('Uploaded file was not uploaded correctly');
throw new \Exception(Context::getI18n()->__('The file was not uploaded correctly'));
}
} else {
Logging::log('Upload error: ' . $thefile['error']);
//.........这里部分代码省略.........
示例2: processIncomingEmailAccount
public function processIncomingEmailAccount(IncomingEmailAccount $account)
{
$count = 0;
if ($emails = $account->getUnprocessedEmails()) {
try {
$current_user = framework\Context::getUser();
foreach ($emails as $email) {
$user = $this->getOrCreateUserFromEmailString($email->from);
if ($user instanceof User) {
if (framework\Context::getUser()->getID() != $user->getID()) {
framework\Context::switchUserContext($user);
}
$message = $account->getMessage($email);
$data = $message->getBodyPlain() ? $message->getBodyPlain() : strip_tags($message->getBodyHTML());
if ($data) {
if (mb_detect_encoding($data, 'UTF-8', true) === false) {
$data = utf8_encode($data);
}
$new_data = '';
foreach (explode("\n", $data) as $line) {
$line = trim($line);
if ($line) {
$line = preg_replace('/^(_{2,}|-{2,})$/', "<hr>", $line);
$new_data .= $line . "\n";
} else {
$new_data .= "\n";
}
}
$data = nl2br($new_data, false);
}
// Parse the subject, and obtain the issues.
$parsed_commit = Issue::getIssuesFromTextByRegex(mb_decode_mimeheader($email->subject));
$issues = $parsed_commit["issues"];
// If any issues were found, add new comment to each issue.
if ($issues) {
foreach ($issues as $issue) {
$text = preg_replace('#(^\\w.+:\\n)?(^>.*(\\n|$))+#mi', "", $data);
$text = trim($text);
if (!$this->processIncomingEmailCommand($text, $issue) && $user->canPostComments()) {
$comment = new Comment();
$comment->setContent($text);
$comment->setPostedBy($user);
$comment->setTargetID($issue->getID());
$comment->setTargetType(Comment::TYPE_ISSUE);
$comment->save();
}
}
} else {
if ($user->canReportIssues($account->getProject())) {
$issue = new Issue();
$issue->setProject($account->getProject());
$issue->setTitle(mb_decode_mimeheader($email->subject));
$issue->setDescription($data);
$issue->setPostedBy($user);
$issue->setIssuetype($account->getIssuetype());
$issue->save();
// Append the new issue to the list of affected issues. This
// is necessary in order to process the attachments properly.
$issues[] = $issue;
}
}
// If there was at least a single affected issue, and mail
// contains attachments, add those attachments to related issues.
if ($issues && $message->hasAttachments()) {
foreach ($message->getAttachments() as $attachment_no => $attachment) {
echo 'saving attachment ' . $attachment_no;
$name = $attachment['filename'];
$new_filename = framework\Context::getUser()->getID() . '_' . NOW . '_' . basename($name);
if (framework\Settings::getUploadStorage() == 'files') {
$files_dir = framework\Settings::getUploadsLocalpath();
$filename = $files_dir . $new_filename;
} else {
$filename = $name;
}
Logging::log('Creating issue attachment ' . $filename . ' from attachment ' . $attachment_no);
echo 'Creating issue attachment ' . $filename . ' from attachment ' . $attachment_no;
$content_type = $attachment['type'] . '/' . $attachment['subtype'];
$file = new File();
$file->setRealFilename($new_filename);
$file->setOriginalFilename(basename($name));
$file->setContentType($content_type);
$file->setDescription($name);
$file->setUploadedBy(framework\Context::getUser());
if (framework\Settings::getUploadStorage() == 'database') {
$file->setContent($attachment['data']);
} else {
Logging::log('Saving file ' . $new_filename . ' with content from attachment ' . $attachment_no);
file_put_contents($new_filename, $attachment['data']);
}
$file->save();
// Attach file to each related issue.
foreach ($issues as $issue) {
$issue->attachFile($file);
}
}
}
$count++;
}
}
} catch (\Exception $e) {
//.........这里部分代码省略.........
示例3: url
<li style="background-image: url('iconsets/oxygen/backup_uploads.png');" class="<?php
if (\thebuggenie\core\framework\Settings::getUploadStorage() != 'files') {
echo 'faded';
}
?>
">
Uploaded files<br>
<?php
if (\thebuggenie\core\framework\Settings::getUploadStorage() != 'files') {
?>
<span class="smaller">When using database file upload storage, this is included in the database backup</span>
<?php
} else {
?>
Remember to keep a copy of all files in <span class="command_box"><?php
echo \thebuggenie\core\framework\Settings::getUploadsLocalpath();
?>
</span>
<?php
}
?>
</li>
<li style="background-image: url('iconsets/oxygen/backup_specialfiles.png');">
The Bug Genie special files<br>
There are a number of configuration files used by The Bug Genie for its initialization and configuration. You should keep a copy of these files:
<ul>
<li class="command_box" style="display: block; margin: 0;"><?php
echo THEBUGGENIE_PATH . 'installed';
?>
</li>
<li class="command_box" style="display: block; margin: 0;"><?php
示例4: runGetFile
public function runGetFile(framework\Request $request)
{
$file = new entities\File((int) $request['id']);
if ($file instanceof entities\File) {
if ($file->hasAccess()) {
$disableCache = true;
$isFile = false;
$this->getResponse()->cleanBuffer();
$this->getResponse()->clearHeaders();
$this->getResponse()->setDecoration(\thebuggenie\core\framework\Response::DECORATE_NONE);
if ($file->isImage() && \thebuggenie\core\framework\Settings::isUploadsImageCachingEnabled()) {
$this->getResponse()->addHeader('Pragma: public');
$this->getResponse()->addHeader('Cache-Control: public, max-age: 15768000');
$this->getResponse()->addHeader("Expires: " . gmdate('D, d M Y H:i:s', time() + 15768000) . " GMT");
$disableCache = false;
}
$this->getResponse()->addHeader('Content-disposition: ' . ($request['mode'] == 'download' ? 'attachment' : 'inline') . '; filename="' . $file->getOriginalFilename() . '"');
$this->getResponse()->setContentType($file->getContentType());
if (framework\Settings::getUploadStorage() == 'files') {
$fh = fopen(framework\Settings::getUploadsLocalpath() . $file->getRealFilename(), 'r');
$isFile = true;
} else {
$fh = $file->getContent();
}
if (is_resource($fh)) {
if ($isFile && \thebuggenie\core\framework\Settings::isUploadsDeliveryUseXsend()) {
$this->getResponse()->addHeader('X-Sendfile: ' . framework\Settings::getUploadsLocalpath() . $file->getRealFilename());
$this->getResponse()->addHeader('X-Accel-Redirect: /files/' . $file->getRealFilename());
$this->getResponse()->renderHeaders($disableCache);
} else {
$this->getResponse()->renderHeaders($disableCache);
fpassthru($fh);
}
} else {
$this->getResponse()->renderHeaders($disableCache);
echo $fh;
}
exit;
}
}
$this->return404(framework\Context::getI18n()->__('This file does not exist'));
}
示例5: __
</td>
</tr>
<tr>
<td class="config_explanation" colspan="2"><?php
echo __('Specify whether you want to use the filesystem or database to store uploaded files. Using the database will make it easier to move your installation to another server.');
?>
</td>
</tr>
<tr>
<td><label for="upload_localpath"><?php
echo __('Upload location');
?>
</label></td>
<td>
<input type="text" name="upload_localpath" id="upload_localpath" style="width: 250px;" value="<?php
echo \thebuggenie\core\framework\Settings::getUploadsLocalpath() != "" ? \thebuggenie\core\framework\Settings::getUploadsLocalpath() : THEBUGGENIE_PATH . 'files/';
?>
"<?php
if (!\thebuggenie\core\framework\Settings::isUploadsEnabled() || \thebuggenie\core\framework\Settings::getUploadStorage() == 'database') {
?>
disabled<?php
}
?>
>
</td>
</tr>
<tr>
<td class="config_explanation" colspan="2"><?php
echo __("If you're storing files on the filesystem, specify where you want to save the files, here. Default location is the %files folder in the main folder (not the public folder)", array('%files' => '<b>files/</b>'));
?>
</td>
示例6: move
public function move($target_path)
{
if (\thebuggenie\core\framework\Settings::getUploadStorage() == 'files') {
rename($this->getFullpath(), \thebuggenie\core\framework\Settings::getUploadsLocalpath() . $target_path);
}
$this->setRealFilename($target_path);
$this->save();
}
示例7: runGetFile
public function runGetFile(framework\Request $request)
{
$file = new entities\File((int) $request['id']);
if ($file instanceof entities\File) {
if ($file->hasAccess()) {
$this->getResponse()->cleanBuffer();
$this->getResponse()->clearHeaders();
$this->getResponse()->setDecoration(\thebuggenie\core\framework\Response::DECORATE_NONE);
$this->getResponse()->addHeader('Content-disposition: ' . ($request['mode'] == 'download' ? 'attachment' : 'inline') . '; filename="' . $file->getOriginalFilename() . '"');
$this->getResponse()->setContentType($file->getContentType());
$this->getResponse()->renderHeaders();
if (framework\Settings::getUploadStorage() == 'files') {
fpassthru(fopen(framework\Settings::getUploadsLocalpath() . $file->getRealFilename(), 'r'));
exit;
} else {
echo $file->getContent();
exit;
}
}
}
$this->return404(framework\Context::getI18n()->__('This file does not exist'));
}