Exemplo n.º 1
0
 /**
  * Method to build and return a full request URL for the request.  This method will
  * add appropriate pagination details if necessary and also prepend the API url
  * to have a complete URL for the request.
  *
  * @param   string   $path   URL to inflect
  * @param   integer  $page   Page to request
  * @param   integer  $limit  Number of results to return per page
  *
  * @return  string   The request URL.
  *
  * @since   11.3
  */
 protected function fetchUrl($path, $page = 0, $limit = 0)
 {
     // Get a new JUri object fousing the api url and given path.
     $uri = new JUri($this->options->get('api.url') . $path);
     if ($this->options->get('gh.token', false)) {
         // Use oAuth authentication - @todo set in request header ?
         $uri->setVar('access_token', $this->options->get('gh.token'));
     } else {
         // Use basic authentication
         if ($this->options->get('api.username', false)) {
             $uri->setUser($this->options->get('api.username'));
         }
         if ($this->options->get('api.password', false)) {
             $uri->setPass($this->options->get('api.password'));
         }
     }
     // If we have a defined page number add it to the JUri object.
     if ($page > 0) {
         $uri->setVar('page', (int) $page);
     }
     // If we have a defined items per page add it to the JUri object.
     if ($limit > 0) {
         $uri->setVar('per_page', (int) $limit);
     }
     return (string) $uri;
 }
Exemplo n.º 2
0
 public function search()
 {
     $model = $this->getModel('user');
     $uri = new JUri('index.php?option=com_kunena&view=user&layout=list');
     $state = $model->getState();
     $search = $state->get('list.search');
     $limitstart = $state->get('list.start');
     if ($search) {
         $uri->setVar('search', $search);
     }
     if ($limitstart) {
         $uri->setVar('limitstart', $search);
     }
     $this->setRedirect(KunenaRoute::_($uri, false));
 }
Exemplo n.º 3
0
 /**
  * Create and return the pagination data object.
  *
  * @return  object  Pagination data object.
  *
  * @since   1.5
  */
 protected function _buildDataObject()
 {
     $data = new stdClass();
     if (!$this->uri) {
         $this->uri = KunenaRoute::$current;
     }
     // Build the additional URL parameters string.
     foreach ($this->additionalUrlParams as $key => $value) {
         $this->uri->setVar($key, $value);
     }
     $limitstartKey = $this->prefix . 'limitstart';
     $data->all = new JPaginationObject(JText::_('JLIB_HTML_VIEW_ALL'), $this->prefix);
     if (!$this->viewall) {
         $this->uri->delVar($limitstartKey, '');
         $data->all->base = '0';
         $data->all->link = JRoute::_((string) $this->uri);
     }
     // Set the start and previous data objects.
     $data->start = new JPaginationObject(JText::_('JLIB_HTML_START'), $this->prefix);
     $data->previous = new JPaginationObject(JText::_('JPREV'), $this->prefix);
     if ($this->pagesCurrent > 1) {
         $page = ($this->pagesCurrent - 2) * $this->limit;
         $this->uri->setVar($limitstartKey, '0');
         $data->start->base = '0';
         $data->start->link = JRoute::_((string) $this->uri);
         $this->uri->setVar($limitstartKey, $page);
         $data->previous->base = $page;
         $data->previous->link = JRoute::_((string) $this->uri);
     }
     // Set the next and end data objects.
     $data->next = new JPaginationObject(JText::_('JNEXT'), $this->prefix);
     $data->end = new JPaginationObject(JText::_('JLIB_HTML_END'), $this->prefix);
     if ($this->pagesCurrent < $this->pagesTotal) {
         $next = $this->pagesCurrent * $this->limit;
         $end = ($this->pagesTotal - 1) * $this->limit;
         $this->uri->setVar($limitstartKey, $next);
         $data->next->base = $next;
         $data->next->link = JRoute::_((string) $this->uri);
         $this->uri->setVar($limitstartKey, $end);
         $data->end->base = $end;
         $data->end->link = JRoute::_((string) $this->uri);
     }
     $data->pages = array();
     $range = range($this->pagesStart, $this->pagesStop);
     $range[] = 1;
     $range[] = $this->pagesTotal;
     sort($range);
     foreach ($range as $i) {
         $offset = ($i - 1) * $this->limit;
         $data->pages[$i] = new JPaginationObject($i, $this->prefix);
         if ($i != $this->pagesCurrent || $this->viewall) {
             $this->uri->setVar($limitstartKey, $offset);
             $data->pages[$i]->base = $offset;
             $data->pages[$i]->link = JRoute::_((string) $this->uri);
         } elseif ($i == $this->pagesCurrent) {
             $data->pages[$i]->active = true;
         }
     }
     return $data;
 }
Exemplo n.º 4
0
 /**
  * @param   string $layout
  *
  * @return JUri
  */
 public static function getUri($layout = null)
 {
     $uri = new JUri('index.php?option=com_kunena&view=announcement');
     if ($layout) {
         $uri->setVar('layout', $layout);
     }
     return $uri;
 }
Exemplo n.º 5
0
 /**
  * Method to build and return a full request URL for the request.  This method will
  * add appropriate pagination details if necessary and also prepend the API url
  * to have a complete URL for the request.
  *
  * @param   string     $path    URL to inflect.
  * @param   integer    $limit   The number of objects per page.
  * @param   integer    $offset  The object's number on the page.
  * @param   timestamp  $until   A unix timestamp or any date accepted by strtotime.
  * @param   timestamp  $since   A unix timestamp or any date accepted by strtotime.
  *
  * @return  string  The request URL.
  *
  * @since   13.1
  */
 protected function fetchUrl($path, $limit = 0, $offset = 0, $until = null, $since = null)
 {
     // Get a new JUri object fousing the api url and given path.
     $uri = new JUri($this->options->get('api.url') . $path);
     if ($limit > 0) {
         $uri->setVar('limit', (int) $limit);
     }
     if ($offset > 0) {
         $uri->setVar('offset', (int) $offset);
     }
     if ($until != null) {
         $uri->setVar('until', $until);
     }
     if ($since != null) {
         $uri->setVar('since', $since);
     }
     return (string) $uri;
 }
 /**
  * @see https://www.warcraftlogs.com/v1/docs#!/Reports/
  * @throws RuntimeException
  *
  * @return stdClass
  */
 public function getData($api_key)
 {
     $uri = new JUri();
     $this->params->set('realm', str_replace("'", '', $this->params->get('realm')));
     $this->params->set('guild', str_replace(' ', '+', $this->params->get('guild')));
     $uri->setPath('/v1/reports/guild/' . $this->params->get('guild') . '/' . JApplicationHelper::stringURLSafe($this->params->get('realm')) . '/' . $this->params->get('region'));
     $uri->setVar('api_key', $api_key);
     return $this->getRemote($uri);
 }
Exemplo n.º 7
0
 /**
  * Method to build and return a full request URL for the request.  This method will
  * add appropriate pagination details if necessary and also prepend the API url
  * to have a complete URL for the request.
  *
  * @param string  $path  URL to inflect
  * @param integer $page  Page to request
  * @param integer $limit Number of results to return per page
  *
  * @return string The request URL.
  *
  * @since   11.3
  */
 protected function fetchUrl($path, $page = 0, $limit = 0)
 {
     // Get a new JUri object fousing the api url and given path.
     $uri = new JUri($this->options->get('api.url') . $path);
     if ($this->options->get('api.username', false)) {
         $uri->setUser($this->options->get('api.username'));
     }
     if ($this->options->get('api.password', false)) {
         $uri->setPass($this->options->get('api.password'));
     }
     // If we have a defined page number add it to the JUri object.
     if ($page > 0) {
         $uri->setVar('page', (int) $page);
     }
     // If we have a defined items per page add it to the JUri object.
     if ($limit > 0) {
         $uri->setVar('per_page', (int) $limit);
     }
     return (string) $uri;
 }
Exemplo n.º 8
0
 /**
  * @param JUri $uri
  * @param bool $persistent
  *
  * @return mixed
  */
 protected function getRemote($uri, $persistent = false)
 {
     $uri->setScheme($this->params->get('scheme', 'https'));
     $uri->setHost($this->params->get('region') . '.api.battle.net');
     $uri->setVar('locale', $this->params->get('locale'));
     $uri->setVar('apikey', $this->params->get('apikey'));
     $this->url = $uri->toString();
     $result = parent::getRemote($this->url, $persistent);
     $result->body = json_decode($result->body);
     if ($result->code != 200) {
         // hide api key from normal users
         if (!JFactory::getUser()->get('isRoot')) {
             $uri->delVar('apikey');
             $this->url = $uri->toString();
         }
         $msg = JText::sprintf('Server Error: %s url: %s', $result->body->reason, JHtml::_('link', $this->url, $result->code, array('target' => '_blank')));
         // TODO JText::_()
         throw new RuntimeException($msg);
     }
     return $result;
 }
Exemplo n.º 9
0
function getBlogItemLink($item)
{
    if ($item->params->get('access-view')) {
        $link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid));
    } else {
        $menu = JFactory::getApplication()->getMenu();
        $active = $menu->getActive();
        $itemId = $active->id;
        $link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId);
        $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid));
        $link = new JUri($link1);
        $link->setVar('return', base64_encode($returnURL));
    }
    return $link;
}
Exemplo n.º 10
0
 /**
  * Renders a Form for an Edit view and returns the corresponding HTML
  *
  * @param   Form   &$form  The form to render
  * @param   DataModel  $model  The model providing our data
  *
  * @return  string    The HTML rendering of the form
  */
 public function renderFormEdit(Form &$form, DataModel $model)
 {
     // Get the key for this model's table
     $key = $model->getKeyName();
     $keyValue = $model->getId();
     $html = '';
     $validate = strtolower($form->getAttribute('validate'));
     if (in_array($validate, array('true', 'yes', '1', 'on'))) {
         \JHTML::_('behavior.formvalidation');
         $class = ' form-validate';
         $this->loadValidationScript($form);
     } else {
         $class = '';
     }
     // Check form enctype. Use enctype="multipart/form-data" to upload binary files in your form.
     $template_form_enctype = $form->getAttribute('enctype');
     if (!empty($template_form_enctype)) {
         $enctype = ' enctype="' . $form->getAttribute('enctype') . '" ';
     } else {
         $enctype = '';
     }
     // Check form name. Use name="yourformname" to modify the name of your form.
     $formname = $form->getAttribute('name');
     if (empty($formname)) {
         $formname = 'adminForm';
     }
     // Check form ID. Use id="yourformname" to modify the id of your form.
     $formid = $form->getAttribute('id');
     if (empty($formid)) {
         $formid = $formname;
     }
     // Check if we have a custom task
     $customTask = $form->getAttribute('customTask');
     if (empty($customTask)) {
         $customTask = '';
     }
     // Get the form action URL
     $platform = $this->container->platform;
     $actionUrl = $platform->isBackend() ? 'index.php' : \JUri::root() . 'index.php';
     $itemid = $this->container->input->getCmd('Itemid', 0);
     if ($platform->isFrontend() && $itemid != 0) {
         $uri = new \JUri($actionUrl);
         if ($itemid) {
             $uri->setVar('Itemid', $itemid);
         }
         $actionUrl = \JRoute::_($uri->toString());
     }
     $html .= '<form action="' . $actionUrl . '" method="post" name="' . $formname . '" id="' . $formid . '"' . $enctype . ' class="form-horizontal' . $class . '">' . "\n";
     $html .= "\t" . '<input type="hidden" name="option" value="' . $this->container->componentName . '" />' . "\n";
     $html .= "\t" . '<input type="hidden" name="view" value="' . $form->getView()->getName() . '" />' . "\n";
     $html .= "\t" . '<input type="hidden" name="task" value="' . $customTask . '" />' . "\n";
     $html .= "\t" . '<input type="hidden" name="' . $key . '" value="' . $keyValue . '" />' . "\n";
     $html .= "\t" . '<input type="hidden" name="' . \JFactory::getSession()->getFormToken() . '" value="1" />' . "\n";
     $html .= $this->renderFormRaw($form, $model, 'edit');
     $html .= '</form>';
     return $html;
 }
Exemplo n.º 11
0
 /**
  * Method to list issues.
  *
  * @param   string   $user       The name of the owner of the GitHub repository.
  * @param   string   $repo       The name of the GitHub repository.
  * @param   string   $milestone  The milestone number, 'none', or *.
  * @param   string   $state      The optional state to filter requests by. [open, closed]
  * @param   string   $assignee   The assignee name, 'none', or *.
  * @param   string   $mentioned  The GitHub user name.
  * @param   string   $labels     The list of comma separated Label names. Example: bug,ui,@high.
  * @param   string   $sort       The sort order: created, updated, comments, default: created.
  * @param   string   $direction  The list direction: asc or desc, default: desc.
  * @param   JDate    $since      The date/time since when issues should be returned.
  * @param   integer  $page       The page number from which to get items.
  * @param   integer  $limit      The number of items on a page.
  *
  * @throws DomainException
  * @since   11.3
  *
  * @return  array
  */
 public function getListByRepository($user, $repo, $milestone = null, $state = null, $assignee = null, $mentioned = null, $labels = null, $sort = null, $direction = null, JDate $since = null, $page = 0, $limit = 0)
 {
     // Build the request path.
     $path = '/repos/' . $user . '/' . $repo . '/issues';
     $uri = new JUri($this->fetchUrl($path, $page, $limit));
     if ($milestone) {
         $uri->setVar('milestone', $milestone);
     }
     if ($state) {
         $uri->setVar('state', $state);
     }
     if ($assignee) {
         $uri->setVar('assignee', $assignee);
     }
     if ($mentioned) {
         $uri->setVar('mentioned', $mentioned);
     }
     if ($labels) {
         $uri->setVar('labels', $labels);
     }
     if ($sort) {
         $uri->setVar('sort', $sort);
     }
     if ($direction) {
         $uri->setVar('direction', $direction);
     }
     if ($since) {
         $uri->setVar('since', $since->toISO8601());
     }
     // Send the request.
     $response = $this->client->get((string) $uri);
     // Validate the response code.
     if ($response->code != 200) {
         // Decode the error response and throw an exception.
         $error = json_decode($response->body);
         throw new DomainException($error->message, $response->code);
     }
     return json_decode($response->body);
 }
Exemplo n.º 12
0
 /**
  * Retrieves items from an OAI-enabled url.
  *
  * @param  JTable  $harvest  The harvesting details.
  */
 public function onJHarvestRetrieve($harvest)
 {
     $params = new \Joomla\Registry\Registry();
     $params->loadString($harvest->params);
     if ($params->get('discovery.type') != 'oai') {
         return;
     }
     $resumptionToken = null;
     $http = JHttpFactory::getHttp();
     $metadataPrefix = $params->get('discovery.plugin.metadata');
     do {
         $queries = array();
         if ($resumptionToken) {
             $queries['resumptionToken'] = $resumptionToken;
             // take a break to avoid any timeout issues.
             if (($sleep = $params->get('follow_on', self::FOLLOW_ON)) != 0) {
                 sleep($sleep);
             }
         } else {
             $queries['metadataPrefix'] = $metadataPrefix;
             if ($harvest->harvested != JFactory::getDbo()->getNullDate()) {
                 $queries['from'] = JFactory::getDate($harvest->harvested)->format('Y-m-d\\TH:i:s\\Z');
             }
             if ($set = $params->get('set')) {
                 $queries['set'] = $set;
             }
             $queries['until'] = $harvest->now->format('Y-m-d\\TH:i:s\\Z');
         }
         $url = new JUri($params->get('discovery.url'));
         $url->setQuery($queries);
         $url->setVar('verb', 'ListRecords');
         JHarvestHelper::log('Retrieving ' . (string) $url . ' for harvest...', JLog::DEBUG);
         $response = $http->get($url);
         $reader = new XMLReader();
         $reader->xml($response->body);
         $prefix = null;
         $identifier = null;
         $resumptionToken = null;
         // empty the resumptionToken to force a reload per page.
         while ($reader->read()) {
             if ($reader->nodeType == XMLReader::ELEMENT) {
                 $doc = new DOMDocument();
                 $doc->appendChild($doc->importNode($reader->expand(), true));
                 $node = simplexml_load_string($doc->saveXML());
                 $attributes = (array) $node->attributes();
                 if (isset($attributes['@attributes'])) {
                     $attributes = $attributes['@attributes'];
                 }
                 switch ($reader->name) {
                     case "record":
                         try {
                             $this->cache($harvest, $node);
                         } catch (Exception $e) {
                             JHarvestHelper::log($e->getMessage(), JLog::ERROR);
                         }
                         break;
                     case 'responseDate':
                         // only get the response date if fresh harvest.
                         if (!$resumptionToken) {
                             $this->harvested = JFactory::getDate($node);
                         }
                         break;
                     case 'request':
                         $prefix = JArrayHelper::getValue($attributes, 'metadataPrefix', null, 'string');
                         break;
                     case 'error':
                         if (JArrayHelper::getValue($attributes, 'code', null, 'string') !== "noRecordsMatch") {
                             throw new Exception((string) $node, 500);
                         }
                         break;
                     case 'resumptionToken':
                         $resumptionToken = (string) $node;
                         break;
                     default:
                         break;
                 }
             }
         }
     } while ($resumptionToken);
 }
 /**
  * Test the setVar method.
  *
  * @return  void
  *
  * @since   11.1
  * @covers  JUri::setVar
  */
 public function testSetVar()
 {
     $this->object->setVar('somevar', 'somevalue');
     $this->assertThat($this->object->getVar('somevar'), $this->equalTo('somevalue'));
 }
Exemplo n.º 14
0
 /**
  * Renders a F0FForm for an Edit view and returns the corresponding HTML
  *
  * @param   F0FForm   &$form  The form to render
  * @param   F0FModel  $model  The model providing our data
  * @param   F0FInput  $input  The input object
  *
  * @return  string    The HTML rendering of the form
  */
 protected function renderFormEdit(F0FForm &$form, F0FModel $model, F0FInput $input)
 {
     // Get the key for this model's table
     $key = $model->getTable()->getKeyName();
     $keyValue = $model->getId();
     JHTML::_('behavior.tooltip');
     $html = '';
     $validate = strtolower($form->getAttribute('validate'));
     $class = '';
     if (in_array($validate, array('true', 'yes', '1', 'on'))) {
         JHtml::_('behavior.formvalidation');
         $class = 'form-validate ';
         $this->loadValidationScript($form);
     }
     // Check form enctype. Use enctype="multipart/form-data" to upload binary files in your form.
     $template_form_enctype = $form->getAttribute('enctype');
     if (!empty($template_form_enctype)) {
         $enctype = ' enctype="' . $form->getAttribute('enctype') . '" ';
     } else {
         $enctype = '';
     }
     // Check form name. Use name="yourformname" to modify the name of your form.
     $formname = $form->getAttribute('name');
     if (empty($formname)) {
         $formname = 'adminForm';
     }
     // Check form ID. Use id="yourformname" to modify the id of your form.
     $formid = $form->getAttribute('name');
     if (empty($formid)) {
         $formid = 'adminForm';
     }
     // Check if we have a custom task
     $customTask = $form->getAttribute('customTask');
     if (empty($customTask)) {
         $customTask = '';
     }
     // Get the form action URL
     $actionUrl = F0FPlatform::getInstance()->isBackend() ? 'index.php' : JUri::root() . 'index.php';
     if (F0FPlatform::getInstance()->isFrontend() && $input->getCmd('Itemid', 0) != 0) {
         $itemid = $input->getCmd('Itemid', 0);
         $uri = new JUri($actionUrl);
         if ($itemid) {
             $uri->setVar('Itemid', $itemid);
         }
         $actionUrl = JRoute::_($uri->toString());
     }
     $html .= '<form action="' . $actionUrl . '" method="post" name="' . $formname . '" id="' . $formid . '"' . $enctype . ' class="' . $class . '">' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="option" value="' . $input->getCmd('option') . '" />' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="view" value="' . $input->getCmd('view', 'edit') . '" />' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="task" value="' . $customTask . '" />' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="' . $key . '" value="' . $keyValue . '" />' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="' . JFactory::getSession()->getFormToken() . '" value="1" />' . PHP_EOL;
     $html .= $this->renderFormRaw($form, $model, $input, 'edit');
     $html .= '</form>';
     return $html;
 }
Exemplo n.º 15
0
 /**
  * redirectToDownload
  *
  * @return  void
  *
  * @throws \Exception
  */
 public static function redirectToDownload()
 {
     $username = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null;
     $password = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null;
     $input = \JFactory::getApplication()->input;
     $uri = new \JUri(\JUri::root());
     $uri->setUser($username);
     $uri->setPass($password);
     $uri->setVar('access_token', $input->get('access_token'));
     $uri->setVar('cmd', 'backup.download');
     \JFactory::getApplication()->redirect($uri);
     exit;
 }
Exemplo n.º 16
0
 public function step()
 {
     // Check permissions
     $this->_checkPermissions();
     // Set the profile
     $this->_setProfile();
     // Get the backup ID
     $backupId = $this->input->get('backupid', null, 'raw', 2);
     if (empty($backupId)) {
         $backupId = null;
     }
     $kettenrad = AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN, $backupId);
     $kettenrad->setBackupId($backupId);
     $kettenrad->tick();
     $array = $kettenrad->getStatusArray();
     $kettenrad->resetWarnings();
     // So as not to have duplicate warnings reports
     AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN, $backupId);
     if ($array['Error'] != '') {
         @ob_end_clean();
         echo '500 ERROR -- ' . $array['Error'];
         flush();
         JFactory::getApplication()->close();
     } elseif ($array['HasRun'] == 1) {
         // All done
         AEFactory::nuke();
         AEUtilTempvars::reset();
         @ob_end_clean();
         echo '200 OK';
         flush();
         JFactory::getApplication()->close();
     } else {
         $noredirect = $this->input->get('noredirect', 0, 'int');
         if ($noredirect != 0) {
             @ob_end_clean();
             echo "301 More work required";
             flush();
             JFactory::getApplication()->close();
         } else {
             $curUri = JUri::getInstance();
             $ssl = $curUri->isSSL() ? 1 : 0;
             $tempURL = JRoute::_('index.php?option=com_akeeba', false, $ssl);
             $uri = new JUri($tempURL);
             $uri->setVar('view', 'backup');
             $uri->setVar('task', 'step');
             $uri->setVar('key', $this->input->get('key', '', 'none', 2));
             $uri->setVar('profile', $this->input->get('profile', 1, 'int'));
             if (!empty($backupId)) {
                 $uri->setVar('backupid', $backupId);
             }
             // Maybe we have a multilingual site?
             $lg = F0FPlatform::getInstance()->getLanguage();
             $languageTag = $lg->getTag();
             $uri->setVar('lang', $languageTag);
             $redirectionUrl = $uri->toString();
             $this->_customRedirect($redirectionUrl);
         }
     }
 }
Exemplo n.º 17
0
 /**
  * Process the build uri query data based on custom defined rules
  *
  * @param   JUri  $uri  The URI
  *
  * @return  void
  */
 protected function _processBuildRules($uri)
 {
     // Make sure any menu vars are used if no others are specified
     if ($this->_mode != JROUTER_MODE_SEF && $uri->getVar('Itemid') && count($uri->getQuery(true)) == 2) {
         $app = JApplication::getInstance('site');
         $menu = $app->getMenu();
         // Get the active menu item
         $itemid = $uri->getVar('Itemid');
         $item = $menu->getItem($itemid);
         if ($item) {
             $uri->setQuery($item->query);
         }
         $uri->setVar('Itemid', $itemid);
     }
     // Process the attached build rules
     parent::_processBuildRules($uri);
     // Get the path data
     $route = $uri->getPath();
     if ($this->_mode == JROUTER_MODE_SEF && $route) {
         if ($limitstart = $uri->getVar('limitstart')) {
             $uri->setVar('start', (int) $limitstart);
             $uri->delVar('limitstart');
         }
     }
     $uri->setPath($route);
 }
Exemplo n.º 18
0
 /**
  * 1. Request authorization on GitHub.
  *
  * @param   string  $client_id     The client ID you received from GitHub when you registered.
  * @param   string  $redirect_uri  URL in your app where users will be sent after authorization.
  * @param   string  $scope         Comma separated list of scopes.
  * @param   string  $state         An unguessable random string. It is used to protect against
  *                                 cross-site request forgery attacks.
  *
  * @since 3.3 (CMS)
  *
  * @return JUri
  */
 public function getAuthorizationLink($client_id, $redirect_uri = '', $scope = '', $state = '')
 {
     $uri = new JUri('https://github.com/login/oauth/authorize');
     $uri->setVar('client_id', $client_id);
     if ($redirect_uri) {
         $uri->setVar('redirect_uri', urlencode($redirect_uri));
     }
     if ($scope) {
         $uri->setVar('scope', $scope);
     }
     if ($state) {
         $uri->setVar('state', $state);
     }
     return (string) $uri;
 }
Exemplo n.º 19
0
 /**
  * Get a file's contents from a repository.
  *
  * @param   string  $user  The name of the owner of the GitHub repository.
  * @param   string  $repo  The name of the GitHub repository.
  * @param   string  $path  The content path.
  * @param   string  $ref   The name of the commit/branch/tag. Default: the repository’s default branch (usually master)
  *
  * @return  \JHttpResponse
  *
  * @since   3.0.0
  */
 public function getFileContents($user, $repo, $path, $ref = null)
 {
     $path = "/repos/{$user}/{$repo}/contents/{$path}";
     $prepared = $this->prepareRequest($path);
     if ($ref) {
         $url = new \JUri($prepared['url']);
         $url->setVar('ref', $ref);
         $prepared['url'] = (string) $url;
     }
     return $this->processResponse($this->client->get($prepared['url'], $prepared['headers']));
 }
Exemplo n.º 20
0
 /**
  * Tests the buildRawRoute() method
  *
  * @return  void
  * @testdox JRouterSite::buildRawRoute() executes a legacy component router's preprocess method
  * @since   3.4
  */
 public function testALegacyComponentRoutersPreprocessMethodIsExecuted()
 {
     $uri = new JUri('index.php');
     $object = new JRouterSite(array(), $this->getMockCmsApp(), TestMockMenu::create($this));
     $buildRawRouteMethod = new ReflectionMethod('JRouterSite', 'buildRawRoute');
     $buildRawRouteMethod->setAccessible(true);
     $uri->setVar('option', 'com_test3');
     $uri->delVar('testvar');
     $buildRawRouteMethod->invokeArgs($object, array(&$uri));
     $this->assertEquals('index.php?option=com_test3', (string) $uri);
 }
Exemplo n.º 21
0
            ?>
">
								<?php 
            echo $this->escape($article->title);
            ?>
							</a>
						<?php 
        } else {
            ?>
							<?php 
            echo $this->escape($article->title) . ' : ';
            $menu = JFactory::getApplication()->getMenu();
            $active = $menu->getActive();
            $itemId = $active->id;
            $link = new JUri(JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false));
            $link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->language)));
            ?>
							<a href="<?php 
            echo $link;
            ?>
" class="register">
								<?php 
            echo JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
            ?>
							</a>
						<?php 
        }
        ?>
						<?php 
        if ($article->state == 0) {
            ?>
Exemplo n.º 22
0
        ?>
	<?php 
    }
}
?>

<?php 
if ($params->get('show_readmore') && $this->item->readmore) {
    if ($params->get('access-view')) {
        $link = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language));
    } else {
        $menu = JFactory::getApplication()->getMenu();
        $active = $menu->getActive();
        $itemId = $active->id;
        $link = new JUri(JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false));
        $link->setVar('return', base64_encode(JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language), false)));
    }
    ?>

	<?php 
    echo JLayoutHelper::render('joomla.content.readmore', array('item' => $this->item, 'params' => $params, 'link' => $link));
    ?>

<?php 
}
?>

<?php 
if ($this->item->state == 0 || strtotime($this->item->publish_up) > strtotime(JFactory::getDate()) || strtotime($this->item->publish_down) < strtotime(JFactory::getDate()) && $this->item->publish_down != '0000-00-00 00:00:00') {
    ?>
	</div>
Exemplo n.º 23
0
	<?php 
    }
    ?>

	<?php 
    if ($params->get('show_readmore') && $this->item->readmore) {
        if ($params->get('access-view')) {
            $link = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid));
        } else {
            $menu = JFactory::getApplication()->getMenu();
            $active = $menu->getActive();
            $itemId = $active->id;
            $link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId);
            $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid));
            $link = new JUri($link1);
            $link->setVar('return', base64_encode($returnURL));
        }
        ?>

	<?php 
        echo JLayoutHelper::render('joomla.content.readmore', array('item' => $this->item, 'params' => $params, 'link' => $link));
        ?>

<?php 
    }
    ?>

<?php 
    if ($this->item->state == 0 || strtotime($this->item->publish_up) > strtotime(JFactory::getDate()) || strtotime($this->item->publish_down) < strtotime(JFactory::getDate()) && $this->item->publish_down != '0000-00-00 00:00:00') {
        ?>
</div>
Exemplo n.º 24
0
 /**
  * transfer all data from $jinput to $input_data
  * and $reservation
  * 
  * @return boolean|multitype:
  */
 private function getData()
 {
     // check is user logged in?
     $user = JFactory::getUser();
     if ($user->id == 0) {
         $login = new JUri(JRoute::_('index.php?option=com_users&view=login'));
         $login->setVar('return', base64_encode(JFactory::getURI()));
         $app->redirect(JRoute::_($login));
         return false;
     }
     // get input data
     $this->getInputData();
     // create reservation data
     $this->reservation = array();
     if (empty($this->input_data['reservation_name'])) {
         $this->reservation['name'] = $user->name;
     } else {
         $this->reservation['name'] = $this->input_data['reservation_name'];
     }
     $this->reservation['name'] = str_replace('--', '&shy;', $this->reservation['name']);
     $this->reservation['reservation_type'] = $this->input_data['reservation_type'];
     $this->reservation['user_id'] = $user->id;
     $this->reservation['id_reservable'] = $this->input_data['id_reservable'];
     $this->reservation['start_time'] = $this->addHours($this->input_data['start_date'], $this->input_data['start_time']);
     $this->reservation['end_time'] = $this->addHours($this->reservation['start_time'], $this->input_data['duration']);
     $this->reservation['start_day'] = $this->input_data['start_day'];
     $this->reservation['end_day'] = $this->input_data['end_day'];
     // create occupations data
     $this->createOccupations();
     return true;
 }
Exemplo n.º 25
0
    }
    ?>
	
		
		<?php 
    //Optional link to let them register to see the whole competitie.
    ?>
		<?php 
    if ($params->get('show_competitie_readmore')) {
        $menu = JFactory::getApplication()->getMenu();
        $active = $menu->getActive();
        $item_id = $active->id;
        $link_1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $item_id);
        $return_url = $this->item->readmore_link;
        $link = new JUri($link_1);
        $link->setVar('return', base64_encode($return_url));
        ?>
					<p class="readmore">
						<a href="<?php 
        echo $link;
        ?>
" itemprop="url">
							<?php 
        if ($this->item->competitie_alternative_readmore == null) {
            if ($params->get('show_competitie_readmore_name') == 0) {
                echo JText::_('COM_KNVBAPI2_REGISTER_TO_READ_MORE');
            } else {
                echo JText::_('COM_KNVBAPI2_REGISTER_TO_READMORE_NAME');
                echo JHtml::_('string.truncate', $this->item->name, $params->get('competitie_readmore_limit'));
            }
        } else {
Exemplo n.º 26
0
            ?>

					<?php 
        } else {
            // Show unauth links.
            ?>
						<td>
							<?php 
            echo $this->escape($item->title) . ' : ';
            $menu = JFactory::getApplication()->getMenu();
            $active = $menu->getActive();
            $item_id = $active->id;
            $link = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $item_id);
            $return_url = JRoute::_(Knvbapi2HelperRoute::getTeamnaamRoute($item->slug, $item->catid, $item->language, $layout, $this->params->get('keep_teamnaam_itemid')));
            $full_url = new JUri($link);
            $full_url->setVar('return', base64_encode($return_url));
            ?>
							<a href="<?php 
            echo $full_url;
            ?>
" class="register">
								<?php 
            echo JText::_('COM_KNVBAPI2_REGISTER_TO_READ_MORE');
            ?>
</a>
						</td>
					<?php 
        }
        ?>
					<?php 
        if ($show_actions) {
Exemplo n.º 27
0
								<?php 
            echo $this->escape($article->title);
            ?>
							</a>
						<?php 
        } else {
            ?>
							<?php 
            echo $this->escape($article->title) . ' : ';
            $menu = JFactory::getApplication()->getMenu();
            $active = $menu->getActive();
            $itemId = $active->id;
            $link = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId);
            $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid));
            $fullURL = new JUri($link);
            $fullURL->setVar('return', base64_encode($returnURL));
            ?>
							<a href="<?php 
            echo $fullURL;
            ?>
" class="register">
								<?php 
            echo JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
            ?>
							</a>
						<?php 
        }
        ?>
						<?php 
        if ($article->state == 0) {
            ?>
Exemplo n.º 28
0
 /**
  * @param JRouter $router
  * @param JUri $uri
  */
 function buildRule(&$router, &$uri)
 {
     $MobileJoomla_Device =& MobileJoomla::getDevice();
     if ($MobileJoomla_Device['markup'] != $MobileJoomla_Device['default_markup']) {
         switch ($uri->getVar('format')) {
             case 'feed':
             case 'json':
             case 'xml':
                 return;
         }
         switch ($uri->getVar('type')) {
             case 'rss':
             case 'atom':
                 return;
         }
         if ((is_a($router, 'shRouter') || class_exists('Sh404sefClassRouter')) && $uri->getVar('Itemid') && count($uri->getQuery(true)) == 2) {
             $itemid = $uri->getVar('Itemid');
             $app = JFactory::getApplication();
             $menu = $app->getMenu();
             $item = $menu->getItem($itemid);
             $uri->setQuery($item->query);
             $uri->setVar('Itemid', $itemid);
             $uri->setVar('device', $MobileJoomla_Device['markup']);
         } else {
             $uri->setVar('device', $MobileJoomla_Device['markup']);
         }
     }
 }
 /**
  * Validates a Yubikey OTP against the Yubikey servers
  *
  * @param   string  $otp  The OTP generated by your Yubikey
  *
  * @return  boolean  True if it's a valid OTP
  *
  * @since   3.2
  */
 public function validateYubikeyOtp($otp)
 {
     $server_queue = array('api.yubico.com', 'api2.yubico.com', 'api3.yubico.com', 'api4.yubico.com', 'api5.yubico.com');
     shuffle($server_queue);
     $gotResponse = false;
     $check = false;
     $http = JHttpFactory::getHttp();
     $token = JSession::getFormToken();
     $nonce = md5($token . uniqid(rand()));
     while (!$gotResponse && !empty($server_queue)) {
         $server = array_shift($server_queue);
         $uri = new JUri('https://' . $server . '/wsapi/2.0/verify');
         // I don't see where this ID is used?
         $uri->setVar('id', 1);
         // The OTP we read from the user
         $uri->setVar('otp', $otp);
         // This prevents a REPLAYED_OTP status of the token doesn't change
         // after a user submits an invalid OTP
         $uri->setVar('nonce', $nonce);
         // Minimum service level required: 50% (at least 50% of the YubiCloud
         // servers must reply positively for the OTP to validate)
         $uri->setVar('sl', 50);
         // Timeou waiting for YubiCloud servers to reply: 5 seconds.
         $uri->setVar('timeout', 5);
         try {
             $response = $http->get($uri->toString(), null, 6);
             if (!empty($response)) {
                 $gotResponse = true;
             } else {
                 continue;
             }
         } catch (Exception $exc) {
             // No response, continue with the next server
             continue;
         }
     }
     // No server replied; we can't validate this OTP
     if (!$gotResponse) {
         return false;
     }
     // Parse response
     $lines = explode("\n", $response->body);
     $data = array();
     foreach ($lines as $line) {
         $line = trim($line);
         $parts = explode('=', $line, 2);
         if (count($parts) < 2) {
             continue;
         }
         $data[$parts[0]] = $parts[1];
     }
     // Validate the response - We need an OK message reply
     if ($data['status'] != 'OK') {
         return false;
     }
     // Validate the response - We need a confidence level over 50%
     if ($data['sl'] < 50) {
         return false;
     }
     // Validate the response - The OTP must match
     if ($data['otp'] != $otp) {
         return false;
     }
     // Validate the response - The token must match
     if ($data['nonce'] != $nonce) {
         return false;
     }
     return true;
 }
Exemplo n.º 30
0
 /**
  * Return JUri object pointing to the Announcement task.
  *
  * @param string $task
  *
  * @return JUri
  */
 public function getTaskUri($task = null)
 {
     $uri = new JUri('index.php?option=com_kunena&view=announcement');
     if ($task) {
         $uri->setVar('task', $task);
     }
     if ($this->id) {
         $uri->setVar('id', $this->id);
     }
     if ($task) {
         $uri->setVar(JSession::getFormToken(), 1);
     }
     return $uri;
 }