在網站上設定“加入收藏、設為首頁”等按鈕是一般網站都會乾的事兒,但是有的網站還有“放到案頭”這樣的功能設定。
下面即產生捷徑並下載到案頭的php實現代碼,摘錄修改於網路,僅作參考
php實現代碼:
複製代碼 代碼如下:
<?php
if(isset($_GET[title]) && trim($_GET[title]) !== "") $title = trim($_GET[tilte]);
$content='
[DEFAULT]
BASEURL=http://www.jb51.net/?desktop
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
[InternetShortcut]
URL=http://www.jb51.net/?desktop
IDList=[{000214A0-0000-0000-C000-000000000046}]
IconFile=http://www.jb51.net/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.jb51.net/?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.jb51.net/?desktop" & vbCrLf
Shortcut = Shortcut & "IDList=[{000214A0-0000-0000-C000-000000000046}]" & vbCrLf
Shortcut = Shortcut & "IconFile=http://www.jb51.net/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捷徑的內容強制輸出為附件,當訪問時即下載到了一個定製的網站捷徑。但是這個功能的作用卻可能是很大的,你可以設定其預設表徵圖與如我的電腦、網路位置、檔案夾等相同,而且因為它是正常的捷徑,不會被殺毒軟體等查殺,因此也常被一些駭客行為所使用,以帶來巨大的真實訪問流量。