true, 'allow_user_to_config'=>false, 'adresse_du_site'=>'www.warriordudimanche.net', 'use_a_choice'=>'choice one',// current value: other values are defined below 'use_a_radiobutton_choice'=>'choice one',// current value: other values are defined below 'my_password'=>'password', 'confirm_password'=>'', );*/ //then render_form($config); /* ##################################################################### # auto_form config # ##################################################################### */ // here are the basic parameters $autoform_config=array( 'use_labels'=>true, 'use_placeholder'=>true, 'method'=>'post', 'action'=>'config_page.php', 'form_name'=>'autoform', 'form_id'=>'autoform', 'form_class'=>'autoform', 'enctype'=>'', 'submit_button_label'=>'Save changes', 'reset_button_label' ); foreach (glob('design/*') as $skin){ $skin=basename($skin);if ($skin!='index.html'){$skins[]=$skin;} } $autoform_config['skin']=$skins; $autoform_config['default_data_folder']=array('private','public'); /* ##################################################################### # the render function # ##################################################################### You can call it from anywhere in the page and render more than one form just call render_form($data_array)to create a brand new form with differents names, classes, ids etc. */ function render_form($var){ global $autoform_config;$all_keys=''; $id=$class=$enctype=$reset=''; if ($autoform_config['form_id']){$id=' id="'.$autoform_config['form_id'].'" ';} 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.' | '; $txt=str_replace('_',' ',$key); $label=""; $idclasname="name='$key' id='$key' class='$key'"; // echo '
  • '; if (is_bool($value)){ // oh, a checkbox ! if ($value==true){$checked=' checked ';}else{$checked='';} echo $label; echo ""; } else{ if (!$autoform_config['use_labels']){$label='';} if (isset($autoform_config[$key])&&is_array($autoform_config[$key])){ // 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"; }else{ // oh, a select input ! echo $label; echo "\n"; } }else if (isset($autoform_config[$key]) && $autoform_config[$key]=='pass'){ //oh, a password input ! echo $label; 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";// this line to prevent unchecked boxes to desapear. echo ' $reset \n
    "; } include('auto_restrict.php'); include('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['filecontent']=""; file_put_contents($auto_form['filename'],$auto_form['filecontent']); if ($postdata['data_folder']!=$GLOBAL['data_folder']){ rename ($GLOBAL['data_folder'],$postdata['data_folder']);} $message=' saved.'; unset($postdata['all_keys']); $GLOBAL=$postdata; } ?> Configuration