Jump to content

[SOLVED] how would one ulink a file once visited?


xcoderx

Recommended Posts

guys i got a script that would store info in a txt file with numbers e.g 33004488.txt and the link gets sent to a person in an email so that he/she can view the content. so what i want to do is once the person visits the content the 33004488.txt files gets deleted from the folder.

here is the part

 

<?php } else if ( (!isset($_POST['submit'])) && (isset($_GET['displayinfo'])) ) { 
$file = isset($_GET['displayinfo']) ?  $_GET['displayinfo'] : ''          ;
$content = file('messages/'.$file.".txt");
$pic   = $content['0'];
unset ($content['0']);
unset ($content['1']);
$main = "";
foreach ($content as $value) {
      $main .= $value;
}
?>           
   <center>Here Is Your E-Card!<br/><br/>
   <img src='thumbs/<?php echo $pic; ?>' alt="E-Card" />
   <br/><br/><br/>
   <?php echo nl2br(htmlspecialchars($main)); ?>
   </center>            
       
<?php } ?>        

Well, this should help you

 

http://ryanfait.com/resources/protect-flash-files-from-download/

 

Basically the concept is to load the file in a PHP script, so they don't see the file itself, but a mirror copy of the file. Use that, but after first run, delete the orriginal file

..first off,sorry if this isn't what you are looking for I just woke up and am still in between worlds lol... but here is something that I think you are talking about...however it is very insecure, but still it should work if you filter it out, and it's only txt files you are showing...

 

<?php
$id=$_GET['id']; //This would be the name of the originall file

include("/home/public_html/uploaded/".$id);  //Use include to show the file

unlink("/home/public_html/uploaded/".$id); //Use unlink to delete the file
?>

Here is one that is a little better:

<?php
$id=$_GET['id']; //This would be the name of the originall file

$page = file_get_contents('http://www.yoursite.com/pages/'.$id);
echo $page;

unlink("/home/public_html/pages/".$id);
?>

this is what i tried

 

<?php } else if ( (!isset($_POST['submit'])) && (isset($_GET['displayinfo'])) ) { 
$file = isset($_GET['displayinfo']) ?  $_GET['displayinfo'] : ''          ;
$content = file('messages/'.$file.".txt");
$pic   = $content['0'];
unset ($content['0']);
unset ($content['1']);
$main = "";
foreach ($content as $value) {
      $main .= $value;
}
?>

delete should be done somewhere here
           
<center>Here Is Your E-Card!<br/><br/>
<img src='thumbs/<?php echo $pic; ?>' alt="E-Card" />
<br/><br/><br/>

<?php 
echo nl2br(htmlspecialchars($main));
$main = file('messages/'.$file.".txt");
unlink($main);
?>

 

and i get this error

 

Warning: unlink() expects parameter 1 to be string, array given in /home2/public_html/card.php on line 142

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.