ASP和PHP實現生成網站快捷方式并下載到桌面的方法
在網站上設置“加入收藏、設為首頁”等按鈕是一般網站都會干的事兒,但是有的網站還有“放到桌面”這樣的功能設置。
下面即生成快捷方式并下載到桌面的php實現代碼,摘錄修改于網絡,僅作參考
php實現代碼:
<?php
if(isset($_GET[title]) && trim($_GET[title]) !== "") $title = trim($_GET[tilte]);
$content='
[DEFAULT]
BASEURL=http://www.dbjr.com.cn/?desktop
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
[InternetShortcut]
URL=http://www.dbjr.com.cn/?desktop
IDList=[{000214A0-0000-0000-C000-000000000046}]
IconFile=http://www.dbjr.com.cn/favicon.ico
IconIndex=1
HotKey=0
Prop3=19,2';
header("Content-type:application/octet-stream");
header("Content-Disposition:attachment; {$title}.url;");
echo $content;
?>
asp實現代碼:
<%
id = int(request("id"))
if id="" then id="1"
title = request("title")
if title="" then title="腳本之家"
Shortcut = "[DEFAULT]" & vbCrLf
Shortcut = Shortcut & "BASEURL=http://www.dbjr.com.cn/?desktop" & vbCrLf
Shortcut = Shortcut & "[{000214A0-0000-0000-C000-000000000046}]" & vbCrLf
Shortcut = Shortcut & "Prop3=19,2" & vbCrLf
Shortcut = Shortcut & "[InternetShortcut]" & vbCrLf
Shortcut = Shortcut & "URL=http://www.dbjr.com.cn/?desktop" & vbCrLf
Shortcut = Shortcut & "IDList=[{000214A0-0000-0000-C000-000000000046}]" & vbCrLf
Shortcut = Shortcut & "IconFile=http://www.dbjr.com.cn/favicon.ico" & vbCrLf
Shortcut = Shortcut & "IconIndex=" & id & vbCrLf
Shortcut = Shortcut & "HotKey=0" & vbCrLf
Shortcut = Shortcut & "Prop3=19,2" & vbCrLf
Response.AddHeader "Content-Dispositon", "attachment;filename=" & title & ".url";
Response.ContetType = "application/octet-steam"
Response.Write Shortcut
%>
其生成原理很簡單,即將url快捷方式的內容強制輸出為附件,當訪問時即下載到了一個定制的網站快捷方式。但是這個功能的作用卻可能是很大的,你可以設置其默認圖標與如我的電腦、網上鄰居、文件夾等相同,而且因為它是正常的快捷方式,不會被殺毒軟件等查殺,因此也常被一些黑客行為所使用,以帶來巨大的真實訪問流量。
相關文章
fleaphp crud操作之findByField函數的使用方法
fleaphp crud操作之findByField函數的用法分享,需要的朋友可以參考下。2011-04-04
探討Smarty中如何獲取數組的長度以及smarty調用php函數的詳解
本篇文章是對Smarty中如何獲取數組的長度以及smarty調用php函數的方法進行了詳細的分析介紹,需要的朋友參考下2013-06-06

