本文整理汇总了PHP中Jaws_Utils::upload_tmp_dir方法的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_Utils::upload_tmp_dir方法的具体用法?PHP Jaws_Utils::upload_tmp_dir怎么用?PHP Jaws_Utils::upload_tmp_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jaws_Utils
的用法示例。
在下文中一共展示了Jaws_Utils::upload_tmp_dir方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UploadFile
/**
* Uploads attachment file
*
* @access public
* @return string javascript script segment
*/
function UploadFile()
{
$file_num = jaws()->request->fetch('attachment_number', 'post');
$file = Jaws_Utils::UploadFiles($_FILES, Jaws_Utils::upload_tmp_dir(), '', null);
if (Jaws_Error::IsError($file)) {
$response = array('type' => 'error', 'message' => $file->getMessage());
} else {
$response = array('type' => 'notice', 'file_info' => array('title' => $file['attachment' . $file_num][0]['user_filename'], 'filename' => $file['attachment' . $file_num][0]['host_filename'], 'filesize_format' => Jaws_Utils::FormatSize($file['attachment' . $file_num][0]['host_filesize']), 'filesize' => $file['attachment' . $file_num][0]['host_filesize'], 'filetype' => $file['attachment' . $file_num][0]['host_filetype']));
}
$response = Jaws_UTF8::json_encode($response);
return "<script type='text/javascript'>parent.onUpload({$response});</script>";
}
示例2: LoadUserInfo
/**
*
* @access public
* @return string HTML content with menu and menu items
*/
function LoadUserInfo()
{
$uid = (int) jaws()->request->fetch('uid');
$uModel = new Jaws_User();
$userInfo = $uModel->GetUser($uid, true, true);
$userInfo['avatar_file_name'] = '';
if (empty($userInfo['avatar'])) {
$userInfo['avatar'] = $GLOBALS['app']->getSiteURL('/gadgets/AddressBook/Resources/images/photo128px.png');
} else {
$userAvatar = $GLOBALS['app']->getDataURL() . 'avatar/' . $userInfo['avatar'];
copy($userAvatar, Jaws_Utils::upload_tmp_dir() . '/' . $userInfo['avatar']);
$userInfo['avatar_file_name'] = $userInfo['avatar'];
$userInfo['avatar'] = $GLOBALS['app']->getDataURL() . 'avatar/' . $userInfo['avatar'];
}
return $userInfo;
}
示例3: LoadAvatar
/**
* Returns avatar as stream data
*
* @access public
* @return bool True on success, false otherwise
*/
function LoadAvatar()
{
$file = jaws()->request->fetch('file', 'get');
$objImage = Jaws_Image::factory();
if (!Jaws_Error::IsError($objImage)) {
if (!empty($file)) {
$file = preg_replace("/[^[:alnum:]_\\.\\-]*/i", "", $file);
$result = $objImage->load(Jaws_Utils::upload_tmp_dir() . '/' . $file, true);
if (!Jaws_Error::IsError($result)) {
$result = $objImage->display();
if (!Jaws_Error::IsError($result)) {
return $result;
}
}
}
}
return false;
}
示例4: LoadImage
/**
* Returns menu image as stream data
*
* @access public
* @return bool True on successful, False otherwise
*/
function LoadImage()
{
$params = jaws()->request->fetch(array('id', 'file'), 'get');
$objImage = Jaws_Image::factory();
if (!Jaws_Error::IsError($objImage)) {
if (is_null($params['file'])) {
$model = $this->gadget->model->load('Menu');
$result = $model->GetMenuImage($params['id']);
if (!Jaws_Error::IsError($result)) {
$result = $objImage->setData($result, true);
}
} else {
$params['file'] = preg_replace("/[^[:alnum:]_\\.\\-]*/i", "", $params['file']);
$result = $objImage->load(Jaws_Utils::upload_tmp_dir() . '/' . $params['file'], true);
}
if (!Jaws_Error::IsError($result)) {
$result = $objImage->display();
if (!Jaws_Error::IsError($result)) {
return $result;
}
}
}
return false;
}
示例5: PrepareForImport
//.........这里部分代码省略.........
case 'home':
$telHome[] = $prefixKey . ':' . $Tel['Value'];
break;
case 'work':
$telWork[] = $prefixKey . ':' . $Tel['Value'];
break;
case 'other':
$telOther[] = $prefixKey . ':' . $Tel['Value'];
break;
}
} else {
$prefixKey = $this->_DefaultTelTypes['voice'];
foreach ($this->_DefaultTelTypes as $tellType => $key) {
if (in_array($tellType, $Tel['Type'])) {
$prefixKey = $key;
}
}
$telOther[] = $prefixKey . ':' . $Tel['Value'];
}
}
}
$data['tel_home'] = implode(',', $telHome);
$data['tel_work'] = implode(',', $telWork);
$data['tel_other'] = implode(',', $telOther);
}
if ($vCard->EMAIL) {
$emailHome = array();
$emailWork = array();
$emailOther = array();
foreach ($vCard->EMAIL as $Email) {
if (is_scalar($Email)) {
$emailOther[] = $this->_DefaultEmailTypes . ':' . $Email['Value'];
} else {
$prefixKey = 0;
foreach ($this->_EmailTypes as $key => $emailType) {
if (in_array($emailType['fieldType'], $Email['Type'])) {
$prefixKey = $key;
}
}
if (!empty($this->_EmailTypes[$prefixKey])) {
switch ($this->_EmailTypes[$prefixKey]['fieldType']) {
case 'home':
$emailHome[] = $prefixKey . ':' . $Email['Value'];
break;
case 'work':
$emailWork[] = $prefixKey . ':' . $Email['Value'];
break;
case 'other':
$emailOther[] = $prefixKey . ':' . $Email['Value'];
break;
}
} else {
$emailOther[] = $this->_DefaultEmailTypes . ':' . $Email['Value'];
}
}
}
$data['email_home'] = implode(',', $emailHome);
$data['email_work'] = implode(',', $emailWork);
$data['email_other'] = implode(',', $emailOther);
}
if ($vCard->URL) {
$data['url'] = implode('\\n', $vCard->URL);
}
if ($vCard->PHOTO) {
foreach ($vCard->PHOTO as $Photo) {
if ($Photo['Encoding'] == 'b') {
$vCard->SaveFile('photo', 0, Jaws_Utils::upload_tmp_dir() . '/test_image.' . $Photo['Type'][0]);
$data['image'] = 'test_image.' . $Photo['Type'][0];
break;
}
}
}
if ($vCard->ADR) {
$adrHome = array();
$adrWork = array();
$adrOther = array();
foreach ($vCard->ADR as $Address) {
$adr = $Address['StreetAddress'] ? $Address['StreetAddress'] . ' ' : '';
$adr .= $Address['POBox'] ? $Address['POBox'] . ' ' : '';
$adr .= $Address['ExtendedAddress'] ? $Address['ExtendedAddress'] . ' ' : '';
$adr .= $Address['Locality'] ? $Address['Locality'] . ' ' : '';
$adr .= $Address['Region'] ? $Address['Region'] . ' ' : '';
$adr .= $Address['PostalCode'] ? $Address['PostalCode'] . ' ' : '';
$adr .= $Address['Country'] ? $Address['Country'] . ' ' : '';
if (in_array('home', $Address['Type'])) {
$adrHome[] = '1:' . $adr;
} elseif (in_array('work', $Address['Type'])) {
$adrWork[] = '2:' . $adr;
} else {
$adrOther[] = '3:' . $adr;
}
}
$data['adr_home'] = implode('\\n ', $adrHome);
$data['adr_work'] = implode('\\n ', $adrWork);
$data['adr_other'] = implode('\\n ', $adrOther);
}
$data['public'] = false;
$data['[user]'] = (int) $GLOBALS['app']->Session->GetAttribute('user');
return $data;
}
示例6: SendEmail
/**
* Sends the Email
*
* @access public
* @param string $target JSON decoded array ([to, cc, bcc] or [user, group])
* @param string $subject Subject of the Email
* @param string $message Message body of the Email
* @param string $attachment Attachment
* @return string XHTML template content
*/
function SendEmail($target, $subject, $message, $attachment)
{
$this->gadget->CheckPermission('AccessToMailer');
$mail = Jaws_Mail::getInstance();
$mail->SetFrom();
$mail->SetSubject(Jaws_XSS::defilter($subject));
// To, Cc, Bcc
if (isset($target['to'])) {
if (!empty($target['to'])) {
$recipients = explode(',', $target['to']);
foreach ($recipients as $recpt) {
$mail->AddRecipient($recpt, 'To');
}
}
if (!empty($target['cc'])) {
$recipients = explode(',', $target['cc']);
foreach ($recipients as $recpt) {
$mail->AddRecipient($recpt, 'Cc');
}
}
if (!empty($target['bcc'])) {
$recipients = explode(',', $target['bcc']);
foreach ($recipients as $recpt) {
$mail->AddRecipient($recpt, 'Bcc');
}
}
} else {
$userModel = new Jaws_User();
if ($target['user'] != 0) {
$user = $userModel->GetUser((int) $target['user']);
if (!Jaws_Error::IsError($user)) {
$mail->AddRecipient($user['nickname'] . ' <' . $user['email'] . '>', 'To');
}
} else {
if ($target['group'] == 0) {
$target['group'] = false;
}
$users = $userModel->GetUsers($target['group'], null, true);
foreach ($users as $user) {
$mail->AddRecipient($user['nickname'] . ' <' . $user['email'] . '>', 'Bcc');
}
}
}
$message = $this->PrepareMessage($message);
$format = $this->gadget->registry->fetch('email_format');
$mail->SetBody($message, $format);
if (!empty($attachment)) {
$attachment = Jaws_Utils::upload_tmp_dir() . '/' . $attachment;
if (file_exists($attachment)) {
$mail->SetBody($attachment, 'file');
Jaws_Utils::Delete($attachment);
}
}
$result = $mail->send();
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_ERROR_EMAIL_NOT_SENT'), RESPONSE_ERROR);
return false;
}
$GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_NOTICE_EMAIL_SENT'), RESPONSE_NOTICE);
return true;
}
示例7: UpdatePersonal
/**
* Update personal information of a user such as fname, lname, gender, etc..
*
* @access public
* @param int $id User's ID
* @param array $pData Personal information data
* @return bool Returns true on success, false on failure
*/
function UpdatePersonal($id, $pData)
{
// unset invalid keys
$invalids = array_diff(array_keys($pData), array('fname', 'lname', 'gender', 'ssn', 'dob', 'url', 'signature', 'about', 'experiences', 'occupations', 'interests', 'avatar', 'privacy'));
foreach ($invalids as $invalid) {
unset($pData[$invalid]);
}
if (array_key_exists('avatar', $pData)) {
// get user information
$user = Jaws_User::GetUser((int) $id, true, true);
if (Jaws_Error::IsError($user) || empty($user)) {
return false;
}
if (!empty($user['avatar'])) {
Jaws_Utils::Delete(AVATAR_PATH . $user['avatar']);
}
if (!empty($pData['avatar'])) {
$fileinfo = pathinfo($pData['avatar']);
if (isset($fileinfo['extension']) && !empty($fileinfo['extension'])) {
if (!in_array($fileinfo['extension'], array('gif', 'jpg', 'jpeg', 'png', 'svg'))) {
return false;
} else {
$new_avatar = $user['username'] . '.' . $fileinfo['extension'];
@rename(Jaws_Utils::upload_tmp_dir() . '/' . $pData['avatar'], AVATAR_PATH . $new_avatar);
$pData['avatar'] = $new_avatar;
}
}
}
}
$pData['last_update'] = time();
$usersTable = Jaws_ORM::getInstance()->table('users');
$result = $usersTable->update($pData)->where('id', $id)->exec();
if (Jaws_Error::IsError($result)) {
return $result;
}
if (isset($GLOBALS['app']->Session) && $GLOBALS['app']->Session->GetAttribute('user') == $id) {
foreach ($pData as $k => $v) {
if ($k == 'avatar') {
$GLOBALS['app']->Session->SetAttribute($k, $this->GetAvatar($v, $user['email'], 48, $pData['last_update']));
} else {
$GLOBALS['app']->Session->SetAttribute($k, $v);
}
}
}
// Let everyone know a user has been updated
$res = $GLOBALS['app']->Listener->Shout('Users', 'UpdateUser', $id);
if (Jaws_Error::IsError($res)) {
return false;
}
return true;
}
示例8: SendMessage
//.........这里部分代码省略.........
$data['insert_time'] = time();
$senderMessageId = $mTable->insert($data)->exec();
}
} else {
// update message
$mTable->update($data)->where('id', $messageData['id'])->exec();
$senderMessageId = $messageData['id'];
}
// Insert message for every recipient
if (!empty($recipient_users) && count($recipient_users) > 0) {
$table = $table->table('pm_messages');
$from = $is_notification ? 0 : $user;
$data['folder'] = $messageData['folder'];
foreach ($recipient_users as $recipient_user) {
$data['insert_time'] = time();
$data['from'] = $from;
$data['to'] = $recipient_user;
$data['read'] = false;
$messageId = $table->insert($data)->exec();
if (Jaws_Error::IsError($messageId)) {
//Rollback Transaction
$table->rollback();
return false;
}
$messageIds[] = $messageId;
// send notification on new private message
if (!$is_notification) {
$params = array();
$params['key'] = crc32('PrivateMessage' . $senderMessageId);
$params['title'] = _t('PRIVATEMESSAGE_NEW_MESSAGE_NOTIFICATION_TITLE');
$params['summary'] = _t('PRIVATEMESSAGE_NEW_MESSAGE_NOTIFICATION');
$params['description'] = _t('PRIVATEMESSAGE_NEW_MESSAGE_NOTIFICATION_DESC', $data['subject']);
$params['user'] = (int) $recipient_user;
$this->gadget->event->shout('Notify', $params);
}
}
}
}
// Insert attachments info
if (!empty($messageData['attachments']) && count($messageData['attachments']) > 0) {
$maData = array();
$pm_dir = JAWS_DATA . 'pm' . DIRECTORY_SEPARATOR . 'attachments' . DIRECTORY_SEPARATOR;
foreach ($messageData['attachments'] as $attachment) {
// check new attachments file -- we must copy tmp files to correct location
if (is_array($attachment)) {
$src_filepath = Jaws_Utils::upload_tmp_dir() . '/' . $attachment['filename'];
$dest_filepath = $pm_dir . $attachment['filename'];
if (!file_exists($src_filepath)) {
continue;
}
if (!file_exists($pm_dir)) {
if (!Jaws_Utils::mkdir($pm_dir)) {
return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', JAWS_DATA));
}
}
$cres = Jaws_Utils::rename($src_filepath, $dest_filepath);
Jaws_Utils::delete($src_filepath);
if ($cres) {
$aData = array('title' => $attachment['title'], 'filename' => $attachment['filename'], 'filesize' => $attachment['filesize'], 'filetype' => $attachment['filetype']);
$table = $table->table('pm_attachments');
$attachmentId = $table->insert($aData)->exec();
if (Jaws_Error::IsError($attachmentId)) {
//Rollback Transaction
$table->rollback();
return false;
}
// Add sender message Id to pm_message_attachment table
$maData[] = array('message' => $senderMessageId, 'attachment' => $attachmentId);
// Add recipient message Id to pm_message_attachment table
foreach ($messageIds as $messageId) {
$maData[] = array('message' => $messageId, 'attachment' => $attachmentId);
}
}
} else {
// Add sender message Id to pm_message_attachment table
$maData[] = array('message' => $senderMessageId, 'attachment' => $attachment);
// Add recipient message Id to pm_message_attachment table
foreach ($messageIds as $messageId) {
$maData[] = array('message' => $messageId, 'attachment' => $attachment);
}
}
}
if (!empty($maData) && count($maData) > 0) {
$table = $table->table('pm_message_attachment');
$res = $table->insertAll(array('message', 'attachment'), $maData)->exec();
if (Jaws_Error::IsError($res)) {
//Rollback Transaction
$table->rollback();
return false;
}
} else {
//Rollback Transaction
$table->rollback();
return false;
}
}
//Commit Transaction
$mTable->commit();
return $senderMessageId;
}
示例9: UploadFile
/**
* Uploads file to system temp directory
*
* @access public
* @return string JavaScript snippet
*/
function UploadFile()
{
$res = Jaws_Utils::UploadFiles($_FILES, Jaws_Utils::upload_tmp_dir(), '', null);
if (Jaws_Error::IsError($res)) {
$response = array('type' => 'error', 'message' => $res->getMessage());
} else {
$response = array('type' => 'notice', 'user_filename' => $res['file'][0]['user_filename'], 'host_filename' => $res['file'][0]['host_filename'], 'filetype' => $res['file'][0]['host_filetype'], 'filesize' => $res['file'][0]['host_filesize']);
}
$response = Jaws_UTF8::json_encode($response);
return "<script>parent.onUpload({$response});</script>";
}
示例10: UpdatePersonal
/**
* Updates user personal
*
* @access public
* @return void
*/
function UpdatePersonal()
{
if (!$GLOBALS['app']->Session->Logged()) {
Jaws_Header::Location($this->gadget->urlMap('LoginBox', array('referrer' => bin2hex(Jaws_Utils::getRequestURL(true)))));
}
$this->gadget->CheckPermission('EditUserPersonal');
$post = jaws()->request->fetch(array('fname', 'lname', 'gender', 'ssn', 'dob', 'url', 'signature', 'about', 'avatar', 'delete_avatar', 'experiences', 'occupations', 'interests'), 'post');
if (!empty($post['dob'])) {
$post['dob'] = Jaws_Date::getInstance()->ToBaseDate(explode('-', $post['dob']), 'Y-m-d');
} else {
$post['dob'] = null;
}
// validate url
if (!preg_match('|^\\S+://\\S+\\.\\S+.+$|i', $post['url'])) {
$post['url'] = '';
}
unset($post['avatar']);
if (empty($post['delete_avatar'])) {
$res = Jaws_Utils::UploadFiles($_FILES, Jaws_Utils::upload_tmp_dir(), 'gif,jpg,jpeg,png,svg');
if (Jaws_Error::IsError($res)) {
$GLOBALS['app']->Session->PushResponse($res->GetMessage(), 'Users.Personal.Response', RESPONSE_ERROR, $post);
Jaws_Header::Location($this->gadget->urlMap('Personal'));
} elseif (!empty($res)) {
$post['avatar'] = $res['avatar'][0]['host_filename'];
}
} else {
$post['avatar'] = '';
}
$model = $this->gadget->model->load('Personal');
$result = $model->UpdatePersonal($GLOBALS['app']->Session->GetAttribute('user'), $post);
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushResponse($result->GetMessage(), 'Users.Personal.Response', RESPONSE_ERROR, $post);
} else {
$GLOBALS['app']->Session->PushResponse(_t('USERS_USERS_PERSONALINFO_UPDATED'), 'Users.Personal.Response');
}
Jaws_Header::Location($this->gadget->urlMap('Personal'));
}
示例11: UpdateAddress
/**
* Insert New AddressBook Data to DB
*
* @access public
* @returns array of Address Books or Jaws_Error on error
*/
function UpdateAddress($id, $data)
{
$data['public'] = (bool) $data['public'];
$data['updatetime'] = time();
$targetDir = JAWS_DATA . 'addressbook' . DIRECTORY_SEPARATOR;
if (array_key_exists('image', $data)) {
// get address information
$adr = $this->GetAddressInfo((int) $id);
if (Jaws_Error::IsError($adr) || empty($adr)) {
return false;
}
if (!empty($adr['image'])) {
Jaws_Utils::Delete($targetDir . 'image' . DIRECTORY_SEPARATOR . $adr['image']);
}
if (!empty($data['image'])) {
$fileinfo = pathinfo($data['image']);
if (isset($fileinfo['extension']) && !empty($fileinfo['extension'])) {
if (!in_array($fileinfo['extension'], array('gif', 'jpg', 'jpeg', 'png'))) {
return false;
} else {
if (!is_dir($targetDir)) {
Jaws_Utils::mkdir($targetDir);
}
$targetDir = $targetDir . 'image' . DIRECTORY_SEPARATOR;
if (!is_dir($targetDir)) {
Jaws_Utils::mkdir($targetDir);
}
$new_image = $adr['id'] . '.' . $fileinfo['extension'];
rename(Jaws_Utils::upload_tmp_dir() . '/' . $data['image'], $targetDir . $new_image);
$data['image'] = $new_image;
}
}
}
}
$adrTable = Jaws_ORM::getInstance()->table('address_book');
return $adrTable->update($data)->where('id', (int) $id)->exec();
}
示例12: UpdateMenu
/**
* Updates the menu
*
* @access public
* @param int $mid menu ID
* @param int $pid
* @param int $gid group ID
* @param string $type
* @param string $acl
* @param string $title
* @param string $url
* @param string $url_target
* @param string $rank
* @param bool $published Published status
* @param string $image
* @return bool True on success or False on failure
*/
function UpdateMenu($mid, $pid, $gid, $type, $acl, $title, $url, $url_target, $rank, $published, $image)
{
$model = $this->gadget->model->load('Menu');
$oldMenu = $model->GetMenu($mid);
if (Jaws_Error::IsError($oldMenu)) {
$GLOBALS['app']->Session->PushLastResponse(_t('MENU_ERROR_GET_MENUS'), RESPONSE_ERROR);
return false;
}
$mData['pid'] = $pid;
$mData['gid'] = $gid;
$mData['menu_type'] = $type;
$mData['title'] = $title;
$mData['url'] = $url;
$mData['url_target'] = $url_target;
$mData['rank'] = $rank;
$mData['published'] = (bool) $published;
if ($image !== 'true') {
if (empty($image)) {
$mData['image'] = null;
} else {
$image = preg_replace("/[^[:alnum:]_\\.\\-]*/i", "", $image);
$filename = Jaws_Utils::upload_tmp_dir() . '/' . $image;
$mData['image'] = array('File://' . $filename, 'blob');
}
}
// ACL
if (!empty($acl)) {
$aclInfo = explode(':', $acl);
$mData['acl_key_name'] = $aclInfo[0];
$mData['acl_key_subkey'] = $aclInfo[1];
} else {
$mData['acl_key_name'] = null;
$mData['acl_key_subkey'] = null;
}
$menusTable = Jaws_ORM::getInstance()->table('menus');
$res = $menusTable->update($mData)->where('id', $mid)->exec();
if (Jaws_Error::IsError($res)) {
$GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_QUERY_FAILED'), RESPONSE_ERROR);
return false;
}
if (isset($filename)) {
Jaws_Utils::Delete($filename);
}
$this->MoveMenu($mid, $gid, $oldMenu['gid'], $pid, $oldMenu['pid'], $rank, $oldMenu['rank']);
$GLOBALS['app']->Session->PushLastResponse(_t('MENU_NOTICE_MENU_UPDATED'), RESPONSE_NOTICE);
return true;
}