Example #1
0
<?php

function test_function(&$text)
{
    echo "Text is {$text}\n";
    $text = "Something new";
}
$testing = "Something";
$existing = "Existing";
$nullset = null;
test_function($testing === null ? $testing : $existing);
test_function($nullset === null ? $existing : $nullset);
if ($testing === null) {
    test_function($testing);
} else {
    test_function($existing);
    // $existing should have a new value after this, but it doesn't
}
if ($nullset === null) {
    test_function($existing);
} else {
    test_function($nullset);
}
Example #2
0
<?php 
header('Content-type: application/json');
test_function();
function test_function()
{
    //$return = $_POST;
    if (!empty($_GET['strAddr']) && !empty($_GET['city']) && !empty($_GET['state']) && !empty($_GET['temperature'])) {
        $addrs = urlencode($_GET['strAddr']);
        $city = urlencode($_GET['city']);
        $state = urlencode($_GET['state']);
        $degree = $_GET['temperature'];
        //echo "https://maps.google.com/maps/api/geocode/xml?address=".$addrs.",".$city.",".$state."&key=AIzaSyAGmGeW3ReonNiDCXE5pEw3kNW52J9VntI";
        $GoogleXMLFile = @simplexml_load_file("https://maps.google.com/maps/api/geocode/xml?address=" . $addrs . "," . $city . "," . $state . "&key=AIzaSyDXJc-HfeU4ZVttzpruI8Q04ZZtzqv4-is") or die("<script>alert('Unable to get XML for Location');</script>");
        $LocArray = GetLocationfromXML($GoogleXMLFile);
        $ApiUrl = "https://api.forecast.io/forecast/e0233df5fb8a3299a02c55c843c4d5dd/" . $LocArray[0] . "," . $LocArray[1] . "?units=" . $degree . "&exclude=flag";
        $JSON_File = file_get_contents($ApiUrl);
        $JSON_Obj = json_decode($JSON_File, true);
        //$return["json"] = json_decode($JSON_File, true);
        echo json_encode($JSON_Obj);
    }
}
function GetLocationfromXML($GoogleXMLFile)
{
    if (strcmp($GoogleXMLFile->xpath("/GeocodeResponse/status")[0], "OK") == 0) {
        $LatArr = array();
        $LngArr = array();
        $LatArr = $GoogleXMLFile->xpath("/GeocodeResponse/result/geometry/location/lat");
        $LngArr = $GoogleXMLFile->xpath("/GeocodeResponse/result/geometry/location/lng");
        $LocArray = array(2);
        $LocArray[0] = $LatArr[0];
Example #3
0
if ($pl) {
    echo m("MPD commands:") . " " . print_yesno($has_commands, true) . "<br />\n";
}
echo m("Metadata directory:") . " " . print_yesno(file_exists($metadata_dir) && is_writeable($metadata_dir) || !file_exists($metadata_dir) && is_writeable($config_dir), true);
?>
</p>

<h3><?php 
echo m("Functions:");
?>
</h3>
<p style='padding: 0px 0px 4px 0px; '>
<?php 
// name:fatal
foreach (array("json_encode:0", "simplexml_load_string:1", "mb_internal_encoding:0") as $f) {
    test_function($f);
}
echo "SimpleXMLaddChild: ";
$sxe = array_to_xml(array("test"));
if ($sxe) {
    echo print_yesno(is_callable(array($sxe, "addChild"), true), true) . "<br/>";
} else {
    echo "<span class='color: red'>error</span>\n";
}
$mem = ceil(return_bytes(ini_get("memory_limit")) / (1024 * 1024));
echo m("PHP memory limit:") . " <span style='color: " . ($mem < 32 ? "orange" : "green") . "'>" . $mem . "MB</span>";
?>
</p>
<?php 
if (get_magic_quotes_runtime()) {
    echo "<p style='color: orange'>";