importing 2007 sources
This commit is contained in:
parent
317c225654
commit
a8376dd19f
2 changed files with 214 additions and 0 deletions
22
README
Normal file
22
README
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
bboschecker - check for new BB device OS releases
|
||||
Copyright (C) 2007 troyengel
|
||||
|
||||
About
|
||||
=====
|
||||
This utility utilizes the OS downloads webpage at BlackBerryFAQ.com, walking
|
||||
through each carrier's OS download page searching for a match to the device
|
||||
model specified. When found this tool will load the OS page itself and report
|
||||
the "Applications" version(s) that it finds.
|
||||
|
||||
Requirements
|
||||
============
|
||||
- PHP webserver with cURL support (including SSL in cURL) compiled in
|
||||
|
||||
Most Red Hat/Fedora/CentOS and Ubuntu distros have the proper cURL/PHP/SSL
|
||||
support ready to run, and I'm sure there are many others as well ready to
|
||||
go (SuSE, Slackware, etc.) - when in doubt check your phpinfo() output.
|
||||
|
||||
License
|
||||
=======
|
||||
This code is licensed under the GPLv2.
|
||||
|
||||
192
bboschecker.php
Normal file
192
bboschecker.php
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
/*
|
||||
bboschecker 0.1 - check for new BB device OS releases
|
||||
Copyright (C) 2007 troyengel
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
*/
|
||||
|
||||
// where is the list of carriers?
|
||||
$BBF_LIST = "http://blackberryfaq.com/index.php/BlackBerry_Operating_System_Downloads";
|
||||
|
||||
// we will delay this many seconds when retrieving pages from the
|
||||
// RIM server, we don't want to be a bad netizen.
|
||||
$RIM_SLEEP = 1;
|
||||
|
||||
// the common download entry point (saves on useless parsing)
|
||||
$RIM_DLURL = "https://www.blackberry.com/Downloads/browseSoftware.do";
|
||||
|
||||
// the user agent we'll masquerade as
|
||||
$SCRIPT_UA = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
|
||||
|
||||
// where to store the session cookiejar
|
||||
$SCRIPT_CJ = "/tmp/bbos_cookies";
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>BlackBerry Device OS Checker</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3>BlackBerry Device OS Checker</h3>
|
||||
|
||||
<?php
|
||||
|
||||
// we need to set this globally and pass it around so that the session
|
||||
// and cookie jar work as a cohesive unit
|
||||
$curl_handle = curl_init();
|
||||
curl_setopt($curl_handle, CURLOPT_USERAGENT, $SCRIPT_UA);
|
||||
curl_setopt($curl_handle, CURLOPT_HEADER, FALSE);
|
||||
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, TRUE);
|
||||
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
curl_setopt($curl_handle, CURLOPT_COOKIEFILE, $SCRIPT_CJ);
|
||||
curl_setopt($curl_handle, CURLOPT_COOKIEJAR, $SCRIPT_CJ);
|
||||
|
||||
function getPage($url, $method="GET", $postfields="") {
|
||||
global $curl_handle;
|
||||
if (!is_string($url)) {
|
||||
return "";
|
||||
} else {
|
||||
curl_setopt($curl_handle, CURLOPT_URL, $url);
|
||||
if ($method == "POST") {
|
||||
curl_setopt($curl_handle, CURLOPT_POST, TRUE);
|
||||
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $postfields);
|
||||
} else {
|
||||
curl_setopt($curl_handle, CURLOPT_POST, FALSE);
|
||||
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "");
|
||||
}
|
||||
|
||||
$output = "";
|
||||
$output = @curl_exec($curl_handle);
|
||||
|
||||
if (curl_errno($curl_handle)) {
|
||||
print curl_error($curl_handle);
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!is_string($output) || !strlen($output)) {
|
||||
echo "Failure Contacting Server";
|
||||
return "";
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['device']) && is_numeric($_REQUEST['device'])) {
|
||||
|
||||
$device = $_REQUEST['device'];
|
||||
// IE hack - it buffers and won't display unless 256b
|
||||
print(str_repeat(" ", 300) . "\n");
|
||||
|
||||
echo "Downloading carrier list from BlackBerryFAQ... ";
|
||||
flush();
|
||||
$carriers = getPage($BBF_LIST);
|
||||
echo "<b>done</b>.<br>\n";
|
||||
flush();
|
||||
|
||||
echo "Parsing carrier list for links... ";
|
||||
flush();
|
||||
$link_array = array();
|
||||
$cnt_array = explode("\n", $carriers);
|
||||
foreach ($cnt_array as $line) {
|
||||
if (stristr($line, "www.blackberry.com")) {
|
||||
// http://www.the-art-of-web.com/php/parse-links/
|
||||
$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
|
||||
if (preg_match_all("/$regexp/siU", $line, $matches, PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
# $match[2] = link address
|
||||
# $match[3] = link text
|
||||
$link_array[$match[2]] = $match[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "<b>done</b>.<br><br>\n";
|
||||
flush();
|
||||
|
||||
echo "Searching for OS releases for the BlackBerry <b>$device</b><br><br>\n";
|
||||
flush();
|
||||
reset($link_array);
|
||||
while (list($link, $title) = each($link_array)) {
|
||||
echo "Checking <a href=\"$link\"><b>$title</b></a>...<br>\n";
|
||||
flush();
|
||||
$rim_page = getPage($link);
|
||||
$rim_array = explode("\n", $rim_page);
|
||||
$got_v = 0;
|
||||
$got_c = 0;
|
||||
$value = "";
|
||||
$code = "";
|
||||
foreach ($rim_array as $line) {
|
||||
// get the value
|
||||
if (stristr($line, $device)) {
|
||||
$regexp = "<option\svalue=\"([^\"]*)\">(.*)<\/option>";
|
||||
if (preg_match("/$regexp/siU", $line, $match)) {
|
||||
$got_v = 1;
|
||||
$value = $match[1];
|
||||
}
|
||||
}
|
||||
// get the code
|
||||
if (stristr($line, "type=\"hidden\" name=\"code\"")) {
|
||||
$regexp = "value=\"([^\"]*)\"(.*)";
|
||||
if (preg_match("/$regexp/siU", $line, $match)) {
|
||||
$got_c = 1;
|
||||
$code = $match[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($got_v && $got_c) {
|
||||
echo " Found one, retrieving product page...<br>\n";
|
||||
flush();
|
||||
$postvars = "productName=$value&code=$code";
|
||||
$os_page = getPage($RIM_DLURL, "POST", $postvars);
|
||||
$os_array = explode("\n", $os_page);
|
||||
foreach ($os_array as $osline) {
|
||||
if (stristr($osline, "Applications:")) {
|
||||
$result = preg_replace("/<(.*)>/siU", "", $osline);
|
||||
echo " <b>$result</b><br>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
sleep($RIM_SLEEP);
|
||||
}
|
||||
|
||||
echo "<br><b>All done!</b><br>\n";
|
||||
|
||||
} else {
|
||||
?>
|
||||
|
||||
Enter the model number ONLY of the device.<br>
|
||||
(7290, 8100, 8320, 8800, etc.)<br>
|
||||
<form name="deviceselect" method="GET" action="<?php $_PHP_SELF; ?>">
|
||||
<br>
|
||||
<input type="text" size="10" name="device">
|
||||
<input type="submit" value="Search Carriers">
|
||||
</form>
|
||||
|
||||
<b>Note</b>: This tool will only search carriers who<br>
|
||||
host their downloads on www.blackberry.com<br>
|
||||
|
||||
<?php
|
||||
} // device
|
||||
curl_close($curl_handle);
|
||||
?>
|
||||
|
||||
<br>
|
||||
Code: <a href="https://github.com/troyengel/bboschecker">bboschecker on github</a><br>
|
||||
Released under the <a href="http://www.gnu.org/licenses/gpl-2.0.txt">GPLv2 license</a><br>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in a new issue