PHP Code:
<title>Zachafer's Quest Helper</title>
<center>
<form action="" method="POST">
Item to lookup: <input type="text" name="item" value="<?php echo @$_REQUEST['item']; ?>" /><br />
<input type="submit" value="Search" /></form>
<?php
if (@$_REQUEST['item']) {
echo "<hr />\n";
$log = @file_get_contents('log.txt');
$ip = $_SERVER['REMOTE_ADDR'];
$limit = 3;
if (preg_match_all('/^(\d+):' . preg_quote($ip) . '$/m', $log, $logs)) {
$uses = 0;
for ($x = count($logs[0]) - 1; $x >= 0; $x--) {
if (strtotime('+1 hour', $logs[1][$x]) > time()) {
if (++$uses >= 3)
die("You have used your $limit searches per hour!");
}
}
}
$cookie = @file_get_contents('cookie.txt');
if (!preg_match('/^neologin=([a-z\d_]{3,20}%2B[a-z\d].+?);/i', $cookie)) {
$cookie = updateCookie();
}
$result = searchItem($cookie);
if (preg_match('%^Location: /login%im', $result)) {
$cookie = updateCookie();
$result = searchItem($cookie);
if (preg_match('%^Location: /login%im', $result)) {
die('Error logging into account! Account could possibly be iced. Please <a href="http://clraik.com/forum/private.php?do=newpm&u=128">notify Zachafer</a>.');
}
}
@file_put_contents('log.txt', time() . ":$ip\n", FILE_APPEND | LOCK_EX);
if (preg_match_all('%(/browseshop\.phtml\?owner=([a-z\d_]{3,20})&buy_obj_info_id=\d+&buy_cost_neopoints=(\d+))%i',
$result, $items)) {
preg_match('%<span style="font-size: 14pt;">(.+)</span>%i', $result, $item);
$item = $item[1];
echo "<TABLE BORDER=1>\n<CAPTION ALIGN=TOP><B>$item:</B></CAPTION>";
echo "<TR>\n<TD>Shop Owner</TD>\n<TD>Item Cost</TD>\n<TD>Buy Link</TD>\n</TR>\n";
for ($x = 0; $x < count($items[0]); $x++) {
echo "<TR>\n<TD>" . $items[2][$x] . "</TD>\n";
echo '<TD>' . number_format($items[3][$x]) . " NP</TD>\n";
echo '<TD><a href="http://hidemyass.com/?http://www.neopets.com' . $items[1][$x] .
'">Buy Now</TD>';
echo "\n</TR>\n";
}
echo '</TABLE>';
} else {
die("Error finding " . @$_REQUEST['item'] . ". I am probably shop wiz banned.");
}
}
function searchItem($cookie)
{
$item = str_replace(' ', '+', @$_REQUEST['item']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.neopets.com/market.phtml');
curl_setopt($ch, CURLOPT_POSTFIELDS, "type=process_wizard&feedset=0&shopwizard=$item&table=shop&criteria=exact&min_price=0&max_price=99999");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_REFERER,
'http://www.neopets.com/market.phtml?type=wizard');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
function updateCookie()
{
$user = '';
$pass = '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.neopets.com/login.phtml');
curl_setopt($ch, CURLOPT_POSTFIELDS, "destination=%252Findex.phtml&username=$user&password=$pass");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
if (!preg_match('/(neologin=[a-z\d_]{3,20}%2B[a-z\d].+?);/i', $result, $newcookie)) {
die('Error checking shop wiz - Please <a href="http://clraik.com/forum/private.php?do=newpm&u=128">notify Zachafer</a>.');
}
@file_put_contents('cookie.txt', $newcookie[1], LOCK_EX);
return $newcookie[1];
}
?><title>Zachafer's Quest Helper</title>
<center>
<form action="" method="POST">
Item to lookup: <input type="text" name="item" value="<?php echo @$_REQUEST['item']; ?>" /><br />
<input type="submit" value="Search" /></form>
<?php
if (@$_REQUEST['item']) {
echo "<hr />\n";
$log = @file_get_contents('log.txt');
$ip = $_SERVER['REMOTE_ADDR'];
$limit = 3;
if (preg_match_all('/^(\d+):' . preg_quote($ip) . '$/m', $log, $logs)) {
$uses = 0;
for ($x = count($logs[0]) - 1; $x >= 0; $x--) {
if (strtotime('+1 hour', $logs[1][$x]) > time()) {
if (++$uses >= 3)
die("You have used your $limit searches per hour!");
}
}
}
$cookie = @file_get_contents('cookie.txt');
if (!preg_match('/^neologin=([a-z\d_]{3,20}%2B[a-z\d].+?);/i', $cookie)) {
$cookie = updateCookie();
}
$result = searchItem($cookie);
if (preg_match('%^Location: /login%im', $result)) {
$cookie = updateCookie();
$result = searchItem($cookie);
if (preg_match('%^Location: /login%im', $result)) {
die('Error logging into account! Account could possibly be iced. Please <a href="http://clraik.com/forum/private.php?do=newpm&u=128">notify Zachafer</a>.');
}
}
@file_put_contents('log.txt', time() . ":$ip\n", FILE_APPEND | LOCK_EX);
if (preg_match_all('%(/browseshop\.phtml\?owner=([a-z\d_]{3,20})&buy_obj_info_id=\d+&buy_cost_neopoints=(\d+))%i',
$result, $items)) {
preg_match('%<span style="font-size: 14pt;">(.+)</span>%i', $result, $item);
$item = $item[1];
echo "<TABLE BORDER=1>\n<CAPTION ALIGN=TOP><B>$item:</B></CAPTION>";
echo "<TR>\n<TD>Shop Owner</TD>\n<TD>Item Cost</TD>\n<TD>Buy Link</TD>\n</TR>\n";
$max = count($items[0]);
for ($x = 0; $x < $max; $x++) {
echo "<TR>\n<TD>" . $items[2][$x] . "</TD>\n";
echo '<TD>' . number_format($items[3][$x]) . " NP</TD>\n";
echo '<TD><a href="http://hidemyass.com/?http://www.neopets.com' . $items[1][$x] .
'">Buy Now</TD>';
echo "\n</TR>\n";
}
echo '</TABLE>';
} else {
die("Error finding " . @$_REQUEST['item'] . ". I am probably shop wiz banned.");
}
}
function searchItem($cookie)
{
$item = str_replace(' ', '+', @$_REQUEST['item']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.neopets.com/market.phtml');
curl_setopt($ch, CURLOPT_POSTFIELDS, "type=process_wizard&feedset=0&shopwizard=$item&table=shop&criteria=exact&min_price=0&max_price=99999");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_REFERER,
'http://www.neopets.com/market.phtml?type=wizard');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
function updateCookie()
{
$user = '';
$pass = '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.neopets.com/login.phtml');
curl_setopt($ch, CURLOPT_POSTFIELDS, "destination=%252Findex.phtml&username=$user&password=$pass");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
if (!preg_match('/(neologin=[a-z\d_]{3,20}%2B[a-z\d].+?);/i', $result, $newcookie)) {
die('Error checking shop wiz - Please <a href="http://clraik.com/forum/private.php?do=newpm&u=128">notify Zachafer</a>.');
}
@file_put_contents('cookie.txt', $newcookie[1], LOCK_EX);
return $newcookie[1];
}
?>