search.php
<?php
$q = $_REQUEST['q'];
$city = $_REQUEST['city'];
$url = 'http://' . $city . '.craigslist.org/search/sss?query=' . urlencode($q);
header('Content-type: text/plain');
$lines = file($url);
foreach ($lines as $ln) {
$ln = trim($ln);
if (preg_match('/<p> [A-Z][a-z][a-z]-\s*\d+\s*/',$ln)) {
echo $ln;
echo "\n";
}
}
?>
index.php
<?php
$SCRIPTS = array('main.js', '../javascripts/prototype.js');
include "../head.php";
include "cities.php";
?>
<h2>search craigslist</h2>
<?php
$q = $_REQUEST['q'];
if (!$q) echo '<p>Input a search (e.g. <a href="?q=wired+magazines">wired magazines</a>) to search craiglist over multiple cities</p>';
?>
<form onsubmit="search(); return false" method="get">
<p>
<input type="text" value="<?php echo $q ?>" id="q" name="q" length="10" class="tbox">
<input type="submit" value="Get"> <em id="note"></em>
<br/>
select
<a href="#" onclick="selectAll()">all</a> |
<a href="#" onclick="selectNone()">none</a>
or <a href="index.php">reload</a>
& here's the <a href="main.js">js</a> + <a href="source.php">php</a> source as proof this is harmless
<?php
foreach ($cities as $n => $v) {
echo '<br/><input type="checkbox" class="o" value="' . $v . '"> ' . $n . '</input>';
echo '<span style="display:inline; overflow:auto; maximum-height:300px; max-height:300px; " id="' . $v . '_div"></span>';
}
?>
</p>
</form>
<?php
if ($q) {
}
?>
<?php include "../foot.php"; ?>
source.php
<?php
$files = array('search','index','source');
foreach ($files as $f) {
$n = $f . '.php';
echo '<h2>' . $n . '</h2>';
highlight_file($n);
}
?>