J'ai ajouté un bouton déconnect,
les pages respawnées se chargent dans une iframe pour conserver un accès
vers l'index (en plus ça fait joli, la barre de titre est réduite dans
ce mode)
j'ai supprimé le bouton 'supprimer une page' dans le mode public (même
si son effet était déjà  inhibé dans le code) ainsi que le bouton
bookmarklet
Les noms des fichiers zippés sont désormais plus explicites.
This commit is contained in:
Bronco 2013-06-25 12:05:16 +02:00
parent 35ecb370ef
commit ea6f226da8
6 changed files with 117 additions and 76 deletions

View file

@ -11,7 +11,7 @@ a:hover { color: #050;text-shadow:0 0 5px green;}
a { color: black; text-decoration: none;}
input{outline:none;-moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; height:25px;padding : 3px ; vertical-align: bottom; margin-top : 3px ;}
input[type=text]{width:80%;min-width:200px; background-color:rgba(255,255,255,0.8);border:1px solid #444;border-top-color:#333;border-bottom-color:#aaa; -moz-box-shadow: inset 0 1px 3px #000000; -webkit-box-shadow: inset 0 1px 3px #000000; box-shadow: inset 0 1px 3px #000000; #000}
input[type=text]{width:80%;min-width:200px; background-color:rgba(255,255,255,0.8);border:1px solid #444;border-top-color:#333;border-bottom-color:#aaa; -moz-box-shadow: inset 0 1px 3px #000000; -webkit-box-shadow: inset 0 1px 3px #000000; box-shadow: inset 0 1px 3px #000000; }
input[type=text]:hover{background-color:rgba(200,255,200,0.8);-moz-box-shadow: inset 0 1px 3px #040; -webkit-box-shadow: inset 0 1px 3px #040; box-shadow: inset 0 1px 3px #040; }
input[type=text]:focus{background-color:rgba(200,255,200,0.9);-moz-box-shadow: inset 0 0 3px #040; -webkit-box-shadow: inset 0 0 3px #040; box-shadow: inset 0 0 3px #040; }
input[type=submit]{cursor: pointer; border:1px solid #494;border-bottom-color:#272;border-top-color:#afa; background-color:rgba(0,200,0,0.8); -moz-box-shadow: 0 1px 2px #080; -webkit-box-shadow: 0 1px 2px #080; box-shadow: 0 1px 2px #080; -ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=2, Direction=135, Color='#000')"; filter: progid:DXImageTransform.Microsoft.Shadow(Strength=2, Direction=135, Color='#000'); }
@ -19,6 +19,7 @@ input[type=submit]:hover{ background-color:rgba(0,255,0,0.8);}
input[type=submit]:active{border-color:black; background-color:rgba(0,255,0,0.8);}
#____q{margin-top:20px;}
header{
-webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
border-bottom:1px solid #222;
-moz-box-shadow: 0 1px 3px #888; -webkit-box-shadow: 0 1px 3px #888; box-shadow: 0 1px 3px #888; -ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=2, Direction=135, Color='#888')"; filter: progid:DXImageTransform.Microsoft.Shadow(Strength=2, Direction=135, Color='#888');
@ -31,7 +32,11 @@ header{
header nav{display:inline-block; vertical-align: top;}
header nav p{color:lightgreen;text-shadow: 0 1px 1px black;font-size:20px;}
aside{height:100%;padding-bottom : 70px;text-align:center;}
aside iframe{height:100%;border:none;}
aside ul{padding:0;}
aside li{margin:5px;list-style:none;vertical-align:middle;border-radius:3px;}
aside .public li{background:rgba(100,255,100,0.2);}
@ -55,3 +60,10 @@ footer {text-align: right; color:#F80;text-shadow: 0 1px 1px black; position:fix
footer a {color:lightgreen;text-shadow:0 1px 1px green;}
footer a:hover {color:white;}
body.iframe aside{padding-bottom:0!important;}
body.iframe header {padding:2px;vertical-align: top;}
body.iframe header img{width:32px;height:auto;}
body.iframe header input{vertical-align: top;}
body.iframe header #____q{margin-top:2px;}
body.iframe header nav{margin-top:2px;display:inline-block; vertical-align: top;}
body.iframe header nav p{margin:0;padding:0;}

179
index.php
View file

@ -1,5 +1,11 @@
<?php
if (isset($_GET['public'])){$public=true;}else{$public=false;include 'auto_restrict.php';}
if (isset($_GET['public'])){$public=true;$bodyclass='publicpage';}else{$bodyclass='';$public=false;include 'auto_restrict.php';}
function aff($a,$stop=true){echo 'Arret a la ligne '.__LINE__.' du fichier '.__FILE__.'<pre>';var_dump($a);echo '</pre>';if ($stop){exit();}}
function BodyClasses($add=''){$regex='#(msie)[/ ]([0-9])+|(firefox)/([0-9])+|(chrome)/([0-9])+|(opera)/([0-9]+)|(safari)/([0-9]+)|(android)|(iphone)|(ipad)|(blackberry)|(Windows Phone)|(symbian)|(mobile)|(bada])#i';@preg_match($regex,$_SERVER['HTTP_USER_AGENT'],$resultat);return ' class="'.$add.' '.@preg_replace('#([a-zA-Z ]+)[ /]([0-9]+)#','$1 $1$2',$resultat[0]).' '.basename($_SERVER['PHP_SELF'],'.php').'" ';}
function title2filename($chaine){$a=array(' ',':','|','#','/','\\','$','*','?','&','<','>');return substr(stripAccents(str_replace($a,'_',$chaine)),0,30);}
function stripAccents($string){ $a=explode(' ','à á â ã ä ç è é ê ë ì í î ï ñ ò ó ô õ ö ù ú û ü ý ÿ À Á Â Ã Ä Ç È É Ê Ë Ì Í Î Ï Ñ Ò Ó Ô Õ Ö Ù Ú Û Ü Ý');$b=explode(' ','a a a a a c e e e e i i i i n o o o o o u u u u y y A A A A A C E E E E I I I I N O O O O O U U U U Y');return str_replace($a,$b,$string);}
if(isset($_GET['publicget'])||isset($_GET['privateget'])){$bodyclass.=' iframe';}
$bodyclass=bodyclasses($bodyclass);$target='';
/* (webpage retriever by Timo Van Neerden; http://lehollandaisvolant.net/contact December 2012)
* last updated : December, 10th, 2012
@ -29,7 +35,7 @@ $GLOBALS['data_folder'] = 'mypersonaldata';
$GLOBALS['private_data_folder'] = $GLOBALS['data_folder'].'/private';
$GLOBALS['public_data_folder'] = $GLOBALS['data_folder'].'/public';
$GLOBALS['default_data_folder'] = $GLOBALS['public_data_folder'];
$GLOBAL['version']='1.0';
$GLOBAL['version']='1.2';
$GLOBALS['message'] = 'Votre webliothèque perso';
$GLOBALS['public_title'] = 'Voici la webliothèque publique de Bronco';
$bookmarklet='<a title="Drag this link to your shortcut bar" href=\'javascript:javascript:(function(){var url = location.href;window.open("http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'].'?q="+ encodeURIComponent(url),"_blank","menubar=yes,height=600,width=1000,toolbar=yes,scrollbars=yes,status=yes");})();\' >Bookmarklet</a>';
@ -227,7 +233,8 @@ if (!$public){
$info .= 'DATE="'.time().'"'."\n";
file_put_contents($GLOBALS['target_folder'].'/'.'index.ini', $info);
$GLOBALS['done']['d'] = 'ajout';
$GLOBALS['done']['lien'] = $GLOBALS['target_folder'].'/';
$GLOBALS['done']['lien'] = $GLOBALS['target_folder'].'/';
}
}//die;
@ -270,34 +277,49 @@ if (!$public){
header("location: index.php");
}
}
// disconnect
if (isset($_GET['discotime'])){log_user('disco','');}
if (isset($_GET['zipprivate'])) {
if (isset($_GET['privateget'])&&is_dir($GLOBALS['private_data_folder'].'/'.$_GET['privateget'])){$target=$GLOBALS['private_data_folder'].'/'.$_GET['privateget'];}
$zip_filename=$GLOBALS['data_folder'].'/zipversions/'.$_GET['zipprivate'].'.zip';
if (is_file($zip_filename)){header("location: $zip_filename");exit();}
if (is_dir($GLOBALS['private_data_folder'].'/'.$_GET['zipprivate'])){
include 'zip.php';
zip($_GET['zipprivate'].'.zip',$GLOBALS['private_data_folder'].'/'.$_GET['zipprivate'],$GLOBALS['data_folder'].'/zipversions/');
header("location: $zip_filename");
if (isset($_GET['zipprivate'])) {
$ini_file = $GLOBALS['private_data_folder'].'/'.$_GET['zipprivate'].'/index.ini';
if(is_file($ini_file)){$info=parse_ini_file($ini_file);}else{$info['TITLE']='';}
$origin_folder_path=$GLOBALS['private_data_folder'].'/'.$_GET['zipprivate'];
$zip_foldername=title2filename($info['TITLE']).'-'.$_GET['zipprivate'];
$zip_filename=$zip_foldername.'.zip';
$zip_completepath=$GLOBALS['data_folder'].'/zipversions/'.$zip_filename;
if (is_file($zip_completepath)){header("location: $zip_completepath");exit();}// il existe déjà, on envoie
if (is_dir($origin_folder_path)){// sinon on crée le zip si le dossier existe
include 'zip.php';
rename ($origin_folder_path,$zip_foldername); // on le déplace pour éviter de voir la structure de dossiers apparaître dans le zip
zip($zip_filename,$zip_foldername,$GLOBALS['data_folder'].'/zipversions/');
rename ($zip_foldername,$origin_folder_path); // on le remet à sa place
header('location: '.$GLOBALS['data_folder'].'/zipversions/'.$zip_filename);
}
}
}
// public get
//download public zip version
if (isset($_GET['zippublic'])) {
$zip_filename=$GLOBALS['data_folder'].'/zipversions/'.$_GET['zippublic'].'.zip';
if (is_file($zip_filename)){header("location: $zip_filename");exit();}
if (is_dir($GLOBALS['public_data_folder'].'/'.$_GET['zippublic'])){
include 'zip.php';
rename ($GLOBALS['public_data_folder'].'/'.$_GET['zippublic'],$_GET['zippublic']); // on le déplace pour éviter de voir la structure de dossiers apparaître dans le zip
zip($_GET['zippublic'].'.zip',$_GET['zippublic'],$GLOBALS['data_folder'].'/zipversions/');
rename ($_GET['zippublic'],$GLOBALS['public_data_folder'].'/'.$_GET['zippublic']); // on le remet à sa place
header("location: $zip_filename");
$ini_file = $GLOBALS['public_data_folder'].'/'.$_GET['zippublic'].'/index.ini';
if(is_file($ini_file)){$info=parse_ini_file($ini_file);}else{$info['TITLE']='';}
$origin_folder_path=$GLOBALS['public_data_folder'].'/'.$_GET['zippublic'];
$zip_foldername=title2filename($info['TITLE']).'-'.$_GET['zippublic'];
$zip_filename=$zip_foldername.'.zip';
$zip_completepath=$GLOBALS['data_folder'].'/zipversions/'.$zip_filename;
if (is_file($zip_completepath)){header("location: $zip_completepath");exit();}// il existe déjà, on envoie
if (is_dir($origin_folder_path)){// sinon on crée le zip si le dossier existe
include 'zip.php';
rename ($origin_folder_path,$zip_foldername); // on le déplace pour éviter de voir la structure de dossiers apparaître dans le zip
zip($zip_filename,$zip_foldername,$GLOBALS['data_folder'].'/zipversions/');
rename ($zip_foldername,$origin_folder_path); // on le remet à sa place
header('location: '.$GLOBALS['data_folder'].'/zipversions/'.$zip_filename);
}
}
if (isset($_GET['publicget'])&&is_dir($GLOBALS['public_data_folder'].'/'.$_GET['publicget'])){$target=$GLOBALS['public_data_folder'].'/'.$_GET['publicget'];}
@ -558,7 +580,7 @@ if ($GLOBALS['done']['d'] !== FALSE) {
<!--[if IE]><script> document.createElement("article");document.createElement("aside");document.createElement("section");document.createElement("footer");</script> <![endif]-->
</head>
<body>
<body <?php echo $bodyclass;?>>
<header><a href="<?php echo $_SERVER['PHP_SELF'];?>"><img src="design/logo2.png"/></a>
<nav id="orpx_nav-bar">
<?php
@ -573,67 +595,38 @@ if ($GLOBALS['done']['d'] !== FALSE) {
</header>
<aside>
<?php
if (!$public){
if (isset($_GET['done']) and $_GET['done'] !== FALSE) {
echo '<div id="new-link">'."\n";
switch($_GET['done']) {
case 'ajout' :
echo "\t".'<a target="_blanc" href="'.urldecode($_GET['loclink']).'">Retrieved page</a> - (<a href="'.htmlspecialchars(urldecode($_GET['lien'])).'">orig. page</a>)' ."\n";
break;
if (!empty($target)){
echo '<iframe src="'.$target.'" width="100%"></iframe>';
}else{
if (!$public){
if (isset($_GET['done']) and $_GET['done'] !== FALSE) {
echo '<div id="new-link">'."\n";
switch($_GET['done']) {
case 'ajout' :
echo "\t".'<a target="_blank" href="'.urldecode($_GET['loclink']).'">Retrieved page</a> - (<a href="'.htmlspecialchars(urldecode($_GET['lien'])).'">orig. page</a>)' ."\n";
break;
case 'remove' :
echo "\t".'Page removed'."\n";
break;
}
echo '</div>'."\n";
}
}
// public pages
echo '<div class="public" style="'.$column_width.'">'."\n";
$liste_pages = scandir($GLOBALS['public_data_folder']);
if ( ($nb = count($liste_pages)) != 0 ) {
echo '<ul id="liste-pages-sauvees">'."\n";
for ($i = 0 ; $i < $nb ; $i++) {
// dont list '.' and '..' folders.
if (is_dir($GLOBALS['public_data_folder'].'/'.$liste_pages[$i]) and ($liste_pages[$i] != '.') and ($liste_pages[$i] != '..')) {
// each folder should contain such a file "index.ini".
$ini_file = $GLOBALS['public_data_folder'].'/'.$liste_pages[$i].'/index.ini';
$favicon = glob($GLOBALS['public_data_folder'].'/'.$liste_pages[$i].'/*favicon.*');
$favicon = (isset($favicon[0])) ? $favicon[0] : '';
if ( is_file($ini_file) and is_readable($ini_file) ) {
$infos = parse_ini_file($ini_file);
} else {
$infos = FALSE;
case 'remove' :
echo "\t".'Page removed'."\n";
break;
}
if (FALSE !== $infos) {
$titre = $infos['TITLE']; $url = $infos['URL']; $date = date('d/m/Y, H:i:s', $infos['DATE']);
} else {
$titre = 'titre'; $url = '#'; $date = 'date inconnue';
}
echo "\t".'<li><a class="suppr" onclick="return window.confirm(\'Sure to remove?\')" href="?suppr='.$GLOBALS['public_data_folder'].'/'.$liste_pages[$i].'" title="suppr"> </a><a class="zip" href="?zippublic='.$liste_pages[$i].'" title="Download zip version"> </a><a class="origine" href="'.$url.'" title="origin"> </a> - <a href="'.$GLOBALS['public_data_folder'].'/'.$liste_pages[$i].'"><img src="'.$favicon.'"/>'.$titre.'</a> <em> ['.$date.']</em>';
if (!$public){echo '<a href="?toprivate='.$liste_pages[$i].'" class="toprivate" title="Change to private">&#9654;</a></li>'."\n";}else{echo "</li>\n";}
echo '</div>'."\n";
}
}
echo '</ul>'."\n";
}
echo '</div>'."\n";
if (!$public){ // don't list private pages
echo '<div class="private" style="'.$column_width.'">'."\n";
$liste_pages = scandir($GLOBALS['private_data_folder']);
// public pages
echo '<div class="public" style="'.$column_width.'">'."\n";
$liste_pages = scandir($GLOBALS['public_data_folder']);
if ( ($nb = count($liste_pages)) != 0 ) {
echo '<ul id="liste-pages-sauvees">'."\n";
for ($i = 0 ; $i < $nb ; $i++) {
// dont list '.' and '..' folders.
if (is_dir($GLOBALS['private_data_folder'].'/'.$liste_pages[$i]) and ($liste_pages[$i] != '.') and ($liste_pages[$i] != '..')) {
if (is_dir($GLOBALS['public_data_folder'].'/'.$liste_pages[$i]) and ($liste_pages[$i] != '.') and ($liste_pages[$i] != '..')) {
// each folder should contain such a file "index.ini".
$ini_file = $GLOBALS['private_data_folder'].'/'.$liste_pages[$i].'/index.ini';
$favicon=glob($GLOBALS['private_data_folder'].'/'.$liste_pages[$i].'/*favicon.*');
$ini_file = $GLOBALS['public_data_folder'].'/'.$liste_pages[$i].'/index.ini';
$favicon = glob($GLOBALS['public_data_folder'].'/'.$liste_pages[$i].'/*favicon.*');
$favicon = (isset($favicon[0])) ? $favicon[0] : '';
if ( is_file($ini_file) and is_readable($ini_file) ) {
$infos = parse_ini_file($ini_file);
@ -645,18 +638,54 @@ if ($GLOBALS['done']['d'] !== FALSE) {
} else {
$titre = 'titre'; $url = '#'; $date = 'date inconnue';
}
echo "\t".'<li><a class="suppr" onclick="return window.confirm(\'Sure to remove?\')" href="?suppr='.$GLOBALS['private_data_folder'].'/'.$liste_pages[$i].'" title="suppr"> </a><a class="zip" href="?zipprivate='.$liste_pages[$i].'" title="Download zip version"> </a><a class="origine" href="'.$url.'" title="origin"> </a> - <a href="'.$GLOBALS['private_data_folder'].'/'.$liste_pages[$i].'"><img src="'.$favicon.'"/>'.$titre.'</a> <em> ['.$date.']</em><a href="?topublic='.$liste_pages[$i].'" class="topublic" title="Change to public">&#9664;</a></li>'."\n";
echo "\t".'<li>';
if (!$public){echo '<a class="suppr" onclick="return window.confirm(\'Sure to remove?\')" href="?suppr='.$GLOBALS['public_data_folder'].'/'.$liste_pages[$i].'" title="suppr"> </a>';}
echo '<a class="zip" href="?zippublic='.$liste_pages[$i].'" title="Download zip version"> </a><a class="origine" href="'.$url.'" title="origin"> </a> - <a href="?publicget='.$liste_pages[$i].'"><img src="'.$favicon.'"/>'.$titre.'</a> <em> ['.$date.']</em>';
if (!$public){echo '<a href="?toprivate='.$liste_pages[$i].'" class="toprivate" title="Change to private">&#9654;</a></li>'."\n";}else{echo "</li>\n";}
}
}
echo '</ul>'."\n";
}
echo '</div>'."\n";
if (!$public){ // don't list private pages
echo '<div class="private" style="'.$column_width.'">'."\n";
$liste_pages = scandir($GLOBALS['private_data_folder']);
if ( ($nb = count($liste_pages)) != 0 ) {
echo '<ul id="liste-pages-sauvees">'."\n";
for ($i = 0 ; $i < $nb ; $i++) {
// dont list '.' and '..' folders.
if (is_dir($GLOBALS['private_data_folder'].'/'.$liste_pages[$i]) and ($liste_pages[$i] != '.') and ($liste_pages[$i] != '..')) {
// each folder should contain such a file "index.ini".
$ini_file = $GLOBALS['private_data_folder'].'/'.$liste_pages[$i].'/index.ini';
$favicon=glob($GLOBALS['private_data_folder'].'/'.$liste_pages[$i].'/*favicon.*');
$favicon = (isset($favicon[0])) ? $favicon[0] : '';
if ( is_file($ini_file) and is_readable($ini_file) ) {
$infos = parse_ini_file($ini_file);
} else {
$infos = FALSE;
}
if (FALSE !== $infos) {
$titre = $infos['TITLE']; $url = $infos['URL']; $date = date('d/m/Y, H:i:s', $infos['DATE']);
} else {
$titre = 'titre'; $url = '#'; $date = 'date inconnue';
}
echo "\t".'<li><a class="suppr" onclick="return window.confirm(\'Sure to remove?\')" href="?suppr='.$GLOBALS['private_data_folder'].'/'.$liste_pages[$i].'" title="suppr"> </a><a class="zip" href="?zipprivate='.$liste_pages[$i].'" title="Download zip version"> </a><a class="origine" href="'.$url.'" title="origin"> </a> - <a href="?privateget='.$liste_pages[$i].'"><img src="'.$favicon.'"/>'.$titre.'</a> <em> ['.$date.']</em><a href="?topublic='.$liste_pages[$i].'" class="topublic" title="Change to public">&#9664;</a></li>'."\n";
}
}
echo '</ul>'."\n";
}
echo '</div>'."\n";
}
}
?>
</aside>
<footer>
<p style='float:left'>
<?php echo $bookmarklet; ?></p><p><a title='from TiMo' href='http://lehollandaisvolant.net/index.php?mode=links&id=20121211195941'>Respawn</a> (bronco edition v<?php echo $GLOBAL['version'];?>) - <?php $GLOBALS['message'];?> - <a href='?public'>Public page link</a>
<?php if (!$public){echo '<a href="?discotime">Disconnect</a>';}?>
<?php if (!$public){echo $bookmarklet;} ?></p><p><a title='from TiMo' href='http://lehollandaisvolant.net/index.php?mode=links&id=20121211195941'>Respawn</a> (bronco edition v<?php echo $GLOBAL['version'];?>) - <?php $GLOBALS['message'];?> - <a href='?public'>Public page link</a>
<script id='flattrbtn'>(function(i){var f,s=document.getElementById(i);f=document.createElement('iframe');f.src='//api.flattr.com/button/view/?uid=Broncowdd&button=compact&url='+encodeURIComponent(document.URL);f.title='Flattr';f.height=20;f.width=110;f.style.borderWidth=0;s.parentNode.insertBefore(f,s);})('flattrbtn');</script>
</p>
</footer>

View file

View file

View file

View file