Files
ms1inscription-v5/compte_resend.php
2026-05-13 09:43:32 -04:00

97 lines
5.2 KiB
PHP
Raw Permalink Blame History

<?php
/**
* Created by PhpStorm.
* User: jesse94
* Date: 14-03-27
* Time: 11:12
*/
session_start();
header('Content-type: text/html; charset=UTF-8');
if (isset($_SESSION['usa_id'])) {
require_once "php/inc_fonctions.php";
function fxGetComptes($intCompte, $strCourriel) {
if ($strCourriel != '') {
$sqlComptes = "SELECT com_id, com_nom, com_prenom, com_courriel, com_creation FROM inscriptions_comptes WHERE com_courriel = '" . $objDatabase->fxEscape($strCourriel) . "' AND com_actif = 0";
$tabComptes = $objDatabase->fxGetResults($sqlComptes);
}
else {
$sqlComptes = "SELECT com_id, com_nom, com_prenom, com_courriel, com_login, com_password, com_langue FROM inscriptions_comptes WHERE com_id = " . intval($intCompte);
$tabComptes = $objDatabase->fxGetRow($sqlComptes);
}
return $tabComptes;
}
function fxSendConfirmation($tabCompte, $strCourriel) {
// envoyer un courriel de confirmation
// FRAN<41>AIS
if ($tabCompte['com_langue'] == 'fr') {
$subject = "Activation de votre nouveau compte client";
$body = "Bonjour " . $tabCompte['com_prenom'] . ",\n\nafin d'activer votre compte MS-1, veuillez cliquer sur le lien suivant:\n\n" . $vDomaine . "/compte.php?valider&courriel=" . $tabCompte['com_courriel'] . "&id=" . $tabCompte['com_id'] . "\n\nSi vous ne pouvez cliquer le lien, copiez-le et collez-le dans votre navigateur.\n\nVoici les informations pour acc<63>der <20> votre compte:\n\nNom d'usager: " . $tabCompte['com_login'] . "\nMot de passe: " . $tabCompte['com_password'] . "\n\nVeuillez conserver ces informations.\nMerci\n\n\nMessage envoy<6F> automatiquement par " . $GLOBALS['vClient'] . " le: " . fxRemoveHtml(fxShowDate(fxGetDate(), $tabCompte['com_langue'])) . " @ " . fxGetTime();
}
// ANGLAIS
else {
$subject = "Activation of your new client account";
$body = "Hello " . $tabCompte['com_prenom'] . ",\n\nto complete your " . $GLOBALS['vClient'] . " client account's registration, please click the following link:\n\n" . $vDomaine . "/compte.php?valider&lang=en&courriel=" . $tabCompte['com_courriel'] . "&id=" . $tabCompte['com_id'] . "\n\nIf you can't click it, copy/paste it in your web browser.\n\nHere are your login deails to access your client account:\n\nUsername: " . $tabCompte['com_login'] . "\nPassword: " . $tabCompte['com_password'] . "\n\nPlease keep those details safe.\nThank you\n\n\nAuto-message sent by " . $GLOBALS['vClient'] . " on: " . fxRemoveHtml(fxShowDate(fxGetDate(), $tabCompte['com_langue'])) . " @ " . fxGetTime();
}
return fxSendMail($subject, $body, $strCourriel, $tabCompte['com_prenom'] . ' ' . $tabCompte['com_nom'], $GLOBALS['vEmail'], $GLOBALS['vClient'], 1, 0);
}
header('Content-type: text/html; charset=UTF-8');
if (!isset($_POST['btn_search']) && !isset($_POST['btn_send'])) {
?>
<form action="compte_resend.php" method="post" id="frm_compte" name="frm_compte">
<fieldset>
<label>Courriel du client : (compte inactif seulemnt)</label>
<input type="text" id="txt_courriel_client" name="txt_courriel_client" size="40">
<br>
<button type="submit" id="btn_search" name="btn_search">Rechercher</button>
</fieldset>
</form>
<?php
} elseif (isset($_POST['btn_search']) && !isset($_POST['btn_send'])) {
$tabComptes = fxGetComptes(0, $_POST['txt_courriel_client']);
if ($tabComptes != null) {
?>
<form action="compte_resend.php" method="post" id="frm_compte" name="frm_compte">
<fieldset>
<?php
for ($intCtr = 1; $intCtr <= count($tabComptes); $intCtr++) {
?>
<input type="radio" name="com_id" value="<?php echo $tabComptes[$intCtr]['com_id']; ?>"> <?php echo fxUnescape($tabComptes[$intCtr]['com_nom']); ?>, <?php echo fxUnescape($tabComptes[$intCtr]['com_prenom']); ?> (<?php echo fxUnescape($tabComptes[$intCtr]['com_courriel']); ?>) | <?php echo fxShowDate($tabComptes[$intCtr]['com_creation'], 'fr'); ?> @ <?php echo fxShowTime($tabComptes[$intCtr]['com_creation']); ?>
<br>
<?php
}
?>
<br>
<label>Courriel à qui envoyer :</label>
<input type="text" id="txt_courriel_send" name="txt_courriel_send" size="40">
<br>
<button type="submit" id="btn_send" name="btn_send">Envoyer</button>
</fieldset>
</form>
<?php
} else {
?>
<p>Aucun compte pour ce courriel.</p>
<p><a href="compte_resend.php">&raquo; retour</a></p>
<?php
}
} elseif (isset($_POST['btn_send'])) {
$tabCompte = fxGetComptes($_POST['com_id'], '');
$blnEnvoi = fxSendConfirmation($tabCompte, $_POST['txt_courriel_send']);
if ($blnEnvoi == 1) {
echo "Envoi réussi !";
} else {
echo "Envoi échoué !";
}
}
} else {
echo '<h1>Accès refusé!</h1>';
}