Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function createFile($filename, $content) {
- $myfile = fopen($filename, "w") or die("cannot open file");
- fwrite($myfile, $content);
- fclose($myfile);
- }
- function createDir($dir) {
- if (!file_exists($dir)) {
- mkdir($dir, 0777, true);
- }
- }
- function generatePostUploadPage($id, $filename, $originalfilename, $adultcontent, $dh, $sz, $outfile) {
- $myFile = $outfile; // or .php
- $fh = fopen($myFile, 'w'); // or die("error");
- $stringData = "
- <body>
- <center>
- <br>
- <a href=\"/\">Go to home page</a>
- <br>
- <img src=\"/logo.png\" alt=\"Logo\" style=\"width:256px;height:256px;\">
- <h2>The Hidden Hosting</h2>
- <h5>Free and anonymous file hosting</h5>
- <hr>
- <a>ID:</a>
- <br>
- <b>".$id."</b>
- <br>
- <br>
- <a>Filename and size:</a>
- <br>
- <b>".$originalfilename.' ('.$sz.')'."</b>
- <br>
- <br>
- <a>Contains adult content:</a>
- <br>
- <b>".$adultcontent."</b>
- <br>
- <br>
- <a>Upload date:</a>
- <br>
- <b>GMT+0 ".$dh."</b>
- <br>
- <br>
- <a href='".$filename."'>Download file</a> <br><br>
- <a href='/delete.php?id=".$id."'>Delete</a>
- </center>
- </body>";
- fwrite($fh, $stringData);
- }
- function formatBytes($bytes, $precision = 2) {
- $units = array('B', 'KB', 'MB', 'GB', 'TB');
- $bytes = max($bytes, 0);
- $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
- $pow = min($pow, count($units) - 1);
- $bytes /= pow(1024, $pow);
- return round($bytes, $precision) . ' ' . $units[$pow];
- }
- function generateRandomString($length = 10) {
- $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
- $charactersLength = strlen($characters);
- $randomString = '';
- for ($i = 0; $i < $length; $i++) {
- $randomString .= $characters[rand(0, $charactersLength - 1)];
- }
- return $randomString;
- }
- if(isset($_POST['btn-upload']))
- {
- $original = $_FILES['pic']['name'];
- $array = explode('.', $original);
- $extension = end($array);
- $id = generateRandomString(16);
- $pic = $id.'.'.$extension;
- $pic_loc = $_FILES['pic']['tmp_name'];
- $folder="uploaded/".$id."/";
- createDir($folder);
- $size = "";
- $outfile = $folder.$pic;
- $postpage = $folder.'download.html';
- $adult = isset($_POST['adultcontent']) && $_POST['adultcontent'] ? "Yes" : "No";
- $now = date("Y/m/d - h:i:s");
- $deletepw = $_POST['deletepw'];
- if(move_uploaded_file($pic_loc, $outfile))
- {
- $size = formatBytes(filesize($folder . $pic));
- generatePostUploadPage($id, $pic, $original, $adult, $now, $size, $postpage);
- createFile($folder . ".deletepw", $deletepw);
- ?>
- <br>
- <!--<script>alert('successfully uploaded to <?php echo $pic?>');</script>-->
- <center><a href="http://hiddenhosting.66ghz.com/<?php echo $postpage;?>"><font size="4" color="blue">Click here to see your uploaded file <?php echo ' (' . $size . ')';?></font></a></center>
- <?php
- }
- else
- {
- ?><script>alert('error');</script><?php
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement