Пример #1
0
}
$db = new PDO('mysql:host=localhost;dbname=hashes;charset=utf8', $db_user, $db_pswd);
$ipfs = new IPFS("localhost", "8080", "5001");
$hostname = $_SERVER['HTTP_HOST'];
$host = $_SERVER['HTTP_HOST'];
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
    $protocol = "https";
} else {
    $protocol = "http";
}
define("defaultTitle", "A picture hosted on the permanent web");
define("defaultThumbnail", $protocol . "://" . $host . "/ipfs/{$hash}");
define("defaultDescription", "Click to see it");
$info = $db->query("SElECT * FROM hash_info WHERE hash='{$hash}'")->fetch();
if ($info['hash']) {
    $dirContent = $ipfs->ls($hash);
    $isDir = $dirContent[0]['Name'] != "";
    $isBanned = $info['banned'];
    $isBackendWorking = True;
    $isSafe = $info['sfw'];
} else {
    $isBanned = false;
    $isSafe = false;
    $dirContent = $ipfs->ls($hash);
    $isBackendWorking = $dirContent != "";
    $isDir = $dirContent[0]['Name'] != "";
    if ($isDir) {
        $type = "dir";
    } else {
        $type = "file";
    }