How to replace local file path to insert url link
download.php

// Free Downloads
  if (isset($_GET['free'])) {
      $row = $android->getFreeDownload($_GET['free']);

      if ($row) {
          $fname = basename($row['filename']);
          $file_path = '';
          $android->fetchFile(BASE_DIR, $fname, $file_path);

          $fsize = filesize($file_path);
          $fext = strtolower(substr(strrchr($fname, "."), 1));

          if (!file_exists($file_path) || !is_file($file_path)) {
              redirect_to(($core->seo == 1) ? $core->site_url . '/content/android/?msg=1' : $core->site_url . '/modules.php?module=android&msg=1');
              die();
          }

          if (!array_key_exists($fext, $allowed_ext)) {
              redirect_to(($core->seo == 1) ? $core->site_url . '/content/android/?msg=1' : $core->site_url . '/modules.php?module=android&msg=2');
              die();
          }

          if ($android->allow_free == 'n' && !$user->logged_in) {
              redirect_to(($core->seo == 1) ? $core->site_url . '/content/android/?msg=1' : $core->site_url . '/modules.php?module=android&msg=3');
              die();
          }

          if ($allowed_ext[$fext] == '') {
              $mtype = '';
              if (function_exists('mime_content_type')) {
                  $mtype = mime_content_type($file_path);
              } elseif (function_exists('finfo_file')) {
                  $finfo = finfo_open(FILEINFO_MIME);
                  $mtype = finfo_file($finfo, $file_path);
                  finfo_close($finfo);
              }
              if ($mtype == '') {
                  $mtype = "application/force-download";
              }
          } else {
              $mtype = $allowed_ext[$fext];
          }

          // set headers
          header("Pragma: public");
          header("Expires: 0");
          header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
          header("Cache-Control: public");
          header("Content-Description: File Transfer");
          header("Content-Type: $mtype");
          header("Content-Disposition: attachment; filename=\"$fname\"");
          header("Content-Transfer-Encoding: binary");
          header("Content-Length: " . $fsize);

          print $android->readFile($file_path, true);

      } else {
          redirect_to(SITEURL . "/index.php");
      }

Thanks All !

Recommended Answers

All 2 Replies

Hi,

Look for the class file, and the method called $android.. OOP have setThisFunction and getThisFunction.. in your case look for the seThisFunction.. e.g. public function fetchFile()..

The item you are looking for is probably located in the constructor, if not look up somewhere above the property block.

By the way, you already asked this question? Why double post it?

Correction, look for the class android, and for the method called filedir as in

  $android = new Android();

 define('BASE_DIR', $android->filedir);

Inspect all the methods in the android class.. one of them is responsible for what you are looking for.. If you don't find it, just extend the android class like so..

 class YourClass extends android{
 private $yourProperty = null;

 public function __construct('redefinePropertyNeededByYourMethodAndMustBeInheritedByYourClass_YourClass,$yourProperty){
 ## below is pretty much the copy of the parents constructor
 parent::__construct('redefinePropertyNeededByYourMethodAndMustBeInheritedByYourClass_YourClass);
 $this->YourProperty = $whatEverIsYourNewProperty;

 ## define your method declare it as public if it is set as private above.
 public function get_yourMethodOrFunction(){

 ## this is the part where you need to do your changes

 }

 return $this->get_changesYouMadeOutOftheParentsMethod;

 }
 ## end of class YourClass
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.