Advertisement
Guest User

Untitled

a guest
Jun 14th, 2017
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.67 KB | None | 0 0
  1. <?php
  2. require_once "maincore.php";
  3. require_once THEMES."templates/header.php";
  4.  
  5. $db2_host = "localhost";
  6. $db2_user = "***";
  7. $db2_pass = "***";
  8. $db2_name = "account";
  9.  
  10. $db312_link = mysql_connect($db2_host, $db2_user, $db2_pass) OR die("Nu sa putut conecta la baza de date.");
  11. @mysql_select_db($db2_name) or die( "Baza de date nu poate fi selectata.");
  12.    
  13.     $get_code = isset($_GET['confirm']) ? cleanurl(stripinput($_GET['confirm'])) : "";
  14.     if(isset($_GET['email'])) {
  15.     $get_mail = preg_match("/^[-0-9A-Z_\.]{1,50}@([-0-9A-Z_\.]+\.){1,50}([0-9A-Z]){2,4}$/i", $_GET['email']) ? $_GET['email'] : "";
  16.     }
  17.     if(!empty($get_code) && !empty($get_mail)){
  18.         $dbselect = dbquery("SELECT cod_unic, actiontime FROM account WHERE Email = '".$get_mail."'");
  19.         if(dbrows($dbselect)) {
  20.         $getdata = dbarray($dbselect);
  21.         $calculate_time = time() - $getdata['actiontime'];
  22.             if($calculate_time < 86400) {
  23.                 $chars = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789-_!@";
  24.                 $char_count = strlen($chars) - 1;
  25.                 $new_pass = "";
  26.                 for ($i = 0; $i < 8; $i++) {
  27.                     $new_pass .= substr($chars, mt_rand(0, $char_count), 1);
  28.                 }
  29.                 $update_pass = dbquery("UPDATE `account` SET `Password` = password('$new_pass') WHERE `Email` = '".$get_mail."' LIMIT 1");
  30.                 if($update_pass) {
  31.                 opentable("Verifica e-mail");
  32.                     $to = $get_mail;
  33.                     $subject = "Recuperare parola Metin2Tim!";
  34.                     $header = "From: Metin2TIM@Metin2TiM.ro";
  35.                     $body = "Noua ta parola este: ".$new_pass." ";
  36.                     if (mail($to, $subject, $body,$header)) {
  37.                     echo "<center>Noua parola a fost trimisa pe e-mail!</center>";
  38.                     } else {
  39.                     echo "<center>A intervenit o eroare incercati inca odata.</center>";
  40.                     }
  41.                 closetable();
  42.                 } else {
  43.                     echo "ERROR!!!";
  44.                 }
  45.             } else {
  46.             opentable("Eroare");
  47.             echo "<center>Acest link a expirat.</center>";
  48.             closetable();
  49.             }
  50.         } else {
  51.             opentable("Eroare");
  52.             echo "<center>A intervenit o eroare incercati inca odata.</center>";
  53.             closetable();
  54.         }
  55.     } else {
  56.         if(!isset($_POST['Email'])) {
  57.         opentable("Recupereaza parola");
  58.         if (iSUPERADMIN) {
  59.         echo "<form action='' method='post'>";
  60.         echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border' align='center'>\n";
  61.         echo "<tr>";
  62.         echo "<td class='tbl2' width='121' valign='top' align='right'>E-mail:</td>";
  63.         echo "<td class='tbl2' width='370' align='left' ><input type='text' name='Email' id='Email' size='43' maxlength='43' class='textbox'></td>";
  64.         echo "</tr>";
  65.         echo "</table>";
  66.         echo "<center><input type='submit' border='0' name='recover' class='button' value='Trimite-mi parola'></center>";
  67.         echo "</form>";
  68.         } else {
  69.         echo "<div style='text-align:center'><br />Ne pare r&#259u dar accesul pe aceast&#259 pagin&#259 este restrictionat!<br /><br />\n</div>\n";
  70.         }
  71.         closetable();
  72.         } else {
  73.             if (!preg_match("/^[-0-9A-Z_\.]{1,50}@([-0-9A-Z_\.]+\.){1,50}([0-9A-Z]){2,4}$/i", $_POST['Email'])) {
  74.             $error = "Adresa de E-Mail introdusa nu este valida.<br />\n";
  75.             }
  76.             if(empty($error)) {
  77.             $res = dbquery("SELECT * FROM account WHERE Email = '".$_POST['Email']."' ");
  78.                 if(dbrows($res)) {
  79.                 $chars = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789-_!@";
  80.                 $char_count = strlen($chars) - 1;
  81.                 $cod_unic = "";
  82.                 for ($i = 0; $i < 8; $i++) {
  83.                     $cod_unic .= substr($chars, mt_rand(0, $char_count), 1);
  84.                 }
  85.                 $db_update = dbquery("UPDATE `account` SET `cod_unic` = password('$cod_unic'),
  86.                                                     `actiontime` = '".time()."' WHERE `Email` ='".$_POST['Email']."' LIMIT 1 ;");
  87.                     if($db_update) {
  88.                         $to = $_POST['Email'];
  89.                         $subject = "Recuperare parola Metin2TIM!";
  90.                         $header = "From: NoReply@Metin2TIM.ro";
  91.                         $body = "Pentru confirmare acceseaza urmatorul link: ".$settings['siteurl']."recover-1.php?confirm=".$cod_unic."&email=".$_POST['Email']." ";
  92.                         if (mail($to, $subject, $body,$header)) {
  93.                         opentable("Verifica E-Mail");
  94.                         echo "<center>In scurt timp vei primi un E-Mail pentru confirmare.</center>";
  95.                         closetable();
  96.                         } else {
  97.                         opentable("Eroare");
  98.                         echo "<center>A aparut o eroare. Mai incearca odata.</center>";
  99.                         closetable();
  100.                         }
  101.                     } else {
  102.                     opentable("Eroare");
  103.                     echo "<center>A aparut o eroare. Mai incearca odata.</center>";
  104.                     closetable();
  105.                     }
  106.                 } else {
  107.                     opentable("Eroare");
  108.                     echo "<center>Adresa de E-Mail introdusa nu se afla in baza noastra de date.</center>";
  109.                     closetable();
  110.                 }
  111.             } else {
  112.             opentable("Eroare");
  113.             echo $error;
  114.             closetable();
  115.             }
  116.         }
  117.     }
  118.  
  119. mysql_close($db312_link);
  120. $link = dbconnect($db_host, $db_user, $db_pass, $db_name);
  121. require_once THEMES."templates/footer.php";
  122. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement