linux - Creating SYMLINK with PHP on Hostgator jailed shell - Get Perm Denied error -


so come problem:

givens:

  1. i have hostgator isp.
  2. i'm using php 5.5
  3. the linux box centos
  4. shared hosting environment
  5. i professional coder , experienced lamp many years

problems:

  1. i'm not familiar jailed shell have idea
  2. i've tried script , have been searching answer
  3. still stuck...

here's current code:

function getmyfakedir($myfile) {      $target = "";     $link = 'content/purchased-items/link';     symlink($target, $link);      echo "read link: ". readlink($link);      return readlink($link);  } 

here's called function:

$linktext = getmyfakedir('somepdfthattheusercandownload.pdf'); 

then pass "$linktext" var phpmailer , wala!!! user clicks download through symlink , i've written code make expire after 24 hours. yeah, got php.net.

so, that's problem....

here's error:

warning: symlink(): permission denied in /homesomewhere/somemasterdir/public_html/webservices/somephpfile.php on line 654 

this link 654 above:
symlink($target, $link);

thanks...

figured out.... simple logic!

first had paths wrong. here's corrected code:

//generate symbolic link blows away fake directory each time //a symbolic link created "this" file below $filename = $myfile; //this directory on server... //a randomly named directory created here...step 1 $downloaddir = "/home/somehostdir/public_html/sldktrulwiu2555ivd0fjvdfgdfgdfgdf/"; //any directory not accessible browser - 1 level $safedir = "/home/somehostdir/content/purchased-items/"; //this equivalent of $downloaddir , browser redirected here , download begins $downloadurl = "http://www.thesomedomain.com/sldktrulwiu2555ivd0fjvdfgdfgdfgdf/"; //this fake directory (which type gobbligook , created mess above) $letters = 'abcdefghijklmnopqrstuvwxyz'; srand((double) microtime() * 1000000); $string = ''; ($i = 1; $i <= rand(4, 12); $i++) {     $q = rand(1, 24);     $string = $string . $letters[$q]; }  $handle = opendir($downloaddir); while ($dir = readdir($handle)) {     if (is_dir($downloaddir . $dir)) {         if ($dir != "." && $dir != "..") {             @unlink($downloaddir . $dir . "/" . $filename);             @rmdir($downloaddir . $dir);         }     } } closedir($handle); mkdir($downloaddir . $string, 0777); symlink($safedir . $filename, $downloaddir . $string . "/" . $filename); //header("location: " . $downloadurl . $string . "/" . $filename); 

that it.

the result dynamic directory inside "/sldktrulwiu2555ivd0fjvdfgdfgdfgdf/" directory this: "dfsgss/" , "shortcut" real location files are. when file downloaded, , page returns index.html, code blows out fake directory never more seen again. thus, if user wants go back, horrible 404 page error file / has been moved or deleted. bummer.

that's folks. assistance, helped me release error. team work!


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -