Пример #1
0
        $add = $db->prepare("INSERT INTO hash_info (hash, type, first_seen) VALUES (:hash, :type, UNIX_TIMESTAMP())");
        $add->bindParam(":hash", $hash);
        $add->bindParam(":type", $type);
        $add->execute();
        $ipfs->pinAdd($hash);
    }
}
$title = constant("defaultTitle");
$thumbnail = constant("defaultThumbnail");
$description = constant("defaultDescription");
if ($isDir and !$isBanned and $isBackendWorking) {
    $size = $ipfs->size($hash);
    $firstElementSize = $dirContent[0]['Size'];
    $firstElementHash = $dirContent[0]['Hash'];
    if ($firstElementSize < 400) {
        $title = $ipfs->cat($firstElementHash);
        foreach ($dirContent as $e) {
            if ($e['Size'] > 400) {
                $thumbnail = "https://ipfs.pics/ipfs/" . $e['Hash'];
                break;
            }
        }
        foreach ($dirContent as $e) {
            if ($e['Size'] < 400 and $e['Hash'] != $firstElementHash) {
                $description = $ipfs->cat($e['Hash']);
                break;
            }
        }
    } else {
        $title = 'A photo album hosted on the permanent web';
        $thumbnail = "https://ipfs.pics/ipfs/{$firstElementHash}";
Пример #2
0
    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include "class/ipfs.class.php";
if (!isset($_GET['hash'])) {
    $hash = "QmX6kHmFXsadTqLDMMnuV5dFqcGQAfNeKAArStw1BKqFW7";
} else {
    if (preg_match('/^[a-z0-9]+$/i', $_GET['hash'])) {
        $hash = $_GET['hash'];
    } else {
        // security problem
        exit("wrong hash");
    }
}
$ipfs = new IPFS("localhost", "8080", "5001");
$imageContent = $ipfs->cat($hash);
if ($imageContent == "") {
    header("Location: https://ipfs.io/ipfs/{$hash}");
} else {
    $imageSize = $ipfs->size($hash);
    if ($imageSize > 7866189) {
        //		exit("image is too big");
    }
    session_cache_limiter('none');
    header("Content-type: image/png");
    header('Cache-control: max-age=' . 60 * 60 * 24 * 365);
    header('Expires: ' . gmdate(DATE_RFC1123, time() + 60 * 60 * 24 * 365));
    header('Last-Modified: Thu, 01 Dec 1983 20:00:00 GMT');
    if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
        header('HTTP/1.1 304 Not Modified');
        die;