/** * Read the RSS XML data from CL and turn it into a usable array datastructure * @param array $location craigslist section * @return array */ private static function _get_records(array $location) { $string = Utils::getFileCache($location['url']); if (!$string) { return array(); } $xml = simplexml_load_string($string, 'SimpleXMLElement', LIBXML_NOCDATA); $search_items = array(); foreach ($xml->item as $item) { $info = get_object_vars($item); $dc_nodes = $item->children('http://purl.org/dc/elements/1.1/'); $dc = get_object_vars($dc_nodes); $data = $info + $dc; unset($data['description']); $search_items[] = array_merge($data, array('location' => $location['partial'])); } return $search_items; }
return false; } set_time_limit(60 * 3); error_reporting(E_ALL); ini_set('error_log', './php_errors.log'); date_default_timezone_set('America/Los_Angeles'); require_once __DIR__ . '/../vendor/autoload.php'; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\ParameterBag; use Silex\Application; use Silex\Provider\TwigServiceProvider; use App\CLAgg\ReadConfig; use App\CLAgg\Scraper; use App\CLAgg\Utils; Utils::$cache_url = './../cache/data/'; $app = new Application(); $sites = array('findstuff' => false, 'findjobs' => false, 'findgigs' => false, 'findplaces' => false, 'findservices' => false); $app->register(new TwigServiceProvider(), array('twig.path' => './../views', 'twig.options' => array('cache' => false))); $app->before(function (Request $request) { if (0 === strpos($request->headers->get('Content-Type'), 'application/json')) { $data = json_decode($request->getContent(), true); $request->request->replace(is_array($data) ? $data : array()); } }); $app->get('/', function (Request $req) use($app, $sites) { return $app['twig']->render('index.html.twig', array('title' => 'My Kraigslist Search', 'server_name' => $_SERVER['SERVER_NAME'], 'sites' => $sites)); }); $app->get('/assets/{type}', function (Request $req, $type) use($app, $sites) { switch ($type) { case 'css':