From 02b0829c8fef95bf06b893348a63f10a82af79fd Mon Sep 17 00:00:00 2001 From: broncowdd Date: Fri, 22 Aug 2014 16:21:43 +0200 Subject: [PATCH 1/2] encodage --- auto_restrict.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto_restrict.php b/auto_restrict.php index b4a8e60..b6a54a0 100644 --- a/auto_restrict.php +++ b/auto_restrict.php @@ -1,4 +1,4 @@ - Date: Fri, 29 Aug 2014 15:51:57 +0200 Subject: [PATCH 2/2] Ajout d'un fichier de config utilisateur --- .gitignore | 1 + config_page.php | 43 ++++++++++++----------- index.php | 91 +++++++++++++++++++++++++------------------------ 3 files changed, 71 insertions(+), 64 deletions(-) diff --git a/.gitignore b/.gitignore index b9d6bd9..9979946 100644 --- a/.gitignore +++ b/.gitignore @@ -213,3 +213,4 @@ pip-log.txt #Mr Developer .mr.developer.cfg +user_config.php diff --git a/config_page.php b/config_page.php index 5430768..0d31f8d 100644 --- a/config_page.php +++ b/config_page.php @@ -3,10 +3,10 @@ * @author bronco@warriordudimanche.com * @copyright open source and free to adapt (keep me aware !) * @version 0.1 - * auto_form.php is a little script to auto create a form and - * its content only with an array. - * It can create text inputs radiobuttons, select lists, passwords inputs. - * All the generated form's elements can be reached by classes + * auto_form.php is a little script to auto create a form and + * its content only with an array. + * It can create text inputs radiobuttons, select lists, passwords inputs. + * All the generated form's elements can be reached by classes * and ids with css or jquery. * * It's possible to configure auto_form to add some features @@ -23,7 +23,7 @@ $config=array( 'use_a_radiobutton_choice'=>'choice one',// current value: other values are defined below 'my_password'=>'password', 'confirm_password'=>'', - + );*/ //then render_form($config); @@ -31,7 +31,7 @@ $config=array( /* ##################################################################### # auto_form config # ##################################################################### - + */ // here are the basic parameters @@ -68,7 +68,7 @@ function render_form($var){ if ($autoform_config['form_class']){$class=' class="'.$autoform_config['form_class'].'" ';} if ($autoform_config['enctype']){$enctype=' enctype="'.$autoform_config['enctype'].'" ';} if (isset($autoform_config['reset_button_label'])){$reset="';} - + echo '
\n "; foreach($var as $key=>$value){ $all_keys.=$key.' | '; @@ -77,7 +77,7 @@ function render_form($var){ $idclasname="name='$key' id='$key' class='$key'"; // echo '
  • '; - if (is_bool($value)){ + if (is_bool($value)){ // oh, a checkbox ! if ($value==true){$checked=' checked ';}else{$checked='';} echo $label; @@ -89,7 +89,7 @@ function render_form($var){ // lists of choices if (isset($autoform_config[$key]['type'])&&$autoform_config[$key]['type']=='radio'){ unset($autoform_config[$key]['type']); - + // oh, a radiobutton list ! echo $txt.'
    '; echo "
      \n"; @@ -98,11 +98,11 @@ function render_form($var){ echo "
    • \n"; } echo "
    \n"; - + }else{ // oh, a select input ! echo $label; - echo "\n"; foreach ($autoform_config[$key] as $choice){ if ($choice==$value){$checked='selected';}else{$checked='';} echo "\n"; @@ -112,15 +112,15 @@ function render_form($var){ }else if (isset($autoform_config[$key]) && $autoform_config[$key]=='pass'){ //oh, a password input ! echo $label; - echo "\n"; - + echo "\n"; + }else{ // ok, so that's a text input... echo $label; if ($autoform_config['use_placeholder']){$placeholder=" placeholder='$txt'";}else{$placeholder='';} - echo "\n"; + echo "\n"; } - + } echo "
  • \n"; } @@ -129,13 +129,16 @@ 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']); $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']=""; @@ -164,9 +167,9 @@ if ($_POST){ - + - Configuration + Configuration @@ -178,7 +181,7 @@ if ($_POST){ diff --git a/index.php b/index.php index 7d327d0..c0a9436 100644 --- a/index.php +++ b/index.php @@ -3,18 +3,18 @@ /* (webpage retriever by Timo Van Neerden; http://lehollandaisvolant.net/contact December 2012) * last updated : December, 10th, 2012 * - * This piece of software is under the WTF Public Licence. - * Everyone is permitted to copy and distribute verbatim or modified + * This piece of software is under the WTF Public Licence. + * Everyone is permitted to copy and distribute verbatim or modified * copies of this program, under the following terms of the WFTPL : * - * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION * * 0. You just DO WHAT THE FUCK YOU WANT TO. * */ -/* all the enhancements (logo, css, session lock, bookmarklet, tags, rss feed, api) are from Bronco (www.warriordudimanche.net) +/* all the enhancements (logo, css, session lock, bookmarklet, tags, rss feed, api) are from Bronco (www.warriordudimanche.net) * and are based on the same licence ;) * thanks a lot to Timo for his great job on this app ;) */ @@ -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(); @@ -299,7 +302,7 @@ if (!$GLOBAL['public']){ // private $matches_url = array_merge($matches_url2, $matches_url); - + // pour chaque URL/URI foreach ($matches_url as $j => $valuej) { @@ -378,11 +381,11 @@ if (!$GLOBAL['public']){ // private $info .= 'TITLE="'.$title.'"'."\n"; $info .= 'DATE="'.time().'"'."\n"; file_put_contents($GLOBAL['target_folder'].'/'.'index.ini', $info); - /*$GLOBAL['done']['d'] = 'ajout'; + /*$GLOBAL['done']['d'] = 'ajout'; $GLOBAL['done']['lien'] = $GLOBAL['target_folder'].'/'; */ - + } - + }//die; @@ -394,7 +397,7 @@ if (!$GLOBAL['public']){ // private $id=idfrompath($_GET['suppr']); $status=statuspath($_GET['suppr']); if (isset($GLOBAL['tag_array'][$status][$id])){deltags($GLOBAL['tag_array'][$status][$id],$_GET['suppr'],$id,$status);} - + // suppr page $sousliste = scandir($_GET['suppr']); // listage des dossiers de data. $nb_sousfichier = count($sousliste); @@ -405,11 +408,11 @@ if (!$GLOBAL['public']){ // private } // then the folder itself. if (TRUE === rmdir($_GET['suppr'])) { - $GLOBAL['done']['d'] = 'remove'; + $GLOBAL['done']['d'] = 'remove'; } } - + header("location: index.php"); } @@ -444,7 +447,7 @@ if (!$GLOBAL['public']){ // private if (isset($_GET['privateget'])&&is_dir($GLOBAL['private_data_folder'].'/'.$_GET['privateget'])){$target=$GLOBAL['private_data_folder'].'/'.$_GET['privateget'];} - if (isset($_GET['zipprivate'])) { + if (isset($_GET['zipprivate'])) { $ini_file = $GLOBAL['private_data_folder'].'/'.$_GET['zipprivate'].'/index.ini'; if(is_file($ini_file)){$info=parse_ini_file($ini_file);}else{$info['TITLE']='';} $origin_folder_path=$GLOBAL['private_data_folder'].'/'.$_GET['zipprivate']; @@ -453,31 +456,31 @@ if (!$GLOBAL['public']){ // private $zip_completepath=$GLOBAL['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'; + 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,$GLOBAL['data_folder'].'/zipversions/'); + zip($zip_filename,$zip_foldername,$GLOBAL['data_folder'].'/zipversions/'); rename ($zip_foldername,$origin_folder_path); // on le remet à sa place header('location: '.$GLOBAL['data_folder'].'/zipversions/'.$zip_filename); } } - if (isset($_GET['rename'])&&isset($_GET['to'])&&isset($_GET['file'])) { + if (isset($_GET['rename'])&&isset($_GET['to'])&&isset($_GET['file'])) { if (is_file($_GET['file'].'/index.ini')){ $ini=parse_ini_file($_GET['file'].'/index.ini'); - + $old=strip_tags(urldecode($_GET['rename'])); $new=strip_tags(urldecode($_GET['to'])); $newini='URL="'.$ini['URL'].'"'."\n".'TITLE="'.$new.'"'."\n".'DATE="'.$ini['DATE'].'"'; file_put_contents($_GET['file'].'/index.ini',$newini); } } - if (isset($_GET['settag'])&&isset($_GET['file'])) { - if (is_file($GLOBAL['data_folder'].'/tags.txt')){$GLOBAL['tag_array']=unstore($GLOBAL['data_folder'].'/tags.txt');}else{$GLOBAL['tag_array']=array();} + if (isset($_GET['settag'])&&isset($_GET['file'])) { + if (is_file($GLOBAL['data_folder'].'/tags.txt')){$GLOBAL['tag_array']=unstore($GLOBAL['data_folder'].'/tags.txt');}else{$GLOBAL['tag_array']=array();} if (isset($_GET['ispublic'])){$type='public';}else{$type='private';} $GLOBAL['tag_array'][$type][$_GET['file']]=strip_tags($_GET['settag']); store($GLOBAL['data_folder'].'/tags.txt',$GLOBAL['tag_array']); } -}else{ // public get +}else{ // public get //download public zip version if (isset($_GET['zippublic'])) { $ini_file = $GLOBAL['public_data_folder'].'/'.$_GET['zippublic'].'/index.ini'; @@ -488,9 +491,9 @@ if (!$GLOBAL['public']){ // private $zip_completepath=$GLOBAL['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'; + 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,$GLOBAL['data_folder'].'/zipversions/'); + zip($zip_filename,$zip_foldername,$GLOBAL['data_folder'].'/zipversions/'); rename ($zip_foldername,$origin_folder_path); // on le remet à sa place header('location: '.$GLOBAL['data_folder'].'/zipversions/'.$zip_filename); } @@ -508,8 +511,8 @@ if (!$GLOBAL['public']){ // private ) ); foreach ($items as $key=>$item){ - if ($item!='index.html'){ - if (is_dir($GLOBAL['public_data_folder'].'/'.$item)){ + if ($item!='index.html'){ + if (is_dir($GLOBAL['public_data_folder'].'/'.$item)){ if (is_file($GLOBAL['public_data_folder'].'/'.$item.'/index.ini')){ $infos=parse_ini_file($GLOBAL['public_data_folder'].'/'.$item.'/index.ini'); date_default_timezone_set('Europe/Paris'); @@ -531,10 +534,10 @@ if (!$GLOBAL['public']){ // private } if (isset($_GET['api'])){ $content=array(); - $items=search('public',$search_tags); + $items=search('public',$search_tags); foreach ($items as $key=>$item){ - if ($item!='index.html'){ - if (is_dir($GLOBAL['public_data_folder'].'/'.$item)){ + if ($item!='index.html'){ + if (is_dir($GLOBAL['public_data_folder'].'/'.$item)){ if (is_file($GLOBAL['public_data_folder'].'/'.$item.'/index.ini')){ $infos=parse_ini_file($GLOBAL['public_data_folder'].'/'.$item.'/index.ini'); date_default_timezone_set('Europe/Paris'); @@ -572,7 +575,7 @@ function url_parts() { } // -// Gets external file by URL. +// Gets external file by URL. // Make a stream context (better). // @@ -813,7 +816,7 @@ if ($GLOBAL['done']['d'] !== FALSE) { - - <?php echo $page_title; ?> + <?php echo $page_title; ?> - + >