本文整理汇总了PHP中FileData类的典型用法代码示例。如果您正苦于以下问题:PHP FileData类的具体用法?PHP FileData怎么用?PHP FileData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Set base meta data and read the comment lines from the file head
*
* Usage example:
* <code>
* <?php
* $file = '/phpdoc/en/reference/array/functions/next.xml';
* $FDEn = new FileData($file, false);
* $file = '/phpdoc/de/reference/array/functions/next.xml';
* $FDTrans = new FileData($file, true);
* ?>
* </code>
*
* @param string $file File name to inspect
* @param bool $isTrans Define if the specified file is a translation
* @return void
*/
public function __construct($file, $isTrans)
{
self::$tags = implode('|', array('EN-Revision', 'Revision', 'Maintainer', 'Status', 'Credits', 'Rev-Revision', 'Reviewer'));
$this->isTranslation = (bool) $isTrans;
$this->data = array();
$handle = fopen($file, 'r');
for ($i = 0; $i <= 9 || feof($handle); ++$i) {
$rawFile = trim(fgets($handle));
switch (substr($rawFile, 0, 4)) {
case '<!--':
$this->setMetaData($rawFile);
break;
case '<?xm':
break;
default:
$i = 9;
break;
}
}
fclose($handle);
$this->data['size'] = round(filesize($file) / 1024, 0);
$this->data['mtime'] = filemtime($file);
clearstatcache();
return;
}
示例2: serve
protected function serve($file_info)
{
$cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . 'cache'));
if ($file_info->getIsCached() && $cache->has($file_info->getId(), 'uploaded_files')) {
$file_data = new FileData();
$file_data->setBinaryData($cache->get($file_info->getId(), 'uploaded_files'));
} else {
$file_data = $file_info->getFileData();
$cache->set($file_info->getId(), 'uploaded_files', fread($file_data->getBinaryData(), $file_info->getSize()));
$file_info->setIsCached(true);
$file_info->save();
}
sfConfig::set('sf_web_debug', false);
// $this->getResponse()->addHttpMeta('content-type', $file_info->getMime());
// $this->getResponse()->addHttpMeta('content-length', $file_info->getSize());
return $file_data;
}
示例3: filesize
public static function filesize($id)
{
$file = ORM::factory('Storage', $id);
if (!$file->loaded()) {
return '';
}
$size = filesize($file->file_path);
return FileData::size($size);
}
示例4: header
<?php
$file = FileData::getByCode($_GET["code"]);
$url = "storage/data/" . $file->user_id . "/";
$filename = $file->filename;
if (!$file->is_folder) {
$fullurl = $url . $filename;
header("Content-Disposition: attachment; filename='{$filename}'");
readfile($fullurl);
// or echo file_get_contents($filename);
}
示例5: paste_from_file
/**
* Paste_from_file
* Parses a named uploaded file of html or txt type
* The function identifies title, head and body for html files,
* or body for text files.
*
* @return FileData object
*/
function paste_from_file()
{
$fileData = new FileData();
if ($_FILES['uploadedfile_paste']['name'] == '') {
$fileData->setErrorMsg(_AT('TR_ERROR_FILE_NOT_SELECTED'));
} elseif ($_FILES['uploadedfile_paste']['type'] == 'text/plain' || $_FILES['uploadedfile_paste']['type'] == 'text/html') {
$path_parts = pathinfo($_FILES['uploadedfile_paste']['name']);
$ext = strtolower($path_parts['extension']);
if (in_array($ext, array('html', 'htm'))) {
$contents = file_get_contents($_FILES['uploadedfile_paste']['tmp_name']);
/* get the <title></title> of this page */
$start_pos = strpos(strtolower($contents), '<title>');
$end_pos = strpos(strtolower($contents), '</title>');
if ($start_pos !== false && $end_pos !== false) {
$start_pos += strlen('<title>');
$fileData->setTitle(trim(substr($contents, $start_pos, $end_pos - $start_pos)));
}
unset($start_pos);
unset($end_pos);
$fileData->setHead(trim(get_html_head_by_tag($contents, array("link", "style", "script"))));
$fileData->setBody(trim(get_html_body($contents)));
} else {
if ($ext == 'txt') {
$fileData->setBody(trim(file_get_contents($_FILES['uploadedfile_paste']['tmp_name'])));
}
}
} else {
$fileData->setErrorMsg(_AT('TR_ERROR_BAD_FILE_TYPE'));
}
return $fileData;
}
示例6: intval
<?php
include '../../includes/inc.main.php';
if ($_GET['action'] == 'newimage') {
if (count($_FILES['image']) > 0) {
$TempDir = $Admin->ImgGalDir();
$Name = "user" . intval(rand() * rand() / rand()) . "__" . $Admin->AdminID;
$Img = new FileData($_FILES['image'], $TempDir, $Name);
echo $Img->BuildImage(200, 200);
die;
}
}
switch (strtolower($_POST['action'])) {
//////////////////////////////////////////// NEW TEST USER ///////////////////////////////////////////////////////////////
case 'generate':
$curl = curl_init();
curl_setopt_array($curl, array(CURLOPT_URL => "https://api.mercadolibre.com/users/test_user?access_token=" . $_SESSION['access_token'], CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\n \"site_id\":\"MLA\"\n}", CURLOPT_HTTPHEADER => array("cache-control: no-cache", "conten: application/json", "content-type: application/json")));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
//$Data = json_decode($response,true);
//$DB->execQuery('INSERT','test_user','id,nickname,password,site_status,email,creation_date',$Data['id']",'".$Data['nickname']."','".$Data['password']."','".$Data['site_status']."','".$Data['email']."',NOW()");
}
die;
break;
//////////////////////////////////////////// EDIT ///////////////////////////////////////////////////////////////
//////////////////////////////////////////// EDIT ///////////////////////////////////////////////////////////////
示例7: session_start
session_start();
include 'odm-load.php';
if (!isset($_SESSION['uid'])) {
redirect_visitor();
}
$last_message = isset($_REQUEST['last_message']) ? $_REQUEST['last_message'] : '';
if (!isset($_REQUEST['id']) || $_REQUEST['id'] == '') {
header('Location:error.php?ec=2');
exit;
}
draw_header(msg('area_view_history'), $last_message);
//revision parsing
if (strchr($_REQUEST['id'], '_')) {
list($_REQUEST['id'], $revision_id) = explode('_', $_REQUEST['id']);
}
$datafile = new FileData($_REQUEST['id'], $pdo);
// verify
if ($datafile->getError() != null) {
header('Location:error.php?ec=2');
exit;
} else {
// obtain data from resultset
$owner_full_name = $datafile->getOwnerFullName();
$owner = $owner_full_name[1] . ', ' . $owner_full_name[0];
$real_name = $datafile->getRealName();
$category = $datafile->getCategoryName();
$created = $datafile->getCreatedDate();
$description = $datafile->getDescription();
$comments = $datafile->getComment();
$status = $datafile->getStatus();
$id = $_REQUEST['id'];
示例8: dirname
require_once dirname(__FILE__) . "/../../PaygateApiClient.class.php";
require_once dirname(__FILE__) . "/../config.php";
$client = new PaygateApiClient(INVIPAY_API_URL, INVIPAY_API_KEY, INVIPAY_SIGNATURE_KEY);
$repository = dirname(__FILE__) . "/repository/";
$payments = scandir($repository);
Logger::info('Scanning payments repository');
foreach ($payments as $paymentFile) {
if ($paymentFile != '.' && $paymentFile != '..') {
Logger::info('Found payment data {0}', $paymentFile);
$paymentData = unserialize(file_get_contents($repository . $paymentFile));
$paymentId = $paymentData->getPaymentId();
Logger::info('Payment {0} has status {1}', $paymentId, $paymentData->getStatus());
if ($paymentData->getStatus() == PaymentRequestStatus::COMPLETED) {
Logger::info('Finalizing payment {0}', $paymentId);
$request = new PaymentManagementData();
$request->setPaymentId($paymentId);
$request->setDoConfirmDelivery(true);
$conversionData = new OrderToInvoiceData();
$conversionData->setInvoiceDocumentNumber("TestInvoice/1/2/3/" . uniqid());
$conversionData->setIssueDate(date('Y-m-d', time()));
$conversionData->setDueDate(date('Y-m-d', time() + 14 * 24 * 60 * 60));
$request->setConversionData($conversionData);
$document = new FileData();
$document->setFromFile(dirname(__FILE__) . '/../test.pdf');
$request->setDocument($document);
$result = $client->managePayment($request);
Logger::info('Result is: {0}', $result);
}
}
}
示例9: FileData
<?php
$data = new FileData();
if (isset($_GET['idsp'])) {
$idsp = $_GET['idsp'];
//id спецификации
echo '<h3><p align="center">Спецификация</p></h3>';
include 'interf/view_specif.php';
} else {
echo '<h3><p align="center">Таблица метериалы и услуги</p></h3>';
if ($curent_user->QwestPriwilege('VEIW_OLL_TABLE_MATERIAL')) {
$data->ViweMaterialTable($data->GetArrayOrganizationIDfinsek(), $curent_user->GetUsersIdViewname());
}
if ($curent_user->QwestPriwilege('VIEW_MY_TABLE_MATERIAL')) {
$data->ViweMaterialTableFoUsers($data->GetArrayOrganizationIDfinsek(), $curent_user->GetOrganizationID());
}
}
示例10: msg
$mail_subject = msg('email_subject_review_status');
$mail_greeting = msg('email_greeting') . ":\n\r\t" . msg('email_i_would_like_to_inform');
$mail_body = msg('email_was_declined_for_publishing_at') . ' ' . $time . ' on ' . $date . ' ' . msg('email_because_you_did_not_revise') . ' ' . $GLOBALS['CONFIG']['revision_expiration'] . ' ' . msg('days');
$mail_salute = "\n\r\n\r" . msg('email_salute') . ",\n\r{$full_name}";
foreach ($data_result as $row) {
$file_obj = new FileData($row['id'], $pdo);
$user_obj = new User($file_obj->getOwner(), $pdo);
$mail_to = $user_obj->getEmailAddress();
if ($GLOBALS['CONFIG']['demo'] == 'False') {
mail($mail_to, $mail_subject . $file_obj->getName(), $mail_greeting . $file_obj->getName() . ' ' . $mail_body . $mail_salute, $mail_headers);
}
}
}
//do not show file
if ($GLOBALS['CONFIG']['file_expired_action'] == 1) {
$reviewer_comments = 'To=' . msg('author') . ';Subject=' . msg('message_file_expired') . ';Comments=' . msg('email_file_was_rejected_because') . ' ' . $GLOBALS['CONFIG']['revision_expiration'] . ' ' . msg('days');
foreach ($data_result as $row) {
$file_obj = new FileData($row['id'], $pdo);
$file_obj->Publishable(-1);
$file_obj->setReviewerComments($reviewer_comments);
}
}
//lock file, not check-outable
if ($GLOBALS['CONFIG']['file_expired_action'] == 2) {
foreach ($data_result as $row) {
$file_obj = new FileData($row['id'], $pdo);
$file_obj->setStatus(-1);
}
}
echo msg('message_all_actions_successfull');
draw_footer();
示例11: trim
<?php
require_once "Math.php";
require_once "File.php";
$job = !isset($_REQUEST["job"]) ? '' : trim($_REQUEST["job"]);
$evenNumbers = array();
$oddNumbers = array();
$fiboNumbers = array();
$file = array();
if ($job == "uploadFile") {
$file = new FileData($_FILES["aNumbers"]);
//assign data from file to $file object
//get even, odd and fibonacci numbers from file and store in respective arrays
$evenNumbers = $file->GetEvenNumbers();
$oddNumbers = $file->GetOddNumbers();
$fiboNumbers = $file->GetFibonacciNumbers();
if (!isset($_SESSION['file'])) {
$_SESSION['file'] = $file;
}
}
$job = !isset($_GET["job"]) ? '' : trim($_GET["job"]);
if ($job == "exportnumbers") {
//If a valid file was submitted with the submit button, then its details are saved in a session
if (isset($_SESSION['file'])) {
$file = $_SESSION['file'];
$file->ExportNumbers($_SESSION["filename"] . ".csv");
//call ExportNumbers function using the filename stored in a session and adding .csv as an extension
}
}
if ($job == "reset") {
session_destroy();
示例12: strlen
<?php
//print_r($_SESSION);
if (!empty($_POST) && isset($_SESSION["user_id"])) {
$alphabeth = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ1234567890_-";
$code = "";
for ($i = 0; $i < 12; $i++) {
$code .= $alphabeth[rand(0, strlen($alphabeth) - 1)];
}
$f = new FileData();
$f->code = $code;
$f->is_public = isset($_POST["is_public"]) ? 1 : 0;
$f->folder_id = $_POST["folder_id"] != "" ? $_POST["folder_id"] : "NULL";
$f->user_id = $_SESSION["user_id"];
$f->description = $_POST["description"];
$handle = new Upload($_FILES['filename']);
if ($handle->uploaded) {
$url = "storage/data/" . $_SESSION["user_id"];
$handle->Process($url);
if ($handle->processed) {
$f->filename = $handle->file_dst_name;
$f->add();
Core::alert("Agregado exitosamente!");
Core::redir("./?view=home");
}
}
}
示例13: getAuthority
function getAuthority($data_id)
{
$data_id = (int) $data_id;
$fileData = new FileData($data_id, $GLOBALS['connection'], DB_NAME);
if ($this->user_obj->isAdmin() || $this->user_obj->isReviewerForFile($data_id)) {
return $this->ADMIN_RIGHT;
}
if ($fileData->isOwner($this->uid) && $fileData->isLocked()) {
return $this->WRITE_RIGHT;
}
$uperm = $this->userperm_obj->getPermission($data_id);
$dperm = $this->deptperm_obj->getPermission($data_id);
if ($uperm >= $this->userperm_obj->NONE_RIGHT and $uperm <= $this->userperm_obj->ADMIN_RIGHT) {
return $uperm;
} else {
return $dperm;
}
}
示例14: display_smarty_template
$GLOBALS['smarty']->assign('lmode', '');
display_smarty_template('deleteview.tpl');
}
} elseif (isset($_POST['submit']) && $_POST['submit'] == 'Delete file(s)') {
isset($_REQUEST['checkbox']) ? $_REQUEST['checkbox'] : '';
foreach ($_REQUEST['checkbox'] as $value) {
if (!pmt_delete($value)) {
header('Location: error.php?ec=21');
exit;
}
}
header('Location:' . urlencode($redirect) . '?last_message=' . urlencode(msg('undeletepage_file_permanently_deleted')));
} elseif (isset($_REQUEST['submit']) && $_REQUEST['submit'] == 'Undelete') {
if (isset($_REQUEST['checkbox'])) {
foreach ($_REQUEST['checkbox'] as $fileId) {
$file_obj = new FileData($fileId, $pdo);
$file_obj->undelete();
fmove($GLOBALS['CONFIG']['archiveDir'] . $fileId . '.dat', $GLOBALS['CONFIG']['dataDir'] . $fileId . '.dat');
}
}
header('Location:' . urlencode($redirect) . '?last_message=' . urlencode(msg('undeletepage_file_undeleted')));
}
draw_footer();
/*
* Permanently Delete A File
* @param integer $id The file ID to be deleted permanently
*/
function pmt_delete($id)
{
global $pdo;
$userperm_obj = new User_Perms($_SESSION['uid'], $pdo);
示例15: confirmDeliveryAndSendInvoice
public function confirmDeliveryAndSendInvoice($order)
{
$invoices = array();
$invoiceNumbers = array();
if ($order->hasInvoices()) {
foreach ($order->getInvoiceCollection() as $invoiceItem) {
$invoices[] = $invoiceItem;
$invoiceNumbers[] = $invoiceItem->getIncrementId();
}
}
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices);
$pdfData = $pdf->render();
$documentNumber = join(', ', $invoiceNumbers);
$issueDate = strtotime($order->getCreatedAt());
$dueDateDays = intval(Mage::getStoreConfig('payment/ipcpaygate/invipay_base_duedate'));
$dueDate = $issueDate + $dueDateDays * 60 * 60 * 24;
$client = $this->getApiClient();
$request = new PaymentManagementData();
$request->setPaymentId($order->getInvipayPaymentId());
$request->setDoConfirmDelivery(true);
$conversionData = new OrderToInvoiceData();
$conversionData->setInvoiceDocumentNumber($documentNumber);
$conversionData->setIssueDate(date('Y-m-d', $issueDate));
$conversionData->setDueDate(date('Y-m-d', $dueDate));
$request->setConversionData($conversionData);
$document = new FileData();
$document->setName('Zamowienie_nr_' . $order->getEntityId() . '.pdf');
$document->setMimeType('application/pdf');
$document->setContentFromBin($pdfData);
$request->setDocument($document);
$result = $client->managePayment($request);
$order->setInvipayDeliveryConfirmed(true);
$order->setInvipayCompleted(true);
$order->save();
}