Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
de5cb8f122 | |||
8b39a207db | |||
6185cbeeaf | |||
f23d8631f9 | |||
584fc5a7e2 | |||
fc4fbf4938 |
8
.gitignore
vendored
|
@ -213,3 +213,11 @@ pip-log.txt
|
|||
|
||||
#Mr Developer
|
||||
.mr.developer.cfg
|
||||
mypersonaldata/private/
|
||||
!mypersonaldata/private/index.html
|
||||
mypersonaldata/public/
|
||||
!mypersonaldata/public/index.html
|
||||
mypersonaldata/zipversions/
|
||||
!mypersonaldata/zipversions/index.html
|
||||
pass.php
|
||||
user_config.php
|
|
@ -1,185 +1,185 @@
|
|||
<?php
|
||||
/**
|
||||
* @author bronco@warriordudimanche.com / www.warriordudimanche.net
|
||||
* @copyright open source and free to adapt (keep me aware !)
|
||||
* @version 2.0
|
||||
*
|
||||
* Verrouille l'accès à une page
|
||||
* Il suffit d'inclure ce fichier pour bloquer l'accès
|
||||
* il gère seul l'expiration de session, la connexion,
|
||||
* la déconnexion.
|
||||
*
|
||||
* Améliorations eventuelles:
|
||||
* ajouter compteur de tentatives sur ban id.
|
||||
* ajouter la sécurisation du $_POST (en cas d'usage d'une base de donnees)
|
||||
*
|
||||
*/
|
||||
session_start();
|
||||
/**
|
||||
* @author bronco@warriordudimanche.com / www.warriordudimanche.net
|
||||
* @copyright open source and free to adapt (keep me aware !)
|
||||
* @version 2.0
|
||||
*
|
||||
* Verrouille l'accès à une page
|
||||
* Il suffit d'inclure ce fichier pour bloquer l'accès
|
||||
* il gère seul l'expiration de session, la connexion,
|
||||
* la déconnexion.
|
||||
*
|
||||
* Améliorations eventuelles:
|
||||
* ajouter compteur de tentatives sur ban id.
|
||||
* ajouter la sécurisation du $_POST (en cas d'usage d'une base de donnees)
|
||||
*
|
||||
*/
|
||||
session_start();
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// configuration
|
||||
// ------------------------------------------------------------------
|
||||
$auto_restrict['error_msg']='Erreur - impossible de se connecter.';// utilisé si on ne veut pas rediriger
|
||||
$auto_restrict['cookie_name']='sonarrss';// nom du cookie
|
||||
$auto_restrict['encryption_key']='abcdef';// clé pour le cryptage de la chaine de vérification
|
||||
$auto_restrict['session_expiration_delay']=120;//minutes
|
||||
//$auto_restrict['login']='bronco'; // caractères alphanum + _ et .
|
||||
$auto_restrict['redirect_error']='index.php?public';// si précisé, pas de message d'erreur
|
||||
// ------------------------------------------------------------------
|
||||
// configuration
|
||||
// ------------------------------------------------------------------
|
||||
$auto_restrict['error_msg']='Erreur - impossible de se connecter.';// utilisé si on ne veut pas rediriger
|
||||
$auto_restrict['cookie_name']='sonarrss';// nom du cookie
|
||||
$auto_restrict['encryption_key']='abcdef';// clé pour le cryptage de la chaine de vérification
|
||||
$auto_restrict['session_expiration_delay']=120;//minutes
|
||||
//$auto_restrict['login']='bronco'; // caractères alphanum + _ et .
|
||||
$auto_restrict['redirect_error']='index.php?public';// si précisé, pas de message d'erreur
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// sécurisation du passe: procédure astucieuse de JérômeJ (http://www.olissea.com/)
|
||||
@include('pass.php');
|
||||
if(!isset($auto_restrict['pass'])){
|
||||
if(isset($_POST['pass'])&&isset($_POST['login'])&&$_POST['pass']!=''&&$_POST['login']!=''){ # Création du fichier pass.php
|
||||
$salt = md5(uniqid('', true));
|
||||
file_put_contents('pass.php', '<?php $auto_restrict["login"]="'.$_POST['login'].'";$auto_restrict["salt"] = '.var_export($salt,true).'; $auto_restrict["pass"] = '.var_export(hash('sha512', $salt.$_POST['pass']),true).'; ?>');
|
||||
include('login_form.php');exit();
|
||||
}
|
||||
else{ # On affiche un formulaire invitant à rentrer le mdp puis on exit le script
|
||||
include('login_form.php');exit();
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------
|
||||
// sécurisation du passe: procédure astucieuse de JérômeJ (http://www.olissea.com/)
|
||||
@include('pass.php');
|
||||
if(!isset($auto_restrict['pass'])){
|
||||
if(isset($_POST['pass'])&&isset($_POST['login'])&&$_POST['pass']!=''&&$_POST['login']!=''){ # Création du fichier pass.php
|
||||
$salt = md5(uniqid('', true));
|
||||
file_put_contents('pass.php', '<?php $auto_restrict["login"]="'.$_POST['login'].'";$auto_restrict["salt"] = '.var_export($salt,true).'; $auto_restrict["pass"] = '.var_export(hash('sha512', $salt.$_POST['pass']),true).'; ?>');
|
||||
include('login_form.php');exit();
|
||||
}
|
||||
else{ # On affiche un formulaire invitant à rentrer le mdp puis on exit le script
|
||||
include('login_form.php');exit();
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// gestion de post pour demande de connexion
|
||||
// si un utilisateur tente de se loguer, on gère ici
|
||||
// ------------------------------------------------------------------
|
||||
if (isset($_POST['login'])&&isset($_POST['pass'])){
|
||||
log_user($_POST['login'],$_POST['pass']);
|
||||
if (isset($_POST['cookie'])){setcookie($auto_restrict['cookie_name'],sha1($_SERVER['HTTP_USER_AGENT']),time()+31104000);}//un an
|
||||
header('location: index.php');
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// gestion de post pour demande de connexion
|
||||
// si un utilisateur tente de se loguer, on gère ici
|
||||
// ------------------------------------------------------------------
|
||||
if (isset($_POST['login'])&&isset($_POST['pass'])){
|
||||
log_user($_POST['login'],$_POST['pass']);
|
||||
if (isset($_POST['cookie'])){setcookie($auto_restrict['cookie_name'],sha1($_SERVER['HTTP_USER_AGENT']),time()+31104000);}//un an
|
||||
header('location: index.php');
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// si pas de demande de connexion on verifie les vars de session
|
||||
// et la duree d'inactivité de la session
|
||||
// si probleme,on include un form de login.
|
||||
// ------------------------------------------------------------------
|
||||
if (!is_ok()){session_destroy();header('location: index.php?public');exit();}
|
||||
// ------------------------------------------------------------------
|
||||
// si pas de demande de connexion on verifie les vars de session
|
||||
// et la duree d'inactivité de la session
|
||||
// si probleme,on include un form de login.
|
||||
// ------------------------------------------------------------------
|
||||
if (!is_ok()){session_destroy();header('location: index.php?public');exit();}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// demande de deco via la variable get 'deconnexion'
|
||||
// ------------------------------------------------------------------
|
||||
if (isset($_GET['deconnexion'])){log_user($_POST['login'],$_POST['pass']);}
|
||||
// ------------------------------------------------------------------
|
||||
//header('location: index.php?public');
|
||||
// ------------------------------------------------------------------
|
||||
// demande de deco via la variable get 'deconnexion'
|
||||
// ------------------------------------------------------------------
|
||||
if (isset($_GET['deconnexion'])){log_user($_POST['login'],$_POST['pass']);}
|
||||
// ------------------------------------------------------------------
|
||||
//header('location: index.php?public');
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// fonctions de cryptage
|
||||
// récupérées sur http://www.info-3000.com/phpmysql/cryptagedecryptage.php
|
||||
// ------------------------------------------------------------------
|
||||
function GenerationCle($Texte,$CleDEncryptage)
|
||||
{
|
||||
$CleDEncryptage = md5($CleDEncryptage);
|
||||
$Compteur=0;
|
||||
$VariableTemp = "";
|
||||
for ($Ctr=0;$Ctr<strlen($Texte);$Ctr++)
|
||||
{
|
||||
if ($Compteur==strlen($CleDEncryptage))
|
||||
$Compteur=0;
|
||||
$VariableTemp.= substr($Texte,$Ctr,1) ^ substr($CleDEncryptage,$Compteur,1);
|
||||
$Compteur++;
|
||||
}
|
||||
return $VariableTemp;
|
||||
}
|
||||
function Crypte($Texte,$Cle)
|
||||
{
|
||||
srand((double)microtime()*1000000);
|
||||
$CleDEncryptage = md5(rand(0,32000) );
|
||||
$Compteur=0;
|
||||
$VariableTemp = "";
|
||||
for ($Ctr=0;$Ctr<strlen($Texte);$Ctr++)
|
||||
{
|
||||
if ($Compteur==strlen($CleDEncryptage))
|
||||
$Compteur=0;
|
||||
$VariableTemp.= substr($CleDEncryptage,$Compteur,1).(substr($Texte,$Ctr,1) ^ substr($CleDEncryptage,$Compteur,1) );
|
||||
$Compteur++;
|
||||
}
|
||||
return base64_encode(GenerationCle($VariableTemp,$Cle) );
|
||||
}
|
||||
function Decrypte($Texte,$Cle)
|
||||
{
|
||||
$Texte = GenerationCle(base64_decode($Texte),$Cle);
|
||||
$VariableTemp = "";
|
||||
for ($Ctr=0;$Ctr<strlen($Texte);$Ctr++)
|
||||
{
|
||||
$md5 = substr($Texte,$Ctr,1);
|
||||
$Ctr++;
|
||||
$VariableTemp.= (substr($Texte,$Ctr,1) ^ $md5);
|
||||
}
|
||||
return $VariableTemp;
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// fonctions de cryptage
|
||||
// récupérées sur http://www.info-3000.com/phpmysql/cryptagedecryptage.php
|
||||
// ------------------------------------------------------------------
|
||||
function GenerationCle($Texte,$CleDEncryptage)
|
||||
{
|
||||
$CleDEncryptage = md5($CleDEncryptage);
|
||||
$Compteur=0;
|
||||
$VariableTemp = "";
|
||||
for ($Ctr=0;$Ctr<strlen($Texte);$Ctr++)
|
||||
{
|
||||
if ($Compteur==strlen($CleDEncryptage))
|
||||
$Compteur=0;
|
||||
$VariableTemp.= substr($Texte,$Ctr,1) ^ substr($CleDEncryptage,$Compteur,1);
|
||||
$Compteur++;
|
||||
}
|
||||
return $VariableTemp;
|
||||
}
|
||||
function Crypte($Texte,$Cle)
|
||||
{
|
||||
srand((double)microtime()*1000000);
|
||||
$CleDEncryptage = md5(rand(0,32000) );
|
||||
$Compteur=0;
|
||||
$VariableTemp = "";
|
||||
for ($Ctr=0;$Ctr<strlen($Texte);$Ctr++)
|
||||
{
|
||||
if ($Compteur==strlen($CleDEncryptage))
|
||||
$Compteur=0;
|
||||
$VariableTemp.= substr($CleDEncryptage,$Compteur,1).(substr($Texte,$Ctr,1) ^ substr($CleDEncryptage,$Compteur,1) );
|
||||
$Compteur++;
|
||||
}
|
||||
return base64_encode(GenerationCle($VariableTemp,$Cle) );
|
||||
}
|
||||
function Decrypte($Texte,$Cle)
|
||||
{
|
||||
$Texte = GenerationCle(base64_decode($Texte),$Cle);
|
||||
$VariableTemp = "";
|
||||
for ($Ctr=0;$Ctr<strlen($Texte);$Ctr++)
|
||||
{
|
||||
$md5 = substr($Texte,$Ctr,1);
|
||||
$Ctr++;
|
||||
$VariableTemp.= (substr($Texte,$Ctr,1) ^ $md5);
|
||||
}
|
||||
return $VariableTemp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
function id_user(){
|
||||
// retourne une chaine identifiant l'utilisateur que l'on comparera par la suite
|
||||
// cette chaine cryptée contient les variables utiles sérialisées
|
||||
$id=array();
|
||||
$id['REMOTE_ADDR']=$_SERVER['REMOTE_ADDR'];
|
||||
$id['HTTP_USER_AGENT']=$_SERVER['HTTP_USER_AGENT'];
|
||||
$id['session_id']=session_id();
|
||||
$id=serialize($id);
|
||||
return $id;
|
||||
}
|
||||
function id_user(){
|
||||
// retourne une chaine identifiant l'utilisateur que l'on comparera par la suite
|
||||
// cette chaine cryptée contient les variables utiles sérialisées
|
||||
$id=array();
|
||||
$id['REMOTE_ADDR']=$_SERVER['REMOTE_ADDR'];
|
||||
$id['HTTP_USER_AGENT']=$_SERVER['HTTP_USER_AGENT'];
|
||||
$id['session_id']=session_id();
|
||||
$id=serialize($id);
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function is_ok(){
|
||||
// vérifie et compare les variables de session
|
||||
// en cas de problème on sort/redirige en détruisant la session
|
||||
global $auto_restrict;
|
||||
$expired=false;
|
||||
if (isset($_COOKIE[$auto_restrict['cookie_name']])&&$_COOKIE[$auto_restrict['cookie_name']]==sha1($_SERVER['HTTP_USER_AGENT'])){return true;}
|
||||
if (!isset($_SESSION['id_user'])){return false;}
|
||||
if ($_SESSION['expire']<time()){$expired=true;}
|
||||
$sid=Decrypte($_SESSION['id_user'],$auto_restrict['encryption_key']);
|
||||
$id=id_user();
|
||||
if ($sid!=$id || $expired==true){// problème
|
||||
return false;
|
||||
}else{ // tout va bien
|
||||
//on redonne un délai à la session
|
||||
$_SESSION['expire']=time()+(60*$auto_restrict['session_expiration_delay']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function is_ok(){
|
||||
// vérifie et compare les variables de session
|
||||
// en cas de problème on sort/redirige en détruisant la session
|
||||
global $auto_restrict;
|
||||
$expired=false;
|
||||
if (isset($_COOKIE[$auto_restrict['cookie_name']])&&$_COOKIE[$auto_restrict['cookie_name']]==sha1($_SERVER['HTTP_USER_AGENT'])){return true;}
|
||||
if (!isset($_SESSION['id_user'])){return false;}
|
||||
if ($_SESSION['expire']<time()){$expired=true;}
|
||||
$sid=Decrypte($_SESSION['id_user'],$auto_restrict['encryption_key']);
|
||||
$id=id_user();
|
||||
if ($sid!=$id || $expired==true){// problème
|
||||
return false;
|
||||
}else{ // tout va bien
|
||||
//on redonne un délai à la session
|
||||
$_SESSION['expire']=time()+(60*$auto_restrict['session_expiration_delay']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function log_user($login_donne,$pass_donne){
|
||||
//cree les variables de session
|
||||
global $auto_restrict;
|
||||
if ($auto_restrict['login']==$login_donne && $auto_restrict['pass']==hash('sha512', $auto_restrict["salt"].$pass_donne)){
|
||||
$_SESSION['id_user']=Crypte(id_user(),$auto_restrict['encryption_key']);
|
||||
$_SESSION['login']=$auto_restrict['login'];
|
||||
$_SESSION['expire']=time()+(60*$auto_restrict['session_expiration_delay']);
|
||||
return true;
|
||||
}else{
|
||||
function log_user($login_donne,$pass_donne){
|
||||
//cree les variables de session
|
||||
global $auto_restrict;
|
||||
if ($auto_restrict['login']==$login_donne && $auto_restrict['pass']==hash('sha512', $auto_restrict["salt"].$pass_donne)){
|
||||
$_SESSION['id_user']=Crypte(id_user(),$auto_restrict['encryption_key']);
|
||||
$_SESSION['login']=$auto_restrict['login'];
|
||||
$_SESSION['expire']=time()+(60*$auto_restrict['session_expiration_delay']);
|
||||
return true;
|
||||
}else{
|
||||
|
||||
exit_redirect();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
exit_redirect();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function redirect_to($page){header('Location: '.$page); }
|
||||
function exit_redirect(){
|
||||
global $auto_restrict;
|
||||
@session_unset();
|
||||
@session_destroy();
|
||||
setcookie($auto_restrict['cookie_name'],'',time()+1);
|
||||
if ($auto_restrict['redirect_error']&&$auto_restrict['redirect_error']!=''){//tester sans la deuxième condition
|
||||
redirect_to($auto_restrict['redirect_error']);
|
||||
}else{exit($auto_restrict['error_msg']);}
|
||||
}
|
||||
function redirect_to($page){header('Location: '.$page); }
|
||||
function exit_redirect(){
|
||||
global $auto_restrict;
|
||||
@session_unset();
|
||||
@session_destroy();
|
||||
setcookie($auto_restrict['cookie_name'],'',time()+1);
|
||||
if ($auto_restrict['redirect_error']&&$auto_restrict['redirect_error']!=''){//tester sans la deuxième condition
|
||||
redirect_to($auto_restrict['redirect_error']);
|
||||
}else{exit($auto_restrict['error_msg']);}
|
||||
}
|
||||
|
||||
|
||||
?>
|
42
config.php
|
@ -1,12 +1,36 @@
|
|||
<?php
|
||||
/* The configuration generated with auto_form*/
|
||||
|
||||
$GLOBAL['data_folder']='mypersonaldata';
|
||||
$GLOBAL['default_data_folder']='public';
|
||||
$GLOBAL['rss_title']='Respawn: le flux de la webliothèque';
|
||||
$GLOBAL['rss_description']='Le respawn de warriordudimanche.net';
|
||||
$GLOBAL['message']='Votre webliothèque perso';
|
||||
$GLOBAL['public_title']='Voici la webliothèque publique de Bronco';
|
||||
$GLOBAL['skin']='pinterest';
|
||||
/* The configuration generated with auto_form*/
|
||||
$GLOBAL['data_folder'] = 'mypersonaldata';
|
||||
$GLOBAL['default_data_folder'] = 'public';
|
||||
$GLOBAL['rss_title'] = 'Respawn: le flux de la webliothèque';
|
||||
$GLOBAL['rss_description'] = 'Le respawn de warriordudimanche.net';
|
||||
$GLOBAL['message'] = 'Votre webliothèque perso';
|
||||
$GLOBAL['public_title'] = 'Voici la webliothèque publique de Bronco';
|
||||
$GLOBAL['skin'] = 'pinterest';
|
||||
|
||||
// File restriction
|
||||
$GLOBAL['image'] = array(
|
||||
'image/png' => 'png',
|
||||
'image/jpg' => 'jpg',
|
||||
'image/jpeg' => 'jpg',
|
||||
'image/jpe' => 'jpg',
|
||||
'image/gif' => 'gif',
|
||||
'image/bmp' => 'bmp',
|
||||
'image/tiff' => 'tiff'
|
||||
);
|
||||
$GLOBAL['document'] = array(
|
||||
'application/vnd.oasis.opendocument.text' => 'odt',
|
||||
'application/vnd.oasis.opendocument.spreadsheet' => 'ods',
|
||||
'application/pdf' => 'pdf',
|
||||
'application/msword' => 'doc',
|
||||
'application/rtf' => 'rtf',
|
||||
'application/vnd.ms-excel' => 'xls',
|
||||
'application/vnd.ms-powerpoint' => 'ppt'
|
||||
);
|
||||
$GLOBAL['archive'] = array(
|
||||
'application/zip' => 'zip',
|
||||
'application/x-rar-compressed' => 'rar',
|
||||
'application/x-msdownload' => 'exe',
|
||||
'application/x-msdownload' => 'msi'
|
||||
);
|
||||
?>
|
|
@ -48,7 +48,10 @@ $autoform_config=array(
|
|||
'reset_button_label'
|
||||
);
|
||||
|
||||
foreach (glob('design/*') as $skin){
|
||||
foreach (glob('design/*',GLOB_ONLYDIR) as $skin){
|
||||
if(basename($skin) === 'icons'){
|
||||
continue;
|
||||
}
|
||||
$skin=basename($skin);if ($skin!='index.html'){$skins[]=$skin;}
|
||||
}
|
||||
$autoform_config['skin']=$skins;
|
||||
|
@ -129,13 +132,17 @@ function render_form($var){
|
|||
}
|
||||
include('auto_restrict.php');
|
||||
include('config.php');
|
||||
if(file_exists('user_config.php')){
|
||||
include('user_config.php');
|
||||
}
|
||||
unset($GLOBAL['private_data_folder']);
|
||||
unset($GLOBAL['public_data_folder']);
|
||||
unset($GLOBAL['image'],$GLOBAL['document'],$GLOBAL['archive']);
|
||||
$GLOBAL['default_data_folder']=basename($GLOBAL['default_data_folder']);
|
||||
|
||||
$message='';
|
||||
if ($_POST){
|
||||
$auto_form['filename']='config.php';
|
||||
$auto_form['filename']='user_config.php';
|
||||
$auto_form['filecontent']="<?php \n /* The configuration generated with auto_form*/\n\n";
|
||||
$auto_form['variable_name']='$GLOBAL';
|
||||
$all_keys=explode(' | ',$_POST['all_keys']);
|
||||
|
|
5
design/icons/AUTHORS
Normal file
|
@ -0,0 +1,5 @@
|
|||
Faenza is designed and developed by Matthieu James <matthieu.james@gmail.com>.
|
||||
|
||||
Faenza icons are all licensed under the GPL.
|
||||
|
||||
Thanks to Holger Seelig and clemyeats for their help for having some text preview inside icons in Nautilus.
|
1
design/icons/bmp.png
Symbolic link
|
@ -0,0 +1 @@
|
|||
png.png
|
1
design/icons/doc.png
Symbolic link
|
@ -0,0 +1 @@
|
|||
odt.png
|
BIN
design/icons/exe.png
Normal file
After Width: | Height: | Size: 748 B |
1
design/icons/gif.png
Symbolic link
|
@ -0,0 +1 @@
|
|||
png.png
|
BIN
design/icons/html.png
Normal file
After Width: | Height: | Size: 770 B |
1
design/icons/jpg.png
Symbolic link
|
@ -0,0 +1 @@
|
|||
png.png
|
1
design/icons/msi.png
Symbolic link
|
@ -0,0 +1 @@
|
|||
exe.png
|
BIN
design/icons/odp.png
Normal file
After Width: | Height: | Size: 630 B |
BIN
design/icons/ods.png
Normal file
After Width: | Height: | Size: 495 B |
BIN
design/icons/odt.png
Normal file
After Width: | Height: | Size: 535 B |
BIN
design/icons/pdf.png
Normal file
After Width: | Height: | Size: 799 B |
BIN
design/icons/png.png
Normal file
After Width: | Height: | Size: 671 B |
1
design/icons/rar.png
Symbolic link
|
@ -0,0 +1 @@
|
|||
zip.png
|
BIN
design/icons/rtf.png
Normal file
After Width: | Height: | Size: 463 B |
1
design/icons/tiff.png
Symbolic link
|
@ -0,0 +1 @@
|
|||
png.png
|
1
design/icons/xls.png
Symbolic link
|
@ -0,0 +1 @@
|
|||
ods.png
|
BIN
design/icons/zip.png
Normal file
After Width: | Height: | Size: 551 B |
70
index.php
|
@ -35,6 +35,9 @@ if (isset($_GET['tag'])){$search_tags=strip_tags($_GET['tag']);}else{$search_tag
|
|||
// CONFIGURABLE OPTIONS
|
||||
// adapter la configuration dans le fichier config.php
|
||||
include('config.php');
|
||||
if(file_exists('user_config.php')){
|
||||
include('user_config.php');
|
||||
}
|
||||
|
||||
$GLOBAL['version']='2.2';
|
||||
$GLOBAL['respawn_url']=returncurrenturl();
|
||||
|
@ -229,13 +232,25 @@ if (!$GLOBAL['public']){ // private
|
|||
else {
|
||||
$GLOBAL['target_folder'] = $GLOBAL['default_data_folder'].'/'.$new_folder;
|
||||
}
|
||||
|
||||
/*GESTION DU PDF ICI*/
|
||||
if (strtolower(substr($_GET['q'],-4))=='.pdf'){
|
||||
$title=basename($_GET['q']);
|
||||
file_put_contents($GLOBAL['target_folder'].'/'.$title,$GLOBAL['main_page_data']);
|
||||
file_put_contents($GLOBAL['target_folder'].'/index.php','<?php header("location: '.$title.'");?>');
|
||||
}else{
|
||||
$urlInfo =pathinfo($GLOBAL['url']);
|
||||
$title = $urlInfo['filename'];
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
$mineType = $finfo->buffer($GLOBAL['main_page_data']);
|
||||
if(array_key_exists($mineType, $GLOBAL['image'])){
|
||||
$ext = $GLOBAL['image'][$mineType];
|
||||
file_put_contents($GLOBAL['target_folder'].'/'.$title.'.'.$ext, $GLOBAL['main_page_data']);
|
||||
file_put_contents($GLOBAL['target_folder'].'/index.php','<!DOCTYPE html><html><head><title>'.$title.'</title></head><body><img src="'.$title.'.'.$ext.'" alt="Save image from '.$GLOBAL['url'].'"/></body></html>');
|
||||
} elseif(array_key_exists($mineType, $GLOBAL['document'])){
|
||||
$ext = $GLOBAL['document'][$mineType];
|
||||
$title=basename($_GET['q']);
|
||||
file_put_contents($GLOBAL['target_folder'].'/'.$title,$GLOBAL['main_page_data']);
|
||||
file_put_contents($GLOBAL['target_folder'].'/index.php','<?php header("location: '.$title.'");?>');
|
||||
} elseif(array_key_exists($mineType, $GLOBAL['archive'])){
|
||||
$ext = $GLOBAL['archive'][$mineType];
|
||||
$title=basename($_GET['q']);
|
||||
file_put_contents($GLOBAL['target_folder'].'/'.$title,$GLOBAL['main_page_data']);
|
||||
file_put_contents($GLOBAL['target_folder'].'/index.php','<?php header("location: '.$title.'");?>');
|
||||
}else{
|
||||
|
||||
|
||||
$liste_css = array();
|
||||
|
@ -371,12 +386,14 @@ if (!$GLOBAL['public']){ // private
|
|||
$n++;
|
||||
$count = count($liste_css);
|
||||
}
|
||||
$mineType = '';
|
||||
}
|
||||
// enregistre un fichier d’informations concernant la page (date, url, titre)
|
||||
// enregistre un fichier d’informations concernant la page (date, url, titre, extension du fichier)
|
||||
$info = '';
|
||||
$info .= 'URL="'.$GLOBAL['url'].'"'."\n";
|
||||
$info .= 'TITLE="'.$title.'"'."\n";
|
||||
$info .= 'DATE="'.time().'"'."\n";
|
||||
$info .= 'TYPE="'.$ext.'"'."\n";
|
||||
file_put_contents($GLOBAL['target_folder'].'/'.'index.ini', $info);
|
||||
/*$GLOBAL['done']['d'] = 'ajout';
|
||||
$GLOBAL['done']['lien'] = $GLOBAL['target_folder'].'/'; */
|
||||
|
@ -792,6 +809,36 @@ function rand_new_name($name) {
|
|||
return 'f_'.str_shuffle('abcd').mt_rand(100, 999).'--'.preg_replace('#[^\w.]#', '_', substr($name, 15)).'.'.pathinfo($name, PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
function returnLocalFavicon($path,$fileType){
|
||||
$favicon = glob($path.'*favicon.*');
|
||||
if(empty($favicon)){
|
||||
if(file_exists('design/icons/'.$fileType.'.png')){
|
||||
return 'design/icons/'.$fileType.'.png';
|
||||
} else {
|
||||
return 'design/icons/html.png';
|
||||
}
|
||||
} else {
|
||||
return $favicon[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Améliore la sortie print
|
||||
*
|
||||
* @author Tatane http://www.tatane.info/index.php/print_rn
|
||||
* @author http://www.blog.cactuscrew.com/77-print_rn.html
|
||||
* @param $data (array) tableau à examiner
|
||||
* @param $name (string) nom a affiché
|
||||
* @return false affiche les clef valeur du tableau $data
|
||||
*/
|
||||
function n_print($data, $name = '') {
|
||||
$aBackTrace = debug_backtrace();
|
||||
echo '<h2>', $name, '</h2>';
|
||||
echo '<fieldset style="border: 1px solid orange; padding: 5px;color: #333; background-color: #fff;">';
|
||||
echo '<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '</legend>';
|
||||
echo '<pre>', htmlentities(print_r($data, 1)), '</pre>';
|
||||
echo '</fieldset><br />';
|
||||
}
|
||||
|
||||
if ($GLOBAL['done']['d'] !== FALSE) {
|
||||
switch($GLOBAL['done']['d']) {
|
||||
|
@ -887,9 +934,7 @@ if ($GLOBAL['done']['d'] !== FALSE) {
|
|||
if (is_dir($GLOBAL['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 = $GLOBAL['public_data_folder'].'/'.$liste_pages[$i].'/index.ini';
|
||||
$favicon = glob($GLOBAL['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 {
|
||||
|
@ -900,7 +945,7 @@ if ($GLOBAL['done']['d'] !== FALSE) {
|
|||
} else {
|
||||
$titre = 'titre'; $url = '#'; $date = 'date inconnue';
|
||||
}
|
||||
|
||||
$favicon = returnLocalFavicon($GLOBAL['public_data_folder'].'/'.$liste_pages[$i].'/',$infos['TYPE']);
|
||||
$tags=$taglinks='';
|
||||
if (isset($GLOBAL['tag_array']['public'][$liste_pages[$i]])){$tags=$GLOBAL['tag_array']['public'][$liste_pages[$i]];$taglinks=tag2links($GLOBAL['tag_array']['public'][$liste_pages[$i]]);}
|
||||
echo "\t".'<li>';
|
||||
|
@ -937,8 +982,6 @@ if ($GLOBAL['done']['d'] !== FALSE) {
|
|||
if (is_dir($GLOBAL['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 = $GLOBAL['private_data_folder'].'/'.$liste_pages[$i].'/index.ini';
|
||||
$favicon=glob($GLOBAL['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 {
|
||||
|
@ -949,6 +992,7 @@ if ($GLOBAL['done']['d'] !== FALSE) {
|
|||
} else {
|
||||
$titre = 'titre'; $url = '#'; $date = 'date inconnue';
|
||||
}
|
||||
$favicon = returnLocalFavicon($GLOBAL['public_data_folder'].'/'.$liste_pages[$i].'/',$infos['TYPE']);
|
||||
$tags=$taglinks='';
|
||||
if (isset($GLOBAL['tag_array']['private'][$liste_pages[$i]])){$tags=$GLOBAL['tag_array']['private'][$liste_pages[$i]];$taglinks=tag2links($GLOBAL['tag_array']['private'][$liste_pages[$i]]);}
|
||||
|
||||
|
|