开心网首页的“设为桌面图标”是怎么实现的? 请问:“开心网”首页的“设为桌面图标”shortcut.php 是怎么实现 在桌面建立快捷方式,而且还是中文名的? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不知道 不过 用Delphi写个小程序很容易就实现了 不就是一个url文件吗?你可以这样做1、访问你需要生成“桌面图标”的网址,最好是有自定义url图标的那种,将地址栏的图标拖到桌面上2、创建一个文件下载的php程序,执行时输出第一步生成的文件 问题是,那是个快捷方式 xxx.url,而不是一个应用程序xxx.exe,请问,这个下载输出怎么实现呢? <?php header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=\"url.url\"");?>关键是设置header 以下代码可以实现,不过IE的默认安全级别是不允许直接对客户端文件进行操作的,使用前得修改ie安全级别。如果能随便写入硬盘文件,那挂马可就容易了。个人感觉不太实用。以下代码在IE8 win7下测试通过(级别低)<script language="JavaScript">function toDesktop(sUrl,sName){try{var WshShell = new ActiveXObject("WScript.Shell");var oUrlLink = WshShell.CreateShortcut(WshShell.SpecialFolders("Desktop") + "\\" + sName + ".url");oUrlLink.TargetPath = sUrl;oUrlLink.Save();}catch(e){alert("当前IE安全级别不允许操作!请设置后在操作.");}}</script><input name="btn" type="button" id="btn" value="创建大智若鲁的快捷方式" onClick="toDesktop('http:\//www.lzpnb.com/','大智若鲁's blog)"> 呵呵,没想到你也对这个感兴趣C:\Documents and Settings\***\Favoritesphp把这里面的某个文件输出并强制下载就行了 我还发现,右键点击这个 shortcut.php 另存为 居然也可以保存为 桌面快捷方式。我怀疑,这个会不会根本就不是真正的php文件啊? 不是吧?就是下载了一个 开心网.url 的文件而已。。 那右键点击 另存为 又怎么解释呢?按理说,是应该下载了 shortcut.php 啊。 加了个http的头呗。给你看一下全部Http协议全文HTTP/1.1 200 OKDate: Thu, 21 Jan 2010 05:31:52 GMTServer: ApacheContent-Encoding: no-gzipContent-Disposition: attachment; filename="¿ªÐÄÍø.url"Content-Length: 114Vary: User-AgentConnection: closeContent-Type: application/octet-stream[InternetShortcut]URL=http://www.kaixin001.com/IDList=[{000214A0-0000-0000-C000-000000000046}]Prop3=19,2 <?php $file='test.url';header("Content-Encoding: no-gzip"); header("Content-Disposition: attachment; filename=\"$file\""); header("Content-Length: 114"); header("Connection: close"); header("Content-Type: application/octet-stream"); echo "[InternetShortcut] URL=http://www.kaixin001.com/ IDList= [{000214A0-0000-0000-C000-000000000046}] Prop3=19,2";?> 没有下载过程,没实现... http头和内容之间要用两个回车,你给少掉啦 <?php $filename="开心网.url";header("Content-Disposition: attachment; filename=".urlencode($filename));header("Content-Type: application/octet-stream");?>[InternetShortcut]URL=http://www.kaixin001.com/IDList=[{000214A0-0000-0000-C000-000000000046}]Prop3=19,2 不就是下载了一个internet快捷方式么 大家可以看看这篇文章类似WebQQ“设为桌面图标”的ASP及PHP源代码http://www.cnarrow.com/post/shorturl.html public function shortcutAction(){ $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender( true ); $url = site_url(); $Shortcut = " [InternetShortcut] URL=".$url." IDList=IconIndex=43 IconFile=/favicon.ico HotKey=1626 [{000214A0-0000-0000-C000-000000000046}] Prop3=19,2"; Header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=开心网.url"); echo $Shortcut; } $Shortcut = "[InternetShortcut] URL=http://www.7guo.com IDList= [{000214A0-0000-0000-C000-000000000046}] Prop3=19,2 "; $ua = $_SERVER["HTTP_USER_AGENT"]; $filename = "开心网.url"; $encoded_filename = urlencode($filename); $encoded_filename = str_replace("+", "%20", $encoded_filename); header('Content-Type: application/octet-stream'); if (preg_match("/MSIE/", $ua)) { header('Content-Disposition: attachment; filename="' . $encoded_filename . '"'); } else if (preg_match("/Firefox/", $ua)) { header('Content-Disposition: attachment; filename*="utf8\'\'' . $filename . '"'); } else { header('Content-Disposition: attachment; filename="' . $filename . '"'); } echo $Shortcut; Excel导入mysql数据丢失 php如何循环读出这个数组里的url和alt bin2hex函数的逆过程是什么函数? 为什么print_r或echo总是多输出一个字节0x0a,如何解决? 有谁对torrent 比较熟悉 这是书本上的上传文件的例子,为什么运行有错误?? 发现PHP漏洞,大家不要用这个方法攻击服务器啊,用这段代码可以使mysql停止服务 CVS 是什么意思呀?! MYsql+PHP的update问题 求程序 MySQL数据库 mysql的id插入问题
你可以这样做
1、访问你需要生成“桌面图标”的网址,最好是有自定义url图标的那种,将地址栏的图标拖到桌面上
2、创建一个文件下载的php程序,执行时输出第一步生成的文件
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=\"url.url\"");
?>关键是设置header
<script language="JavaScript">
function toDesktop(sUrl,sName){
try
{
var WshShell = new ActiveXObject("WScript.Shell");
var oUrlLink = WshShell.CreateShortcut(WshShell.SpecialFolders("Desktop") + "\\" + sName + ".url");
oUrlLink.TargetPath = sUrl;
oUrlLink.Save();
}
catch(e)
{
alert("当前IE安全级别不允许操作!请设置后在操作.");
}
}
</script>
<input name="btn" type="button" id="btn" value="创建大智若鲁的快捷方式" onClick="toDesktop('http:\//www.lzpnb.com/','大智若鲁's blog)">
Date: Thu, 21 Jan 2010 05:31:52 GMT
Server: Apache
Content-Encoding: no-gzip
Content-Disposition: attachment; filename="¿ªÐÄÍø.url"
Content-Length: 114
Vary: User-Agent
Connection: close
Content-Type: application/octet-stream[InternetShortcut]
URL=http://www.kaixin001.com/
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
<?php
$file='test.url';
header("Content-Encoding: no-gzip");
header("Content-Disposition: attachment; filename=\"$file\"");
header("Content-Length: 114");
header("Connection: close");
header("Content-Type: application/octet-stream");
echo "[InternetShortcut]
URL=http://www.kaixin001.com/
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2";
?>
没有下载过程,没实现...
$filename="开心网.url";
header("Content-Disposition: attachment; filename=".urlencode($filename));
header("Content-Type: application/octet-stream");
?>
[InternetShortcut]
URL=http://www.kaixin001.com/
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
http://www.cnarrow.com/post/shorturl.html
public function shortcutAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender( true );
$url = site_url();
$Shortcut = "
[InternetShortcut]
URL=".$url."
IDList=IconIndex=43
IconFile=/favicon.ico
HotKey=1626
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2";
Header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=开心网.url");
echo $Shortcut;
}
URL=http://www.7guo.com
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
";
$ua = $_SERVER["HTTP_USER_AGENT"]; $filename = "开心网.url";
$encoded_filename = urlencode($filename);
$encoded_filename = str_replace("+", "%20", $encoded_filename);
header('Content-Type: application/octet-stream');
if (preg_match("/MSIE/", $ua)) {
header('Content-Disposition: attachment; filename="' . $encoded_filename . '"');
} else if (preg_match("/Firefox/", $ua)) {
header('Content-Disposition: attachment; filename*="utf8\'\'' . $filename . '"');
} else {
header('Content-Disposition: attachment; filename="' . $filename . '"');
}
echo $Shortcut;