PHP - Hiding Download Links
Hi all,
I am going to be offering downloads on my site to members. However i want to somehow hide the download link so that they are unable to copy and paste and give it to their friends. IE, they have to be logged into my site to be able to download it else its not possible. Any ideas? Thanks Jake! PS. Not sure if this is the correct forum. Similar TutorialsHi, I have one webhost (A) that supports no PHP and has unlimited bandwidth. I have a second webhost (B) that does support PHP, but has limited bandwidth. The website is on host A and contains a 5mb file that people can download and I'd like to count the downloads. But now I need to use host B to count the downloads. I'm using this small script on host B to count the downloads. <?php $hits=file("count.txt"); $hits[0]++;$fp=fopen("count.txt","w"); fputs($fp,$hits[0]); fclose($fp); header("Location: http://webhost-A.com/files/download.zip"); ?> The download link people see on my website is: http://webhost-B.com/download.php Generally this works fine, but I found out that people can still find the direct link with download managers and then put that direct link on their website, which prevents me from counting those downloads. A solution I found is to use ReadFile. But the problem is that when using ReadFile, host B first downloads the file from host A and then sends it to the user and that's exactly what I don't want. Is it possible to let people download the file directly from host A without showing the direct download link in any way and also count the downloads?
Basically I would like to place a link on my website and have the user download a file, but rather than just right clicking and choosing save target as, the link must be clicked, on the next page the file is fetched and then the client can download the file. How would I go about setting this up please? I have made a Php program that downloads an Inno setup installation file for installing a program. However, if I for one or another reason want to make a new download of the same Inno setup installation file, the previous file will still be found in the Download folder. Each of the downloads get a number in parenthesis, setup(1), setup(2), setup(3) etc. However, I wondered if it is posible to erase the previous file in the same process as I download a new one, so that however many downloads I do, there will all the time only be one occurence of this file in the Download folder. The download code is as follows: $exe = "Inno script/Test_setup.exe"; header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"Test_setup.exe\""); header("Content-Length: " . filesize($exe)); readfile($exe); Thanks in advance. Sincerely
<html> <?php $id = $_GET['id']; $dbusername="web148-matt"; $dbpassword="matt"; $dbdatabase="web148-matt"; mysql_connect(localhost,$dbusername,$dbpassword); @mysql_select_db($dbdatabase) or die( "Unable to select database"); mysql_query("UPDATE count SET clicks=clicks+1 WHERE id='$id'"); $sql = mysql_query("SELECT link FROM count WHERE id='$id'"); $fetch = mysql_fetch_row($sql); $result = mysql_query("SELECT * FROM count"); while($row = mysql_fetch_array($result)) { echo "<a href=" .$row['link']. ">Link</a>"; } ?> <a href='http://www.google.com'>Google</a> <a href='/index.php?id=2'>link2</a> </html> Hi people! I have this code: if ($_POST['remember'] == true) { // COOKIES ON! $time = time() + 20000; setcookie(user, $username, $time); setcookie(pass, $password, $time); header("Location: index.php"); echo "<h1 class='welcome'>Welcome ".$_COOKIE['user']." |</h1>"; echo "<div id='divlogin' style='visibility:hidden'></div>"; echo "<a href='logout.php'><h1 class='logout'><b>Logout</b></h1></a>"; }elseif ($_POST['remember'] == false){ echo "<div id='divlogin' style='visibility:hidden'></div>"; echo "Div hidden!"; } "remember" - is a checkbox. So, if the checkbox is checked then I will activate the cookies and hide the divlogin (till now everything is fine), but if the checkbox isn't checked, I will just hide the divlogin (and this don't happen), however, the echo "Div hidden!" works nicely. The code detects if the checkbox is checked or not, the only problem is that if isn't checked the div doens't hide. Any ideas? Thanks Hello, What if I wanted to publish a php program but want to hide the code so that even buyers would not get a look at it despite having the program fully functioning on their servers, is there a means through which I can hide the code so that it won't be shown even when the .php files are opened in a text editor? When I display my database entries, I want to hide some of the data. As you can see in this example: http://www.beat-the-spread.net/week1.php What I'd like to do is leave all the cells blank where the spread is zero. Here's the code I'm using: Code: [Select] while($row = mysql_fetch_array( $result )) { $i=1; if ($row['game_id']='$i') { echo "<tr><td>"; echo $row['date']; echo "</td><td>"; echo $row['team_name']; echo "</td><td>"; echo $row['owner']; echo "</td><td>"; echo $row['pt_spread']; echo "</td><td>"; echo $row['team_pts']; echo "</td><td>"; echo $row['team_bet']; echo "</td><td>"; echo $row['team_cover']; echo "</td><td>"; echo $row['owner_pts']; echo "</td></tr>"; if ($table_row_count % 2 && $table_row_count != 0) { echo ' <tr style="height: 8px"></tr> '; } $table_row_count++; } $i++; } echo "</table>"; I've been fooling with this for a couple hours and can't seem to find a decent way to do this. Can anybody help with this? Thanks. Hi all I have a website which has a payment system on it, I use sagepay, paypal and a few others. They all have relatively similar forms, in which the total amount to be paid is passed in a hidden form field, such as <input type="hidden" name="amount" value="25"> all the payment gateways I use have the same or similar method to send the total amount (ie: 25) for example, my paypal form is like <form action="https://www.paypal.com/cgi-bin/webscr" name="paypal_form" method="post">"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="item_name" value="items"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="notify_url" value="complete.php"> <input type="hidden" name="return" value="complete.php"> <input type="hidden" name="cancel_return" value="complete.php"> <input type="submit" name="submit" value="PayPal" /> </form> this is all fine, apart from the user can use things like "firebug" to alter the total to be paid, so they can change $25 to $4 for example. So my question is, is there anyway with PHP to send over these form values are hidden variables. My idea was to post my form fields apart from the "cost" to a PHP script, then get PHP to grab the total from the database and dump the value in cost field and send it along with the other posted values. So really, is there anyway to get PHP to process a form data in a hidden enviroment, so my payment form URL is something like process.php and then process.php on my server deals with the sending of the paypal form data, but in a way that the user cannot see this data, so they basically never get to see the paypal form and any of its contents. Hopefully that kind of makes sense I have tried so many ideas, but cannot seem to find a solution, although when I do, hopefully the same method can be used on all my payment forms. Thanks tons in advance Hi! I have got an array which contains messages for different types of errors on my website (for login errors and such). My problem is however, that when the array is empty it still shows the message box (the CSS). here is the code I am using: Code: [Select] public function showMessages() { if (count($this->_messages > 0)) { echo '<div id="messages">'; foreach ($this->_messages as $msg) { echo $msg . '<br />'; } echo '</div>'; } } I am starting to think that I need to be doing this in JavaScript. I would prefer to do it using PHP only, if it is possible though. Thanks for the help! I'd like to play music in the background of a page, but don't want to display the url of the music files in the source code or encrypt it. Is that possible to do using php? Hi there, Is it possible to hide text on a page using PHP? For example, hide the word "hello" every time it appears on the page? Or have it display in a different color? Hi I want to hide the login box's of my webpage once you login. I have thought of two ways of doing it but which one would you say is better practice? 1. use a PHP if statement to echo 'Display: none on css' - when viewing source code it still shows the form but not displayed on page itself 2. use a PHP if statement around the whole <form></form> so it physically doesnt write the html if already logged in? Or if anyone has a better way it would be appreciated if you would share it? Thanks in advance Ok so I have a website with two types of photo gallerys. Model Cars and Model Planes. The galleries are becoming so big that I need to add an archive link to the galleries, but it's messy to have the archive link there until we actually enable the archived photos. So what I want to do is show the DIV with the archive link in it if the page can find database a 1 in the model_pictures.car_gallery AND model_pictures.archive. How would I achieve this? The page is already connected to the database as it's pulling the images and information for the gallery. I need it to scan the entire 'archive' column in the database and also the 'car_gallery' and if it finds 1's in there AND the car_gallery then to show the link. What I would like to avoid, as I have two galleries, is having the archive link show on the car gallery when it finds a 1 in the archives column, but that archive is for a plane_gallery photo. Hence why I would like to have check both car_gallery + archive and then plane_gallery + archive. Any help would be greatly appreciated. Hi I am trying to hide the image filepath and found this tutorial http://www.bounmis.com/en/PHP/How_To_Hide_Image_Source.html which I am currently using. It works but I need an additional security here so this script parses images only if the user is logged in to wordpress here's what i have so far: <?php include('wp-config.php'); $wp->init(); $wp->parse_request(); $wp->query_posts(); $wp->register_globals(); Header('Content-type: image/jpeg'); $exp=GMDate('D, d M Y H:i:s',time()+999); Header('Expires: $exp GMT'); $image_path = 'pathtoimages/'; $file=$image_path . $_GET["img"]; // getting image name and your image path if ( is_user_logged_in() ) { $file=$image_path.'authorized.jpg'; } else { $file=$image_path.'notauthorized.jpg'; }; if (file_exists($file)){ $info=getimagesize($file); $width=$info[0]; $height=$info[1]; if ($info[2]==1){ $img=@imagecreatefromgif($file); } else if ($info[2]==2){ $img=@imagecreatefromjpeg($file); } else if ($info[2]==3){ $img=@imagecreatefrompng($file); } else { $width=800; $height=600; $file = 'notauthorized.jpg'; // if there is not such image, it will show default image $img=@imagecreatefrompng($file); } ImageJpeg($img); imagedestroy($img); } ?> the script doesnt work. I think it's because i set headers Header('Content-type: image/jpeg'); What can I do to make it work? Please help thanks I am building a member-based website, and I've got a bunch of buttons that lead from page to page. The links for these buttons are generated based on user ID and subsequent pages receive this variable as well. So, if you hover over the buttons, you get a link like this: http://www.mysite.com?id=423 How can I hide the last part? The '?id=423'? I must use this format of variable, and cannot resort to session variables. Is there a way to hide this portion of the links?? Hey, im trying to hide a form for a upload script. but it will just look like this (see picture). its for a school project, here is the code Code: [Select] <div class="brick-left"> <?php $brugernavn = $_SESSION['brugernavn']; if ($_SESSION['brugernavn']) { $result = mysql_query("SELECT * FROM bruger WHERE brugernavn='$brugernavn'"); while ($row = mysql_fetch_array($result)) { $admin = $row['admin']; } if ($admin == 1){ echo"<center>"; echo"<form action=" . print $_SERVER["PHP_SELF"] . "method='post' enctype='multipart/form-data'>"; echo"<p><input type='hidden' name='contxt' value='upload'>"; echo"<input type='hidden' name='userId' value='123'>"; echo"<input type='file' name='upFile'></p>"; echo"<p><button type='submit'>Upload</button></p>"; echo"</form>"; } } ?> <?php print $message ?> </center> </div> Hi! So I have got some code that looks like this: Code: [Select] if (isset($_GET['view_log'])) { // show content (text from db) } When I click the button named "view_log" everything displays just fine, however I would like to be able to click the button again and make the content disappear. Is this possible using only PHP?? Thanks for the help!:) It is greatly appreciated! Alright, first off, I'm fairly new to this aspect of web design. While I have been messing around and designing sites using your basic HTML/CSS/Flash for some time, I've decided to get into the more serious aspects of web design. As of right now, I'm using a fairly basic webhosting service that doesn't give me full administrative permission to MySQL because, as far as I can tell, the databases reside under their super-database and not on your actual allotted server. This creates a problem with creating a true MySQL database in which you set up users for their given tables you want them to be able to edit. Let me remind you here again that I am faily new to this aspect of web design, so maybe no one actually runs their databases in this way. My work around is to have the first table be the user/password table and only have a singular script that I call up every time my forms need to modify a table. I hide this small connection script in the root folder of my server where it is not viewable and just call it into my php scripts using 'include()' or 'get_file_contents.' What I'm asking here I guess is if this method is secure? And if anyone has any other ideas as to how to go about creating this database. Thanks in advance! Good day all
My site is hosted on yahoo server. Due to security reason, .htaccess is not allowed. I need to hide (or mask) actual url, or atleast .php file name. Can anyone help.
Warm regards.
Shonali
well i have a problem... i have a website running and anyone can get to the admin control panel login page by going to "mywebsite.com/admin" how can i hide this or change it so that they cant get to it unless they know it...? problem 2... when u visit my website... its shows in the url the path of the file for example... "mywebsite.com/register.php" when on the register page or like "mywebsite.com/sells.php" if on the sells page... how can i hide it so that only my website name is showing and not the path of the file? |