ASP和PHP實現產生網站捷徑並下載到案頭的方法_php技巧

來源:互聯網
上載者:User

在網站上設定“加入收藏、設為首頁”等按鈕是一般網站都會乾的事兒,但是有的網站還有“放到案頭”這樣的功能設定。
下面即產生捷徑並下載到案頭的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捷徑的內容強制輸出為附件,當訪問時即下載到了一個定製的網站捷徑。但是這個功能的作用卻可能是很大的,你可以設定其預設表徵圖與如我的電腦、網路位置、檔案夾等相同,而且因為它是正常的捷徑,不會被殺毒軟體等查殺,因此也常被一些駭客行為所使用,以帶來巨大的真實訪問流量。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.