Mam problem z wolno działającym skryptem
ma on pobrać RSS do bazy danych
Oto skrypt:
<?php date_default_timezone_set('Europe/Warsaw'); // required since PHP 5.4(?) require_once 'database/compatibility_patch.php'; require_once 'database/DB.php'; if ( ! $db ){ 'hostname' => 'localhost', 'username' => 'zmoderowane', 'password' => 'zmoderowane', 'database' => 'rss', 'dbprefix' => '', 'dbdriver' => 'mysql', 'pconnect' => true, 'db_debug' => true, 'cache_on' => false, 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', ); try { $db = DB($dbconfig); } catch ( Exception $e ){ } } switch ($_REQUEST['action']){ case 'cron-crawl-rss': $url = 'http://wiadomosci.gazeta.pl/pub/rss/wiadomosci_kraj.htm'; require_once 'phpquery.php'; $content_type = null; // auto $xml = phpQuery::newDocument($data, $content_type); $len = $xml->find('item')->length; // var_dump($items);exit; $i = 0; while ( $i < $len ){ $title = $xml->find('item:eq('.$i.') title')->text(); $link = $xml->find('item:eq('.$i.') link')->text(); 'title' => $title, 'link' => $link, ); $i += 1; } $exists = 0; $inserted = 0; // var_dump($items);exit; foreach ($items as $item){ $result = $db ->where('link', $item['link']) ->limit(1) ->get('rss') ->row_array(); if ( $result ){ $exists += 1; } else { $db ->set('title', $item['title']) // ->set('body', ) // ->set('thumb', ) ->set('link', $item['link']) ->insert('rss'); $inserted += 1; } } // 'code' => 100, 'message' => 'OK', 'slug' => 'ok', 'status' => 'success', 'exists' => $exists, 'inserted' => $inserted, ); break; default: 'status' => 'error', 'message' => 'No action.', ); break; } if ( $db ){ $db->close(); } // header('Access-Control-Allow-Headers: Content-Type'); } } if ( ! $_no_output ){ if ( $_REQUEST['callback'] ){ } } else { } } }
a to jest link: http://rss.myfreespace.us/run.php?action=cron-crawl-rss
Ktoś może wie dlaczego to tak muli czasami?