<?php error_reporting(0); include "../pswd.php"; include "class/ipfs.class.php"; if (!isset($_GET['hash'])) { $hash = "QmYqA8GiZ4MCeyJkERReLwGRnjSdQBx5SzjvMgiNwQZfx6"; } else { if (preg_match('/^[a-z0-9]+$/i', $_GET['hash'])) { $hash = $_GET['hash']; } else { exit("wrong hash"); } } $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'];
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');
it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 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/>. */ error_reporting(0); include "../pswd.php"; include "class/ipfs.class.php"; $ipfs = new IPFS("localhost", "8080", "5001"); $errorHash = "QmW3FgNGeD46kHEryFUw1ftEUqRw254WkKxYeKaouz7DJA"; $host = $_SERVER['HTTP_HOST']; if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { $protocol = "https"; } else { $protocol = "http"; } $db = new PDO('mysql:host=localhost;dbname=hashes;charset=utf8', $db_user, $db_pswd); $uploadsInLastHour = $db->query("SELECT COUNT(*) FROM hash_info WHERE first_seen > UNIX_TIMESTAMP() - 3600")->fetch(); if ($uploadsInLastHour[0] < 100) { $image = $_FILES['img']['tmp_name']; $fo = fopen($_FILES['img']['tmp_name'], "r"); $imageContent = fread($fo, filesize($image)); $hash = $ipfs->add($imageContent); } else {
published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 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/>. */ error_reporting(0); include "../pswd.php"; include "../app/class/ipfs.class.php"; print "gc \n \n"; $db = new PDO('mysql:host=localhost;dbname=hashes;charset=utf8', $db_user, $db_pswd); $ipfs = new IPFS("localhost", "8080", "5001"); // Makes sure all the banned hashes are removed $bannedHashes = $db->query("SElECT * FROM hash_info WHERE banned = 1;")->fetchAll(); foreach ($bannedHashes as $i) { $hash = $i['hash']; $ipfs->pinRm($hash); print "Removed banned hash: {$hash} \n"; } $notBannedHashes = $db->query("SElECT * FROM hash_info WHERE banned != 1;")->fetchAll(); foreach ($notBannedHashes as $i) { $hash = $i['hash']; $ipfs->pinAdd($hash); print "Pinned hash: {$hash} \n"; } print "You can now run ipfs built-in garbage collector \n";