private function update_news() { if (file_exists(guildnewsfeed::$cachefile)) { if (time() - guildnewsfeed::$updatetime * 60 < filemtime(guildnewsfeed::$cachefile)) { return; } } $fp = fopen(guildnewsfeed::$feedurl, "r"); $inul = 0; $inli = 0; $line = 0; $li = array(); while (!feof($fp)) { $input = fgets($fp); if (preg_match("/<ul class=\"activity-feed activity-feed-wide\">/", $input)) { $inul = 1; } if ($inul && preg_match("/<\\/ul>/", $input)) { $inul = 0; } if ($inul) { if (preg_match("/<li[^>]*>/", $input)) { $inli = 1; } if ($inli) { $li[$line] .= trim($input); } if ($inli && preg_match("/<\\/li>/", $input)) { $inli = 0; $line++; } } } fclose($fp); $fp = fopen(guildnewsfeed::$cachefile, "w"); foreach ($li as $x) { fwrite($fp, guildnewsfeed::process($x) . "\n"); } fclose($fp); }
<?php /** * @package Guild News Feed Module for joomla 1.5 * @author Brad Cimbura * @copyright (C) 2010- Brad Cimbura * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html * @link http://soylentcode.com/ **/ //don't allow other scripts to grab and execute our file defined('_JEXEC') or die('Direct Access to this location is not allowed.'); require_once dirname(__FILE__) . DS . 'helper.php'; guildnewsfeed::setvars($params->get('realm'), $params->get('guild'), $params->get('updatetimer'), $params->get('displaycount')); $data = guildnewsfeed::getdata(); require JModuleHelper::getLayoutPath('mod_guildnewsfeed');