amodkarmarkar Posted October 14, 2013 Share Posted October 14, 2013 Hi all, Is the above subject possible. If yes can someone help in this matter. Regards Amod Link to comment Share on other sites More sharing options...
vekia Posted October 14, 2013 Share Posted October 14, 2013 it is possible, if I were you i will change Validate.php class (classes/Validate.php) there is a function which checking birthdate format: public static function isBirthDate($date) add there if condition to check age: if (date('Y')-$birth_date[1]<=18) return false; final code of isBirtDate function: public static function isBirthDate($date) { if (empty($date) || $date == '0000-00-00') return false; if (preg_match('/^([0-9]{4})-((?:0?[1-9])|(?:1[0-2]))-((?:0?[1-9])|(?:[1-2][0-9])|(?:3[01]))([0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date, $birth_date)) { if (date('Y')-$birth_date[1]<=18) return false; if ($birth_date[1] > date('Y') && $birth_date[2] > date('m') && $birth_date[3] > date('d')) return false; return true; } return false; } voila 3 Link to comment Share on other sites More sharing options...
tuk66 Posted October 14, 2013 Share Posted October 14, 2013 How you can do it if everybody can cheat. Link to comment Share on other sites More sharing options...
vekia Posted October 14, 2013 Share Posted October 14, 2013 that's correct, but in some countries you have to block possibility to "watch" or "order" adult contents. May i know where you live? here, in europe, in several countries we have really weirdy law in some cases (like cookies notification: LOL) Link to comment Share on other sites More sharing options...
amodkarmarkar Posted October 14, 2013 Author Share Posted October 14, 2013 Thank you Vekia it helped. Tuk 66: Even though it is needed. Again Vekia: I am from india. It is not about adult site. Here technically online purchaser must be 18 and above. Some Obey some dont. Regards Amod Link to comment Share on other sites More sharing options...
vekia Posted October 14, 2013 Share Posted October 14, 2013 thank you for information that it works i marked this thread as [solved] now we have working solution and new feature in validation class with regards, Milos Link to comment Share on other sites More sharing options...
sooroos Posted April 1, 2014 Share Posted April 1, 2014 it is possible, if I were you i will change Validate.php class (classes/Validate.php) there is a function which checking birthdate format: public static function isBirthDate($date) add there if condition to check age: if (date('Y')-$birth_date[1]<=18) return false; final code of isBirtDate function: public static function isBirthDate($date) { if (empty($date) || $date == '0000-00-00') return false; if (preg_match('/^([0-9]{4})-((?:0?[1-9])|(?:1[0-2]))-((?:0?[1-9])|(?:[1-2][0-9])|(?:3[01]))([0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date, $birth_date)) { if (date('Y')-$birth_date[1]<=18) return false; if ($birth_date[1] > date('Y') && $birth_date[2] > date('m') && $birth_date[3] > date('d')) return false; return true; } return false; } voila hi vekia this condition is not really accurate. We are now for example in 2014 and let say some1 turned 18 last or any oder day this year. the condition wont work. It is now taking into account only customers that have been born until 31 - Dec - 1995 Link to comment Share on other sites More sharing options...
sooroos Posted April 1, 2014 Share Posted April 1, 2014 hi vekia this condition is not really accurate. We are now for example in 2014 and let say some1 turned 18 last or any oder day this year. the condition wont work. It is now taking into account only customers that have been born until 31 - Dec - 1995 the conndition must be written according to entire date not only year if (date('Y')-$birth_date[1]<=18) Link to comment Share on other sites More sharing options...
sooroos Posted April 2, 2014 Share Posted April 2, 2014 the right code for this seems to be this one public static function isBirthDate($date) { if (empty($date) || $date == '0000-00-00') return false; if (preg_match('/^([0-9]{4})-((?:0?[1-9])|(?:1[0-2]))-((?:0?[1-9])|(?:[1-2][0-9])|(?:3[01]))([0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date, $birth_date)) { if ((floor((time() - strtotime($date))/31556926))<18) return false; if ($birth_date[1] > date('Y') && $birth_date[2] > date('m') && $birth_date[3] > date('d')) return false; return true; } return false; } i have tested and it works 1 1 Link to comment Share on other sites More sharing options...
sooroos Posted April 11, 2014 Share Posted April 11, 2014 (edited) it worked for 1.5 but seems like it wont work for 1.6 edit: it works with my code in 1.6 too the problem is that i couldnt override the class. i have modified the original file Edited April 11, 2014 by sooroos (see edit history) Link to comment Share on other sites More sharing options...
AlexProgramador Posted May 13, 2014 Share Posted May 13, 2014 the right code for this seems to be this one public static function isBirthDate($date) { if (empty($date) || $date == '0000-00-00') return false; if (preg_match('/^([0-9]{4})-((?:0?[1-9])|(?:1[0-2]))-((?:0?[1-9])|(?:[1-2][0-9])|(?:3[01]))([0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date, $birth_date)) { if ((floor((time() - strtotime($date))/31556926))<18) return false; if ($birth_date[1] > date('Y') && $birth_date[2] > date('m') && $birth_date[3] > date('d')) return false; return true; } return false; } i have tested and it works Thank you, works perfectly. Only need to change the error message log(if you are not 18 years old), but that's no problem. Link to comment Share on other sites More sharing options...
miguelhtc19 Posted June 6, 2014 Share Posted June 6, 2014 (edited) Thanks is helpful follow all the steps, I run into prestashop. 1 6 Edited June 6, 2014 by miguelhtc19 (see edit history) Link to comment Share on other sites More sharing options...
Nanou2301 Posted August 25, 2014 Share Posted August 25, 2014 Thank you, works perfectly. Only need to change the error message log(if you are not 18 years old), but that's no problem. Hi, Could you please explain how do you change the error message log only if the user isn't 18 years old ? Thank you Link to comment Share on other sites More sharing options...
vekia Posted August 25, 2014 Share Posted August 25, 2014 you can do it with code like: if (Validate::isBirthDate($date)==false) { echo "you aren't 18 years old"; } Link to comment Share on other sites More sharing options...
Nanou2301 Posted August 25, 2014 Share Posted August 25, 2014 you can do it with code like: if (Validate::isBirthDate($date)==false) { echo "you aren't 18 years old"; } Thank you for your answer ! But could you precise me where I have to write this ? Because .tpl files don't support php code... Link to comment Share on other sites More sharing options...
vekia Posted August 25, 2014 Share Posted August 25, 2014 but i don't know what you're trying to achieve please shed some more light on this Link to comment Share on other sites More sharing options...
Nanou2301 Posted August 25, 2014 Share Posted August 25, 2014 but i don't know what you're trying to achieve please shed some more light on this For example, if an user isn't 18 years old and try to create an account, the error message says "you aren't 18 years old". 1 Link to comment Share on other sites More sharing options...
paez903 Posted September 1, 2014 Share Posted September 1, 2014 (edited) For example, if an user isn't 18 years old and try to create an account, the error message says "you aren't 18 years old". ve a tu pagina/translations/es o en/errors.php y busca la linea 736 donde dice Fecha de nacimiento inválida cambialo por Debe tener 18 años de Edad para poder Registrarte en nuestra Tienda o algo asi. cierra guardas los cambios y listo lo hice asi y me funciona de maravilla claro con el codigo que ustedes me dieron. IF YOU WANT TO LOOK AT THE PAGE THAT I TEST AND TRY TO REGISTER WITH A DATE TO BE MINOR AND WATCH THE NOTICE GOES www.nino.hol.es Edited September 3, 2014 by paez903 (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted September 1, 2014 Share Posted September 1, 2014 For example, if an user isn't 18 years old and try to create an account, the error message says "you aren't 18 years old". so, you followed guidelines that i mentioned severa posts before? an answer for your question is there just follow guidelines, apply code that i suggested to use (and sooroos) and it will work ve a tu pagina/translations/es o en/errors.php y busca la linea 736 donde dice Fecha de nacimiento inválida cambialo por Debe tener 18 años de Edad para poder Registrarte en nuestra Tienda o algo asi. cierra guardas los cambios y listo lo hice asi y me funciona de maravilla claro con el codigo que ustedes me dieron. i don't understand please in english here Link to comment Share on other sites More sharing options...
paez903 Posted September 2, 2014 Share Posted September 2, 2014 (edited) sorry was not my intention, first of all go to your website via FTP, and seeks the following address: name of your page / translations / en / errors.php and Find the line where it says 736 invalid Birthdate By change it must be 18 years of age to check in our store or message you want it to say. Guard changes and ready. I did it that way and it works to perfection and use the story to the code that provided in this topic. IF YOU WANT TO LOOK AT THE PAGE THAT I TEST AND TRY TO REGISTER WITH A DATE TO BE MINOR AND WATCH THE NOTICE GOES www.nino.hol.es Edited September 3, 2014 by paez903 (see edit history) Link to comment Share on other sites More sharing options...
paez903 Posted September 2, 2014 Share Posted September 2, 2014 so, you followed guidelines that i mentioned severa posts before? an answer for your question is there just follow guidelines, apply code that i suggested to use (and sooroos) and it will work i don't understand please in english here sorry was not my intention, first of all go to your website via FTP, and seeks the following address: name of your page / translations / en / errors.php and Find the line where it says 736 invalid Birthdate By change it must be 18 years of age to check in our store or message you want it to say. Guard changes and ready. I did it that way and it works to perfection and use the story to the code that provided in this topic. Link to comment Share on other sites More sharing options...
iip Posted November 22, 2014 Share Posted November 22, 2014 (edited) Hi can you tell me if this Validate.php has to be edited with Notepad++ only or it can be edited with regular notepad also? Edited November 22, 2014 by iip (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted November 23, 2014 Share Posted November 23, 2014 Hi can you tell me if this Validate.php has to be edited with Notepad++ only or it can be edited with regular notepad also? better to edit with notepad++ because it will handle proper coding of file. in some cases simple notepad can change the file encoding and you will have little troubles with BOM (weirdy chars at the begining of the file). it can affect many things. Link to comment Share on other sites More sharing options...
paez903 Posted November 23, 2014 Share Posted November 23, 2014 Cheers for that I do not complicate sending the file to copy it and sin as it appears therein are indications that must do to detail. you click here 1 Link to comment Share on other sites More sharing options...
iip Posted November 24, 2014 Share Posted November 24, 2014 better to edit with notepad++ because it will handle proper coding of file. in some cases simple notepad can change the file encoding and you will have little troubles with BOM (weirdy chars at the begining of the file). it can affect many things. Thank you, yes i think i recently had troubles when editing with just notepad so i had to restore the language to fix it. So in order to set limitation to age on my website i just have to edit validate.php file the way you wrote on the begining of this thread right? Link to comment Share on other sites More sharing options...
KevinNash Posted December 23, 2014 Share Posted December 23, 2014 you can do it with code like: if (Validate::isBirthDate($date)==false) { echo "you aren't 18 years old"; } Hi I tried to place that code on several places in Validate.php but I got an error each time. Can you give me the full piece of code master Vekia ? 1 Link to comment Share on other sites More sharing options...
vondrys Posted January 4, 2015 Share Posted January 4, 2015 Hi, I'm using pres 1.6 and it doesn't work for me too.... Link to comment Share on other sites More sharing options...
Kai2040 Posted May 10, 2015 Share Posted May 10, 2015 (edited) where can i find the validate.php file? I have looked in override/classes and theres nothing. Edited May 10, 2015 by Kai2040 (see edit history) Link to comment Share on other sites More sharing options...
visualcd Posted April 21, 2017 Share Posted April 21, 2017 Sorry to revive old topic. I use PS 1.6 and it worked for me. Just want to say Thank you ! it is possible, if I were you i will change Validate.php class (classes/Validate.php) there is a function which checking birthdate format: public static function isBirthDate($date) add there if condition to check age: if (date('Y')-$birth_date[1]<=18) return false; final code of isBirtDate function: public static function isBirthDate($date) { if (empty($date) || $date == '0000-00-00') return false; if (preg_match('/^([0-9]{4})-((?:0?[1-9])|(?:1[0-2]))-((?:0?[1-9])|(?:[1-2][0-9])|(?:3[01]))([0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date, $birth_date)) { if (date('Y')-$birth_date[1]<=18) return false; if ($birth_date[1] > date('Y') && $birth_date[2] > date('m') && $birth_date[3] > date('d')) return false; return true; } return false; } voila Link to comment Share on other sites More sharing options...
Recommended Posts