Jump to content

SUBIECTE NOI
« 1 / 5 »
RSS
Sfat achizitie sistem audio pentr...

tavan fals rigips

Ce preferați: produse mai scumpe ...

Demagnetizare (minimala) ori ba?
 Cum pot sa vad pe un proiector pr...

Joc Drone

Dropshipping

Sfat achizitie AC Gree Fairy vs P...
 MONITOR LG fara sonor !

Batalia pentru Bucuresti - ND, Fi...

Identificare font

problema ping in jocuri online
 Problema calculator

Samsung Galaxy A35

Sfat pentru aprinderea automata a...

Rfg crescut
 

Trimitere email

- - - - -
  • Please log in to reply
2 replies to this topic

#1
bunicu9

bunicu9

    Member

  • Grup: Members
  • Posts: 253
  • Înscris: 14.07.2013
Am o problema la site, unii utilizatori fac cereri de resetare a parolei de zeci de ori in cateva secunde.
Scriptul meu functioneaza normal, dar cred ca sunt niste boti care fac asta.
Ma poate ajuta cineva sa fac o mini protectie?

Am incercat sa introduc asta dar nu am reusit.


Scriptul meu arata asa acum:

Quote

<?php
    if (auth::isSession()) {
    header("Location: /account/wall");
    }
    $email = '';
    $error = false;
    $error_message = '';
    $sent = false;
    if ( isset($_GET['sent']) ) {
    $sent = isset($_GET['sent']) ? $_GET['sent'] : 'false';
    if ($sent === 'success') {
    $sent = true;
    } else {
    $sent = false;
    }
    }
    if (!empty($_POST)) {
    $email = isset($_POST['email']) ? $_POST['email'] : '';
    $token = isset($_POST['authenticity_token']) ? $_POST['authenticity_token'] : '';
    $email = helper::clearText($email);
    $email = helper::escapeText($email);
    if (auth::getAuthenticityToken() !== $token) {
    $error = true;
    $error_message[] = $LANG['msg-error-unknown'];
    }
    if (!helper::isCorrectEmail($email)) {
    $error = true;
    $error_message[] = $LANG['msg-email-incorrect'];
    }
    if ( !$error && !$helper->isEmailExists($email) ) {
    $error = true;
    $error_message[] = $LANG['msg-email-not-found'];
    }
    if (!$error) {
    $accountId = $helper->getUserIdByEmail($email);
    if ($accountId != 0) {
    $account = new account($dbo, $accountId);
    $accountInfo = $account->get();
    if ($accountInfo['error'] === false && $accountInfo['state'] != ACCOUNT_STATE_BLOCKED) {
    $clientId = 0; // Desktop version
    $restorePointInfo = $account->restorePointCreate($email, $clientId);
    ob_start();
    ?>
    <html>
<head>
</head>
    <body>
<p>..</p>

    </body>
    </html>
<?php
  
  
require_once '../class/SMTPMailer.php';
$subject = APP_TITLE." | Password reset";
$sitename = APP_TITLE;
$sitedomain = APP_URL;
$to = $email;

$mail = new SMTPMailer();
$mail->addTo($to);
$mail->Subject($subject);
$mail->Body(
    '<h3>Dear </h3>
    <p>You requested to reset your password. Follow this link <a href="'.$sitedomain.'/restore/?hash='.$restorePointInfo['hash'].'">'.$sitedomain.'/restore/?hash='.$restorePointInfo['hash'].'</a> to change your password. </p>
<h3>Thank you, '.$sitename.'</h3>'
);
    if ($mail->Send()) echo 'Mail sent successfully';
    else    echo 'Mail failure';
    }
    }
    $sent = true;
    header("Location: /remind/?sent=success");
    }
    }
    auth::newAuthenticityToken();
    $page_id = "restore";
    $css_files = array("main.css", "my.css");
    $page_title = $LANG['page-restore']." | ".APP_TITLE;
    include_once("../html/common/header.inc.php");
?>
<body class="remind-page" onload="createCaptcha()">
<script>
var code;
function createCaptcha() {
  //clear the contents of captcha div first
  document.getElementById('captcha').innerHTML = "";
  var charsArray =
  "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@!#$%^&*";
  var lengthOtp = 6;
  var captcha = [];
  for (var i = 0; i < lengthOtp; i++) {
    //below code will not allow Repetition of Characters
    var index = Math.floor(Math.random() * charsArray.length + 1); //get the next character from the array
    if (captcha.indexOf(charsArray[index]) == -1)
  captcha.push(charsArray[index]);
    else i--;
  }
  var canv = document.createElement("canvas");
  canv.id = "captcha";
  canv.width = 100;
  canv.height = 50;
  var ctx = canv.getContext("2d");
  ctx.font = "25px Georgia";
  ctx.strokeText(captcha.join(""), 0, 30);
  //storing captcha so that can validate you can save it somewhere else according to your specific requirements
  code = captcha.join("");
  document.getElementById("captcha").appendChild(canv); // adds the canvas to the body element
}
function validateCaptcha() {
  event.preventDefault();
  debugger
  if (document.getElementById("cpatchaTextBox").value == code) {
    alert("Valid Captcha")
  }else{
    alert("Invalid Captcha. try Again");
    createCaptcha();
  }
}
</script>
    <?php
    include_once("../html/common/topbar.inc.php");
    ?>
    <div class="wrap content-page">
    <div class="main-column">
    <div class="main-content">
    <div class="standard-page">
    <?php
    if ($sent) {
    ?>
    <h1><?php echo $LANG['page-restore']; ?></h1>
    <div class="opt-in">
    <label for="user_receive_digest">
    <b><?php echo $LANG['msg-reset-password-sent']; ?></b>
    </label>
    </div>
    <?php
    } else {
    ?>
    <h1><?php echo $LANG['page-restore']; ?></h1>
    <form onsubmit="validateCaptcha()" accept-charset="UTF-8" action="/remind" class="custom-form" id="remind-form" method="post">
    <input id="email" name="email" placeholder="<?php echo $LANG['label-email']; ?>" required="required" size="30" type="text" value="<?php echo $email; ?>">
    <input autocomplete="off" type="hidden" name="authenticity_token" value="<?php echo helper::getAuthenticityToken(); ?>">
  
<br>
  <form onsubmit="validateCaptcha()">
    <div id="captcha">
    </div>
    <input type="text" placeholder="Captcha" id="cpatchaTextBox"/>
<br>
  
    <div class="login-button">
    <input name="commit" type="submit" class="blue" value="<?php echo $LANG['action-next']; ?>">
    </div>

  
    </form>
    <?php
    }
    ?>
    </div>
    </div>
    </div>
    </div>
    <?php
    include_once("../html/common/footer.inc.php");
    ?>
</body>
</html>


Cand incerc sa resetez parola, introduc codul, imi raspunde "Valid Captcha", dar nu se trimite.

#2
OriginalCopy

OriginalCopy

    I'm harmful, fear me please! :))

  • Grup: Senior Members
  • Posts: 27,268
  • Înscris: 10.08.2006
Folosește reCaptcha de la google.

#3
bunicu9

bunicu9

    Member

  • Grup: Members
  • Posts: 253
  • Înscris: 14.07.2013
Am reusit, multumesc!

Edited by bunicu9, 15 July 2019 - 17:48.


Anunturi

Chirurgia spinală minim invazivă Chirurgia spinală minim invazivă

Chirurgia spinală minim invazivă oferă pacienților oportunitatea unui tratament eficient, permițându-le o recuperare ultra rapidă și nu în ultimul rând minimizând leziunile induse chirurgical.

Echipa noastră utilizează un spectru larg de tehnici minim invazive, din care enumerăm câteva: endoscopia cu variantele ei (transnazală, transtoracică, transmusculară, etc), microscopul operator, abordurile trans tubulare și nu în ultimul rând infiltrațiile la toate nivelurile coloanei vertebrale.

www.neurohope.ro

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Forumul Softpedia foloseste "cookies" pentru a imbunatati experienta utilizatorilor Accept
Pentru detalii si optiuni legate de cookies si datele personale, consultati Politica de utilizare cookies si Politica de confidentialitate