File "arbo_test011.php"
Full Path: /home/analogde/www/Prog/File explorer/arbo_test011.php
File size: 42.92 KB
MIME-type: text/x-php
Charset: utf-8
<?php
session_start();
include 'classe.php';
$uri = $_SERVER['REQUEST_URI'];
//echo $uri; // Outputs: URI
//echo "<br>";
//echo "<br>";
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//echo $url; // Outputs: Full URL
//echo "<br>";
//echo "<br>";
//$query = $_SERVER['QUERY_STRING'];
//echo $query; // Outputs: Query String
echo "<br>";
echo "<br>";
if (!isset($_SESSION["visits"]))
$_SESSION["visits"] = 0;
$_SESSION["visits"] = $_SESSION["visits"] + 1;
if ($_SESSION["visits"] > 1)
{
//you refreshed the page!
}
else
{
//nothing to do here!
}
$pageWasRefreshed = isset($_SERVER['HTTP_CACHE_CONTROL']) && $_SERVER['HTTP_CACHE_CONTROL'] === 'max-age=0';
if($pageWasRefreshed )
{
// refreshed;
$refresh = true;
}
else
{
//do nothing
$refresh = false;
}
echo "pipo --> " .$_GET['pipo'] ."<br>";
echo "typefile --> " .$_GET['typefile'] ."<br>";
echo "upload --> " .$_GET['upload'] ."<br>";
echo "<br>";
echo "<br>";
//home/analogde/www/Fusion/POO
$highlightjs_style = 'vs';
define('FM_HIGHLIGHTJS_STYLE', $highlightjs_style);
?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.2.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.2.0/styles/<?php echo FM_HIGHLIGHTJS_STYLE ?>.min.css">
<?php
// echo 'Referrer is ' . $_SERVER['HTTP_REFERER'] . '<br>';
/* function goback()
{
header("Location: {$_SERVER['HTTP_REFERER']}");
//exit;
}
goback();*/
///$_SERVER['HTTP_REFERER']
// https://www.tutorialspoint.com/how-to-stop-browser-s-back-button-using-javascript
// How to Disable Browser Back Button using JavaScript
//$file = "pipo.html";
//$file = "GANTT";
/*
function test_file_or_folder()
{
$file = $_SERVER['DOCUMENT_ROOT'] ."/Fusion/GANTT";
if(is_dir($file))
{
echo ("$file is a directory");
}
else
{
echo ("$file is not a directory");
}
$file = $_SERVER['DOCUMENT_ROOT'] ."/Fusion/pipo.html";
if(is_file($file))
{
echo ("$file is a file");
}
else
{
echo ("$file is not a file");
}
$root_path = $_SERVER['DOCUMENT_ROOT'];
$dirReference = $root_path ."/Fusion";
}
*/
?>
<style>
#wrapper{max-width:1000px;min-width:400px;margin:10px auto}
.path{padding:4px 7px;border:1px solid #ddd;background-color:#fff;margin-bottom:10px}
/*
.file-name {
width: 200px;
border: 1px solid #aaa;
overflow-wrap: break-word;
padding: 2px;
}
input[type='file'] {
display: none;
}
*/
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
// https://www.dotnetfunda.com/forums/show/21633/is-it-possible-to-detect-a-page-refresh-f5-using-jquery
/*
$(document.body).on("keydown", this,
function (event) {
if (event.keyCode == 116) { alert('F5 pressed!');
}
});
*/
// https://www.geeksforgeeks.org/how-to-make-ajax-call-from-javascript/
/*document.addEventListener("keypress", function(event) {
if (event.keyCode == 13) {
alert('hi.');
}
});*/
//document.onkeydown = fkey;
//document.onkeypress = fkey
/* inactif
document.onkeyup = fkey;
var wasPressed = false;
function fkey(e){
e = e || window.event;
if( wasPressed ) return;
if (e.keyCode == 116) {
// alert("Refresh f5 pressed");
pipo();
wasPressed = true;
}
/*else {
alert("Window closed");
}*/
/*}*/
/*function changeSession()
{
var value="recharger_page";
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
{
alert(xmlHttp.responseText);
}
}
xmlHttp.open("post", "change_session_variable.php");
xmlHttp.send(value);
}*/
/*
function pipo()
{
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function()
{
// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
if(xhr.readyState == 4 && xhr.status == 200)
{
retour = xhr.responseText;
//alert(retour);
//location.reload();
}
}
xhr.open("POST","change_session_variable.php",true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
var value="recharger_page";
xhr.send("envoi="+value);
}
*/
</script>
<style type="text/css">
.tbl {width: 640px;}
.tbl tr {background-color: Blue; height: 24px}
.tbl tr:hover {background-color: Red;}
</style>
<style>
tr:hover {
background-color: #ffff99;
}
.selected {
background-color: #E30B5C;
}
.noselected {
background-color: #5555;
}
.newRow
{
color: #dd0000;
background-color:#ffd700;
}
.blankcell {
background: none!important;
border: none!important;
}
.aligned {
display: flex;
align-items: center;
}
.aligned > img {
margin-right: 10px;
}
a { text-decoration: none; }
</style>
<script type="text/javascript">
function disableBack()
{ window.history.forward(); }
//setTimeout("disableBack()", 0);
//window.onunload = function () { null };
// JavaScript Code to Highlight any
// row in the given table.
/* document.getElementById('table_to_highlight')
.addEventListener('click', function (item) {
// To get tr tag
// In the row where we click
var row = item.path[1];
var row_value = "";
for (var j = 0; j < row.cells.length; j++) {
row_value += row.cells[j].innerHTML;
row_value += " | ";
}
alert(row_value);
// Toggle the highlight
if (row.classList.contains('highlight'))
row.classList.remove('highlight');
else
row.classList.add('highlight');
});
*/
</script>
<script>
function toggle(source)
{
let checkboxes = document.querySelectorAll('input[type="checkbox"]');
for (let i = 1; i < checkboxes.length; i++)
{
if (checkboxes[i] != source)
{
checkboxes[i].checked = source.checked;
// document.getElementById("table_to_highlight").rows[i].style.background = selected;
// document.getElementById('t2').style.backgroundColor=color3;
//x[i].innerHTML = "NEW CONTENT";
}
}
selectedRow();
}
function plouf(element)
{
//alert("Bingo...");
//var x = document.getElementById("table_to_highlight").rows[element].cells;
// x.className = "newRow";
// console.log(x);
/*if( element.style == "selected")
{
element.classList.toggle("noselected");
alert("annule");
}
else
{
element.classList.toggle("selected");
alert("flash");
} */
element.classList.toggle("selected");
}
function selectedRow(){
var index,
table = document.getElementById("table_to_highlight");
for(var i = 1; i < table.rows.length; i++)
{
//table.rows[i].onclick = function()
//{
// remove the background from the previous selected row
//if(typeof index !== "undefined"){
// table.rows[index].classList.toggle("selected");
//}
//console.log(typeof index);
// get the selected row index
var index = this.rowIndex;
// add class selected to the row
//console.log("message....");
//this.classList.toggle("selected");
//console.log(typeof index);
table.rows[i].classList.toggle("selected");
//};
}
}
function test_checkbox()
{
console.log(" Au total : " + document.querySelectorAll('input[type="checkbox"]').length);
let checkboxes = document.querySelectorAll('input[type="checkbox"]');
console.log(checkboxes);
for(var i=0, n=checkboxes.length;i<n;i++)
{
//checkboxes[i].checked = source.checked;
if (checkboxes[i].checked == true)
{
console.log( i + " " + checkboxes[i] + " OK " );
}
else
{
console.log( i + " " + checkboxes[i] + " No " );
}
}
const checked = document.querySelectorAll('input[type="checkbox"]:checked')
let selected = [];
selected = Array.from(checked).map(x => x.value)
console.log(" +++++ " + selected);
/*var item = document.getElementById("ck1");
if (item.checked == true)
{
console.log(" +++++ " + document.getElementById("ck1").value);
} */
}
function tutu()
{
let checkboxes = document.querySelectorAll('input[type="checkbox"]');
//let nb = checkboxes.length;
selection_elements = [];
for(var i=1 ; i<checkboxes.length ;i++)
{
let numerotation = "CK" + i;
console.log(" ***** " + numerotation);
var obj = document.getElementById(numerotation);
if (obj.checked == true )
{
var contenu = document.getElementById(numerotation).value;
console.log(" Selection ---->>>> " + contenu);
selection_elements.push(contenu);
//console.log("\n");
}
}
/* const jsonContent = JSON.stringify(selection_elements);
const fs = require("fs");
fs.writeFile("./alphabet.json", jsonContent, 'utf8', function (err)
{
if (err)
{
return console.log(err);
}
console.log("The file was saved!");
}); */
/*$.ajax({
url: "titi.php",
type: "POST",
dataType: 'json',
data: JSON.stringify(selection_elements),
success: function(response){}
});
*/
var tab1 = new Array();
tab1.push("champ_date");
tab1.push("champ_valeur");
xmlhttp = new XMLHttpRequest();
var JsonString = JSON.stringify(tab1);
var aze = "+";
//xmlhttp.onreadystatechange = respond;
xmlhttp.open("POST", "titi.php", true);
xmlhttp.send(JsonString);
}
</script>
<?php
/**************************************************************/
$tableau_fichiers = array();
$tableau_repertoires = array();
echo "Display session variables ";
echo "<br>";
var_dump($_SESSION);
echo "<br>";
echo "<br>";
$root_path = $_SERVER['DOCUMENT_ROOT'];
echo " Root path " .$root_path;
echo "<br>";
echo "<br>";
$dirReference = $root_path ."/Fusion";
echo " Reference path" .$dirReference ."<br>";
echo "<br>";
echo "<br>";
/**************************************************************/
// https://unitedwebsoft.in/blog/jqueryajax-file-upload-php
// https://bootstrapfriendly.com/blog/uploading-multiple-files-with-progress-bar-via-ajax-and-php
// https://www.geeksforgeeks.org/how-to-upload-a-file-in-php/?ref=next_article
// https://www.tutorialswebsite.com/uploading-video-with-a-progress-bar-in-php/
// https://www.youtube.com/watch?v=HnTWyfuN_Do
// https://www.codestacked.info/2018/11/ajax-file-upload-with-dynamic-progress-bar.html
// https://www.tutorialswebsite.com/ajax-file-upload-with-progress-bar-using-php-and-jquery/
// https://www.9lessons.info/2012/04/file-upload-progress-bar-with-jquery.html
//https://abdultechhub.com/blog/upload-multiple-files-with-progress-bar-using-ajax-and-php
// https://www.webslesson.info/2018/08/ajax-file-upload-with-progress-bar-using-php-jquery.html
// https://www.sourcecodester.com/tutorial/javascript/16808/file-uploading-progress-bar-using-php-and-javascript-tutorial
// https://berwick.fr/blog/2016/08/26/formulaire-dupload-ajax-jquery-php-avec-barre-de-progression/
// https://www.hackandphp.com/blog/multiple-form-file-uploader-using-jquery-ajax-php-and-bootstrap-progressbar
// https://www.sitepoint.com/tracking-upload-progress-with-php-and-javascript/
// https://www.webslesson.info/2021/07/javascript-multiple-file-upload-progress-bar-with-php.html#google_vignette
// http://www.matlus.com/html5-file-upload-with-progress/
// https://www.simplifiedcoding.net/file-upload-progress-bar-using-php-jquery-form-plugin/
// https://www.binaryintellect.net/articles/859d32c8-945d-4e5d-8c89-775388598f62.aspx
if (isset($_GET['download']))
{
echo " ****** " .$_GET['p'];
// vider le cache ???
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header("Content-Type: application/force-download");
header("Content-Type: application/download");
header('Content-Disposition: attachment; filename="'.basename($_GET['p']).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($_GET['p']));
flush();
readfile($_GET['p']);
//header("location:" . $_SERVER['HTTP_REFERER']);
die();
}
if (isset($_GET['downloadxxxxxx']))
{
echo "<<<<<<< WARNING >>>>>>>>>>>>";
echo "<br><br>";
$tmp = str_replace( "/home/analogde/www" , $_SERVER['SERVER_NAME'] , $_SESSION['dirpath']);
$file_path = "http://" .$tmp ."/" .$_SESSION['selection_fichier'];
echo "Chemin du fichier à télécharger " .$file_path;
echo "<br><br>";
echo "Retour " .$_SESSION['url'];
echo "<br><br>";
echo "<<<<<<< WARNING >>>>>>>>>>>>";
echo "<br><br>";
echo "<<<<<<< WARNING >>>>>>>>>>>>";
echo "<br><br>";
header("Location: pipo.php");
//header("location: index.php");
//header("Location: http://analog-design.net/Fusion/File%20explorer/test_download.php");
// die();
$path_file = "http://analog-design.net/Fusion/upload_file/008/code.html";
echo " >>>>>> Position " .getcwd();
chdir("/home/analogde/www/Fusion/upload_file/008");
echo "<br><br>";
echo " >>>>>> Maintenant" .getcwd();
echo "<br><br>";
$path = getcwd() ."/" ."dependency.php";
echo " -------- " .$path;
if (file_exists("dependency.php"))
{
echo "The file exists";
}else {
echo "The file does not exists";
}
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($path) . '"');
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($path ));
readfile($path);
exit;
/*
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($path).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
flush();
readfile($path);
exit;
*/
//https://analog-design.net/Fusion/File%20explorer/arbo_test011.php?p=http://analog-design.net/Fusion&download=code03.html
/*
echo "<br><br>";
echo "TRACE " .$_SESSION['chemin_fichier'];
echo "<br><br>";
chdir($_SESSION['chemin_fichier']);
//$fichier = $_SESSION['selection_fichier'];
echo ">>>>> " .getcwd();
echo "<br><br>";
if (file_exists($_SESSION['selection_fichier'] ))
{
echo "The file exists";
}else {
echo "The file does not exists";
}
$file = $_SESSION['chemin_fichier'] ."/" .$_SESSION['selection_fichier']; // myfile.json
*/
//probléme car /home/analogde/www il faut analog-design.net/....
// echo " ******** " .$file;
// /home/analogde/www/Fusion/upload_file/005
/*
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
// header('Content-Disposition: attachment; filename="'.basename().'"');
header('Content-Disposition: attachment; filename="'.basename($file_path).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file_path));
flush(); // Flush system output buffer
//readfile($filepath);
readfile($file_path);
die();
// header('Location: ' .$_SESSION['url']);
//header('Location: ' .$_SESSION['url']);
// header("Location: http://www.google.fr/");
//exit;
*/
}
if($_GET['upload'] == "yes")
{
$titi = 5;
echo " Upload des fichiers dans le répertoire : " .$_SESSION['dirpath'];
$tmp = str_replace( "/home/analogde/www", "" , $_SESSION['dirpath']);
echo "<br>";
echo $tmp;
?>
<div id="wrapper">
<div class="path">
<p><b>Uploading files</b></p>
<p class="break-word">Destination folder: </p>
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="p" value="<?php echo $tmp ?>">
<input type="hidden" name="upl" value="1">
<input type="file" name="upload[]"><br>
<input type="file" name="upload[]"><br>
<input type="file" name="upload[]"><br>
<input type="file" name="upload[]"><br>
<input type="file" name="upload[]"><br>
<br>
<p>
<button class="btn"><i class="icon-apply"></i> Upload</button>
<!--
<b><a href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="icon-cancel"></i> Cancel</a></b>
-->
</p>
</form>
</div>
</div>
<?php
}
else
{
if( $refresh == false)
{
echo "MODE NORMAL";
echo "<br>";
echo "<br>";
if (isset($_GET['pipo']))
{
if ($_GET['pipo'] != "..")
{
$dirPath = $_SESSION['dirpath'] ."/" .$_GET['pipo'];
echo "Répertoire courant : " .$_GET['pipo'];
echo "<br>";
echo "<br>";
// descendre dans le répertoire
if( is_dir($dirPath))
{
echo "<br>";
echo " Folder >>>> " . $dirPath;
echo "<br>";
$_SESSION['dirpath'] = $dirPath;
if( $dirReference != $_SESSION['dirpath'] ) //$dirPath )
{
//echo "==> " .$_SESSION['dirpath'] ."<br>";
// on doit rajouter le double point ( retour en arriére)
$obj = new fileObject();
$obj->setName("..");
$obj->setType('folder');
$tableau_repertoires[] = $obj;
}
}
// on va traiter le fichier
else
{
//is_file($dirPath)
$file_path = $_SESSION['dirpath'] ."/" .$_GET['pipo'];
//echo "<br>";
//echo " File ------->>>> " . $file_path;
//echo "<br>";
// analyse($file_path);
}
}
// remonter dans le répertoire parent
else
{
echo "Remonter d'un cran ...";
echo "<br>";
echo "<br>";
echo "Session dirpath " .$_SESSION['dirpath'];
//if(is_dir($_GET['pipo']))
//{
//echo "Zoulou " .$_SESSION['dirpath'] ."<br>";
//echo " <== " .$dirPath ."<br>";
$chunks = explode('/', $_SESSION['dirpath']);
echo "<pre>";
print_r($chunks);
echo "</pre>";
for($i=0; $i< count($chunks)-1 ; $i++)
{
$dirPath .= "/" .$chunks[$i];
}
$dirPath = substr($dirPath, 1);
$_SESSION['dirpath'] = $dirPath;
// securité
if( $_SESSION['dirpath'] == "/home/analogde/www" )
{
$_SESSION['dirpath'] = $dirReference;
echo " Limite la navigation";
echo "<br>";
echo "<br>";
}
echo " ------ " .$_SESSION['dirpath']; //.$dirPath;
echo "<br>";
echo "<br>";
if( $dirReference != $_SESSION['dirpath'] ) //$dirPath )
{
//echo "<== " .$_SESSION['dirpath'] ."<br>";
// on doit rajouter le double point ( retour en arriére)
$obj = new fileObject();
$obj->setName("..");
$obj->setType('folder');
$tableau_repertoires[] = $obj;
}
}
}
else
{
// initialisation
echo "TRACE initialisation ...";
echo "<br>";
echo "<br>";
$dirPath = $root_path ."/Fusion";
$_SESSION['dirpath'] = $dirPath;
//$_SESSION['variable'] = "initialisation";
//echo "Current start " .$_SESSION['dirpath'] ."<br>";
}
}
if( $refresh == true)
{
echo "MODE REFRESH";
echo "<br>";
echo "<br>";
//
if(isset($_GET['typefile']) && $_GET['typefile'] == "folder" )
{
if( $_SESSION['dirpath'] != $dirReference )
{
echo "Ajout parent pour le refresh";
echo "<br>";
echo "<br>";
$obj = new fileObject();
$obj->setName("..");
$obj->setType('folder');
$tableau_repertoires[] = $obj;
}
}
}
$visualisation_flag = false;
if (isset($_GET['typefile']))
{
if( $_GET['typefile'] == "file" )
{
echo "TRACE file ";
echo "<br>";
echo "<br>";
$visualisation_flag = true;
//$str_to_be_replaced = "/home/analogde/www";
//$tmp = str_replace( $str_to_be_replaced, $_SERVER['SERVER_NAME'] , $dirPath);
//$chemin = "http://" .$tmp;
// $_SESSION['dirpath'] ."/" .
$str_to_be_replaced = "/home/analogde/www";
$tmp = str_replace( $str_to_be_replaced, $_SERVER['SERVER_NAME'] , $_SESSION['dirpath']);
$chemin = "http://" .$tmp ."/" .$_GET['pipo'];
echo "Chargement du fichier : " .$chemin;
echo "<br>";
echo "<br>";
echo "<br>";
$ext = strtolower(pathinfo($chemin, PATHINFO_EXTENSION));
echo "<br>";
echo $ext;
echo "<br>";
$mime_type = get_mime_type($chemin);
echo $mime_type;
echo "<br>";
$url = "http://" .$tmp;
$_SESSION['chemin_fichier'] = $_SESSION['dirpath'];
$_SESSION['selection_fichier'] = $_GET['pipo'];
// urlencode($url)
$tmp = str_replace( "/home/analogde/www" , $_SERVER['SERVER_NAME'] , $_SESSION['dirpath']);
$file_path = "http://" .$tmp ."/" .$_SESSION['selection_fichier'];
echo " <<<<<+++++++++>>>> " .$file_path;
?>
<a href="abc.php?path=<?php echo $file_path ?>"> TEST</a>
<b><a href="?p=<?php echo $file_path ?>&download=<?php echo urlencode($_GET['pipo']) ?>">Download</a></b>
<!--
header("Location: abc.php");
exit;
-->
<b><a href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="icon-goback"></i> Back</a></b>
<br>
<br>
<?php
if(in_array($ext, get_office_exts()) )
{
echo " Office element";
echo "<br>";
echo "<br>";
//echo '<iframe src="https://docs.google.com/viewer?embedded=true&hl=en&url=' . $chemin . '" frameborder="no" style="width:100%;min-height:460px"></iframe>';
// OK
//echo ' <div class="viewer doc"> ';
//echo ' <iframe src="//docs.google.com/viewer?embedded=true&url=http://www.snee.com/xml/xslt/sample.doc" width="600" height="780" scrolling="no" style="border: none;">
// </iframe>';
//echo '</div>';
// OK
//echo ' <div class="viewer doc"> ';
//echo ' <iframe src="//docs.google.com/viewer?embedded=true&url=https://analog-design.net/Fusion/Doc2.doc" width="600" height="780" scrolling="no" style="border: none;">
// </iframe>';
//echo '</div>';
$v = "https://analog-design.net/Fusion/Doc2.doc";
?>
<!-- OK
<div class="viewer doc">
<iframe src="//docs.google.com/viewer?embedded=true&url=<?php echo $chemin; ?>" width="600" height="780" scrolling="no" style="border: none;">
</iframe>
</div>
-->
<!-- OK
<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=https://analog-design.net/Fusion/Doc2.doc' width='100%' height='650px' frameborder='0'></iframe>
-->
<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=<?php echo $chemin; ?>' width='100%' height='650px' frameborder='0'></iframe>
<!--
<script >
window.location.reload()
</script>
-->
<?php
//header("Refresh:1");
// window.location.reload()
// $page = $_SERVER['PHP_SELF'];
//echo "Page self " .$page;
//$sec = "1";
// header("Refresh: $sec; url=$page");
/* echo ' <iframe src="//docs.google.com/viewer?embedded=true&url=' .$chemin .' width="600" height="780" scrolling="no" style="border: none;">
</iframe>';*/
}
if($ext == "pdf")
{
$pdfData = displayPdfFromUrl($chemin);
$base64 = base64_encode($pdfData);
echo '<iframe src="data:application/pdf;base64,' .$base64 .' " width="100%" height="600"></iframe>';
}
if(in_array($ext, get_text_exts()) )
{
$content = file_get_contents($chemin); //($file_path);
//echo '<textarea class="numbered" readonly style="resize:none;" rows="4" cols="50" width="400px" height="400px">' . htmlspecialchars($content). '</textarea>';
$hljs_class = 'lang-' . $ext;
$content = '<pre class="with-hljs"><code class="' . $hljs_class . '">' . fm_enc($content) . '</code></pre>';
echo $content;
}
if (in_array($ext, get_image_exts()))
{
$imageData = base64_encode(file_get_contents($chemin)); //$file_path
echo '<img src="data:image/jpeg;base64,'.$imageData.'">';
}
}
}
/**** Répertoire exploré ****/
echo "Search ....... " .$_SESSION['dirpath'] ."<br>";
$tableau_content = array();
$dir = $_SESSION['dirpath']; // $dirPath;
$directories = array();
$files_list = array();
$files = scandir($dir);
foreach($files as $file)
{
if(($file != '.') && ($file != '..'))
{
$obj = new fileObject();
$obj->setName($file);
if(is_dir($dir.'/'.$file))
{
$directories[] = $file;
$obj->setType('folder');
$obj->setExtension("None");
$tableau_repertoires[] = $obj;
//echo " ---- " .$file . " folder" ."<br>";
}
else
{
$files_list[] = $file;
$obj->setType('file');
$tableau_fichiers[] = $obj;
$obj->setSize( get_filesize(filesize( $_SESSION['dirpath'] ."/" .$file)) );
$extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
$obj->setExtension($extension);
}
$tableau_content[] = $obj;
}
}
$tableau_concatenate = array_merge( $tableau_repertoires, $tableau_fichiers);
define('FM_PATH', $_SESSION['dirpath']);
/*
echo '<a title="Upload files" href="?p=<?php echo urlencode(FM_PATH) ?>&upload"></a>';
*/
echo "8888888888888888888888888888";
echo "<br>";
// echo $_SESSION['dirpath'];
$pipo = "https://analog-design.net/Fusion/File%20explorer?p=coco/";
//echo '<a title="Upload" href="https://www.w3schools.com/">Visit W3Schools.com!</a>';
echo '<a title="Upload" href="https://analog-design.net">Visit W3Schools.com!</a>';
echo "<br>";
//
echo '<a title="Click to visit the Microsoft website" target="_blank" href="https://microsoft.com">Microsoft</a>';
echo "<br>";
$str_to_be_replaced = "/home/analogde/www";
$tmp = str_replace( $str_to_be_replaced, $_SERVER['SERVER_NAME'] , $_SESSION['dirpath']);
$chemin = "http://" .$tmp ;
echo $_SERVER['SERVER_NAME'] . " " .$_SESSION['dirpath'] ." " .$tmp;
echo "<br>";
echo " --> " .$chemin;
echo "<br>";
echo '<a title="Blablasdfsfsd" href=<?php echo $tmp ?> Zoulou ohoh </a>';
echo "<br>";
// echo basename($_SERVER['REQUEST_URI']);
echo "<br>";
// echo " ++++ " .$_SERVER['QUERY_STRING'];
echo "<br>";
// echo " ---- " .$_SERVER['HTTP_HOST'];
echo "<br>";
// echo " ---- " .$_SERVER['HTTPS'];
echo "<br>";
echo "<br>";
echo "<br>";
//echo '<pre>';
//print_r($_SERVER);
//echo '</pre>';
echo "<br>";
echo "<br>";
echo "<br>";
echo " ---- " .$_SERVER['REQUEST_URI'];
echo "<br";
$chemin = $_SERVER['SERVER_NAME'] .$_SERVER['REQUEST_URI'];
$_SESSION['url'] = $_SERVER['SERVER_NAME'] .$_SERVER['REQUEST_URI'];
echo "<br>";
echo " ***********>>>>>>>>>> " .$_SESSION['url'];
echo "<br>";
$chemin = $_SERVER['REQUEST_URI'];
echo "<br>";
echo " ***********> " .$chemin;
echo "<br>";
define('FM_PATH', $chemin);
// construire l'url
// il faut transmettre la fin du chemin
// http://analog-design.net/Fusion/Charts/js
$v = $chemin ."?p=upload&path=" .$chemin;
echo " v " .$v;
//on rajoute pour chaque refresh p=upload
//sinon on envoie sur une autre page et on transmet les infos ou paramétres pour éviter la répétition
// $v = "https://www.google.fr";
?>
<!--
<a title="Upload files" href="?p=<?php echo urlencode(FM_PATH) ?>&upload"><i class="icon-upload"></i></a>
-->
<!--
analog-design.net/Fusion/File%20explorer/arbo_test09.php
-->
<!-- OK
<a title="Upload files" target="_blank" href="<?php echo $chemin ?>?p=upload" > blase </a>
-->
<a title="Upload files" target="_blank" href="<?php echo $v ?> "> blase </a>
<?php
$blase ="wwwwwwwww";
$url = "https://analog-design.net/Fusion/File%20explorer/arbo_test09.php?zorro=555";
echo "<img src=\"upload_icon.png\" width='48' height='48' ><a href=\"$file_name?pipo=$blase&typefile=$typeFile&upload=yes\">$blase</a>";
/*if(isset( $_SESSION['variable'] ) && !empty($_SESSION['variable']) )
{
unset($_SESSION['variable']);
echo "Effacement variable";
echo "<br>";
echo "<br>";
}*/
//echo "<pre>";
//echo var_dump($tableau_concatenate);
//echo "<pre>";
if( $visualisation_flag == false )
{
echo "<table id='table_to_highlight' border=1 cellpadding=5 cellspacing=0 class=whitelinks>";
// la classe bloque les highlight sur la ligne des titres (header)
echo "<tr class='blankcell'>";
echo "<th><input type='checkbox' onclick='toggle(this);'></th>";
echo "<th>Filename</th>";
echo "<th>Filetype</th><th>Filesize</th>";
echo "</tr>";
for($index=0; $index < count($tableau_concatenate); $index++)
{
//if (substr("$dirArray[$index]", 0, 1) != ".")
//{ // don't list hidden files
//print("<TR><TD><a href=\"$dirArray[$index]\">$dirArray[$index]</a></td>");
// il faut faire la différence entre un répertoire et un fichier !!!
$numerotation = $index + 1;
$champ = "CK" .$numerotation;
$blase = $tableau_concatenate[$index]->getName();
//$blase = $blase . " +++ ";
echo " <tr onclick='plouf(this)'>";
echo "<td>";
echo "<input type='checkbox' id='$champ' value = '$blase' >";
// onclick='abc()'
echo "</td>";
$typeFile = $tableau_concatenate[$index]->getType();
if( $typeFile == "folder")
{
$icon = "folder-icon.png";
}
if( $typeFile == "file")
{
$ext = $tableau_concatenate[$index]->getExtension();
if( $ext == "docx")
{
$icon = "docx-icon.png";
}
else if( $ext == "pptx")
{
$icon = "pptx-icon.png";
}
else if( $ext == "xlsx")
{
$icon = "xlsx-icon.png";
}
else if( $ext == "pdf")
{
$icon = "pdf-icon.png";
}
else if( $ext == "gif" )
{
$icon = "gif-icon.png";
}
else if( $ext == "bmp" )
{
$icon = "bmp-icon.png";
}
else if( $ext == "png" )
{
$icon = "png-icon.png";
}
else if( $ext == "jpg" || $ext == "jpeg" )
{
$icon = "jpg-icon.png";
}
else if( $ext == "html" || $ext == "htm" )
{
$icon = "html-icon.png";
}
else if( $ext == "php" )
{
$icon = "php-icon.png";
}
else if( $ext == "css" )
{
$icon = "css-icon.png";
}
else if( $ext == "js" )
{
$icon = "javascript-icon.png";
}
else if( $ext == "py" )
{
$icon = "python-icon.png";
}
else if( $ext == "zip" )
{
$icon = "zip-icon.png";
}
// par défaut
else
{
$icon = "text-icon.png";
}
}
$file_name = basename($_SERVER['PHP_SELF']);
echo "<td>";
echo "<div class=\"aligned\">";
//echo "<img src=\"folder-icon.png\" width='24' height='24'><a href=\"arbo_test05.php?pipo=$blase&typefile=$typeFile\">$blase</a>";
//echo "<img src=\"$icon\" width='24' height='24'><a href=\"arbo_test06.php?pipo=$blase&typefile=$typeFile\">$blase</a>";
echo "<img src=\"$icon\" width='24' height='24'><a href=\"$file_name?pipo=$blase&typefile=$typeFile\">$blase</a>";
//$filelink = '?p=' . urlencode(FM_PATH) . '&view=' . urlencode($f);
echo "</div>";
echo "</td>";
echo "<td>";
echo $tableau_concatenate[$index]->getType();
echo "</td>";
if( $tableau_concatenate[$index]->getName() != "..")
{
print("<td>");
echo $tableau_concatenate[$index]->getSize();
print("</td>");
}
else
{
echo "<td>";
echo "";
echo "</td>";
}
echo "</tr>";
}
echo "</table>\n";
echo "<br>";
echo "<br>";
echo "<input type='button' id='btn_selection' onclick='test_checkbox()' value='Validation'>";
echo "<br>";
echo "<br>";
echo "<input type='button' id='test' onclick='tutu()' value='Check'>";
}
}
function get_filesize($size)
{
if ($size < 1000) {
return sprintf('%s B', $size);
} elseif (($size / 1024) < 1000) {
return sprintf('%s KiB', round(($size / 1024), 2));
} elseif (($size / 1024 / 1024) < 1000) {
return sprintf('%s MiB', round(($size / 1024 / 1024), 2));
} elseif (($size / 1024 / 1024 / 1024) < 1000) {
return sprintf('%s GiB', round(($size / 1024 / 1024 / 1024), 2));
} else {
return sprintf('%s TiB', round(($size / 1024 / 1024 / 1024 / 1024), 2));
}
}
function removeLastDir($path, $level)
{
if (is_int($level) && $level > 0) {
$path = preg_replace('#\/[^/]*$#', '', $path);
return $this->removeLastDir($path, (int)$level - 1);
}
return $path;
}
function analyse($file_path)
{
$ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
echo "<br>";
echo $ext;
echo "<br>";
$mime_type = get_mime_type($file_path);
echo $mime_type;
echo "<br>";
$is_zip = false;
$is_image = false;
$is_audio = false;
$is_video = false;
$is_text = false;
if (in_array($ext, get_image_exts()))
{
$is_image = true;
$view_title = 'Image';
echo $is_image ." " .$view_title;
//$image = 'http://www.google.com/doodle4google/images/d4g_logo_global.jpg';
$imageData = base64_encode(file_get_contents($file_path));
echo '<img src="data:image/jpeg;base64,'.$imageData.'">';
// header('Content-type: image/jpeg');
//echo file_get_contents($file_path);
//header('Content-Type: image/jpeg');
//readfile($file_path);
}
if(in_array($ext, get_text_exts()) ) //|| substr($mime_type, 0, 4) == 'text' || in_array($mime_type, fm_get_text_mimes())) {
{ $is_text = true;
$content = file_get_contents($file_path);
echo '<textarea class="numbered" readonly style="resize:none;" rows="4" cols="50" width="400px" height="400px">' . htmlspecialchars($content). '</textarea>';
$content = '<pre class="with-hljs"><code class="' . $hljs_class . '">' . $content . '</code></pre>';
echo $content;
}
footer();
exit();
}
function get_mime_type($file_path)
{
if (function_exists('finfo_open'))
{
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $file_path);
finfo_close($finfo);
return $mime;
}
elseif (function_exists('mime_content_type'))
{
return mime_content_type($file_path);
}
elseif (!stristr(ini_get('disable_functions'), 'shell_exec'))
{
$file = escapeshellarg($file_path);
$mime = shell_exec('file -bi ' . $file);
return $mime;
}
else
{
return '--';
}
}
function get_image_exts()
{
return array('ico', 'gif', 'jpg', 'jpeg', 'jpc', 'jp2', 'jpx', 'xbm', 'wbmp', 'png', 'bmp', 'tif', 'tiff', 'psd');
}
function get_text_exts()
{
return array(
'txt', 'css', 'ini', 'conf', 'log', 'htaccess', 'passwd', 'ftpquota', 'sql', 'js', 'json', 'sh', 'config',
'php', 'php4', 'php5', 'phps', 'phtml', 'htm', 'html', 'shtml', 'xhtml', 'xml', 'xsl', 'm3u', 'm3u8', 'pls', 'cue',
'eml', 'msg', 'csv', 'bat', 'twig', 'tpl', 'md', 'gitignore', 'less', 'sass', 'scss', 'c', 'cpp', 'cs', 'py',
'map', 'lock', 'dtd', 'svg',
);
}
function get_office_exts()
{
return array( 'doc', 'docx', 'xls', 'xlsx', "ppt", "pptx" );
}
function displayPdfFromUrl($url) {
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute cURL request
$data = curl_exec($ch);
// Close cURL session
curl_close($ch);
// Return PDF file content
return $data;
}
function footer()
{
?>
<p class="center"><small><a href="https://github.com/alexantr/filemanager" target="_blank">PHP File Manager</a></small></p>
</div>
<?php
}
function fm_enc($text)
{
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Patoche</title>
<style>
code,pre{display:block;margin-bottom:10px;font:13px/16px Consolas,'Courier New',Courier,monospace;border:1px dashed #ccc;padding:5px;overflow:auto}
pre.with-hljs{padding:0}
pre.with-hljs code{margin:0;border:0;overflow:visible}
</style>
</head>
<body>
<div id="wrapper">
</body>
</html>