Ejemplo n.º 1
0
/**
* Saves the record from an edit form submit
* @param string The current GET/POST option
*/
function saveSyndicate($option)
{
    global $database;
    josSpoofCheck();
    $params = mosGetParam($_POST, 'params', '');
    if (is_array($params)) {
        $txt = array();
        foreach ($params as $k => $v) {
            $txt[] = "{$k}={$v}";
        }
        $_POST['params'] = mosParameters::textareaHandling($txt);
    }
    $id = intval(mosGetParam($_POST, 'id', '17'));
    $row = new mosComponent($database);
    $row->load($id);
    if (!$row->bind($_POST)) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $msg = 'Settings successfully Saved';
    mosRedirect('index2.php?option=' . $option, $msg);
}
Ejemplo n.º 2
0
 /**
  * @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($uid);
     $row = new mosComponent($database);
     // load the row from the db table
     $row->load($menu->componentid);
     // fail if checked out not by 'me'
     if ($menu->checked_out && $menu->checked_out != $my->id) {
         echo "<script>alert('" . sprintf(T_('"The module %s is currently being edited by another administrator'), $menu->title) . "'); document.location.href='index2.php?option={$option}'</script>\n";
         exit(0);
     }
     if ($uid) {
         // do stuff for existing item
         $menu->checkout($my->id);
     } else {
         // do stuff for new item
         $menu->type = 'components';
         $menu->menutype = $menutype;
         $menu->browserNav = 0;
         $menu->ordering = 9999;
         $menu->parent = intval(mosGetParam($_POST, 'parent', 0));
         $menu->published = 1;
     }
     $query = "SELECT c.id AS value, c.name AS text, c.link" . "\n FROM #__components AS c" . "\n WHERE c.link <> ''" . "\n ORDER BY c.name";
     $database->setQuery($query);
     $components = $database->loadObjectList();
     // build the html select list for section
     $lists['componentid'] = mosAdminMenus::Component($menu, $uid);
     // componentname
     $lists['componentname'] = mosAdminMenus::ComponentName($menu, $uid);
     // 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 mosAdminParameters($menu->params, $mainframe->getPath('com_xml', $row->option), 'component');
     components_menu_html::edit($menu, $components, $lists, $params, $option);
 }
Ejemplo n.º 3
0
 /**
  * @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);
     $row = new mosComponent($database);
     // load the row from the db table
     $row->load((int) $menu->componentid);
     // 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) {
         // do stuff for existing item
         $menu->checkout($my->id);
     } else {
         // do stuff for new item
         $menu->type = 'components';
         $menu->menutype = $menutype;
         $menu->browserNav = 0;
         $menu->ordering = 9999;
         $menu->parent = intval(mosGetParam($_POST, 'parent', 0));
         $menu->published = 1;
     }
     $query = "SELECT c.id AS value, c.name AS text, c.link" . "\n FROM #__components AS c" . "\n WHERE c.link != ''" . "\n ORDER BY c.name";
     $database->setQuery($query);
     $components = $database->loadObjectList();
     // build the html select list for section
     $lists['componentid'] = mosAdminMenus::Component($menu, $uid);
     // componentname
     $lists['componentname'] = mosAdminMenus::ComponentName($menu, $uid);
     // 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('com_xml', $row->option), 'component');
     components_menu_html::edit($menu, $components, $lists, $params, $option);
 }
Ejemplo n.º 4
0
Archivo: rss.php Proyecto: cwcw/cms
/**
* @version $Id: rss.php,v 1.16 2004/09/19 15:38:45 prazgod Exp $
* @package Mambo_4.5
* @copyright (C) 2000 - 2004 Miro International Pty Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* Mambo is Free Software
*/
/** ensure this file is being included by a parent file */
defined('_VALID_MOS') or die('Direct Access to this location is not allowed.');
require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/feedcreator.class.php';
global $database, $mainframe, $my, $Itemid;
$query = "SELECT a.id" . "\n FROM #__components AS a" . "\n WHERE a.name = 'Syndicate'";
$database->setQuery($query);
$id = $database->loadResult();
$component = new mosComponent($database);
$component->load($id);
$params =& new mosParameters($component->params);
// parameters
$now = date('Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60);
$info['date'] = date('r');
$info['year'] = date('Y');
$info['encoding'] = split('=', _ISO);
$info['link'] = htmlspecialchars($mosConfig_sitename);
$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', 'Powered by Mambo 4.5.1');
$info['description'] = $params->def('description', 'Mambo site syndication');
$info['image_file'] = $params->def('image_file', 'mambo_rss.png');
if ($info['image_file'] == -1) {
Ejemplo n.º 5
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);
}
Ejemplo n.º 6
0
function feedFrontpage($showFeed)
{
    global $database, $mainframe;
    global $mosConfig_live_site, $mosConfig_offset, $mosConfig_sef, $mosConfig_absolute_path;
    // get id of the syndication component
    $query = "SELECT a.id" . "\n FROM #__components AS a" . "\n WHERE a.name = 'Syndicate'";
    $database->setQuery($query);
    $id = $database->loadResult();
    // load the row from the database table
    $row = new mosComponent($database);
    $row->load($id);
    // get syndication param definitions
    $params =& new mosParameters($row->params, $mainframe->getPath('com_xml', $row->option), 'component');
    $query = "SELECT id FROM #__modules WHERE published=1 AND module='mod_rssfeed'";
    $database->setQuery($query);
    if (!$database->loadResult()) {
        mosNotAuth();
        return;
    }
    $now = date('Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60);
    $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', 'Powered by Mambo');
    $info['description'] = $params->def('description', 'Mambo site syndication');
    $info['image_file'] = $params->def('image_file', 'mambo_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 Mambo');
    $info['limit_text'] = $params->def('limit_text', 1);
    $info['text_length'] = $params->def('text_length', 20);
    // get feed type from url
    $info['feed'] = mosGetParam($_GET, 'feed', 'RSS2.0');
    // live bookmarks
    $info['live_bookmark'] = $params->def('live_bookmark', '');
    $info['bookmark_file'] = $params->def('bookmark_file', '');
    // content to syndicate
    //	$info[ 'content' ]		= $params->def( 'content', -1 );
    // set filename for live bookmarks feed
    if (!$showFeed & $info['live_bookmark']) {
        if ($info['bookmark_file']) {
            // custom bookmark filename
            $info['file'] = $mosConfig_absolute_path . '/cache/' . $info['bookmark_file'];
        } else {
            // standard bookmark filename
            $info['file'] = $mosConfig_absolute_path . '/cache/' . $info['live_bookmark'];
        }
    } else {
        // set filename for rss feeds
        $info['file'] = getFeedType($info['feed']);
        if (!$info['file']) {
            return;
        }
    }
    // 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;
    }
    $join = "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id";
    $_and = '';
    // query of frontpage content items
    $query = "SELECT a.*, u.name AS author, u.usertype" . "\n FROM #__content AS a" . $join . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n WHERE a.state = '1'" . $_and . "\n AND a.access = 0" . "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '" . $now . "' )" . "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '" . $now . "' )" . "\n ORDER BY " . $orderby . ($info['count'] ? "\n LIMIT " . $info['count'] : '');
    $database->setQuery($query);
    $rows = $database->loadObjectList();
    foreach ($rows as $row) {
        // title for particular item
        $item_title = htmlspecialchars($row->title);
        $item_title = html_entity_decode($item_title);
        // article author
        $item_author = $row->author;
        $ItemID = $mainframe->getItemid($row->id);
        if ($ItemID == 0) {
            //If the content item is not tied to a menu and the ItemID is 0 then the URL fails with SEF on
            //Reset to frontpage if this is the case
            $ItemID = 1;
        }
        // url link to article (& used instead of &amp; as this is converted by feed creator)
        /* Build the $item_link a bit differently for SEF since sefRelToAbs doesn't convert the URL properly when 
        		passed $mosConfig_live_site.  No SEF needs $mosConfig_live_site, else &amp; becomes an issue. */
        if ($mosConfig_sef == 1) {
            $item_link = 'index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $ItemID;
        } else {
            $item_link = $mosConfig_live_site . '/index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $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->author = $item_author;
        // loads item info into rss array
        $rss->addItem($item);
    }
    // save feed file
    $rss->saveFeed($info['feed'], $info['file'], $showFeed);
}