21,887
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<title>test</title>
<script language=javascript>
<!--
function updir(obj)
{
dirval = "mytest.php?flag=2&dir=";
dirval += obj;
alert(dirval);
location.replace(dirval);
}
//停止拖动;
function clickselect(obj)
{
fromList = eval(obj);
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
if (current.selected)
{
var dirval = fromList.options[i].value;
var url = dirval;
dirval = "mytest.php?dir=";
dirval += url;
location.replace(dirval);
break;
}
}
}
function copyToList(from,to)
{
fromList = eval(from);
toList = eval(to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
var sel = false;
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
if (current.selected)
{
sel = true;
if (current.value == 'temp')
{
alert ('你不能选择这一项!');
return;
}
txt = current.text;
val = current.value;
toList.options[toList.length] = new Option(txt,val);
}
}
if (!sel) alert ('你还没有选择任何项');
}
function del(from)
{
fromList = eval(from);
var sel = false;
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
if (current.selected)
{
sel = true;
if (current.value == 'temp')
{
alert ('你不能选择这一项!');
return;
}
txt = current.text;
val = current.value;
fromList.options[i] = null;
i--;
}
}
if (!sel) alert ('你还没有选择任何项');
}
//-->
</script>
</head>
<body>
<select name="possible" size="8" MULTIPLE width=120 ondblclick="clickselect(this)" >
<?
if($flag==2) {
$cut1=strrpos($dir,"/");
$dir=trim(substr($dir,0,$cut1));
echo "<SCRIPT LANGUAGE=javascript>";
echo "alert(\"$dir\")";
echo "</SCRIPT>";
}
exec("/bin/ls $dir > /tmp/syslog");
$logInf = file("/tmp/syslog");
$logInfNum = count($logInf);
for ($i=0; $i<$logInfNum; $i++){
$value = $dir."/";
echo "<option value=\"$value$logInf[$i]\"";
echo ">$logInf[$i]";
}
?>
</select>
<td width="20%" align="center">
<a <? echo "href=\"javascript:updir('$dir')\"";?> >up</a><br>
<a href="javascript:copyToList('possible','possible0')">add</a><br>
<br><a href="javascript:del('possible0')">del</a></td>
<td width="40%" align="center">
<select name="possible0" size="8" MULTIPLE width=120 >
</select>
</body>
</html>
//要获取dir从$_GET里
//要设置起始的dir
extract($_GET);
if($dir == "")
$dir = "...";
if($flag==2) {
$cut1=strrpos($dir,"/");
$dir=trim(substr($dir,0,$cut1));
echo "<SCRIPT LANGUAGE=javascript>";
echo "alert(\"$dir\")";
echo "</SCRIPT>";
}