2013-01-24 11:25:15 +00:00
|
|
|
|
<?php
|
|
|
|
|
/*
|
2017-10-11 09:58:04 +00:00
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
LICENSE
|
2013-02-01 09:01:30 +00:00
|
|
|
|
|
2017-10-11 09:58:04 +00:00
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License (GPL)
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
2013-02-01 09:01:30 +00:00
|
|
|
|
|
2017-10-11 09:58:04 +00:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
2013-02-01 09:01:30 +00:00
|
|
|
|
|
2017-10-11 09:58:04 +00:00
|
|
|
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
*/
|
2013-02-01 09:01:30 +00:00
|
|
|
|
|
2017-10-11 09:58:04 +00:00
|
|
|
|
/**
|
|
|
|
|
* An HTML page to browse for a folder on a remote server and choose it using
|
|
|
|
|
* Javascript. Chroot the user to its root,
|
|
|
|
|
*
|
|
|
|
|
* @copyright AlternC-Team 2000-2017 https://alternc.com/
|
2013-02-01 09:01:30 +00:00
|
|
|
|
*/
|
2017-10-11 09:58:04 +00:00
|
|
|
|
|
2013-01-24 11:25:15 +00:00
|
|
|
|
include("../class/config.php");
|
|
|
|
|
|
|
|
|
|
$fields = array (
|
2013-02-01 09:01:30 +00:00
|
|
|
|
"caller" => array ("request", "string", ""),
|
|
|
|
|
"select" => array ("request", "string", ""),
|
|
|
|
|
"curdir" => array ("request", "string", ""),
|
|
|
|
|
"lastcurdir" => array ("request", "string", ""),
|
|
|
|
|
"file" => array ("request", "string", ""),
|
|
|
|
|
"bid" => array ("request", "string", ""),
|
|
|
|
|
);
|
2013-01-24 11:25:15 +00:00
|
|
|
|
getFields($fields);
|
|
|
|
|
|
2014-03-26 13:59:41 +00:00
|
|
|
|
/**
|
|
|
|
|
* @param integer $pos
|
|
|
|
|
* @param integer $level
|
2014-03-26 15:05:05 +00:00
|
|
|
|
* @param string $curdir
|
2014-03-26 13:59:41 +00:00
|
|
|
|
*/
|
2013-01-24 11:25:15 +00:00
|
|
|
|
function _subbrowse($curdir,$pos,$level) {
|
2013-02-01 09:01:30 +00:00
|
|
|
|
global $maxlevel,$root,$brlist;
|
|
|
|
|
if ($level>$maxlevel)
|
|
|
|
|
$maxlevel=$level;
|
|
|
|
|
$rot=substr($curdir,0,$pos);
|
|
|
|
|
$next=@strpos($curdir,"/",$pos+1);
|
|
|
|
|
$nextstr=substr($curdir,$pos+1,$next-$pos-1);
|
|
|
|
|
$c=opendir($root.$rot);
|
|
|
|
|
$i=0; $tmp = array();
|
|
|
|
|
while ($r=readdir($c)) {
|
|
|
|
|
if (is_dir($root.$rot."/".$r) && $r!="." && $r!="..") { $tmp[$i++]=$r; }
|
|
|
|
|
}
|
|
|
|
|
sort($tmp);
|
|
|
|
|
foreach ($tmp as $r) {
|
|
|
|
|
/* Ajout */
|
|
|
|
|
$brlist[]=array("dir"=>$r,"level"=>$level,"put"=> ife($curdir==$rot."/".$r."/","",$rot."/".$r));
|
|
|
|
|
if ($r==$nextstr) {
|
|
|
|
|
_subbrowse($curdir,$next,$level+1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-01-24 11:25:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-26 14:36:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* @param string $curdir
|
|
|
|
|
*/
|
2013-01-24 11:25:15 +00:00
|
|
|
|
function browseforfolder($curdir) {
|
2013-02-01 09:01:30 +00:00
|
|
|
|
global $maxlevel,$root,$brlist;
|
|
|
|
|
$maxlevel=0;
|
|
|
|
|
$brlist=array(array("dir"=>"/","level"=>0,"put"=> ife($curdir=="/","","/") ));
|
|
|
|
|
_subbrowse($curdir,0,1);
|
|
|
|
|
return $brlist;
|
2013-01-24 11:25:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$root=getuserpath();
|
|
|
|
|
// pour utiliser 'la ou est browseforfolder', mettre dirname($HTTP_SERVER_VARS["PATH_TRANSLATED"]);
|
|
|
|
|
|
|
|
|
|
if (substr($file,0,1)!="/") $file="/".$file;
|
|
|
|
|
if (substr($file,-1)!="/") $file.="/";
|
|
|
|
|
if (!$file) $file="/";
|
|
|
|
|
|
|
|
|
|
$errbrowsefold=0; /* Erreur lors de la cr<63>ation d'un dossier */
|
|
|
|
|
$brlist=array(); /* Liste des dossiers ... */
|
|
|
|
|
$maxlevel=0;
|
|
|
|
|
?>
|
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
|
|
|
|
|
<head>
|
|
|
|
|
<title>Recherche d'un dossier</title>
|
|
|
|
|
<link rel="stylesheet" href="styles/style.css" type="text/css" />
|
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
2018-06-24 14:49:43 +00:00
|
|
|
|
<script src="/javascript/jquery/jquery.min.js" type="text/javascript"></script>
|
2013-01-24 11:25:15 +00:00
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
/* Fonction appell<6C>e lors du lancement d'un popup Fichier : */
|
|
|
|
|
function popupfile() {
|
2013-02-01 09:01:30 +00:00
|
|
|
|
window.focus();
|
|
|
|
|
if (document.forms["main"].file)
|
|
|
|
|
document.forms["main"].file.focus();
|
2013-01-24 11:25:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addslashes(ch) {
|
2013-02-01 09:01:30 +00:00
|
|
|
|
ch = ch.replace(/\\/g,"\\\\")
|
|
|
|
|
ch = ch.replace(/\'/g,"\\'")
|
|
|
|
|
ch = ch.replace(/\"/g,"\\\"")
|
|
|
|
|
return ch
|
2013-01-24 11:25:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Fontion de retour de la valeur selectionnee */
|
|
|
|
|
function retour() {
|
2015-05-12 14:07:39 +00:00
|
|
|
|
window.parent.jQuery('#<?php echo $caller; ?>').val( $("#file").val() );
|
2013-01-24 11:25:15 +00:00
|
|
|
|
window.parent.jQuery('#<?php echo $bid; ?>').dialog('close');
|
2013-02-01 09:01:30 +00:00
|
|
|
|
return false;
|
2013-01-24 11:25:15 +00:00
|
|
|
|
}
|
2015-05-12 14:07:39 +00:00
|
|
|
|
|
2013-01-24 11:25:15 +00:00
|
|
|
|
</script>
|
|
|
|
|
</head>
|
2013-01-30 15:27:43 +00:00
|
|
|
|
<body class="light" onload="popupfile();">
|
2013-01-24 13:23:55 +00:00
|
|
|
|
<h3><?php __("Searching for a folder"); ?></h3>
|
2013-01-24 11:25:15 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
$ar=browseforfolder($file);
|
|
|
|
|
if ($errbrowsefold) {
|
2013-02-01 09:01:30 +00:00
|
|
|
|
/* Si le dossier sp<73>cifi<66> n'existe pas ou est un fichier : */
|
|
|
|
|
echo _("Error, cannot find this folder")."<br />";
|
|
|
|
|
/* Retour : */
|
|
|
|
|
echo "<a href=\"browseforfolder2.php?caller=".urlencode($caller)."&curdir=".$root."&bid=".$bid."\">"._("Back to the root folder")."</a><br />";
|
2013-01-24 11:25:15 +00:00
|
|
|
|
} else {
|
2013-02-01 09:01:30 +00:00
|
|
|
|
/* Sinon, tout va bien, on affiche le tableau */
|
|
|
|
|
reset($ar);
|
|
|
|
|
?>
|
|
|
|
|
<form method="post" id="main" name="main" action="browseforfolder2.php">
|
2016-05-20 12:21:47 +00:00
|
|
|
|
<?php csrf_get(); ?>
|
2013-02-01 09:01:30 +00:00
|
|
|
|
<p>
|
2016-05-23 14:08:23 +00:00
|
|
|
|
<input type="hidden" name="caller" value="<?php ehe($caller); ?>" />
|
|
|
|
|
<input type="hidden" name="lastcurdir" value="<?php ehe($curdir); ?>" />
|
|
|
|
|
<input type="hidden" name="bid" value="<?php ehe($bid); ?>" />
|
2013-02-01 09:01:30 +00:00
|
|
|
|
|
|
|
|
|
<input type="text" class="int" id="file" name="file" size="20" value="<?php ehe($file); ?>" /><br />
|
|
|
|
|
|
|
|
|
|
<input type="button" name="select" value="<?php __("Select"); ?>" class="inb" onclick="retour();" />
|
2016-05-22 18:14:26 +00:00
|
|
|
|
<input type="button" name="cancel" value="<?php __("Cancel"); ?>" class="inb" onclick="window.parent.jQuery('#<?php ehe($bid); ?>').dialog('close');" />
|
2013-02-01 09:01:30 +00:00
|
|
|
|
</p>
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
<table style="border: 0" cellspacing="2" cellpadding="0">
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
while (list($key,$val)=each($ar)) {
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
for ($i=0;$i<$val["level"];$i++)
|
|
|
|
|
echo "<td width=\"16\"></td>";
|
|
|
|
|
if ($val["put"]!="") {
|
|
|
|
|
?>
|
|
|
|
|
<td width="16"><img src="icon/folder.png" width="16" height="16" alt="" /></td>
|
|
|
|
|
<?php
|
|
|
|
|
} else {
|
|
|
|
|
?>
|
|
|
|
|
<td width="16"><img src="icon/openfold.png" width="16" height="16" alt="" /></td>
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
echo "<td colspan=\"".($maxlevel-$val["level"]+1)."\">";
|
|
|
|
|
if ($val["put"]!="") {
|
2016-05-22 18:14:26 +00:00
|
|
|
|
echo "<a href=\"browseforfolder2.php?caller=".eue($caller,false)."&bid=".eue($bid,false)."&file=".eue($val["put"],false)."\">".ehe($val["dir"],false)."</a>";
|
2013-02-01 09:01:30 +00:00
|
|
|
|
} else {
|
2016-05-22 18:14:26 +00:00
|
|
|
|
echo "<b>".ehe($val["dir"],false)."</b>";
|
2013-02-01 09:01:30 +00:00
|
|
|
|
}
|
|
|
|
|
echo "</td>\n</tr>\n";
|
|
|
|
|
}
|
2013-01-24 11:25:15 +00:00
|
|
|
|
} // OK ?
|
|
|
|
|
?>
|
|
|
|
|
</table>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|