Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function afficheConfig($filename) {
- $config = parse_ini_file($filename, true);
- #echo '<pre>'. print_r($config, 1) . '</pre>';
- $content = [];
- $content[] = '<form id=formConfig name=formConfig method=post action=sendFormConfig.html onsubmit="return newAjaxJSON(this.getAttribute(\'action\'), this)">';
- $content[] = '<fieldset><legend>SITE</legend>';
- $content[] = '<label for=SITE_titre>Titre</label>';
- $content[] = '<input required type=text id=SITE_titre name="SITE[titre]" value='.$config['SITE']['titre'].'>';
- $content[] = '<label for=SITE_images>Images</label>';
- $content[] = '<input required type=text id=SITE_images name="SITE[images]" value='.$config['SITE']['images'].'>';
- $content[] = '</fieldset>';
- $content[] = '<fieldset><legend>ADMIN</legend>';
- $content[] = '<label for=ADMIN_mail>Mail</label>';
- $content[] = '<input required type=text id=ADMIN_mail name="ADMIN[mail]" value='.$config['ADMIN']['mail'].'>';
- $content[] = '<label for=ADMIN_label>Label</label>';
- $content[] = '<input required type=text id=ADMIN_label name="ADMIN[label]" value='.$config['ADMIN']['label'].'>';
- $content[] = '</fieldset>';
- $content[] = '<fieldset><legend>EPHEC</legend>';
- $content[] = '<label for=ADMIN_mail>Mail</label>';
- $content[] = '<input required type=text id=EPHEC_mail name="EPHEC[mail]" value='.$config['EPHEC']['mail'].'>';
- $content[] = '<label for=ADMIN_nom>Nom/prénom</label>';
- $content[] = '<input required type=text id=EPHEC_nom name="EPHEC[nom]" value='.$config['EPHEC']['nom'].'>';
- $content[] = '<label for=ADMIN_matricule>Matricule</label>';
- $content[] = '<input required type=text id=EPHEC_matricule name="EPHEC[matricule]" value='.$config['EPHEC']['matricule'].'>';
- $content[] = '<label for=ADMIN_groupe>Groupe</label>';
- $content[] = '<input required type=text id=EPHEC_groupe name="EPHEC[groupe]" value='.$config['EPHEC']['groupe'].'>';
- $content[] = '<label for=ADMIN_host>Host</label>';
- $content[] = '<input required type=text id=EPHEC_host name="EPHEC[host]" value='.$config['EPHEC']['host'].'>';
- $content[] = '</fieldset>';
- $content[] = '<fieldset><legend>LOGO</legend>';
- $content[] = '<label for=LOGO_logo>Logo</label>';
- $content[] = '<input required type=text id=LOGO_logo name="LOGO[logo]" value='.$config['LOGO']['logo'].'>';
- $content[] = '<label for=LOGO_TAILLE>Taille</label>';
- $content[] = '<input required type=number id=LOGO_TAILLE name="LOGO[taille]" value='.$config['LOGO']['taille'].' min='.$config['LOGO']['min'].' max='.$config['LOGO']['max'].' step='.$config['LOGO']['pas'].'>';
- $content[] = '<input hidden name="LOGO[min]" value='.$config['LOGO']['min'].'>';
- $content[] = '<input hidden name="LOGO[max]" value='.$config['LOGO']['max'].'>';
- $content[] = '<input hidden name="LOGO[pas]" value='.$config['LOGO']['pas'].'>';
- $content[] = '</fieldset>';
- $content[] = '<fieldset><legend>DB</legend>';
- $content[] = '<label for=DB_host>Host</label>';
- $content[] = '<input required type=text id=DB_host name="DB[host]" value='.$config['DB']['host'].'>';
- $content[] = '<label for=DB_user>User</label>';
- $content[] = '<input required type=text id=DB_user name="DB[user]" value='.$config['DB']['user'].'>';
- $content[] = '<label for=DB_pswd>Password</label>';
- $content[] = '<input required type=text id=DB_pswd name="DB[pswd]" value='.$config['DB']['pswd'].'>';
- $content[] = '<label for=DB_name>Name</label>';
- $content[] = '<input required type=text id=DB_name name="DB[dbname]" value='.$config['DB']['dbname'].'>';
- $content[] = '</fieldset>';
- $content[] = '<fieldset><legend>AVATAR</legend>';
- $content[] = '<label for=AVATAR_dossier>Dossier</label>';
- $content[] = '<input required type=text id=AVATAR_dossier name="AVATAR[dossier]" value='.$config['AVATAR']['dossier'].'>';
- $content[] = '<label for=AVATAR_anonyme>Anonyme</label>';
- $content[] = '<input required type=text id=AVATAR_anonyme name="AVATAR[anonyme]" value='.$config['AVATAR']['anonyme'].'>';
- $content[] = '<label for=AVATAR_taille>Taille</label>';
- $content[] = '<input required type=text id=AVATAR_taille name="AVATAR[taille]" value='.$config['AVATAR']['taille'].' min='.$config['AVATAR']['min'].' max='.$config['AVATAR']['max'].'>';
- $content[] = '<input hidden name="AVATAR[min]" value='.$config['AVATAR']['min'].'>';
- $content[] = '<input hidden name="AVATAR[max]" value='.$config['AVATAR']['max'].'>';
- $content[] = '<label for=AVATAR_type>Type</label>';
- $content[] = '<span id=AVATAR_type>';
- foreach($config['AVATAR']['type'] as $type) {
- $checked = in_array($type, $config['AVATAR']['choix']) ? 'checked' : '';
- $content[] = '<input hidden type=checkbox checked name="AVATAR[type]['.$type.']">';
- $content[] = '<label for=AVATAR_type_'.$type.'>'.$type.'</label>';
- $content[] = '<input type=checkbox name="AVATAR[choix]['.$type.']" id=AVATAR_type_'.$type.' '.$checked.'>';
- }
- $content[] = '</span>';
- $content[] = '</label>';
- $content[] = '</fieldset>';
- $content[] = '<button type=submit>envoyer</button>';
- $content[] = '<span id=modifCfg></span>';
- $content[] = '</from>';
- return implode("\r\n", $content);
- }
- function updateConfig($filename) {
- $file = fopen($filename, 'w');
- foreach($_POST as $name => $block) {
- fwrite($file, "[$name]\r\n");
- foreach($block as $key => $value) {
- if (gettype($value) != 'array')
- fwrite($file, "$key = $value\r\n");
- else
- foreach($value as $subkey => $_)
- fwrite($file, $key."[] = $subkey\r\n");
- }
- }
- fclose($file);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement