====== PHP ======
Here are some snippets for if you're stuck writing PHP.
# full current URL
function current_url() {
$pageURL = 'http';
if (@$_SERVER["HTTPS"] == "on") $pageURL .= "s";
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
# URL to this script, skipping parameters, and not excising "index.php"
function script_url() {
$pageURL = 'http';
if (@$_SERVER["HTTPS"] == "on") $pageURL .= "s";
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["SCRIPT_NAME"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["SCRIPT_NAME"];
}
return $pageURL;
}
# true if string $str ends with $test
function endswith($str,$test) {
return substr_compare($str, $test, -strlen($test), strlen($test)) === 0;
}
===== Android App Inventor TinyWebDB interface =====
[[http://www.android.com/|Android]] is a mobile platform. [[http://appinventor.googlelabs.com/|App Inventor]] lets you make apps quickly and easily for Android without coding. [[http://appinventor.googlelabs.com/learn/reference/other/tinywebdb.html|TinyWebDB]] is a web transaction mechanism originally intended for storing data remotely, but which can be co-opted for any web-based operations. Here's some code that will speak TinyWebDB protocol for both the get & set methods. If you go to this script with a regular browser, it will tell you what the service URL should be.
TinyWebDB interface
Hello. Point your TinyWebDB-based app to this location: $url