Home > php教程 > PHP源码 > body text

可让软件读取更新的PHP页面

PHP中文网
Release: 2016-05-25 17:06:42
Original
1266 people have browsed it

如果直接访问页面,会显示公开信息.  带p值访问,会显示隐藏信息. 
不是什么新异的思路,刚才写个小软件需要用到自动更新,所以就写了这个PHP来让软件读取. 
index.php是主页面, 
up.php是上传附件页面,呃.这个页面貌似没什么用

1. [PHP]代码

index.php
 
<?php
//Y-m-d H:i:s任选 分别是取年月日时分秒
$n1="azhus.com".date("H"); //第一个权限
$n2="azhus".date("H"); //第二个权限
 
$p=$_POST[&#39;p&#39;]; //p为POST的p参数
 
 
if ($p==$n1)
  echo "版本:2;地址:http://bbs.vvell.com/201304/13175552.rar;"; //格式为"版本:**;地址:**;" 下同
elseif ($p==$n2)
  echo "版本:3;地址:http://bbs.vvell.com/201304/13175628.rar;"; 
else
  echo "公告:<br>来自爱注释论坛,http://azhus.com"; 
 
?>
 
 
up.php
 
<?
    $fileup     = 0; //上传功能开关 0打开 1关闭
    $filesize   = 200; //文件大小单位KB 1M=1024KB
    $filetype   = array(&#39;jpg&#39;,&#39;gif&#39;,&#39;bmp&#39;,&#39;rar&#39;,&#39;zip&#39;,&#39;7z&#39;); //文件类型
    $filepath   = &#39;./&#39;; //文件保存目录 后面要加/ 不能超过两级目录
if ($_GET[&#39;up&#39;]){
    if ($fileup) exit (&#39;上传功能已关闭!&#39;);
    $fileend = end(explode(&#39;.&#39;,basename($_FILES[&#39;file&#39;][&#39;name&#39;])));//取得后缀名
    //判断文件类型和大小
    if(in_array($fileend,$filetype) && $_FILES[&#39;file&#39;][&#39;size&#39;] < 1024*$filesize){
        if (!file_exists($filepath)) mkdir ($filepath);
        //如果不是当前目录需要这句 判断文件保存目录是否存在 没有则创建
        $filepath = $filepath.date(&#39;Ym&#39;).&#39;/&#39;;//以年月作为目录
        if (!file_exists($filepath)) mkdir ($filepath);//判断年月目录是否存在 没有则创建
        date_default_timezone_set(&#39;PRC&#39;);//中国时间
        $fileurl = $filepath.date(&#39;dHis.&#39;).$fileend;//文件路径 用日时分秒作为文件名
        move_uploaded_file($_FILES[&#39;file&#39;][&#39;tmp_name&#39;],$fileurl);//把上传的文件移动到我们指定的文件路径
    }else{
        exit(&#39;<script>alert("文件大小或类型错误!");location="?";</script>&#39;);
    }
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>上传文件</title>
</head>
<body style="font-size:14px; line-height:25px;">
<? if($_GET[&#39;up&#39;]){ ?>
    <p>
    <strong>上传成功!</strong><br/>请复制文件地址:
    <input type="text" onClick="select();" value="<? if ($_GET[&#39;up&#39;]) echo $fileurl ?>" /><br/>
    点文本框自动全选 Ctrl+C 复制 或 鼠标右键复制<br/>
    在需要使用的地方 Ctrl+V 粘贴 或 鼠标右键粘贴
    </p>
<? }?>
<? if($fileend==&#39;jpg&#39;||$fileend==&#39;gif&#39;||$fileend==&#39;bmp&#39;){ ?>
    <p><strong>图片预览</strong>:<br>
    <img src="<?=$fileurl?>"/></a></p>
<? }?>
<form method="post" action="?up=file" enctype="multipart/form-data">
    <input name="file" type="file"><input type="submit" value="上传">
</form>
<p><strong>大小:</strong><?=$filesize?> KB<br/><strong>类型:</strong>
<? for($i=0; $i < count($filetype); $i++) echo $filetype[$i],&#39; &#39; ?></p>
</body>
</html>
Copy after login

以上就是可让软件读取更新的PHP页面的内容,更多相关内容请关注PHP中文网(m.sbmmt.com)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!