当前位置: 首页>>代码示例>>PHP>>正文


PHP TBGSettings::getUploadsLocalpath方法代码示例

本文整理汇总了PHP中TBGSettings::getUploadsLocalpath方法的典型用法代码示例。如果您正苦于以下问题:PHP TBGSettings::getUploadsLocalpath方法的具体用法?PHP TBGSettings::getUploadsLocalpath怎么用?PHP TBGSettings::getUploadsLocalpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TBGSettings的用法示例。


在下文中一共展示了TBGSettings::getUploadsLocalpath方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __

								</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 TBGSettings::getUploadsLocalpath() != "" ? TBGSettings::getUploadsLocalpath() : THEBUGGENIE_PATH . 'files/';
    ?>
"<?php 
    if (!TBGSettings::isUploadsEnabled() || TBGSettings::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>
开发者ID:ronaldbroens,项目名称:thebuggenie,代码行数:31,代码来源:configureuploads.html.php

示例2: handleUpload

 /**
  * Handles an uploaded file, stores it to the correct folder, adds an entry
  * to the database and returns a TBGFile object
  * 
  * @param string $thefile The request parameter the file was sent as
  * 
  * @return TBGFile The TBGFile 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 (TBGSettings::isUploadsEnabled()) {
                 TBGLogging::log('Uploads enabled');
                 if ($thefile['error'] == UPLOAD_ERR_OK) {
                     TBGLogging::log('No upload errors');
                     if (filesize($thefile['tmp_name']) > TBGSettings::getUploadsMaxSize(true) && TBGSettings::getUploadsMaxSize() > 0) {
                         throw new Exception(TBGContext::getI18n()->__('You cannot upload files bigger than %max_size% MB', array('%max_size%' => TBGSettings::getUploadsMaxSize())));
                     }
                     TBGLogging::log('Upload filesize ok');
                     $extension = substr(basename($thefile['name']), strpos(basename($thefile['name']), '.'));
                     if ($extension == '') {
                         TBGLogging::log('OOps, could not determine upload filetype', 'main', TBGLogging::LEVEL_WARNING_RISK);
                         //throw new Exception(TBGContext::getI18n()->__('Could not determine filetype'));
                     } else {
                         TBGLogging::log('Checking uploaded file extension');
                         $extension = substr($extension, 1);
                         $upload_extensions = TBGSettings::getUploadsExtensionsList();
                         if (TBGSettings::getUploadsRestrictionMode() == 'blacklist') {
                             TBGLogging::log('... using blacklist');
                             foreach ($upload_extensions as $an_ext) {
                                 if (strtolower(trim($extension)) == strtolower(trim($an_ext))) {
                                     TBGLogging::log('Upload extension not ok');
                                     throw new Exception(TBGContext::getI18n()->__('This filetype is not allowed'));
                                 }
                             }
                             TBGLogging::log('Upload extension ok');
                         } else {
                             TBGLogging::log('... using whitelist');
                             $is_ok = false;
                             foreach ($upload_extensions as $an_ext) {
                                 if (strtolower(trim($extension)) == strtolower(trim($an_ext))) {
                                     TBGLogging::log('Upload extension ok');
                                     $is_ok = true;
                                     break;
                                 }
                             }
                             if (!$is_ok) {
                                 TBGLogging::log('Upload extension not ok');
                                 throw new Exception(TBGContext::getI18n()->__('This filetype is not allowed'));
                             }
                         }
                         /*if (in_array(strtolower(trim($extension)), array('php', 'asp')))
                         		{
                         			TBGLogging::log('Upload extension is php or asp');
                         			throw new Exception(TBGContext::getI18n()->__('This filetype is not allowed'));
                         		}*/
                     }
                     if (is_uploaded_file($thefile['tmp_name'])) {
                         TBGLogging::log('Uploaded file is uploaded');
                         $files_dir = TBGSettings::getUploadsLocalpath();
                         $new_filename = TBGContext::getUser()->getID() . '_' . NOW . '_' . basename($thefile['name']);
                         TBGLogging::log('Moving uploaded file to ' . $new_filename);
                         if (!move_uploaded_file($thefile['tmp_name'], $files_dir . $new_filename)) {
                             TBGLogging::log('Moving uploaded file failed!');
                             throw new Exception(TBGContext::getI18n()->__('An error occured when saving the file'));
                         } else {
                             TBGLogging::log('Upload complete and ok, storing upload status and returning filename ' . $new_filename);
                             $content_type = TBGFile::getMimeType($files_dir . $new_filename);
                             $file = new TBGFile();
                             $file->setRealFilename($new_filename);
                             $file->setOriginalFilename(basename($thefile['name']));
                             $file->setContentType($content_type);
                             $file->setDescription($this->getParameter($key . '_description'));
                             if (TBGSettings::getUploadStorage() == 'database') {
                                 $file->setContent(file_get_contents($files_dir . $new_filename));
                             }
                             $file->save();
                             //$file = TBGFile::createNew($new_filename, basename($thefile['name']), $content_type, $this->getParameter($key.'_description'), ((TBGSettings::getUploadStorage() == 'database') ? file_get_contents($files_dir.$new_filename) : null));
                             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 {
                         TBGLogging::log('Uploaded file was not uploaded correctly');
                         throw new Exception(TBGContext::getI18n()->__('The file was not uploaded correctly'));
                     }
                 } else {
                     TBGLogging::log('Upload error: ' . $thefile['error']);
                     switch ($thefile['error']) {
                         case UPLOAD_ERR_INI_SIZE:
                         case UPLOAD_ERR_FORM_SIZE:
                             throw new Exception(TBGContext::getI18n()->__('You cannot upload files bigger than %max_size% MB', array('%max_size%' => TBGSettings::getUploadsMaxSize())));
                             break;
//.........这里部分代码省略.........
开发者ID:ronaldbroens,项目名称:thebuggenie,代码行数:101,代码来源:TBGRequest.class.php

示例3: move

 public function move($target_path)
 {
     if (TBGSettings::getUploadStorage() == 'files') {
         rename($this->getFullpath(), TBGSettings::getUploadsLocalpath() . $target_path);
     }
     $this->setRealFilename($target_path);
     $this->save();
 }
开发者ID:oparoz,项目名称:thebuggenie,代码行数:8,代码来源:TBGFile.class.php

示例4: runGetFile

 public function runGetFile(TBGRequest $request)
 {
     $file = new TBGFile((int) $request['id']);
     if ($file instanceof TBGFile) {
         if ($file->hasAccess()) {
             $this->getResponse()->cleanBuffer();
             $this->getResponse()->clearHeaders();
             $this->getResponse()->setDecoration(TBGResponse::DECORATE_NONE);
             $this->getResponse()->addHeader('Content-disposition: ' . ($request['mode'] == 'download' ? 'attachment' : 'inline') . '; filename="' . $file->getOriginalFilename() . '"');
             $this->getResponse()->setContentType($file->getContentType());
             $this->getResponse()->renderHeaders();
             if (TBGSettings::getUploadStorage() == 'files') {
                 fpassthru(fopen(TBGSettings::getUploadsLocalpath() . $file->getRealFilename(), 'r'));
                 exit;
             } else {
                 echo $file->getContent();
                 exit;
             }
             return true;
         }
     }
     $this->return404(TBGContext::getI18n()->__('This file does not exist'));
 }
开发者ID:oparoz,项目名称:thebuggenie,代码行数:23,代码来源:actions.class.php

示例5: url

						<li style="background-image: url('iconsets/oxygen/backup_uploads.png');" class="<?php 
        if (TBGSettings::getUploadStorage() != 'files') {
            echo 'faded';
        }
        ?>
">
							Uploaded files<br>
							<?php 
        if (TBGSettings::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 TBGSettings::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 
开发者ID:oparoz,项目名称:thebuggenie,代码行数:31,代码来源:upgrade.html.php

示例6: getFullpath

 public function getFullpath()
 {
     return TBGSettings::getUploadsLocalpath() . $this->getOriginalFilename();
 }
开发者ID:ronaldbroens,项目名称:thebuggenie,代码行数:4,代码来源:TBGFile.class.php

示例7: runGetFile

 public function runGetFile(TBGRequest $request)
 {
     $file = TBGFilesTable::getTable()->doSelectById((int) $request->getParameter('id'));
     if ($file instanceof B2DBRow) {
         $this->getResponse()->cleanBuffer();
         $this->getResponse()->clearHeaders();
         $this->getResponse()->setDecoration(TBGResponse::DECORATE_NONE);
         $this->getResponse()->addHeader('Content-disposition: ' . ($request->getParameter('mode') == 'download' ? 'attachment' : 'inline') . '; filename="' . $file->get(TBGFilesTable::ORIGINAL_FILENAME) . '"');
         $this->getResponse()->addHeader('Content-type: ' . $file->get(TBGFilesTable::CONTENT_TYPE) . '; charset=UTF-8');
         $this->getResponse()->renderHeaders();
         if (TBGSettings::getUploadStorage() == 'files') {
             echo fpassthru(fopen(TBGSettings::getUploadsLocalpath() . $file->get(TBGFilesTable::REAL_FILENAME), 'r'));
             exit;
         } else {
             echo $file->get(TBGFilesTable::CONTENT);
             exit;
         }
         return true;
     }
     $this->return404(TBGContext::getI18n()->__('This file does not exist'));
 }
开发者ID:ronaldbroens,项目名称:thebuggenie,代码行数:21,代码来源:actions.class.php

示例8: processIncomingEmailAccount

 public function processIncomingEmailAccount(TBGIncomingEmailAccount $account, $limit = 25)
 {
     $count = 0;
     if ($emails = $account->getUnprocessedEmails()) {
         try {
             $current_user = TBGContext::getUser();
             foreach ($emails as $email) {
                 $user = $this->getOrCreateUserFromEmailString($email->from);
                 if ($user instanceof TBGUser) {
                     if (TBGContext::getUser()->getID() != $user->getID()) {
                         TBGContext::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 = TBGIssue::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) && $user->canPostComments()) {
                                 $comment = new TBGComment();
                                 $comment->setContent($text);
                                 $comment->setPostedBy($user);
                                 $comment->setTargetID($issue->getID());
                                 $comment->setTargetType(TBGComment::TYPE_ISSUE);
                                 $comment->save();
                             }
                         }
                     } else {
                         if ($user->canReportIssues($account->getProject())) {
                             $issue = new TBGIssue();
                             $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 = TBGContext::getUser()->getID() . '_' . NOW . '_' . basename($name);
                             if (TBGSettings::getUploadStorage() == 'files') {
                                 $files_dir = TBGSettings::getUploadsLocalpath();
                                 $filename = $files_dir . $new_filename;
                             } else {
                                 $filename = $name;
                             }
                             TBGLogging::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 TBGFile();
                             $file->setRealFilename($new_filename);
                             $file->setOriginalFilename(basename($name));
                             $file->setContentType($content_type);
                             $file->setDescription($name);
                             $file->setUploadedBy(TBGContext::getUser());
                             if (TBGSettings::getUploadStorage() == 'database') {
                                 $file->setContent($attachment['data']);
                             } else {
                                 TBGLogging::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) {
//.........这里部分代码省略.........
开发者ID:oparoz,项目名称:thebuggenie,代码行数:101,代码来源:TBGMailing.class.php


注:本文中的TBGSettings::getUploadsLocalpath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。