Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

download.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. include('../../includes/config.php');
  3. require_once('../../includes/PiwikTracker.php');
  4. PiwikTracker::$URL = get_page_url('stats', $CONF).'/';
  5. $fileURL = $_GET['file'];
  6. $file_db = $db->select('uploads', "url=? LIMIT 1", array($fileURL));
  7. $file_path = $CONF['upload_dir'] . $file_db['filename'];
  8. $temp_path = sys_get_temp_dir()."\\".$file_db['filename'];
  9. if (file_exists($file_path) && $file_db)
  10. {
  11. $t = new PiwikTracker( $idSite = 1);
  12. $t->setUserAgent($userAgent = $_SERVER['HTTP_USER_AGENT']);
  13. $t->setUrlReferrer($url = $_SERVER['HTTP_REFERER']);
  14. $t->setUrl($url = get_page_url('u', $CONF).'/'.$fileURL);
  15. $t->doTrackPageView($documentTitle = 'Teknik Upload - '.$fileURL);
  16. if ($file_db['hash'] != "")
  17. {
  18. $crypt = new Cryptography();
  19. $result = $crypt->Decrypt($CONF['key'], $file_db['hash'], $file_path, $temp_path, $file_db['cipher']);
  20. if ($result)
  21. {
  22. $file_path = $temp_path;
  23. }
  24. }
  25. $file_type = $file_db['type'];
  26. $pattern = "/^((image)|(text)|(audio)|(video))\/(.*)$/";
  27. if(!preg_match($pattern, $file_type))
  28. {
  29. header("Content-Disposition: attachment; filename=\"".$file_db['filename']."\"");
  30. header("Pragma: public");
  31. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  32. header('Content-Type: '.$file_type);
  33. header('Content-Length: '.$file_db['filesize']);
  34. set_time_limit(0);
  35. }
  36. else
  37. {
  38. header('Content-Type: '.$file_type);
  39. header('Content-Length: '.$file_db['filesize']);
  40. }
  41. readfile($file_path);
  42. if ($file_db['hash'] != "")
  43. {
  44. $result = unlink($file_path);
  45. }
  46. }
  47. else
  48. {
  49. header('Location: '.get_page_url("error", $CONF).'/404');
  50. }
  51. ?>