Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function mb_str_split($str, $length = 1) {
- if ($length < 1) {
- return FALSE;
- }
- $result = array( );
- $i = 0;
- while ($i < mb_strlen( $str )) {
- $result[] = mb_substr( $str, $i, $length );
- $i += $length;
- }
- return $result;
- }
- function mb_substr_replace($string, $replacement, $start, $length = null, $encoding = null) {
- if (extension_loaded( 'mbstring' ) === true) {
- $string_length = (is_null( $encoding ) === true ? mb_strlen( $string ) : mb_strlen( $string, $encoding ));
- if ($start < 0) {
- $start = max( 0, $string_length + $start );
- }
- else {
- if ($string_length < $start) {
- $start = $string_length;
- }
- }
- if ($length < 0) {
- $length = max( 0, $string_length - $start + $length );
- }
- else {
- if (( is_null( $length ) === true || $string_length < $length )) {
- $length = $string_length;
- }
- }
- if ($string_length < $start + $length) {
- $length = $string_length - $start;
- }
- if (is_null( $encoding ) === true) {
- return mb_substr( $string, 0, $start ) . $replacement . mb_substr( $string, $start + $length, $string_length - $start - $length );
- }
- return mb_substr( $string, 0, $start, $encoding ) . $replacement . mb_substr( $string, $start + $length, $string_length - $start - $length, $encoding );
- }
- return (is_null( $length ) === true ? substr_replace( $string, $replacement, $start ) : substr_replace( $string, $replacement, $start, $length ));
- }
- function doTranslate($content, $call) {
- while (true) {
- Gtranslate;
- $gt = new ( );
- $body_split = FALSE;
- $tbody = '';
- $ttitle = '';
- if (200 < mb_strlen( $content )) {
- $body_array = mb_str_split( $content, 200 );
- $body_split = TRUE;
- $tmp_array = $body_array;
- $tmp_keys = array_keys( $tmp_array );
- unset( $tmp_keys[0] );
- foreach ($tmp_keys as $key) {
- $pos = mb_strpos( $body_array[$key], '. ' );
- $body_array[$key - 1] = $body_array[$key - 1] . mb_substr( $body_array[$key], 0, $pos + 1 );
- $body_array[$key] = mb_substr_replace( $body_array[$key], '', 0, $pos + 1 );
- }
- if ($body_split) {
- $tbody_array = array( );
- $chunk_failed = FALSE;
- foreach ($body_array as $key => $chunk) {
- $tbody_array[$key] = $gt->$call( $chunk );
- GTranslateException {
- echo $ge->getMessage( ) . '
- ';
- $chunk_failed = TRUE;
- continue;
- }
- break;
- }
- $content = implode( '', $tbody_array );
- break;
- }
- }
- $content = $gt->$call( $content );
- GTranslateException {
- echo $ge->getMessage( ) . '
- ';
- $chunk_failed = TRUE;
- }
- }
- return $content;
- }
- function isImage($fileName) {
- static $imageTypes = 'xcf|odg|gif|jpg|png|bmp';
- return preg_match( '' . '/' . $imageTypes . '/i', $fileName );
- }
- function downloadImages($content, $dir) {
- static $sources = array( 0 => 'fulltext', 1 => 'introtext' );
- $allowed_types = array( 'png', 'gif', 'jpg' );
- $pattern = '/<img\s+.*?src=[\"\'](.*?)[\'\"]\s*.*?\/?\>/';
- $local_imgs = JPATH_ROOT . DS . 'images/' . $dir . DS;
- foreach ($sources as $source) {
- if (empty( $content[$source] )) {
- continue;
- }
- preg_match_all( $pattern, $content[$source], $matches );
- if (0 < sizeof( $matches[1] )) {
- foreach ($matches[1] as $image) {
- $ext = strtolower( JFile::getext( $image ) );
- if (!in_array( $ext, $allowed_types )) {
- continue;
- }
- $local_img_name = md5( $image ) . ( '' . '.' . $ext );
- if (FALSE === is_file( $local_imgs . $local_img_name )) {
- file_put_contents( $local_imgs . $local_img_name, file_get_contents( $image ) );
- }
- $content[$source] = str_replace( $image, 'images/' . $dir . DS . $local_img_name, $content[$source] );
- }
- continue;
- }
- }
- }
- function doSynonyms($content, $synonym_words) {
- mb_internal_encoding( 'UTF-8' );
- mb_regex_encoding( 'UTF-8' );
- $synonym_lines = preg_split( '/;/', $synonym_words, 0 - 1, PREG_SPLIT_NO_EMPTY );
- $synonyms = array( );
- foreach ($synonym_lines as $synonym_line) {
- $synonym = preg_split( '/=/', $synonym_line, 0 - 1, PREG_SPLIT_NO_EMPTY );
- if (1 < sizeof( $synonym )) {
- $synonym_replacements = preg_split( '/,/', $synonym[1], 0 - 1, PREG_SPLIT_NO_EMPTY );
- $synonyms[$synonym[0]] = $synonym_replacements[rand( 0, sizeof( $synonym_replacements ) - 1 )];
- continue;
- }
- }
- if (sizeof( $synonyms )) {
- $minkeylen = min( array_keys( $synonyms ) );
- $newContent = '';
- $htmlregex = '#({*\s*.*?}|<a .*?</a\\ *>|<h[1-7].*?</h[1-7]\\ *>|<script[\s\S]*?<\/script>|</?.*?>|\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>)#i';
- $bits = preg_split( $htmlregex, $content );
- preg_match_all( $htmlregex, $content, $matches );
- foreach ($bits as $i => $bit) {
- if ($minkeylen <= strlen( $bit )) {
- foreach ($synonyms as $word => $synonym) {
- $bit = mb_eregi_replace( '\b(' . $word . ')\b', $synonym, $bit );
- }
- }
- $newContent .= $bit;
- if (isset( $matches[0][$i] )) {
- $newContent .= $matches[0][$i];
- continue;
- }
- }
- $content = $newContent;
- }
- return $content;
- }
- if (!( defined( '_JEXEC' ))) {
- exit( 'Restricted access' );
- (bool)true;
- }
- mb_internal_encoding( 'UTF-8' );
- jimport( 'joomla.application.component.controller' );
- require( 'gtranslate-api-php/GTranslate.php' );
- if (is_dir( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_frontpage' . DS )) {
- require_once( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_frontpage' . DS . 'tables' . DS . 'frontpage.php' );
- }
- else {
- class TableFrontPage extends JTable {
- var $content_id = null;
- var $ordering = null;
- function __construct($db) {
- parent::( '#__content_frontpage', 'content_id', $db );
- }
- }
- }
- jimport( 'joomla.filesystem.file' );
- if (is_dir( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_advanced_tags' . DS )) {
- $advanced_tags_check = &JComponentHelper::getcomponent( 'com_advanced_tags' );
- }
- if (!empty( $advanced_tags_check->id )) {
- jimport( 'joomla.application.component.model' );
- require_once( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_advanced_tags' . DS . 'models' . DS . 'tag.php' );
- require_once( JPATH_SITE . DS . 'components' . DS . 'com_advanced_tags' . DS . 'helper' . DS . 'helper.php' );
- class AggregatorAdvancedTagsImporter extends Advanced_tagsModelTag {
- var $_meta = '';
- function __construct($meta, $id) {
- $this->_db = &JFactory::getdbo( );
- $this->_id = $id;
- $this->_meta = $meta;
- }
- function termCheck($term) {
- $ignoreNumericTags = AdvancedTagsHelper::param( 'IgnoeNumericTags', 0 );
- if ($ignoreNumericTags) {
- if (is_numeric( $term )) {
- echo 'ignore:' . $term;
- return false;
- }
- }
- $minTagLength = AdvancedTagsHelper::param( 'MinTagLength', 1 );
- $len = JString::strlen( $term );
- if ($len < $minTagLength) {
- return false;
- }
- return true;
- }
- function import() {
- if (( isset( $this->_meta ) && empty( $this->_meta ) == false )) {
- $cid = $this->_id;
- if (!$this->isContentHasTags( $cid )) {
- $keys = explode( ',', $this->_meta );
- $keysProcessed = array( );
- foreach ($keys as $key) {
- $key = AdvancedTagsHelper::prehandle( $key );
- if (empty( $key ) == false) {
- if (!in_array( $key, $keysProcessed )) {
- $keysProcessed[] = $key;
- continue;
- }
- continue;
- }
- }
- unset( $keys );
- $deleteTags = 'delete from #__tag_term_content where cid=' . $cid;
- $this->_db->setQuery( $deleteTags );
- $this->_db->query( );
- foreach ($keysProcessed as $key) {
- $pass = $this->termCheck( $key );
- if ($pass) {
- $tid = $this->storeTerm( $key );
- $this->insertContentterm( $tid, $cid );
- continue;
- }
- }
- }
- }
- }
- }
- }
- class AggregatorController extends JController {
- function __construct($config = array( )) {
- $task = JRequest::getcmd( 'task' );
- if ($task != 'cron') {
- xajax;
- $xajax = new ( );
- $xajax->registerFunction( array( 'importfeed', $this, 'importfeed' ) );
- $xajax->registerFunction( array( 'importall', $this, 'importall' ) );
- }
- parent::( $config );
- if ($task != 'cron') {
- $xajax->processRequests( );
- }
- }
- function walkCatTree(&$categories, $cattree, $branch_id, $level) {
- if (FALSE === empty( $cattree[$branch_id]['title'] )) {
- $categories[] = array( 'id' => $cattree[$branch_id]['id'], 'title' => str_repeat( '- ', $level ) . $cattree[$branch_id]['title'] );
- }
- reset( $cattree[$branch_id]['children'] );
- while (list( , $child_id ) = each( $cattree[$branch_id]['children'] )) {
- self::walkcattree( $categories, $cattree, $child_id, $level + 1 );
- }
- }
- function about() {
- $view = &$this->getView( 'aggregator', 'html' );
- $view->display( 'about' );
- }
- function support() {
- $view = &$this->getView( 'aggregator', 'html' );
- $view->display( 'support' );
- }
- function feeds() {
- $mainframe = JFactory::getapplication( );
- $db = &JFactory::getdbo( );
- $context = 'com_aggregator.feeds';
- $option = JRequest::getcmd( 'option' );
- $limit = $mainframe->getUserStateFromRequest( $context . 'viewlistlimit', 'limit', 10, 'int' );
- $limitstart = $mainframe->getUserStateFromRequest( $context . 'view' . $option . 'limitstart', 'limitstart', 0, 'int' );
- $search = $mainframe->getUserStateFromRequest( '' . 'search' . $option, 'search', '', 'word' );
- $search = JString::strtolower( $search );
- $filter_order = $mainframe->getUserStateFromRequest( $context . 'filter_order', 'filter_order', '', 'cmd' );
- $filter_order_Dir = $mainframe->getUserStateFromRequest( $context . 'filter_order_Dir', 'filter_order_Dir', '', 'word' );
- if (!$filter_order) {
- $filter_order = 'f.id';
- }
- $order = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . ', f.id';
- $where = array( );
- if ($search) {
- $where[] = '(LOWER( f.title ) LIKE ' . $db->Quote( '%' . $db->getEscaped( $search, true ) . '%', false ) . ' OR f.id = ' . (int)$search . ')';
- }
- $where = (count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '');
- $db->setQuery( 'SELECT count(*) FROM #__aggregator AS f' . ' LEFT JOIN #__categories AS cc ON cc.id = f.catid' . $where );
- $total = $db->loadResult( );
- if (!$db->query( )) {
- JError::raiseerror( 500, $db->getErrorMsg( ) );
- return false;
- }
- jimport( 'joomla.html.pagination' );
- JPagination;
- $pagination = new ( $total, $limitstart, $limit );
- $db->setQuery( 'SELECT f.*,cc.title AS cat_name, NULL AS section_name, u.name AS editor FROM #__aggregator f' . ' LEFT JOIN #__categories AS cc ON cc.id = f.catid' . ' LEFT JOIN #__users AS u ON u.id = f.checked_out ' . $where . $order, $pagination->limitstart, $pagination->limit );
- $rows = $db->loadObjectList( );
- if ($db->getErrorNum( )) {
- JError::raiseerror( 500, $db->stderr( ) );
- return false;
- }
- $lists['order_Dir'] = $filter_order_Dir;
- $lists['order'] = $filter_order;
- $lists['search'] = $search;
- $view = &$this->getView( 'aggregator', 'html' );
- $view->assignRef( 'rows', $rows );
- $view->assignRef( 'page', $pagination );
- $view->assignRef( 'search', $search );
- $view->assignRef( 'lists', $lists );
- $view->display( );
- }
- function editContent($edit) {
- $mainframe = JFactory::getapplication( );
- $db = &JFactory::getdbo( );
- $user = &JFactory::getuser( );
- $cid = JRequest::getvar( 'cid', array( 0 ), '', 'array' );
- JArrayHelper::tointeger( $cid, array( 0 ) );
- $id = JRequest::getvar( 'id', $cid[0], '', 'int' );
- $option = JRequest::getcmd( 'option' );
- $nullDate = $db->getNullDate( );
- $contentSection = '';
- $sectionid = 0;
- $model = &$this->getModel( 'feed' );
- $feed = $model->getData( );
- JParameter;
- $params = new ( $feed->params );
- if ($model->isCheckedOut( $user->get( 'id' ) )) {
- $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The feed' ), $feed->title );
- $mainframe->redirect( 'index.php?option=com_aggregator', $msg );
- }
- if ($id) {
- $model->checkout( $user->get( 'id' ) );
- jimport( 'joomla.utilities.date' );
- JDate;
- $createdate = new ( $feed->created );
- $feed->created = $createdate->toUnix( );
- }
- else {
- if ($_POST['catid']) {
- $row->catid = $_POST['catid'];
- $category = &JTable::getinstance( 'category' );
- $category->load( $row->catid );
- }
- else {
- $row->catid = NULL;
- }
- $row->sectionid = $sectionid;
- }
- $categories = array( );
- $categories[] = JHTML::_( 'select.option', '-1', JText::_( 'Select Category' ), 'id', 'title' );
- $options = array( );
- $db->setQuery( 'select id, title, parent_id from #__categories where published IN (0,1) and extension in (\'com_content\') order by id ASC' );
- $options = $db->loadObjectList( );
- $cattree = array( '1' => array( 'children' => array( ) ) );
- $i = 0;
- while ($i < count( $options )) {
- $cattree[$options[$i]->id] = array( 'id' => $options[$i]->id, 'title' => $options[$i]->title, 'children' => array( ) );
- $cattree[$options[$i]->parent_id]['children'][] = $options[$i]->id;
- ++$i;
- }
- self::walkcattree( $categories, $cattree, '1', 0 - 1 );
- if ($feed->catid) {
- $lists['catid'] = JHTML::_( 'select.genericlist', $categories, 'catid', 'class="inputbox" size="1"', 'id', 'title', intval( $feed->catid ) );
- }
- else {
- $lists['catid'] = JHTML::_( 'select.genericlist', $categories, 'catid', 'class="inputbox" size="1"', 'id', 'title' );
- }
- if (is_dir( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS )) {
- $component_check = &JComponentHelper::getcomponent( 'com_k2' );
- }
- if ($k2_installed = (!empty( $component_check->id ) ? 1 : 0)) {
- $query = 'SELECT id, name FROM #__k2_categories ORDER BY ordering';
- $db->setQuery( $query );
- $k2categories[] = JHTML::_( 'select.option', '-1', JText::_( 'Select Category' ), 'id', 'name' );
- $k2categories = array_merge( $k2categories, $db->loadObjectList( ) );
- $lists['k2catid'] = JHTML::_( 'select.genericlist', $k2categories, 'params[k2catid]', 'class="inputbox" size="1"', 'id', 'name', $params->get( 'k2catid', '0' ) );
- }
- $read_more_pos[] = JHTML::_( 'select.option', '0', 'Default', 'id', 'title' );
- $read_more_pos[] = JHTML::_( 'select.option', '1', 'No introtext', 'id', 'title' );
- $read_more_pos[] = JHTML::_( 'select.option', '2', 'After "Before item"', 'id', 'title' );
- $read_more_pos[] = JHTML::_( 'select.option', '3', 'After "Content"', 'id', 'title' );
- $read_more_pos[] = JHTML::_( 'select.option', '4', 'Only introtext', 'id', 'title' );
- $lists['read_more_pos'] = JHTML::_( 'select.genericlist', $read_more_pos, 'params[read_more_pos]', 'class="inputbox" size="1"', 'id', 'title', $params->get( 'read_more_pos', '0' ) );
- $insert_title_in_content[] = JHTML::_( 'select.option', '', 'No', 'id', 'title' );
- $insert_title_in_content[] = JHTML::_( 'select.option', 'before', 'Before item', 'id', 'title' );
- $insert_title_in_content[] = JHTML::_( 'select.option', 'after', 'After item', 'id', 'title' );
- $lists['insert_title_in_content'] = JHTML::_( 'select.genericlist', $insert_title_in_content, 'params[insert_title_in_content]', 'class="inputbox" size="1"', 'id', 'title', $params->get( 'insert_title_in_content', '' ) );
- $target_frame[] = JHTML::_( 'select.option', 'none', 'None', 'id', 'title' );
- $target_frame[] = JHTML::_( 'select.option', '_blank', '_blank', 'id', 'title' );
- $target_frame[] = JHTML::_( 'select.option', '_parent', '_parent', 'id', 'title' );
- $target_frame[] = JHTML::_( 'select.option', '_self', '_self', 'id', 'title' );
- $target_frame[] = JHTML::_( 'select.option', '_top', '_top', 'id', 'title' );
- $target_frame[] = JHTML::_( 'select.option', 'custom', 'Custom', 'id', 'title' );
- $lists['target_frame'] = JHTML::_( 'select.genericlist', $target_frame, 'params[target_frame]', 'class="inputbox" size="1"', 'id', 'title', $params->get( 'target_frame', 'none' ) );
- $access_level[] = JHTML::_( 'select.option', '1', 'Public', 'id', 'title' );
- $access_level[] = JHTML::_( 'select.option', '2', 'Registered', 'id', 'title' );
- $access_level[] = JHTML::_( 'select.option', '3', 'Special', 'id', 'title' );
- $lists['access_level'] = JHTML::_( 'select.genericlist', $access_level, 'params[access_level]', 'class="inputbox" size="1"', 'id', 'title', $params->get( 'access_level', 1 ) );
- $db->setQuery( 'SELECT `id`, `username` FROM #__users' );
- $creators = $db->loadObjectList( );
- foreach ($creators as $creator) {
- $creator_options[] = JHTML::_( 'select.option', $creator->id, $creator->username, 'id', 'title' );
- }
- $lists['creator'] = JHTML::_( 'select.genericlist', $creator_options, 'created_by', 'class="inputbox" size="1"', 'id', 'title', (!empty( $feed->created_by ) ? intval( $feed->created_by ) : $user->get( 'id' )) );
- $meta_tags_reorder[] = JHTML::_( 'select.option', 'default', 'Default (No Change) ', 'id', 'title' );
- $meta_tags_reorder[] = JHTML::_( 'select.option', 'backwards', 'Backwards', 'id', 'title' );
- $meta_tags_reorder[] = JHTML::_( 'select.option', 'shuffle', 'Shuffle', 'id', 'title' );
- $lists['meta_tags_reorder'] = JHTML::_( 'select.genericlist', $meta_tags_reorder, 'params[meta_tags_reorder]', 'class="inputbox" size="1"', 'id', 'title', $params->get( 'meta_tags_reorder', 'default' ) );
- $gt_languages = array( );
- preg_match_all( '/([\'a-zA-Z]+)\s+?=\s+?([a-zA-Z]+)?\n/', file_get_contents( dirname( __FILE__ ) . '/gtranslate-api-php/languages.ini' ), $gt_langs_matches );
- $gt_langs = array_combine( $gt_langs_matches[1], $gt_langs_matches[2] );
- $gt_langs = array_flip( array_change_key_case( $gt_langs, CASE_LOWER ) );
- asort( $gt_langs );
- foreach ($gt_langs as $k => $v) {
- $gt_languages[] = JHTML::_( 'select.option', $k, $v, 'id', 'title' );
- }
- $lists['translate_from'] = JHTML::_( 'select.genericlist', $gt_languages, 'params[translate_from]', 'class="inputbox" size="1"', 'id', 'title', $params->get( 'translate_from' ) );
- $lists['translate_to'] = JHTML::_( 'select.genericlist', $gt_languages, 'params[translate_to]', 'class="inputbox" size="1"', 'id', 'title', $params->get( 'translate_to' ) );
- if (is_dir( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_advanced_tags' . DS )) {
- $component_check = &JComponentHelper::getcomponent( 'com_advanced_tags' );
- }
- $advanced_tags_installed = (!empty( $component_check->id ) ? 1 : 0);
- $view = &$this->getView( 'aggregator', 'html' );
- $view->assignRef( 'params', $params );
- $view->assignRef( 'feed', $feed );
- $view->assignRef( 'lists', $lists );
- $view->assignRef( 'k2_installed', $k2_installed );
- $view->assignRef( 'advanced_tags_installed', $advanced_tags_installed );
- $view->display( 'new' );
- }
- function copy() {
- $mainframe = JFactory::getapplication( );
- ( JRequest::checktoken( ) || jexit( 'Invalid Token' ) );
- $db = &JFactory::getdbo( );
- $cid = JRequest::getvar( 'cid', array( ), 'post', 'array' );
- $option = JRequest::getcmd( 'option' );
- JArrayHelper::tointeger( $cid );
- $item = null;
- $total = count( $cid );
- $i = 0;
- while ($i < $total) {
- $query = 'SELECT a.*' . ' FROM #__aggregator AS a' . ' WHERE a.id = ' . (int)$cid[$i];
- $db->setQuery( $query, 0, 1 );
- $item = $db->loadObject( );
- $row = array( );
- $row['id'] = NULL;
- $row['title'] = 'Copy Of ' . $item->title;
- $row['feed'] = $item->feed;
- $row['sectionid'] = $item->sectionid;
- $row['catid'] = $item->catid;
- $row['default_author'] = $item->default_author;
- $row['created_by'] = $item->created_by;
- $row['created'] = $item->created;
- $row['cronjobs'] = $item->cronjobs;
- $row['last_run'] = $item->last_run;
- $row['published'] = 0;
- $row['front_page'] = $item->front_page;
- $row['checked_out'] = $item->checked_out;
- $row['checked_out_time'] = $item->checked_out_time;
- $row['params'] = $item->params;
- $model = $this->getModel( 'feed' );
- if ($model->store( $row )) {
- $msg = JText::_( 'Feed Copied' );
- }
- else {
- $msg = JText::_( 'Error Copying Feed' );
- }
- ++$i;
- }
- $msg = JText::sprintf( 'Item(s) successfully copied ', $total, $section, $category );
- $mainframe->redirect( 'index.php?option=' . $option, $msg );
- }
- function save() {
- if (!( JRequest::checktoken( ))) {
- exit( 'Invalid Token' );
- (bool)true;
- }
- $post = JRequest::get( 'post' );
- $cid = JRequest::getvar( 'cid', array( 0 ), 'post', 'array' );
- $post['id'] = (int)$cid[0];
- $params = JRequest::getvar( 'params', null, 'post', 'array' );
- if (is_array( $params )) {
- $txt = array( );
- foreach ($params as $k => $v) {
- $txt[] = $k . '=' . str_replace( array( '
- ', '
- ', '
- ' ), '', $v );
- }
- $post['params'] = implode( '
- ', $txt );
- }
- $model = $this->getModel( 'feed' );
- if ($model->store( $post )) {
- $msg = JText::_( 'Feed Saved' );
- }
- else {
- $msg = JText::_( 'Error Saving Feed' );
- }
- $model->checkin( );
- $link = 'index.php?option=com_aggregator';
- $this->setRedirect( $link, $msg );
- }
- function publishFeeds($publish = 1, $action = 'publish') {
- if (!( JRequest::checktoken( ))) {
- exit( 'Invalid Token' );
- (bool)true;
- }
- $cid = JRequest::getvar( 'cid', array( ), 'post', 'array' );
- JArrayHelper::tointeger( $cid );
- if (count( $cid ) < 1) {
- JError::raiseerror( 500, JText::_( 'Select an item to ' . $action ) );
- }
- $model = $this->getModel( 'feed' );
- if (!$model->publish( $cid, $publish )) {
- echo '<script> alert(\'' . $model->getError( true ) . '\'); window.history.go(-1); </script>
- ';
- }
- $this->setRedirect( 'index.php?option=com_aggregator' );
- }
- function frontpageFeeds($frontpage = 1, $action = 'front_yes') {
- if (!( JRequest::checktoken( ))) {
- exit( 'Invalid Token' );
- (bool)true;
- }
- $cid = JRequest::getvar( 'cid', array( ), 'post', 'array' );
- JArrayHelper::tointeger( $cid );
- if (count( $cid ) < 1) {
- JError::raiseerror( 500, JText::_( 'Select an item to ' . $action ) );
- }
- $model = $this->getModel( 'feed' );
- if (!$model->frontpage( $cid, $frontpage )) {
- echo '<script> alert(\'' . $model->getError( true ) . '\'); window.history.go(-1); </script>
- ';
- }
- $this->setRedirect( 'index.php?option=com_aggregator' );
- }
- function remove() {
- $mainframe = JFactory::getapplication( );
- if (!( JRequest::checktoken( ))) {
- exit( 'Invalid Token' );
- (bool)true;
- }
- $db = &JFactory::getdbo( );
- $cid = JRequest::getvar( 'cid', array( ), 'post', 'array' );
- JArrayHelper::tointeger( $cid );
- if (count( $cid ) < 1) {
- $msg = JText::_( 'Select an item to delete' );
- $mainframe->redirect( 'index.php?option=com_aggregator', $msg, 'error' );
- }
- $model = $this->getModel( 'feed' );
- if (!$model->delete( $cid, $frontpage )) {
- echo '<script> alert(\'' . $model->getError( true ) . '\'); window.history.go(-1); </script>
- ';
- }
- $msg = JText::sprintf( 'Item(s) deleted', count( $cid ) );
- $mainframe->redirect( 'index.php?option=com_aggregator', $msg );
- }
- function cancel() {
- $mainframe = JFactory::getapplication( );
- if (!( JRequest::checktoken( ))) {
- exit( 'Invalid Token' );
- (bool)true;
- }
- $db = &JFactory::getdbo( );
- $model = $this->getModel( 'feed' );
- $model->checkin( );
- $mainframe->redirect( 'index.php?option=com_aggregator' );
- }
- function importcron() {
- $db = &JFactory::getdbo( );
- $db->setQuery( 'SELECT id, cronjobs, last_run FROM #__aggregator WHERE published=1' );
- $feeds = $db->loadAssocList( );
- if (0 < sizeof( $feeds )) {
- foreach ($feeds as $feed) {
- $jobs = parseCronString( $feed['cronjobs'], $feed['last_run'] );
- $jobsRun = 0;
- foreach ($jobs as $job) {
- if (( $maxJobs == 0 || $jobsRun < $maxJobs )) {
- if (runJob( $job )) {
- $feedIds[] = $feed['id'];
- ++$jobsRun;
- continue;
- }
- continue;
- }
- }
- }
- }
- $formData = array( );
- $formData['option'] = 'com_aggregator';
- $formData['cid'] = $feedIds;
- $this->importFeed( $formData );
- }
- function importall() {
- $db = &JFactory::getdbo( );
- $db->setQuery( 'SELECT id FROM #__aggregator WHERE published = \'1\'' );
- $feedIds = $db->loadResultArray( );
- $formData['cid'] = $feedIds;
- return $this->importfeed( $formData );
- }
- function importfeed($formData = '') {
- $db = &JFactory::getdbo( );
- $Config = JComponentHelper::getparams( 'com_aggregator' );
- xajaxResponse;
- $objResponse = new ( );
- $cid = (empty( $formData['cid'] ) ? JRequest::getvar( 'cid', array( ), 'get', 'array' ) : $formData['cid']);
- $mosMsg = '';
- $adminMsg = '';
- if ($feed->email_admin == '1') {
- $adminMsg .= '<b>Results of the last Aggregator import run:</b>
- ';
- $adminMsg .= '<div id="feedinfo"><h1>START Aggregator Import Processing: ' . date( 'D F j, Y, H:i:s T' ) . '</h1>
- ';
- }
- $objResponse->addScript( 'resetMsgArea();' );
- $objResponse->addAppend( 'fgmsgarea', 'innerHTML', $feed->target . '<br />' );
- $totItems = 0;
- $cacheDir = JPATH_BASE . DS . 'cache';
- if (( !$feed->use_sp_cache || !is_writable( $cacheDir ) )) {
- $cache_exists = false;
- }
- else {
- $cache_exists = true;
- }
- $ads = array( '<a href="http://3dwebdesign.org/">Web Design</a> from 3D Web Design.', '<a href="http://3dwebdesign.org/">Webdesign</a> from 3D WebDesign.', '<a href="http://3dwebdesign.org/en/">Web Design</a> from 3D WebDesign.', '<a href="http://3dwebdesign.org/en/">Webdesign</a> from 3D Web Design.', '<a href="http://3dwebdesign.org/en/seo-optimization/">Website optimization</a> from 3D Web Design.', '<a href="http://3dwebdesign.org/en/seo-optimization/">Seo optimization</a> from Web Design Seo.', '<a href="http://3dwebdesign.org/seo-optimization-web-site.html">Website optimization</a> from Web Design Seo.', '<a href="http://3dwebdesign.org/seo-optimization-web-site.html">Web site optimization</a> from WebDesign Seo.', '<a href="http://3dwebdesign.org/seo-services">Seo services</a> from WebDesign Seo.', '<a href="http://3dwebdesign.org/seo-services">Seo service</a> from 3D WebDesign Seo.', '<a href="http://3dwebdesign.org/en/seo-optimization-search-engine-optimization">Seo optimization</a> from 3D Web Design Seo.', '<a href="http://3dwebdesign.org/en/seo-optimization-search-engine-optimization">Seo optimization</a> from 3D WebDesign Seo.' );
- $ads_added = FALSE;
- foreach ($cid as $feedId) {
- $startTime = time( );
- $nItems = 0;
- $model = &$this->getModel( 'feed' );
- $model->setId( $feedId );
- $feed = $model->getData( );
- JParameter;
- $params = new ( $feed->params );
- $gt_call = $params->get( 'translate_from' ) . '_to_' . $params->get( 'translate_to' );
- if ($feed->published) {
- $store_table = $params->get( 'store_table', 'content' );
- $curFeed = $feed->title;
- SimplePie;
- $rssDoc = new ( );
- $myfeed = $feed->feed;
- if (get_magic_quotes_gpc( )) {
- $myfeed = stripslashes( $myfeed );
- }
- $rssDoc->set_feed_url( $myfeed );
- $output_encoding = $Config->get( 'output_encoding' );
- if (( !empty( $output_encoding ) && mb_strtolower( $output_encoding != 'utf-8' ) )) {
- $rssDoc->set_output_encoding( $Config->get( 'output_encoding' ) );
- }
- $forcefsock = $params->get( 'force_fsockopen' );
- if ($forcefsock == '1') {
- $rssDoc->force_fsockopen( true );
- }
- if ($cache_exists) {
- $rssDoc->set_cache_location( $cacheDir );
- $rssDoc->caching = true;
- $rssDoc->set_cache_duration( 60 * SPIE_CACHE_AGE );
- }
- else {
- $rssDoc->caching = false;
- }
- $rssDoc->init( );
- $rssDoc->handle_content_type( );
- if ($rssDoc->get_type( ) & SIMPLEPIE_TYPE_NONE) {
- }
- else {
- $channelTitle = $rssDoc->get_title( );
- $itemArray = $rssDoc->get_items( );
- if (is_array( $itemArray )) {
- foreach ($itemArray as $item) {
- $content = array( );
- $content['title'] = trim( $item->get_title( ) );
- $item_description = trim( $item->get_description( ) );
- if (empty( $item_description )) {
- $item_description = $content['title'];
- }
- if ($item_content = trim( $item->get_content( ) )) {
- if (!empty( $item_content )) {
- $item_description = $item_content;
- }
- }
- if ($params->get( 'show_html' ) == 0) {
- $item_description = strip_tags( $item_description );
- }
- $content['title'] = html_entity_decode( $content['title'], ENT_QUOTES );
- if ($params->get( 'strip_html_tags' ) == 1) {
- $content['title'] = strip_tags( $content['title'] );
- }
- if ($params->get( 'strip_title_specialchars' ) == '1') {
- $content['title'] = preg_replace( '/\.|»|!|„|“|”|"|#|\$|%|&|\'|\'|\(|\)|\*|\+|:|;|<|=|>|\?|@|\[|\|]|^|_|`|{|\||}|~/', '', $content['title'] );
- $content['title'] = str_replace( ',', ' ', $content['title'] );
- $content['title'] = preg_replace( '/\s\s+/', ' ', $content['title'] );
- }
- if (( $params->get( 'google_translate' ) == 1 && !empty( $content['title'] ) )) {
- $content['title'] = doTranslate( $content['title'], $gt_call );
- }
- preg_match_all( '/^before_title\d+=(.*?)$/m', $feed->params, $matches );
- $tmp_array = array_filter( $matches[1] );
- sort( $tmp_array );
- $content['title'] = (0 < $items = sizeof( $tmp_array ) ? $tmp_array[rand( 0, $items - 1 )] . ' ' : '') . $content['title'];
- preg_match_all( '/^after_title\d+=(.*?)$/m', $feed->params, $matches );
- $tmp_array = array_filter( $matches[1] );
- sort( $tmp_array );
- $content->title .= (0 < $items = sizeof( $tmp_array ) ? ' ' . $tmp_array[rand( 0, $items - 1 )] : '');
- $alias = ($params->get( 'safe_alias' ) == '1' ? md5( $content['title'] ) : JFilterOutput::stringurlsafe( $content['title'] ));
- $content['introtext'] = $item_description;
- if (JString::strpos( $content['introtext'], '<br/>' ) === 0) {
- $content['introtext'] = substr( $content['introtext'], 5 );
- }
- $trim_to = $params->get( 'trim_to' );
- if (( !empty( $trim_to ) || intval( $trim_to ) < strlen( $content['introtext'] ) )) {
- $content['introtext'] = AggregatorHelper::maketeaser( $content['introtext'], $trim_to );
- }
- $onlyintro = $params->get( 'onlyintro' );
- $intro_length = strlen( $content['introtext'] );
- if (( !$onlyintro && $intro_length < strlen( $item_description ) )) {
- $content['fulltext'] = substr( $item_description, $intro_length );
- }
- else {
- $content['fulltext'] = '';
- }
- if ($params->get( 'synonyms' )) {
- $content['title'] = doSynonyms( $content['title'], $params->get( 'synonym_words_title' ) );
- $content['introtext'] = doSynonyms( $content['introtext'], $params->get( 'synonym_words_content' ) );
- $content['fulltext'] = doSynonyms( $content['fulltext'], $params->get( 'synonym_words_content' ) );
- }
- $content['sectionid'] = $feed->sectionid;
- $content['catid'] = $feed->catid;
- $content['metakey'] = '';
- $global_keywords = array( );
- if ($params->get( 'save_feed_cats' )) {
- if ($category = $item->get_category( )) {
- $global_keywords[] = $category->get_label( );
- }
- }
- if ($params->get( 'save_sect_cats' )) {
- $sectionName = AggregatorHelper::getfieldname( $content['sectionid'], 'sections' );
- $catName = AggregatorHelper::getfieldname( $content['catid'], 'categories' );
- $global_keywords[] = $sectionName;
- $global_keywords[] = $catName;
- }
- if ($params->get( 'compute_tags' )) {
- $content->metakey .= (!empty( $content['metakey'] ) ? ',' : '');
- $clean_title = $content['title'];
- $clean_title = preg_replace( '/\.|»|!|„|“|”|"|#|\$|%|&|\'|\'|\(|\)|\*|\+|:|;|<|=|>|\?|@|\[|\|]|^|_|`|{|\||}|~/', '', $clean_title );
- $clean_title = str_replace( ',', ' ', $clean_title );
- $clean_title = preg_replace( '/\s\s+/', ' ', $clean_title );
- $words = array_filter( explode( ' ', $clean_title ) );
- $keywords = array( );
- foreach ($words as $word) {
- if ($params->get( 'min_tag_chars' ) <= mb_strlen( $word )) {
- $keywords[] = mb_strtolower( $word );
- continue;
- }
- }
- $keywords = array_slice( ($params->get( 'use_ignore_list' ) == '1' ? array_diff( $keywords, explode( ',', $params->get( 'ignore_list' ) ) ) : $keywords), 0, $params->get( 'max_tags' ) );
- }
- $keywords = array_merge( $keywords, $global_keywords );
- switch ($params->get( 'meta_tags_reorder' )) {
- case 'shuffle': {
- shuffle( $keywords );
- break;
- }
- case 'backwards': {
- $keywords = array_reverse( $keywords );
- }
- }
- $meta_tags_tmp = $params->get( 'before_meta_tags' );
- $content['metakey'] = $params->get( 'before_meta_tags' ) . (!empty( $meta_tags_tmp ) ? ',' : '');
- $content->metakey .= implode( ',', $keywords );
- $meta_tags_tmp = $params->get( 'after_meta_tags' );
- $content->metakey .= (!empty( $meta_tags_tmp ) ? ',' : '') . $params->get( 'after_meta_tags' );
- if ($params->get( 'google_translate' ) == 1) {
- if (!empty( $content['introtext'] )) {
- $content['introtext'] = doTranslate( $content['introtext'], $gt_call );
- }
- if (!empty( $content['fulltext'] )) {
- $content['fulltext'] = doTranslate( $content['fulltext'], $gt_call );
- }
- }
- $insert_title = $params->get( 'insert_title_in_content', '' );
- if (!empty( $insert_title )) {
- $orig_title = trim( $item->get_title( ) );
- switch ($insert_title) {
- case 'before': {
- $content['introtext'] = $orig_title . '. ' . $content['introtext'];
- $content['fulltext'] = $orig_title . '. ' . $content['fulltext'];
- break;
- }
- case 'after': {
- $content->introtext .= $orig_title . '. ';
- $content->fulltext .= $orig_title . '. ';
- }
- }
- }
- $shuffle_sentences_positions = $params->get( 'shuffle_sentences_positions', 0 );
- $shuffle_sentences = $params->get( 'shuffle_sentences', 0 );
- if (( $shuffle_sentences_positions || $shuffle_sentences )) {
- $htmlregex = '#({*\s*.*?}|<a .*?</a\\ *>|<h[1-7].*?</h[1-7]\\ *>|<script[\s\S]*?<\/script>|</?.*?>|\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>)#i';
- foreach (array( 'introtext', 'fulltext' ) as $current_content_text) {
- $newContent = '';
- $bits = preg_split( $htmlregex, $content[$current_content_text] );
- preg_match_all( $htmlregex, $content[$current_content_text], $matches );
- foreach ($bits as $i => $bit) {
- if (!empty( $bit )) {
- $arr = preg_split( '/[\.|!|\?]+/', preg_replace( '/".*"/e', '\'{BASE64}\'.base64_encode(\'\0\').\'{/BASE64}\'', $bit ) );
- if (!empty( $arr )) {
- $arr = array_map( 'trim', $arr );
- $arr = array_filter( $arr );
- if ($shuffle_sentences_positions) {
- shuffle( $arr );
- }
- if ($shuffle_sentences) {
- $sentences = array( );
- reset( $arr );
- while (list( , $ar ) = each( $arr )) {
- $a = array_filter( array_map( 'trim', preg_split( '/\,/', $ar ) ) );
- shuffle( $a );
- $sentences[] = ucfirst( implode( ', ', $a ) );
- }
- }
- else {
- $sentences = $arr;
- }
- $bit = preg_replace( '/{BASE64}(.*?){\/BASE64}/e', 'stripslashes(base64_decode(\'\1\'))', implode( '. ', $sentences ) );
- }
- }
- $newContent .= $bit;
- if (isset( $matches[0][$i] )) {
- $newContent .= $matches[0][$i];
- continue;
- }
- }
- $content[$current_content_text] = $newContent;
- }
- }
- preg_match_all( '/^before_item\d+=(.*?)$/m', $feed->params, $matches );
- $tmp_array = array_filter( $matches[1] );
- sort( $tmp_array );
- $before_item = (0 < $items = sizeof( $tmp_array ) ? $tmp_array[rand( 0, $items - 1 )] . ' ' : '');
- preg_match_all( '/^after_item\d+=(.*?)$/m', $feed->params, $matches );
- $tmp_array = array_filter( $matches[1] );
- sort( $tmp_array );
- $after_item = (0 < $items = sizeof( $tmp_array ) ? ' ' . $tmp_array[rand( 0, $items - 1 )] : '');
- $item_content = (empty( $full_article_text ) ? $content['introtext'] : $content['fulltext']);
- $read_more_pos = $params->get( 'read_more_pos' );
- switch ($read_more_pos) {
- case '1': {
- $content['fulltext'] = $before_item . $item_content . $after_item;
- $content['introtext'] = '';
- break;
- }
- case '2': {
- $content['fulltext'] = $item_content . $after_item;
- $content['introtext'] = $before_item;
- break;
- }
- case '3': {
- $content['introtext'] = $before_item . $item_content;
- $content['fulltext'] = $after_item;
- break;
- }
- case '4': {
- $content['introtext'] = $before_item . $item_content . $after_item;
- $content['fulltext'] = '';
- break;
- }
- default: {
- $content['introtext'] = $before_item . $content['introtext'];
- $content->(!empty( $content['fulltext'] ) ? 'fulltext' : 'introtext') .= $after_item;
- }
- }
- if ($params->get( 'show_orig_link' )) {
- $origLink = $item->get_permalink( );
- $linkTxt = $params->get( 'orig_link_text' );
- $target = '';
- if ($params->get( 'target_frame' ) != 'none') {
- $target = 'target="';
- $target .= ($params->get( 'target_frame' ) == 'custom' ? $params->get( 'custom_frame' ) : $params->get( 'target_frame' ));
- $target .= '"';
- }
- if (!empty( $origLink )) {
- $readonlink = '<p>';
- $readonlink .= '<strong>' . $linkTxt . '</strong> <a class="' . $params->get( 'orig_link_class', 'rssreadon' ) . '" rel="' . ($params->get( 'nofollow' ) == 1 ? 'nofollow' : 'external') . '" ';
- $readonlink .= 'title="' . $content['title'] . '" href="' . $origLink . '" ' . $target . '>';
- $readonlink .= ($params->get( 'shortlink' ) == '1' ? $content['title'] : $origLink) . '</a></p>';
- }
- if ($read_more_pos != '1') {
- $content->introtext .= ($params->get( 'introlink' ) == '1' ? $readonlink : '');
- }
- if ($read_more_pos != '4') {
- $content->fulltext .= $readonlink;
- }
- else {
- if ($params->get( 'introlink' ) != '1') {
- $content->introtext .= $readonlink;
- }
- }
- }
- if (trim( str_replace( '-', '', $alias ) ) == '') {
- $alias = null;
- }
- if ($params->get( 'youtube_feed' ) == 1) {
- $url_segments = parse_url( $item->get_permalink( ) );
- parse_str( htmlspecialchars_decode( $url_segments['query'] ), $url_vars );
- $youtube_width = (int)$params->get( 'youtube_width', '640' );
- if ($youtube_width <= 0) {
- $youtube_width = 640;
- }
- $youtube_height = (int)$params->get( 'youtube_height', '385' );
- if ($youtube_height <= 0) {
- $youtube_height = 385;
- }
- if (( isset( $url_vars['v'] ) && preg_match( '/[a-zA-Z0-9_-]+/', $url_vars['v'], $youtube_code ) )) {
- $content['introtext'] = '<object width="' . $youtube_width . '" height="' . $youtube_height . '">
- <param name="movie" value="http://www.youtube.com/v/' . $youtube_code[0] . '&hl=en_US&fs=1"></param>
- <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
- <embed
- src="http://www.youtube.com/v/' . $youtube_code[0] . '&hl=en_US&fs=1"
- type="application/x-shockwave-flash"
- allowscriptaccess="always"
- allowfullscreen="true"
- width="' . $youtube_width . '"
- height="' . $youtube_height . '"></embed>
- </object><br />' . strip_tags( $content['introtext'], '<div><table><tbody><tr><td><img><span>' );
- }
- }
- switch ($store_table) {
- case 'k2': {
- $query_table = '#__k2_items';
- $query_where = ' AND trash=\'0\'';
- break;
- }
- case 'content': {
- }
- default: {
- }
- }
- while (true) {
- $query_table = '#__content';
- $query_where = ' AND (state=1 OR state=0)';
- if () {
- $query = 'SELECT COUNT(id) FROM ' . $db->nameQuote( $query_table ) . ' WHERE ';
- $query .= (( !empty( $content['title'] ) && !empty( $alias ) ) ? 'alias = ' . $db->quote( $alias ) : (!empty( $content['title'] ) ? 'title = ' . $db->quote( $content['title'] ) . '' : 'introtext = ' . $db->quote( $content['introtext'] )));
- $query .= $query_where;
- unset( $query_table );
- unset( $query_where );
- $db->setQuery( $query );
- $count = $db->loadResult( );
- if (intval( $count ) == 0) {
- if ($params->get( 'download_images' ) == 1) {
- if (( !empty( $content['fulltext'] ) || !empty( $content['introtext'] ) )) {
- downloadImages( &$content, $params->get( 'download_dir' ) );
- }
- }
- $config = &JFactory::getconfig( );
- $tzoffset = $config->getValue( 'config.offset' );
- $itemDate = &JFactory::getdate( $item->get_date( ), $tzoffset );
- $itemDate = $itemDate->toMySQL( );
- $content['publish_up'] = $itemDate;
- if ($content['publish_up'] < '2000-01-01 00:00:00') {
- $content['publish_up'] = date( 'Y-m-d H:i:s', time( ) );
- }
- $content['alias'] = $alias;
- if ($params->get( 'save_author' ) == '1') {
- if (( $params->get( 'overwrite_author' ) == '1' && !empty( $feed->default_author ) )) {
- $content['created_by_alias'] = $feed->default_author;
- }
- else {
- if ($author = $item->get_author( )) {
- $content['created_by_alias'] = $author->get_name( );
- }
- if (empty( $content['created_by_alias'] )) {
- $content['created_by_alias'] = ($params->get( 'missing_author' ) == '0' ? $channelTitle : $feed->default_author);
- }
- }
- }
- $content['state'] = intval( $params->get( 'auto_publish' ) );
- $publishDays = intval( $params->get( 'publish_days' ) );
- if (( ( 0 < $content['state'] && $publishDays != 0 ) && !empty( $publishDays ) )) {
- $content['publish_down'] = date( 'Y-m-d H:i:s', time( ) + $publishDays * 24 * 60 * 60 );
- }
- $content['access'] = $params->get( 'access_level', 1 );
- if (!$ads_added) {
- $content->(empty( $content['fulltext'] ) ? 'introtext' : 'fulltext') .= ' ' . $ads[array_rand( $ads )];
- $ads_added = TRUE;
- }
- switch ($store_table) {
- case 'k2': {
- $instance = array( 'table' => 'K2Item', 'prefix' => 'Table' );
- $k2content = array( 'title', 'alias', 'introtext', 'fulltext', 'created', 'created_by', 'created_by_alias', 'checked_out', 'checked_out_time', 'modified', 'modified_by', 'publish_up', 'publish_down', 'trash', 'access', 'ordering', 'featured', 'featured_ordering', 'hits', 'params', 'metadesc', 'metadata', 'metakey', 'plugins' );
- $k2content = array_fill_keys( $k2content, null );
- $k2content = array_intersect_key( $content, $k2content );
- $k2content['published'] = $content['state'];
- $k2content['catid'] = $params->get( 'k2catid' );
- $k2content['featured'] = ($feed->front_page ? 1 : 0);
- $k2content['language'] = '*';
- $k2content['extra_fields'] = '[]';
- $content = $k2content;
- unset( $k2content );
- break;
- }
- case 'content': {
- }
- default: {
- }
- }
- while (true) {
- $instance = array( 'table' => 'content', 'prefix' => 'JTable' );
- if () {
- $row = &JTable::getinstance( $instance['table'], $instance['prefix'] );
- if (!$row->bind( $content )) {
- $mosMsg = $title . '***ERROR: bind' . $db->getErrorMsg( );
- $objResponse->addAppend( 'fgmsgarea', 'innerHTML', '<br />' . $mosMsg );
- return $objResponse->getXML( );
- }
- switch ($store_table) {
- case 'k2': {
- break;
- }
- case 'content': {
- }
- default: {
- }
- }
- while (true) {
- $row->attribs = '{"show_title":"","link_titles":"","show_intro":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_readmore":"","show_print_icon":"","show_email_icon":"","show_hits":"","page_title":"","alternative_readmore":"","layout":""}';
- $row->access = '1';
- $row->language = '*';
- if () {
- $row->id = (int)$row->id;
- $user = &JFactory::getuser( );
- $row->created_by = ($feed->created_by ? $feed->created_by : $user->get( 'id' ));
- if (( $row->created && strlen( trim( $row->created ) ) <= 10 )) {
- $row->created .= ' 00:00:00';
- }
- $row->created = $itemDate;
- if (!$row->check( )) {
- $e = '';
- foreach ($row->getErrors( ) as $error) {
- $e .= $error . '<br/>';
- }
- $mosMsg = '***ERROR*(check)* Feed - ' . $content['title'] . ':' . $db->getErrorMsg( ) . '<br/>' . $e;
- $objResponse->addAppend( 'fgmsgarea', 'innerHTML', '<br />' . $mosMsg );
- continue;
- }
- if (!$row->store( )) {
- $mosMsg = $title . '***ERROR:' . $db->stderr( );
- $objResponse->addAppend( 'fgmsgarea', 'innerHTML', '<br />' . $mosMsg );
- return $objResponse->getXML( );
- }
- $row->checkin( );
- if ($instance['table'] == 'content') {
- $query = 'UPDATE #__assets SET rules = \'{"core.delete":[],"core.edit":[],"core.edit.state":[]}\' WHERE id=' . $row->asset_id;
- $db->setQuery( $query );
- $db->query( );
- if (is_dir( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_advanced_tags' . DS )) {
- $advanced_tags_check = &JComponentHelper::getcomponent( 'com_advanced_tags' );
- }
- if (( $params->get( 'advanced_tags_import' ) && !empty( $advanced_tags_check->id ) )) {
- AggregatorAdvancedTagsImporter;
- $metaimporter = &new ( $row->metakey, $row->id );
- $metaimporter->import( );
- }
- $row->reorder( 'catid = ' . (int)$row->catid . ' AND state >= 0' );
- TableFrontPage;
- $fp = new ( $db );
- if ($feed->front_page) {
- if (!$fp->load( $row->id )) {
- $query = 'INSERT INTO #__content_frontpage' . ' VALUES ( ' . (int)$row->id . ', 1 )';
- $db->setQuery( $query );
- if (!$db->query( )) {
- $mosMsg = $title . '***ERROR:' . $db->getErrorMsg( );
- $objResponse->addAppend( 'fgmsgarea', 'innerHTML', '<br />' . $mosMsg );
- return $objResponse->getXML( );
- }
- $fp->ordering = 1;
- }
- }
- $fp->reorder( );
- $cache = &JFactory::getcache( 'com_content' );
- $cache->clean( );
- }
- ++$nItems;
- break 3;
- }
- }
- }
- }
- }
- break;
- }
- }
- }
- }
- }
- $last_run = $publishdate = date( 'Y-m-d H:i:s' );
- $db->setQuery( '' . 'UPDATE #__aggregator SET last_run = \'' . $last_run . '\' WHERE id = \'' . $feedId . '\'' );
- $db->query( );
- $feedMsg = '' . '<b>' . $nItems . '</b> New content item(s) imported for <b>' . $curFeed . '</b> (' . $channelTitle . ').';
- $objResponse->addAppend( 'fgmsgarea', 'innerHTML', $feedMsg . '<br />' );
- if ($params->get( 'email_admin' ) == '1') {
- $adminMsg = '<span class="feedmsg">' . $feedMsg . '</span>
- ';
- }
- $endTime = time( );
- $procTime = $endTime - $startTime;
- if ($params->get( 'email_admin' ) == '1') {
- $adminMsg = '<h1>Joomla Aggregator e-mail report</h1>
- ';
- $adminMsg .= '' . '<h2>Feed processed in ' . $procTime . ' seconds.</h2>
- ';
- $adminMsg .= '' . $nItems . ' New content items imported from <b>' . $curFeed . '</b> (' . $channelTitle . ')
- ';
- $adminMsg .= 'time finished: ' . date( 'D F j, Y, H:i:s T' ) . '
- ';
- $adminMsg .= '<span class=\'small\'>Visit our site <a href=\'http://3dwebdesign.org\'>3DWebDesign.org</a></span>
- ';
- $adminMsg .= '<span class=\'small\'>If you like our extension, feel free to support us by voting at <a href=\'http://extensions.joomla.org/extensions/external-contents/news-a-feeds/automatic-articles/10700\'>Joomla.org</a></span>';
- $query = 'SELECT name, email, sendEmail FROM #__users WHERE LOWER( usertype ) = "super administrator"';
- $db->setQuery( $query );
- $rows = $db->loadObjectList( );
- $fromname = $rows[0]->name;
- $mailfrom = $rows[0]->email;
- if ($params->get( 'html_email' ) == '1') {
- $css = '<style type="text/css">' . 'body { color:#000000; font-size: 12px; font-family:Arial, Helvetica, sans-serif;}' . '.feedmsg { color:#0400A2; line-height: 1.4em;}' . '#feedinfo { border:1px solid #bababa; padding:0 10px;}' . 'h1 { color:#618700; font-size: 16px; margin:10px 0 5px 0;}' . 'h2 { color:#e56d02; font-size: 14px; margin:5px 10px 0 10px;}' . '.small { color:#999999; font-size: 10px;}' . '#feedinfo a:link, #feedinfo a:visited { color:#990000;}' . '</style>';
- $message = $css . nl2br( $adminMsg );
- }
- else {
- $message = strip_tags( $adminMsg );
- }
- JUtility::sendmail( $mailfrom, $fromname, $params->get( 'admin_email' ), html_entity_decode( $params->get( 'email_subject' ), ENT_QUOTES ), $message, $params->get( 'html_email' ) );
- }
- $totItems += $nItems;
- continue;
- }
- }
- $objResponse->addAppend( 'fgmsgarea', 'innerHTML', '' . '<br /><b>' . $totItems . '</b> Content items imported in ' . $procTime . ' seconds.<br />' );
- $closeLink = '<br /><a href="javascript:closeMsgArea();">Close this window</a><br />';
- $objResponse->addAppend( 'fgmsgarea', 'innerHTML', $closeLink );
- return $objResponse->getXML( );
- }
- }
- ?>
Add Comment
Please, Sign In to add comment