Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修正一些notice #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class dir{
function __construct(){
$this->notex=array("php","js","tgz");//不允许显示的后缀名文件
$this->notdir=array("a","phpmyadmin");//不允许显示的文件夹
if ($_GET['dir']) {
if (!empty($_GET['dir'])) {
foreach ($this->notdir as $key => $value) {
if(strtolower($_GET['dir'])==$value){
$_GET['dir']=".";
Expand Down Expand Up @@ -45,7 +45,8 @@ function jugg($jugg){
$this->dirdir[]=$this->dir."/".$jugg;
}
}else{
$ex=array_pop(explode(".", $jugg));
$arrJugg = explode(".", $jugg);
$ex=array_pop($arrJugg);
//如果报错可将前一行代码写成以下形式
//$ar=explode(".", $jugg);
//$ex=array_pop($ar);
Expand All @@ -60,7 +61,8 @@ function dirurl($dir){
return "?dir=".$urf;
}
function type($file){
$ex=strtolower(array_pop(explode(".", $file)));
$arrFile = explode(".", $file);
$ex=strtolower(array_pop($arrFile));
switch ($ex) {
case 'png':
case 'jpg':
Expand Down Expand Up @@ -126,7 +128,8 @@ function torrent($torrent){

}
function filename($file){
return array_pop(explode("/", $file));
$arrFiles = explode("/", $file);
return array_pop($arrFiles);
}
function text($file){

Expand Down Expand Up @@ -154,7 +157,8 @@ function ctime($file){

}
function icon($file){
$ex=strtolower(array_pop(explode(".", $file)));
$arrFile = explode(".", $file);
$ex=strtolower(array_pop($arrFile));
switch ($ex) {
case 'png':
case 'jpg':
Expand Down Expand Up @@ -361,4 +365,4 @@ function pre(){

</script>
</body>
</html>
</html>
65 changes: 37 additions & 28 deletions wadir.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class dir{
function __construct(){
$this->notex=array("php","js","tgz");//不允许显示的后缀名文件
$this->notdir=array("a","phpmyadmin");//不允许显示的文件夹
if ($_GET['dir']) {
if (!empty($_GET['dir'])) {
foreach ($this->notdir as $key => $value) {
if(strtolower($_GET['dir'])==$value){
$_GET['dir']=".";
Expand All @@ -63,8 +63,8 @@ function open_dir(){
while(($file=readdir($dh))!==false){
$this->jugg($file);
}
sort($this->file);
sort($this->dirdir);
$this->file && sort($this->file);
$this->dirdir && sort($this->dirdir);
closedir($dh);
}
}else{
Expand All @@ -78,7 +78,8 @@ function jugg($jugg){
$this->dirdir[]=$this->dir."/".$jugg;
}
}else{
$ex=array_pop(explode(".", $jugg));
$arrJugg = explode(".", $jugg);
$ex=array_pop($arrJugg);
if(!in_array(strtolower($ex), $this->notex)){
$this->file[]=$this->dir."/".$jugg;
}
Expand All @@ -90,7 +91,8 @@ function dirurl($dir){
return "?dir=".$urf;
}
function type($file){
$ex=strtolower(array_pop(explode(".", $file)));
$arrFile = explode(".", $file);
$ex=strtolower(array_pop($arrFile));
switch ($ex) {
case 'png':
case 'jpg':
Expand Down Expand Up @@ -156,7 +158,8 @@ function torrent($torrent){

}
function filename($file){
return array_pop(explode("/", $file));
$arrFile = explode("/", $file);
return array_pop($arrFile);
}
function text($file){

Expand Down Expand Up @@ -184,7 +187,8 @@ function ctime($file){

}
function icon($file){
$ex=strtolower(array_pop(explode(".", $file)));
$arrFile = explode(".", $file);
$ex=strtolower(array_pop($arrFile));
switch ($ex) {
case 'png':
case 'jpg':
Expand Down Expand Up @@ -230,6 +234,7 @@ function pre(){
if($num>=2){
@array_shift($dir_array);
$url="<a class=\"text-success\" href=?>/.</a>";
$step = '';
foreach ($dir_array as $key => $value) {
$step=$step.$value."/";
$url=$url."<a class=\"text-success\" href=\"?dir=".$step."\">/".$value."</a>";
Expand Down Expand Up @@ -284,10 +289,10 @@ function size($fz){
</head>
<body>
<?php
if ($_POST['password']==PASS) {
if (isset($_POST['password']) && $_POST['password']==PASS) {
$_SESSION['user']="666";
}
if($_SESSION['user']){
if(isset($_SESSION['user']) && $_SESSION['user']){
}else{
?>
<div class="container">
Expand All @@ -311,21 +316,21 @@ function size($fz){
<?php
return;
}
if (strlen($_GET['url'])>5) {//验证session才能添加操作
if (isset($_GET['url']) && strlen($_GET['url'])>5) {//验证session才能添加操作
$url=$_GET['url'];
$dir=dirname(__FILE__);
$aria2 = new Aria2('http://127.0.0.1:6800/jsonrpc');
$json=$aria2->addUri(array($url),array('dir'=>$dir,));
echo json_encode($json);
return;
}
if(strlen($_GET['pause'])>5){
if(isset($_GET['pause']) && strlen($_GET['pause'])>5){
$aria2 = new Aria2('http://127.0.0.1:6800/jsonrpc');
$aria2->pause($_GET['pause']);
header("Location:".$_SERVER['HTTP_REFERER']);
return;
}
if(strlen($_GET['unpause'])>5){
if(isset($_GET['unpause']) && strlen($_GET['unpause'])>5){
$aria2 = new Aria2('http://127.0.0.1:6800/jsonrpc');
$aria2->unpause($_GET['unpause']);
header("Location:".$_SERVER['HTTP_REFERER']);
Expand Down Expand Up @@ -367,22 +372,26 @@ function size($fz){
<th>下载</th>
</tr>
<?php
foreach ($x->dirdir as $key => $value) {
echo "<tr>";
echo "<td><a href=\"".$x->dirurl($value)."\"><span class=\"glyphicon glyphicon-list\"> ".$x->filename($value)."</span></a></td>";
echo "<td>目录</td>";
echo "<td>".$x->mtime($value)."</td>";
echo "<td></td>";
echo "</tr>";
}
foreach ($x->file as $key => $value) {
echo "<tr>";
echo "<td><span class=\" click_onload ".$x->icon($value)." fileshow\" type=\"".$x->type($value)."\" value=\"".rawurlencode($value)."\"> ".$x->filename($value)."</span></td>";
echo "<td>".$x->size($value)."</td>";
echo "<td>".$x->mtime($value)."</td>";
echo "<td>".$x->download($value)."</td>";
echo "</tr>";
}
if ($x->dirdir) {
foreach ($x->dirdir as $key => $value) {
echo "<tr>";
echo "<td><a href=\"".$x->dirurl($value)."\"><span class=\"glyphicon glyphicon-list\"> ".$x->filename($value)."</span></a></td>";
echo "<td>目录</td>";
echo "<td>".$x->mtime($value)."</td>";
echo "<td></td>";
echo "</tr>";
}
}
if ($x->file) {
foreach ($x->file as $key => $value) {
echo "<tr>";
echo "<td><span class=\" click_onload ".$x->icon($value)." fileshow\" type=\"".$x->type($value)."\" value=\"".rawurlencode($value)."\"> ".$x->filename($value)."</span></td>";
echo "<td>".$x->size($value)."</td>";
echo "<td>".$x->mtime($value)."</td>";
echo "<td>".$x->download($value)."</td>";
echo "</tr>";
}
}
?>
</table>
<span>Powered by <a href="https://git.oschina.net/supercell/webdir">webdir</a></span>
Expand Down