Пример #1
0
 function config_xml($memcache_expire = 0)
 {
     global $rsscache_config_xml;
     static $config = NULL;
     if ($config) {
         return $config;
     }
     if ($memcache_expire > 0) {
         $memcache = new Memcache();
         if ($memcache->connect('localhost', 11211) == TRUE) {
             // data from the cache
             $p = $memcache->get(md5($rsscache_config_xml[0]));
             if ($p != FALSE) {
                 $p = unserialize($p);
                 // DEBUG
                 //            echo 'cached';
                 echo $p;
                 rsscache_sql_close();
                 exit;
             }
         } else {
             echo 'ERROR: could not connect to memcached';
             rsscache_sql_close();
             exit;
         }
     }
     // DEBUG
     //  echo 'read config';
     $config = array();
     if (!is_array($rsscache_config_xml)) {
         $config[] = simplexml_load_file($rsscache_config_xml, 'SimpleXMLElement', LIBXML_NOCDATA);
     } else {
         for ($i = 0; isset($rsscache_config_xml[$i]); $i++) {
             $config[] = simplexml_load_file($rsscache_config_xml[$i], 'SimpleXMLElement', LIBXML_NOCDATA);
         }
     }
     // DEBUG
     //  echo '<pre><tt>';
     //  print_r ($config);
     //exit;
     $config = config_xml_normalize($config);
     // DEBUG
     //  echo '<pre><tt>';
     //  print_r ($config);
     //exit;
     // use memcache
     if ($memcache_expire > 0) {
         $memcache->set(md5($rsscache_config_xml[0]), serialize($config), 0, $memcache_expire);
     }
     return $config;
 }
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//phpinfo ();
//error_reporting(E_ALL | E_STRICT);
require_once '../htdocs/rsscache/default.php';
require_once '../htdocs/config.php';
require_once '../htdocs/misc/misc.php';
require_once '../htdocs/misc/sql.php';
require_once '../htdocs/misc/rss.php';
require_once '../htdocs/misc/youtube.php';
require_once '../htdocs/rsscache/rsscache_sql.php';
require_once '../htdocs/rsscache/rsscache_misc.php';
// main ()
// unlimited execution time
//ini_set('max_execution_time', '3600');
set_time_limit(0);
rsscache_sql_open();
$config = config_xml();
echo misc_exec('/etc/init.d/tor restart');
// DEBUG
echo 'database: ' . $rsscache_dbname . ' (' . $rsscache_dbuser . ')' . "\n";
for ($i = 0; isset($config['item'][$i]); $i++) {
    if (isset($config['item'][$i]['category'])) {
        print_r($config['item'][$i]);
        rsscache_download_feeds_by_category($config['item'][$i]['category']);
    }
}
rsscache_sql_close();
exit;