Example #1
0
 /**
  * Displays blog comments manager
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function ManageComments()
 {
     $this->gadget->CheckPermission('ManageComments');
     if (!Jaws_Gadget::IsGadgetInstalled('Comments')) {
         Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog');
     }
     $cHTML = Jaws_Gadget::getInstance('Comments')->action->loadAdmin('Comments');
     return $cHTML->Comments($this->gadget->name, $this->MenuBar('ManageComments'));
 }
Example #2
0
 /**
  * Switch between dashboards
  *
  * @access  public
  * @return  mixed   Redirect if switched successfully otherwise content of 403 html status code
  */
 function Dashboard()
 {
     if (!$GLOBALS['app']->Session->GetPermission('Users', 'AccessDashboard')) {
         return Jaws_HTTPError::Get(403);
     }
     $layoutModel = $this->gadget->model->load('Layout');
     $layoutModel->InitialLayout('Index.Dashboard');
     Jaws_Header::Location('');
 }
Example #3
0
 /**
  * Event execute method
  *
  */
 function Execute($shouter, $code)
 {
     $reqURL = Jaws_Utils::getRequestURL(true);
     $uModel = $this->gadget->model->loadAdmin('ErrorMaps');
     $res = $uModel->GetHTTPError($reqURL, $code);
     if (!Jaws_Error::IsError($res) && !empty($res) && ($res['code'] == 301 || $res['code'] == 302)) {
         Jaws_Header::Location($res['url'], $res['code']);
     }
     return $res;
 }
Example #4
0
 /**
  * Switch between dashboards
  *
  * @access  public
  * @return  mixed   Redirect if switched successfully otherwise content of 403 html status code
  */
 function Dashboard()
 {
     if (!$GLOBALS['app']->Session->GetPermission('Users', 'AccessDashboard')) {
         return Jaws_HTTPError::Get(403);
     }
     //$user = jaws()->request->fetch('user');
     $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     $layoutModel = $this->gadget->model->load('Layout');
     $layoutModel->DashboardSwitch($user);
     Jaws_Header::Location('');
 }
Example #5
0
 /**
  * Build and export data with VCard format
  *
  * @access  public
  * @return  string HTML content with menu and menu items
  */
 function VCardBuild()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(403);
     }
     require_once JAWS_PATH . 'gadgets/Addressbook/vCard.php';
     $model = $this->gadget->model->load('AddressBook');
     $agModel = $this->gadget->model->load('AddressBookGroup');
     $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     $ids = jaws()->request->fetch('adr:array');
     $link = $this->gadget->urlMap('AddressBook', array(), true);
     if (empty($ids)) {
         Jaws_Header::Location($link);
         return false;
     }
     $addressItems = $model->GetAddresses($ids, $user);
     if (Jaws_Error::IsError($addressItems) || empty($addressItems)) {
         return Jaws_HTTPError::Get(404);
     }
     $result = '';
     $nVCard = array('LastName', 'FirstName', 'AdditionalNames', 'Prefixes', 'Suffixes');
     foreach ($addressItems as $addressItem) {
         $vCard = new vCard();
         $names = explode(';', $addressItem['name']);
         foreach ($names as $key => $name) {
             $vCard->n($name, $nVCard[$key]);
         }
         $vCard->fn($names[3] . (trim($names[3]) == '' ? '' : ' ') . $names[1] . (trim($names[1]) == '' ? '' : ' ') . $names[0]);
         $vCard->nickname($addressItem['nickname']);
         $vCard->title($addressItem['title']);
         $adrGroups = $agModel->GetGroupNames($addressItem['address_id'], $user);
         $vCard->categories(implode(',', $adrGroups));
         $this->FillVCardTypes($vCard, 'tel', $addressItem['tel_home'], $this->_TelTypes);
         $this->FillVCardTypes($vCard, 'tel', $addressItem['tel_work'], $this->_TelTypes);
         $this->FillVCardTypes($vCard, 'tel', $addressItem['tel_other'], $this->_TelTypes);
         $this->FillVCardTypes($vCard, 'email', $addressItem['email_home'], $this->_EmailTypes);
         $this->FillVCardTypes($vCard, 'email', $addressItem['email_work'], $this->_EmailTypes);
         $this->FillVCardTypes($vCard, 'email', $addressItem['email_other'], $this->_EmailTypes);
         $this->FillVCardTypes($vCard, 'adr', $addressItem['adr_home'], $this->_AdrTypes, '\\n');
         $this->FillVCardTypes($vCard, 'adr', $addressItem['adr_work'], $this->_AdrTypes, '\\n');
         $this->FillVCardTypes($vCard, 'adr', $addressItem['adr_other'], $this->_AdrTypes, '\\n');
         $this->FillVCardTypes($vCard, 'url', $addressItem['url'], null, '\\n');
         $vCard->note($addressItem['notes']);
         $result = $result . $vCard;
     }
     header("Content-Disposition: attachment; filename=\"" . 'address.vcf' . "\"");
     header("Content-type: application/csv");
     header("Content-Length: " . strlen($result));
     header("Pragma: no-cache");
     header("Expires: 0");
     header("Connection: close");
     echo $result;
     exit;
 }
Example #6
0
 /**
  * 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();
 }
Example #7
0
 /**
  * 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();
 }
Example #8
0
 /**
  * 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'));
 }
Example #9
0
 /**
  * Saves a new trackback if all is ok and sends response
  * The function other people send to so our blog gadget
  * gets trackbacks
  *
  * @access  public
  * @return  string  trackback xml response
  */
 function Trackback()
 {
     // Based on Wordpress trackback implementation
     $tb_msg_error = '<?xml version="1.0" encoding="iso-8859-1"?><response><error>1</error><message>#MESSAGE#</message></response>';
     $tb_msg_ok = '<?xml version="1.0" encoding="iso-8859-1"?><response><error>0</error></response>';
     $sender = Jaws_Utils::GetRemoteAddress();
     $ip = $sender['proxy'] . (!empty($sender['proxy']) ? '-' : '') . $sender['client'];
     $post = jaws()->request->fetch(array('title', 'url', 'blog_name', 'excerpt'), 'post');
     if (is_null($post['title']) || is_null($post['url']) || is_null($post['blog_name']) || is_null($post['excerpt'])) {
         Jaws_Header::Location('');
     }
     $id = jaws()->request->fetch('id', 'get');
     if (is_null($id)) {
         $id = jaws()->request->fetch('id', 'post');
         if (is_null($id)) {
             $id = '';
         }
     }
     $title = urldecode($post['title']);
     $url = urldecode($post['url']);
     $blogname = urldecode($post['blog_name']);
     $excerpt = urldecode($post['excerpt']);
     if (trim($id) == '') {
         Jaws_Header::Location('');
     } elseif (empty($title) && empty($url) && empty($blogname)) {
         $url = $this->gadget->urlMap('SingleView', array('id' => $id), true);
         Jaws_Header::Location($url);
     } elseif ($this->gadget->registry->fetch('trackback') == 'true') {
         header('Content-Type: text/xml');
         $model = $this->gadget->model->load('Trackbacks');
         $trackback = $model->NewTrackback($id, $url, $title, $excerpt, $blogname, $ip);
         if (Jaws_Error::IsError($trackback)) {
             return str_replace('#MESSAGE#', $trackback->GetMessage(), $tb_msg_error);
         }
         return $tb_msg_ok;
     } else {
         header('Content-Type: text/xml');
         return str_replace('#MESSAGE#', _t('BLOG_TRACKBACK_DISABLED'), $tb_msg_error);
     }
 }
Example #10
0
 /**
  * Import data with VCard format from file
  *
  * @access  public
  * @return  string HTML content with menu and menu items
  */
 function VCardImportFile()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(403);
     }
     require_once JAWS_PATH . 'gadgets/Addressbook/vCard.php';
     if (empty($_FILES) || !is_array($_FILES)) {
         $GLOBALS['app']->Session->PushResponse(_t('ADDRESSBOOK_RESULT_ERROR_IMPORT_PLEASE_SELECT_FILE'), 'AddressBook.Import', RESPONSE_ERROR);
         Jaws_Header::Location($this->gadget->urlMap('VCardImport'));
     }
     try {
         $vCard = new vCard($_FILES['vcard_file']['tmp_name'], false, array('Collapse' => false));
         $model = $this->gadget->model->load('AddressBook');
         if (count($vCard) == 0) {
             $GLOBALS['app']->Session->PushResponse(_t('ADDRESSBOOK_RESULT_ERROR_VCARD_DATA_NOT_FOUND'), 'AddressBook.Import', RESPONSE_ERROR);
             Jaws_Header::Location($this->gadget->urlMap('VCardImport'));
         } elseif (count($vCard) == 1) {
             $result = $this->PrepareForImport($vCard);
             if ($result) {
                 $adrID = $model->InsertAddress($result);
             }
         } else {
             foreach ($vCard as $Index => $vCardPart) {
                 $result = $this->PrepareForImport($vCardPart);
                 if ($result) {
                     $adrID = $model->InsertAddress($result);
                 }
             }
         }
     } catch (Exception $e) {
         $GLOBALS['app']->Session->PushResponse($e->getMessage(), 'AddressBook.Import', RESPONSE_ERROR);
         // TODO: Translate Messages
         Jaws_Header::Location($this->gadget->urlMap('VCardImport'));
     }
     $GLOBALS['app']->Session->PushResponse(_t('ADDRESSBOOK_RESULT_IMPORT_COMPLETED'), 'AddressBook');
     Jaws_Header::Location($this->gadget->urlMap('AddressBook'));
 }
Example #11
0
 /**
  * Send a message
  *
  * @access  public
  * @return  void
  */
 function SendMessage()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(401);
     }
     $this->gadget->CheckPermission('SendMessage');
     $post = jaws()->request->fetch(array('id', 'recipient_users', 'recipient_groups', 'folder', 'subject', 'body', 'attachments:array', 'is_draft:bool'), 'post');
     $post['body'] = jaws()->request->strip_crlf($post['body']);
     $user = $GLOBALS['app']->Session->GetAttribute('user');
     $model = $this->gadget->model->load('Message');
     if (empty($post['folder'])) {
         $post['folder'] = $post['is_draft'] ? PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_DRAFT : PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX;
     }
     $message_id = $model->SendMessage($user, $post);
     $url = $this->gadget->urlMap('Messages', array('folder' => PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX));
     if (Jaws_Error::IsError($message_id)) {
         $GLOBALS['app']->Session->PushResponse($message_id->getMessage(), 'PrivateMessage.Compose', RESPONSE_ERROR);
     } else {
         if ($post['is_draft']) {
             $GLOBALS['app']->Session->PushResponse(_t('PRIVATEMESSAGE_DRAFT_SAVED'), 'PrivateMessage.Compose', RESPONSE_NOTICE, array('is_draft' => true, 'message_id' => $message_id));
         } else {
             $GLOBALS['app']->Session->PushResponse(_t('PRIVATEMESSAGE_MESSAGE_SEND'), 'PrivateMessage.Compose', RESPONSE_NOTICE, array('url' => $url));
         }
     }
     Jaws_Header::Location($url, 'PrivateMessage.Compose');
 }
Example #12
0
 /**
  * Deletes the given blog category
  *
  * @access  public
  */
 function DeleteCategory()
 {
     $this->gadget->CheckPermission('ManageCategories');
     $model = $this->gadget->model->loadAdmin('Categories');
     $model->DeleteCategory(jaws()->request->fetch('catid', 'post'));
     Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog&action=ManageCategories');
 }
Example #13
0
 /**
  * Updates user contacts information
  *
  * @access  public
  * @return  void
  */
 function UpdateContacts()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         Jaws_Header::Location($this->gadget->urlMap('LoginBox', array('referrer' => bin2hex(Jaws_Utils::getRequestURL(true)))));
     }
     $this->gadget->CheckPermission('EditUserContacts');
     $post = jaws()->request->fetch(array('country', 'city', 'address', 'postal_code', 'phone_number', 'mobile_number', 'fax_number'), 'post');
     $uModel = $this->gadget->model->load('Contacts');
     $result = $uModel->UpdateContacts($GLOBALS['app']->Session->GetAttribute('user'), $post['country'], $post['city'], $post['address'], $post['postal_code'], $post['phone_number'], $post['mobile_number'], $post['fax_number']);
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushResponse($result->GetMessage(), 'Users.Contacts', RESPONSE_ERROR, $post);
     } else {
         $GLOBALS['app']->Session->PushResponse(_t('USERS_USERS_CONTACTINFO_UPDATED'), 'Users.Contacts');
     }
     Jaws_Header::Location($this->gadget->urlMap('Contacts'), 'Users.Contacts');
 }
Example #14
0
 /**
  * Redirects request to banner's target
  *
  * @access  public
  * @return  mixed    Void if Success, 404  XHTML template content on Failure
  */
 function Click()
 {
     $model = $this->gadget->model->load('Banners');
     $id = (int) jaws()->request->fetch('id', 'get');
     $banner = $model->GetBanners($id);
     if (!Jaws_Error::IsError($banner) && !empty($banner)) {
         $click = $model->ClickBanner($banner[0]['id']);
         if (!Jaws_Error::IsError($click)) {
             $link = $banner[0]['url'];
             Jaws_Header::Location($link);
         }
     } else {
         return Jaws_HTTPError::Get(404);
     }
 }
Example #15
0
 /**
  * Adds a new emblem
  *
  * @access  public
  * @see     EmblemsModel->AddEmblem()
  */
 function AddEmblem()
 {
     $post = jaws()->request->fetch(array('title', 'url', 'type', 'published'), 'post');
     $post['url'] = Jaws_XSS::defilter($post['url']);
     $res = Jaws_Utils::UploadFiles($_FILES, JAWS_DATA . 'emblems/', 'jpg,gif,swf,png,jpeg,bmp,svg');
     if (Jaws_Error::IsError($res)) {
         $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
     } elseif (empty($res)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('EMBLEMS_ERROR_NO_IMAGE_UPLOADED'), RESPONSE_ERROR);
     } else {
         $post['image'] = $res['image'][0]['host_filename'];
         $post['published'] = (bool) $post['published'];
         $model = $this->gadget->model->loadAdmin('Emblems');
         $res = $model->AddEmblem($post);
         if (Jaws_Error::IsError($res)) {
             Jaws_Utils::delete(JAWS_DATA . 'emblems/' . $post['image']);
             $GLOBALS['app']->Session->PushLastResponse(_t('EMBLEMS_ERROR_NOT_ADDED'), RESPONSE_ERROR);
         } else {
             $GLOBALS['app']->Session->PushLastResponse(_t('EMBLEMS_ADDED'), RESPONSE_NOTICE);
         }
     }
     Jaws_Header::Location(BASE_SCRIPT . '?gadget=Emblems');
 }
Example #16
0
 /**
  * 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'));
 }
Example #17
0
 /**
  * Searches through notes including shared noes from other users
  *
  * @access  public
  * @return  array   Response array
  */
 function Search()
 {
     $post = jaws()->request->fetch(array('filter', 'query', 'page'), 'post');
     foreach ($post as $k => $v) {
         if ($v === null) {
             unset($post[$k]);
         }
     }
     $url = $this->gadget->urlMap('Notepad', $post);
     Jaws_Header::Location($url);
     /*if (strlen($search['query']) < 2) {
           $GLOBALS['app']->Session->PushResponse(
               _t('NOTEPAD_ERROR_SHORT_QUERY'),
               'Notepad.Response',
               RESPONSE_ERROR
           );
       }*/
 }
Example #18
0
 /**
  * Updates the page
  *
  * @access  public
  * @return  void
  */
 function SaveEditPage()
 {
     $this->gadget->CheckPermission('EditPage');
     $model = $this->gadget->model->loadAdmin('Page');
     $fetch = array('page', 'title', 'group_id', 'language', 'fast_url', 'meta_keys', 'meta_desc', 'tags', 'published', 'show_title');
     $post = jaws()->request->fetch($fetch, 'post');
     $post['content'] = jaws()->request->fetch('content', 'post', 'strip_crlf');
     $id = (int) $post['page'];
     $model->UpdatePage($id, $post['group_id'], $post['show_title'], $post['title'], $post['content'], $post['language'], $post['fast_url'], $post['meta_keys'], $post['meta_desc'], $post['tags'], $post['published']);
     Jaws_Header::Location(BASE_SCRIPT . '?gadget=StaticPage&action=EditPage&id=' . $id);
 }
Example #19
0
 /**
  * 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();
 }
Example #20
0
 /**
  * Uploads a new theme
  *
  * @access  public
  * @return  void
  */
 function UploadTheme()
 {
     $this->gadget->CheckPermission('UploadTheme');
     $res = Jaws_Utils::ExtractFiles($_FILES, JAWS_DATA . 'themes' . DIRECTORY_SEPARATOR, false);
     if (!Jaws_Error::IsError($res)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('TMS_THEME_UPLOADED'), RESPONSE_NOTICE);
     } else {
         $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
     }
     Jaws_Header::Location(BASE_SCRIPT . '?gadget=Tms&action=Themes');
 }
Example #21
0
 /**
  * Delete a photo
  *
  * @access  public
  */
 function DeletePhoto()
 {
     $post = jaws()->request->fetch(array('image', 'fromalbum'), 'post');
     $model = $this->gadget->model->loadAdmin('Photos');
     $model->DeletePhoto($post['image']);
     Jaws_Header::Location(BASE_SCRIPT . '?gadget=Phoo&album=' . $post['fromalbum']);
 }
Example #22
0
 /**
  * Searches among events
  *
  * @access  public
  * @return  array   Response array
  */
 function Search()
 {
     $post = jaws()->request->fetch(array('query', 'filter', 'start', 'stop', 'page'), 'post');
     $GLOBALS['app']->Session->PushSimpleResponse($post, 'Events.Search');
     $url = $this->gadget->urlMap('ManageEvents');
     Jaws_Header::Location($url);
 }
Example #23
0
 /**
  * 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();
 }
Example #24
0
 /**
  * Delete a file in text editor mode
  *
  * @access  public
  * @return  void
  */
 function DeleteFile()
 {
     $this->gadget->CheckPermission('ManageFiles');
     $model = $this->gadget->model->loadAdmin('Files');
     $post = jaws()->request->fetch(array('path', 'selected_item', 'extra_params'), 'post');
     if ($model->Delete($post['path'], $post['selected_item'])) {
         $model->DeleteDBFileInfo($post['path'], $post['selected_item']);
     }
     Jaws_Header::Location(BASE_SCRIPT . '?gadget=FileBrowser&action=BrowseFile&path=' . $post['path'] . html_entity_decode($post['extra_params']));
 }
Example #25
0
    define('COMPRESS_LEVEL', 4);
}
// Lets support older PHP versions so we can use spanking new functions
require JAWS_PATH . 'include/Jaws/PHPFunctions.php';
// lets setup the include_path
set_include_path('.' . PATH_SEPARATOR . JAWS_PATH . 'libraries/pear');
// Create application
$GLOBALS['app'] = jaws();
// get an instance of Jaws_DB
$objDatabase = Jaws_DB::getInstance('default', $db);
if (Jaws_Error::IsError($objDatabase)) {
    Jaws_Error::Fatal($objDatabase->getMessage());
}
$db_jaws_version = $GLOBALS['app']->Registry->Init();
if ($db_jaws_version != JAWS_VERSION) {
    if (strrstr(JAWS_VERSION, '.', true) != strrstr($db_jaws_version, '.', true)) {
        //require_once JAWS_PATH . 'upgrade/JawsUpgrader.php';
        //require_once JAWS_PATH . 'upgrade/JawsUpgraderStage.php';
        //require_once JAWS_PATH . 'upgrade/stages/111To120.php';
        //$objStage = new Upgrader_111To120;
        //$result = $objStage->Run();
        //if (Jaws_Error::IsError($result)) {
        Jaws_Header::Location('upgrade/index.php');
        //}
    }
    $GLOBALS['app']->Registry->update('version', JAWS_VERSION);
}
// init application
$GLOBALS['app']->init();
// load Piwi initialize
require_once JAWS_PATH . 'include/Jaws/InitPiwi.php';
Example #26
0
File: admin.php Project: uda/jaws
        } else {
            $loginMsg = $resCheck->GetMessage();
        }
    }
    if ($httpAuthEnabled) {
        $httpAuth->showLoginBox();
    }
    // Init layout
    $GLOBALS['app']->InstanceLayout();
    $cpl = Jaws_Gadget::getInstance('ControlPanel')->action->loadAdmin('Login');
    $data = $cpl->LoginBox($loginMsg);
    terminate($data, 401);
}
// remove checksess(check session) parameter from requested url
if (!is_null(jaws()->request->fetch('checksess', 'get'))) {
    Jaws_Header::Location(substr(Jaws_Utils::getRequestURL(false), 0, -10));
}
// Can use Control Panel?
$GLOBALS['app']->Session->CheckPermission('ControlPanel', 'default_admin');
if (Jaws_Gadget::IsGadgetEnabled($ReqGadget)) {
    $GLOBALS['app']->Session->CheckPermission($ReqGadget, 'default_admin');
    $objAction = Jaws_Gadget::getInstance($ReqGadget)->action->loadAdmin();
    if (Jaws_Error::IsError($objAction)) {
        Jaws_Error::Fatal("Error loading gadget: {$ReqGadget}");
    }
    $ReqAction = empty($ReqAction) ? $objAction->gadget->default_admin_action : $ReqAction;
    // set requested gadget/action
    $GLOBALS['app']->mainGadget = $ReqGadget;
    $GLOBALS['app']->mainAction = $ReqAction;
    // Init layout
    $GLOBALS['app']->InstanceLayout();
Example #27
0
 /**
  * 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();
 }
Example #28
0
 /**
  * Delete Group
  *
  * @access  public
  */
 function DeleteGroup()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(403);
     }
     $gids = jaws()->request->fetch('gid:array');
     $model = $this->gadget->model->load('Groups');
     $result = $model->DeleteGroups($gids, (int) $GLOBALS['app']->Session->GetAttribute('user'));
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushResponse($result->getMessage(), 'AddressBook.Groups', RESPONSE_ERROR);
     } else {
         $GLOBALS['app']->Session->PushResponse(_t('ADDRESSBOOK_RESULT_DELETE_GROUP_COMPLETE'), 'AddressBook.Groups');
     }
     Jaws_Header::Location($this->gadget->urlMap('ManageGroups'), 'AddressBook.Groups');
 }
Example #29
0
 /**
  * Updates event
  *
  * @access  public
  * @return  array   Response array
  */
 function UpdateEvent()
 {
     $data = jaws()->request->fetch(array('id', 'subject', 'location', 'description', 'type', 'priority', 'reminder', 'recurrence', 'month', 'day', 'wday', 'start_date', 'stop_date', 'start_time', 'stop_time'), 'post');
     if (empty($data['subject']) || empty($data['start_date'])) {
         $GLOBALS['app']->Session->PushResponse(_t('EVENTSCALENDAR_ERROR_INCOMPLETE_DATA'), 'Events.Response', RESPONSE_ERROR, $data);
         Jaws_Header::Referrer();
     }
     // Validate event
     $model = $this->gadget->model->load('Event');
     $id = (int) $data['id'];
     $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     $event = $model->GetEvent($id, $user);
     if (Jaws_Error::IsError($event)) {
         $GLOBALS['app']->Session->PushResponse(_t('EVENTSCALENDAR_ERROR_RETRIEVING_DATA'), 'Events.Response', RESPONSE_ERROR);
         Jaws_Header::Referrer();
     }
     // Verify owner
     if ($event['owner'] != $user) {
         $GLOBALS['app']->Session->PushResponse(_t('EVENTSCALENDAR_ERROR_NO_PERMISSION'), 'Events.Response', RESPONSE_ERROR);
         Jaws_Header::Referrer();
     }
     $data['user'] = (int) $GLOBALS['app']->Session->GetAttribute('user');
     if (empty($data['stop_date'])) {
         $data['stop_date'] = $data['start_date'];
     }
     if (empty($data['stop_time'])) {
         $data['stop_time'] = $data['start_time'];
     }
     $result = $model->UpdateEvent($id, $data, $event);
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushResponse(_t('EVENTSCALENDAR_ERROR_EVENT_UPDATE'), 'Events.Response', RESPONSE_ERROR, $data);
         Jaws_Header::Referrer();
     }
     $GLOBALS['app']->Session->PushResponse(_t('EVENTSCALENDAR_NOTICE_EVENT_UPDATED'), 'Events.Response');
     Jaws_Header::Location($this->gadget->urlMap('ManageEvents'));
 }
Example #30
0
 /**
  * Shows confirm. screen for deleting a blog entry or deletes it if confirm. was done
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function DeleteEntry()
 {
     $this->gadget->CheckPermission('DeleteEntries');
     $model = $this->gadget->model->loadAdmin('Posts');
     $bModel = $this->gadget->model->load('Posts');
     $post = jaws()->request->fetch(array('id', 'step'), 'post');
     if (!is_null($post['step']) && $post['step'] == 'delete') {
         // Delete Post
         $res = $model->DeleteEntry($post['id']);
         if (Jaws_Error::IsError($res)) {
             $GLOBALS['app']->Session->PushLastResponse(_t('BLOG_ERROR_ENTRY_NOT_DELETED'), RESPONSE_ERROR);
         } else {
             $GLOBALS['app']->Session->PushLastResponse(_t('BLOG_ENTRY_DELETED'), RESPONSE_NOTICE);
         }
         Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog&action=ListEntries');
     }
     $get = jaws()->request->fetch(array('id', 'action'), 'get');
     // Ask for confirmation...
     $entry = $bModel->GetEntry($get['id']);
     if (Jaws_Error::IsError($entry)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('BLOG_ERROR_DOES_NOT_EXISTS'));
         Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog&action=ListEntries');
     }
     $tpl = $this->gadget->template->loadAdmin('EntryDelete.html');
     $tpl->SetBlock('delete_entry');
     $tpl->SetVariable('base_script', BASE_SCRIPT);
     // Header
     $tpl->SetVariable('menubar', $this->MenuBar($get['action']));
     // Message
     $tpl->SetVariable('delete_message', _t('BLOG_DELETE_CONFIRM_ENTRY'));
     // Delete
     $deleteButton =& Piwi::CreateWidget('Button', 'delete', _t('GLOBAL_DELETE'), STOCK_DELETE);
     $deleteButton->SetSubmit();
     $tpl->SetVariable('delete_button', $deleteButton->Get());
     // Cancel
     $cancelButton =& Piwi::CreateWidget('Button', 'cancel', _t('GLOBAL_CANCEL'), STOCK_CANCEL);
     $cancelButton->AddEvent(ON_CLICK, "javascript: this.form.action.value = 'ListEntries'; this.form.submit(); ");
     $tpl->SetVariable('cancel_button', $cancelButton->Get());
     // ID
     $idHidden =& Piwi::CreateWidget('HiddenEntry', 'id', $get['id']);
     $tpl->SetVariable('id', $idHidden->Get());
     $tpl->SetVariable('title', $entry['title']);
     $tpl->SetVariable('text', $this->gadget->ParseText($entry['text']));
     $tpl->SetVariable('user', $entry['username']);
     $date = Jaws_Date::getInstance();
     $tpl->SetVariable('createtime', $date->Format($entry['publishtime']));
     $pos = 1;
     $categories = '';
     foreach ($entry['categories'] as $cat) {
         $categories .= $cat['name'];
         if ($pos != count($entry['categories'])) {
             $categories .= ', ';
         }
         $pos++;
     }
     $tpl->SetVariable('category', $categories);
     $tpl->ParseBlock('delete_entry');
     return $tpl->Get();
 }