Guest User

Untitled

a guest
May 29th, 2013
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.15 KB | None | 0 0
  1. <?php
  2.  
  3. function mb_str_split($str, $length = 1) {
  4. if ($length < 1) {
  5. return FALSE;
  6. }
  7.  
  8. $result = array( );
  9. $i = 0;
  10.  
  11. while ($i < mb_strlen( $str )) {
  12. $result[] = mb_substr( $str, $i, $length );
  13. $i += $length;
  14. }
  15.  
  16. return $result;
  17. }
  18.  
  19. function mb_substr_replace($string, $replacement, $start, $length = null, $encoding = null) {
  20. if (extension_loaded( 'mbstring' ) === true) {
  21. $string_length = (is_null( $encoding ) === true ? mb_strlen( $string ) : mb_strlen( $string, $encoding ));
  22.  
  23. if ($start < 0) {
  24. $start = max( 0, $string_length + $start );
  25. }
  26. else {
  27. if ($string_length < $start) {
  28. $start = $string_length;
  29. }
  30. }
  31.  
  32.  
  33. if ($length < 0) {
  34. $length = max( 0, $string_length - $start + $length );
  35. }
  36. else {
  37. if (( is_null( $length ) === true || $string_length < $length )) {
  38. $length = $string_length;
  39. }
  40. }
  41.  
  42.  
  43. if ($string_length < $start + $length) {
  44. $length = $string_length - $start;
  45. }
  46.  
  47.  
  48. if (is_null( $encoding ) === true) {
  49. return mb_substr( $string, 0, $start ) . $replacement . mb_substr( $string, $start + $length, $string_length - $start - $length );
  50. }
  51.  
  52. return mb_substr( $string, 0, $start, $encoding ) . $replacement . mb_substr( $string, $start + $length, $string_length - $start - $length, $encoding );
  53. }
  54.  
  55. return (is_null( $length ) === true ? substr_replace( $string, $replacement, $start ) : substr_replace( $string, $replacement, $start, $length ));
  56. }
  57.  
  58. function doTranslate($content, $call) {
  59. while (true) {
  60. Gtranslate;
  61. $gt = new ( );
  62. $body_split = FALSE;
  63. $tbody = '';
  64. $ttitle = '';
  65.  
  66. if (200 < mb_strlen( $content )) {
  67. $body_array = mb_str_split( $content, 200 );
  68. $body_split = TRUE;
  69. $tmp_array = $body_array;
  70. $tmp_keys = array_keys( $tmp_array );
  71. unset( $tmp_keys[0] );
  72. foreach ($tmp_keys as $key) {
  73. $pos = mb_strpos( $body_array[$key], '. ' );
  74. $body_array[$key - 1] = $body_array[$key - 1] . mb_substr( $body_array[$key], 0, $pos + 1 );
  75. $body_array[$key] = mb_substr_replace( $body_array[$key], '', 0, $pos + 1 );
  76. }
  77.  
  78.  
  79. if ($body_split) {
  80. $tbody_array = array( );
  81. $chunk_failed = FALSE;
  82. foreach ($body_array as $key => $chunk) {
  83. $tbody_array[$key] = $gt->$call( $chunk );
  84. GTranslateException {
  85. echo $ge->getMessage( ) . '
  86.  
  87. ';
  88. $chunk_failed = TRUE;
  89. continue;
  90. }
  91.  
  92. break;
  93. }
  94.  
  95. $content = implode( '', $tbody_array );
  96. break;
  97. }
  98. }
  99.  
  100. $content = $gt->$call( $content );
  101. GTranslateException {
  102. echo $ge->getMessage( ) . '
  103.  
  104. ';
  105. $chunk_failed = TRUE;
  106. }
  107. }
  108.  
  109. return $content;
  110. }
  111.  
  112. function isImage($fileName) {
  113. static $imageTypes = 'xcf|odg|gif|jpg|png|bmp';
  114.  
  115. return preg_match( '' . '/' . $imageTypes . '/i', $fileName );
  116. }
  117.  
  118. function downloadImages($content, $dir) {
  119. static $sources = array( 0 => 'fulltext', 1 => 'introtext' );
  120.  
  121. $allowed_types = array( 'png', 'gif', 'jpg' );
  122. $pattern = '/<img\s+.*?src=[\"\'](.*?)[\'\"]\s*.*?\/?\>/';
  123. $local_imgs = JPATH_ROOT . DS . 'images/' . $dir . DS;
  124. foreach ($sources as $source) {
  125. if (empty( $content[$source] )) {
  126. continue;
  127. }
  128.  
  129. preg_match_all( $pattern, $content[$source], $matches );
  130.  
  131. if (0 < sizeof( $matches[1] )) {
  132. foreach ($matches[1] as $image) {
  133. $ext = strtolower( JFile::getext( $image ) );
  134.  
  135. if (!in_array( $ext, $allowed_types )) {
  136. continue;
  137. }
  138.  
  139. $local_img_name = md5( $image ) . ( '' . '.' . $ext );
  140.  
  141. if (FALSE === is_file( $local_imgs . $local_img_name )) {
  142. file_put_contents( $local_imgs . $local_img_name, file_get_contents( $image ) );
  143. }
  144.  
  145. $content[$source] = str_replace( $image, 'images/' . $dir . DS . $local_img_name, $content[$source] );
  146. }
  147.  
  148. continue;
  149. }
  150. }
  151.  
  152. }
  153.  
  154. function doSynonyms($content, $synonym_words) {
  155. mb_internal_encoding( 'UTF-8' );
  156. mb_regex_encoding( 'UTF-8' );
  157. $synonym_lines = preg_split( '/;/', $synonym_words, 0 - 1, PREG_SPLIT_NO_EMPTY );
  158. $synonyms = array( );
  159. foreach ($synonym_lines as $synonym_line) {
  160. $synonym = preg_split( '/=/', $synonym_line, 0 - 1, PREG_SPLIT_NO_EMPTY );
  161.  
  162. if (1 < sizeof( $synonym )) {
  163. $synonym_replacements = preg_split( '/,/', $synonym[1], 0 - 1, PREG_SPLIT_NO_EMPTY );
  164. $synonyms[$synonym[0]] = $synonym_replacements[rand( 0, sizeof( $synonym_replacements ) - 1 )];
  165. continue;
  166. }
  167. }
  168.  
  169.  
  170. if (sizeof( $synonyms )) {
  171. $minkeylen = min( array_keys( $synonyms ) );
  172. $newContent = '';
  173. $htmlregex = '#({*\s*.*?}|<a .*?</a\\ *>|<h[1-7].*?</h[1-7]\\ *>|<script[\s\S]*?<\/script>|</?.*?>|\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>)#i';
  174. $bits = preg_split( $htmlregex, $content );
  175. preg_match_all( $htmlregex, $content, $matches );
  176. foreach ($bits as $i => $bit) {
  177. if ($minkeylen <= strlen( $bit )) {
  178. foreach ($synonyms as $word => $synonym) {
  179. $bit = mb_eregi_replace( '\b(' . $word . ')\b', $synonym, $bit );
  180. }
  181. }
  182.  
  183. $newContent .= $bit;
  184.  
  185. if (isset( $matches[0][$i] )) {
  186. $newContent .= $matches[0][$i];
  187. continue;
  188. }
  189. }
  190.  
  191. $content = $newContent;
  192. }
  193.  
  194. return $content;
  195. }
  196.  
  197.  
  198. if (!( defined( '_JEXEC' ))) {
  199. exit( 'Restricted access' );
  200. (bool)true;
  201. }
  202.  
  203. mb_internal_encoding( 'UTF-8' );
  204. jimport( 'joomla.application.component.controller' );
  205. require( 'gtranslate-api-php/GTranslate.php' );
  206.  
  207. if (is_dir( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_frontpage' . DS )) {
  208. require_once( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_frontpage' . DS . 'tables' . DS . 'frontpage.php' );
  209. }
  210. else {
  211. class TableFrontPage extends JTable {
  212. var $content_id = null;
  213. var $ordering = null;
  214.  
  215. function __construct($db) {
  216. parent::( '#__content_frontpage', 'content_id', $db );
  217. }
  218. }
  219. }
  220.  
  221. jimport( 'joomla.filesystem.file' );
  222.  
  223. if (is_dir( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_advanced_tags' . DS )) {
  224. $advanced_tags_check = &JComponentHelper::getcomponent( 'com_advanced_tags' );
  225. }
  226.  
  227.  
  228. if (!empty( $advanced_tags_check->id )) {
  229. jimport( 'joomla.application.component.model' );
  230. require_once( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_advanced_tags' . DS . 'models' . DS . 'tag.php' );
  231. require_once( JPATH_SITE . DS . 'components' . DS . 'com_advanced_tags' . DS . 'helper' . DS . 'helper.php' );
  232. class AggregatorAdvancedTagsImporter extends Advanced_tagsModelTag {
  233. var $_meta = '';
  234.  
  235. function __construct($meta, $id) {
  236. $this->_db = &JFactory::getdbo( );
  237.  
  238. $this->_id = $id;
  239. $this->_meta = $meta;
  240. }
  241.  
  242. function termCheck($term) {
  243. $ignoreNumericTags = AdvancedTagsHelper::param( 'IgnoeNumericTags', 0 );
  244.  
  245. if ($ignoreNumericTags) {
  246. if (is_numeric( $term )) {
  247. echo 'ignore:' . $term;
  248. return false;
  249. }
  250. }
  251.  
  252. $minTagLength = AdvancedTagsHelper::param( 'MinTagLength', 1 );
  253. $len = JString::strlen( $term );
  254.  
  255. if ($len < $minTagLength) {
  256. return false;
  257. }
  258.  
  259. return true;
  260. }
  261.  
  262. function import() {
  263. if (( isset( $this->_meta ) && empty( $this->_meta ) == false )) {
  264. $cid = $this->_id;
  265.  
  266. if (!$this->isContentHasTags( $cid )) {
  267. $keys = explode( ',', $this->_meta );
  268. $keysProcessed = array( );
  269. foreach ($keys as $key) {
  270. $key = AdvancedTagsHelper::prehandle( $key );
  271.  
  272. if (empty( $key ) == false) {
  273. if (!in_array( $key, $keysProcessed )) {
  274. $keysProcessed[] = $key;
  275. continue;
  276. }
  277.  
  278. continue;
  279. }
  280. }
  281.  
  282. unset( $keys );
  283. $deleteTags = 'delete from #__tag_term_content where cid=' . $cid;
  284. $this->_db->setQuery( $deleteTags );
  285. $this->_db->query( );
  286. foreach ($keysProcessed as $key) {
  287. $pass = $this->termCheck( $key );
  288.  
  289. if ($pass) {
  290. $tid = $this->storeTerm( $key );
  291. $this->insertContentterm( $tid, $cid );
  292. continue;
  293. }
  294. }
  295. }
  296. }
  297.  
  298. }
  299. }
  300. }
  301.  
  302. class AggregatorController extends JController {
  303. function __construct($config = array( )) {
  304. $task = JRequest::getcmd( 'task' );
  305.  
  306. if ($task != 'cron') {
  307. xajax;
  308. $xajax = new ( );
  309. $xajax->registerFunction( array( 'importfeed', $this, 'importfeed' ) );
  310. $xajax->registerFunction( array( 'importall', $this, 'importall' ) );
  311. }
  312.  
  313. parent::( $config );
  314.  
  315. if ($task != 'cron') {
  316. $xajax->processRequests( );
  317. }
  318.  
  319. }
  320.  
  321. function walkCatTree(&$categories, $cattree, $branch_id, $level) {
  322. if (FALSE === empty( $cattree[$branch_id]['title'] )) {
  323. $categories[] = array( 'id' => $cattree[$branch_id]['id'], 'title' => str_repeat( '- ', $level ) . $cattree[$branch_id]['title'] );
  324. }
  325.  
  326. reset( $cattree[$branch_id]['children'] );
  327.  
  328. while (list( , $child_id ) = each( $cattree[$branch_id]['children'] )) {
  329. self::walkcattree( $categories, $cattree, $child_id, $level + 1 );
  330. }
  331.  
  332. }
  333.  
  334. function about() {
  335. $view = &$this->getView( 'aggregator', 'html' );
  336.  
  337. $view->display( 'about' );
  338. }
  339.  
  340. function support() {
  341. $view = &$this->getView( 'aggregator', 'html' );
  342.  
  343. $view->display( 'support' );
  344. }
  345.  
  346. function feeds() {
  347. $mainframe = JFactory::getapplication( );
  348. $db = &JFactory::getdbo( );
  349.  
  350. $context = 'com_aggregator.feeds';
  351. $option = JRequest::getcmd( 'option' );
  352. $limit = $mainframe->getUserStateFromRequest( $context . 'viewlistlimit', 'limit', 10, 'int' );
  353. $limitstart = $mainframe->getUserStateFromRequest( $context . 'view' . $option . 'limitstart', 'limitstart', 0, 'int' );
  354. $search = $mainframe->getUserStateFromRequest( '' . 'search' . $option, 'search', '', 'word' );
  355. $search = JString::strtolower( $search );
  356. $filter_order = $mainframe->getUserStateFromRequest( $context . 'filter_order', 'filter_order', '', 'cmd' );
  357. $filter_order_Dir = $mainframe->getUserStateFromRequest( $context . 'filter_order_Dir', 'filter_order_Dir', '', 'word' );
  358.  
  359. if (!$filter_order) {
  360. $filter_order = 'f.id';
  361. }
  362.  
  363. $order = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . ', f.id';
  364. $where = array( );
  365.  
  366. if ($search) {
  367. $where[] = '(LOWER( f.title ) LIKE ' . $db->Quote( '%' . $db->getEscaped( $search, true ) . '%', false ) . ' OR f.id = ' . (int)$search . ')';
  368. }
  369.  
  370. $where = (count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '');
  371. $db->setQuery( 'SELECT count(*) FROM #__aggregator AS f' . ' LEFT JOIN #__categories AS cc ON cc.id = f.catid' . $where );
  372. $total = $db->loadResult( );
  373.  
  374. if (!$db->query( )) {
  375. JError::raiseerror( 500, $db->getErrorMsg( ) );
  376. return false;
  377. }
  378.  
  379. jimport( 'joomla.html.pagination' );
  380. JPagination;
  381. $pagination = new ( $total, $limitstart, $limit );
  382. $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 );
  383. $rows = $db->loadObjectList( );
  384.  
  385. if ($db->getErrorNum( )) {
  386. JError::raiseerror( 500, $db->stderr( ) );
  387. return false;
  388. }
  389.  
  390. $lists['order_Dir'] = $filter_order_Dir;
  391. $lists['order'] = $filter_order;
  392. $lists['search'] = $search;
  393. $view = &$this->getView( 'aggregator', 'html' );
  394.  
  395. $view->assignRef( 'rows', $rows );
  396. $view->assignRef( 'page', $pagination );
  397. $view->assignRef( 'search', $search );
  398. $view->assignRef( 'lists', $lists );
  399. $view->display( );
  400. }
  401.  
  402. function editContent($edit) {
  403. $mainframe = JFactory::getapplication( );
  404. $db = &JFactory::getdbo( );
  405. $user = &JFactory::getuser( );
  406.  
  407. $cid = JRequest::getvar( 'cid', array( 0 ), '', 'array' );
  408. JArrayHelper::tointeger( $cid, array( 0 ) );
  409. $id = JRequest::getvar( 'id', $cid[0], '', 'int' );
  410. $option = JRequest::getcmd( 'option' );
  411. $nullDate = $db->getNullDate( );
  412. $contentSection = '';
  413. $sectionid = 0;
  414. $model = &$this->getModel( 'feed' );
  415.  
  416. $feed = $model->getData( );
  417. JParameter;
  418. $params = new ( $feed->params );
  419.  
  420. if ($model->isCheckedOut( $user->get( 'id' ) )) {
  421. $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The feed' ), $feed->title );
  422. $mainframe->redirect( 'index.php?option=com_aggregator', $msg );
  423. }
  424.  
  425.  
  426. if ($id) {
  427. $model->checkout( $user->get( 'id' ) );
  428. jimport( 'joomla.utilities.date' );
  429. JDate;
  430. $createdate = new ( $feed->created );
  431. $feed->created = $createdate->toUnix( );
  432. }
  433. else {
  434. if ($_POST['catid']) {
  435. $row->catid = $_POST['catid'];
  436. $category = &JTable::getinstance( 'category' );
  437.  
  438. $category->load( $row->catid );
  439. }
  440. else {
  441. $row->catid = NULL;
  442. }
  443.  
  444. $row->sectionid = $sectionid;
  445. }
  446.  
  447. $categories = array( );
  448. $categories[] = JHTML::_( 'select.option', '-1', JText::_( 'Select Category' ), 'id', 'title' );
  449. $options = array( );
  450. $db->setQuery( 'select id, title, parent_id from #__categories where published IN (0,1) and extension in (\'com_content\') order by id ASC' );
  451. $options = $db->loadObjectList( );
  452. $cattree = array( '1' => array( 'children' => array( ) ) );
  453. $i = 0;
  454.  
  455. while ($i < count( $options )) {
  456. $cattree[$options[$i]->id] = array( 'id' => $options[$i]->id, 'title' => $options[$i]->title, 'children' => array( ) );
  457. $cattree[$options[$i]->parent_id]['children'][] = $options[$i]->id;
  458. ++$i;
  459. }
  460.  
  461. self::walkcattree( $categories, $cattree, '1', 0 - 1 );
  462.  
  463. if ($feed->catid) {
  464. $lists['catid'] = JHTML::_( 'select.genericlist', $categories, 'catid', 'class="inputbox" size="1"', 'id', 'title', intval( $feed->catid ) );
  465. }
  466. else {
  467. $lists['catid'] = JHTML::_( 'select.genericlist', $categories, 'catid', 'class="inputbox" size="1"', 'id', 'title' );
  468. }
  469.  
  470.  
  471. if (is_dir( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS )) {
  472. $component_check = &JComponentHelper::getcomponent( 'com_k2' );
  473. }
  474.  
  475.  
  476. if ($k2_installed = (!empty( $component_check->id ) ? 1 : 0)) {
  477. $query = 'SELECT id, name FROM #__k2_categories ORDER BY ordering';
  478. $db->setQuery( $query );
  479. $k2categories[] = JHTML::_( 'select.option', '-1', JText::_( 'Select Category' ), 'id', 'name' );
  480. $k2categories = array_merge( $k2categories, $db->loadObjectList( ) );
  481. $lists['k2catid'] = JHTML::_( 'select.genericlist', $k2categories, 'params[k2catid]', 'class="inputbox" size="1"', 'id', 'name', $params->get( 'k2catid', '0' ) );
  482. }
  483.  
  484. $read_more_pos[] = JHTML::_( 'select.option', '0', 'Default', 'id', 'title' );
  485. $read_more_pos[] = JHTML::_( 'select.option', '1', 'No introtext', 'id', 'title' );
  486. $read_more_pos[] = JHTML::_( 'select.option', '2', 'After "Before item"', 'id', 'title' );
  487. $read_more_pos[] = JHTML::_( 'select.option', '3', 'After "Content"', 'id', 'title' );
  488. $read_more_pos[] = JHTML::_( 'select.option', '4', 'Only introtext', 'id', 'title' );
  489. $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' ) );
  490. $insert_title_in_content[] = JHTML::_( 'select.option', '', 'No', 'id', 'title' );
  491. $insert_title_in_content[] = JHTML::_( 'select.option', 'before', 'Before item', 'id', 'title' );
  492. $insert_title_in_content[] = JHTML::_( 'select.option', 'after', 'After item', 'id', 'title' );
  493. $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', '' ) );
  494. $target_frame[] = JHTML::_( 'select.option', 'none', 'None', 'id', 'title' );
  495. $target_frame[] = JHTML::_( 'select.option', '_blank', '_blank', 'id', 'title' );
  496. $target_frame[] = JHTML::_( 'select.option', '_parent', '_parent', 'id', 'title' );
  497. $target_frame[] = JHTML::_( 'select.option', '_self', '_self', 'id', 'title' );
  498. $target_frame[] = JHTML::_( 'select.option', '_top', '_top', 'id', 'title' );
  499. $target_frame[] = JHTML::_( 'select.option', 'custom', 'Custom', 'id', 'title' );
  500. $lists['target_frame'] = JHTML::_( 'select.genericlist', $target_frame, 'params[target_frame]', 'class="inputbox" size="1"', 'id', 'title', $params->get( 'target_frame', 'none' ) );
  501. $access_level[] = JHTML::_( 'select.option', '1', 'Public', 'id', 'title' );
  502. $access_level[] = JHTML::_( 'select.option', '2', 'Registered', 'id', 'title' );
  503. $access_level[] = JHTML::_( 'select.option', '3', 'Special', 'id', 'title' );
  504. $lists['access_level'] = JHTML::_( 'select.genericlist', $access_level, 'params[access_level]', 'class="inputbox" size="1"', 'id', 'title', $params->get( 'access_level', 1 ) );
  505. $db->setQuery( 'SELECT `id`, `username` FROM #__users' );
  506. $creators = $db->loadObjectList( );
  507. foreach ($creators as $creator) {
  508. $creator_options[] = JHTML::_( 'select.option', $creator->id, $creator->username, 'id', 'title' );
  509. }
  510.  
  511. $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' )) );
  512. $meta_tags_reorder[] = JHTML::_( 'select.option', 'default', 'Default (No Change) ', 'id', 'title' );
  513. $meta_tags_reorder[] = JHTML::_( 'select.option', 'backwards', 'Backwards', 'id', 'title' );
  514. $meta_tags_reorder[] = JHTML::_( 'select.option', 'shuffle', 'Shuffle', 'id', 'title' );
  515. $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' ) );
  516. $gt_languages = array( );
  517. 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 );
  518. $gt_langs = array_combine( $gt_langs_matches[1], $gt_langs_matches[2] );
  519. $gt_langs = array_flip( array_change_key_case( $gt_langs, CASE_LOWER ) );
  520. asort( $gt_langs );
  521. foreach ($gt_langs as $k => $v) {
  522. $gt_languages[] = JHTML::_( 'select.option', $k, $v, 'id', 'title' );
  523. }
  524.  
  525. $lists['translate_from'] = JHTML::_( 'select.genericlist', $gt_languages, 'params[translate_from]', 'class="inputbox" size="1"', 'id', 'title', $params->get( 'translate_from' ) );
  526. $lists['translate_to'] = JHTML::_( 'select.genericlist', $gt_languages, 'params[translate_to]', 'class="inputbox" size="1"', 'id', 'title', $params->get( 'translate_to' ) );
  527.  
  528. if (is_dir( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_advanced_tags' . DS )) {
  529. $component_check = &JComponentHelper::getcomponent( 'com_advanced_tags' );
  530. }
  531.  
  532. $advanced_tags_installed = (!empty( $component_check->id ) ? 1 : 0);
  533. $view = &$this->getView( 'aggregator', 'html' );
  534.  
  535. $view->assignRef( 'params', $params );
  536. $view->assignRef( 'feed', $feed );
  537. $view->assignRef( 'lists', $lists );
  538. $view->assignRef( 'k2_installed', $k2_installed );
  539. $view->assignRef( 'advanced_tags_installed', $advanced_tags_installed );
  540. $view->display( 'new' );
  541. }
  542.  
  543. function copy() {
  544. $mainframe = JFactory::getapplication( );
  545. ( JRequest::checktoken( ) || jexit( 'Invalid Token' ) );
  546. $db = &JFactory::getdbo( );
  547.  
  548. $cid = JRequest::getvar( 'cid', array( ), 'post', 'array' );
  549. $option = JRequest::getcmd( 'option' );
  550. JArrayHelper::tointeger( $cid );
  551. $item = null;
  552. $total = count( $cid );
  553. $i = 0;
  554.  
  555. while ($i < $total) {
  556. $query = 'SELECT a.*' . ' FROM #__aggregator AS a' . ' WHERE a.id = ' . (int)$cid[$i];
  557. $db->setQuery( $query, 0, 1 );
  558. $item = $db->loadObject( );
  559. $row = array( );
  560. $row['id'] = NULL;
  561. $row['title'] = 'Copy Of ' . $item->title;
  562. $row['feed'] = $item->feed;
  563. $row['sectionid'] = $item->sectionid;
  564. $row['catid'] = $item->catid;
  565. $row['default_author'] = $item->default_author;
  566. $row['created_by'] = $item->created_by;
  567. $row['created'] = $item->created;
  568. $row['cronjobs'] = $item->cronjobs;
  569. $row['last_run'] = $item->last_run;
  570. $row['published'] = 0;
  571. $row['front_page'] = $item->front_page;
  572. $row['checked_out'] = $item->checked_out;
  573. $row['checked_out_time'] = $item->checked_out_time;
  574. $row['params'] = $item->params;
  575. $model = $this->getModel( 'feed' );
  576.  
  577. if ($model->store( $row )) {
  578. $msg = JText::_( 'Feed Copied' );
  579. }
  580. else {
  581. $msg = JText::_( 'Error Copying Feed' );
  582. }
  583.  
  584. ++$i;
  585. }
  586.  
  587. $msg = JText::sprintf( 'Item(s) successfully copied ', $total, $section, $category );
  588. $mainframe->redirect( 'index.php?option=' . $option, $msg );
  589. }
  590.  
  591. function save() {
  592. if (!( JRequest::checktoken( ))) {
  593. exit( 'Invalid Token' );
  594. (bool)true;
  595. }
  596.  
  597. $post = JRequest::get( 'post' );
  598. $cid = JRequest::getvar( 'cid', array( 0 ), 'post', 'array' );
  599. $post['id'] = (int)$cid[0];
  600. $params = JRequest::getvar( 'params', null, 'post', 'array' );
  601.  
  602. if (is_array( $params )) {
  603. $txt = array( );
  604. foreach ($params as $k => $v) {
  605. $txt[] = $k . '=' . str_replace( array( '
  606. ', '
  607. ', '
  608. ' ), '', $v );
  609. }
  610.  
  611. $post['params'] = implode( '
  612. ', $txt );
  613. }
  614.  
  615. $model = $this->getModel( 'feed' );
  616.  
  617. if ($model->store( $post )) {
  618. $msg = JText::_( 'Feed Saved' );
  619. }
  620. else {
  621. $msg = JText::_( 'Error Saving Feed' );
  622. }
  623.  
  624. $model->checkin( );
  625. $link = 'index.php?option=com_aggregator';
  626. $this->setRedirect( $link, $msg );
  627. }
  628.  
  629. function publishFeeds($publish = 1, $action = 'publish') {
  630. if (!( JRequest::checktoken( ))) {
  631. exit( 'Invalid Token' );
  632. (bool)true;
  633. }
  634.  
  635. $cid = JRequest::getvar( 'cid', array( ), 'post', 'array' );
  636. JArrayHelper::tointeger( $cid );
  637.  
  638. if (count( $cid ) < 1) {
  639. JError::raiseerror( 500, JText::_( 'Select an item to ' . $action ) );
  640. }
  641.  
  642. $model = $this->getModel( 'feed' );
  643.  
  644. if (!$model->publish( $cid, $publish )) {
  645. echo '<script> alert(\'' . $model->getError( true ) . '\'); window.history.go(-1); </script>
  646. ';
  647. }
  648.  
  649. $this->setRedirect( 'index.php?option=com_aggregator' );
  650. }
  651.  
  652. function frontpageFeeds($frontpage = 1, $action = 'front_yes') {
  653. if (!( JRequest::checktoken( ))) {
  654. exit( 'Invalid Token' );
  655. (bool)true;
  656. }
  657.  
  658. $cid = JRequest::getvar( 'cid', array( ), 'post', 'array' );
  659. JArrayHelper::tointeger( $cid );
  660.  
  661. if (count( $cid ) < 1) {
  662. JError::raiseerror( 500, JText::_( 'Select an item to ' . $action ) );
  663. }
  664.  
  665. $model = $this->getModel( 'feed' );
  666.  
  667. if (!$model->frontpage( $cid, $frontpage )) {
  668. echo '<script> alert(\'' . $model->getError( true ) . '\'); window.history.go(-1); </script>
  669. ';
  670. }
  671.  
  672. $this->setRedirect( 'index.php?option=com_aggregator' );
  673. }
  674.  
  675. function remove() {
  676. $mainframe = JFactory::getapplication( );
  677.  
  678. if (!( JRequest::checktoken( ))) {
  679. exit( 'Invalid Token' );
  680. (bool)true;
  681. }
  682.  
  683. $db = &JFactory::getdbo( );
  684.  
  685. $cid = JRequest::getvar( 'cid', array( ), 'post', 'array' );
  686. JArrayHelper::tointeger( $cid );
  687.  
  688. if (count( $cid ) < 1) {
  689. $msg = JText::_( 'Select an item to delete' );
  690. $mainframe->redirect( 'index.php?option=com_aggregator', $msg, 'error' );
  691. }
  692.  
  693. $model = $this->getModel( 'feed' );
  694.  
  695. if (!$model->delete( $cid, $frontpage )) {
  696. echo '<script> alert(\'' . $model->getError( true ) . '\'); window.history.go(-1); </script>
  697. ';
  698. }
  699.  
  700. $msg = JText::sprintf( 'Item(s) deleted', count( $cid ) );
  701. $mainframe->redirect( 'index.php?option=com_aggregator', $msg );
  702. }
  703.  
  704. function cancel() {
  705. $mainframe = JFactory::getapplication( );
  706.  
  707. if (!( JRequest::checktoken( ))) {
  708. exit( 'Invalid Token' );
  709. (bool)true;
  710. }
  711.  
  712. $db = &JFactory::getdbo( );
  713.  
  714. $model = $this->getModel( 'feed' );
  715. $model->checkin( );
  716. $mainframe->redirect( 'index.php?option=com_aggregator' );
  717. }
  718.  
  719. function importcron() {
  720. $db = &JFactory::getdbo( );
  721.  
  722. $db->setQuery( 'SELECT id, cronjobs, last_run FROM #__aggregator WHERE published=1' );
  723. $feeds = $db->loadAssocList( );
  724.  
  725. if (0 < sizeof( $feeds )) {
  726. foreach ($feeds as $feed) {
  727. $jobs = parseCronString( $feed['cronjobs'], $feed['last_run'] );
  728. $jobsRun = 0;
  729. foreach ($jobs as $job) {
  730. if (( $maxJobs == 0 || $jobsRun < $maxJobs )) {
  731. if (runJob( $job )) {
  732. $feedIds[] = $feed['id'];
  733. ++$jobsRun;
  734. continue;
  735. }
  736.  
  737. continue;
  738. }
  739. }
  740. }
  741. }
  742.  
  743. $formData = array( );
  744. $formData['option'] = 'com_aggregator';
  745. $formData['cid'] = $feedIds;
  746. $this->importFeed( $formData );
  747. }
  748.  
  749. function importall() {
  750. $db = &JFactory::getdbo( );
  751.  
  752. $db->setQuery( 'SELECT id FROM #__aggregator WHERE published = \'1\'' );
  753. $feedIds = $db->loadResultArray( );
  754. $formData['cid'] = $feedIds;
  755. return $this->importfeed( $formData );
  756. }
  757.  
  758. function importfeed($formData = '') {
  759. $db = &JFactory::getdbo( );
  760.  
  761. $Config = JComponentHelper::getparams( 'com_aggregator' );
  762. xajaxResponse;
  763. $objResponse = new ( );
  764. $cid = (empty( $formData['cid'] ) ? JRequest::getvar( 'cid', array( ), 'get', 'array' ) : $formData['cid']);
  765. $mosMsg = '';
  766. $adminMsg = '';
  767.  
  768. if ($feed->email_admin == '1') {
  769. $adminMsg .= '<b>Results of the last Aggregator import run:</b>
  770.  
  771. ';
  772. $adminMsg .= '<div id="feedinfo"><h1>START Aggregator Import Processing: ' . date( 'D F j, Y, H:i:s T' ) . '</h1>
  773. ';
  774. }
  775.  
  776. $objResponse->addScript( 'resetMsgArea();' );
  777. $objResponse->addAppend( 'fgmsgarea', 'innerHTML', $feed->target . '<br />' );
  778. $totItems = 0;
  779. $cacheDir = JPATH_BASE . DS . 'cache';
  780.  
  781. if (( !$feed->use_sp_cache || !is_writable( $cacheDir ) )) {
  782. $cache_exists = false;
  783. }
  784. else {
  785. $cache_exists = true;
  786. }
  787.  
  788. $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.' );
  789. $ads_added = FALSE;
  790. foreach ($cid as $feedId) {
  791. $startTime = time( );
  792. $nItems = 0;
  793. $model = &$this->getModel( 'feed' );
  794.  
  795. $model->setId( $feedId );
  796. $feed = $model->getData( );
  797. JParameter;
  798. $params = new ( $feed->params );
  799. $gt_call = $params->get( 'translate_from' ) . '_to_' . $params->get( 'translate_to' );
  800.  
  801. if ($feed->published) {
  802. $store_table = $params->get( 'store_table', 'content' );
  803. $curFeed = $feed->title;
  804. SimplePie;
  805. $rssDoc = new ( );
  806. $myfeed = $feed->feed;
  807.  
  808. if (get_magic_quotes_gpc( )) {
  809. $myfeed = stripslashes( $myfeed );
  810. }
  811.  
  812. $rssDoc->set_feed_url( $myfeed );
  813. $output_encoding = $Config->get( 'output_encoding' );
  814.  
  815. if (( !empty( $output_encoding ) && mb_strtolower( $output_encoding != 'utf-8' ) )) {
  816. $rssDoc->set_output_encoding( $Config->get( 'output_encoding' ) );
  817. }
  818.  
  819. $forcefsock = $params->get( 'force_fsockopen' );
  820.  
  821. if ($forcefsock == '1') {
  822. $rssDoc->force_fsockopen( true );
  823. }
  824.  
  825.  
  826. if ($cache_exists) {
  827. $rssDoc->set_cache_location( $cacheDir );
  828. $rssDoc->caching = true;
  829. $rssDoc->set_cache_duration( 60 * SPIE_CACHE_AGE );
  830. }
  831. else {
  832. $rssDoc->caching = false;
  833. }
  834.  
  835. $rssDoc->init( );
  836. $rssDoc->handle_content_type( );
  837.  
  838. if ($rssDoc->get_type( ) & SIMPLEPIE_TYPE_NONE) {
  839. }
  840. else {
  841. $channelTitle = $rssDoc->get_title( );
  842. $itemArray = $rssDoc->get_items( );
  843.  
  844. if (is_array( $itemArray )) {
  845. foreach ($itemArray as $item) {
  846. $content = array( );
  847. $content['title'] = trim( $item->get_title( ) );
  848. $item_description = trim( $item->get_description( ) );
  849.  
  850. if (empty( $item_description )) {
  851. $item_description = $content['title'];
  852. }
  853.  
  854.  
  855. if ($item_content = trim( $item->get_content( ) )) {
  856. if (!empty( $item_content )) {
  857. $item_description = $item_content;
  858. }
  859. }
  860.  
  861.  
  862. if ($params->get( 'show_html' ) == 0) {
  863. $item_description = strip_tags( $item_description );
  864. }
  865.  
  866. $content['title'] = html_entity_decode( $content['title'], ENT_QUOTES );
  867.  
  868. if ($params->get( 'strip_html_tags' ) == 1) {
  869. $content['title'] = strip_tags( $content['title'] );
  870. }
  871.  
  872.  
  873. if ($params->get( 'strip_title_specialchars' ) == '1') {
  874. $content['title'] = preg_replace( '/\.|»|!|„|“|”|"|#|\$|%|&|\'|\'|\(|\)|\*|\+|:|;|<|=|>|\?|@|\[|\|]|^|_|`|{|\||}|~/', '', $content['title'] );
  875. $content['title'] = str_replace( ',', ' ', $content['title'] );
  876. $content['title'] = preg_replace( '/\s\s+/', ' ', $content['title'] );
  877. }
  878.  
  879.  
  880. if (( $params->get( 'google_translate' ) == 1 && !empty( $content['title'] ) )) {
  881. $content['title'] = doTranslate( $content['title'], $gt_call );
  882. }
  883.  
  884. preg_match_all( '/^before_title\d+=(.*?)$/m', $feed->params, $matches );
  885. $tmp_array = array_filter( $matches[1] );
  886. sort( $tmp_array );
  887. $content['title'] = (0 < $items = sizeof( $tmp_array ) ? $tmp_array[rand( 0, $items - 1 )] . ' ' : '') . $content['title'];
  888. preg_match_all( '/^after_title\d+=(.*?)$/m', $feed->params, $matches );
  889. $tmp_array = array_filter( $matches[1] );
  890. sort( $tmp_array );
  891. $content->title .= (0 < $items = sizeof( $tmp_array ) ? ' ' . $tmp_array[rand( 0, $items - 1 )] : '');
  892. $alias = ($params->get( 'safe_alias' ) == '1' ? md5( $content['title'] ) : JFilterOutput::stringurlsafe( $content['title'] ));
  893. $content['introtext'] = $item_description;
  894.  
  895. if (JString::strpos( $content['introtext'], '<br/>' ) === 0) {
  896. $content['introtext'] = substr( $content['introtext'], 5 );
  897. }
  898.  
  899. $trim_to = $params->get( 'trim_to' );
  900.  
  901. if (( !empty( $trim_to ) || intval( $trim_to ) < strlen( $content['introtext'] ) )) {
  902. $content['introtext'] = AggregatorHelper::maketeaser( $content['introtext'], $trim_to );
  903. }
  904.  
  905. $onlyintro = $params->get( 'onlyintro' );
  906. $intro_length = strlen( $content['introtext'] );
  907.  
  908. if (( !$onlyintro && $intro_length < strlen( $item_description ) )) {
  909. $content['fulltext'] = substr( $item_description, $intro_length );
  910. }
  911. else {
  912. $content['fulltext'] = '';
  913. }
  914.  
  915.  
  916. if ($params->get( 'synonyms' )) {
  917. $content['title'] = doSynonyms( $content['title'], $params->get( 'synonym_words_title' ) );
  918. $content['introtext'] = doSynonyms( $content['introtext'], $params->get( 'synonym_words_content' ) );
  919. $content['fulltext'] = doSynonyms( $content['fulltext'], $params->get( 'synonym_words_content' ) );
  920. }
  921.  
  922. $content['sectionid'] = $feed->sectionid;
  923. $content['catid'] = $feed->catid;
  924. $content['metakey'] = '';
  925. $global_keywords = array( );
  926.  
  927. if ($params->get( 'save_feed_cats' )) {
  928. if ($category = $item->get_category( )) {
  929. $global_keywords[] = $category->get_label( );
  930. }
  931. }
  932.  
  933.  
  934. if ($params->get( 'save_sect_cats' )) {
  935. $sectionName = AggregatorHelper::getfieldname( $content['sectionid'], 'sections' );
  936. $catName = AggregatorHelper::getfieldname( $content['catid'], 'categories' );
  937. $global_keywords[] = $sectionName;
  938. $global_keywords[] = $catName;
  939. }
  940.  
  941.  
  942. if ($params->get( 'compute_tags' )) {
  943. $content->metakey .= (!empty( $content['metakey'] ) ? ',' : '');
  944. $clean_title = $content['title'];
  945. $clean_title = preg_replace( '/\.|»|!|„|“|”|"|#|\$|%|&|\'|\'|\(|\)|\*|\+|:|;|<|=|>|\?|@|\[|\|]|^|_|`|{|\||}|~/', '', $clean_title );
  946. $clean_title = str_replace( ',', ' ', $clean_title );
  947. $clean_title = preg_replace( '/\s\s+/', ' ', $clean_title );
  948. $words = array_filter( explode( ' ', $clean_title ) );
  949. $keywords = array( );
  950. foreach ($words as $word) {
  951. if ($params->get( 'min_tag_chars' ) <= mb_strlen( $word )) {
  952. $keywords[] = mb_strtolower( $word );
  953. continue;
  954. }
  955. }
  956.  
  957. $keywords = array_slice( ($params->get( 'use_ignore_list' ) == '1' ? array_diff( $keywords, explode( ',', $params->get( 'ignore_list' ) ) ) : $keywords), 0, $params->get( 'max_tags' ) );
  958. }
  959.  
  960. $keywords = array_merge( $keywords, $global_keywords );
  961. switch ($params->get( 'meta_tags_reorder' )) {
  962. case 'shuffle': {
  963. shuffle( $keywords );
  964. break;
  965. }
  966.  
  967. case 'backwards': {
  968. $keywords = array_reverse( $keywords );
  969. }
  970. }
  971.  
  972. $meta_tags_tmp = $params->get( 'before_meta_tags' );
  973. $content['metakey'] = $params->get( 'before_meta_tags' ) . (!empty( $meta_tags_tmp ) ? ',' : '');
  974. $content->metakey .= implode( ',', $keywords );
  975. $meta_tags_tmp = $params->get( 'after_meta_tags' );
  976. $content->metakey .= (!empty( $meta_tags_tmp ) ? ',' : '') . $params->get( 'after_meta_tags' );
  977.  
  978. if ($params->get( 'google_translate' ) == 1) {
  979. if (!empty( $content['introtext'] )) {
  980. $content['introtext'] = doTranslate( $content['introtext'], $gt_call );
  981. }
  982.  
  983.  
  984. if (!empty( $content['fulltext'] )) {
  985. $content['fulltext'] = doTranslate( $content['fulltext'], $gt_call );
  986. }
  987. }
  988.  
  989. $insert_title = $params->get( 'insert_title_in_content', '' );
  990.  
  991. if (!empty( $insert_title )) {
  992. $orig_title = trim( $item->get_title( ) );
  993. switch ($insert_title) {
  994. case 'before': {
  995. $content['introtext'] = $orig_title . '. ' . $content['introtext'];
  996. $content['fulltext'] = $orig_title . '. ' . $content['fulltext'];
  997. break;
  998. }
  999.  
  1000. case 'after': {
  1001. $content->introtext .= $orig_title . '. ';
  1002. $content->fulltext .= $orig_title . '. ';
  1003. }
  1004. }
  1005. }
  1006.  
  1007. $shuffle_sentences_positions = $params->get( 'shuffle_sentences_positions', 0 );
  1008. $shuffle_sentences = $params->get( 'shuffle_sentences', 0 );
  1009.  
  1010. if (( $shuffle_sentences_positions || $shuffle_sentences )) {
  1011. $htmlregex = '#({*\s*.*?}|<a .*?</a\\ *>|<h[1-7].*?</h[1-7]\\ *>|<script[\s\S]*?<\/script>|</?.*?>|\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>)#i';
  1012. foreach (array( 'introtext', 'fulltext' ) as $current_content_text) {
  1013. $newContent = '';
  1014. $bits = preg_split( $htmlregex, $content[$current_content_text] );
  1015. preg_match_all( $htmlregex, $content[$current_content_text], $matches );
  1016. foreach ($bits as $i => $bit) {
  1017. if (!empty( $bit )) {
  1018. $arr = preg_split( '/[\.|!|\?]+/', preg_replace( '/".*"/e', '\'{BASE64}\'.base64_encode(\'\0\').\'{/BASE64}\'', $bit ) );
  1019.  
  1020. if (!empty( $arr )) {
  1021. $arr = array_map( 'trim', $arr );
  1022. $arr = array_filter( $arr );
  1023.  
  1024. if ($shuffle_sentences_positions) {
  1025. shuffle( $arr );
  1026. }
  1027.  
  1028.  
  1029. if ($shuffle_sentences) {
  1030. $sentences = array( );
  1031. reset( $arr );
  1032.  
  1033. while (list( , $ar ) = each( $arr )) {
  1034. $a = array_filter( array_map( 'trim', preg_split( '/\,/', $ar ) ) );
  1035. shuffle( $a );
  1036. $sentences[] = ucfirst( implode( ', ', $a ) );
  1037. }
  1038. }
  1039. else {
  1040. $sentences = $arr;
  1041. }
  1042.  
  1043. $bit = preg_replace( '/{BASE64}(.*?){\/BASE64}/e', 'stripslashes(base64_decode(\'\1\'))', implode( '. ', $sentences ) );
  1044. }
  1045. }
  1046.  
  1047. $newContent .= $bit;
  1048.  
  1049. if (isset( $matches[0][$i] )) {
  1050. $newContent .= $matches[0][$i];
  1051. continue;
  1052. }
  1053. }
  1054.  
  1055. $content[$current_content_text] = $newContent;
  1056. }
  1057. }
  1058.  
  1059. preg_match_all( '/^before_item\d+=(.*?)$/m', $feed->params, $matches );
  1060. $tmp_array = array_filter( $matches[1] );
  1061. sort( $tmp_array );
  1062. $before_item = (0 < $items = sizeof( $tmp_array ) ? $tmp_array[rand( 0, $items - 1 )] . ' ' : '');
  1063. preg_match_all( '/^after_item\d+=(.*?)$/m', $feed->params, $matches );
  1064. $tmp_array = array_filter( $matches[1] );
  1065. sort( $tmp_array );
  1066. $after_item = (0 < $items = sizeof( $tmp_array ) ? ' ' . $tmp_array[rand( 0, $items - 1 )] : '');
  1067. $item_content = (empty( $full_article_text ) ? $content['introtext'] : $content['fulltext']);
  1068. $read_more_pos = $params->get( 'read_more_pos' );
  1069. switch ($read_more_pos) {
  1070. case '1': {
  1071. $content['fulltext'] = $before_item . $item_content . $after_item;
  1072. $content['introtext'] = '';
  1073. break;
  1074. }
  1075.  
  1076. case '2': {
  1077. $content['fulltext'] = $item_content . $after_item;
  1078. $content['introtext'] = $before_item;
  1079. break;
  1080. }
  1081.  
  1082. case '3': {
  1083. $content['introtext'] = $before_item . $item_content;
  1084. $content['fulltext'] = $after_item;
  1085. break;
  1086. }
  1087.  
  1088. case '4': {
  1089. $content['introtext'] = $before_item . $item_content . $after_item;
  1090. $content['fulltext'] = '';
  1091. break;
  1092. }
  1093.  
  1094. default: {
  1095. $content['introtext'] = $before_item . $content['introtext'];
  1096. $content->(!empty( $content['fulltext'] ) ? 'fulltext' : 'introtext') .= $after_item;
  1097. }
  1098. }
  1099.  
  1100.  
  1101. if ($params->get( 'show_orig_link' )) {
  1102. $origLink = $item->get_permalink( );
  1103. $linkTxt = $params->get( 'orig_link_text' );
  1104. $target = '';
  1105.  
  1106. if ($params->get( 'target_frame' ) != 'none') {
  1107. $target = 'target="';
  1108. $target .= ($params->get( 'target_frame' ) == 'custom' ? $params->get( 'custom_frame' ) : $params->get( 'target_frame' ));
  1109. $target .= '"';
  1110. }
  1111.  
  1112.  
  1113. if (!empty( $origLink )) {
  1114. $readonlink = '<p>';
  1115. $readonlink .= '<strong>' . $linkTxt . '</strong> <a class="' . $params->get( 'orig_link_class', 'rssreadon' ) . '" rel="' . ($params->get( 'nofollow' ) == 1 ? 'nofollow' : 'external') . '" ';
  1116. $readonlink .= 'title="' . $content['title'] . '" href="' . $origLink . '" ' . $target . '>';
  1117. $readonlink .= ($params->get( 'shortlink' ) == '1' ? $content['title'] : $origLink) . '</a></p>';
  1118. }
  1119.  
  1120.  
  1121. if ($read_more_pos != '1') {
  1122. $content->introtext .= ($params->get( 'introlink' ) == '1' ? $readonlink : '');
  1123. }
  1124.  
  1125.  
  1126. if ($read_more_pos != '4') {
  1127. $content->fulltext .= $readonlink;
  1128. }
  1129. else {
  1130. if ($params->get( 'introlink' ) != '1') {
  1131. $content->introtext .= $readonlink;
  1132. }
  1133. }
  1134. }
  1135.  
  1136.  
  1137. if (trim( str_replace( '-', '', $alias ) ) == '') {
  1138. $alias = null;
  1139. }
  1140.  
  1141.  
  1142. if ($params->get( 'youtube_feed' ) == 1) {
  1143. $url_segments = parse_url( $item->get_permalink( ) );
  1144. parse_str( htmlspecialchars_decode( $url_segments['query'] ), $url_vars );
  1145. $youtube_width = (int)$params->get( 'youtube_width', '640' );
  1146.  
  1147. if ($youtube_width <= 0) {
  1148. $youtube_width = 640;
  1149. }
  1150.  
  1151. $youtube_height = (int)$params->get( 'youtube_height', '385' );
  1152.  
  1153. if ($youtube_height <= 0) {
  1154. $youtube_height = 385;
  1155. }
  1156.  
  1157.  
  1158. if (( isset( $url_vars['v'] ) && preg_match( '/[a-zA-Z0-9_-]+/', $url_vars['v'], $youtube_code ) )) {
  1159. $content['introtext'] = '<object width="' . $youtube_width . '" height="' . $youtube_height . '">
  1160. <param name="movie" value="http://www.youtube.com/v/' . $youtube_code[0] . '&amp;hl=en_US&amp;fs=1"></param>
  1161. <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
  1162. <embed
  1163. src="http://www.youtube.com/v/' . $youtube_code[0] . '&amp;hl=en_US&amp;fs=1"
  1164. type="application/x-shockwave-flash"
  1165. allowscriptaccess="always"
  1166. allowfullscreen="true"
  1167. width="' . $youtube_width . '"
  1168. height="' . $youtube_height . '"></embed>
  1169. </object><br />' . strip_tags( $content['introtext'], '<div><table><tbody><tr><td><img><span>' );
  1170. }
  1171. }
  1172.  
  1173. switch ($store_table) {
  1174. case 'k2': {
  1175. $query_table = '#__k2_items';
  1176. $query_where = ' AND trash=\'0\'';
  1177. break;
  1178. }
  1179.  
  1180. case 'content': {
  1181. }
  1182.  
  1183. default: {
  1184. }
  1185. }
  1186.  
  1187.  
  1188. while (true) {
  1189. $query_table = '#__content';
  1190. $query_where = ' AND (state=1 OR state=0)';
  1191.  
  1192. if () {
  1193. $query = 'SELECT COUNT(id) FROM ' . $db->nameQuote( $query_table ) . ' WHERE ';
  1194. $query .= (( !empty( $content['title'] ) && !empty( $alias ) ) ? 'alias = ' . $db->quote( $alias ) : (!empty( $content['title'] ) ? 'title = ' . $db->quote( $content['title'] ) . '' : 'introtext = ' . $db->quote( $content['introtext'] )));
  1195. $query .= $query_where;
  1196. unset( $query_table );
  1197. unset( $query_where );
  1198. $db->setQuery( $query );
  1199. $count = $db->loadResult( );
  1200.  
  1201. if (intval( $count ) == 0) {
  1202. if ($params->get( 'download_images' ) == 1) {
  1203. if (( !empty( $content['fulltext'] ) || !empty( $content['introtext'] ) )) {
  1204. downloadImages( &$content, $params->get( 'download_dir' ) );
  1205. }
  1206. }
  1207.  
  1208. $config = &JFactory::getconfig( );
  1209.  
  1210. $tzoffset = $config->getValue( 'config.offset' );
  1211. $itemDate = &JFactory::getdate( $item->get_date( ), $tzoffset );
  1212.  
  1213. $itemDate = $itemDate->toMySQL( );
  1214. $content['publish_up'] = $itemDate;
  1215.  
  1216. if ($content['publish_up'] < '2000-01-01 00:00:00') {
  1217. $content['publish_up'] = date( 'Y-m-d H:i:s', time( ) );
  1218. }
  1219.  
  1220. $content['alias'] = $alias;
  1221.  
  1222. if ($params->get( 'save_author' ) == '1') {
  1223. if (( $params->get( 'overwrite_author' ) == '1' && !empty( $feed->default_author ) )) {
  1224. $content['created_by_alias'] = $feed->default_author;
  1225. }
  1226. else {
  1227. if ($author = $item->get_author( )) {
  1228. $content['created_by_alias'] = $author->get_name( );
  1229. }
  1230.  
  1231.  
  1232. if (empty( $content['created_by_alias'] )) {
  1233. $content['created_by_alias'] = ($params->get( 'missing_author' ) == '0' ? $channelTitle : $feed->default_author);
  1234. }
  1235. }
  1236. }
  1237.  
  1238. $content['state'] = intval( $params->get( 'auto_publish' ) );
  1239. $publishDays = intval( $params->get( 'publish_days' ) );
  1240.  
  1241. if (( ( 0 < $content['state'] && $publishDays != 0 ) && !empty( $publishDays ) )) {
  1242. $content['publish_down'] = date( 'Y-m-d H:i:s', time( ) + $publishDays * 24 * 60 * 60 );
  1243. }
  1244.  
  1245. $content['access'] = $params->get( 'access_level', 1 );
  1246.  
  1247. if (!$ads_added) {
  1248. $content->(empty( $content['fulltext'] ) ? 'introtext' : 'fulltext') .= ' ' . $ads[array_rand( $ads )];
  1249. $ads_added = TRUE;
  1250. }
  1251.  
  1252. switch ($store_table) {
  1253. case 'k2': {
  1254. $instance = array( 'table' => 'K2Item', 'prefix' => 'Table' );
  1255. $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' );
  1256. $k2content = array_fill_keys( $k2content, null );
  1257. $k2content = array_intersect_key( $content, $k2content );
  1258. $k2content['published'] = $content['state'];
  1259. $k2content['catid'] = $params->get( 'k2catid' );
  1260. $k2content['featured'] = ($feed->front_page ? 1 : 0);
  1261. $k2content['language'] = '*';
  1262. $k2content['extra_fields'] = '[]';
  1263. $content = $k2content;
  1264. unset( $k2content );
  1265. break;
  1266. }
  1267.  
  1268. case 'content': {
  1269. }
  1270.  
  1271. default: {
  1272. }
  1273. }
  1274.  
  1275.  
  1276. while (true) {
  1277. $instance = array( 'table' => 'content', 'prefix' => 'JTable' );
  1278.  
  1279. if () {
  1280. $row = &JTable::getinstance( $instance['table'], $instance['prefix'] );
  1281.  
  1282. if (!$row->bind( $content )) {
  1283. $mosMsg = $title . '***ERROR: bind' . $db->getErrorMsg( );
  1284. $objResponse->addAppend( 'fgmsgarea', 'innerHTML', '<br />' . $mosMsg );
  1285. return $objResponse->getXML( );
  1286. }
  1287.  
  1288. switch ($store_table) {
  1289. case 'k2': {
  1290. break;
  1291. }
  1292.  
  1293. case 'content': {
  1294. }
  1295.  
  1296. default: {
  1297. }
  1298. }
  1299.  
  1300.  
  1301. while (true) {
  1302. $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":""}';
  1303. $row->access = '1';
  1304. $row->language = '*';
  1305.  
  1306. if () {
  1307. $row->id = (int)$row->id;
  1308. $user = &JFactory::getuser( );
  1309.  
  1310. $row->created_by = ($feed->created_by ? $feed->created_by : $user->get( 'id' ));
  1311.  
  1312. if (( $row->created && strlen( trim( $row->created ) ) <= 10 )) {
  1313. $row->created .= ' 00:00:00';
  1314. }
  1315.  
  1316. $row->created = $itemDate;
  1317.  
  1318. if (!$row->check( )) {
  1319. $e = '';
  1320. foreach ($row->getErrors( ) as $error) {
  1321. $e .= $error . '<br/>';
  1322. }
  1323.  
  1324. $mosMsg = '***ERROR*(check)* Feed - ' . $content['title'] . ':' . $db->getErrorMsg( ) . '<br/>' . $e;
  1325. $objResponse->addAppend( 'fgmsgarea', 'innerHTML', '<br />' . $mosMsg );
  1326. continue;
  1327. }
  1328.  
  1329.  
  1330. if (!$row->store( )) {
  1331. $mosMsg = $title . '***ERROR:' . $db->stderr( );
  1332. $objResponse->addAppend( 'fgmsgarea', 'innerHTML', '<br />' . $mosMsg );
  1333. return $objResponse->getXML( );
  1334. }
  1335.  
  1336. $row->checkin( );
  1337.  
  1338. if ($instance['table'] == 'content') {
  1339. $query = 'UPDATE #__assets SET rules = \'{"core.delete":[],"core.edit":[],"core.edit.state":[]}\' WHERE id=' . $row->asset_id;
  1340. $db->setQuery( $query );
  1341. $db->query( );
  1342.  
  1343. if (is_dir( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_advanced_tags' . DS )) {
  1344. $advanced_tags_check = &JComponentHelper::getcomponent( 'com_advanced_tags' );
  1345. }
  1346.  
  1347.  
  1348. if (( $params->get( 'advanced_tags_import' ) && !empty( $advanced_tags_check->id ) )) {
  1349. AggregatorAdvancedTagsImporter;
  1350. $metaimporter = &new ( $row->metakey, $row->id );
  1351.  
  1352. $metaimporter->import( );
  1353. }
  1354.  
  1355. $row->reorder( 'catid = ' . (int)$row->catid . ' AND state >= 0' );
  1356. TableFrontPage;
  1357. $fp = new ( $db );
  1358.  
  1359. if ($feed->front_page) {
  1360. if (!$fp->load( $row->id )) {
  1361. $query = 'INSERT INTO #__content_frontpage' . ' VALUES ( ' . (int)$row->id . ', 1 )';
  1362. $db->setQuery( $query );
  1363.  
  1364. if (!$db->query( )) {
  1365. $mosMsg = $title . '***ERROR:' . $db->getErrorMsg( );
  1366. $objResponse->addAppend( 'fgmsgarea', 'innerHTML', '<br />' . $mosMsg );
  1367. return $objResponse->getXML( );
  1368. }
  1369.  
  1370. $fp->ordering = 1;
  1371. }
  1372. }
  1373.  
  1374. $fp->reorder( );
  1375. $cache = &JFactory::getcache( 'com_content' );
  1376.  
  1377. $cache->clean( );
  1378. }
  1379.  
  1380. ++$nItems;
  1381. break 3;
  1382. }
  1383. }
  1384. }
  1385. }
  1386. }
  1387.  
  1388. break;
  1389. }
  1390. }
  1391. }
  1392. }
  1393. }
  1394.  
  1395. $last_run = $publishdate = date( 'Y-m-d H:i:s' );
  1396. $db->setQuery( '' . 'UPDATE #__aggregator SET last_run = \'' . $last_run . '\' WHERE id = \'' . $feedId . '\'' );
  1397. $db->query( );
  1398. $feedMsg = '' . '<b>' . $nItems . '</b> New content item(s) imported for <b>' . $curFeed . '</b> (' . $channelTitle . ').';
  1399. $objResponse->addAppend( 'fgmsgarea', 'innerHTML', $feedMsg . '<br />' );
  1400.  
  1401. if ($params->get( 'email_admin' ) == '1') {
  1402. $adminMsg = '<span class="feedmsg">' . $feedMsg . '</span>
  1403. ';
  1404. }
  1405.  
  1406. $endTime = time( );
  1407. $procTime = $endTime - $startTime;
  1408.  
  1409. if ($params->get( 'email_admin' ) == '1') {
  1410. $adminMsg = '<h1>Joomla Aggregator e-mail report</h1>
  1411. ';
  1412. $adminMsg .= '' . '<h2>Feed processed in ' . $procTime . ' seconds.</h2>
  1413. ';
  1414. $adminMsg .= '' . $nItems . ' New content items imported from <b>' . $curFeed . '</b> (' . $channelTitle . ')
  1415. ';
  1416. $adminMsg .= 'time finished: ' . date( 'D F j, Y, H:i:s T' ) . '
  1417.  
  1418.  
  1419. ';
  1420. $adminMsg .= '<span class=\'small\'>Visit our site <a href=\'http://3dwebdesign.org\'>3DWebDesign.org</a></span>
  1421. ';
  1422. $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>';
  1423. $query = 'SELECT name, email, sendEmail FROM #__users WHERE LOWER( usertype ) = "super administrator"';
  1424. $db->setQuery( $query );
  1425. $rows = $db->loadObjectList( );
  1426. $fromname = $rows[0]->name;
  1427. $mailfrom = $rows[0]->email;
  1428.  
  1429. if ($params->get( 'html_email' ) == '1') {
  1430. $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>';
  1431. $message = $css . nl2br( $adminMsg );
  1432. }
  1433. else {
  1434. $message = strip_tags( $adminMsg );
  1435. }
  1436.  
  1437. JUtility::sendmail( $mailfrom, $fromname, $params->get( 'admin_email' ), html_entity_decode( $params->get( 'email_subject' ), ENT_QUOTES ), $message, $params->get( 'html_email' ) );
  1438. }
  1439.  
  1440. $totItems += $nItems;
  1441. continue;
  1442. }
  1443. }
  1444.  
  1445. $objResponse->addAppend( 'fgmsgarea', 'innerHTML', '' . '<br /><b>' . $totItems . '</b> Content items imported in ' . $procTime . ' seconds.<br />' );
  1446. $closeLink = '<br /><a href="javascript:closeMsgArea();">Close this window</a><br />';
  1447. $objResponse->addAppend( 'fgmsgarea', 'innerHTML', $closeLink );
  1448. return $objResponse->getXML( );
  1449. }
  1450. }
  1451.  
  1452. ?>
Add Comment
Please, Sign In to add comment