本文整理汇总了PHP中Jaws_Header::Referrer方法的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_Header::Referrer方法的具体用法?PHP Jaws_Header::Referrer怎么用?PHP Jaws_Header::Referrer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jaws_Header
的用法示例。
在下文中一共展示了Jaws_Header::Referrer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Link
/**
* Redirect to the URL and increase the clicks by one
*
* @access public
*/
function Link()
{
$lid = jaws()->request->fetch('id', 'get');
$lid = Jaws_XSS::defilter($lid);
$model = $this->gadget->model->load('Links');
$link = $model->GetLink($lid);
if (!Jaws_Error::IsError($link) && !empty($link)) {
$click = $model->Click($link['id']);
if (!Jaws_Error::IsError($click)) {
Jaws_Header::Location($link['url'], null, 301);
}
}
// By default, on the errors stay in the main page
Jaws_Header::Referrer();
}
示例2: Export
/**
* Export language
*
* @access public
* @return void
*/
function Export()
{
$lang = jaws()->request->fetch('lang', 'get');
require_once PEAR_PATH . 'File/Archive.php';
$tmpDir = sys_get_temp_dir();
$tmpFileName = "{$lang}.tar";
$tmpArchiveName = $tmpDir . DIRECTORY_SEPARATOR . $tmpFileName;
$writerObj = File_Archive::toFiles();
$src = File_Archive::read(JAWS_DATA . "languages/{$lang}", $lang);
$dst = File_Archive::toArchive($tmpArchiveName, $writerObj);
$res = File_Archive::extract($src, $dst);
if (!PEAR::isError($res)) {
return Jaws_Utils::Download($tmpArchiveName, $tmpFileName);
}
Jaws_Header::Referrer();
}
示例3: CreateNote
/**
* Creates a new note
*
* @access public
* @return array Response array
*/
function CreateNote()
{
$data = jaws()->request->fetch(array('title', 'content'), 'post');
if (empty($data['title']) || empty($data['content'])) {
$GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_INCOMPLETE_DATA'), 'Notepad.Response', RESPONSE_ERROR, $data);
Jaws_Header::Referrer();
}
$model = $this->gadget->model->load('Notepad');
$data['user'] = (int) $GLOBALS['app']->Session->GetAttribute('user');
$data['title'] = Jaws_XSS::defilter($data['title']);
$data['content'] = Jaws_XSS::defilter($data['content']);
$result = $model->Insert($data);
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_NOTE_CREATE'), 'Notepad.Response', RESPONSE_ERROR, $data);
Jaws_Header::Referrer();
}
$GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_NOTICE_NOTE_CREATED'), 'Notepad.Response');
Jaws_Header::Location($this->gadget->urlMap('Notepad'));
}
示例4: ExportLogs
/**
* Export Logs
*
* @access public
* @return void
*/
function ExportLogs()
{
$this->gadget->CheckPermission('ExportLogs');
$filters = jaws()->request->fetch(array('from_date', 'to_date', 'gname', 'user', 'priority', 'status'), 'get');
$filters['gadget'] = $filters['gname'];
unset($filters['gname']);
$model = $this->gadget->model->load('Logs');
$logs = $model->GetLogs($filters);
if (Jaws_Error::IsError($logs) || count($logs) < 1) {
return;
}
$tmpDir = sys_get_temp_dir();
$tmpCSVFileName = uniqid(rand(), true) . '.csv';
$fp = fopen($tmpDir . DIRECTORY_SEPARATOR . $tmpCSVFileName, 'w');
$date = Jaws_Date::getInstance();
foreach ($logs as $log) {
$exportData = '';
$exportData .= $log['id'] . ',';
$exportData .= $log['username'] . ',';
$exportData .= $log['gadget'] . ',';
$exportData .= $log['action'] . ',';
$exportData .= $log['priority'] . ',';
$exportData .= $log['apptype'] . ',';
$exportData .= $log['backend'] . ',';
$exportData .= long2ip($log['ip']) . ',';
$exportData .= $log['status'] . ',';
$exportData .= $date->Format($log['insert_time'], 'Y-m-d H:i:s');
$exportData .= PHP_EOL;
fwrite($fp, $exportData);
}
fclose($fp);
require_once PEAR_PATH . 'File/Archive.php';
$tmpFileName = uniqid(rand(), true) . '.tar.gz';
$tmpArchiveName = $tmpDir . DIRECTORY_SEPARATOR . $tmpFileName;
$writerObj = File_Archive::toFiles();
$src = File_Archive::read($tmpDir . DIRECTORY_SEPARATOR . $tmpCSVFileName);
$dst = File_Archive::toArchive($tmpArchiveName, $writerObj);
$res = File_Archive::extract($src, $dst);
if (!PEAR::isError($res)) {
return Jaws_Utils::Download($tmpArchiveName, $tmpFileName);
}
Jaws_Header::Referrer();
}
示例5: UpdateGroup
/**
* Update Selected AddressBook Group Data.
*
* @access public
* @return string HTML content with menu and menu items
*/
function UpdateGroup()
{
if (!$GLOBALS['app']->Session->Logged()) {
return Jaws_HTTPError::Get(403);
}
$post = jaws()->request->fetch(array('name', 'description'), 'post');
$gid = (int) jaws()->request->fetch('gid', 'post');
$model = $this->gadget->model->load('Groups');
$info = $model->GetGroupInfo($gid);
if (!isset($info)) {
return Jaws_HTTPError::Get(404);
}
if ($info['user'] != $GLOBALS['app']->Session->GetAttribute('user')) {
return Jaws_HTTPError::Get(403);
}
if (empty($post['name']) || trim($post['name']) == '') {
$GLOBALS['app']->Session->PushResponse(_t('ADDRESSBOOK_GROUPS_EMPTY_NAME_WARNING'), 'AddressBook.Groups', RESPONSE_WARNING);
Jaws_Header::Referrer();
}
$post['[description]'] = $post['description'];
unset($post['description']);
$result = $model->UpdateGroup($gid, $post);
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushResponse($result->getMessage(), 'AddressBook.Groups', RESPONSE_ERROR);
Jaws_Header::Referrer();
} else {
$GLOBALS['app']->Session->PushResponse(_t('ADDRESSBOOK_RESULT_EDIT_GROUP_SAVED'), 'AddressBook.AdrGroups');
$link = $this->gadget->urlMap('GroupMembers', array('id' => $gid));
Jaws_Header::Location($link);
}
}
示例6: Vote
/**
* Adds a new vote to an answer of a certain poll
*
* @access public
*/
function Vote()
{
$post = jaws()->request->fetch(array('pid', 'answers:array'), 'post');
$model = $this->gadget->model->load('Poll');
$poll = $model->GetPoll((int) $post['pid']);
if (!Jaws_Error::IsError($poll) && !empty($poll)) {
if (($poll['poll_type'] == 1 || !$GLOBALS['app']->Session->GetCookie('poll_' . $poll['id'])) && is_array($post['answers']) && count($post['answers']) > 0) {
$GLOBALS['app']->Session->SetCookie('poll_' . $poll['id'], 'voted', (int) $this->gadget->registry->fetch('cookie_period') * 24 * 60);
foreach ($post['answers'] as $aid) {
$model->AddAnswerVote($poll['id'], (int) $aid);
}
}
}
$GLOBALS['app']->Session->PushSimpleResponse(_t('POLL_THANKS'), 'Poll');
Jaws_Header::Referrer();
}
示例7: UpdateNote
/**
* Updates note
*
* @access public
* @return array Response array
*/
function UpdateNote()
{
$data = jaws()->request->fetch(array('id', 'title', 'content'), 'post');
if (empty($data['id']) || empty($data['title']) || empty($data['content'])) {
$GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_INCOMPLETE_DATA'), 'Notepad.Response', RESPONSE_ERROR, $data);
Jaws_Header::Referrer();
}
// Validate note
$model = $this->gadget->model->load('Notepad');
$id = (int) $data['id'];
$user = (int) $GLOBALS['app']->Session->GetAttribute('user');
$note = $model->GetNote($id, $user);
if (Jaws_Error::IsError($note)) {
$GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_RETRIEVING_DATA'), 'Notepad.Response', RESPONSE_ERROR);
Jaws_Header::Referrer();
}
// Verify owner
if ($note['user'] != $user) {
$GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_NO_PERMISSION'), 'Notepad.Response', RESPONSE_ERROR);
Jaws_Header::Referrer();
}
$data['title'] = Jaws_XSS::defilter($data['title']);
$data['content'] = Jaws_XSS::defilter($data['content']);
$result = $model->Update($id, $data);
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_NOTE_UPDATE'), 'Notepad.Response', RESPONSE_ERROR, $data);
Jaws_Header::Referrer();
}
$GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_NOTICE_NOTE_UPDATED'), 'Notepad.Response');
Jaws_Header::Location($this->gadget->urlMap('Notepad'));
}
示例8: PostMessage
/**
* Adds a new entry to the comments, sets cookie with user data and redirects to main page
*
* @access public
* @return void
*/
function PostMessage()
{
$post = jaws()->request->fetch(array('message', 'name', 'email', 'url', 'url2', 'requested_gadget', 'requested_action', 'reference', 'is_private'), 'post');
if ($GLOBALS['app']->Session->Logged()) {
$post['name'] = $GLOBALS['app']->Session->GetAttribute('nickname');
$post['email'] = $GLOBALS['app']->Session->GetAttribute('email');
$post['url'] = $GLOBALS['app']->Session->GetAttribute('url');
}
if (trim($post['message']) == '' || trim($post['name']) == '') {
$GLOBALS['app']->Session->PushResponse(_t('COMMENTS_COMMENT_INCOMPLETE_FIELDS'), 'Comments', RESPONSE_ERROR, $post);
Jaws_Header::Referrer();
}
/* lets check if it's spam
* it's rather common that spam engines
* fill out all inputs and this one is hidden
* via CSS so not many engines are smart enough
* to not fill this out
*/
if (!empty($post['url2'])) {
$GLOBALS['app']->Session->PushResponse(_t('COMMENTS_FAILED_SPAM_CHECK_MESSAGES'), 'Comments', RESPONSE_ERROR, $post);
Jaws_Header::Referrer();
}
$mPolicy = Jaws_Gadget::getInstance('Policy')->action->load('Captcha');
$resCheck = $mPolicy->checkCaptcha();
if (Jaws_Error::IsError($resCheck)) {
$GLOBALS['app']->Session->PushResponse($resCheck->getMessage(), 'Comments', RESPONSE_ERROR, $post);
Jaws_Header::Referrer();
}
$permalink = $GLOBALS['app']->GetSiteURL();
$status = $this->gadget->registry->fetch('default_comment_status');
if ($this->gadget->GetPermission('ManageComments')) {
$status = Comments_Info::COMMENTS_STATUS_APPROVED;
}
$objHook = Jaws_Gadget::getInstance($post['requested_gadget'])->hook->load('Comments');
if (Jaws_Error::IsError($objHook)) {
$GLOBALS['app']->Session->PushResponse($objHook->getMessage(), 'Comments', RESPONSE_ERROR, $post);
Jaws_Header::Referrer();
}
$reference = $objHook->Execute($post['requested_action'], $post['reference']);
if (empty($reference)) {
$GLOBALS['app']->Session->PushResponse(_t('COMMENTS_ERROR_REFERENCE_EXISTS'), 'Comments', RESPONSE_ERROR, $post);
Jaws_Header::Referrer();
}
$res = $this->gadget->model->load('EditComments')->insertComment($post['requested_gadget'], $post['reference'], $post['requested_action'], $post['name'], $post['email'], $post['url'], $post['message'], $_SERVER['REMOTE_ADDR'], $permalink, $status, $post['is_private']);
if (Jaws_Error::isError($res)) {
$GLOBALS['app']->Session->PushResponse($res->getMessage(), 'Comments', RESPONSE_ERROR, $post);
} else {
$this->EmailComment($reference, $post['message']);
$GLOBALS['app']->Session->PushResponse(_t('COMMENTS_MESSAGE_SENT'), 'Comments');
}
Jaws_Header::Location($reference['url']);
}
示例9: PublishTopic
/**
* Publish/Draft a topic
*
* @access public
*/
function PublishTopic()
{
if (!$GLOBALS['app']->Session->Logged()) {
return Jaws_HTTPError::Get(403);
}
$this->gadget->CheckPermission('PublishTopic');
$rqst = jaws()->request->fetch(array('fid', 'tid', 'notification'), 'get');
$tModel = $this->gadget->model->load('Topics');
$topic = $tModel->GetTopic($rqst['tid'], $rqst['fid']);
if (Jaws_Error::IsError($topic)) {
// redirect to referrer page
Jaws_Header::Referrer();
}
// check user permissions
$logged_user = (int) $GLOBALS['app']->Session->GetAttribute('user');
if ($logged_user != $topic['first_post_uid'] && !$this->gadget->GetPermission('ForumManage', $topic['fid'])) {
return Jaws_HTTPError::Get(403);
}
$result = $tModel->PublishTopic($topic['id'], $topic['fid'], !$topic['published']);
if (Jaws_Error::IsError($result)) {
// do nothing
}
$event_type = $topic['published'] ? 'published' : 'draft';
$topic_link = $this->gadget->urlMap('Posts', array('fid' => $topic['fid'], 'tid' => $topic['id']), true);
$result = $tModel->TopicNotification($event_type, $topic['forum_title'], $topic_link, $topic['subject'], $this->gadget->ParseText($topic['message'], 'Forums', 'index'));
if (Jaws_Error::IsError($result)) {
// do nothing
}
// redirect to referrer page
Jaws_Header::Referrer();
}
示例10: Logout
/**
* Logout user
*
* @access public
* @return void
*/
function Logout()
{
$GLOBALS['app']->Session->Logout();
Jaws_Header::Referrer();
}
示例11: DeletePost
/**
* Delete a post
*
* @access public
*/
function DeletePost()
{
if (!$GLOBALS['app']->Session->Logged()) {
return Jaws_HTTPError::Get(403);
}
$rqst = jaws()->request->fetch(array('fid', 'tid', 'pid', 'delete_reason', 'notification', 'confirm'));
$pModel = $this->gadget->model->load('Posts');
$post = $pModel->GetPost($rqst['pid'], $rqst['tid'], $rqst['fid']);
if (Jaws_Error::IsError($post) || empty($post) || $post['id'] == $post['topic_first_post_id']) {
return false;
}
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
$topic_link = $this->gadget->urlMap('Posts', array('fid' => $post['fid'], 'tid' => $post['tid']), true);
if (!is_null($rqst['confirm'])) {
// delete min limit time
$delete_limit_time = (int) $this->gadget->registry->fetch('edit_min_limit_time');
// check delete permissions
$forumManage = $this->gadget->GetPermission('ForumManage', $post['fid']);
if (!$this->gadget->GetPermission('DeletePost') || $post['uid'] != (int) $GLOBALS['app']->Session->GetAttribute('user') && !$forumManage || $post['topic_locked'] && !$forumManage || time() - $post['insert_time'] > $delete_limit_time && !$forumManage) {
return Jaws_HTTPError::Get(403);
}
$result = $pModel->DeletePost($post['id'], $post['tid'], $post['fid']);
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushSimpleResponse(_t('FORUMS_POSTS_DELETE_ERROR'), 'DeletePost');
// redirect to referrer page
Jaws_Header::Referrer();
}
$send_notification = $this->gadget->GetPermission('ForumManage', $post['fid']) ? (bool) $rqst['notification'] : true;
// send delete notification
if ($send_notification) {
$result = $pModel->PostNotification('', 'delete', $post['forum_title'], $topic_link, $post['subject'], $this->gadget->ParseText($post['message'], 'Forums', 'index', 'index'), $this->gadget->ParseText($rqst['delete_reason'], 'Forums', 'index'));
if (Jaws_Error::IsError($result)) {
// do nothing
}
}
}
// redirect to topic posts list
Jaws_Header::Location($topic_link);
} else {
$tpl = $this->gadget->template->load('DeletePost.html');
$tpl->SetBlock('post');
$tpl->SetVariable('fid', $post['fid']);
$tpl->SetVariable('tid', $post['tid']);
$tpl->SetVariable('pid', $post['id']);
$tpl->SetVariable('findex_title', _t('FORUMS_FORUMS'));
$tpl->SetVariable('findex_url', $this->gadget->urlMap('Forums'));
$tpl->SetVariable('forum_title', $post['forum_title']);
$tpl->SetVariable('forum_url', $this->gadget->urlMap('Topics', array('fid' => $post['fid'])));
$tpl->SetVariable('topic_title', $post['subject']);
$tpl->SetVariable('topic_url', $this->gadget->urlMap('Posts', array('fid' => $post['fid'], 'tid' => $post['tid'])));
$tpl->SetVariable('title', _t('FORUMS_POSTS_DELETE_TITLE'));
// error response
if ($response = $GLOBALS['app']->Session->PopSimpleResponse('DeletePost')) {
$tpl->SetVariable('msg', $response);
}
// date format
$date_format = $this->gadget->registry->fetch('date_format');
$date_format = empty($date_format) ? 'DN d MN Y' : $date_format;
// post meta data
$tpl->SetVariable('postedby_lbl', _t('FORUMS_POSTEDBY'));
$tpl->SetVariable('username', $post['username']);
$tpl->SetVariable('nickname', $post['nickname']);
$tpl->SetVariable('user_url', $GLOBALS['app']->Map->GetURLFor('Users', 'Profile', array('user' => $post['username'])));
$objDate = Jaws_Date::getInstance();
$tpl->SetVariable('insert_time', $objDate->Format($post['insert_time'], $date_format));
$tpl->SetVariable('insert_time_iso', $objDate->ToISO((int) $post['insert_time']));
// message
$tpl->SetVariable('message', $this->gadget->ParseText($post['message']));
// delete reason
$tpl->SetVariable('lbl_delete_reason', _t('FORUMS_POSTS_DELETE_REASON'));
// notification
if ($this->gadget->GetPermission('ForumManage', $post['fid'])) {
$tpl->SetBlock('post/notification');
$tpl->SetVariable('lbl_send_notification', _t('FORUMS_NOTIFICATION_MESSAGE'));
$tpl->SetBlock('post/notification/checked');
$tpl->ParseBlock('post/notification/checked');
$tpl->ParseBlock('post/notification');
}
$tpl->SetVariable('btn_submit_title', _t('FORUMS_POSTS_DELETE_BUTTON'));
$tpl->SetVariable('btn_cancel_title', _t('GLOBAL_CANCEL'));
$tpl->ParseBlock('post');
return $tpl->Get();
}
}
示例12: UpdateAddress
//.........这里部分代码省略.........
case 2:
case 3:
$telHome[] = $tels['tel_type'][$key] . ':' . $telNumber;
break;
case 4:
//Work
//Work
case 5:
case 6:
$telWork[] = $tels['tel_type'][$key] . ':' . $telNumber;
break;
case 7:
//Other
//Other
case 8:
case 9:
$telOther[] = $tels['tel_type'][$key] . ':' . $telNumber;
break;
}
}
}
}
$post['tel_home'] = implode(',', $telHome);
$post['tel_work'] = implode(',', $telWork);
$post['tel_other'] = implode(',', $telOther);
$emails = jaws()->request->fetch(array('email_type:array', 'email:array'), 'post');
$emailHome = array();
$emailWork = array();
$emailOther = array();
if (isset($emails['email_type'])) {
foreach ($emails['email'] as $key => $email) {
if (trim($email) != '') {
switch ($emails['email_type'][$key]) {
case 1:
//Home
$emailHome[] = $emails['email_type'][$key] . ':' . $email;
break;
case 2:
//Work
$emailWork[] = $emails['email_type'][$key] . ':' . $email;
break;
case 3:
//Other
$emailOther[] = $emails['email_type'][$key] . ':' . $email;
break;
}
}
}
}
$post['email_home'] = implode(',', $emailHome);
$post['email_work'] = implode(',', $emailWork);
$post['email_other'] = implode(',', $emailOther);
$adrs = jaws()->request->fetch(array('adr_type:array', 'adr:array'), 'post');
$adrHome = array();
$adrWork = array();
$adrOther = array();
$arrSearch = array("\r\n", "\n", "\r");
if (isset($adrs['adr_type'])) {
foreach ($adrs['adr'] as $key => $adr) {
$adr = str_replace($arrSearch, ' ', $adr);
if (trim($adr) != '') {
switch ($adrs['adr_type'][$key]) {
case 1:
//Home
$adrHome[] = $adrs['adr_type'][$key] . ':' . $adr;
break;
case 2:
//Work
$adrWork[] = $adrs['adr_type'][$key] . ':' . $adr;
break;
case 3:
//Other
$adrOther[] = $adrs['adr_type'][$key] . ':' . $adr;
break;
}
}
}
}
$post['adr_home'] = implode('\\n', $adrHome);
$post['adr_work'] = implode('\\n', $adrWork);
$post['adr_other'] = implode('\\n', $adrOther);
$urls = jaws()->request->fetch('url:array', 'post');
$post['url'] = implode('\\n', $urls);
$result = $model->UpdateAddress($id, $post);
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushResponse($result->getMessage(), 'AddressBook', RESPONSE_ERROR);
Jaws_Header::Referrer();
} else {
$agModel = $this->gadget->model->load('AddressBookGroup');
$agModel->DeleteGroupForAddress($id, $addressInfo['user']);
if (is_array($groupIDs) && count($groupIDs) > 0) {
foreach ($groupIDs as $gid) {
$agModel->AddGroupToAddress($id, $gid, $user);
}
}
$GLOBALS['app']->Session->PushResponse(_t('ADDRESSBOOK_RESULT_EDIT_ADDRESS_SAVED'), 'AddressBook');
$link = $this->gadget->urlMap('AddressBook');
Jaws_Header::Location($link);
}
}
示例13: UpdateGadgetSubscription
/**
* Update user one subscription item
*
* @access public
* @return void
*/
function UpdateGadgetSubscription()
{
$post = jaws()->request->fetch(array('email', 'mobile', 'subscription_gadget', 'subscription_action', 'subscription_reference', 'is_subscribe'), 'post');
$sModel = $this->gadget->model->load('Subscription');
$result = $sModel->UpdateGadgetSubscription($GLOBALS['app']->Session->GetAttribute('user'), $post['email'], $post['mobile'], $post['subscription_gadget'], $post['subscription_action'], $post['subscription_reference'], $post['is_subscribe']);
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushResponse($result->GetMessage(), 'Subscription.Subscription', RESPONSE_ERROR, $post);
} else {
$GLOBALS['app']->Session->PushResponse(_t('SUBSCRIPTION_SUBSCRIPTION_UPDATED'), 'Subscription.Subscription');
}
Jaws_Header::Referrer();
}
示例14: Vote
/**
* Adds a new vote to an answer of a certain poll
*
* @access public
*/
function Vote()
{
$post = jaws()->request->fetch(array('pid', 'answers:array'), 'post');
$model = $this->gadget->model->load('Poll');
$poll = $model->GetPoll((int) $post['pid']);
if (!Jaws_Error::IsError($poll) && !empty($poll)) {
$allowVote = false;
switch ($poll['restriction']) {
case Poll_Info::POLL_RESTRICTION_TYPE_IP:
$ip = $_SERVER['REMOTE_ADDR'];
$allowVote = $model->CheckAllowVoteForIP($poll['id'], $ip);
break;
case Poll_Info::POLL_RESTRICTION_TYPE_USER:
$currentUser = $GLOBALS['app']->Session->GetAttribute('user');
$allowVote = $model->CheckAllowVoteForUser($poll['id'], $currentUser);
break;
case Poll_Info::POLL_RESTRICTION_TYPE_SESSION:
$session = $GLOBALS['app']->Session->GetCookie('poll_' . $poll['id']);
$allowVote = $model->CheckAllowVoteForUser($poll['id'], $session);
break;
case Poll_Info::POLL_RESTRICTION_TYPE_FREE:
$allowVote = true;
break;
}
if ($allowVote && is_array($post['answers']) && count($post['answers']) > 0) {
$GLOBALS['app']->Session->SetCookie('poll_' . $poll['id'], 'voted', (int) $this->gadget->registry->fetch('cookie_period') * 24 * 60);
$res = $model->AddAnswerVotes($poll['id'], $post['answers']);
}
if (Jaws_Error::IsError($res)) {
$GLOBALS['app']->Session->PushSimpleResponse($res->getMessage(), 'Poll');
} else {
$GLOBALS['app']->Session->PushSimpleResponse(_t('POLL_THANKS'), 'Poll');
}
Jaws_Header::Referrer();
}
}
示例15: Send
/**
* Save contact in database
*
* @access public
*/
function Send()
{
$post = jaws()->request->fetch(array('name', 'email', 'company', 'url', 'tel', 'fax', 'mobile', 'address', 'recipient', 'subject', 'message'), 'post');
if ($GLOBALS['app']->Session->Logged()) {
$post['name'] = $GLOBALS['app']->Session->GetAttribute('nickname');
$post['email'] = $GLOBALS['app']->Session->GetAttribute('email');
$post['url'] = $GLOBALS['app']->Session->GetAttribute('url');
}
if (trim($post['name']) == '' || trim($post['subject']) == '' || trim($post['message']) == '') {
$GLOBALS['app']->Session->PushResponse(_t('CONTACT_INCOMPLETE_FIELDS'), 'Contact.Response', RESPONSE_ERROR);
$GLOBALS['app']->Session->PushSimpleResponse($post, 'Contact.Data');
Jaws_Header::Referrer();
}
$mPolicy = Jaws_Gadget::getInstance('Policy')->action->load('Captcha');
$resCheck = $mPolicy->checkCaptcha();
if (Jaws_Error::IsError($resCheck)) {
$GLOBALS['app']->Session->PushResponse($resCheck->getMessage(), 'Contact.Response', RESPONSE_ERROR);
$GLOBALS['app']->Session->PushSimpleResponse($post, 'Contact.Data');
Jaws_Header::Referrer();
}
if ($this->gadget->registry->fetch('use_antispam') == 'true') {
if (!preg_match("/^[[:alnum:]-_.]+\\@[[:alnum:]-_.]+\\.[[:alnum:]-_]+\$/", $post['email'])) {
$GLOBALS['app']->Session->PushResponse(_t('CONTACT_RESULT_BAD_EMAIL_ADDRESS'), 'Contact.Response', RESPONSE_ERROR);
$GLOBALS['app']->Session->PushSimpleResponse($post, 'Contact.Data');
Jaws_Header::Referrer();
}
}
$attachment = null;
if ($this->gadget->registry->fetch('enable_attachment') == 'true' && $this->gadget->GetPermission('AllowAttachment')) {
$attach = Jaws_Utils::UploadFiles($_FILES, JAWS_DATA . 'contact', '', false);
if (Jaws_Error::IsError($attach)) {
$GLOBALS['app']->Session->PushResponse($attach->getMessage(), 'Contact.Response', RESPONSE_ERROR);
$GLOBALS['app']->Session->PushSimpleResponse($post, 'Contact.Data');
Jaws_Header::Referrer();
}
if (!empty($attach)) {
$attachment = $attach['attachment'][0]['host_filename'];
}
}
$model = $this->gadget->model->load('Contacts');
$result = $model->InsertContact($post['name'], $post['email'], $post['company'], $post['url'], $post['tel'], $post['fax'], $post['mobile'], $post['address'], $post['recipient'], $post['subject'], $attachment, $post['message']);
if (Jaws_Error::IsError($result)) {
$res_msg = _t('CONTACT_RESULT_ERROR_DB');
$res_type = RESPONSE_ERROR;
} else {
$to = '';
$cid = $result;
$rid = (int) $post['recipient'];
if (!empty($rid)) {
$model = $this->gadget->model->load('Recipients');
$recipient = $model->GetRecipient((int) $post['recipient']);
if (Jaws_Error::IsError($recipient) || !isset($recipient['id'])) {
$res_msg = _t('CONTACT_ERROR_RECIPIENT_DOES_NOT_EXISTS');
$res_type = RESPONSE_ERROR;
} elseif ($recipient['inform_type'] == 1) {
//Send To Email
$to = $recipient['email'];
}
}
$this->SendEmailToRecipient($to, $cid);
$res_msg = _t('CONTACT_RESULT_SENT');
$res_type = RESPONSE_NOTICE;
}
$GLOBALS['app']->Session->PushResponse($res_msg, 'Contact.Response', $res_type);
Jaws_Header::Referrer();
}