Editeur Editez un fichier

Edition d'un fichier

Editez le fichier applications/nuasix/profile-settings.php
<?php 
//_________________________________________________________________________________
//Récupération des profils de réglages
$reqSettings            = getQueries("nx_settings", array("application_uniqid" => $_SESSION['current_application_uniqid']));
$settings               = $reqSettings['result'];
//_________________________________________________________________________________
//_________________________________________________________________________________
//Création d'un profil de réglage
if(isset($_POST['add-setting'])) {
    
    //Données du formulaire
    $form       = array('setting_name'          => htmlspecialchars($_POST['setting_name']), 
                        'setting_json'          => $_POST['setting_json'], 
                        'setting_uniqid'        => uniqid(), 
                        'application_uniqid'    => htmlspecialchars($_POST['application_uniqid']), 
                        'user_id'               => $user -> getUserId());
    
    $flag       = dbRowInsert2("nx_settings", $form);
    
    if($flag) {
        
        itsLog(array('log_table'        => "nx_settings",
                     'log_operation'    => "Ajout d'un profil de réglage", 
                     'log_request'      => json_encode($form),
                     'log_response'     => json_encode($flag),
                     'log_color'        => "success", 
                     'log_display'      => 1,
                     'log_timeout'      => 5000,
                     'id_log'           => getLastId("nx_settings", 'idSetting'), 
                     'user_id'          => $user -> getUserId()
        ));
        
    } else {
        itsLog(array('log_table'        => "nx_settings",
                     'log_operation'    => "Erreur durant l'ajout du profil de réglage", 
                     'log_request'      => json_encode($form),
                     'log_response'     => json_encode($flag),
                     'log_color'        => "danger", 
                     'log_display'      => 1,
                     'log_timeout'      => 5000, 
                     'user_id'          => $user -> getUserId()
        ));
    }
    
    //Refresh
    redirect($_SERVER['REQUEST_URI']);
}
//_________________________________________________________________________________
?>
                    <div class="content d-flex flex-column flex-column-fluid" id="kt_content">
						<!--begin::Container-->
						<div class="container-xxl" id="kt_content_container">
							<!--begin::Card-->
                            <div class="card">
								<!--begin::Card header-->
								<div class="card-header border-0 pt-6">
									<!--begin::Card toolbar-->
									<div class="card-toolbar">
										<!--begin::Toolbar-->
										<div class="d-flex justify-content-end" data-kt-user-table-toolbar="base">
											<!--begin::Add user-->
											<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#add-item">
											<!--begin::Svg Icon | path: icons/duotune/arrows/arr075.svg-->
											<span class="svg-icon svg-icon-2">
												<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
													<rect opacity="0.5" x="11.364" y="20.364" width="16" height="2" rx="1" transform="rotate(-90 11.364 20.364)" fill="black" />
													<rect x="4.36396" y="11.364" width="16" height="2" rx="1" fill="black" />
												</svg>
											</span>
											<!--end::Svg Icon-->Ajouter</button>
											<!--end::Add user-->
										</div>
										<!--end::Toolbar-->
										<!--begin::Modal - Add task-->
										<div class="modal fade" id="add-item" tabindex="-1" aria-hidden="true">
											<!--begin::Modal dialog-->
											<div class="modal-dialog modal-dialog-centered mw-650px">
												<!--begin::Modal content-->
												<div class="modal-content">
													<!--begin::Modal header-->
													<div class="modal-header" id="kt_modal_add_user_header">
														<!--begin::Modal title-->
														<h2 class="fw-bolder">Ajouter un profil de réglage</h2>
														<!--end::Modal title-->
														<!--begin::Close-->
														<div class="btn btn-icon btn-sm btn-active-icon-primary" data-bs-dismiss="modal">
															<!--begin::Svg Icon | path: icons/duotune/arrows/arr061.svg-->
															<span class="svg-icon svg-icon-1">
																<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
																	<rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="black" />
																	<rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="black" />
																</svg>
															</span>
															<!--end::Svg Icon-->
														</div>
														<!--end::Close-->
													</div>
													<!--end::Modal header-->
													<!--begin::Modal body-->
													<div class="modal-body scroll-y mx-5 mx-xl-15 my-7">
                                                        <!--begin::Heading-->
                                                        <div class="text-center mb-13">
                                                            <!--begin::JSON-->
                                                            <div class="text-muted fw-bold fs-5">Editeur JSON 
                                                                <a href="https://jsonformatter.org/json-editor" class="link-primary fw-bolder" target="_blank">disponible ici</a>.
                                                            </div>
                                                            <!--end::JSON-->
                                                        </div>
                                                        <!--end::Heading-->
														<!--begin::Form-->
														<form  class="form" action="" method="post">
															<!--begin::Scroll-->
															<div class="d-flex flex-column scroll-y me-n7 pe-7" id="kt_modal_add_user_scroll" data-kt-scroll="true" data-kt-scroll-activate="{default: false, lg: true}" data-kt-scroll-max-height="auto" data-kt-scroll-dependencies="#kt_modal_add_user_header" data-kt-scroll-wrappers="#kt_modal_add_user_scroll" data-kt-scroll-offset="300px">
																<!--begin::Input group-->
																<div class="fv-row mb-7">
																	<!--begin::Label-->
																	<label class="required fw-bold fs-6 mb-2">Nom</label>
																	<!--end::Label-->
																	<!--begin::Input-->
																	<input type="text" name="setting_name" class="form-control form-control-solid mb-3 mb-lg-0" placeholder="Ex: Ressource par défaut" />
																	<!--end::Input-->
																</div>
																<!--end::Input group-->
																<!--begin::Input group-->
																<div class="fv-row mb-7">
																	<!--begin::Label-->
																	<label class="required fw-bold fs-6 mb-2">Paramètres au format JSON</label>
																	<!--end::Label-->
																	<!--begin::Input-->
                                                                    <textarea name="setting_json" class="form-control form-control-solid mb-3 mb-lg-0" style="height:300px;"></textarea>
																	<!--end::Input-->
                                                                    <!--begin::Hint-->
                                                                    <div class="form-text">Décrivez vos paramètres au format JSON</div>
                                                                    <!--end::Hint-->
																</div>
																<!--end::Input group-->
																<!--begin::Input group-->
																<div class="mb-7">
																	<!--begin::Label-->
																	<label class="required fw-bold fs-6 mb-5">Application</label>
																	<!--end::Label-->
																	<!--begin::Applications-->
                                                                    <?php
                                                                    $reqApplications    = getQueries("nx_applications");
                                                                    $applications       = $reqApplications['result'];
                                                                    foreach($applications as $application) {
                                                                        //Checked ?
                                                                        $checked    = ($_SESSION['current_application_uniqid'] == $application['application_uniqid']) ? "checked" : "";
                                                                    ?>
                                                                    <!--begin::Input row-->
																	<div class="d-flex fv-row">
																		<!--begin::Radio-->
																		<div class="form-check form-check-custom form-check-solid">
																			<!--begin::Input-->
																			<input class="form-check-input me-3" name="application_uniqid" type="radio" value="<?= $application['application_uniqid']?>" id="application_<?= $application['application_name']?>" <?= $checked?> />
																			<!--end::Input-->
																			<!--begin::Label-->
																			<label class="form-check-label" for="application_<?= $application['application_name']?>">
																				<div class="fw-bolder text-gray-800"><?= $application['application_name']?></div>
																				<div class="text-gray-600"><?= $application['application_description']?></div>
																			</label>
																			<!--end::Label-->
																		</div>
																		<!--end::Radio-->
                                                                        <div class='separator separator-dashed my-5'></div>

																	</div>
																	<!--end::Input row-->  
                                                                    <?php
                                                                    }
                                                                    ?>
																	<!--end::Applications-->
																</div>
																<!--end::Input group-->
															</div>
															<!--end::Scroll-->
															<!--begin::Actions-->
															<div class="text-center pt-15">
																<button type="reset" class="btn btn-light me-3" data-bs-dismiss="modal">Annuler</button>
																<button type="submit" class="btn btn-primary" data-kt-users-modal-action="submit" name="add-setting">
																	<span class="indicator-label">Ajouter</span>
																	<span class="indicator-progress">2 secondes...
																	<span class="spinner-border spinner-border-sm align-middle ms-2"></span></span>
																</button>
															</div>
															<!--end::Actions-->
														</form>
														<!--end::Form-->
													</div>
													<!--end::Modal body-->
												</div>
												<!--end::Modal content-->
											</div>
											<!--end::Modal dialog-->
										</div>
										<!--end::Modal - Add task-->
									</div>
									<!--end::Card toolbar-->
								</div>
								<!--end::Card header-->
								<!--begin::Card body-->
								<div class="card-body pt-0">
									<!--begin::Table-->
                                    <table id="datatable_nuasix_default" class="table table-row-bordered gy-5">
                                        <thead>
                                            <tr class="fw-bold fs-6 text-muted">
												<th class="min-w-125px">Nom</th>
												<th class="min-w-125px">Uniqid</th>
												<th class="text-end min-w-70px">Actions</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                                            foreach($settings as $setting) {?>
                                            
											<tr data-table="<?= encrypt_decrypt("encrypt", "nx_settings", $key_user, $iv_user)?>" data-column_primary="<?= encrypt_decrypt("encrypt", "idSetting", $key_user, $iv_user)?>" data-id="<?= encrypt_decrypt("encrypt", $setting['idSetting'], $key_user, $iv_user)?>" data-method="custom">
												<!--begin::Nom réglage=-->
												<td>
													<a href="index.php?page_slug=profil-setting-single&element=<?= rawurlencode(encrypt_decrypt("encrypt", $setting['idSetting'], $key_user, $iv_user))?>" class="text-gray-800 text-hover-primary mb-1"><?= $setting['setting_name']?></a>
												</td>
												<!--end::Nom réglage-->
												<!--begin::UNIQUE ID-->
												<td><?= $setting['setting_uniqid']?></td>
												<!--end::UNIQUE ID-->
												<!--begin::Action-->
												<td class="text-end">
													<a href="index.php?page_slug=profil-setting-single&element=<?= rawurlencode(encrypt_decrypt("encrypt", $setting['idSetting'], $key_user, $iv_user))?>" class="btn btn-sm btn-icon btn-bg-light btn-active-color-primary">
                                                        <!--begin::Svg Icon | path: assets/media/icons/duotune/general/gen055.svg-->
                                                        <span class="svg-icon svg-icon-muted svg-icon-2hx"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
                                                        <path opacity="0.3" fill-rule="evenodd" clip-rule="evenodd" d="M2 4.63158C2 3.1782 3.1782 2 4.63158 2H13.47C14.0155 2 14.278 2.66919 13.8778 3.04006L12.4556 4.35821C11.9009 4.87228 11.1726 5.15789 10.4163 5.15789H7.1579C6.05333 5.15789 5.15789 6.05333 5.15789 7.1579V16.8421C5.15789 17.9467 6.05333 18.8421 7.1579 18.8421H16.8421C17.9467 18.8421 18.8421 17.9467 18.8421 16.8421V13.7518C18.8421 12.927 19.1817 12.1387 19.7809 11.572L20.9878 10.4308C21.3703 10.0691 22 10.3403 22 10.8668V19.3684C22 20.8218 20.8218 22 19.3684 22H4.63158C3.1782 22 2 20.8218 2 19.3684V4.63158Z" fill="black"/>
                                                        <path d="M10.9256 11.1882C10.5351 10.7977 10.5351 10.1645 10.9256 9.77397L18.0669 2.6327C18.8479 1.85165 20.1143 1.85165 20.8953 2.6327L21.3665 3.10391C22.1476 3.88496 22.1476 5.15129 21.3665 5.93234L14.2252 13.0736C13.8347 13.4641 13.2016 13.4641 12.811 13.0736L10.9256 11.1882Z" fill="black"/>
                                                        <path d="M8.82343 12.0064L8.08852 14.3348C7.8655 15.0414 8.46151 15.7366 9.19388 15.6242L11.8974 15.2092C12.4642 15.1222 12.6916 14.4278 12.2861 14.0223L9.98595 11.7221C9.61452 11.3507 8.98154 11.5055 8.82343 12.0064Z" fill="black"/>
                                                        </svg></span>
                                                        <!--end::Svg Icon-->
                                                    </a>
                                                    <a href="#" class="btn btn-sm btn-icon btn-bg-light btn-active-color-primary" data-action="delete">
                                                        <!--begin::Svg Icon | path: assets/media/icons/duotune/general/gen027.svg-->
                                                        <span class="svg-icon svg-icon-muted svg-icon-2hx"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
                                                        <path d="M5 9C5 8.44772 5.44772 8 6 8H18C18.5523 8 19 8.44772 19 9V18C19 19.6569 17.6569 21 16 21H8C6.34315 21 5 19.6569 5 18V9Z" fill="black"/>
                                                        <path opacity="0.5" d="M5 5C5 4.44772 5.44772 4 6 4H18C18.5523 4 19 4.44772 19 5V5C19 5.55228 18.5523 6 18 6H6C5.44772 6 5 5.55228 5 5V5Z" fill="black"/>
                                                        <path opacity="0.5" d="M9 4C9 3.44772 9.44772 3 10 3H14C14.5523 3 15 3.44772 15 4V4H9V4Z" fill="black"/>
                                                        </svg></span>
                                                        <!--end::Svg Icon-->
                                                    </a>
												</td>
												<!--end::Action-->
											</tr>    
                                            <?php
                                            }
                                            ?>
                                        </tbody>
                                    </table>
                                    <!--end::Table-->
								</div>
								<!--end::Card body-->
							</div>
							<!--end::Card-->
						</div>
						<!--end::Container-->
					</div>

Conseils et liens

Liens vers des ressources utiles pour l'édition de fichier