public function test($value, $expected, $testName)
 {
     if ($value != $expected) {
         failed("{$testName} - Expected '{$expected}', Got: '{$value}'");
     } else {
         logMessage("  Passed: {$testName} - value '{$value}'");
     }
 }
function mo_http_request($uri, $context)
{
    global $http_response_header;
    $result = file_get_contents($uri, false, $context);
    if ($result === false) {
        failed($http_response_header);
    }
    return $result;
}
Esempio n. 3
0
';
			</script>
		<?php 
            } else {
                $d = mysql_query("update ref_kelurahan set kelurahan='{$nama}' where id_kelurahan='" . $_GET["id_prov"] . "'");
                if ($d) {
                    benar("./index.php?mod=home&opt=kel&opts=list");
                } else {
                    salah("./index.php?mod=home&opt=kel&opts=edit&id_wilayah=" . $_GET["id_prov"]);
                }
            }
        } else {
            failed();
        }
    } else {
        if ((int) $_GET["mode"] == 3) {
            if ($_GET["id_prov"] != 0) {
                $d = mysql_query("delete from ref_kelurahan where id_kelurahan='" . $_GET["id_prov"] . "'");
                if ($d) {
                    benar("./index.php?mod=home&opt=kel&opts=list");
                } else {
                    salah("./index.php?mod=home&opt=kel&opts=list");
                }
            } else {
                failed();
            }
        } else {
            failed();
        }
    }
}
Esempio n. 4
0
    });
}
//var_dump(download(new ChapterPage(
//    new Chapter('Sudome', 'http://www.mangatown.com/manga/sundome/v01/c002/3.html'),
//    new Page('03', 'http://www.mangatown.com/manga/sundome/v01/c002/3.html'),
//    new PageImage('http://a.mangatown.com/store/manga/3412/01-002.0/compressed/002.jpg?v=51215960241')
//)));
//die;
IO\getArgs()->map(get(0))->map(function (Maybe\Maybe $argument) {
    return $argument->map(function ($mangaUrl) {
        var_dump('started ', $mangaUrl);
        $mangaData = fetchMangaData($mangaUrl);
        var_dump('manga data ready');
        $afterDownload = $mangaData->map(f\map(f\map(download)));
        var_dump('manga first run');
        $afterDownload->map(function (Collection $collection) {
            $ttl = 2;
            do {
                var_dump('re-download');
                $toRetry = f\filter(function (Maybe\Maybe $maybe) {
                    return $maybe->extract() instanceof Either\Left;
                }, $collection);
                $count = count($toRetry);
                $collection = Collection::of($toRetry)->map(function ($a) use(&$ttl, $count) {
                    var_dump('retry', $ttl, $count);
                    return failed($a, $ttl);
                });
            } while (count($toRetry) > 0);
        });
    });
})->run();
Esempio n. 5
0
    $id = intval($id);
    $mysqli->query("DELETE FROM photos WHERE photos.id = {$id}");
    error("Something went wrong when uploading your file!");
}
// Variables
$time = time();
$name = $_FILES['photo']['name'];
$tmp_name = $_FILES['photo']['tmp_name'];
$ext = explode(".", $name);
$ext = end($ext);
$allowedExts = array('png', 'jpeg', 'jpg', 'gif');
$destination = "{$CONFIG['SITE_DIR']}photos/files/";
// error checking
if (!strlen($tmp_name)) {
    error("You need to upload a file.");
}
if (!in_array($ext, $allowedExts)) {
    error("Incorrect file type.");
}
// Mysql query
$mysqli->query("INSERT INTO photos (`user_id`,`datestamp`) VALUES ({$viewer->id},{$time})");
$id = $mysqli->insert_id;
// Finish destination
$destination .= "{$id}.{$ext}";
// Photo upload
move_uploaded_file($tmp_name, $destination);
if (file_exists($destination)) {
    header("Location: {$_SERVER['HTTP_REFERER']}");
} else {
    failed($id);
}
    $decode = json_decode($result, true);
    if (!isset($decode["id"])) {
        failed($decode);
    }
    $SERVERS[$decode["id"]] = isset($decode["mongodb_auth_uri"]) ? $decode["mongodb_auth_uri"] : $decode["mongodb_uri"];
    printf("'%s'\t(took: %.2f secs)\n", $SERVERS[$decode["id"]], lap());
}
echo "---\n";
foreach ($PRESETS["replicasets"] as $preset) {
    lap();
    $json = json_decode(file_get_contents($preset), true);
    printf("Starting %-20s ...  ", $json["id"]);
    $result = file_get_contents(getMOUri() . "/replica_sets", false, make_ctx(getMOPresetBase() . $preset));
    $decode = json_decode($result, true);
    if (!isset($decode["id"])) {
        failed($decode);
    }
    $SERVERS[$decode["id"]] = isset($decode["mongodb_auth_uri"]) ? $decode["mongodb_auth_uri"] : $decode["mongodb_uri"];
    printf("'%s'\t(took: %.2f secs)\n", $SERVERS[$decode["id"]], lap());
}
file_put_contents($FILENAME, json_encode($SERVERS, JSON_PRETTY_PRINT));
/*
wget --body-data='' --method='GET' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE-AUTH
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE-24
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE-26
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/RS-two
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/RS-arbiter
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE-PLAIN
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE-X509