ASP和PHP实现生成网站快捷方式并下载到桌面的方法

yipeiwu_com5年前PHP代码库

在网站上设置“加入收藏、设为首页”等按钮是一般网站都会干的事儿,但是有的网站还有“放到桌面”这样的功能设置。
下面即生成快捷方式并下载到桌面的php实现代码,摘录修改于网络,仅作参考

php实现代码:

复制代码 代码如下:

<?php
if(isset($_GET[title]) && trim($_GET[title]) !== "") $title = trim($_GET[tilte]);
$content='
[DEFAULT]
BASEURL=//www.jb51.net/?desktop
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
[InternetShortcut]
URL=//www.jb51.net/?desktop
IDList=[{000214A0-0000-0000-C000-000000000046}]
IconFile=//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="【宜配屋www.yipeiwu.com】"

Shortcut = "[DEFAULT]" & vbCrLf
Shortcut = Shortcut & "BASEURL=//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=//www.jb51.net/?desktop" & vbCrLf
Shortcut = Shortcut & "IDList=[{000214A0-0000-0000-C000-000000000046}]" & vbCrLf
Shortcut = Shortcut & "IconFile=//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快捷方式的内容强制输出为附件,当访问时即下载到了一个定制的网站快捷方式。但是这个功能的作用却可能是很大的,你可以设置其默认图标与如我的电脑、网上邻居、文件夹等相同,而且因为它是正常的快捷方式,不会被杀毒软件等查杀,因此也常被一些黑客行为所使用,以带来巨大的真实访问流量。

相关文章

php输出xml必须header的解决方法

本文实例讲述了php输出xml必须header的解决方法。分享给大家供大家参考。具体方法如下: 问题描述: 最近在做一个xml输出时发现我们直接使用echo输入的xml文档会提示Erro...

php中几种常见安全设置详解

另外,目前闹的轰轰烈烈的SQL Injection也是在PHP上有很多利用方式,所以要保证安全,PHP代码编写是一方面,PHP的配置更是非常关键。 我们php手手工安装的,php的默认...

phpinfo() 中 Local Value(局部变量)Master Value(主变量) 的区别

phpinfo() 的很多部分有两个Column:Local Value和Master Value 1. Master Value是PHP.ini文件中的内容。 2.Local valu...

php 魔术方法详解

从PHP 5以后的版本,PHP中的类就可以使用魔术方法了。其规定以两个下划线(__)开头的方法都保留为魔术方法,所以建议大家函数名最好不用__开头,除非是为了重载已有的魔术方法。PHP...

php数组函数序列之array_search()- 按元素值返回键名

array_search()定义和用法 array_search() 函数与 in_array() 一样,在数组中查找一个键值。如果找到了该值,匹配元素的键名会被返回。如果没找到,则返回...