function dv_data_definition_update()
{
    check_rid();
    global $com_name, $conf;
    $base = $conf['dir_base'];
    $db_id = Request::getString('db', false);
    $dd_name = Request::getString('dd', false);
    $dd_text = $_POST['dd_text'];
    if (get_magic_quotes_gpc()) {
        $dd_text = stripslashes($dd_text);
    }
    $db_conf_file = $base . DS . $db_id . DS . 'database.json';
    $db_conf = json_decode(file_get_contents($db_conf_file), true);
    $author = User::get('name') . ' <' . User::get('email') . '>';
    $dd_file_php = "{$base}/{$db_id}/applications/{$com_name}/datadefinitions-php/{$dd_name}.php";
    file_put_contents($dd_file_php, $dd_text);
    $cmd = "cd {$base}/{$db_id}/applications/{$com_name}/datadefinitions-php/; git commit {$dd_name}.php --author=\"{$author}\" -m\"[UPDATE] {$dd_name}.php.\"  > /dev/null";
    system($cmd);
    $dd_file_json = "{$base}/{$db_id}/applications/{$com_name}/datadefinitions/{$dd_name}.json";
    $cmd = "cd " . JPATH_COMPONENT . "; php ./ddconvert.php -i{$dd_file_php} -o{$dd_file_json}";
    system($cmd);
    $cmd = "cd {$base}/{$db_id}/applications/{$com_name}/datadefinitions/; git commit {$dd_name}.json --author=\"{$author}\" -m\"[UPDATE] {$dd_name}.json.\"  > /dev/null";
    system($cmd);
    $url = str_replace($_SERVER['SCRIPT_URL'], '', $_SERVER['SCRIPT_URI']);
    $url .= "/administrator/index.php?option=com_{$com_name}&task=data_definition&db={$db_id}&dd={$dd_name}";
    header("Location: {$url}");
    exit;
}
Example #2
0
 /**
  * Calls an HTTP POST function to verify if the user's guess was correct
  *
  * @return  True if the answer is correct, false otherwise
  * @since  2.5
  */
 public function onCheckAnswer($code)
 {
     // Initialise variables
     $privatekey = $this->params->get('private_key');
     $remoteip = Request::getVar('REMOTE_ADDR', '', 'SERVER');
     $challenge = Request::getString('recaptcha_challenge_field', '');
     $response = Request::getString('recaptcha_response_field', '');
     // Check for Private Key
     if (empty($privatekey)) {
         $this->_subject->setError(Lang::txt('PLG_RECAPTCHA_ERROR_NO_PRIVATE_KEY'));
         return false;
     }
     // Check for IP
     if (empty($remoteip)) {
         $this->_subject->setError(Lang::txt('PLG_RECAPTCHA_ERROR_NO_IP'));
         return false;
     }
     // Discard spam submissions
     if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
         $this->_subject->setError(Lang::txt('PLG_RECAPTCHA_ERROR_EMPTY_SOLUTION'));
         return false;
     }
     $response = $this->_recaptcha_http_post(self::RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", array('privatekey' => $privatekey, 'remoteip' => $remoteip, 'challenge' => $challenge, 'response' => $response));
     $answers = explode("\n", $response[1]);
     if (trim($answers[0]) == 'true') {
         return true;
     } else {
         //@todo use exceptions here
         $this->_subject->setError(Lang::txt('PLG_RECAPTCHA_ERROR_' . strtoupper(str_replace('-', '_', $answers[1]))));
         return false;
     }
 }
Example #3
0
 /**
  * Method to get the help search string
  * @return string Help search string
  */
 function &getHelpSearch()
 {
     if (is_null($this->help_search)) {
         $this->help_search = Request::getString('helpsearch');
     }
     return $this->help_search;
 }
Example #4
0
 function &getData()
 {
     $data = new stdClass();
     $data->link = urldecode(Request::getVar('link', '', 'method', 'base64'));
     if ($data->link == '') {
         App::abort(403, Lang::txt('COM_MAILTO_LINK_IS_MISSING'));
         $false = false;
         return $false;
     }
     // Load with previous data, if it exists
     $mailto = Request::getString('mailto', '', 'post');
     $sender = Request::getString('sender', '', 'post');
     $from = Request::getString('from', '', 'post');
     $subject = Request::getString('subject', '', 'post');
     if (User::get('id') > 0) {
         $data->sender = User::get('name');
         $data->from = User::get('email');
     } else {
         $data->sender = $sender;
         $data->from = $from;
     }
     $data->subject = $subject;
     $data->mailto = $mailto;
     return $data;
 }
Example #5
0
function view()
{
    global $html_path, $com_name, $dv_conf;
    $hash = Request::getVar('hash');
    if ($hash != '') {
        $file = $_SESSION['dv']['file_download']['list'][$hash];
        $file_name = basename($file);
        $full_path = $file;
    } else {
        $base_path = $dv_conf['base_path'];
        $file = Request::getString('f', false);
        $pi = pathinfo($file);
        $file_name = $pi['basename'];
        $full_path = $base_path . $file;
    }
    if (!$file || !file_exists($full_path)) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
        exit;
    }
    if ($full_path !== realpath($full_path)) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
        exit;
    }
    if (is_file($full_path)) {
        if (!preg_match('/\\.(gif|jpe?g|png|pdf)$/i', $file_name)) {
            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename="' . $file_name . '"');
            header('Content-Transfer-Encoding: binary');
        } else {
            $mime = 'application/octet-stream';
            switch (strtolower(pathinfo($full_path, PATHINFO_EXTENSION))) {
                case 'jpeg':
                case 'jpg':
                    $mime = 'image/jpeg';
                    break;
                case 'png':
                    $mime = 'image/png';
                    break;
                case 'gif':
                    $mime = 'image/gif';
                    break;
                case 'pdf':
                    $mime = 'application/pdf';
                    break;
            }
            header('X-Content-Type-Options: nosniff');
            header('Content-Type: ' . $mime);
            header('Content-Disposition: inline; filename="' . $file_name . '"');
        }
        header('Content-Length: ' . filesize($full_path));
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s T', filemtime($full_path)));
        ob_clean();
        ob_end_flush();
        readfile($full_path);
    }
    exit;
}
Example #6
0
 /**
  * @covers Request::getString
  */
 public function testGetStringGET()
 {
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $_GET['name'] = "fruition sciences";
     $key = "name";
     $actual = $this->req->getString($key);
     $excepted = "fruition sciences";
     $this->assertEquals($excepted, $actual);
 }
Example #7
0
 public function onAfterInitialise()
 {
     // No remember me for admin
     if (!App::isSite()) {
         return;
     }
     if (User::isGuest()) {
         $hash = App::hash('JLOGIN_REMEMBER');
         if ($str = Request::getString($hash, '', 'cookie', 1 | 2)) {
             $credentials = array();
             $goodCookie = true;
             $filter = JFilterInput::getInstance();
             // Create the encryption key, apply extra hardening using the user agent string.
             // Since we're decoding, no UA validity check is required.
             $privateKey = App::hash(@$_SERVER['HTTP_USER_AGENT']);
             $crypt = new \Hubzero\Encryption\Encrypter(new \Hubzero\Encryption\Cipher\Simple(), new \Hubzero\Encryption\Key('simple', $privateKey, $privateKey));
             try {
                 $str = $crypt->decrypt($str);
                 if (!is_string($str)) {
                     throw new Exception('Decoded cookie is not a string.');
                 }
                 $cookieData = json_decode($str);
                 if (null === $cookieData) {
                     throw new Exception('JSON could not be docoded.');
                 }
                 if (!is_object($cookieData)) {
                     throw new Exception('Decoded JSON is not an object.');
                 }
                 // json_decoded cookie could be any object structure, so make sure the
                 // credentials are well structured and only have user and password.
                 if (isset($cookieData->username) && is_string($cookieData->username)) {
                     $credentials['username'] = $filter->clean($cookieData->username, 'username');
                 } else {
                     throw new Exception('Malformed username.');
                 }
                 if (isset($cookieData->password) && is_string($cookieData->password)) {
                     $credentials['password'] = $filter->clean($cookieData->password, 'string');
                 } else {
                     throw new Exception('Malformed password.');
                 }
                 // We're only doing this for the site app, so we explicitly set the action here
                 $return = App::get('auth')->login($credentials, array('silent' => true, 'action' => 'core.login.site'));
                 if (!$return) {
                     throw new Exception('Log-in failed.');
                 }
             } catch (Exception $e) {
                 $cookie_domain = Config::get('cookie_domain', '');
                 $cookie_path = Config::get('cookie_path', '/');
                 // Clear the remember me cookie
                 setcookie(App::hash('JLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain);
                 Log::warning('A remember me cookie was unset for the following reason: ' . $e->getMessage());
             }
         }
     }
 }
Example #8
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return  void
  * @since   1.6
  */
 protected function populateState()
 {
     // Set the component (option) we are dealing with.
     $component = Request::getCmd('component');
     $this->setState('component.option', $component);
     // Set an alternative path for the configuration file.
     if ($path = Request::getString('path')) {
         $path = Filesystem::cleanPath(PATH_ROOT . '/' . $path);
         \Hubzero\Filesystem\Util::checkCheck($path);
         $this->setState('component.path', $path);
     }
 }
Example #9
0
 /**
  * get marker coordinates
  */
 public function getmarkersTask()
 {
     $checked = Request::getVar('checked', array(), 'request');
     $tags = trim(Request::getString('tags', '', 'request'));
     $resources = Request::get('resources', array());
     $filters = array();
     $filters['scope'] = $resources;
     // get markers object
     $GM = new \Components\Geosearch\Tables\GeosearchMarkers($this->database);
     echo $GM->getMarkers($filters);
     exit;
 }
Example #10
0
 /**
  * Configure the Linkbar.
  *
  * @param   string  $vName  The name of the active view.
  *
  * @return  void
  *
  * @since   1.6
  */
 public static function addSubmenu($vName)
 {
     Submenu::addEntry(Lang::txt('COM_USERS_SUBMENU_MEMBERS'), Route::url('index.php?option=com_members&view=users'), $vName == 'users');
     // Groups and Levels are restricted to core.admin
     $canDo = self::getActions();
     if ($canDo->get('core.admin')) {
         Submenu::addEntry(Lang::txt('COM_USERS_SUBMENU_GROUPS'), Route::url('index.php?option=com_users&view=groups'), $vName == 'groups');
         Submenu::addEntry(Lang::txt('COM_USERS_SUBMENU_LEVELS'), Route::url('index.php?option=com_users&view=levels'), $vName == 'levels');
         Submenu::addEntry(Lang::txt('COM_USERS_SUBMENU_NOTES'), Route::url('index.php?option=com_users&view=notes'), $vName == 'notes');
         $extension = Request::getString('extension');
         Submenu::addEntry(Lang::txt('COM_USERS_SUBMENU_NOTE_CATEGORIES'), Route::url('index.php?option=com_categories&extension=com_users'), $vName == 'categories' || $extension == 'com_users');
     }
 }
Example #11
0
 /**
  * Object Constructor.
  *
  * @param   object  $subject  The object to observe -- event dispatcher.
  * @param   object  $config   The configuration object for the plugin.
  * @return  void
  */
 public function __construct(&$subject, $config)
 {
     parent::__construct($subject, $config);
     $this->loadLanguage();
     $hash = App::hash('plgSystemLogout');
     if (App::isSite() and Request::getString($hash, null, 'cookie')) {
         // Destroy the cookie
         $cookie_domain = Config::get('config.cookie_domain', '');
         $cookie_path = Config::get('config.cookie_path', '/');
         setcookie($hash, false, time() - 86400, $cookie_path, $cookie_domain);
         // Set the error handler for E_ALL to be the class handleError method.
         set_exception_handler(array('plgSystemLogout', 'handleError'));
     }
 }
Example #12
0
 /**
  * Save the manual order inputs from the categories list page.
  *
  * @return	void
  * @since	1.6
  */
 public function saveorder()
 {
     Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
     // Get the arrays from the Request
     $order = Request::getVar('order', null, 'post', 'array');
     $originalOrder = explode(',', Request::getString('original_order_values'));
     // Make sure something has changed
     if (!($order === $originalOrder)) {
         parent::saveorder();
     } else {
         // Nothing to reorder
         $this->setRedirect(Route::url('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
         return true;
     }
 }
function dv_config_update()
{
    check_rid();
    global $com_name, $conf;
    $base = $conf['dir_base'];
    $db_id = Request::getString('db', false);
    $dv_conf_text = Request::getString('conf_text', false);
    $dv_conf_file = $base . DS . $db_id . DS . 'applications/dataviewer/config.json';
    file_put_contents($dv_conf_file, $dv_conf_text);
    $_SESSION['dataviewer']['conf_file_updated'] = true;
    $url = str_replace($_SERVER['SCRIPT_URL'], '', $_SERVER['SCRIPT_URI']);
    $url .= "/administrator/index.php?option=com_" . $conf['com_name'] . "&task=config&db={$db_id}";
    header("Location: {$url}");
    exit;
}
Example #14
0
 /**
  * Don't allow categories to be deleted if they contain items or subcategories with items
  *
  * @param	string	The context for the content passed to the plugin.
  * @param	object	The data relating to the content that was deleted.
  * @return	boolean
  * @since	1.6
  */
 public function onContentBeforeDelete($context, $data)
 {
     // Skip plugin if we are deleting something other than categories
     if ($context != 'com_categories.category') {
         return true;
     }
     // Check if this function is enabled.
     if (!$this->params->def('check_categories', 1)) {
         return true;
     }
     $extension = Request::getString('extension');
     // Default to true if not a core extension
     $result = true;
     $tableInfo = array('com_banners' => array('table_name' => '#__banners'), 'com_contact' => array('table_name' => '#__contact_details'), 'com_content' => array('table_name' => '#__content'), 'com_newsfeeds' => array('table_name' => '#__newsfeeds'), 'com_weblinks' => array('table_name' => '#__weblinks'));
     // Now check to see if this is a known core extension
     if (isset($tableInfo[$extension])) {
         // Get table name for known core extensions
         $table = $tableInfo[$extension]['table_name'];
         // See if this category has any content items
         $count = $this->_countItemsInCategory($table, $data->get('id'));
         // Return false if db error
         if ($count === false) {
             $result = false;
         } else {
             // Show error if items are found in the category
             if ($count > 0) {
                 $msg = Lang::txt('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) . Lang::txts('COM_CATEGORIES_N_ITEMS_ASSIGNED', $count);
                 Notify::warning(403, $msg);
                 $result = false;
             }
             // Check for items in any child categories (if it is a leaf, there are no child categories)
             if (!$data->isLeaf()) {
                 $count = $this->_countItemsInChildren($table, $data->get('id'), $data);
                 if ($count === false) {
                     $result = false;
                 } elseif ($count > 0) {
                     $msg = Lang::txt('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) . Lang::txts('COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS', $count);
                     Notify::warning(403, $msg);
                     $result = false;
                 }
             }
         }
         return $result;
     }
 }
Example #15
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @since	1.6
  */
 protected function populateState($ordering = null, $direction = null)
 {
     parent::populateState();
     // Add archive properties
     $params = $this->state->params;
     // Filter on archived articles
     $this->setState('filter.published', 2);
     // Filter on month, year
     $this->setState('filter.month', Request::getInt('month'));
     $this->setState('filter.year', Request::getInt('year'));
     // Optional filter text
     $this->setState('list.filter', Request::getString('filter-search'));
     // Get list limit
     $app = JFactory::getApplication();
     $itemid = Request::getInt('Itemid', 0);
     $limit = $app->getUserStateFromRequest('com_content.archive.list' . $itemid . '.limit', 'limit', $params->get('display_num'), 'uint');
     $this->setState('list.limit', $limit);
 }
Example #16
0
 /**
  * Prepare content
  *
  * @param   string   $context  The context of the content being passed to the plugin.
  * @param   object   $article  The article object.  Note $article->text is also available
  * @param   object   $params   The article params
  * @param   integer  $page     The 'page' number
  * @return  void
  */
 public function onContentBeforeDisplay($context, &$row, &$params, $page = 0)
 {
     $html = '';
     if ($params->get('show_vote')) {
         $rating = intval(@$row->rating);
         $rating_count = intval(@$row->rating_count);
         $view = Request::getString('view', '');
         $img = '';
         // look for images in template if available
         $starImageOn = Html::asset('image', 'system/rating_star.png', NULL, NULL, true);
         $starImageOff = Html::asset('image', 'system/rating_star_blank.png', NULL, NULL, true);
         for ($i = 0; $i < $rating; $i++) {
             $img .= $starImageOn;
         }
         for ($i = $rating; $i < 5; $i++) {
             $img .= $starImageOff;
         }
         $html .= '<span class="content_rating">';
         $html .= Lang::txt('PLG_VOTE_USER_RATING', $img, $rating_count);
         $html .= "</span>\n<br />\n";
         if ($view == 'article' && $row->state == 1) {
             $uri = JFactory::getURI();
             $uri->setQuery($uri->getQuery() . '&hitcount=0');
             $html .= '<form method="post" action="' . htmlspecialchars($uri->toString()) . '">';
             $html .= '<div class="content_vote">';
             $html .= Lang::txt('PLG_VOTE_POOR');
             $html .= '<input type="radio" title="' . Lang::txt('PLG_VOTE_VOTE', '1') . '" name="user_rating" value="1" />';
             $html .= '<input type="radio" title="' . Lang::txt('PLG_VOTE_VOTE', '2') . '" name="user_rating" value="2" />';
             $html .= '<input type="radio" title="' . Lang::txt('PLG_VOTE_VOTE', '3') . '" name="user_rating" value="3" />';
             $html .= '<input type="radio" title="' . Lang::txt('PLG_VOTE_VOTE', '4') . '" name="user_rating" value="4" />';
             $html .= '<input type="radio" title="' . Lang::txt('PLG_VOTE_VOTE', '5') . '" name="user_rating" value="5" checked="checked" />';
             $html .= Lang::txt('PLG_VOTE_BEST');
             $html .= '&#160;<input class="button" type="submit" name="submit_vote" value="' . Lang::txt('PLG_VOTE_RATE') . '" />';
             $html .= '<input type="hidden" name="task" value="article.vote" />';
             $html .= '<input type="hidden" name="hitcount" value="0" />';
             $html .= '<input type="hidden" name="url" value="' . htmlspecialchars($uri->toString()) . '" />';
             $html .= Html::input('token');
             $html .= '</div>';
             $html .= '</form>';
         }
     }
     return $html;
 }
function dv_data_definition_remove()
{
    check_rid();
    global $com_name, $conf;
    $base = $conf['dir_base'];
    $db_id = Request::getString('db', false);
    $dd_name = Request::getString('dd_name', false);
    $author = User::get('name') . ' <' . User::get('email') . '>';
    $dd_file_php = "{$base}/{$db_id}/applications/{$com_name}/datadefinitions-php/{$dd_name}.php";
    system("rm {$dd_file_php}");
    $cmd = "cd {$base}/{$db_id}/applications/{$com_name}/datadefinitions-php/; git commit {$dd_name}.php --author=\"{$author}\" -m\"[DELETE] {$dd_name}.php.\"  > /dev/null";
    system($cmd);
    $dd_file_json = "{$base}/{$db_id}/applications/{$com_name}/datadefinitions/{$dd_name}.json";
    system("rm {$dd_file_json}");
    $cmd = "cd {$base}/{$db_id}/applications/{$com_name}/datadefinitions/; git commit {$dd_name}.json --author=\"{$author}\" -m\"[DELETE] {$dd_name}.json.\"  > /dev/null";
    system($cmd);
    db_msg('Dataview successfully removed', 'message');
    $url = str_replace($_SERVER['SCRIPT_URL'], '', $_SERVER['SCRIPT_URI']);
    $url .= "/administrator/index.php?option=com_{$com_name}&task=dataview_list&db={$db_id}";
    header("Location: {$url}");
}
function dv_config_current()
{
    global $com_name, $conf;
    $base = $conf['dir_base'];
    $db_id = Request::getString('db', false);
    require_once JPATH_COMPONENT_SITE . DS . 'dv_config.php';
    $dv_conf_file = $base . DS . $db_id . DS . 'applications/dataviewer/config.json';
    $db_dv_conf = array();
    if (file_exists($dv_conf_file)) {
        $db_dv_conf = json_decode(file_get_contents($dv_conf_file), true);
        if (!is_array($db_dv_conf)) {
            $db_dv_conf = array();
        }
        if (isset($db_dv_conf['settings'])) {
            $db_dv_conf['settings'] = array_merge($dv_conf['settings'], $db_dv_conf['settings']);
        }
    }
    $dv_conf = array_merge($dv_conf, $db_dv_conf);
    print json_format(json_encode($dv_conf));
    exit;
}
Example #19
0
 /**
  * Return results for autocompleter
  *
  * @return     string JSON
  */
 public function autocompleteTask()
 {
     $filters = array('limit' => 20, 'start' => 0, 'admin' => 0, 'search' => trim(Request::getString('value', '')), 'getowner' => 1);
     // Get records
     $rows = $this->model->entries('list', $this->view->filters, false);
     // Output search results in JSON format
     $json = array();
     if (count($rows) > 0) {
         foreach ($rows as $row) {
             $title = str_replace("\n", '', stripslashes(trim($row->get('title'))));
             $title = str_replace("\r", '', $title);
             $item = array('id' => $row->get('alias'), 'name' => $title);
             // Push exact matches to the front
             if ($row->get('alias') == $filters['search']) {
                 array_unshift($json, $item);
             } else {
                 $json[] = $item;
             }
         }
     }
     echo json_encode($json);
 }
Example #20
0
 public function stdin($buf)
 {
     $this->buf .= $buf;
     start:
     $l = strlen($this->buf);
     if ($l < 6) {
         return;
     }
     // not enough data yet.
     extract(unpack('Ctype/Chlen/Nblen', binarySubstr($this->buf, 0, 6)));
     if ($l < 6 + $hlen + $blen) {
         return;
     }
     // not enough data yet.
     $header = binarySubstr($this->buf, 6, $hlen);
     $body = binarySubstr($this->buf, 6 + $hlen, $blen);
     $this->buf = binarySubstr($this->buf, 6 + $hlen + $blen);
     list($reqId, $authKey) = explode('.', $header);
     if (isset($this->appInstance->queue[$reqId]->downstream) && $this->appInstance->queue[$reqId]->authKey == $authKey) {
         if ($type === WebSocketOverCOMET::IPCPacketType_C2S) {
             $this->appInstance->queue[$reqId]->downstream->onFrame($body, WebSocketServer::STRING);
             $this->appInstance->queue[$reqId]->atime = time();
         } elseif ($type === WebSocketOverCOMET::IPCPacketType_S2C) {
             if (isset($this->appInstance->polling[$header])) {
                 foreach ($this->appInstance->polling[$header] as $pollReqId) {
                     if (isset($this->appInstance->queue[$pollReqId])) {
                         $req = $this->appInstance->queue[$pollReqId];
                         if (isset($req->attrs->get['_script'])) {
                             $q = Request::getString($req->attrs->get['q']);
                             $body = 'var Response' . $q . ' = ' . $body . ";\n";
                         } else {
                             $body .= "\n";
                         }
                         $req->out($body);
                         $req->finish();
                     }
                 }
             }
         } elseif ($type === WebSocketOverCOMET::IPCPacketType_POLL) {
             $this->appInstance->queue[$reqId]->polling[] = $this->connId;
             $this->appInstance->queue[$reqId]->flushBufferedPackets($body);
             $this->appInstance->queue[$reqId]->atime = time();
         }
     } else {
         if (Daemon::$settings['logerrors']) {
             Daemon::log('Undispatched packet (type = ' . $type . ', reqId = ' . $reqId . ', authKey = ' . $authKey . ', exists = ' . (isset($this->appInstance->queue[$reqId]) ? '1 - ' . get_class($this->appInstance->queue[$reqId]) : '0') . ').');
         }
     }
     goto start;
 }
function dv_data_definition_new()
{
    global $com_name, $conf;
    $base = $conf['dir_base'];
    $document = App::get('document');
    $db_id = Request::getString('db', false);
    $table = Request::getString('table', false);
    $name = Request::getString('name', false);
    $title = Request::getString('title', false);
    $name = strtolower(preg_replace('/\\W/', '_', $name));
    $db_conf_file = $base . DS . $db_id . DS . 'database.json';
    $db_conf = json_decode(file_get_contents($db_conf_file), true);
    $jdb = JDatabase::getInstance($db_conf['database_ro']);
    $dd = array();
    $dd['table'] = $table;
    $dd['title'] = $title;
    $sql = "SHOW COLUMNS FROM {$table}";
    $jdb->setQuery($sql);
    $cols = $jdb->loadAssocList();
    $first_col = true;
    $pk = '';
    foreach ($cols as $col) {
        if ($col['Key'] == 'PRI') {
            $pk = $dd['table'] . '.' . $col['Field'];
        }
        $dd['cols'][$dd['table'] . '.' . $col['Field']] = array('label' => ucwords(str_replace('_', ' ', $col['Field'])));
    }
    $dd_text = "<?php\ndefined('_HZEXEC_') or die();\n\n";
    $dd_text .= "function get_{$name}()\n{\n";
    $dd_text .= "\t" . '$dd[\'title\'] = \'' . $title . '\';' . "\n";
    $dd_text .= "\t" . '$dd[\'table\'] = \'' . $dd['table'] . '\';' . "\n";
    $dd_text .= "\t" . '$dd[\'pk\'] = \'' . $pk . '\';' . "\n\n";
    foreach ($dd['cols'] as $col => $val) {
        $dd_text .= "\t" . '$dd[\'cols\'][\'' . $col . '\'] = ' . format_var(var_export($val, true)) . "\n";
    }
    $dd_text .= "\n\t" . 'return $dd;' . "\n\n}\n?>";
    // Check directories
    if (!file_exists("{$base}/{$db_id}/applications/{$com_name}/datadefinitions-php/")) {
        $dir = "{$base}/{$db_id}/applications/{$com_name}/datadefinitions-php/";
        $cmd = "mkdir -p {$dir}; cd {$dir}; git init > /dev/null";
        system($cmd);
    }
    if (!file_exists("{$base}/{$db_id}/applications/{$com_name}/datadefinitions/")) {
        $dir = "{$base}/{$db_id}/applications/{$com_name}/datadefinitions/";
        $cmd = "mkdir -p {$dir}; cd {$dir}; git init > /dev/null";
        system($cmd);
    }
    $dd_name = $name;
    $author = User::get('name') . ' <' . User::get('email') . '>';
    $dd_file_php = "{$base}/{$db_id}/applications/{$com_name}/datadefinitions-php/{$dd_name}.php";
    file_put_contents($dd_file_php, $dd_text);
    $cmd = "cd {$base}/{$db_id}/applications/{$com_name}/datadefinitions-php/; git add {$dd_name}.php; git commit {$dd_name}.php --author=\"{$author}\" -m\"[ADD] {$dd_name}.php Initial commit.\"  > /dev/null";
    system($cmd);
    $dd_file_json = "{$base}/{$db_id}/applications/{$com_name}/datadefinitions/{$dd_name}.json";
    $cmd = "cd " . JPATH_COMPONENT . "; php ./ddconvert.php -i{$dd_file_php} -o{$dd_file_json}";
    system($cmd);
    $cmd = "cd {$base}/{$db_id}/applications/{$com_name}/datadefinitions/; git add {$dd_name}.json; git commit {$dd_name}.json --author=\"{$author}\" -m\"[ADD] {$dd_name}.json Initial commit.\"  > /dev/null";
    system($cmd);
    db_msg('New Dataview Added', 'message');
    $url = str_replace($_SERVER['SCRIPT_URL'], '', $_SERVER['SCRIPT_URI']);
    $url .= "/administrator/index.php?option=com_{$com_name}&task=data_definition&db={$db_id}&dd={$dd_name}";
    header("Location: {$url}");
    exit;
}
Example #22
0
" alt="" /> <span title="<?php 
        echo $item->get('localPath');
        ?>
"><?php 
        echo \Components\Projects\Helpers\Html::shortenFileName($item->get('name'), 50);
        ?>
</span>
			</span>

		</li>
	<?php 
    }
} else {
    ?>
	<li class="noresults <?php 
    echo ($parent = Request::getString('parent', '')) ? 'parent-' . $parent : '';
    ?>
"><?php 
    echo $this->model->isProvisioned() ? Lang::txt('PLG_PROJECTS_FILES_SELECTOR_NO_FILES_FOUND_PROV') : Lang::txt('PLG_PROJECTS_FILES_SELECTOR_NO_FILES_FOUND');
    ?>
</li>
<?php 
}
?>

<?php 
if (!isset($this->noUl) || !$this->noUl) {
    ?>
	</ul>
<?php 
}
Example #23
0
 /**
  * @param	string	The context of the content being passed to the plugin.
  * @param	object	The article object.  Note $article->text is also available
  * @param	object	The article params
  * @param	int		The 'page' number
  *
  * @return	void
  * @since	1.6
  */
 public function onContentPrepare($context, &$row, &$params, $page = 0)
 {
     $canProceed = $context == 'com_content.article';
     if (!$canProceed) {
         return;
     }
     $style = $this->params->get('style', 'pages');
     // Expression to search for.
     $regex = '#<hr(.*)class="system-pagebreak"(.*)\\/>#iU';
     $print = Request::getBool('print');
     $showall = Request::getBool('showall');
     if (!$this->params->get('enabled', 1)) {
         $print = true;
     }
     if ($print) {
         $row->text = preg_replace($regex, '<br />', $row->text);
         return true;
     }
     // Simple performance check to determine whether bot should process further.
     if (JString::strpos($row->text, 'class="system-pagebreak') === false) {
         return true;
     }
     $db = App::get('db');
     $view = Request::getString('view');
     $full = Request::getBool('fullview');
     if (!$page) {
         $page = 0;
     }
     if ($params->get('intro_only') || $params->get('popup') || $full || $view != 'article') {
         $row->text = preg_replace($regex, '', $row->text);
         return;
     }
     // Find all instances of plugin and put in $matches.
     $matches = array();
     preg_match_all($regex, $row->text, $matches, PREG_SET_ORDER);
     if ($showall && $this->params->get('showall', 1)) {
         $hasToc = $this->params->get('multipage_toc', 1);
         if ($hasToc) {
             // Display TOC.
             $page = 1;
             $this->_createToc($row, $matches, $page);
         } else {
             $row->toc = '';
         }
         $row->text = preg_replace($regex, '<br />', $row->text);
         return true;
     }
     // Split the text around the plugin.
     $text = preg_split($regex, $row->text);
     // Count the number of pages.
     $n = count($text);
     // We have found at least one plugin, therefore at least 2 pages.
     if ($n > 1) {
         $title = $this->params->get('title', 1);
         $hasToc = $this->params->get('multipage_toc', 1);
         // Adds heading or title to <site> Title.
         if ($title) {
             if ($page) {
                 $page_text = $page + 1;
                 if ($page && @$matches[$page - 1][2]) {
                     $attrs = JUtility::parseAttributes($matches[$page - 1][1]);
                     if (@$attrs['title']) {
                         $row->page_title = $attrs['title'];
                     }
                 }
             }
         }
         // Reset the text, we already hold it in the $text array.
         $row->text = '';
         if ($style == 'pages') {
             // Display TOC.
             if ($hasToc) {
                 $this->_createToc($row, $matches, $page);
             } else {
                 $row->toc = '';
             }
             // traditional mos page navigation
             $pageNav = new \Hubzero\Pagination\Paginator($n, $page, 1);
             // Page counter.
             $row->text .= '<div class="pagenavcounter">';
             $row->text .= $pageNav->getPagesCounter();
             $row->text .= '</div>';
             // Page text.
             $text[$page] = str_replace('<hr id="system-readmore" />', '', $text[$page]);
             $row->text .= $text[$page];
             // $row->text .= '<br />';
             $row->text .= '<div class="pagination">';
             // Adds navigation between pages to bottom of text.
             if ($hasToc) {
                 $this->_createNavigation($row, $page, $n);
             }
             // Page links shown at bottom of page if TOC disabled.
             if (!$hasToc) {
                 $row->text .= $pageNav->getPagesLinks();
             }
             $row->text .= '</div>';
         } else {
             $t[] = $text[0];
             $t[] = (string) Html::$style('start');
             foreach ($text as $key => $subtext) {
                 if ($key >= 1) {
                     $match = $matches[$key - 1];
                     $match = (array) JUtility::parseAttributes($match[0]);
                     if (isset($match['alt'])) {
                         $title = stripslashes($match["alt"]);
                     } elseif (isset($match['title'])) {
                         $title = stripslashes($match['title']);
                     } else {
                         $title = Lang::txt('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $key + 1);
                     }
                     $t[] = (string) Html::$style('panel', $title, 'basic-details');
                 }
                 $t[] = (string) $subtext;
             }
             $t[] = (string) Html::$style('end');
             $row->text = implode(' ', $t);
         }
     }
     return true;
 }
 public function parseRule(&$router, &$uri)
 {
     $array = array();
     $lang_code = Request::getString(App::hash('language'), null, 'cookie');
     // No cookie - let's try to detect browser language or use site default
     if (!$lang_code) {
         if ($this->params->get('detect_browser', 1)) {
             $lang_code = JLanguageHelper::detectLanguage();
         } else {
             $lang_code = self::$default_lang;
         }
     }
     if (self::$mode_sef) {
         $path = $uri->getPath();
         $parts = explode('/', $path);
         $sef = $parts[0];
         // Redirect only if not in post
         $post = Request::get('POST');
         if (!empty($lang_code) && (Request::method() != "POST" || count($post) == 0)) {
             if ($this->params->get('remove_default_prefix', 0) == 0) {
                 // redirect if sef does not exists
                 if (!isset(self::$sefs[$sef])) {
                     // Use the current language sef or the default one
                     $sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef;
                     $uri->setPath($sef . '/' . $path);
                     if (Config::get('sef_rewrite')) {
                         App::redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment')));
                     } else {
                         $path = $uri->toString(array('path', 'query', 'fragment'));
                         App::redirect($uri->base() . 'index.php' . ($path ? '/' . $path : ''));
                     }
                 }
             } else {
                 // redirect if sef does not exists and language is not the default one
                 if (!isset(self::$sefs[$sef]) && $lang_code != self::$default_lang) {
                     $sef = isset(self::$lang_codes[$lang_code]) && empty($path) ? self::$lang_codes[$lang_code]->sef : self::$default_sef;
                     $uri->setPath($sef . '/' . $path);
                     if (Config::get('sef_rewrite')) {
                         App::redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment')));
                     } else {
                         $path = $uri->toString(array('path', 'query', 'fragment'));
                         App::redirect($uri->base() . 'index.php' . ($path ? '/' . $path : ''));
                     }
                 } elseif (isset(self::$sefs[$sef]) && self::$default_lang == self::$sefs[$sef]->lang_code && (!$this->params->get('detect_browser', 1) || JLanguageHelper::detectLanguage() == self::$tag || self::$cookie)) {
                     array_shift($parts);
                     $uri->setPath(implode('/', $parts));
                     if (Config::get('sef_rewrite')) {
                         App::redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment')));
                     } else {
                         $path = $uri->toString(array('path', 'query', 'fragment'));
                         App::redirect($uri->base() . 'index.php' . ($path ? '/' . $path : ''));
                     }
                 }
             }
         }
         $lang_code = isset(self::$sefs[$sef]) ? self::$sefs[$sef]->lang_code : '';
         if ($lang_code && Lang::exists($lang_code)) {
             array_shift($parts);
             $uri->setPath(implode('/', $parts));
         }
     } else {
         $sef = $uri->getVar('lang');
         if (!isset(self::$sefs[$sef])) {
             $sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef;
             $uri->setVar('lang', $sef);
             $post = Request::get('POST');
             if (Request::method() != "POST" || count($post) == 0) {
                 App::redirect(Request::base(true) . '/index.php?' . $uri->getQuery());
             }
         }
     }
     $array = array('lang' => $sef);
     return $array;
 }
Example #25
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * return	void
  * @since	1.6
  */
 protected function populateState($ordering = null, $direction = null)
 {
     // Initiliase variables.
     $app = JFactory::getApplication('site');
     $pk = Request::getInt('id');
     $this->setState('category.id', $pk);
     // Load the parameters. Merge Global and Menu Item params into new object
     $params = $app->getParams();
     $menuParams = new \Hubzero\Config\Registry();
     if ($menu = \App::get('menu')->getActive()) {
         $menuParams->parse($menu->params);
     }
     $mergedParams = clone $menuParams;
     $mergedParams->merge($params);
     $this->setState('params', $mergedParams);
     $user = User::getInstance();
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $groups = implode(',', $user->getAuthorisedViewLevels());
     if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) {
         // limit to published for people who can't edit or edit.state.
         $this->setState('filter.published', 1);
         // Filter by start and end dates.
         $nullDate = $db->Quote($db->getNullDate());
         $nowDate = $db->Quote(Date::toSQL());
         $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')');
         $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
     } else {
         $this->setState('filter.published', array(0, 1, 2));
     }
     // process show_noauth parameter
     if (!$params->get('show_noauth')) {
         $this->setState('filter.access', true);
     } else {
         $this->setState('filter.access', false);
     }
     // Optional filter text
     $this->setState('list.filter', Request::getString('filter-search'));
     // filter.order
     $itemid = Request::getInt('id', 0) . ':' . Request::getInt('Itemid', 0);
     $orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
     if (!in_array($orderCol, $this->filter_fields)) {
         $orderCol = 'a.ordering';
     }
     $this->setState('list.ordering', $orderCol);
     $listOrder = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
     if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) {
         $listOrder = 'ASC';
     }
     $this->setState('list.direction', $listOrder);
     $this->setState('list.start', Request::getUInt('limitstart', 0));
     // set limit for query. If list, use parameter. If blog, add blog parameters for limit.
     if (Request::getCmd('layout') == 'blog' || $params->get('layout_type') == 'blog') {
         $limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links');
         $this->setState('list.links', $params->get('num_links'));
     } else {
         $limit = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.limit', 'limit', $params->get('display_num'), 'uint');
     }
     $this->setState('list.limit', $limit);
     // set the depth of the category query based on parameter
     $showSubcategories = $params->get('show_subcategory_content', '0');
     if ($showSubcategories) {
         $this->setState('filter.max_category_levels', $params->get('show_subcategory_content', '1'));
         $this->setState('filter.subcategories', true);
     }
     $this->setState('filter.language', App::get('language.filter'));
     $this->setState('layout', Request::getCmd('layout'));
 }
Example #26
0
function pathway($dd)
{
    $db_id = $dd['db_id'];
    Document::setTitle($dd['title']);
    if (isset($db_id['extra']) && $db_id['extra'] == 'table') {
        $ref_title = "Datastore";
        Pathway::append($ref_title, '/datastores/' . $db_id['name'] . '#tables');
    } elseif (isset($_SERVER['HTTP_REFERER'])) {
        $ref_title = Request::getString('ref_title', $dd['title'] . " Resource");
        $ref_title = htmlentities($ref_title);
        Pathway::append($ref_title, $_SERVER['HTTP_REFERER']);
    }
    Pathway::append($dd['title'], $_SERVER['REQUEST_URI']);
}
Example #27
0
 /**
  * Method to get a list of articles.
  *
  * Overriden to inject convert the attribs field into a JParameter object.
  *
  * @return	mixed	An array of objects on success, false on failure.
  * @since	1.6
  */
 public function getItems()
 {
     $items = parent::getItems();
     $userId = User::get('id');
     $guest = User::get('guest');
     $groups = User::getAuthorisedViewLevels();
     // Get the global params
     $globalParams = Component::params('com_content', true);
     // Convert the parameter fields into objects.
     foreach ($items as &$item) {
         $articleParams = new \Hubzero\Config\Registry($item->attribs);
         // Unpack readmore and layout params
         $item->alternative_readmore = $articleParams->get('alternative_readmore');
         $item->layout = $articleParams->get('layout');
         $item->params = clone $this->getState('params');
         // For blogs, article params override menu item params only if menu param = 'use_article'
         // Otherwise, menu item params control the layout
         // If menu item is 'use_article' and there is no article param, use global
         if (Request::getString('layout') == 'blog' || Request::getString('view') == 'featured' || $this->getState('params')->get('layout_type') == 'blog') {
             // create an array of just the params set to 'use_article'
             $menuParamsArray = $this->getState('params')->toArray();
             $articleArray = array();
             foreach ($menuParamsArray as $key => $value) {
                 if ($value === 'use_article') {
                     // if the article has a value, use it
                     if ($articleParams->get($key) != '') {
                         // get the value from the article
                         $articleArray[$key] = $articleParams->get($key);
                     } else {
                         // otherwise, use the global value
                         $articleArray[$key] = $globalParams->get($key);
                     }
                 }
             }
             // merge the selected article params
             if (count($articleArray) > 0) {
                 $articleParams = new \Hubzero\Config\Registry($articleArray);
                 $item->params->merge($articleParams);
             }
         } else {
             // For non-blog layouts, merge all of the article params
             $item->params->merge($articleParams);
         }
         // get display date
         switch ($item->params->get('list_show_date')) {
             case 'modified':
                 $item->displayDate = $item->modified;
                 break;
             case 'published':
                 $item->displayDate = $item->publish_up == 0 ? $item->created : $item->publish_up;
                 break;
             default:
             case 'created':
                 $item->displayDate = $item->created;
                 break;
         }
         // Compute the asset access permissions.
         // Technically guest could edit an article, but lets not check that to improve performance a little.
         if (!$guest) {
             $asset = 'com_content.article.' . $item->id;
             // Check general edit permission first.
             if (User::authorise('core.edit', $asset)) {
                 $item->params->set('access-edit', true);
             } elseif (!empty($userId) && User::authorise('core.edit.own', $asset)) {
                 // Check for a valid user and that they are the owner.
                 if ($userId == $item->created_by) {
                     $item->params->set('access-edit', true);
                 }
             }
         }
         $access = $this->getState('filter.access');
         if ($access) {
             // If the access filter has been set, we already have only the articles this user can view.
             $item->params->set('access-view', true);
         } else {
             // If no access filter is set, the layout takes some responsibility for display of limited information.
             if ($item->catid == 0 || $item->category_access === null) {
                 $item->params->set('access-view', in_array($item->access, $groups));
             } else {
                 $item->params->set('access-view', in_array($item->access, $groups) && in_array($item->category_access, $groups));
             }
         }
     }
     return $items;
 }
Example #28
0
function dv_dataview_list()
{
    global $com_name, $conf;
    $base = $conf['dir_base'];
    $document = App::get('document');
    $document->addScript(DB_PATH . DS . 'html' . DS . 'ace/ace.js');
    $db_id = Request::getString('db', false);
    $db_conf_file = $base . DS . $db_id . DS . 'database.json';
    $db_conf = json_decode(file_get_contents($db_conf_file), true);
    $jdb = JDatabase::getInstance($db_conf['database_ro']);
    Toolbar::title($db_conf['name'] . ' >> <small> The list of Dataviews</small>', 'databases');
    if (!$jdb->getErrorMsg()) {
        Toolbar::custom('new', 'new', 'new', 'New Dataview', false);
    }
    Toolbar::custom('back', 'back', 'back', 'Go back', false);
    $path = "{$base}/{$db_id}/applications/{$com_name}/datadefinitions/";
    // Check directories
    if (!file_exists($path)) {
        $cmd = "mkdir -p {$path}; cd {$path}; git init > /dev/null";
        system($cmd);
        system("chmod ug+Xrw -R {$path}");
    }
    $path_php = "{$base}/{$db_id}/applications/{$com_name}/datadefinitions-php/";
    if (!file_exists($path_php)) {
        $cmd = "mkdir -p {$path_php}; cd {$path_php}; git init > /dev/null";
        system($cmd);
        system("chmod ug+Xrw -R {$path_php}");
    }
    $files = array();
    if (is_dir($path_php)) {
        $files = scandir($path_php);
    }
    $back_link = "/administrator/index.php?option=com_databases";
    db_show_msg();
    ?>

	<script>
		var com_name = '<?php 
    echo $com_name;
    ?>
';
		var db_back_link = '<?php 
    echo $back_link;
    ?>
';
	</script>
	<style type="text/css"> .toolbar-box .header:before {content: " ";}</style>

	<table class="adminlist" summary="">
		<thead>
		 	<tr>
		 		<th>#</th>
				<th width="55%">Title</th>
				<th>Remove</th>
				<th>Last Updated</th>
				<th>Data View</th>
				<th>Data Definition</th>
			</tr>
		</thead>


		<tbody>
<?php 
    if (count($files) < 1) {
        print "<h2>No Dataviews available</h2>";
    } else {
        asort($files);
        $c = 0;
        foreach ($files as $file) {
            if (substr($file, -4) === '.php') {
                $dd_name = substr($file, 0, -4);
                $json_file = $path . DS . $dd_name . '.json';
                $php_file = $path_php . DS . $dd_name . '.php';
                // Create JSON data definition if unavailable
                if (!file_exists($json_file)) {
                    $cmd = "cd " . JPATH_COMPONENT . "; php ./ddconvert.php -i{$php_file} -o{$json_file}";
                    system($cmd);
                    $author = User::get('name') . ' <' . User::get('email') . '>';
                    $cmd = "cd {$path}; git add {$dd_name}.json; git commit {$dd_name}.json --author=\"{$author}\" -m\"[ADD] {$dd_name}.json Initial commit.\"  > /dev/null";
                    system($cmd);
                }
                $dd = json_decode(file_get_contents($json_file), true);
                $last_mod = date("Y-m-d H:i:s", filemtime($php_file));
                print '<tr>';
                print '<td >' . ++$c . '</td>';
                print '<td >' . $dd['title'] . ' &nbsp;<small>[' . $dd_name . ']</small></td>';
                print '<td ><a class="db-dd-remove-link" style="color: red;" data-dd="' . $dd_name . '" href="#" />Remove</td>';
                print '<td>' . $last_mod . '</td>';
                print '<td align="center"><a target="_blank" href="/' . $com_name . "/view/{$db_id}:db/" . $dd_name . '/">View</a></td>';
                print '<td><a href="/administrator/index.php?option=com_dataviewer&task=data_definition&db=' . $db_id . '&dd=' . $dd_name . '">' . 'Edit &nbsp; ' . '</a>&nbsp;[<a target="_blank" href="/administrator/index.php?option=com_dataviewer&tmpl=component&task=data_definition&db=' . $db_id . '&dd=' . $dd_name . '">' . 'Full Screen' . '</a>]</td>';
                print '</tr>';
            }
        }
    }
    ?>
		<tbody>
	</table>


<?php 
    if (get_class($jdb) === 'JException' || $jdb->getErrorMsg()) {
        print "<h3>Invalid Database connection information</h3>";
        return;
    } else {
        $sql = 'SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ' . $jdb->quote($db_conf['database_ro']['database']) . ' GROUP BY TABLE_NAME ORDER BY TABLE_NAME';
        $jdb->setQuery($sql);
        $list = $jdb->loadAssocList();
    }
    ?>

	<!-- Remove Table form -->
	<form id="db-dd-remove-frm" method="post" action="/administrator/index.php?option=com_<?php 
    echo $com_name;
    ?>
&task=data_definition_remove" style="display: none;">
			<input name="<?php 
    echo DB_RID;
    ?>
" type="hidden" value="<?php 
    echo DB_RID;
    ?>
" />
			<input name="db" type="hidden" value="<?php 
    echo $db_id;
    ?>
" />
			<input name="dd_name" type="hidden">
	</form>



	<div id="db-dd-new" style="display: none;" title="<?php 
    echo $db_conf['name'];
    ?>
 Database : Add new Dataview">
		<form method="post" action="/administrator/index.php?option=com_<?php 
    echo $com_name;
    ?>
&task=data_definition_new">
			<input name="<?php 
    echo DB_RID;
    ?>
" type="hidden" value="<?php 
    echo DB_RID;
    ?>
" />
			<input name="db" type="hidden" value="<?php 
    echo $db_id;
    ?>
" />
			<label for="table">Select Table:</label>
			<br />
			<select name="table" id="table">
			<?php 
    foreach ($list as $table) {
        print '<option value="' . $table['TABLE_NAME'] . '">' . $table['TABLE_NAME'] . '</option>';
    }
    ?>
			</select>

			<br />
			<label for="name">Name:</label>
			<br />
			<input type="text" id="name" name="name" />

			<br />
			<label for="title">Title:</label>
			<br />
			<input type="text" id="title" name="title" />


			<input type="submit" value="Create" />
		</form>
	</div>
<?php 
}
Example #29
0
 /**
  * Send the message and display a notice
  *
  * @access public
  * @since 1.5
  */
 function send()
 {
     // Check for request forgeries
     Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
     $timeout = Session::get('com_mailto.formtime', 0);
     if ($timeout == 0 || time() - $timeout < 20) {
         throw new Exception(Lang::txt('COM_MAILTO_EMAIL_NOT_SENT'), 500);
         return $this->mailto();
     }
     $SiteName = Config::get('sitename');
     $MailFrom = Config::get('mailfrom');
     $FromName = Config::get('fromname');
     $link = MailtoHelper::validateHash(Request::getCMD('link', '', 'post'));
     // Verify that this is a local link
     if (!$link || !JURI::isInternal($link)) {
         //Non-local url...
         throw new Exception(Lang::txt('COM_MAILTO_EMAIL_NOT_SENT'), 500);
         return $this->mailto();
     }
     // An array of email headers we do not want to allow as input
     $headers = array('Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:');
     // An array of the input fields to scan for injected headers
     $fields = array('mailto', 'sender', 'from', 'subject');
     /*
      * Here is the meat and potatoes of the header injection test.  We
      * iterate over the array of form input and check for header strings.
      * If we find one, send an unauthorized header and die.
      */
     foreach ($fields as $field) {
         foreach ($headers as $header) {
             if (strpos($_POST[$field], $header) !== false) {
                 App::abort(403, '');
             }
         }
     }
     // Free up memory
     unset($headers, $fields);
     $email = Request::getString('mailto', '', 'post');
     $sender = Request::getString('sender', '', 'post');
     $from = Request::getString('from', '', 'post');
     $subject_default = Lang::txt('COM_MAILTO_SENT_BY', $sender);
     $subject = Request::getString('subject', $subject_default, 'post');
     // Check for a valid to address
     $error = false;
     if (!$email || !JMailHelper::isEmailAddress($email)) {
         $error = Lang::txt('COM_MAILTO_EMAIL_INVALID', $email);
         Notify::warning($error);
     }
     // Check for a valid from address
     if (!$from || !JMailHelper::isEmailAddress($from)) {
         $error = Lang::txt('COM_MAILTO_EMAIL_INVALID', $from);
         Notify::warning($error);
     }
     if ($error) {
         return $this->mailto();
     }
     // Build the message to send
     $msg = Lang::txt('COM_MAILTO_EMAIL_MSG');
     $body = sprintf($msg, $SiteName, $sender, $from, $link);
     // Clean the email data
     $subject = JMailHelper::cleanSubject($subject);
     $body = JMailHelper::cleanBody($body);
     $sender = JMailHelper::cleanAddress($sender);
     // Send the email
     if (JFactory::getMailer()->sendMail($from, $sender, $email, $subject, $body) !== true) {
         throw new Exception(Lang::txt('COM_MAILTO_EMAIL_NOT_SENT'), 500);
         return $this->mailto();
     }
     Request::setVar('view', 'sent');
     $this->display();
 }
Example #30
0
 /**
  * Method to log in a user.
  *
  * @since	1.6
  */
 public function login()
 {
     // Populate the data array:
     $data = array();
     $options = array();
     $data['return'] = base64_decode(Request::getVar('return', '', 'POST', 'BASE64'));
     $data['username'] = Request::getVar('username', '', 'method', 'username');
     $data['password'] = Request::getString('passwd', '', 'post', JREQUEST_ALLOWRAW);
     $authenticator = Request::getVar('authenticator', '', 'method');
     // If a specific authenticator is specified try to call the login method for that plugin
     if (!empty($authenticator)) {
         Plugin::import('authentication');
         $plugins = Plugin::byType('authentication');
         foreach ($plugins as $plugin) {
             $className = 'plg' . $plugin->type . $plugin->name;
             if ($plugin->name != $authenticator) {
                 continue;
             }
             if (class_exists($className)) {
                 if (method_exists($className, 'login')) {
                     $myplugin = new $className($this, (array) $plugin);
                     $myplugin->login($credentials, $options);
                     if (isset($options['return'])) {
                         $data['return'] = $options['return'];
                     }
                 }
                 $options['authenticator'] = $authenticator;
                 $options['action'] = 'core.login.site';
                 break;
             }
         }
     }
     // If no authenticator is specified, or the login method for that plugin did not exist then use joomla default
     if (!isset($myplugin)) {
         // Check for request forgeries
         Session::checkToken('request');
         if ($return = Request::getVar('return', '', 'method', 'base64')) {
             $return = base64_decode($return);
             if (!JURI::isInternal($return)) {
                 $return = '';
             }
         }
         if ($freturn = Request::getVar('freturn', '', 'method', 'base64')) {
             $freturn = base64_decode($freturn);
             if (!JURI::isInternal($freturn)) {
                 $freturn = '';
             }
         }
         // Get the log in options.
         $options = array();
         $options['remember'] = Request::getBool('remember', false);
         $options['return'] = $data['return'];
         $options['action'] = 'core.login.site';
         if (!empty($authenticator)) {
             $options['authenticator'] = $authenticator;
         }
         // Get the log in credentials.
         $credentials = array();
         $credentials['username'] = $data['username'];
         $credentials['password'] = $data['password'];
     }
     // Set the return URL if empty.
     if (empty($data['return'])) {
         $data['return'] = 'index.php?option=com_members&task=myaccount';
     }
     // Set the return URL in the user state to allow modification by plugins
     User::setState('users.login.form.return', $data['return']);
     try {
         $result = App::get('auth')->login($credentials, $options);
     } catch (Exception $e) {
         $result = $e;
     }
     // Perform the log in.
     if (true === $result) {
         // Success
         User::setState('users.login.form.data', array());
         // If no_html is set, return json response
         if (Request::getInt('no_html', 0)) {
             echo json_encode(array("success" => true, "redirect" => Route::url(User::getState('users.login.form.return'), false)));
             exit;
         } else {
             App::redirect(Route::url(User::getState('users.login.form.return'), false));
         }
     } else {
         // Login failed !
         $data['remember'] = isset($options['remember']) ? (int) $options['remember'] : 0;
         User::setState('users.login.form.data', $data);
         // Facilitate third party login forms
         if (!isset($return) || !$return) {
             $return = Route::url('index.php?option=com_users&view=login');
         }
         if (isset($freturn)) {
             $return = $freturn;
         }
         $error = $result ? $result->getMessage() : 'An unknown error has occurred';
         // If no_html is set, return json response
         if (Request::getInt('no_html', 0)) {
             echo json_encode(array("error" => $error, "freturn" => Route::url($return, false)));
             exit;
         } else {
             // Redirect to a login form
             App::redirect(Route::url($return, false), $error, 'error');
         }
     }
 }