Computers Windows Internet

Disaster date gos reg html. Domain name renewal date monitoring. Now let's create the main scripts for further work.

Good day friends! Let's take a look at user registration in PHP with you. First, let's define the conditions for our user registration:

  • We encrypt the password using the algorithm MD5
  • The password will be "salted"
  • Check if Login is busy
  • User activation by letter.
  • Writing and storing data in MySQL DBMS

To write this script, we need to understand what user registration is. User registration is receiving data from a real user, processing and storing data.

If explain in simple words then registration is just the recording and storage of certain data by which we can authorize the user in our case - this is Login and Password.

Authorization is the granting of a certain person or group of persons the rights to perform certain actions, as well as the process of verifying these rights when trying to perform these actions. Simply put, using authorization, we can delimit access to this or that content on our website.

Let's consider the structure of the script directories for the implementation of our registration with authorization. We need to break scripts into logical components. We have placed the registration and authorization modules in a separate directory. We will also place the connection to the database in separate directories. MySQL, file with custom functions, style file CSS and our template Html... This structure allows you to quickly navigate the scripts. Imagine you have a large site with a bunch of modules, etc. and if there is no order, it will be very difficult to find something in such a mess.

Since we will store all data in MySQL DBMS, then let's create a small table in which we will store registration data.

First, you need to create a table in the database. The table will be called bez_reg where bez is the table prefix, and reg name of the table.

Table structure: bez_reg

- - Table structure `bez_reg` - CREATE TABLE IF NOT EXISTS` bez_reg` (`id` int (11) NOT NULL AUTO_INCREMENT,` login` varchar (200) NOT NULL, `pass` varchar (32) NOT NULL , `salt` varchar (32) NOT NULL,` active_hex` varchar (32) NOT NULL, `status` int (1) NOT NULL, PRIMARY KEY (` id`)) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1;

Now let's create the main scripts for further work.

INDEX.PHP File

CONFIG.PHP File

"); ?>

404.html file

Error 404

Error 404

A 404 error occurred on the page

Return


BD.PHP File

INDEX.HTML File

PHP MySQL user registration with email activation



FUNCT.PHP File

"." \ n "; if (is_array ($ data)) (foreach ($ data as $ val) $ err. ="

  • ". $ val."
  • "." \ n ";) else $ err. ="
  • ". $ data."
  • "." \ n "; $ err. =""." \ n "; return $ err;) / ** Simple wrapper for MySQL queries * @param string $ sql * / function mysqlQuery ($ sql) ($ res = mysql_query ($ sql); / * Checking the result This shows the real query sent to MySQL, as well as the error. Convenient for debugging. * / if (! $ res) ($ message = "Invalid query:". mysql_error (). "\ n"; $ message. = "Query in full : ". $ sql; die ($ message);) return $ res;) / ** Simple salt generator * @param string $ sql * / function salt () ($ salt = substr (md5 (uniqid ()), - 8); return $ salt;)

    Let's get down to writing registration. First, we will need to make a registration form template so that the user can enter his data for processing. Next, we will need to write the form handler itself, which will check the entered user data for correctness. After the data has been successfully verified, we write them into our database and send a letter to the user to activate his account.

    REG.PHP file

    You have successfully registered! Please activate your account !!"; // Activate the account if (isset ($ _ GET [" key "])) (// Check the key $ sql =" SELECT * FROM `". BEZ_DBPREFIX. "Reg` WHERE` active_hex` = "". Escape_str ( $ _GET ["key"]). "" "; $ Res = mysqlQuery ($ sql); if (mysql_num_rows ($ res) == 0) $ err =" The activation key is not correct! "; // Check for errors and display to the user if (count ($ err)> 0) echo showErrorMessage ($ err); else (// Get the user's address $ row = mysql_fetch_assoc ($ res); $ email = $ row ["login"]; // Activate the account user $ sql = "UPDATE` ". BEZ_DBPREFIX." reg` SET `status` = 1 WHERE` login` = "". $ email. "" "; $ res = mysqlQuery ($ sql); // Send an email to activate $ title = "(! LANG: Your account on http: // site has been successfully activated"; $message = "Поздравляю Вас, Ваш аккаунт на http://сайт успешно активирован"; sendMessageMail($email, BEZ_MAIL_AUTOR, $title, $message); /*Перенаправляем пользователя на нужную нам страницу*/ header("Location:". BEZ_HOST ."less/reg/?mode=reg&active=ok"); exit; } } /*Если нажата кнопка на регистрацию, начинаем проверку*/ if(isset($_POST["submit"])) { //Утюжим пришедшие данные if(empty($_POST["email"])) $err = "Поле Email не может быть пустым!"; else { if(!preg_match("/^!} [email protected](+ \.) + (2,6) $ / i ", $ _POST [" email "])) $ err =" E-mail entered incorrectly "." \ N ";) if (empty ($ _ POST [ "pass"])) $ err = "The Password field cannot be empty"; if (empty ($ _ POST ["pass2"])) $ err = "The Confirm password field cannot be empty"; // Check for errors and display to the user if (count ($ err)> 0) echo showErrorMessage ($ err); else (/ * Continue checking the entered data Check passwords for matching * / if ($ _ POST ["pass"]! = $ _POST ["pass2" ]) $ err = "Passwords do not match"; // Check for errors and display it to the user if (count ($ err)> 0) echo showErrorMessage ($ err); else (/ * Check if we have such a user in the database * / $ sql = "SELECT` login` FROM `". BEZ_DBPREFIX. "reg` WHERE` login` = "". escape_str ($ _ POST ["email"]). "" "; $ res = mysqlQuery ($ sql); if (mysql_num_rows ($ res)> 0) $ err = "Sorry Login: ". $ _POST [" email "]." busy! "; // Check for errors and display it to the user if (count ($ err)> 0) echo showErrorMessage ($ err); else (// Get the HASH of the salt $ salt = salt (); // Salt the password $ pass = md5 (md5 ($ _ POST ["pass"]). $ salt); / * If all is well, write the data to the database * / $ sql = "INSERT INTO` ". BEZ_DBPREFIX." reg` VALUES ("", "" . escape_str ($ _ POST ["email"]). "", "". $ pass. "", "". $ salt. "", "". md5 ($ salt). "", 0) "; $ res = mysqlQuery ($ sql); // Sending an email to activate $ url = BEZ_HOST. "less / reg /? mode = reg & key =". md5 ($ salt); $ title = "(! LANG: Registration on http: / /site"; $message = "Для активации Вашего акаунта пройдите по ссылке ". $url .""; sendMessageMail($_POST["email"], BEZ_MAIL_AUTOR, $title, $message); //Сбрасываем параметры header("Location:". BEZ_HOST ."less/reg/?mode=reg&status=ok"); exit; } } } } ?>!}

    REG_FORM.HTML File

    PHP MySQL user registration with email activation

    Email *:
    Password *:
    Password confirmation *:

    Fields with an icon * are required

    Since we are ready to register users, it's time to write an authorization. Let's create a form for user authorization, then write an authorization form handler and finally make a script show.php which will show us whether we are authorized in the system or not.

    AUTH.PHP file

    0) echo showErrorMessage ($ err); else (/ * Create a query to fetch from the database to check the authenticity of the user * / $ sql = "SELECT * FROM` ". BEZ_DBPREFIX." reg` WHERE `login` =" ". escape_str ($ _ POST [" email "]) . "" AND `status` = 1"; $ res = mysqlQuery ($ sql); // If the login matches, check the password if (mysql_num_rows ($ res)> 0) (// Get data from the table $ row = mysql_fetch_assoc ( $ res); if (md5 (md5 ($ _ POST ["pass"]). $ row ["salt"]) == $ row ["pass"]) ($ _SESSION ["user"] = true; // Reset parameters header ("Location:". BEZ_HOST. "Less / reg /? Mode = auth"); exit;) else echo showErrorMessage ("Wrong password!");) Else echo showErrorMessage ("Login ". $ _POST [" email "]." not found! ");))?>

    For those who have the latest version of PHP, I post this script using PDO since extension MySQL deprecated and removed from the newer PHP version. Download registration and authorization php mysql pdo

    The archive was updated on February 24, 2015.

    Attention: If you are using this script on a local server like DENWER,XAMPP, then you should not wait for letters to your mailbox. Letters are in a blank sendmail... V Denwer you can find them along the way Z: \ tmp \! Sendmail \ you can open these files in any mail client.

    If the renewal of the .RU, .РФ and SU domain registration service is not paid before its expiration date, the service is suspended (domain delegation is canceled) on the day specified in the paid-till field in the Whois service. If the scheduled shutdown date falls on a weekend or holiday, the domain shutdown is carried over to the first business day after the weekend.

    After the suspension of domain delegation, all http requests to the domain are redirected to the service page with information about the temporary failure to provide the service. Administrators of .RU and .РФ domains can refuse to be redirected to the service page before the expiration of the domain name registration period by sending a request in any form to the address.

    Within 30 days after the expiration of the service (during the preferential renewal period), the Registrant of the .RU, .РФ or.SU domains retains the opportunity to pay for its renewal.

    In case of payment, the provision of the service is resumed.

    Removal of .RU, .SU, .РФ domains from the Registry for non-payment

    If the renewal of the domain registration is not paid within 30 days after its end (during the preferential renewal period), the registration is canceled (the domain is released).

    Published in the free-date field of information about the domain after the expiration of its registration period.

    RU-CENTER can delete the .SU domain at any time from the date of the planned free-date. If this does not happen, the domains are automatically deleted by the Technical Center.

    During the pre-emptive renewal period, .RU and .РФ domain names will not be canceled.

    Date of domain deletion by the Technical Center

    Domains .RU, .РФ and SU are deleted by the Technical Center on the day corresponding to the planned date of deletion (free-date).

    Domains .RU, .РФ or.SU will be deleted on the second business day after the weekend, if the date of deletion falls on a weekend or a day following the weekend.

    The procedure for deleting domains in the Technical Center starts working:

    • for domains .RU, .РФ at 17:00 (MSK),
    • for domains.SU at 19:30 (MSK).

    Registration through RU-CENTER of .RU, .SU, .РФ domains subject to release

    Applications for registration of a domain being released from the Registry can be submitted on the www..site / auction / server before the domain is released from the Registry.

    For .RU and .РФ domains, applications begin to be accepted 30 days prior to the day the domain is released from the Registry in accordance with the service for registering the released domain in RU and Russian domains.

    For SU domains - at any time before the domain is released from the Registry in accordance with the registration service for the vacated domain in SU, COM.RU, NET.RU, ORG.RU, PP.RU domains and geodomains.

    For domains .RU, .SU, .РФ - on the day the domain is removed from the Registry through the web interface on the page, while:

    • A letter about the actions taken is sent to the contact addresses of the person who made the application.

    2. International and foreign

    If the renewal of the service is not paid before the expiration of its validity period, the provision of the service is suspended (domain delegation is canceled) the next day after the date specified in the Expiration Date field in. If the scheduled shutdown date falls on a weekend or holiday, the domain shutdown is carried over to the second business day after the weekend.

    Within 30 days after the expiration of the service, the Domain Administrator retains the opportunity to pay for its renewal. In case of payment, the provision of the service is resumed.

    Removing domains from Registries in international and foreign national domains

    If the renewal of domain registration is not paid within 30 days from the date of expiration of the service, RU-CENTER will initiate the domain deletion procedure in the Registry. If the date of deletion falls on a weekend or a holiday, the start of the domain deletion procedure is postponed to the second business day after the weekend.

    The procedure for deleting a domain in the Registry takes 35 days. The exceptions are:

    • .HN domains, the deletion procedure of which lasts 15 days, and the domain cannot be restored or renewed during this period;
    • domains .NAME, which are deleted after 30 days after the expiration of the registration period.
    • domains .KZ, which are deleted after 20 days after the expiration of the registration period.

    In this case, the Registry for 30 days sets the corresponding status for the domain in:
    .NET, .COM, .CC, .TV, .AG, .BZ, .LC, .MN, .SC, .VC - RedemptionPeriod,
    .BIZ, .TEL - Pending Delete,
    .INFO, .ORG, .ME, .MOBI, .AERO, .TRAVEL, .XXX, .PRO - PendingDelete Restorable.

    The start date of the thirty-day period is indicated in the field:
    Updated Date for .NET, .COM, .CC, .TV, .AG, .BZ, .HN, .LC, .MN, .SC, .VC domains
    Domain Last Updated Date - BIZ, .TEL, or
    Last Updated On - INFO, .ORG, .ME, .MOBI, .AERO, .TRAVEL, .XXX, .PRO.

    Domain recovery

    Within 25 days from the start of the deletion procedure, the domain can be restored and renewed (except for .HN, NAME, .KZ) at the request of the Domain Administrator.

    If the domain has not been restored and renewed, it will be removed from the Registry 5 days after the end of the RedemptionPeriod (Pending Delete or PendingDelete Restorable). During these 5 days (domain status in the Registry - PendingDelete), it is impossible to restore, renew or register the domain.

    After the domain is removed from the Registry, the domain can be registered by any person.

    3. Domains of the 3rd level

    Removal of domain delegation for non-payment

    If the renewal of the service is not paid before the expiration of its validity period, the provision of the service is suspended (domain delegation is canceled) the next day after the date specified in the paid-till field in the Whois service. For .NET.RU, .ORG.RU and .PP.RU domains, the service is suspended (domain delegation is canceled) on the day specified in the paid-till field in the Whois service.

    If the scheduled shutdown date falls on a weekend or holiday, the domain shutdown is carried over to the second business day after the weekend.

    After the suspension of domain delegation, all http-requests to the .NET.RU, .ORG.RU and .PP.RU domains are redirected to the official website of the .NET.RU, .ORG.RU and .PP.RU domains Administrator, TsVKS "MSK-IX", with information about the reason for the termination of the delegation.

    Within 30 days after the expiration of the service (pre-emptive renewal period), the Domain Administrator retains the opportunity to pay for its renewal. In case of payment, the provision of the service is resumed.

    During the pre-emptive renewal period, .NET.RU, .ORG.RU and .PP.RU domains will not be canceled.

    If the payment for the service renewal is made on the last working day of the preferential renewal period, RU-CENTER is not responsible for the successful renewal.

    Deleting domains

    Registration of a third-level domain name is canceled (the domain is released) if it is not renewed within 30 (thirty) calendar days from the expiration date of the domain name registration.

    Planned domain release date is published in the free-date field in the domain information in the RU-CENTER Whois service after the expiration of its registration period. In this case, the deletion is made one day later than the planned release date, if the deletion day (free-date + 1) does not fall on a non-working day or the day following a non-working day (otherwise, the deletion is made on the second working day after the weekend).

    The .NET.RU, .ORG.RU and .PP.RU domains are deleted by the Technical Center on the day corresponding to the planned deletion date (free-date). Domains .NET.RU, .ORG.RU and .PP.RU will be deleted on the second business day after the weekend if the date of deletion falls on a weekend or a day following the weekend.

    Registration through RU-CENTER of the third level domains being released

    Applications for registration of vacated domains from the Registry or .COM.RU domains can be submitted on the www..site / auction / server at any time before the domains are released from the Registry in accordance with the service “Registration of vacated domains in the .COM.RU domains and geodomains”.

    On the day of domain deletion, an application for a domain registration service is accepted through the web interface on the page, while:

    • the application is satisfied if at the time of its processing the domain is free;
    • A letter is sent to the contact e-mail addresses of the person who made the application about the actions taken.

    Domain name renewal date monitoring is an action that should not be underestimated. I already wrote about that, and now let's deal with another common problem - the unexpected expiration of the domain name registration period. It would seem that all registrars today remind about this in advance (and usually several times). But the problem is that these letters are either not read, or they somehow end up in spam. In general, not everyone is aware that their domain name registration period is running out. As a result, the site does not work, people do not understand why, and sometimes spend a lot of time to understand what is happening. Meanwhile, the domain name disappears from the DNS cache, and after a couple of days (or even earlier, depending on various factors), visitors stop getting to the site. Let's see how to monitor the expiration date of a domain name registration. Naturally, a bash script.

    How to get the domain name registration date

    The easiest option is to use the global whois database. It stores information about domain names such as organization, person in charge, contact details, registration date and registration expiration date. And this is exactly what we need. Let's take a popular domain as an example. Let it be yandex.ru. Here is the information stored in the whois database about this domain:

    $ whois yandex.ru% By submitting a query to RIPN "s Whois Service% you agree to abide by the following terms of use:% http://www.ripn.net/about/servpol.html#3.2 (in Russian) % http://www.ripn.net/about/en/servpol.html#3.2 (in English). domain: YANDEX.RU nserver: ns1.yandex.ru. 213.180.193.1, 2a02: 6b8 :: 1 nserver: ns2.yandex.ru.93.158.134.1, 2a02: 6b8: 0: 1 :: 1 state: REGISTERED, DELEGATED, VERIFIED org: YANDEX, LLC.registrar: RU-CENTER-RU admin-contact: https: // www. nic.ru/whois created: 1997.09.23 paid-till: 2017.10.01 free-date: 2017.11.01 source: TCI Last updated on 2017.01.03 05:46:31 MSK

    The field we are interested in is "paid-till", this is the date until which we have paid for the domain.

    We will do the monitoring of the domain name renewal date in much the same way as monitoring the certificate, but much easier. We get domain data, look for a field containing the registration expiration date, if it is present (if whois data for this domain is not closed), get this date, get today's date and display the difference in days. If you wish, you can add sending a letter if there is, say, less than 30 days left before the end of registration. But it's not that simple. Because there are at least three types of registration expiration records. The first looks like this:

    Paid-till: 2017.10.01

    The second looks like this:

    Registrar Registration Expiration Date: 2020-09-13T21: 00: 00-0700

    And the third looks like this:

    Registry Expiry Date: 2018-05-11T04: 00: 00Z

    And we, accordingly, need to provide for all three options. Or, if there is a fourth, then the fourth. Let's deal with these three for now.

    This is what the script looks like:

    #! / bin / bash # If the parameter is not specified, display a hint and exit if ["$ 1" == ""] then cat<< EOF Script that monitors how many days left until domain registration ends. Usage: $(basename $0) domain.name EOF exit fi # Получаем строку, содержащую дату окончания регистрации PAIDTILL=$(whois $1 | grep "paid-till\|Registrar Registration Expiration Date\|Registry Expiry Date") # Если такая строка не найдена, выходим с ошибкой if [ -z "$PAIDTILL" ] then echo "Registration end date is not available in whois database" exit 1 else # Если дата выглядит как ГГГГ.ММ.ДД, то добавляем 00:00:00 в конец [[ "$PAIDTILL" =~ "paid-till" ]] && PAIDTILL=${PAIDTILL//./-}" 00:00:00" # Удаляем из строки всё до двоеточия, само двоеточие # плюс автоматически будут удалены пробелы PAIDTILL=${PAIDTILL#*:} # Получаем текущую дату CURRENTDATE=$(date "+%Y-%m-%d %H:%M:%S") # Находим разницу между датами, получаем количество оставшихся дней DAYS_LEFT=$((($(date -d "$PAIDTILL" +%s) - $(date -d "$CURRENTDATE" +%s)) / 86400)) # Выводим, сколько дней осталось echo $DAYS_LEFT days left fi

    Here is the output of this script for different domains at the time of this writing:

    $ ./check-dn-reg.sh linux.org 492 days left $ ./check-dn-reg.sh yahoo.com 2206 days left $ ./check-dn-reg.sh yandex.ru 270 days left $. /check-dn-reg.sh google.com 1349 days left $ ./check-dn-reg.sh ok.ru 331 days left $ ./check-dn-reg.sh vk.com 170 days left $ ./check -dn-reg.sh linux.org 492 days left $ ./check-dn-reg.sh linux.org.ru 345 days left

    Agree, it looks comfortable. Domain name renewal date monitoring with script only 660 bytes in size. It can already be used in monitoring with Nagios or Zabbix.

    If there are additions, comments, write in the comments.