[SOLVED] Desktop short cut for a webpage

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
iijb
Forum Commoner
Posts: 43
Joined: Wed Nov 26, 2008 11:34 pm

[SOLVED] Desktop short cut for a webpage

Post by iijb »

Hi all,
I have a webpage in which there is an image which when drag to desktop , should make a desktop short cut for the webpage. Is that possible. Please help me out.

Thanks in advance
iijb
Last edited by iijb on Wed Jul 20, 2011 12:45 am, edited 2 times in total.
edziffel
Forum Newbie
Posts: 9
Joined: Wed Jul 13, 2011 6:32 am

Re: Desktop short cut for a webpage

Post by edziffel »

Never heard of making a short cut like that. Depending on the browser and OS you use, you can sometimes drag the URL to the desktop, Why not just us the favorites or book mark function of your browser?
User avatar
Pazuzu156
Forum Contributor
Posts: 241
Joined: Sat Nov 20, 2010 9:00 pm
Location: GA, USA
Contact:

Re: Desktop short cut for a webpage

Post by Pazuzu156 »

Simple, right click the desktop, and name it 'My Page.url'

In the file type:

Code: Select all

[InternetShortcut]
URL=http://www.mycompany.com
Save it, there you go :)
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
User avatar
iijb
Forum Commoner
Posts: 43
Joined: Wed Nov 26, 2008 11:34 pm

Desktop short cut for a webpage

Post by iijb »

Hi,
Thanks Pazuzu156 that is what I need.

Thanks all
iijb
Last edited by iijb on Mon Jul 18, 2011 11:15 pm, edited 1 time in total.
User avatar
Pazuzu156
Forum Contributor
Posts: 241
Joined: Sat Nov 20, 2010 9:00 pm
Location: GA, USA
Contact:

Re: Desktop short cut for a webpage

Post by Pazuzu156 »

If you wanted to do this with php, you could do this:

Code: Select all

<?php

// Create function and use a parameter for the url you will be using
function create_icon($url) {
	$filename = "./my_icon.url"; // make variable with the filename you will be using to be created
	
	/* make variable to have at the top,
	* this is to keep the file from messing up with
	* way the file has to be created*/
	$sc = '[InternetShortcut]';
	
	// check if $filename exists
	if(!file_exists($filename)) {
		file_put_contents($filename, $sc."\nURL=".$url); // if not, create the file, and place the content inside
	} else {
		file_put_contents($filename, $sc."\nURL=".$url); // if it does, do the same as if it doesn't exist
	}
}

// call up the function, use the url as the parameter
create_icon('http://www.domain.com');
?>
With the page order, I've played with this code, and if you don't do it like that, it messes up.
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
User avatar
iijb
Forum Commoner
Posts: 43
Joined: Wed Nov 26, 2008 11:34 pm

Re: Desktop short cut for a webpage

Post by iijb »

Hi,
I created the icon in the same folder of php script.
But there comes another problem for me. I have to get the Desktop path of the client machine for creating icon in desktop. How to get the desktop path using php. Also can we create a file in user's desktop. Please help.
Thanks again
iijb
User avatar
Pazuzu156
Forum Contributor
Posts: 241
Joined: Sat Nov 20, 2010 9:00 pm
Location: GA, USA
Contact:

Re: Desktop short cut for a webpage

Post by Pazuzu156 »

I'm sorry to say you cannot get to the desktop path using PHP, and even if you could that would be a MAJOR security hole in your site not to mention people turning you in for hacking and whatnot. My suggestion to you is have a link, and when they click the link that it will use the function to create the file for them on download, but it would be temporary and deleted once obtained. If you need input on that I could made up a drafted code for you after class tomorrow.
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
User avatar
iijb
Forum Commoner
Posts: 43
Joined: Wed Nov 26, 2008 11:34 pm

Re: Desktop short cut for a webpage

Post by iijb »

Hi,
Thanks Pazuzu156 for your reply. I have made download shortcut as you told.

Thanks
iijb
User avatar
Pazuzu156
Forum Contributor
Posts: 241
Joined: Sat Nov 20, 2010 9:00 pm
Location: GA, USA
Contact:

Re: Desktop short cut for a webpage

Post by Pazuzu156 »

Anytime man, glad I could help.
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
Post Reply