[PHP] Auto Link Maker (For Right Click > Save As)

Q&A, advice, reviews, and news about the computers, phones, TVs, stereos, and pretty much anything else that can't be easily whittled out of a stick or chipped out of stone.
User avatar
TopCat
Redshirt
Posts: 3783
Joined: Wed May 21, 2003 1:34 am
Gender: Male
Contact:

[PHP] Auto Link Maker (For Right Click > Save As)

Post by TopCat » Sat Mar 06, 2004 5:45 am

Have you ever used mozilla and been to a page where they're showing 'funny videos' 'funny ads' or whatever, and its wmv? I'm able to right click and get the url, but i cant just place that in and get it to dl, it shows text. So theres no way to install the plugin (if someone knows a way tell me) and I can't view WMV.

So here comes my thoughts. I'd have a PHP that I'd go to, paste a link, and it'd give back the same page, but with the link so i could right click and save as. This way I'd be able to view the wmv, without having to edit a freaking html file each time, saving, and opening.

Since this is (at least seemingly) a simple project, and yet I lack the knowledge to do it, I thought someone here could whip some magic php miracles in mere seconds, and post the code.
hahaha i don't come to these forums anymore :x

User avatar
Ryom
Redshirt
Posts: 291
Joined: Mon May 19, 2003 7:06 am

Post by Ryom » Sat Mar 06, 2004 6:26 am

That was a problem in the older versions of firebird and mozilla, when improper mime encoding was sent by the server it would show ascii charaters in the browser instead of downloading the binary info. The latest version, FireFox, doesn't have this problem.

You could also use a download manager such as leechget to capture the link and download it when you click in the browser.

If I interpreted what you are asking wrong I'm sorry. I'm in a rush :)
Image

User avatar
Vektor T. Gecko
Redshirt
Posts: 859
Joined: Fri Feb 14, 2003 8:43 am
Gender: Male
Location: Ontario

Post by Vektor T. Gecko » Sat Mar 06, 2004 8:52 am

That's not a problem with the browser, that's the browser doing exactly what it's supposed to. The server is saying it's text/plain, then the browser most certainly SHOULD be displaying the file as plain text, and it's something that needs to be fixed on the server, not the browser.

Why not just code the script yourself? All the documentation (and it's quite thorough documentation) for PHP functions is available on php.net
If all else fails, use fire.

MasteR
Redshirt
Posts: 3064
Joined: Thu Mar 06, 2003 12:48 am

Post by MasteR » Sat Mar 06, 2004 9:53 am

hold shift and click the link.

or

put the link in the bar, hold shift, and hit enter


i think its shift anyway

EvilPanda
Redshirt
Posts: 780
Joined: Thu Jun 19, 2003 11:16 pm
Location: New Jersey

Post by EvilPanda » Sat Mar 06, 2004 7:14 pm

Open windows media player or whatever and click "open url" if its a direct link to a .wmv file.

dmpotter
Redshirt
Posts: 4057
Joined: Tue Apr 01, 2003 7:10 pm
Location: Massachusetts, US
Contact:

Post by dmpotter » Sat Mar 06, 2004 7:19 pm

[quote="Vektor T. Gecko";p="294355"]That's not a problem with the browser, that's the browser doing exactly what it's supposed to. The server is saying it's text/plain, then the browser most certainly SHOULD be displaying the file as plain text, and it's something that needs to be fixed on the server, not the browser.[/quote]
I half-agree, but then again... It's such a common problem that I fully support the people that want Mozilla to auto-detect MIME types when it receives "text/plain" as the MIME type.

Yeah, the server is mis-configured, but... (This is really IE's fault for always going by the file extension for MIME types. I've forgotten how many times I've had to end URLs to scripts end with ?ie=/a.jpg to make IE accept that the the URL it's accessing really is a JPG.)

BTW, try the View Info dialog. Right click on the page, choose "View Info" and go to the Media tab and find the video in the list of links. There's a "Save As..." button there that saves the image.

Or at least there is in Firefox, I haven't been using Mozilla since 1.5.

User avatar
TopCat
Redshirt
Posts: 3783
Joined: Wed May 21, 2003 1:34 am
Gender: Male
Contact:

Post by TopCat » Sat Mar 06, 2004 7:58 pm

I know about that save as thing, but it doesn't seem to work with embeded wmv's, at least in my history.

However, I've found something 'slightly' related to this.

http://javascript.internet.com/forms/html-preview.html

I just have to figure out how to merge

Code: Select all

<a href="
with
[/code]">Right Click Here</a>[/code]

and let that form submit, return a page, and there we go. Again, I've read through the stuff on php.net, and it's a LOT of stuff, and it's really good, but forms and POST are really difficult to understand, especially the part about returning what was POSTed.
hahaha i don't come to these forums anymore :x

User avatar
Vektor T. Gecko
Redshirt
Posts: 859
Joined: Fri Feb 14, 2003 8:43 am
Gender: Male
Location: Ontario

Post by Vektor T. Gecko » Sat Mar 06, 2004 8:33 pm

Code: Select all

$_POST['name']
where 'name' is the name of the form element you want to retrieve.

for something like:

Code: Select all

<FORM ACTION="myscript.php" METHOD="POST">
  <INPUT TYPE=whatever NAME="pants">
  .
  .
  .
</FORM>
you would use the variable:

Code: Select all

$_POST['pants']
to retrieve the value of that element.
If all else fails, use fire.

User avatar
TopCat
Redshirt
Posts: 3783
Joined: Wed May 21, 2003 1:34 am
Gender: Male
Contact:

Post by TopCat » Sat Mar 06, 2004 9:02 pm

So something like

Code: Select all

<Form ACTION="linker.php" METHOD="POST">
   <INPUT TYPE=text NAME="filename">
</Form>
then

Code: Select all

<a href="$_POST['filename']">Rightclickme</a>
I don't know how to $+ $+ in php, and I've not found the way. Actually I think it is $+!

:-/
hahaha i don't come to these forums anymore :x

Stapr
Redshirt
Posts: 75
Joined: Wed Jun 11, 2003 12:48 am

Post by Stapr » Sat Mar 06, 2004 10:22 pm

In order to output variables, you have two choices. Both are okay, but for more advanced outputs, the second one will have less conflicts.

Code: Select all

echo "some plain text, $varname, some more plain text"; // 1st option
echo "some plain text, ".$varname.", some more plain text"; // 2nd option
So, for what you want, you can use the following code.

Code: Select all

<?php
// linker.php
if ($newpage) {
  echo "<a href='".$newpage."'>Generated link is here.</a>";
} else {
  echo "<form action='linker.php' method='post'>URL: <input type='text' name='newpage'>";
  echo "<p><input type='submit' value='Submit'></form>";
}
?>
if ($you == "dumb") { $me = "Slap $you upside the head."; $you = "pissed"; }
if ($you == "pissed") { $me = "Laugh and laugh at $you."; $you = "Slap $me upside the head."; $me_chicken = "yes"; }
if ($me_chicken == "yes") { return; }

User avatar
TopCat
Redshirt
Posts: 3783
Joined: Wed May 21, 2003 1:34 am
Gender: Male
Contact:

Post by TopCat » Sat Mar 06, 2004 10:36 pm

/me transfers $5 to Stapr's Swiss bank account.

/me works on making it display the submit bit again after giving the link, or something, so that I may do it on another url.

viewing videos will forever not suck now thanks to Stapr.
hahaha i don't come to these forums anymore :x

Stapr
Redshirt
Posts: 75
Joined: Wed Jun 11, 2003 12:48 am

Post by Stapr » Sat Mar 06, 2004 10:55 pm

To make it display the submit button again, just remove the else part of the if...then...else statment, like so.

Code: Select all

<?php 
// linker.php 
if ($newpage) { 
  echo "<a href='".$newpage."'>Generated link is here.</a>"; 
}
echo "<p><form action='linker.php' method='post'>URL: <input type='text' name='newpage'>"; 
echo "<p><input type='submit' value='Submit'></form>"; 
?>
if ($you == "dumb") { $me = "Slap $you upside the head."; $you = "pissed"; }
if ($you == "pissed") { $me = "Laugh and laugh at $you."; $you = "Slap $me upside the head."; $me_chicken = "yes"; }
if ($me_chicken == "yes") { return; }

User avatar
Deacon
Shining Adonis
Posts: 44234
Joined: Wed Jul 30, 2003 3:00 pm
Gender: Male
Location: Lakehills, TX

Post by Deacon » Sun Mar 07, 2004 2:36 am

[quote="DJ TopCat";p="294483"]I know about that save as thing, but it doesn't seem to work with embeded wmv's, at least in my history.[/quote]
Install and use Firefox.

Visit page with embedded media.

Select "Tools" -> "Page Info" (CTRL+J)

Click on "Media" tab.

Click on the embedded media from the list.

Click "Save As..." button.

Figure the rest out yourself :)
The follies which a man regrets the most in his life are those which he didn't commit when he had the opportunity. - Helen Rowland, A Guide to Men, 1922

User avatar
TopCat
Redshirt
Posts: 3783
Joined: Wed May 21, 2003 1:34 am
Gender: Male
Contact:

Post by TopCat » Sun Mar 07, 2004 3:59 am

Shut the fuck up, fanboy.

Visit page with embedded media.

Realize it hasn't even been downloaded, as you don't have the plugin to download it.

Try to save as anyway.

Get an error viewing the file.

Shoot deacon in head, laugh, use linker.php, smile.
hahaha i don't come to these forums anymore :x

User avatar
Deacon
Shining Adonis
Posts: 44234
Joined: Wed Jul 30, 2003 3:00 pm
Gender: Male
Location: Lakehills, TX

Post by Deacon » Sun Mar 07, 2004 5:07 am

Image
The follies which a man regrets the most in his life are those which he didn't commit when he had the opportunity. - Helen Rowland, A Guide to Men, 1922

Locked

Who is online

Users browsing this forum: No registered users and 1 guest