Advertisement
cocaineee

example1

Jan 24th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.76 KB | None | 0 0
  1. define ( 'DATALIFEENGINE', true );
  2. define ( 'FILE_DIR', '../uploads/files/' );
  3. define ( 'ROOT_DIR', '..' );
  4. define ( 'ENGINE_DIR', ROOT_DIR . '/engine' );
  5.  
  6. @error_reporting ( E_ALL ^ E_WARNING ^ E_NOTICE );
  7. @ini_set ( 'display_errors', true );
  8. @ini_set ( 'html_errors', false );
  9. @ini_set ( 'error_reporting', E_ALL ^ E_WARNING ^ E_NOTICE );
  10.  
  11. require ENGINE_DIR . '/data/config.php';
  12.  
  13. date_default_timezone_set ( $config['date_adjust'] );
  14.  
  15. if ($config['http_home_url'] == "") {
  16.    
  17.     $config['http_home_url'] = explode ( "engine/download.php", $_SERVER['PHP_SELF'] );
  18.     $config['http_home_url'] = reset ( $config['http_home_url'] );
  19.     $config['http_home_url'] = "http://" . $_SERVER['HTTP_HOST'] . $config['http_home_url'];
  20.  
  21. }
  22.  
  23. require_once ENGINE_DIR . '/classes/mysql.php';
  24. require_once ENGINE_DIR . '/data/dbconfig.php';
  25. require_once ENGINE_DIR . '/modules/functions.php';
  26.  
  27. dle_session();
  28.  
  29. require_once ENGINE_DIR . '/modules/sitelogin.php';
  30. require_once ENGINE_DIR . '/classes/download.class.php';
  31.  
  32. function reset_url($url) {
  33.     $value = str_replace ( "http://", "", $url );
  34.     $value = str_replace ( "https://", "", $value );
  35.     $value = str_replace ( "www.", "", $value );
  36.     $value = explode ( "/", $value );
  37.     $value = reset ( $value );
  38.     return $value;
  39. }
  40.  
  41. function clear_url_dir($var) {
  42.     if ( is_array($var) ) return "";
  43.    
  44.     $var = str_ireplace( ".php", "", $var );
  45.     $var = str_ireplace( ".php", ".ppp", $var );
  46.     $var = trim( strip_tags( $var ) );
  47.     $var = str_replace( "\\", "/", $var );
  48.     $var = preg_replace( "/[^a-z0-9\/\_\-]+/mi", "", $var );
  49.     return $var;
  50.    
  51. }
  52.  
  53. //################# Определение групп пользователей
  54. $user_group = get_vars ( "usergroup" );
  55.  
  56. if (! $user_group) {
  57.    
  58.     $user_group = array ();
  59.    
  60.     $db->query ( "SELECT * FROM " . USERPREFIX . "_usergroups ORDER BY id ASC" );
  61.    
  62.     while ( $row = $db->get_row () ) {
  63.        
  64.         $user_group[$row['id']] = array ();
  65.        
  66.         foreach ( $row as $key => $value ) {
  67.             $user_group[$row['id']][$key] = $value;
  68.         }
  69.    
  70.     }
  71.    
  72.     set_vars ( "usergroup", $user_group );
  73.     $db->free ();
  74.  
  75. }
  76.  
  77. if (! $is_logged) {
  78.     $member_id['user_group'] = 5;
  79. }
  80.  
  81. if (! $user_group[$member_id['user_group']]['allow_files'])
  82.     die ( "Access denied" );
  83.  
  84. if ($config['files_antileech']) {
  85.    
  86.     $_SERVER['HTTP_REFERER'] = reset_url ( $_SERVER['HTTP_REFERER'] );
  87.     $_SERVER['HTTP_HOST'] = reset_url ( $_SERVER['HTTP_HOST'] );
  88.  
  89.     if ($_SERVER['HTTP_HOST'] != $_SERVER['HTTP_REFERER']) {
  90.         @header ( 'Location: ' . $config['http_home_url'] );
  91.         die ( "Access denied!!!<br /><br />Please visit <a href=\"{$config['http_home_url']}\">{$config['http_home_url']}</a>" );
  92.     }
  93.  
  94. }
  95.  
  96. $id = intval ( $_REQUEST['id'] );
  97.  
  98. if ($_REQUEST['area'] == "static")
  99.     $row = $db->super_query ( "SELECT name, onserver FROM " . PREFIX . "_static_files WHERE id ='{$id}'" );
  100. else
  101.     $row = $db->super_query ( "SELECT name, onserver FROM " . PREFIX . "_files WHERE id ='{$id}'" );
  102.  
  103. if (! $row)
  104.     die ( "Access denied" );
  105.  
  106. $url = @parse_url ( $row['onserver'] );
  107.  
  108. $file_path = dirname (clear_url_dir($url['path']));
  109. $file_name = pathinfo($url['path']);
  110. $file_name = totranslit($file_name['basename'], false);
  111.  
  112. if ($file_path AND $file_path != ".") $file_name = $file_path."/".$file_name;
  113.  
  114. $file = new download ( FILE_DIR . $file_name, $row['name'], $config['files_force'], intval($user_group[$member_id['user_group']]['files_max_speed']) );
  115.  
  116. if ($_REQUEST['area'] == "static") {
  117.    
  118.     if ($config['files_count'] and ! $file->range)
  119.         $db->query ( "UPDATE " . PREFIX . "_static_files SET dcount=dcount+1 WHERE id ='$id'" );
  120.  
  121. } else {
  122.    
  123.     if ($config['files_count'] and ! $file->range)
  124.         $db->query ( "UPDATE " . PREFIX . "_files SET dcount=dcount+1 WHERE id ='$id'" );
  125.  
  126. }
  127.  
  128. $db->close ();
  129. session_write_close();
  130.  
  131. $file->download_file();
  132. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement