本文整理汇总了PHP中Jaws_XSS::defilter方法的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_XSS::defilter方法的具体用法?PHP Jaws_XSS::defilter怎么用?PHP Jaws_XSS::defilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jaws_XSS
的用法示例。
在下文中一共展示了Jaws_XSS::defilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ViewTerm
/**
* Look for a term and prints it
*
* @access public
* @return string XHTML template content
*/
function ViewTerm()
{
$term = jaws()->request->fetch('term', 'get');
$term = Jaws_XSS::defilter($term);
$model = $this->gadget->model->load('Term');
$term = $model->GetTerm($term);
if (!Jaws_Error::IsError($term) && isset($term['term'])) {
$this->SetTitle($term['term']);
$tpl = $this->gadget->template->load('ViewTerm.html');
$tpl->SetBlock('definition');
$tpl->SetVariable('title', $this->gadget->title);
$date = Jaws_Date::getInstance();
$tpl->SetBlock('definition/term');
$tpl->SetVariable('term', $term['term']);
$tid = empty($term['fast_url']) ? $term['id'] : $term['fast_url'];
$tpl->SetVariable('url', $this->gadget->urlMap('ViewTerm', array('term' => $tid)));
$tpl->SetVariable('description', $this->gadget->ParseText($term['description']));
$tpl->SetVariable('created_in', _t('GLOBAL_CREATETIME'));
$tpl->SetVariable('updated_in', _t('GLOBAL_UPDATETIME'));
$tpl->SetVariable('createtime', $date->Format($term['createtime']));
$tpl->SetVariable('updatetime', $date->Format($term['updatetime']));
$tpl->ParseBlock('definition/term');
$tpl->ParseBlock('definition');
} else {
return Jaws_HTTPError::Get(404);
}
return $tpl->Get();
}
示例2: ShowAtomCategory
/**
* Displays an Atom feed for a given blog category
*
* @access public
* @return string xml with Atom feed
*/
function ShowAtomCategory()
{
header('Content-type: application/atom+xml; charset=utf-8');
$id = jaws()->request->fetch('id', 'get');
$id = Jaws_XSS::defilter($id);
$model = $this->gadget->model->load('Feeds');
$xml = $model->MakeCategoryAtom($id);
if (Jaws_Error::IsError($xml)) {
return '';
}
return $xml;
}
示例3: GroupPages
/**
* Displays a block of pages belongs to the specified group
*
* @access public
* @param mixed $gid ID or fast_url of the group (int/string)
* @param int $orderBy
* @param int $limit limit show pages
* @return string XHTML content
*/
function GroupPages($gid = 0, $orderBy = 1, $limit = 0)
{
if (empty($gid)) {
$get = $this->gadget->request->fetch(array('gid', 'order'), 'get');
$gid = Jaws_XSS::defilter($get['gid']);
$orderBy = $get['order'];
}
$pModel = $this->gadget->model->load('Page');
$gModel = $this->gadget->model->load('Group');
$group = $gModel->GetGroup($gid);
if (Jaws_Error::IsError($group) || $group == null) {
return false;
}
if (!$this->gadget->GetPermission('AccessGroup', $group['id'])) {
return Jaws_HTTPError::Get(403);
}
$GLOBALS['app']->Layout->SetTitle($group['title']);
$GLOBALS['app']->Layout->AddToMetaKeywords($group['meta_keywords']);
$GLOBALS['app']->Layout->SetDescription($group['meta_description']);
if (!is_numeric($gid)) {
$gid = $group['id'];
}
$pages = $pModel->GetPages($gid, $limit, $orderBy, null, true);
if (Jaws_Error::IsError($pages)) {
return false;
}
$tpl = $this->gadget->template->load('StaticPage.html');
$tpl->SetBlock('group_pages');
$tpl->SetVariable('title', $group['title']);
foreach ($pages as $page) {
$param = array('gid' => empty($group['fast_url']) ? $group['id'] : $group['fast_url'], 'pid' => empty($page['fast_url']) ? $page['base_id'] : $page['fast_url']);
$link = $this->gadget->urlMap('Pages', $param);
$tpl->SetBlock('group_pages/item');
$tpl->SetVariable('page', $page['title']);
$tpl->SetVariable('link', $link);
$tpl->ParseBlock('group_pages/item');
}
// parsing read-more block if required
if (!empty($limit) && count($pages) >= $limit && $GLOBALS['app']->requestedActionMode == ACTION_MODE_LAYOUT) {
$urlParam = array('gid' => empty($group['fast_url']) ? $group['id'] : $group['fast_url'], 'order' => $orderBy);
// prevent duplicate content via two different url
if ($orderBy == 1) {
unset($urlParam['order']);
}
$tpl->SetBlock('group_pages/read-more');
$tpl->SetVariable('url', $this->gadget->urlMap('GroupPages', $urlParam));
$tpl->SetVariable('read_more', _t('STATICPAGE_GROUP_PAGES_LIST', $group['title']));
$tpl->ParseBlock('group_pages/read-more');
}
$tpl->ParseBlock('group_pages');
return $tpl->Get();
}
示例4: UpdateEmblem
/**
* Updates the emblem
*
* @access public
* @return array Response array (notice or error)
*/
function UpdateEmblem()
{
@(list($id, $data) = jaws()->request->fetch(array('0', '1:array'), 'post'));
$data['url'] = Jaws_XSS::defilter($data['url']);
$model = $this->gadget->model->loadAdmin('Emblems');
$res = $model->UpdateEmblem($id, $data);
if (Jaws_Error::IsError($res)) {
$GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_QUERY_FAILED'), RESPONSE_ERROR);
return new Jaws_Error($res->getMessage());
}
$GLOBALS['app']->Session->PushLastResponse(_t('EMBLEMS_UPDATED'), RESPONSE_NOTICE);
return $GLOBALS['app']->Session->PopLastResponse();
}
示例5: Category
/**
* Show links of the category
*
* @access public
* @return mixed XHTML template content or false on error
*/
function Category($gid = 0)
{
if (empty($gid)) {
$gid = $this->gadget->request->fetch('id', 'get');
$gid = Jaws_XSS::defilter($gid);
$limit_count = null;
$tplFile = 'Category.html';
} else {
$limit_count = 10;
$tplFile = 'LinkDump.html';
}
$model = $this->gadget->model->load('Groups');
$group = $model->GetGroup($gid);
if (Jaws_Error::IsError($group) || empty($group)) {
return false;
}
$tpl = $this->gadget->template->load($tplFile);
$tpl->SetBlock('category');
$tpl->SetVariable('gid', $group['id']);
$tpl->SetVariable('title', $this->gadget->title);
$tpl->SetVariable('name', $group['title']);
$tpl->SetVariable('feed', _t('LINKDUMP_LINKS_FEED'));
$gid = empty($group['fast_url']) ? $group['id'] : $group['fast_url'];
$tpl->SetVariable('url_category', $this->gadget->urlMap('Category', array('id' => $gid)));
$group_id = empty($group['fast_url']) ? $group['id'] : $group['fast_url'];
$tpl->SetVariable('linkdump_rss', $this->gadget->urlMap('RSS', array('id' => $group_id)));
$target = $this->gadget->registry->fetch('links_target');
$target = $target == 'blank' ? '_blank' : '_self';
$block = $group['link_type'] == 0 ? 'list' : 'link';
$links = $model->GetGroupLinks($group['id'], empty($limit_count) ? null : $group['limit_count'], $group['order_type']);
if (!Jaws_Error::IsError($links)) {
foreach ($links as $link) {
$tpl->SetBlock("category/{$block}");
$tpl->SetVariable('target', $target);
$tpl->SetVariable('title', $link['title']);
$tpl->SetVariable('description', $link['description']);
$tpl->SetVariable('url', $link['url']);
$tpl->SetVariable('clicks', $link['clicks']);
$tpl->SetVariable('lbl_clicks', _t('LINKDUMP_LINKS_CLICKS'));
if ($group['link_type'] == 2) {
$lid = empty($link['fast_url']) ? $link['id'] : $link['fast_url'];
$tpl->SetVariable('visit_url', $this->gadget->urlMap('Link', array('id' => $lid)));
} else {
$tpl->SetVariable('visit_url', $link['url']);
}
$tpl->ParseBlock("category/{$block}");
}
}
$tpl->ParseBlock('category');
return $tpl->Get();
}
示例6: AdvancedBox
/**
* Builds the advanced search box
*
* @access public
* @return string XHTML search box
*/
function AdvancedBox()
{
$post = jaws()->request->fetch(array('all', 'exact', 'least', 'exclude', 'gadgets', 'date'), 'get');
$post['all'] = Jaws_XSS::defilter($post['all']);
$tpl = $this->gadget->template->load('Search.html');
$tpl->SetBlock('AdvancedBox');
$tpl->SetVariable('base_script', BASE_SCRIPT);
$tpl->SetVariable('title', $this->gadget->title);
$tpl->SetVariable('lbl_word_filter', _t('SEARCH_WORD_FILTER'));
$tpl->SetVariable('lbl_all', _t('SEARCH_WORD_FILTER_ALL'));
$tpl->SetVariable('lbl_exact', _t('SEARCH_WORD_FILTER_EXACT'));
$tpl->SetVariable('lbl_least', _t('SEARCH_WORD_FILTER_LEAST'));
$tpl->SetVariable('lbl_exclude', _t('SEARCH_WORD_FILTER_EXCLUDE'));
$tpl->SetVariable('lbl_data_filter', _t('SEARCH_DATA_FILTER'));
$tpl->SetVariable('lbl_search_in', _t('SEARCH_SEARCH_IN'));
$model = $this->gadget->model->load('Search');
$options = $model->parseSearch($post, $searchable);
$wordAll =& Piwi::CreateWidget('Entry', 'all', implode(' ', $options['all']));
$wordExact =& Piwi::CreateWidget('Entry', 'exact', implode(' ', $options['exact']));
$wordLeast =& Piwi::CreateWidget('Entry', 'least', implode(' ', $options['least']));
$wordExclude =& Piwi::CreateWidget('Entry', 'exclude', implode(' ', $options['exclude']));
$tpl->SetVariable('all', $wordAll->Get());
$tpl->SetVariable('exclude', $wordExclude->Get());
$tpl->SetVariable('least', $wordLeast->Get());
$tpl->SetVariable('exact', $wordExact->Get());
//Gadgets filter combo
$gadgetList = $model->GetSearchableGadgets();
$gSearchable = $this->gadget->registry->fetch('searchable_gadgets');
$searchableGadgets = $gSearchable == '*' ? array_keys($gadgetList) : explode(', ', $gSearchable);
$gchk =& Piwi::CreateWidget('Combo', 'gadgets');
$gchk->addOption(_t('GLOBAL_ALL'), '');
foreach ($searchableGadgets as $gadget) {
$info = Jaws_Gadget::getInstance($gadget);
if (Jaws_Error::IsError($info)) {
continue;
}
$gchk->AddOption($info->title, $gadget);
}
$default = !is_null($post['gadgets']) ? $post['gadgets'] : '';
$gchk->SetDefault($default);
$tpl->SetVariable('gadgets_combo', $gchk->Get());
//Search button
$btnSearch =& Piwi::CreateWidget('Button', '', _t('SEARCH_BUTTON'));
$btnSearch->SetID('btn_search');
$btnSearch->SetSubmit(true);
$tpl->SetVariable('btn_search', $btnSearch->Get());
$tpl->ParseBlock('AdvancedBox');
return $tpl->Get();
}
示例7: ViewCategory
/**
* Displays a concrete category
*
* @access public
* @return string XHTML template content
*/
function ViewCategory()
{
$model = $this->gadget->model->load('Question');
$cat_id = jaws()->request->fetch('id', 'get');
$cat_id = Jaws_XSS::defilter($cat_id);
$this->SetTitle($this->gadget->title . ' - ' . _t('FAQ_CATEGORIES'));
$questions = $model->GetQuestions($cat_id, true);
if (is_array($questions) && count($questions) > 0) {
$tpl = $this->gadget->template->load('Category.html');
foreach ($questions as $cat) {
$tpl->SetBlock('faq_category');
$tpl->SetVariable('title', _t('FAQ_TITLE'));
$tpl->SetVariable('category', $cat['category']);
$tpl->SetVariable('description', $this->gadget->ParseText($cat['description']));
if (isset($cat['questions']) && is_array($cat['questions'])) {
$qPos = 0;
}
foreach ($cat['questions'] as $q) {
$qPos++;
$tpl->SetBlock('faq_category/question');
$tpl->SetVariable('id', $q['id']);
$tpl->SetVariable('pos', $qPos);
$tpl->SetVariable('question', $q['question'], 'Faq', false);
$tpl->SetVariable('url', $this->gadget->urlMap('ViewCategory', array('id' => $cat_id)));
$tpl->ParseBlock('faq_category/question');
}
if (isset($cat['questions']) && is_array($cat['questions'])) {
$qPos = 0;
}
foreach ($cat['questions'] as $q) {
$qPos++;
$tpl->SetBlock('faq_category/item');
$tpl->SetVariable('top_label', _t('FAQ_GO_TO_TOP'));
$tpl->SetVariable('top_link', $this->gadget->urlMap('ViewCategory', array('id' => $cat_id)) . '#topfaq');
$tpl->SetVariable('id', $q['id']);
$tpl->SetVariable('pos', $qPos);
$qid = empty($q['fast_url']) ? $q['id'] : $q['fast_url'];
$tpl->SetVariable('url', $this->gadget->urlMap('ViewQuestion', array('id' => $qid)));
$tpl->SetVariable('question', $q['question']);
$tpl->SetVariable('answer', $this->gadget->ParseText($q['answer']));
$tpl->ParseBlock('faq_category/item');
}
$tpl->ParseBlock('faq_category');
}
return $tpl->Get();
}
// FIXME: We should return something like "No questions found"
return '';
}
示例8: 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();
}
示例9: ViewQuestion
/**
* Displays a concrete question & answer
*
* @access public
* @return string XHTML template content
*/
function ViewQuestion()
{
$qid = jaws()->request->fetch('id', 'get');
$qid = Jaws_XSS::defilter($qid);
$tpl = $this->gadget->template->load('Question.html');
$tpl->SetBlock('faq_question');
$model = $this->gadget->model->load('Question');
$q = $model->GetQuestion($qid);
if (!Jaws_Error::IsError($q) && !empty($q)) {
$this->SetTitle($q['question']);
$tpl->SetVariable('title', $q['question']);
$tpl->SetVariable('answer', $this->gadget->ParseText($q['answer']));
}
$tpl->ParseBlock('faq_question');
return $tpl->Get();
}
示例10: ShowCategory
/**
* Displays a list of blog posts included on the given category
*
* @access public
* @param int $cat category ID
* @return string XHTML template content
*/
function ShowCategory($cat = null)
{
$cModel = $this->gadget->model->load('Categories');
$pModel = $this->gadget->model->load('Posts');
$rqst = jaws()->request->fetch(array('id', 'page'), 'get');
$page = $rqst['page'];
if (is_null($page) || $page <= 0) {
$page = 1;
}
if (is_null($cat)) {
if (empty($rqst['id'])) {
$catInfo = array('id' => 0, 'name' => _t('BLOG_UNCATEGORIZED'), 'fast_url' => '', 'description' => '', 'meta_keywords' => '', 'meta_description' => '');
} else {
$cat = Jaws_XSS::defilter($rqst['id']);
$catInfo = $cModel->GetCategory($cat);
if (Jaws_Error::IsError($catInfo) || empty($catInfo)) {
return Jaws_HTTPError::Get(404);
}
// Check dynamic ACL
if (!$this->gadget->GetPermission('CategoryAccess', $catInfo['id'])) {
return Jaws_HTTPError::Get(403);
}
}
}
$name = $catInfo['name'];
$tpl = $this->gadget->template->load('CategoryPosts.html');
$GLOBALS['app']->Layout->AddHeadLink($this->gadget->urlMap('ShowAtomCategory', array('id' => $cat)), 'alternate', 'application/atom+xml', 'Atom - ' . $name);
$GLOBALS['app']->Layout->AddHeadLink($this->gadget->urlMap('ShowRSSCategory', array('id' => $cat)), 'alternate', 'application/rss+xml', 'RSS 2.0 - ' . $name);
$this->SetTitle($name);
$this->AddToMetaKeywords($catInfo['meta_keywords']);
$this->SetDescription($catInfo['meta_description']);
$tpl->SetBlock('view_category');
$tpl->SetVariable('title', $name);
$total = $cModel->GetCategoryNumberOfPages($catInfo['id']);
$limit = $this->gadget->registry->fetch('last_entries_limit');
$params = array('id' => $cat);
$tpl->SetVariable('navigation', $this->GetNumberedPageNavigation($page, $limit, $total, 'ShowCategory', $params));
$entries = $pModel->GetEntriesByCategory($catInfo['id'], $page);
if (!Jaws_Error::IsError($entries)) {
foreach ($entries as $entry) {
$this->ShowEntry($tpl, 'view_category', $entry);
}
}
$tpl->ParseBlock('view_category');
return $tpl->Get();
}
示例11: 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'));
}
示例12: GroupPages
/**
* Displays a block of pages belongs to the specified group
*
* @access public
* @param mixed $gid ID or fast_url of the group (int/string)
* @param int $orderBy
* @param int $limit limit show pages
* @return string XHTML content
*/
function GroupPages($gid = 0, $orderBy = 1, $limit = 0)
{
if (empty($gid)) {
$get = $this->gadget->request->fetch(array('gid', 'order'), 'get');
$gid = Jaws_XSS::defilter($get['gid']);
$orderBy = $get['order'];
}
$pModel = $this->gadget->model->load('Page');
$gModel = $this->gadget->model->load('Group');
$group = $gModel->GetGroup($gid);
if (Jaws_Error::IsError($group) || $group == null) {
return false;
}
if (!$this->gadget->GetPermission('AccessGroup', $group['id'])) {
return Jaws_HTTPError::Get(403);
}
$GLOBALS['app']->Layout->SetTitle($group['title']);
$GLOBALS['app']->Layout->AddToMetaKeywords($group['meta_keywords']);
$GLOBALS['app']->Layout->SetDescription($group['meta_description']);
if (!is_numeric($gid)) {
$gid = $group['id'];
}
$pages = $pModel->GetPages($gid, $limit, $orderBy, null, true);
if (Jaws_Error::IsError($pages)) {
return false;
}
$tpl = $this->gadget->template->load('StaticPage.html');
$tpl->SetBlock('group_pages');
$tpl->SetVariable('title', $group['title']);
foreach ($pages as $page) {
$param = array('gid' => empty($group['fast_url']) ? $group['id'] : $group['fast_url'], 'pid' => empty($page['fast_url']) ? $page['base_id'] : $page['fast_url']);
$link = $this->gadget->urlMap('Pages', $param);
$tpl->SetBlock('group_pages/item');
$tpl->SetVariable('page', $page['title']);
$tpl->SetVariable('link', $link);
$tpl->ParseBlock('group_pages/item');
}
$tpl->ParseBlock('group_pages');
return $tpl->Get();
}
示例13: UpdateFile
/**
* Updates file
*
* @access public
* @return array Response array
*/
function UpdateFile()
{
try {
// Validate data
$data = jaws()->request->fetch(array('id', 'title', 'description', 'parent', 'hidden', 'user_filename', 'host_filename', 'filetype', 'filesize'));
if (empty($data['title'])) {
throw new Exception(_t('DIRECTORY_ERROR_INCOMPLETE_DATA'));
}
$data['title'] = Jaws_XSS::defilter($data['title']);
$data['description'] = Jaws_XSS::defilter($data['description']);
$model = $this->gadget->model->loadAdmin('Files');
// Validate file
$id = (int) $data['id'];
$file = $model->GetFile($id);
if (Jaws_Error::IsError($file)) {
throw new Exception($file->getMessage());
}
// Upload file
$path = $GLOBALS['app']->getDataURL('directory');
if (!is_dir($path)) {
if (!Jaws_Utils::mkdir($path, 2)) {
throw new Exception('DIRECTORY_ERROR_FILE_UPLOAD');
}
}
$res = Jaws_Utils::UploadFiles($_FILES, $path, '', null);
if (Jaws_Error::IsError($res)) {
throw new Exception($res->getMessage());
} else {
if ($res !== false) {
$data['host_filename'] = $res['file'][0]['host_filename'];
$data['user_filename'] = $res['file'][0]['user_filename'];
$data['filetype'] = $res['file'][0]['host_filetype'];
$data['filesize'] = $res['file'][0]['host_filesize'];
} else {
if ($data['host_filename'] === ':nochange:') {
unset($data['host_filename']);
} else {
if (empty($data['host_filename'])) {
throw new Exception(_t('DIRECTORY_ERROR_FILE_UPLOAD'));
} else {
$filename = Jaws_Utils::upload_tmp_dir() . '/' . $data['host_filename'];
if (file_exists($filename)) {
$target = $path . '/' . $data['host_filename'];
$res = Jaws_Utils::rename($filename, $target, false);
if ($res === false) {
throw new Exception(_t('DIRECTORY_ERROR_FILE_UPLOAD'));
}
$data['host_filename'] = basename($res);
} else {
throw new Exception(_t('DIRECTORY_ERROR_FILE_UPLOAD'));
}
}
}
}
}
// Update file in database
unset($data['user']);
$data['updatetime'] = time();
$data['hidden'] = $data['hidden'] ? true : false;
$model = $this->gadget->model->loadAdmin('Files');
$res = $model->Update($id, $data);
if (Jaws_Error::IsError($res)) {
throw new Exception(_t('DIRECTORY_ERROR_FILE_UPDATE'));
}
// Update Tags
if (Jaws_Gadget::IsGadgetInstalled('Tags')) {
$tags = jaws()->request->fetch('tags');
$tModel = Jaws_Gadget::getInstance('Tags')->model->loadAdmin('Tags');
$tModel->UpdateReferenceTags('Directory', 'file', $id, !$data['hidden'], time(), $tags);
}
} catch (Exception $e) {
return $GLOBALS['app']->Session->GetResponse($e->getMessage(), RESPONSE_ERROR);
}
return $GLOBALS['app']->Session->GetResponse(_t('DIRECTORY_NOTICE_FILE_UPDATED'), RESPONSE_NOTICE);
}
示例14: SendReply
/**
* Send contact reply
*
* @access public
* @param int $cid Contact ID
* @return mixed True on Success or Jaws_Error on Failure
*/
function SendReply($cid)
{
$model = $this->gadget->model->loadAdmin('Contacts');
$contact = $model->GetReply($cid);
if (Jaws_Error::IsError($contact)) {
$GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_QUERY_FAILED'), RESPONSE_ERROR);
return new Jaws_Error(_t('GLOBAL_ERROR_QUERY_FAILED'));
}
if (!isset($contact['id'])) {
$GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_ERROR_CONTACT_DOES_NOT_EXISTS'), RESPONSE_ERROR);
return new Jaws_Error(_t('CONTACT_ERROR_CONTACT_DOES_NOT_EXISTS'));
}
$from_name = '';
$from_email = '';
$to = $contact['email'];
$rid = $contact['recipient'];
if ($rid != 0) {
$rModel = $this->gadget->model->load('Recipients');
$recipient = $rModel->GetRecipient($rid);
if (Jaws_Error::IsError($recipient)) {
$GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_QUERY_FAILED'), RESPONSE_ERROR);
return new Jaws_Error(_t('GLOBAL_ERROR_QUERY_FAILED'));
}
if (!isset($recipient['id'])) {
$GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_ERROR_RECIPIENT_DOES_NOT_EXISTS'), RESPONSE_ERROR);
return new Jaws_Error(_t('CONTACT_ERROR_RECIPIENT_DOES_NOT_EXISTS'));
}
$from_name = $recipient['name'];
$from_email = $recipient['email'];
}
$format = $this->gadget->registry->fetch('email_format');
if ($format == 'html') {
$reply = $this->gadget->ParseText($contact['reply']);
} else {
$reply = $contact['reply'];
}
$jDate = Jaws_Date::getInstance();
$site_url = $GLOBALS['app']->getSiteURL('/');
$site_name = $this->gadget->registry->fetch('site_name', 'Settings');
$site_language = $this->gadget->registry->fetch('site_language', 'Settings');
$profile_url = $GLOBALS['app']->getSiteURL('/') . $GLOBALS['app']->Map->GetURLFor('Users', 'Profile', array('user' => $GLOBALS['app']->Session->GetAttribute('username')));
Jaws_Translate::getInstance()->LoadTranslation('Global', JAWS_COMPONENT_OTHERS, $site_language);
Jaws_Translate::getInstance()->LoadTranslation('Contact', JAWS_COMPONENT_GADGET, $site_language);
$tpl = $this->gadget->template->load('SendReplyTo.html', array('loadFromTheme' => true, 'loadRTLDirection' => _t_lang($site_language, 'GLOBAL_LANG_DIRECTION') == 'rtl'));
$tpl->SetBlock($format);
$tpl->SetVariable('lbl_name', _t_lang($site_language, 'GLOBAL_NAME'));
$tpl->SetVariable('lbl_email', _t_lang($site_language, 'GLOBAL_EMAIL'));
$tpl->SetVariable('lbl_message', _t_lang($site_language, 'CONTACT_MESSAGE'));
$tpl->SetVariable('lbl_reply', _t_lang($site_language, 'CONTACT_REPLY'));
$tpl->SetVariable('name', $contact['name']);
$tpl->SetVariable('email', $contact['email']);
$tpl->SetVariable('subject', $contact['subject']);
$tpl->SetVariable('message', $contact['msg_txt']);
$tpl->SetVariable('reply', $reply);
$tpl->SetVariable('createtime', $jDate->Format($contact['createtime']));
$tpl->SetVariable('nickname', $GLOBALS['app']->Session->GetAttribute('nickname'));
$tpl->SetVariable('profile_url', $profile_url);
$tpl->SetVariable('site-name', $site_name);
$tpl->SetVariable('site-url', $site_url);
$tpl->ParseBlock($format);
$template = $tpl->Get();
$subject = _t_lang($site_language, 'CONTACT_REPLY_TO', Jaws_XSS::defilter($contact['subject']));
$mail = Jaws_Mail::getInstance();
$mail->SetFrom($from_email, $from_name);
$mail->AddRecipient($to);
$mail->AddRecipient('', 'cc');
$mail->SetSubject($subject);
$mail->SetBody($template, $format);
$result = $mail->send();
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_ERROR_REPLY_NOT_SENT'), RESPONSE_ERROR);
return false;
}
$model->UpdateReplySent($cid, true);
$GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_REPLY_SENT'), RESPONSE_NOTICE);
return true;
}
示例15: UpdateDirectory
/**
* Updates directory
*
* @access public
* @return array Response array
*/
function UpdateDirectory()
{
try {
$data = jaws()->request->fetch(array('title', 'description', 'parent'), 'post');
// Validate data
if (empty($data['title'])) {
throw new Exception(_t('DIRECTORY_ERROR_INCOMPLETE_DATA'));
}
$data['title'] = Jaws_XSS::defilter($data['title']);
$data['description'] = Jaws_XSS::defilter($data['description']);
$id = (int) jaws()->request->fetch('id', 'post');
$model = $this->gadget->model->load('Files');
// Validate directory
$dir = $model->GetFile($id);
if (Jaws_Error::IsError($dir)) {
throw new Exception($dir->getMessage());
}
// Validate user
$user = (int) $GLOBALS['app']->Session->GetAttribute('user');
if ($dir['user'] != $user) {
throw new Exception(_t('DIRECTORY_ERROR_DIR_UPDATE'));
}
// Update directory
$data['updatetime'] = time();
$result = $model->Update($id, $data);
if (Jaws_Error::IsError($result)) {
throw new Exception(_t('DIRECTORY_ERROR_DIR_UPDATE'));
}
// Update shortcuts
if ($dir['shared']) {
$shortcut = array('updatetime' => $data['updatetime']);
$model->UpdateShortcuts($id, $shortcut);
}
} catch (Exception $e) {
return $GLOBALS['app']->Session->GetResponse($e->getMessage(), RESPONSE_ERROR);
}
return $GLOBALS['app']->Session->GetResponse(_t('DIRECTORY_NOTICE_DIR_UPDATED'), RESPONSE_NOTICE);
}