Esempio n. 1
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     // Get view related request variables.
     $this->type = $app->input->get('type', '', 'cmd');
     $this->pid = $app->input->get('pid', 0, 'int');
     // Get model data.
     $m = $this->getModel();
     $this->state = $this->get('State');
     $this->isecure = $m->itemIsSecure($this->pid);
     $item = $m->getItem($app->input->get('nid', 0, 'int'));
     //echo'<xmp>';var_dump($item);echo'</xmp>';jexit();
     // Construct the breadcrumb
     $this->buildPathway($item ? $item->itemID : $this->pid);
     if ($item && (int) $item->secured) {
         $item->title = base64_decode($item->title);
         if ($item->contentID) {
             $cookn = UserNotesHelper::hashCookieName($item->itemID, $item->contentID);
             $cookv = $app->input->cookie->getBase64($cookn);
             if ($cookv) {
                 setcookie($cookn, '', time() - 3600);
                 $item->ephrase = UserNotesHelper::doCrypt($item->itemID . '-@:' . $item->contentID, base64_decode($cookv), true);
             } elseif ($ephrase = $app->input->post->get('ephrase', '', 'string')) {
                 $item->ephrase = $ephrase;
             } else {
                 $this->item = $item;
                 return parent::display('ephrase');
             }
             $item->serial_content = UserNotesHelper::doCrypt($item->ephrase, base64_decode($item->serial_content), true);
         }
     }
     if (!$item) {
         $item = (object) array('itemID' => 0, 'parentID' => $this->pid, 'contentID' => null, 'checked_out' => null, 'secured' => $this->isecure ? '1' : null);
     } else {
         $m->checkOut($item->itemID);
     }
     $this->item = $item;
     $this->form = $m->getForm($item);
     if ($this->type == 'f') {
         if ($this->isecure) {
             $this->form->removeField('maksec');
         } else {
             $this->form->removeField('pissec');
         }
     }
     //echo'<xmp>';var_dump($this->form);jexit();
     $this->form->setFieldAttribute('ephrase', 'type', 'password');
     // Check for errors.
     // @TODO: Maybe this could go into JComponentHelper::raiseErrors($this->get('Errors'))
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // Get the current menu item
     $this->params = $app->getParams();
     // Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $this->_prepareDocument();
     return parent::display($tpl);
 }
Esempio n. 2
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     // Get view related request variables.
     // Get model data.
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     //var_dump($this->item);
     // Construct the breadcrumb
     $this->buildPathway($this->item->itemID);
     //		if ($this->state->secured && !$app->input->post->get('ephrase','','string')) {
     if ($this->item->secured && !$app->input->post->get('ephrase', '', 'string')) {
         return parent::display('ephrase');
     }
     //echo'<xmp>';var_dump($app->input->post->get('ephrase','','string'), $this->item, UserNotesHelper::hashCookieName($this->item->itemID, $this->item->contentID));echo'</xmp>';
     //		if ($this->state->secured) {
     if ($this->item->secured) {
         $cookn = UserNotesHelper::hashCookieName($this->item->itemID, $this->item->contentID);
         $ephrase = $app->input->post->get('ephrase', '', 'string');
         $this->item->serial_content = UserNotesHelper::doCrypt($ephrase, base64_decode($this->item->serial_content), true);
         $cookv = UserNotesHelper::doCrypt($this->item->itemID . '-@:' . $this->item->contentID, $ephrase);
         setcookie($cookn, base64_encode($cookv), 0, '', '', true);
     }
     // Check for errors.
     // @TODO: Maybe this could go into JComponentHelper::raiseErrors($this->get('Errors'))
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // Get the component parameters
     $cparams = JComponentHelper::getParams('com_usernotes');
     // Get the current menu item
     $this->params = $app->getParams();
     // Meld the params
     if (!$this->params->get('maxUpload')) {
         $this->params->set('maxUpload', $cparams->get('maxUpload', UserNotesHelper::phpMaxUp()));
     }
     // establish the max file upload size
     $this->maxUploadBytes = min($this->params->get('maxUpload'), UserNotesHelper::phpMaxUp());
     // Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $this->_prepareDocument();
     return parent::display($tpl);
 }
Esempio n. 3
0
 public function storeNote($note, $user)
 {
     //		$ntbl = $note['ephrase'] ? 'secureds' : 'notes';
     $ntbl = 'notes';
     $secured = 0;
     if (isset($note['ephrase'])) {
         $secured = 1;
         $ephrase = $note['ephrase'];
         $ntitl = base64_encode($note['title']);
         $ncont = base64_encode(UserNotesHelper::doCrypt($ephrase, $note['serial_content']));
     } else {
         $ntitl = $note['title'];
         $ncont = $note['serial_content'];
     }
     try {
         $db = $this->getDbo();
         if ($note['itemID']) {
             $q = $db->getQuery(true);
             $q->update('content')->set('serial_content=' . $db->quote($ncont))->where('contentID=' . $note['contentID']);
             $db->setQuery($q);
             $db->execute();
             $q = $db->getQuery(true);
             $q->update($ntbl)->set('title=' . $db->quote($ntitl))->where('itemID=' . $note['itemID']);
             $db->setQuery($q);
             $db->execute();
         } else {
             $q = $db->getQuery(true);
             $q->insert('content')->columns('serial_content')->values($db->quote($ncont));
             $db->setQuery($q);
             $db->execute();
             $cid = $db->insertid();
             $q = $db->getQuery(true);
             $q->insert($ntbl)->columns('ownerID,shared,isParent,title,contentID,parentID,secured')->values(implode(',', array($user, 1, 0, $db->quote($ntitl), $cid, $note['parentID'], $secured)));
             $db->setQuery($q);
             $db->execute();
         }
     } catch (Exception $e) {
         $this->setError($e);
     }
 }