public function Download($path, $speed = null, $cdn = false) { if (is_file($path) === true or $cdn) { set_time_limit(0); while (ob_get_level() > 0) { ob_end_clean(); } $ext = pathinfo($path, PATHINFO_EXTENSION); $basename = md5(basename($path) . time() . time()) . '.' . $ext; $size = $cdn ? curl_get_file_size($path) : sprintf('%u', filesize($path)); $speed = is_null($speed) === true ? $size : intval($speed) * 1024; header('Expires: 0'); header('Pragma: public'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Type: application/octet-stream'); header('Content-Length: ' . $size); header('Content-Disposition: attachment; filename="' . $basename . '"'); header('Content-Transfer-Encoding: binary'); for ($i = 0; $i <= $size; $i = $i + $speed) { echo file_get_contents($path, false, null, $i, $speed); while (ob_get_level() > 0) { ob_end_clean(); } flush(); sleep(1); } exit; } return false; }
function cache_get($url, $cache_file, $verbose = true, $update = false, $cache_life = 43200) { $message = ''; $content = ''; clearstatcache(); if ($url == '') { $message .= '[empty url]'; } else { if (file_exists($cache_file) && time() - filemtime($cache_file) <= $cache_life) { $message .= '[use cache]'; $content = @file_get_contents($cache_file); } else { $message .= '[update cache : '; if ($update && file_exists($cache_file) && curl_get_file_size($url) <= filesize($cache_file)) { $message .= 'cache file is already bigger'; $content = @file_get_contents($cache_file); } else { if (($content = curl_download($url)) !== false) { // @file_get_contents($url) rmkdir(dirname($cache_file)); if (($size = @file_put_contents($cache_file, $content)) === false) { $message .= 'not updatable (' . $cache_file . ')'; } else { $message .= 'updated (' . human_filesize($size) . ')'; } if (strpos($url, 'http://www.magic-ville.com') !== false) { time_nanosleep(0, 500000000); } // Avoid anti-leech mechanism on MV (30 queries every 15 sec) } else { $message .= 'not downloadable (' . $url . ')'; } } $message .= ']'; } } if ($verbose) { echo $message; } return $content; }
$result = $content_length; } } echo $result; return $result; } $dom = new DOMDocument(); @$dom->loadHTML($html); // grab all the on the page $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate("/html/body//a"); for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); $url = $href->getAttribute('href'); echo $url . '<br />'; $file_size = curl_get_file_size($url); } // Check connection if ($link === false) { die("ERROR: Could not connect. " . mysqli_connect_error()); } } ?> <html> <head> <title>BESTNEWS - Registration</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
//Limit usage of this tool header("Location: http://crushedpixel.eu/skull?error=2"); exit; } if (isset($_POST["fileURL"])) { $fileURL = $_POST["fileURL"]; } foreach ($_FILES as $file) { $tmp = $file['tmp_name']; $unlink = false; if (strlen($tmp) == 0) { if (!isset($fileURL)) { header("Location: http://crushedpixel.eu/skull?error=3"); exit; } $size = curl_get_file_size($fileURL); if ($size <= 0 or $size > 100 * 1024) { header("Location: http://crushedpixel.eu/skull?error=0"); } $temp_file = tempnam(sys_get_temp_dir(), 'skin'); file_put_contents($temp_file, file_get_contents($fileURL)); $tmp = $temp_file; $unlink = true; } if ($file["size"] > 100 * 1024) { //if more than 100KB, probably no valid skin header("Location: http://crushedpixel.eu/skull?error=0"); } $hash = md5_file($tmp); $sql = "SELECT * FROM generated WHERE hash=?"; $stmt = $con->prepare($sql);
public function load($path, $table, $chunk_size = null, $segment_count = null, $columns_str = null, $set_str = null, $ignore = "", $replace = "") { if (!isset($chunk_size)) { $chunk_size = $this->chunk_size; } $fs = false; $url = false; if (!isset($segment_count)) { $chunker = new ChunkIt($this->line_terminator); if (strstr($path, "s3://")) { if (!isset($this->SQ->state->aws_access_key) || !isset($this->SQ->state->aws_secret_key)) { $this->errors[] = "Missing AWS secret key or AWS access key. Please set them in the schemata_config table"; return false; } $pathinfo = $this->extract_s3_path($path); $bucket = $pathinfo[1]; $file = $pathinfo[2]; $s3 = new S3($this->SQ->state->aws_access_key, $this->SQ->state->aws_secret_key); $info = @$s3->getObjectInfo($bucket, $file); if (!$info) { $this->errors[] = "Could not get S3 information for {$path}"; return false; } $segment_count = floor($info['size'] / $chunk_size); echo "Getting file offsets (may take awhile)\n"; $info = $chunker->s3_find_offsets($s3, $bucket, $file, $info['size'], $chunk_size, $segment_count); } elseif (strstr($path, "http://") || strstr($path, "https://")) { $fs = curl_get_file_size($path); if (!$fs) { $this->errors[] = "Could not get size of {$path}"; return false; } $segment_count = floor($fs / $chunk_size); $info = $chunker->http_find_offsets($path, $fs, $chunk_size, $segment_count); } else { /* NON-S3 load here */ $fs = filesize($path); if (!$fs) { $this->errors[] = "Could not get size of {$path}"; return false; } $segment_count = floor($fs / $chunk_size); $info = $chunker->find_offsets($path, $segment_count); } } if (!isset($pathinfo)) { $pathinfo = $path; } foreach ($info as $segment) { $return = $this->load_segment($pathinfo, $table, $segment['start'], $segment['end'], $columns_str, $set_str, $ignore, $replace); } if (!isset($this->errors)) { $this->errors = array(); } echo "done!\n"; }