Exemplo n.º 1
0
/**
*/
function botMosImage($published, &$row, &$params, $page = 0)
{
    global $database, $_MAMBOTS;
    // simple performance check to determine whether bot should process further
    if (strpos($row->text, 'mosimage') === false) {
        return true;
    }
    // expression to search for
    $regex = '/{mosimage\\s*.*?}/i';
    // check whether mosimage has been disabled for page
    // check whether mambot has been unpublished
    if (!$published || !$params->get('image')) {
        $row->text = preg_replace($regex, '', $row->text);
        return true;
    }
    //count how many {mosimage} are in introtext if it is set to hidden.
    $introCount = 0;
    if (!$params->get('introtext') & !$params->get('intro_only')) {
        preg_match_all($regex, $row->introtext, $matches);
        $introCount = count($matches[0]);
    }
    // find all instances of mambot and put in $matches
    preg_match_all($regex, $row->text, $matches);
    // Number of mambots
    $count = count($matches[0]);
    // mambot only processes if there are any instances of the mambot in the text
    if ($count) {
        // check if param query has previously been processed
        if (!isset($_MAMBOTS->_content_mambot_params['mosimage'])) {
            // load mambot params info
            $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'mosimage'" . "\n AND folder = 'content'";
            $database->setQuery($query);
            $database->loadObject($mambot);
            // save query to class variable
            $_MAMBOTS->_content_mambot_params['mosimage'] = $mambot;
        }
        // pull query data from class variable
        $mambot = $_MAMBOTS->_content_mambot_params['mosimage'];
        $botParams = new mosParameters($mambot->params);
        $botParams->def('padding');
        $botParams->def('margin');
        $botParams->def('link', 0);
        $images = processImages($row, $botParams, $introCount);
        // store some vars in globals to access from the replacer
        $GLOBALS['botMosImageCount'] = 0;
        $GLOBALS['botMosImageParams'] =& $botParams;
        $GLOBALS['botMosImageArray'] =& $images;
        //$GLOBALS['botMosImageArray'] 	=& $combine;
        // perform the replacement
        $row->text = preg_replace_callback($regex, 'botMosImage_replacer', $row->text);
        // clean up globals
        unset($GLOBALS['botMosImageCount']);
        unset($GLOBALS['botMosImageMask']);
        unset($GLOBALS['botMosImageArray']);
        unset($GLOBALS['botJosIntroCount']);
        return true;
    }
}
Exemplo n.º 2
0
/**
* Contacts Search method
*
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
*/
function botSearchNewsfeedslinks($text, $phrase = '', $ordering = '')
{
    global $database, $my, $_MAMBOTS;
    // check if param query has previously been processed
    if (!isset($_MAMBOTS->_search_mambot_params['newsfeeds'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'newsfeeds.searchbot'" . "\n AND folder = 'search'";
        $database->setQuery($query);
        $database->loadObject($mambot);
        // save query to class variable
        $_MAMBOTS->_search_mambot_params['newsfeeds'] = $mambot;
    }
    // pull query data from class variable
    $mambot = $_MAMBOTS->_search_mambot_params['newsfeeds'];
    $botParams = new mosParameters($mambot->params);
    $limit = $botParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $wheres = array();
    switch ($phrase) {
        case 'exact':
            $wheres2 = array();
            $wheres2[] = "LOWER(a.name) LIKE '%{$text}%'";
            $wheres2[] = "LOWER(a.link) LIKE '%{$text}%'";
            $where = '(' . implode(') OR (', $wheres2) . ')';
            break;
        case 'all':
        case 'any':
        default:
            $words = explode(' ', $text);
            $wheres = array();
            foreach ($words as $word) {
                $wheres2 = array();
                $wheres2[] = "LOWER(a.name) LIKE '%{$word}%'";
                $wheres2[] = "LOWER(a.link) LIKE '%{$word}%'";
                $wheres[] = implode(' OR ', $wheres2);
            }
            $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
            break;
    }
    switch ($ordering) {
        case 'alpha':
            $order = 'a.name ASC';
            break;
        case 'category':
            $order = 'b.title ASC, a.name ASC';
            break;
        case 'oldest':
        case 'popular':
        case 'newest':
        default:
            $order = 'a.name ASC';
    }
    $query = "SELECT a.name AS title," . "\n '' AS created," . "\n a.link AS text," . "\n CONCAT_WS( ' / '," . $database->Quote(_SEARCH_NEWSFEEDS) . ", b.title )AS section," . "\n CONCAT( 'index.php?option=com_newsfeeds&task=view&feedid=', a.id ) AS href," . "\n '1' AS browsernav" . "\n FROM #__newsfeeds AS a" . "\n INNER JOIN #__categories AS b ON b.id = a.catid" . "\n WHERE ( {$where} )" . "\n AND a.published = 1" . "\n AND b.published = 1" . "\n AND b.access <= " . (int) $my->gid . "\n ORDER BY {$order}";
    $database->setQuery($query, 0, $limit);
    $rows = $database->loadObjectList();
    return $rows;
}
 /**
  * @param database A database connector object
  * @param integer The unique id of the category to edit (0 if new)
  */
 function edit(&$uid, $menutype, $option)
 {
     global $database, $my, $mainframe;
     $menu = new mosMenu($database);
     $menu->load((int) $uid);
     // fail if checked out not by 'me'
     if ($menu->checked_out && $menu->checked_out != $my->id) {
         mosErrorAlert("The module " . $menu->title . " is currently being edited by another administrator");
     }
     if ($uid) {
         $menu->checkout($my->id);
         // get previously selected Categories
         $params = new mosParameters($menu->params);
         $catids = $params->def('categoryid', '');
         if ($catids) {
             $catidsArray = explode(',', $catids);
             mosArrayToInts($catidsArray);
             $catids = 'c.id=' . implode(' OR c.id=', $catidsArray);
             $query = "SELECT c.id AS `value`, c.section AS `id`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" . "\n FROM #__sections AS s" . "\n INNER JOIN #__categories AS c ON c.section = s.id" . "\n WHERE s.scope = 'content'" . "\n AND ( {$catids} )" . "\n ORDER BY s.name,c.name";
             $database->setQuery($query);
             $lookup = $database->loadObjectList();
         } else {
             $lookup = '';
         }
     } else {
         $menu->type = 'content_blog_category';
         $menu->menutype = $menutype;
         $menu->ordering = 9999;
         $menu->parent = intval(mosGetParam($_POST, 'parent', 0));
         $menu->published = 1;
         $lookup = '';
     }
     // build the html select list for category
     $rows[] = mosHTML::makeOption('', 'All Categories');
     $query = "SELECT c.id AS `value`, c.section AS `id`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" . "\n FROM #__sections AS s" . "\n INNER JOIN #__categories AS c ON c.section = s.id" . "\n WHERE s.scope = 'content'" . "\n ORDER BY s.name,c.name";
     $database->setQuery($query);
     $rows = array_merge($rows, $database->loadObjectList());
     $category = mosHTML::selectList($rows, 'catid[]', 'class="inputbox" size="10" multiple="multiple"', 'value', 'text', $lookup);
     $lists['categoryid'] = $category;
     // build the html select list for ordering
     $lists['ordering'] = mosAdminMenus::Ordering($menu, $uid);
     // build the html select list for the group access
     $lists['access'] = mosAdminMenus::Access($menu);
     // build the html select list for paraent item
     $lists['parent'] = mosAdminMenus::Parent($menu);
     // build published button option
     $lists['published'] = mosAdminMenus::Published($menu);
     // build the url link output
     $lists['link'] = mosAdminMenus::Link($menu, $uid);
     // get params definitions
     $params = new mosParameters($menu->params, $mainframe->getPath('menu_xml', $menu->type), 'menu');
     /* chipjack: passing $sectCatList (categories) instead of $slist (sections) */
     content_blog_category_html::edit($menu, $lists, $params, $option);
 }
 /**
  * @param database A database connector object
  * @param integer The unique id of the section to edit (0 if new)
  */
 function edit($uid, $menutype, $option)
 {
     global $database, $my, $mainframe;
     $menu = new mosMenu($database);
     $menu->load((int) $uid);
     // fail if checked out not by 'me'
     if ($menu->checked_out && $menu->checked_out != $my->id) {
         mosErrorAlert("O módulo " . $menu->title . " está sendo editado atualmente por outro administrador");
     }
     if ($uid) {
         $menu->checkout($my->id);
         // get previously selected Categories
         $params = new mosParameters($menu->params);
         $secids = $params->def('sectionid', '');
         if ($secids) {
             $secidsArray = explode(',', $secids);
             mosArrayToInts($secidsArray);
             $secids = 's.id=' . implode(' OR s.id=', $secidsArray);
             $query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`" . "\n FROM #__sections AS s" . "\n WHERE s.scope = 'content'" . "\n AND ( {$secids} )" . "\n ORDER BY s.name";
             $database->setQuery($query);
             $lookup = $database->loadObjectList();
         } else {
             $lookup = '';
         }
     } else {
         $menu->type = 'content_blog_section';
         $menu->menutype = $menutype;
         $menu->ordering = 9999;
         $menu->parent = intval(mosGetParam($_POST, 'parent', 0));
         $menu->published = 1;
         $lookup = '';
     }
     // build the html select list for section
     $rows[] = mosHTML::makeOption('', 'Todas as Seções');
     $query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`" . "\n FROM #__sections AS s" . "\n WHERE s.scope = 'content'" . "\n ORDER BY s.name";
     $database->setQuery($query);
     $rows = array_merge($rows, $database->loadObjectList());
     $section = mosHTML::selectList($rows, 'secid[]', 'class="inputbox" size="10" multiple="multiple"', 'value', 'text', $lookup);
     $lists['sectionid'] = $section;
     // build the html select list for ordering
     $lists['ordering'] = mosAdminMenus::Ordering($menu, $uid);
     // build the html select list for the group access
     $lists['access'] = mosAdminMenus::Access($menu);
     // build the html select list for paraent item
     $lists['parent'] = mosAdminMenus::Parent($menu);
     // build published button option
     $lists['published'] = mosAdminMenus::Published($menu);
     // build the url link output
     $lists['link'] = mosAdminMenus::Link($menu, $uid);
     // get params definitions
     $params = new mosParameters($menu->params, $mainframe->getPath('menu_xml', $menu->type), 'menu');
     content_blog_section_html::edit($menu, $lists, $params, $option);
 }
/**
* Sections Search method
*
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
*/
function botSearchSections($text, $phrase = '', $ordering = '')
{
    global $database, $my, $_MAMBOTS;
    // check if param query has previously been processed
    if (!isset($_MAMBOTS->_search_mambot_params['sections'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'sections.searchbot'" . "\n AND folder = 'search'";
        $database->setQuery($query);
        $database->loadObject($mambot);
        // save query to class variable
        $_MAMBOTS->_search_mambot_params['sections'] = $mambot;
    }
    // pull query data from class variable
    $mambot = $_MAMBOTS->_search_mambot_params['sections'];
    $botParams = new mosParameters($mambot->params);
    $limit = $botParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    switch ($ordering) {
        case 'alpha':
            $order = 'a.name ASC';
            break;
        case 'category':
        case 'popular':
        case 'newest':
        case 'oldest':
        default:
            $order = 'a.name DESC';
    }
    $query = "SELECT a.name AS title," . "\n a.description AS text," . "\n '' AS created," . "\n '2' AS browsernav," . "\n a.id AS secid, m.id AS menuid, m.type AS menutype" . "\n FROM #__sections AS a" . "\n LEFT JOIN #__menu AS m ON m.componentid = a.id" . "\n WHERE ( a.name LIKE '%{$text}%'" . "\n OR a.title LIKE '%{$text}%'" . "\n OR a.description LIKE '%{$text}%' )" . "\n AND a.published = 1" . "\n AND a.access <= " . (int) $my->gid . "\n AND ( m.type = 'content_section' OR m.type = 'content_blog_section' )" . "\n GROUP BY a.id" . "\n ORDER BY {$order}";
    $database->setQuery($query, 0, $limit);
    $rows = $database->loadObjectList();
    $count = count($rows);
    for ($i = 0; $i < $count; $i++) {
        if ($rows[$i]->menutype == 'content_section') {
            $rows[$i]->href = 'index.php?option=com_content&task=section&id=' . $rows[$i]->secid . '&Itemid=' . $rows[$i]->menuid;
            $rows[$i]->section = _SEARCH_SECLIST;
        }
        if ($rows[$i]->menutype == 'content_blog_section') {
            $rows[$i]->href = 'index.php?option=com_content&task=blogsection&id=' . $rows[$i]->secid . '&Itemid=' . $rows[$i]->menuid;
            $rows[$i]->section = _SEARCH_SECBLOG;
        }
    }
    return $rows;
}
/**
* Contacts Search method
*
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
*/
function botSearchContacts($text, $phrase = '', $ordering = '')
{
    global $database, $my, $_MAMBOTS;
    // check if param query has previously been processed
    if (!isset($_MAMBOTS->_search_mambot_params['contacts'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'contacts.searchbot'" . "\n AND folder = 'search'";
        $database->setQuery($query);
        $database->loadObject($mambot);
        // save query to class variable
        $_MAMBOTS->_search_mambot_params['contacts'] = $mambot;
    }
    // pull query data from class variable
    $mambot = $_MAMBOTS->_search_mambot_params['contacts'];
    $botParams = new mosParameters($mambot->params);
    $limit = $botParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $section = _CONTACT_TITLE;
    switch ($ordering) {
        case 'alpha':
            $order = 'a.name ASC';
            break;
        case 'category':
            $order = 'b.title ASC, a.name ASC';
            break;
        case 'popular':
        case 'newest':
        case 'oldest':
        default:
            $order = 'a.name DESC';
            break;
    }
    $query = "SELECT a.name AS title," . "\n CONCAT_WS( ', ', a.name, a.con_position, a.misc ) AS text," . "\n '' AS created," . "\n CONCAT_WS( ' / ', " . $database->Quote($section) . ", b.title ) AS section," . "\n '2' AS browsernav," . "\n CONCAT( 'index.php?option=com_contact&task=view&contact_id=', a.id ) AS href" . "\n FROM #__contact_details AS a" . "\n INNER JOIN #__categories AS b ON b.id = a.catid" . "\n WHERE ( a.name LIKE '%{$text}%'" . "\n OR a.misc LIKE '%{$text}%'" . "\n OR a.con_position LIKE '%{$text}%'" . "\n OR a.address LIKE '%{$text}%'" . "\n OR a.suburb LIKE '%{$text}%'" . "\n OR a.state LIKE '%{$text}%'" . "\n OR a.country LIKE '%{$text}%'" . "\n OR a.postcode LIKE '%{$text}%'" . "\n OR a.telephone LIKE '%{$text}%'" . "\n OR a.fax LIKE '%{$text}%' )" . "\n AND a.published = 1" . "\n AND b.published = 1" . "\n AND a.access <= " . (int) $my->gid . "\n AND b.access <= " . (int) $my->gid . "\n GROUP BY a.id" . "\n ORDER BY {$order}";
    $database->setQuery($query, 0, $limit);
    $rows = $database->loadObjectList();
    return $rows;
}
Exemplo n.º 7
0
/**
* Mambot that loads module positions within content
*/
function botMosLoadPosition($published, &$row, &$params, $page = 0)
{
    global $database, $_MAMBOTS;
    // simple performance check to determine whether bot should process further
    if (strpos($row->text, 'mosloadposition') === false) {
        return true;
    }
    // expression to search for
    $regex = '/{mosloadposition\\s*.*?}/i';
    // check whether mambot has been unpublished
    if (!$published) {
        $row->text = preg_replace($regex, '', $row->text);
        return true;
    }
    // find all instances of mambot and put in $matches
    preg_match_all($regex, $row->text, $matches);
    // Number of mambots
    $count = count($matches[0]);
    // mambot only processes if there are any instances of the mambot in the text
    if ($count) {
        // check if param query has previously been processed
        if (!isset($_MAMBOTS->_content_mambot_params['mosloadposition'])) {
            // load mambot params info
            $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'mosloadposition'" . "\n AND folder = 'content'";
            $database->setQuery($query);
            $database->loadObject($mambot);
            // save query to class variable
            $_MAMBOTS->_content_mambot_params['mosloadposition'] = $mambot;
        }
        // pull query data from class variable
        $mambot = $_MAMBOTS->_content_mambot_params['mosloadposition'];
        $botParams = new mosParameters($mambot->params);
        $style = $botParams->def('style', -2);
        processPositions($row, $matches, $count, $regex, $style);
    }
}
function botExtendedMenuSourceWeblinks_onLoadMenu(&$menuLoader, $name = '')
{
    global $database;
    $botName = 'bot_exmenu_source_weblinks';
    // load parameters
    $database->setQuery('SELECT m.params FROM #__mambots AS m WHERE element = \'' . $botName . '\' AND folder = \'exmenu\'');
    $params = new mosParameters($database->loadResult());
    $params->def('source_name', 'weblinks');
    if ($name != $params->get('source_name')) {
        return FALSE;
    }
    $rootMenuNode =& $menuLoader->getRootMenuNode();
    $database->setQuery('SELECT * FROM #__weblinks WHERE published = 1 ORDER BY hits DESC, title LIMIT 10');
    $rows = $database->loadObjectList();
    foreach (array_keys($rows) as $key) {
        $row =& $rows[$key];
        $menuNode =& $menuLoader->getEmptyMenuNode();
        $menuNode->type = 'url';
        $menuNode->link = $row->url;
        $menuNode->name = $row->title;
        $menuLoader->addMenuNode($rootMenuNode, $menuNode);
    }
    return TRUE;
}
Exemplo n.º 9
0
 function edit(&$uid, $menutype, $option)
 {
     global $database, $my, $mainframe;
     $menu = new mosMenu($database);
     $menu->load((int) $uid);
     // fail if checked out not by 'me'
     if ($menu->checked_out && $menu->checked_out != $my->id) {
         mosErrorAlert("O módulo " . $menu->title . " está sendo editado atualmente por outro administrador");
     }
     if ($uid) {
         $menu->checkout($my->id);
     } else {
         $menu->type = 'wrapper';
         $menu->menutype = $menutype;
         $menu->ordering = 9999;
         $menu->parent = intval(mosGetParam($_POST, 'parent', 0));
         $menu->published = 1;
         $menu->link = 'index.php?option=com_wrapper';
     }
     // build the html select list for ordering
     $lists['ordering'] = mosAdminMenus::Ordering($menu, $uid);
     // build the html select list for the group access
     $lists['access'] = mosAdminMenus::Access($menu);
     // build the html select list for paraent item
     $lists['parent'] = mosAdminMenus::Parent($menu);
     // build published button option
     $lists['published'] = mosAdminMenus::Published($menu);
     // build the url link output
     $lists['link'] = mosAdminMenus::Link($menu, $uid);
     // get params definitions
     $params = new mosParameters($menu->params, $mainframe->getPath('menu_xml', $menu->type), 'menu');
     if ($uid) {
         $menu->url = $params->def('url', '');
     }
     wrapper_menu_html::edit($menu, $lists, $params, $option);
 }
Exemplo n.º 10
0
 $_SESSION['session_username'] = $my->username;
 $_SESSION['session_usertype'] = $my->usertype;
 $_SESSION['session_gid'] = $my->gid;
 $_SESSION['session_logintime'] = $logintime;
 $_SESSION['session_user_params'] = $my->params;
 $_SESSION['session_userstate'] = array();
 session_write_close();
 $expired = 'index2.php';
 // check if site designated as a production site
 // for a demo site disallow expired page functionality
 if ($_VERSION->SITE == 1 && @$mosConfig_admin_expired === '1') {
     $file = $mainframe->getPath('com_xml', 'com_users');
     $params = new mosParameters($my->params, $file, 'component');
     $now = time();
     // expired page functionality handling
     $expired = $params->def('expired', '');
     $expired_time = $params->def('expired_time', '');
     // if now expired link set or expired time is more than half the admin session life set, simply load normal admin homepage
     $checktime = ($mosConfig_session_life_admin ? $mosConfig_session_life_admin : 1800) / 2;
     if (!$expired || $now - $expired_time > $checktime) {
         $expired = 'index2.php';
     }
     // link must also be a Joomla link to stop malicious redirection
     if (strpos($expired, 'index2.php?option=com_') !== 0) {
         $expired = 'index2.php';
     }
     // clear any existing expired page data
     $params->set('expired', '');
     $params->set('expired_time', '');
     // param handling
     if (is_array($params->toArray())) {
Exemplo n.º 11
0
/**
* Page break mambot
*
* <b>Usage:</b>
* <code>{mospagebreak}</code>
* <code>{mospagebreak title=The page title}</code>
* or
* <code>{mospagebreak heading=The first page}</code>
* or
* <code>{mospagebreak title=The page title&heading=The first page}</code>
* or
* <code>{mospagebreak heading=The first page&title=The page title}</code>
*
*/
function botMosPaging($published, &$row, &$params, $page = 0)
{
    global $mainframe, $Itemid, $database, $_MAMBOTS;
    // simple performance check to determine whether bot should process further
    if (strpos($row->text, 'mospagebreak') === false) {
        return true;
    }
    // expression to search for
    $regex = '/{(mospagebreak)\\s*(.*?)}/i';
    // check whether mambot has been unpublished
    if (!$published || $params->get('intro_only') || $params->get('popup')) {
        $row->text = preg_replace($regex, '', $row->text);
        return;
    }
    // find all instances of mambot and put in $matches
    $matches = array();
    preg_match_all($regex, $row->text, $matches, PREG_SET_ORDER);
    // split the text around the mambot
    $text = preg_split($regex, $row->text);
    // count the number of pages
    $n = count($text);
    // we have found at least one mambot, therefore at least 2 pages
    if ($n > 1) {
        // check if param query has previously been processed
        if (!isset($_MAMBOTS->_content_mambot_params['mospaging'])) {
            // load mambot params info
            $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'mospaging'" . "\n AND folder = 'content'";
            $database->setQuery($query);
            $database->loadObject($mambot);
            // save query to class variable
            $_MAMBOTS->_content_mambot_params['mospaging'] = $mambot;
        }
        // pull query data from class variable
        $mambot = $_MAMBOTS->_content_mambot_params['mospaging'];
        $botParams = new mosParameters($mambot->params);
        $title = $botParams->def('title', 1);
        // adds heading or title to <site> Title
        if ($title) {
            $page_text = $page + 1;
            $row->page_title = _PN_PAGE . ' ' . $page_text;
            if (!$page) {
                // processing for first page
                parse_str(html_entity_decode($matches[0][2]), $args);
                if (@$args['heading']) {
                    //$row->page_title = $args['heading'];
                    $row->page_title = '';
                } else {
                    $row->page_title = '';
                }
            } else {
                if ($matches[$page - 1][2]) {
                    parse_str(html_entity_decode($matches[$page - 1][2]), $args);
                    if (@$args['title']) {
                        $row->page_title = ': ' . stripslashes($args['title']);
                    }
                }
            }
        }
        // reset the text, we already hold it in the $text array
        $row->text = '';
        $hasToc = $mainframe->getCfg('multipage_toc');
        if ($hasToc) {
            // display TOC
            createTOC($row, $matches, $page);
        } else {
            $row->toc = '';
        }
        // traditional mos page navigation
        require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php';
        $pageNav = new mosPageNav($n, $page, 1);
        // page counter
        $row->text .= '<div class="pagenavcounter">';
        $row->text .= $pageNav->writeLeafsCounter();
        $row->text .= '</div>';
        // page text
        $row->text .= $text[$page];
        $row->text .= '<br />';
        $row->text .= '<div class="pagenavbar">';
        // adds navigation between pages to bottom of text
        if ($hasToc) {
            createNavigation($row, $page, $n);
        }
        // page links shown at bottom of page if TOC disabled
        if (!$hasToc) {
            $row->text .= $pageNav->writePagesLinks('index.php?option=com_content&amp;task=view&amp;id=' . $row->id . '&amp;Itemid=' . $Itemid);
        }
        $row->text .= '</div><br />';
    }
    return true;
}
Exemplo n.º 12
0
function dofreePDF()
{
    global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_offset;
    global $mainframe, $database, $my;
    $id = intval(mosGetParam($_REQUEST, 'id', 1));
    $gid = $my->gid;
    $now = _CURRENT_SERVER_TIME;
    $nullDate = $database->getNullDate();
    // query to check for state and access levels
    $query = "SELECT a.*, cc.name AS category, s.name AS section, s.published AS sec_pub, cc.published AS cat_pub," . "\n  s.access AS sec_access, cc.access AS cat_access, s.id AS sec_id, cc.id as cat_id" . "\n FROM #__content AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = 'content'" . "\n WHERE a.id = " . (int) $id . "\n AND a.state = 1" . "\n AND a.access <= " . (int) $gid . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )";
    $database->setQuery($query);
    $row = NULL;
    if ($database->loadObject($row)) {
        /*
         * check whether category is published
         */
        if (!$row->cat_pub && $row->catid) {
            mosNotAuth();
            return;
        }
        /*
         * check whether section is published
         */
        if (!$row->sec_pub && $row->sectionid) {
            mosNotAuth();
            return;
        }
        /*
         * check whether category access level allows access
         */
        if ($row->cat_access > $gid && $row->catid) {
            mosNotAuth();
            return;
        }
        /*
         * check whether section access level allows access
         */
        if ($row->sec_access > $gid && $row->sectionid) {
            mosNotAuth();
            return;
        }
        include 'includes/class.ezpdf.php';
        $params = new mosParameters($row->attribs);
        $params->def('author', !$mainframe->getCfg('hideAuthor'));
        $params->def('createdate', !$mainframe->getCfg('hideCreateDate'));
        $params->def('modifydate', !$mainframe->getCfg('hideModifyDate'));
        $row->fulltext = pdfCleaner($row->fulltext);
        $row->introtext = pdfCleaner($row->introtext);
        $pdf = new Cezpdf('a4', 'P');
        //A4 Portrait
        $pdf->ezSetCmMargins(2, 1.5, 1, 1);
        $pdf->selectFont('./fonts/Helvetica.afm');
        //choose font
        $all = $pdf->openObject();
        $pdf->saveState();
        $pdf->setStrokeColor(0, 0, 0, 1);
        // footer
        $pdf->addText(250, 822, 6, $mosConfig_sitename);
        $pdf->line(10, 40, 578, 40);
        $pdf->line(10, 818, 578, 818);
        $pdf->addText(30, 34, 6, $mosConfig_live_site);
        $pdf->addText(250, 34, 6, _PDF_POWERED);
        $pdf->addText(450, 34, 6, _PDF_GENERATED . ' ' . date('j F, Y, H:i', time() + $mosConfig_offset * 60 * 60));
        $pdf->restoreState();
        $pdf->closeObject();
        $pdf->addObject($all, 'all');
        $pdf->ezSetDy(30);
        $txt1 = $row->title;
        $pdf->ezText($txt1, 14);
        $txt2 = AuthorDateLine($row, $params);
        $pdf->ezText($txt2, 8);
        $txt3 = $row->introtext . "\n" . $row->fulltext;
        $pdf->ezText($txt3, 10);
        $pdf->ezStream();
    } else {
        mosNotAuth();
        return;
    }
}
Exemplo n.º 13
0
function contactpage($contact_id)
{
    global $mainframe, $database, $my, $Itemid;
    $query = "SELECT a.id AS value, CONCAT_WS( ' - ', a.name, a.con_position ) AS text, a.catid, cc.access AS cat_access" . "\n FROM #__contact_details AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n WHERE a.published = 1" . "\n AND cc.published = 1" . "\n AND a.access <= " . (int) $my->gid . "\n ORDER BY a.default_con DESC, a.ordering ASC";
    $database->setQuery($query);
    $checks = $database->loadObjectList();
    $count = count($checks);
    if ($count) {
        if ($contact_id < 1) {
            $contact_id = $checks[0]->value;
        }
        $query = "SELECT a.*, cc.access AS cat_access" . "\n FROM #__contact_details AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n WHERE a.published = 1" . "\n AND a.id = " . (int) $contact_id . "\n AND a.access <= " . (int) $my->gid;
        $database->SetQuery($query);
        $contacts = $database->LoadObjectList();
        if (!$contacts) {
            echo _NOT_AUTH;
            return;
        }
        $contact = $contacts[0];
        /*
         * check whether category access level allows access
         */
        if ($contact->cat_access > $my->gid) {
            mosNotAuth();
            return;
        }
        $list = array();
        foreach ($checks as $check) {
            if ($check->catid == $contact->catid) {
                $list[] = $check;
            }
        }
        // creates dropdown select list
        $contact->select = mosHTML::selectList($list, 'contact_id', 'class="inputbox" onchange="ViewCrossReference(this);"', 'value', 'text', $contact_id);
        // Adds parameter handling
        $params = new mosParameters($contact->params);
        $params->set('page_title', 0);
        $params->def('pageclass_sfx', '');
        $params->def('back_button', $mainframe->getCfg('back_button'));
        $params->def('print', !$mainframe->getCfg('hidePrint'));
        $params->def('name', 1);
        $params->def('email', 0);
        $params->def('street_address', 1);
        $params->def('suburb', 1);
        $params->def('state', 1);
        $params->def('country', 1);
        $params->def('postcode', 1);
        $params->def('telephone', 1);
        $params->def('fax', 1);
        $params->def('misc', 1);
        $params->def('image', 1);
        $params->def('email_description', 1);
        $params->def('email_description_text', _EMAIL_DESCRIPTION);
        $params->def('email_form', 1);
        $params->def('email_copy', 0);
        // global pront|pdf|email
        $params->def('icons', $mainframe->getCfg('icons'));
        // contact only icons
        $params->def('contact_icons', 0);
        $params->def('icon_address', '');
        $params->def('icon_email', '');
        $params->def('icon_telephone', '');
        $params->def('icon_fax', '');
        $params->def('icon_misc', '');
        $params->def('drop_down', 0);
        $params->def('vcard', 0);
        if ($contact->email_to && $params->get('email')) {
            // email cloacking
            $contact->email = mosHTML::emailCloaking($contact->email_to);
        }
        // loads current template for the pop-up window
        $pop = intval(mosGetParam($_REQUEST, 'pop', 0));
        if ($pop) {
            $params->set('popup', 1);
            $params->set('back_button', 0);
        }
        if ($params->get('email_description')) {
            $params->set('email_description', $params->get('email_description_text'));
        } else {
            $params->set('email_description', '');
        }
        // needed to control the display of the Address marker
        $temp = $params->get('street_address') . $params->get('suburb') . $params->get('state') . $params->get('country') . $params->get('postcode');
        $params->set('address_check', $temp);
        // determines whether to use Text, Images or nothing to highlight the different info groups
        switch ($params->get('contact_icons')) {
            case 1:
                // text
                $params->set('marker_address', _CONTACT_ADDRESS);
                $params->set('marker_email', _CONTACT_EMAIL);
                $params->set('marker_telephone', _CONTACT_TELEPHONE);
                $params->set('marker_fax', _CONTACT_FAX);
                $params->set('marker_misc', _CONTACT_MISC);
                $params->set('column_width', '100');
                break;
            case 2:
                // none
                $params->set('marker_address', '');
                $params->set('marker_email', '');
                $params->set('marker_telephone', '');
                $params->set('marker_fax', '');
                $params->set('marker_misc', '');
                $params->set('column_width', '0');
                break;
            default:
                // icons
                $image1 = mosAdminMenus::ImageCheck('con_address.png', '/images/M_images/', $params->get('icon_address'), '/images/M_images/', _CONTACT_ADDRESS, _CONTACT_ADDRESS);
                $image2 = mosAdminMenus::ImageCheck('emailButton.png', '/images/M_images/', $params->get('icon_email'), '/images/M_images/', _CONTACT_EMAIL, _CONTACT_EMAIL);
                $image3 = mosAdminMenus::ImageCheck('con_tel.png', '/images/M_images/', $params->get('icon_telephone'), '/images/M_images/', _CONTACT_TELEPHONE, _CONTACT_TELEPHONE);
                $image4 = mosAdminMenus::ImageCheck('con_fax.png', '/images/M_images/', $params->get('icon_fax'), '/images/M_images/', _CONTACT_FAX, _CONTACT_FAX);
                $image5 = mosAdminMenus::ImageCheck('con_info.png', '/images/M_images/', $params->get('icon_misc'), '/images/M_images/', _CONTACT_MISC, _CONTACT_MISC);
                $params->set('marker_address', $image1);
                $params->set('marker_email', $image2);
                $params->set('marker_telephone', $image3);
                $params->set('marker_fax', $image4);
                $params->set('marker_misc', $image5);
                $params->set('column_width', '40');
                break;
        }
        // params from menu item
        $menu = $mainframe->get('menu');
        $menu_params = new mosParameters($menu->params);
        $menu_params->def('page_title', 1);
        $menu_params->def('header', $menu->name);
        $menu_params->def('pageclass_sfx', '');
        HTML_contact::viewcontact($contact, $params, $count, $list, $menu_params);
    } else {
        $params = new mosParameters('');
        $params->def('back_button', $mainframe->getCfg('back_button'));
        HTML_contact::nocontact($params);
    }
}
Exemplo n.º 14
0
/**
* TinyMCE WYSIWYG Editor - javascript initialisation
*/
function botTinymceEditorInit()
{
    global $mosConfig_live_site, $database, $mosConfig_absolute_path, $mainframe;
    // load tinymce info
    $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'tinymce'" . "\n AND folder = 'editors'";
    $database->setQuery($query);
    $database->loadObject($mambot);
    $params = new mosParameters($mambot->params);
    $theme = $params->get('theme', 'advanced');
    // handling for former default option
    if ($theme == 'default') {
        $theme = 'advanced';
    }
    $toolbar = $params->def('toolbar', 'top');
    $html_height = $params->def('html_height', '550');
    $html_width = $params->def('html_width', '750');
    $text_direction = $params->def('text_direction', 'ltr');
    $content_css = $params->def('content_css', 1);
    $content_css_custom = $params->def('content_css_custom', '');
    $invalid_elements = $params->def('invalid_elements', 'script,applet,iframe');
    $newlines = $params->def('newlines', 0);
    $cleanup = $params->def('cleanup', 1);
    $cleanup_startup = $params->set('cleanup_startup', 0);
    // Currently disabled due to bugs in TinyMCE
    $compressed = $params->def('compressed', 0);
    $relative_urls = $params->def('relative_urls', 0);
    // Plugins
    // preview
    $preview = $params->def('preview', 1);
    $preview_height = $params->def('preview_height', '550');
    $preview_width = $params->def('preview_width', '750');
    // insert date
    $insertdate = $params->def('insertdate', 1);
    $format_date = $params->def('format_date', '%Y-%m-%d');
    // insert time
    $inserttime = $params->def('inserttime', 1);
    $format_time = $params->def('format_time', '%H:%M:%S');
    // search & replace
    $searchreplace = $params->def('searchreplace', 1);
    // emotions
    $smilies = $params->def('smilies', 1);
    // flash
    $flash = $params->def('flash', 1);
    // table
    $table = $params->def('table', 1);
    // horizontal line
    $hr = $params->def('hr', 1);
    // fullscreen
    $fullscreen = $params->def('fullscreen', 1);
    // autosave
    $autosave = $params->def('autosave', 0);
    // layer
    $layer = $params->def('layer', 1);
    // style
    $style = $params->def('style', 1);
    // visualchars
    $visualchars = $params->def('visualchars', 1);
    // media
    $media = $params->def('media', 1);
    // nonbreaking
    $nonbreaking = $params->def('nonbreaking', 1);
    if ($relative_urls) {
        $relative_urls = 'true';
    } else {
        $relative_urls = 'false';
    }
    if ($content_css_custom) {
        $content_css = 'content_css : "' . $content_css_custom . '", ';
    } else {
        $query = "SELECT template" . "\n FROM #__templates_menu" . "\n WHERE client_id = 0" . "\n AND menuid = 0";
        $database->setQuery($query);
        $template = $database->loadResult();
        $file_path = $mosConfig_absolute_path . '/templates/' . $template . '/css/';
        if ($content_css) {
            $file = 'template.css';
        } else {
            $file = 'editor_content.css';
        }
        $content_css = 'content_css : "' . $mosConfig_live_site . '/templates/' . $template . '/css/';
        if (file_exists($file_path . '/' . $file)) {
            $content_css = $content_css . $file . '", ';
        } else {
            $content_css = $content_css . 'template_css.css", ';
        }
    }
    $plugins[] = '';
    $buttons2[] = '';
    $buttons3[] = '';
    $elements[] = '';
    if ($cleanup) {
        $cleanup = 'true';
    } else {
        $cleanup = 'false';
    }
    if ($cleanup_startup) {
        $cleanup_startup = 'true';
    } else {
        $cleanup_startup = 'false';
    }
    if ($newlines) {
        $br_newlines = 'true';
        $p_newlines = 'false';
    } else {
        $br_newlines = 'false';
        $p_newlines = 'true';
    }
    // Tiny Compressed mode
    if ($compressed) {
        $load = '<script type="text/javascript" src="' . $mosConfig_live_site . '/mambots/editors/tinymce/jscripts/tiny_mce/tiny_mce_gzip.js"></script>';
        $load_init = '
		<script type="text/javascript">
		tinyMCE_GZ.init({
			plugins : \'style,layer,table,save,advhr,advimage,advlink,emotions,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking\',
			themes : \'simple,advanced\',
			languages : \'en\',
			disk_cache : true,
			debug : false
		});
		</script>';
    } else {
        $load = '<script type="text/javascript" src="' . $mosConfig_live_site . '/mambots/editors/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script>';
        $load_init = '';
    }
    // preview
    if ($preview) {
        $plugins[] = 'preview';
        $buttons2[] = 'preview';
    }
    // search & replace
    if ($searchreplace) {
        $plugins[] = 'searchreplace';
        $buttons2[] = 'search,replace';
    }
    $plugins[] = 'insertdatetime';
    // insert date
    if ($insertdate) {
        $buttons2[] = 'insertdate';
    }
    // insert time
    if ($inserttime) {
        $buttons2[] = 'inserttime';
    }
    // emotions
    if ($smilies) {
        $plugins[] = 'emotions';
        $buttons2[] = 'emotions';
    }
    // horizontal line
    if ($hr) {
        $plugins[] = 'advhr';
        $elements[] = 'hr[class|width|size|noshade]';
        $buttons3[] = 'advhr';
    }
    // flash
    if ($flash) {
        $plugins[] = 'flash';
        $buttons3[] = 'flash';
    }
    // table
    if ($table) {
        $plugins[] = 'table';
        $buttons3[] = 'tablecontrols';
    }
    // fullscreen
    if ($fullscreen) {
        $plugins[] = 'fullscreen';
        $buttons3[] = 'fullscreen';
    }
    // autosave
    if ($autosave) {
        $plugins[] = 'autosave';
    }
    // layer
    if ($layer) {
        $plugins[] = 'layer';
        $buttons2[] = 'insertlayer';
        $buttons2[] = 'moveforward';
        $buttons2[] = 'movebackward';
        $buttons2[] = 'absolute';
    }
    // style
    if ($style) {
        $plugins[] = 'style';
        $buttons3[] = 'styleprops';
    }
    // visualchars
    if ($visualchars) {
        $plugins[] = 'visualchars';
        $buttons3[] = 'visualchars';
    }
    // media
    if ($media) {
        $plugins[] = 'media';
        $buttons3[] = 'media';
    }
    // nonbreaking
    if ($nonbreaking) {
        $plugins[] = 'nonbreaking';
        $buttons3[] = 'nonbreaking';
    }
    $buttons2 = implode(', ', $buttons2);
    $buttons3 = implode(', ', $buttons3);
    $plugins = implode(', ', $plugins);
    $elements = implode(', ', $elements);
    return <<<EOD
\t{$load}\t
\t{$load_init}\t
\t<script type="text/javascript">
\ttinyMCE.init({
\t\ttheme : "{$theme}",
\t\tlanguage : "en",
\t\tmode : "specific_textareas",
\t\tdocument_base_url : "{$mosConfig_live_site}/",
\t\trelative_urls : {$relative_urls},
\t\tremove_script_host : false,
\t\tsave_callback : "TinyMCE_Save",
\t\tinvalid_elements : "{$invalid_elements}",
\t\ttheme_advanced_toolbar_location : "{$toolbar}",
\t\ttheme_advanced_source_editor_height : "{$html_height}",
\t\ttheme_advanced_source_editor_width : "{$html_width}",
\t\tdirectionality: "{$text_direction}",
\t\tforce_br_newlines : "{$br_newlines}",
\t\tforce_p_newlines : "{$p_newlines}",
\t\t{$content_css}
\t\tdebug : false,
\t\tcleanup : {$cleanup},
\t\tcleanup_on_startup : {$cleanup_startup},
\t\tsafari_warning : false,
\t\tplugins : "advlink, advimage, {$plugins}",
\t\ttheme_advanced_buttons2_add : "{$buttons2}",
\t\ttheme_advanced_buttons3_add : "{$buttons3}",
\t\tplugin_insertdate_dateFormat : "{$format_date}",
\t\tplugin_insertdate_timeFormat : "{$format_time}",
\t\tplugin_preview_width : "{$preview_width}",
\t\tplugin_preview_height : "{$preview_height}",
\t\textended_valid_elements : "a[name|href|target|title|onclick], img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name], {$elements}",
\t\tdisk_cache : true,
\t\tdebug : false,\t
\t\tfullscreen_settings : {
\t\t\ttheme_advanced_path_location : "top"
\t\t}
\t});
\tfunction TinyMCE_Save(editor_id, content, node)
\t{
\t\tbase_url = tinyMCE.settings['document_base_url'];
\t\tvar vHTML = content;
\t\tif (true == true){
\t\t\tvHTML = tinyMCE.regexpReplace(vHTML, 'href\\s*=\\s*"?'+base_url+'', 'href="', 'gi');
\t\t\tvHTML = tinyMCE.regexpReplace(vHTML, 'src\\s*=\\s*"?'+base_url+'', 'src="', 'gi');
\t\t\tvHTML = tinyMCE.regexpReplace(vHTML, 'mce_real_src\\s*=\\s*"?', '', 'gi');
\t\t\tvHTML = tinyMCE.regexpReplace(vHTML, 'mce_real_href\\s*=\\s*"?', '', 'gi');
\t\t}
\t\treturn vHTML;
\t}\t
</script>
EOD;
}
Exemplo n.º 15
0
function showWrap($option)
{
    global $database, $Itemid, $mainframe;
    $menu = $mainframe->get('menu');
    $params = new mosParameters($menu->params);
    $params->def('back_button', $mainframe->getCfg('back_button'));
    $params->def('scrolling', 'auto');
    $params->def('page_title', '1');
    $params->def('pageclass_sfx', '');
    $params->def('header', $menu->name);
    $params->def('height', '500');
    $params->def('height_auto', '0');
    $params->def('width', '100%');
    $params->def('add', '1');
    $url = $params->def('url', '');
    $row = new stdClass();
    if ($params->get('add')) {
        // adds 'http://' if none is set
        if (substr($url, 0, 1) == '/') {
            // relative url in component. use server http_host.
            $row->url = 'http://' . $_SERVER['HTTP_HOST'] . $url;
        } elseif (!strstr($url, 'http') && !strstr($url, 'https')) {
            $row->url = 'http://' . $url;
        } else {
            $row->url = $url;
        }
    } else {
        $row->url = $url;
    }
    // auto height control
    if ($params->def('height_auto')) {
        $row->load = 'onload="iFrameHeight()"';
    } else {
        $row->load = '';
    }
    $mainframe->SetPageTitle($menu->name);
    HTML_wrapper::displayWrap($row, $params, $menu);
}
Exemplo n.º 16
0
function pollresult($uid)
{
    global $database, $Itemid;
    global $mainframe;
    $poll = new mosPoll($database);
    $poll->load((int) $uid);
    // if id value is passed and poll not published then exit
    if ($poll->id != '' && !$poll->published) {
        mosNotAuth();
        return;
    }
    $first_vote = '';
    $last_vote = '';
    $votes = '';
    /*
    Check if there is a poll corresponding to id
    and if poll is published
    */
    if (isset($poll->id) && $poll->id != '' && $poll->published == 1) {
        if (empty($poll->title)) {
            $poll->id = '';
            $poll->title = _SELECT_POLL;
        }
        $query = "SELECT MIN( date ) AS mindate, MAX( date ) AS maxdate" . "\n FROM #__poll_date" . "\n WHERE poll_id = " . (int) $poll->id;
        $database->setQuery($query);
        $dates = $database->loadObjectList();
        if (isset($dates[0]->mindate)) {
            $first_vote = mosFormatDate($dates[0]->mindate, _DATE_FORMAT_LC2);
            $last_vote = mosFormatDate($dates[0]->maxdate, _DATE_FORMAT_LC2);
        }
        $query = "SELECT a.id, a.text, a.hits, b.voters" . "\n FROM #__poll_data AS a" . "\n INNER JOIN #__polls AS b ON b.id = a.pollid" . "\n WHERE a.pollid = " . (int) $poll->id . "\n AND a.text != ''" . "\n AND b.published = 1";
        $database->setQuery($query);
        $votes = $database->loadObjectList();
    }
    // list of polls for dropdown selection
    $query = "SELECT id, title" . "\n FROM #__polls" . "\n WHERE published = 1" . "\n ORDER BY id";
    $database->setQuery($query);
    $polls = $database->loadObjectList();
    // Itemid for dropdown
    $_Itemid = '';
    if ($Itemid && $Itemid != 99999999) {
        $_Itemid = '&amp;Itemid=' . $Itemid;
    }
    // dropdown output
    $link = sefRelToAbs('index.php?option=com_poll&amp;task=results&amp;id=\' + this.options[selectedIndex].value + \'' . $_Itemid . '\' + \'');
    $pollist = '<select name="id" class="inputbox" size="1" style="width:200px" onchange="if (this.options[selectedIndex].value != \'\') {document.location.href=\'' . $link . '\'}">';
    $pollist .= '<option value="">' . _SELECT_POLL . '</option>';
    for ($i = 0, $n = count($polls); $i < $n; $i++) {
        $k = $polls[$i]->id;
        $t = $polls[$i]->title;
        $sel = $k == intval($poll->id) ? " selected=\"selected\"" : '';
        $pollist .= "\n\t<option value=\"" . $k . "\"{$sel}>" . $t . "</option>";
    }
    $pollist .= '</select>';
    // Adds parameter handling
    $menu = $mainframe->get('menu');
    $params = new mosParameters($menu->params);
    $params->def('page_title', 1);
    $params->def('pageclass_sfx', '');
    $params->def('back_button', $mainframe->getCfg('back_button'));
    $params->def('header', $menu->name);
    $mainframe->SetPageTitle($poll->title);
    poll_html::showResults($poll, $votes, $first_vote, $last_vote, $pollist, $params);
}
Exemplo n.º 17
0
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined('_VALID_MOS') or die('Restricted access');
// load the html drawing class
require_once $mainframe->getPath('front_html');
global $database, $my, $mainframe;
global $mosConfig_live_site, $mosConfig_frontend_login, $mosConfig_db;
if ($mosConfig_frontend_login != NULL && ($mosConfig_frontend_login === 0 || $mosConfig_frontend_login === '0')) {
    header("HTTP/1.0 403 Forbidden");
    echo _NOT_AUTH;
    return;
}
$menu = $mainframe->get('menu');
$params = new mosParameters($menu->params);
$params->def('page_title', 1);
$params->def('header_login', $menu->name);
$params->def('header_logout', $menu->name);
$params->def('pageclass_sfx', '');
$params->def('back_button', $mainframe->getCfg('back_button'));
$params->def('login', $mosConfig_live_site);
$params->def('logout', $mosConfig_live_site);
$params->def('login_message', 0);
$params->def('logout_message', 0);
$params->def('description_login', 1);
$params->def('description_logout', 1);
$params->def('description_login_text', _LOGIN_DESCRIPTION);
$params->def('description_logout_text', _LOGOUT_DESCRIPTION);
$params->def('image_login', 'key.jpg');
$params->def('image_logout', 'key.jpg');
$params->def('image_login_align', 'right');
Exemplo n.º 18
0
function showFeed($feedid)
{
    global $database, $mainframe, $mosConfig_absolute_path, $mosConfig_cachepath, $Itemid, $my;
    // check if cache directory is writeable
    $cacheDir = $mosConfig_cachepath . '/';
    if (!is_writable($cacheDir)) {
        echo 'Cache Directory Unwriteable';
        return;
    }
    require_once $mainframe->getPath('class');
    $newsfeed = new mosNewsFeed($database);
    $newsfeed->load((int) $feedid);
    /*
     * Check if newsfeed is published
     */
    if (!$newsfeed->published) {
        mosNotAuth();
        return;
    }
    $category = new mosCategory($database);
    $category->load((int) $newsfeed->catid);
    /*
     * Check if newsfeed category is published
     */
    if (!$category->published) {
        mosNotAuth();
        return;
    }
    /*
     * check whether category access level allows access
     */
    if ($category->access > $my->gid) {
        mosNotAuth();
        return;
    }
    // full RSS parser used to access image information
    require_once $mosConfig_absolute_path . '/includes/domit/xml_domit_rss.php';
    $LitePath = $mosConfig_absolute_path . '/includes/Cache/Lite.php';
    // Adds parameter handling
    $menu = $mainframe->get('menu');
    $params = new mosParameters($menu->params);
    $params->def('page_title', 1);
    $params->def('header', $menu->name);
    $params->def('pageclass_sfx', '');
    $params->def('back_button', $mainframe->getCfg('back_button'));
    // Feed Display control
    $params->def('feed_image', 1);
    $params->def('feed_descr', 1);
    $params->def('item_descr', 1);
    $params->def('word_count', 0);
    // Encoding
    $params->def('utf8', 1);
    if (!$params->get('page_title')) {
        $params->set('header', '');
    }
    $and = '';
    if ($feedid) {
        $and = "\n AND id = {$feedid}";
    }
    $mainframe->SetPageTitle($menu->name);
    HTML_newsfeed::showNewsfeeds($newsfeed, $LitePath, $cacheDir, $params);
}
Exemplo n.º 19
0
function feedFrontpage($showFeed)
{
    global $database, $mainframe;
    global $mosConfig_live_site, $mosConfig_cachepath;
    $nullDate = $database->getNullDate();
    // pull id of syndication component
    $query = "SELECT a.id" . "\n FROM #__components AS a" . "\n WHERE ( a.admin_menu_link = 'option=com_syndicate' OR a.admin_menu_link = 'option=com_syndicate&hidemainmenu=1' )" . "\n AND a.option = 'com_syndicate'";
    $database->setQuery($query);
    $id = $database->loadResult();
    // load syndication parameters
    $component = new mosComponent($database);
    $component->load((int) $id);
    $params = new mosParameters($component->params);
    // test if security check is enbled
    $check = $params->def('check', 1);
    if ($check) {
        // test if rssfeed module is published
        // if not disable access
        $query = "SELECT m.id" . "\n FROM #__modules AS m" . "\n WHERE m.module = 'mod_rssfeed'" . "\n AND m.published = 1";
        $database->setQuery($query);
        $check = $database->loadResultArray();
        if (empty($check)) {
            mosNotAuth();
            return;
        }
    }
    $now = _CURRENT_SERVER_TIME;
    $iso = split('=', _ISO);
    // parameter intilization
    $info['date'] = date('r');
    $info['year'] = date('Y');
    $info['encoding'] = $iso[1];
    $info['link'] = htmlspecialchars($mosConfig_live_site);
    $info['cache'] = $params->def('cache', 1);
    $info['cache_time'] = $params->def('cache_time', 3600);
    $info['count'] = $params->def('count', 5);
    $info['orderby'] = $params->def('orderby', '');
    $info['title'] = $params->def('title', 'Joomla! powered Site');
    $info['description'] = $params->def('description', 'Joomla! site syndication');
    $info['image_file'] = $params->def('image_file', 'joomla_rss.png');
    if ($info['image_file'] == -1) {
        $info['image'] = NULL;
    } else {
        $info['image'] = $mosConfig_live_site . '/images/M_images/' . $info['image_file'];
    }
    $info['image_alt'] = $params->def('image_alt', 'Powered by Joomla!');
    $info['limit_text'] = $params->def('limit_text', 0);
    $info['text_length'] = $params->def('text_length', 20);
    // get feed type from url
    $info['feed'] = strval(mosGetParam($_GET, 'feed', 'RSS2.0'));
    // live bookmarks
    $info['live_bookmark'] = $params->def('live_bookmark', '');
    $info['bookmark_file'] = $params->def('bookmark_file', '');
    // set filename for live bookmarks feed
    if (!$showFeed & $info['live_bookmark']) {
        if ($info['bookmark_file']) {
            // custom bookmark filename
            $filename = $info['bookmark_file'];
        } else {
            // standard bookmark filename
            $filename = $info['live_bookmark'];
        }
    } else {
        // set filename for rss feeds
        $info['file'] = strtolower(str_replace('.', '', $info['feed']));
        // security check to limit arbitrary file creation.
        // and to allow disabling/enabling of selected feed types
        switch ($info['file']) {
            case 'rss091':
                if (!$params->get('rss091', 1)) {
                    echo _NOT_AUTH;
                    return;
                }
                break;
            case 'rss10':
                if (!$params->get('rss10', 1)) {
                    echo _NOT_AUTH;
                    return;
                }
                break;
            case 'rss20':
                if (!$params->get('rss20', 1)) {
                    echo _NOT_AUTH;
                    return;
                }
                break;
            case 'atom03':
                if (!$params->get('atom03', 1)) {
                    echo _NOT_AUTH;
                    return;
                }
                break;
            case 'opml':
                if (!$params->get('opml', 1)) {
                    echo _NOT_AUTH;
                    return;
                }
                break;
            default:
                echo _NOT_AUTH;
                return;
                break;
        }
    }
    $filename = $info['file'] . '.xml';
    // security check to stop server path disclosure
    if (strstr($filename, '/')) {
        echo _NOT_AUTH;
        return;
    }
    $info['file'] = $mosConfig_cachepath . '/' . $filename;
    // load feed creator class
    $rss = new UniversalFeedCreator();
    // load image creator class
    $image = new FeedImage();
    // loads cache file
    if ($showFeed && $info['cache']) {
        $rss->useCached($info['feed'], $info['file'], $info['cache_time']);
    }
    $rss->title = $info['title'];
    $rss->description = $info['description'];
    $rss->link = $info['link'];
    $rss->syndicationURL = $info['link'];
    $rss->cssStyleSheet = NULL;
    $rss->encoding = $info['encoding'];
    if ($info['image']) {
        $image->url = $info['image'];
        $image->link = $info['link'];
        $image->title = $info['image_alt'];
        $image->description = $info['description'];
        // loads image info into rss array
        $rss->image = $image;
    }
    // Determine ordering for sql
    switch (strtolower($info['orderby'])) {
        case 'date':
            $orderby = 'a.created';
            break;
        case 'rdate':
            $orderby = 'a.created DESC';
            break;
        case 'alpha':
            $orderby = 'a.title';
            break;
        case 'ralpha':
            $orderby = 'a.title DESC';
            break;
        case 'hits':
            $orderby = 'a.hits DESC';
            break;
        case 'rhits':
            $orderby = 'a.hits ASC';
            break;
        case 'front':
            $orderby = 'f.ordering';
            break;
        default:
            $orderby = 'f.ordering';
            break;
    }
    // query of frontpage content items
    $query = "SELECT a.*, u.name AS author, u.usertype, UNIX_TIMESTAMP( a.created ) AS created_ts, cat.title AS cat_title, sec.title AS section_title" . "\n FROM #__content AS a" . "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id" . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n LEFT JOIN #__categories AS cat ON cat.id = a.catid" . "\n LEFT JOIN #__sections AS sec ON sec.id = a.sectionid" . "\n WHERE a.state = 1" . "\n AND cat.published = 1" . "\n AND sec.published = 1" . "\n AND a.access = 0" . "\n AND cat.access = 0" . "\n AND sec.access = 0" . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )" . "\n ORDER BY {$orderby}";
    $database->setQuery($query, 0, $info['count']);
    $rows = $database->loadObjectList();
    foreach ($rows as $row) {
        // title for particular item
        $item_title = htmlspecialchars($row->title);
        $item_title = html_entity_decode($item_title);
        // url link to article
        // & used instead of &amp; as this is converted by feed creator
        $_Itemid = '';
        $itemid = $mainframe->getItemid($row->id);
        if ($itemid) {
            $_Itemid = '&Itemid=' . $itemid;
        }
        $item_link = 'index.php?option=com_content&task=view&id=' . $row->id . $_Itemid;
        $item_link = sefRelToAbs($item_link);
        // removes all formating from the intro text for the description text
        $item_description = $row->introtext;
        $item_description = mosHTML::cleanText($item_description);
        $item_description = html_entity_decode($item_description);
        if ($info['limit_text']) {
            if ($info['text_length']) {
                // limits description text to x words
                $item_description_array = split(' ', $item_description);
                $count = count($item_description_array);
                if ($count > $info['text_length']) {
                    $item_description = '';
                    for ($a = 0; $a < $info['text_length']; $a++) {
                        $item_description .= $item_description_array[$a] . ' ';
                    }
                    $item_description = trim($item_description);
                    $item_description .= '...';
                }
            } else {
                // do not include description when text_length = 0
                $item_description = NULL;
            }
        }
        // load individual item creator class
        $item = new FeedItem();
        // item info
        $item->title = $item_title;
        $item->link = $item_link;
        $item->description = $item_description;
        $item->source = $info['link'];
        $item->date = date('r', $row->created_ts);
        $item->category = $row->section_title . ' - ' . $row->cat_title;
        // loads item info into rss array
        $rss->addItem($item);
    }
    // save feed file
    $rss->saveFeed($info['feed'], $info['file'], $showFeed);
}
Exemplo n.º 20
0
function showItem($uid, $gid, &$access, $pop, $option = 'com_content', $now)
{
    global $database, $mainframe, $Itemid;
    global $mosConfig_MetaTitle, $mosConfig_MetaAuthor;
    $now = _CURRENT_SERVER_TIME;
    $nullDate = $database->getNullDate();
    if ($access->canEdit) {
        $xwhere = '';
    } else {
        $xwhere = " AND ( a.state = 1 OR a.state = -1 )" . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )";
    }
    // main query
    $query = "SELECT a.*, u.name AS author, u.usertype, cc.name AS category, s.name AS section, g.name AS groups," . "\n s.published AS sec_pub, cc.published AS cat_pub, s.access AS sec_access, cc.access AS cat_access," . "\n s.id AS sec_id, cc.id as cat_id" . "\n FROM #__content AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = 'content'" . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n LEFT JOIN #__groups AS g ON a.access = g.id" . "\n WHERE a.id = " . (int) $uid . $xwhere . "\n AND a.access <= " . (int) $gid;
    $database->setQuery($query);
    $row = NULL;
    if ($database->loadObject($row)) {
        /*
         * check whether category is published
         */
        if (!$row->cat_pub && $row->catid) {
            mosNotAuth();
            return;
        }
        /*
         * check whether section is published
         */
        if (!$row->sec_pub && $row->sectionid) {
            mosNotAuth();
            return;
        }
        /*
         * check whether category access level allows access
         */
        if ($row->cat_access > $gid && $row->catid) {
            mosNotAuth();
            return;
        }
        /*
         * check whether section access level allows access
         */
        if ($row->sec_access > $gid && $row->sectionid) {
            mosNotAuth();
            return;
        }
        $params = new mosParameters($row->attribs);
        $params->set('intro_only', 0);
        $params->def('back_button', $mainframe->getCfg('back_button'));
        if ($row->sectionid == 0) {
            $params->set('item_navigation', 0);
        } else {
            $params->set('item_navigation', $mainframe->getCfg('item_navigation'));
        }
        // loads the links for Next & Previous Button
        if ($params->get('item_navigation')) {
            // Paramters for menu item as determined by controlling Itemid
            $menu = $mainframe->get('menu');
            $mparams = new mosParameters($menu->params);
            // the following is needed as different menu items types utilise a different param to control ordering
            // for Blogs the `orderby_sec` param is the order controlling param
            // for Table and List views it is the `orderby` param
            $mparams_list = $mparams->toArray();
            if (array_key_exists('orderby_sec', $mparams_list)) {
                $order_method = $mparams->get('orderby_sec', '');
            } else {
                $order_method = $mparams->get('orderby', '');
            }
            // additional check for invalid sort ordering
            if ($order_method == 'front') {
                $order_method = '';
            }
            $orderby = _orderby_sec($order_method);
            // array of content items in same category correctly ordered
            $query = "SELECT a.id" . "\n FROM #__content AS a" . "\n WHERE a.catid = " . (int) $row->catid . "\n AND a.state = " . (int) $row->state . ($access->canEdit ? '' : "\n AND a.access <= " . (int) $gid) . $xwhere . "\n ORDER BY {$orderby}";
            $database->setQuery($query);
            $list = $database->loadResultArray();
            // this check needed if incorrect Itemid is given resulting in an incorrect result
            if (!is_array($list)) {
                $list = array();
            }
            // location of current content item in array list
            $location = array_search($uid, $list);
            $row->prev = '';
            $row->next = '';
            if ($location - 1 >= 0) {
                // the previous content item cannot be in the array position -1
                $row->prev = $list[$location - 1];
            }
            if ($location + 1 < count($list)) {
                // the next content item cannot be in an array position greater than the number of array postions
                $row->next = $list[$location + 1];
            }
        }
        // page title
        $mainframe->setPageTitle($row->title);
        if ($mosConfig_MetaTitle == '1') {
            $mainframe->addMetaTag('title', $row->title);
        }
        if ($mosConfig_MetaAuthor == '1') {
            $mainframe->addMetaTag('author', $row->author);
        }
        show($row, $params, $gid, $access, $pop);
    } else {
        mosNotAuth();
        return;
    }
}
Exemplo n.º 21
0
 function getFirstLevelItem($mitem)
 {
     global $Itemid, $urlpath;
     $app = JFactory::getApplication();
     $txt = '';
     switch ($mitem->type) {
         case 'separator':
         case 'component_item_link':
             break;
         case 'content_item_link':
             $temp = split("&task=view&id=", $mitem->link);
             $mitem->link .= '&Itemid=' . $app->getItemid($temp[1]);
             break;
         case 'url':
             if (eregi('index.php\\?', $mitem->link)) {
                 if (!eregi('Itemid=', $mitem->link)) {
                     $mitem->link .= '&Itemid=' . $mitem->id;
                 }
             }
             break;
         case 'content_typed':
         default:
             $mitem->link .= '&Itemid=' . $Itemid;
             break;
     }
     $id = 'id="menu' . $mitem->id . '"';
     if (strcasecmp(substr($mitem->link, 0, 4), 'http')) {
         $mitem->link = JRoute::_($mitem->link);
     }
     $menuclass = 'mainlevel' . $this->parent->_params->get('class_sfx');
     // Active Menu highlighting
     $current_itemid = trim(JRequest::getInt('Itemid'));
     if (in_array($mitem->id, $this->parent->open)) {
         $menuclass = 'mainlevel_active' . $this->parent->_params->get('class_sfx');
     }
     switch ($mitem->browserNav) {
         // cases are slightly different
         case 1:
             // open in a new window
             $txt = '<a href="' . $mitem->link . '" target="_blank" class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</a>';
             break;
         case 2:
             // open in a popup window
             $txt = "<a href=\"#\" onclick=\"javascript: window.open('" . $mitem->link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\" class=\"{$menuclass}\" " . $id . ">" . $mitem->name . "</a>\n";
             break;
         case 3:
             // don't link it
             $txt = '<span class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</span>';
             break;
         default:
             // formerly case 2
             // open in parent window
             $txt = '<a href="' . $mitem->link . '" class="' . $menuclass . '" ' . $id . '>' . $mitem->name;
             if ($this->parent->hasSubItems($mitem->id)) {
                 $txt .= '&nbsp;&nbsp;<img border="0" src="' . $this->parent->_params->get('LSPath') . '/img/tabarrow.gif" alt="arrow" />';
             }
             $txt .= '</a>';
             break;
     }
     if ($this->parent->_params->get('menu_images')) {
         $menu_params = new stdClass();
         $menu_params = new mosParameters($mitem->params);
         $menu_image = $menu_params->def('menu_image', -1);
         if ($menu_image != '-1' && $menu_image) {
             $image = '<img src="' . $urlpath . 'images/stories/' . $menu_image . '" border="0" alt="' . $mitem->name . '"/>';
             if ($this->parent->_params->get('menu_images_align')) {
                 $txt = $txt . ' ' . $image;
             } else {
                 $txt = $image . ' ' . $txt;
             }
         }
     }
     return $txt;
 }
Exemplo n.º 22
0
 static function ownersList($option)
 {
     global $database, $my, $Itemid, $mainframe, $booklibrary_configuration, $acl, $mosConfig_list_limit, $limit, $limitstart;
     PHP_booklibrary::addTitleAndMetaTags();
     $symbol = mosGetParam($_REQUEST, 'letindex', '');
     $symbol_str = '';
     if ($symbol) {
         $symbol_str = " AND (LOWER(u.name) LIKE '{$symbol}%' ) ";
     }
     //getting groups of user
     $s = getWhereUsergroupsString("c");
     //   $menu = new JTableMenu( $database );
     //   $menu->load( $Itemid );
     //   $params = new mosParameters( $menu->params );
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $menu = new JTableMenu($database);
         $menu->load($Itemid);
         $params = new JRegistry();
         $params->loadString($menu->params);
     } else {
         $menu = new mosMenu($database);
         $menu->load($Itemid);
         $params = new mosParameters($menu->params);
     }
     $database->setQuery("SELECT id FROM #__menu WHERE link='index.php?option=com_booklibrary'");
     if ($database->loadResult() != $Itemid) {
         $params->def('wrongitemid', '1');
     }
     $params->def('header', _BOOKLIBRARY_LABEL_TITLE_OWNERSLIST);
     if (!$params->get('wrongitemid')) {
         $pathway = sefRelToAbs('index.php?option=' . $option . '&amp;task=owners_list&amp;Itemid=' . $Itemid);
         $pathway_name = _BOOKLIBRARY_LABEL_TITLE_OWNERSLIST;
         $mainframe->appendPathWay($pathway_name, $pathway);
     }
     if (checkAccessBL($booklibrary_configuration['ownerslist']['registrationlevel'], 'NORECURSE', userGID_BL($my->id), $acl) && $booklibrary_configuration['ownerslist']['show']) {
         $params->def('ownerslist_show', 1);
     }
     $db = JFactory::getDBO();
     $query = "SELECT COUNT(DISTINCT u.email)\n                          \nFROM #__booklibrary AS bl\n                          \nLEFT JOIN #__booklibrary_categories AS mc ON mc.bookid=bl.id\n                          \nLEFT JOIN #__booklibrary_main_categories AS c ON c.id=mc.catid\n                          \nLEFT JOIN #__users AS u ON bl.owneremail=u.email\n                          \nWHERE bl.published=1 AND bl.approved=1 AND c.published=1\n                                AND ({$s}) {$symbol_str};\n                          ";
     $database->setQuery($query);
     $total = $database->loadResult();
     $pageNav = new JPagination($total, $limitstart, $limit);
     // for J 1.6
     $query = "SELECT u.name, COUNT(DISTINCT mc.bookid) AS books\n                          \nFROM #__booklibrary AS bl\n                          \nLEFT JOIN #__booklibrary_categories AS mc ON  mc.bookid=bl.id\n                          \nLEFT JOIN #__booklibrary_main_categories AS c ON c.id=mc.catid\n                          \nLEFT JOIN #__users AS u ON bl.owneremail=u.email\n                          \nWHERE bl.published=1 AND bl.approved=1 AND c.published=1 AND bl.owneremail!=''\n                                  AND ({$s}) {$symbol_str}\n                          \nGROUP BY u.name\n                          \nORDER BY u.name\n                          \nLIMIT {$pageNav->limitstart},{$pageNav->limit};";
     $database->setQuery($query);
     $ownerslist = $database->loadObjectList();
     if (!empty($ownerslist[0]->books) && !isset($ownerslist[0]->name)) {
         $ownerslist[0]->name = 'anonymous';
     }
     $query = "SELECT DISTINCT UPPER(SUBSTRING(u.name, 1,1)) AS symb \n                          \nFROM #__booklibrary AS bl\n                          \nLEFT JOIN #__booklibrary_categories AS mc ON mc.bookid=bl.id\n                          \nLEFT JOIN #__booklibrary_main_categories AS c ON c.id=mc.catid\n                          \nLEFT JOIN #__users AS u ON bl.owneremail=u.email\n                          \nWHERE bl.published=1 AND bl.approved=1 AND c.published=1 AND bl.owneremail!=''\n                                  AND ({$s})\n                          \nORDER BY u.name ;";
     $database->setQuery($query);
     $symb = $database->loadObjectList();
     if (count($symb) > 0) {
         $symb_list_str = '<div style="display:inline; margin-left:auto;margin-right:auto;">';
         foreach ($symb as $symbol) {
             $symb_list_str .= '<span style="padding:5px; ">' . '<a href="index.php?option=' . $option . '&task=owners_list' . '&letindex=' . $symbol->symb . '&Itemid=' . $Itemid . '">' . $symbol->symb . '</a></span>';
         }
         $symb_list_str .= "</div>";
         $params->def('symb_list_str', $symb_list_str);
     }
     $params->def('ownerlist01', "{loadposition com_booklibrary_owner_list_01}");
     $params->def('ownerlist02', "{loadposition com_booklibrary_owner_list_02}");
     $params->def('ownerlist03', "{loadposition com_booklibrary_owner_list_03}");
     //print_r($ownerslist);
     HTML_booklibrary::showOwnersList($params, $ownerslist, $pageNav);
 }
Exemplo n.º 23
0
function viewSearch()
{
    global $mainframe, $mosConfig_absolute_path, $mosConfig_lang, $my;
    global $Itemid, $database, $_MAMBOTS;
    global $mosConfig_list_limit;
    $restriction = 0;
    // try to find search component's Itemid
    // Only search if we don't have a valid Itemid (e.g. from module)
    if (!intval($Itemid) || intval($Itemid) == 99999999) {
        $query = "SELECT id" . "\n FROM #__menu" . "\n WHERE type = 'components'" . "\n AND published = 1" . "\n AND link = 'index.php?option=com_search'";
        $database->setQuery($query);
        $_Itemid = $database->loadResult();
        if ($_Itemid != "") {
            $Itemid = $_Itemid;
        }
    }
    $gid = $my->gid;
    // Adds parameter handling
    if ($Itemid > 0 && $Itemid != 99999999) {
        $menu = $mainframe->get('menu');
        $params = new mosParameters($menu->params);
        $params->def('page_title', 1);
        $params->def('pageclass_sfx', '');
        $params->def('header', $menu->name);
        $params->def('back_button', $mainframe->getCfg('back_button'));
    } else {
        $params = new mosParameters('');
        $params->def('page_title', 1);
        $params->def('pageclass_sfx', '');
        $params->def('header', _SEARCH_TITLE);
        $params->def('back_button', $mainframe->getCfg('back_button'));
    }
    // html output
    search_html::openhtml($params);
    $searchphrase = mosGetParam($_REQUEST, 'searchphrase', 'any');
    $searchphrase = preg_replace('/[^a-z]/', '', strtolower($searchphrase));
    $searchword = strval(mosGetParam($_REQUEST, 'searchword', ''));
    $searchword = trim(stripslashes($searchword));
    // limit searchword to 20 characters
    if (strlen($searchword) > 20) {
        $searchword = substr($searchword, 0, 19);
        $restriction = 1;
    }
    // searchword must contain a minimum of 3 characters
    if ($searchword && strlen($searchword) < 3) {
        $searchword = '';
        $restriction = 1;
    }
    if ($searchphrase != 'exact') {
        $aterms = explode(' ', strtolower($searchword));
        $search_ignore = array();
        // filter out search terms that are too small
        foreach ($aterms as $aterm) {
            if (strlen($aterm) < 3) {
                $search_ignore[] = $aterm;
            }
        }
        $pruned = array_diff($aterms, $search_ignore);
        $pruned = array_unique($pruned);
        $searchword = implode(' ', $pruned);
        if (trim($searchword) == '') {
            $restriction = 1;
        }
    }
    @(include "{$mosConfig_absolute_path}/language/{$mosConfig_lang}.ignore.php");
    $orders = array();
    $orders[] = mosHTML::makeOption('newest', _SEARCH_NEWEST);
    $orders[] = mosHTML::makeOption('oldest', _SEARCH_OLDEST);
    $orders[] = mosHTML::makeOption('popular', _SEARCH_POPULAR);
    $orders[] = mosHTML::makeOption('alpha', _SEARCH_ALPHABETICAL);
    $orders[] = mosHTML::makeOption('category', _SEARCH_CATEGORY);
    $ordering = mosGetParam($_REQUEST, 'ordering', 'newest');
    $ordering = preg_replace('/[^a-z]/', '', strtolower($ordering));
    $lists = array();
    $lists['ordering'] = mosHTML::selectList($orders, 'ordering', 'id="search_ordering" class="inputbox"', 'value', 'text', $ordering);
    $searchphrases = array();
    $phrase = new stdClass();
    $phrase->value = 'any';
    $phrase->text = _SEARCH_ANYWORDS;
    $searchphrases[] = $phrase;
    $phrase = new stdClass();
    $phrase->value = 'all';
    $phrase->text = _SEARCH_ALLWORDS;
    $searchphrases[] = $phrase;
    $phrase = new stdClass();
    $phrase->value = 'exact';
    $phrase->text = _SEARCH_PHRASE;
    $searchphrases[] = $phrase;
    $lists['searchphrase'] = mosHTML::radioList($searchphrases, 'searchphrase', '', $searchphrase);
    // html output
    search_html::searchbox(htmlspecialchars($searchword), $lists, $params);
    if (!$searchword) {
        if (count($_POST)) {
            // html output
            // no matches found
            search_html::message(_NOKEYWORD, $params);
        } else {
            if ($restriction) {
                // html output
                search_html::message(_SEARCH_MESSAGE, $params);
            }
        }
    } else {
        if (in_array($searchword, $search_ignore)) {
            // html output
            search_html::message(_IGNOREKEYWORD, $params);
        } else {
            // html output
            if ($restriction) {
                // html output
                search_html::message(_SEARCH_MESSAGE, $params);
            }
            $searchword_clean = htmlspecialchars($searchword);
            search_html::searchintro($searchword_clean, $params);
            mosLogSearch($searchword);
            $_MAMBOTS->loadBotGroup('search');
            $results = $_MAMBOTS->trigger('onSearch', array($database->getEscaped($searchword, true), $searchphrase, $ordering));
            $totalRows = 0;
            $rows = array();
            for ($i = 0, $n = count($results); $i < $n; $i++) {
                $rows = array_merge((array) $rows, (array) $results[$i]);
            }
            $totalRows = count($rows);
            for ($i = 0; $i < $totalRows; $i++) {
                $text =& $rows[$i]->text;
                if ($searchphrase == 'exact') {
                    $searchwords = array($searchword);
                    $needle = $searchword;
                } else {
                    $searchwords = explode(' ', $searchword);
                    $needle = $searchwords[0];
                }
                $text = mosPrepareSearchContent($text, 200, $needle);
                foreach ($searchwords as $k => $hlword) {
                    $searchwords[$k] = htmlspecialchars(stripslashes($hlword));
                }
                $searchRegex = implode('|', $searchwords);
                $text = eregi_replace('(' . $searchRegex . ')', '<span class="highlight">\\0</span>', $text);
                if (strpos($rows[$i]->href, 'http') == false) {
                    $url = parse_url($rows[$i]->href);
                    parse_str(@$url['query'], $link);
                    // determines Itemid for Content items where itemid has not been included
                    if (isset($rows[$i]->type) && @$link['task'] == 'view' && isset($link['id']) && !isset($link['Itemid'])) {
                        $itemid = '';
                        $_itemid = $mainframe->getItemid($link['id'], 0);
                        if ($_itemid) {
                            $itemid = '&amp;Itemid=' . $_itemid;
                        }
                        $rows[$i]->href = $rows[$i]->href . $itemid;
                    }
                }
            }
            $mainframe->setPageTitle(_SEARCH_TITLE);
            $total = $totalRows;
            $limit = intval(mosGetParam($_GET, 'limit', $mosConfig_list_limit));
            $limit = $limit ? $limit : $mosConfig_list_limit;
            $limitstart = intval(mosGetParam($_GET, 'limitstart', 0));
            // prepares searchword for proper display in url
            $searchword_clean = urlencode($searchword_clean);
            if ($n) {
                // html output
                require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php';
                $pageNav = new mosPageNav($total, $limitstart, $limit);
                search_html::display($rows, $params, $pageNav, $limitstart, $limit, $total, $totalRows, $searchword_clean);
            } else {
                // html output
                search_html::displaynoresult();
            }
            // html output
            search_html::conclusion($searchword_clean, $pageNav);
        }
    }
    // displays back button
    echo '<br/>';
    mosHTML::BackButton($params, 0);
}
Exemplo n.º 24
0
function listWeblinks($catid)
{
    global $mainframe, $database, $my;
    global $mosConfig_live_site;
    global $Itemid;
    $rows = array();
    $currentcat = null;
    if ($catid) {
        // url links info for category
        $query = "SELECT id, url, title, description, date, hits, params" . "\n FROM #__weblinks" . "\n WHERE catid = " . (int) $catid . "\n AND published = 1" . "\n AND archived = 0" . "\n ORDER BY ordering";
        $database->setQuery($query);
        $rows = $database->loadObjectList();
        // current cate info
        $query = "SELECT *" . "\n FROM #__categories" . "\n WHERE id = " . (int) $catid . "\n AND published = 1" . "\n AND access <= " . (int) $my->gid;
        $database->setQuery($query);
        $database->loadObject($currentcat);
        /*
        Check if the category is published or if access level allows access
        */
        if (!$currentcat->name) {
            mosNotAuth();
            return;
        }
    }
    /* Query to retrieve all categories that belong under the web links section and that are published. */
    $query = "SELECT cc.*, a.catid, a.title, a.url, COUNT(a.id) AS numlinks" . "\n FROM #__categories AS cc" . "\n LEFT JOIN #__weblinks AS a ON a.catid = cc.id" . "\n WHERE a.published = 1" . "\n AND section = 'com_weblinks'" . "\n AND cc.published = 1" . "\n AND cc.access <= " . (int) $my->gid . "\n GROUP BY cc.id" . "\n ORDER BY cc.ordering";
    $database->setQuery($query);
    $categories = $database->loadObjectList();
    // Parameters
    $menu = $mainframe->get('menu');
    $params = new mosParameters($menu->params);
    $params->def('page_title', 1);
    $params->def('header', $menu->name);
    $params->def('pageclass_sfx', '');
    $params->def('headings', 1);
    $params->def('hits', $mainframe->getCfg('hits'));
    $params->def('item_description', 1);
    $params->def('other_cat_section', 1);
    $params->def('other_cat', 1);
    $params->def('description', 1);
    $params->def('description_text', _WEBLINKS_DESC);
    $params->def('image', '-1');
    $params->def('weblink_icons', '');
    $params->def('image_align', 'right');
    $params->def('back_button', $mainframe->getCfg('back_button'));
    if ($catid) {
        $params->set('type', 'category');
    } else {
        $params->set('type', 'section');
    }
    // page description
    $currentcat->descrip = '';
    if (@$currentcat->description != '') {
        $currentcat->descrip = $currentcat->description;
    } else {
        if (!$catid) {
            // show description
            if ($params->get('description')) {
                $currentcat->descrip = $params->get('description_text');
            }
        }
    }
    // page image
    $currentcat->img = '';
    $path = $mosConfig_live_site . '/images/stories/';
    if (@$currentcat->image != '') {
        $currentcat->img = $path . $currentcat->image;
        $currentcat->align = $currentcat->image_position;
    } else {
        if (!$catid) {
            if ($params->get('image') != -1) {
                $currentcat->img = $path . $params->get('image');
                $currentcat->align = $params->get('image_align');
            }
        }
    }
    // page header
    $currentcat->header = '';
    if (@$currentcat->name != '') {
        $currentcat->header = $currentcat->name;
    } else {
        $currentcat->header = $params->get('header');
    }
    // used to show table rows in alternating colours
    $tabclass = array('sectiontableentry1', 'sectiontableentry2');
    HTML_weblinks::displaylist($categories, $rows, $catid, $currentcat, $params, $tabclass);
}
Exemplo n.º 25
0
/**
* Mambot that Cloaks all emails in content from spambots via javascript
*/
function botMosEmailCloak($published, &$row, &$params, $page = 0)
{
    global $database, $_MAMBOTS;
    // check whether mambot has been unpublished
    if (!$published) {
        return true;
    }
    // simple performance check to determine whether bot should process further
    if (strpos($row->text, '@') === false) {
        return true;
    }
    // simple check to allow disabling of bot
    $regex = '{emailcloak=off}';
    if (strpos($row->text, $regex) !== false) {
        $row->text = str_replace($regex, '', $row->text);
        return true;
    }
    // check if param query has previously been processed
    if (!isset($_MAMBOTS->_content_mambot_params['mosemailcloak'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'mosemailcloak'" . "\n AND folder = 'content'";
        $database->setQuery($query);
        $database->loadObject($mambot);
        // save query to class variable
        $_MAMBOTS->_content_mambot_params['mosemailcloak'] = $mambot;
    }
    // pull query data from class variable
    $mambot = $_MAMBOTS->_content_mambot_params['mosemailcloak'];
    $botParams = new mosParameters($mambot->params);
    $mode = $botParams->def('mode', 1);
    // any@email.address.com
    $search_email = "([[:alnum:]_\\.\\-]+)(\\@[[:alnum:]\\.\\-]+\\.+)([[:alnum:]\\.\\-]+)";
    // any@email.address.com?subject=anyText
    $search_email_msg = "([[:alnum:]_\\.\\-]+)(\\@[[:alnum:]\\.\\-]+\\.+)([[:alnum:]\\.\\-]+)([[:alnum:][:space:][:punct:]][^\"<>]+)";
    // anyText
    $search_text = "([[:alnum:][:space:][:punct:]][^<>]+)";
    // search for derivativs of link code <a href="mailto:email@amail.com">email@amail.com</a>
    $pattern = botMosEmailCloak_searchPattern($search_email, $search_email);
    while (eregi($pattern, $row->text, $regs)) {
        $mail = $regs[2] . $regs[3] . $regs[4];
        $mail_text = $regs[5] . $regs[6] . $regs[7];
        // check to see if mail text is different from mail addy
        if ($mail_text) {
            $replacement = mosHTML::emailCloaking($mail, $mode, $mail_text);
        } else {
            $replacement = mosHTML::emailCloaking($mail, $mode);
        }
        // replace the found address with the js cloacked email
        $row->text = str_replace($regs[0], $replacement, $row->text);
    }
    // search for derivativs of link code <a href="mailto:email@amail.com">anytext</a>
    $pattern = botMosEmailCloak_searchPattern($search_email, $search_text);
    while (eregi($pattern, $row->text, $regs)) {
        $mail = $regs[2] . $regs[3] . $regs[4];
        $mail_text = $regs[5];
        $replacement = mosHTML::emailCloaking($mail, $mode, $mail_text, 0);
        // replace the found address with the js cloacked email
        $row->text = str_replace($regs[0], $replacement, $row->text);
    }
    // search for derivativs of link code <a href="mailto:email@amail.com?subject=Text&body=Text">email@amail.com</a>
    $pattern = botMosEmailCloak_searchPattern($search_email_msg, $search_email);
    while (eregi($pattern, $row->text, $regs)) {
        $mail = $regs[2] . $regs[3] . $regs[4] . $regs[5];
        $mail_text = $regs[6] . $regs[7] . $regs[8];
        //needed for handling of Body parameter
        $mail = str_replace('&amp;', '&', $mail);
        // check to see if mail text is different from mail addy
        if ($mail_text) {
            $replacement = mosHTML::emailCloaking($mail, $mode, $mail_text);
        } else {
            $replacement = mosHTML::emailCloaking($mail, $mode);
        }
        // replace the found address with the js cloacked email
        $row->text = str_replace($regs[0], $replacement, $row->text);
    }
    // search for derivativs of link code <a href="mailto:email@amail.com?subject=Text&body=Text">anytext</a>
    $pattern = botMosEmailCloak_searchPattern($search_email_msg, $search_text);
    while (eregi($pattern, $row->text, $regs)) {
        $mail = $regs[2] . $regs[3] . $regs[4] . $regs[5];
        $mail_text = $regs[6];
        //needed for handling of Body parameter
        $mail = str_replace('&amp;', '&', $mail);
        $replacement = mosHTML::emailCloaking($mail, $mode, $mail_text, 0);
        // replace the found address with the js cloacked email
        $row->text = str_replace($regs[0], $replacement, $row->text);
    }
    // search for plain text email@amail.com
    while (eregi($search_email, $row->text, $regs)) {
        $mail = $regs[0];
        $replacement = mosHTML::emailCloaking($mail, $mode);
        // replace the found address with the js cloacked email
        $row->text = str_replace($regs[0], $replacement, $row->text);
    }
}
Exemplo n.º 26
0
 function getParameters($id)
 {
     global $database, $mosConfig_offset, $mosConfig_live_site;
     $feed = new rdRssData($database);
     $feed->load($id);
     $params = new mosParameters($feed->params);
     $params->id = $id;
     $params->catids = $feed->catids;
     $params->published = $feed->published;
     if (method_exists($database, "getNullDate")) {
         $params->nullDate = $database->getNullDate();
     } else {
         $params->nullDate = '0000-00-00 00:00:00';
     }
     $params->now = date('Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60);
     $iso = split('=', _ISO);
     // parameter intilization
     $params->date = date('r');
     $params->year = date('Y');
     $params->encoding = $iso[1];
     $params->link = htmlspecialchars($mosConfig_live_site);
     $params->cache = $params->def('cache', 1);
     $params->cache_time = $params->def('cache_time', 3600);
     $params->count = $params->def('count', 5);
     $params->orderby = $params->def('orderby', '');
     $params->title = $params->def('title', 'Joomla! powered Site');
     $params->description = $params->def('description', 'Joomla! site syndication');
     $params->image_file = $params->def('image_file', 'joomla_rss.png');
     if ($params->image_file == -1) {
         $params->image = NULL;
     } else {
         $params->image = $mosConfig_live_site . '/images/M_images/' . $params->image_file;
     }
     $params->image_alt = $params->def('image_alt', 'Powered by Joomla!');
     $params->limit_text = $params->def('limit_text', 1);
     $params->text_length = $params->def('text_length', 20);
     // get feed type from url
     $params->feed = mosGetParam($_GET, 'feed', 'RSS2.0');
     // live bookmarks
     $params->live_bookmark = $params->def('live_bookmark', '');
     return $params;
 }
Exemplo n.º 27
0
 /**
  * Utility function for writing a menu link
  */
 function mosGetMenuLink($mitem, $level = 0, &$params, $open = null)
 {
     global $Itemid, $mosConfig_live_site, $mainframe;
     $txt = '';
     switch ($mitem->type) {
         case 'separator':
         case 'component_item_link':
             break;
         case 'url':
             if (preg_match('/index.php\\?/', $link) && !preg_match('/http/', $link) && !preg_match('/https/', $link)) {
                 if (!preg_match('/Itemid=/', $link)) {
                     $mitem->link .= '&Itemid=' . $mitem->id;
                 }
             }
             break;
         case 'content_item_link':
         case 'content_typed':
             // load menu params
             $menuparams = new mosParameters($mitem->params, $mainframe->getPath('menu_xml', $mitem->type), 'menu');
             $unique_itemid = $menuparams->get('unique_itemid', 1);
             if ($unique_itemid) {
                 $mitem->link .= '&Itemid=' . $mitem->id;
             } else {
                 $temp = split('&task=view&id=', $mitem->link);
                 if ($mitem->type == 'content_typed') {
                     $mitem->link .= '&Itemid=' . $mainframe->getItemid($temp[1], 1, 0);
                 } else {
                     $mitem->link .= '&Itemid=' . $mainframe->getItemid($temp[1], 0, 1);
                 }
             }
             break;
         default:
             $mitem->link .= '&Itemid=' . $mitem->id;
             break;
     }
     // Active Menu highlighting
     $current_itemid = $Itemid;
     if (!$current_itemid) {
         $id = '';
     } else {
         if ($current_itemid == $mitem->id) {
             $id = 'id="active_menu' . $params->get('class_sfx') . '"';
         } else {
             if ($params->get('activate_parent') && isset($open) && in_array($mitem->id, $open)) {
                 $id = 'id="active_menu' . $params->get('class_sfx') . '"';
             } else {
                 $id = '';
             }
         }
     }
     if ($params->get('full_active_id')) {
         // support for `active_menu` of 'Link - Component Item'
         if ($id == '' && $mitem->type == 'component_item_link') {
             parse_str($mitem->link, $url);
             if ($url['Itemid'] == $current_itemid) {
                 $id = 'id="active_menu' . $params->get('class_sfx') . '"';
             }
         }
         // support for `active_menu` of 'Link - Url' if link is relative
         if ($id == '' && $mitem->type == 'url' && strpos('http', $mitem->link) === false) {
             parse_str($mitem->link, $url);
             if (isset($url['Itemid'])) {
                 if ($url['Itemid'] == $current_itemid) {
                     $id = 'id="active_menu' . $params->get('class_sfx') . '"';
                 }
             }
         }
     }
     // replace & with amp; for xhtml compliance
     $mitem->link = ampReplace($mitem->link);
     // run through SEF convertor
     $mitem->link = sefRelToAbs($mitem->link);
     $menuclass = 'mainlevel' . $params->get('class_sfx');
     if ($level > 0) {
         $menuclass = 'sublevel' . $params->get('class_sfx');
     }
     // replace & with amp; for xhtml compliance
     // remove slashes from excaped characters
     $mitem->name = stripslashes(ampReplace($mitem->name));
     switch ($mitem->browserNav) {
         // cases are slightly different
         case 1:
             // open in a new window
             $txt = '<a href="' . $mitem->link . '" target="_blank" class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</a>';
             break;
         case 2:
             // open in a popup window
             $txt = "<a href=\"#\" onclick=\"javascript: window.open('" . $mitem->link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\" class=\"{$menuclass}\" " . $id . ">" . $mitem->name . "</a>\n";
             break;
         case 3:
             // don't link it
             $txt = '<span class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</span>';
             break;
         default:
             // open in parent window
             $txt = '<a href="' . $mitem->link . '" class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</a>';
             break;
     }
     if ($params->get('menu_images')) {
         $menu_params = new stdClass();
         $menu_params = new mosParameters($mitem->params);
         $menu_image = $menu_params->def('menu_image', -1);
         if ($menu_image != '-1' && $menu_image) {
             $image = '<img src="' . $mosConfig_live_site . '/images/stories/' . $menu_image . '" border="0" alt="' . $mitem->name . '"/>';
             if ($params->get('menu_images_align')) {
                 $txt = $txt . ' ' . $image;
             } else {
                 $txt = $image . ' ' . $txt;
             }
         }
     }
     return $txt;
 }
Exemplo n.º 28
0
/**
* Content Search method
*
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
*/
function botSearchContent($text, $phrase = '', $ordering = '')
{
    global $database, $my, $_MAMBOTS;
    // check if param query has previously been processed
    if (!isset($_MAMBOTS->_search_mambot_params['content'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'content.searchbot'" . "\n AND folder = 'search'";
        $database->setQuery($query);
        $database->loadObject($mambot);
        // save query to class variable
        $_MAMBOTS->_search_mambot_params['content'] = $mambot;
    }
    // pull query data from class variable
    $mambot = $_MAMBOTS->_search_mambot_params['content'];
    $botParams = new mosParameters($mambot->params);
    $limit = $botParams->def('search_limit', 50);
    $nonmenu = $botParams->def('nonmenu', 1);
    $nullDate = $database->getNullDate();
    $now = _CURRENT_SERVER_TIME;
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $wheres = array();
    switch ($phrase) {
        case 'exact':
            $wheres2 = array();
            $wheres2[] = "LOWER(a.title) LIKE LOWER('%{$text}%')";
            $wheres2[] = "LOWER(a.introtext) LIKE LOWER('%{$text}%')";
            $wheres2[] = "LOWER(a.fulltext) LIKE LOWER('%{$text}%')";
            $wheres2[] = "LOWER(a.metakey) LIKE LOWER('%{$text}%')";
            $wheres2[] = "LOWER(a.metadesc) LIKE LOWER('%{$text}%')";
            $where = '(' . implode(') OR (', $wheres2) . ')';
            break;
        case 'all':
        case 'any':
        default:
            $words = explode(' ', $text);
            $wheres = array();
            foreach ($words as $word) {
                $wheres2 = array();
                $wheres2[] = "LOWER(a.title) LIKE LOWER('%{$word}%')";
                $wheres2[] = "LOWER(a.introtext) LIKE LOWER('%{$word}%')";
                $wheres2[] = "LOWER(a.fulltext) LIKE LOWER('%{$word}%')";
                $wheres2[] = "LOWER(a.metakey) LIKE LOWER('%{$word}%')";
                $wheres2[] = "LOWER(a.metadesc) LIKE LOWER('%{$word}%')";
                $wheres[] = implode(' OR ', $wheres2);
            }
            $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
            break;
    }
    $morder = '';
    switch ($ordering) {
        case 'oldest':
            $order = 'a.created ASC';
            break;
        case 'popular':
            $order = 'a.hits DESC';
            break;
        case 'alpha':
            $order = 'a.title ASC';
            break;
        case 'category':
            $order = 'b.title ASC, a.title ASC';
            $morder = 'a.title ASC';
            break;
        case 'newest':
        default:
            $order = 'a.created DESC';
            break;
    }
    // search content items
    $query = "SELECT a.title AS title," . "\n a.created AS created," . "\n CONCAT(a.introtext, a.fulltext) AS text," . "\n CONCAT_WS( '/', u.title, b.title ) AS section," . "\n CONCAT( 'index.php?option=com_content&task=view&id=', a.id ) AS href," . "\n '2' AS browsernav," . "\n 'content' AS type" . "\n, u.id AS sec_id, b.id as cat_id" . "\n FROM #__content AS a" . "\n INNER JOIN #__categories AS b ON b.id=a.catid" . "\n INNER JOIN #__sections AS u ON u.id = a.sectionid" . "\n WHERE ( {$where} )" . "\n AND a.state = 1" . "\n AND u.published = 1" . "\n AND b.published = 1" . "\n AND a.access <= " . (int) $my->gid . "\n AND b.access <= " . (int) $my->gid . "\n AND u.access <= " . (int) $my->gid . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )" . "\n GROUP BY a.id" . "\n ORDER BY {$order}";
    $database->setQuery($query, 0, $limit);
    $list = $database->loadObjectList();
    // search static content
    $query = "SELECT a.title AS title," . "\n a.created AS created," . "\n a.introtext AS text," . "\n " . $database->Quote(_STATIC_CONTENT) . " AS section," . "\n CONCAT( 'index.php?option=com_content&task=view&id=', a.id, '&Itemid=', m.id ) AS href," . "\n '2' AS browsernav," . "\n a.id" . "\n FROM #__content AS a" . "\n LEFT JOIN #__menu AS m ON m.componentid = a.id" . "\n WHERE ({$where})" . "\n AND a.state = 1" . "\n AND a.access <= " . (int) $my->gid . "\n AND m.type = 'content_typed'" . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )" . "\n GROUP BY a.id" . "\n ORDER BY " . ($morder ? $morder : $order);
    $database->setQuery($query, 0, $limit);
    $list2 = $database->loadObjectList();
    // search archived content
    $query = "SELECT a.title AS title," . "\n a.created AS created," . "\n a.introtext AS text," . "\n CONCAT_WS( '/', " . $database->Quote(_SEARCH_ARCHIVED) . ", u.title, b.title ) AS section," . "\n CONCAT('index.php?option=com_content&task=view&id=',a.id) AS href," . "\n '2' AS browsernav," . "\n 'content' AS type" . "\n FROM #__content AS a" . "\n INNER JOIN #__categories AS b ON b.id=a.catid" . "\n INNER JOIN #__sections AS u ON u.id = a.sectionid" . "\n WHERE ( {$where} )" . "\n AND a.state = -1" . "\n AND u.published = 1" . "\n AND b.published = 1" . "\n AND a.access <= " . (int) $my->gid . "\n AND b.access <= " . (int) $my->gid . "\n AND u.access <= " . (int) $my->gid . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )" . "\n ORDER BY {$order}";
    $database->setQuery($query, 0, $limit);
    $list3 = $database->loadObjectList();
    // check if search of nonmenu linked static content is allowed
    if ($nonmenu) {
        // collect ids of static content items linked to menu items
        // so they can be removed from query that follows
        $ids = null;
        if (count($list2)) {
            foreach ($list2 as $static) {
                $ids[] = (int) $static->id;
            }
            $ids = "a.id != " . implode(" OR a.id != ", $ids);
        }
        // search static content not connected to a menu
        $query = "SELECT a.title AS title," . "\n a.created AS created," . "\n a.introtext AS text," . "\n '2' as browsernav, " . $database->Quote(_STATIC_CONTENT) . " AS section," . "\n CONCAT( 'index.php?option=com_content&task=view&id=', a.id ) AS href," . "\n a.id" . "\n FROM #__content AS a" . "\n WHERE ({$where})" . ($ids ? "\n AND ( {$ids} )" : '') . "\n AND a.state = 1" . "\n AND a.access <= " . (int) $my->gid . "\n AND a.sectionid = 0" . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )" . "\n ORDER BY " . ($morder ? $morder : $order);
        $database->setQuery($query, 0, $limit);
        $list4 = $database->loadObjectList();
    } else {
        $list4 = array();
    }
    return array_merge($list, $list2, $list3, (array) $list4);
}
Exemplo n.º 29
0
/**
* Assembles head tags
*/
function mosShowHead()
{
    global $database, $option, $my, $mainframe, $_VERSION, $task, $id;
    global $mosConfig_MetaDesc, $mosConfig_MetaKeys, $mosConfig_live_site, $mosConfig_sef, $mosConfig_absolute_path, $mosConfig_sitename, $mosConfig_favicon;
    $mainframe->appendMetaTag('description', $mosConfig_MetaDesc);
    $mainframe->appendMetaTag('keywords', $mosConfig_MetaKeys);
    $mainframe->addMetaTag('Generator', $_VERSION->PRODUCT . ' - ' . $_VERSION->COPYRIGHT);
    $mainframe->addMetaTag('robots', 'index, follow');
    // cache activation
    if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
        $cache =& mosCache::getCache('com_content');
        echo $cache->call('mainframe->getHead', @$_SERVER['QUERY_STRING'], $id);
    } else {
        echo $mainframe->getHead();
    }
    if (isset($mosConfig_sef) && $mosConfig_sef) {
        echo "<base href=\"{$mosConfig_live_site}/\" />\r\n";
    }
    if ($my->id || $mainframe->get('joomlaJavascript')) {
        ?>
		<script src="<?php 
        echo $mosConfig_live_site;
        ?>
/includes/js/joomla.javascript.js" type="text/javascript"></script>
		<?php 
    }
    $row = new mosComponent($database);
    $query = "SELECT a.*" . "\n FROM #__components AS a" . "\n WHERE ( a.admin_menu_link = 'option=com_syndicate' OR a.admin_menu_link = 'option=com_syndicate&hidemainmenu=1' )" . "\n AND a.option = 'com_syndicate'";
    $database->setQuery($query);
    $database->loadObject($row);
    // get params definitions
    $syndicateParams = new mosParameters($row->params, $mainframe->getPath('com_xml', $row->option), 'component');
    // needed to reduce query
    $GLOBALS['syndicateParams'] = $syndicateParams;
    $live_bookmark = $syndicateParams->get('live_bookmark', 0);
    // and to allow disabling/enabling of selected feed types
    switch ($live_bookmark) {
        case 'RSS0.91':
            if (!$syndicateParams->get('rss091', 1)) {
                $live_bookmark = 0;
            }
            break;
        case 'RSS1.0':
            if (!$syndicateParams->get('rss10', 1)) {
                $live_bookmark = 0;
            }
            break;
        case 'RSS2.0':
            if (!$syndicateParams->get('rss20', 1)) {
                $live_bookmark = 0;
            }
            break;
        case 'ATOM0.3':
            if (!$syndicateParams->get('atom03', 1)) {
                $live_bookmark = 0;
            }
            break;
    }
    // support for Live Bookmarks ability for site syndication
    if ($live_bookmark) {
        $show = 1;
        $link_file = $mosConfig_live_site . '/index2.php?option=com_rss&feed=' . $live_bookmark . '&no_html=1';
        // xhtml check
        $link_file = ampReplace($link_file);
        // security chcek
        $check = $syndicateParams->def('check', 1);
        if ($check) {
            // test if rssfeed module is published
            // if not disable access
            $query = "SELECT m.id" . "\n FROM #__modules AS m" . "\n WHERE m.module = 'mod_rssfeed'" . "\n AND m.published = 1";
            $database->setQuery($query);
            $check = $database->loadResultArray();
            if (empty($check)) {
                $show = 0;
            }
        }
        // outputs link tag for page
        if ($show) {
            // test if security check is enbled
            ?>
			<link rel="alternate" type="application/rss+xml" title="<?php 
            echo $mosConfig_sitename;
            ?>
" href="<?php 
            echo $link_file;
            ?>
" />
			<?php 
        }
    }
    // favourites icon
    if (!$mosConfig_favicon) {
        $mosConfig_favicon = 'favicon.ico';
    }
    $icon = $mosConfig_absolute_path . '/images/' . $mosConfig_favicon;
    // checks to see if file exists
    if (!file_exists($icon)) {
        $icon = $mosConfig_live_site . '/images/favicon.ico';
    } else {
        $icon = $mosConfig_live_site . '/images/' . $mosConfig_favicon;
    }
    // outputs link tag for page
    ?>
	<link rel="shortcut icon" href="<?php 
    echo $icon;
    ?>
" />
	<?php 
}