How to check password requirement in Prestashop? - passwords

In Prestashop 1.5, the code to check if the customer password has 5 characters is located in Validate.php file and is the following :
public static function isPasswd($passwd, $size = 5)
{
return (Tools::strlen($passwd) >= $size && Tools::strlen($passwd) < 255);
}
Would anyone know how to change it, in order to check if the password complies with the five here below rules :
at least 8 characters
at least one uppercase
at least one lowercase
at least one special character
at least one digit
Thank you any advance for any help in this matter.
Patrick

In PrestaShop 8, there will be a new password policy with the implementation of zxcvbn. You can see the implementation here:
https://github.com/PrestaShop/PrestaShop/pull/28127
You can modify the isPasswd function and implement the checks you need. Here's an example of doing so:
Password strength check in PHP
One more thing. This might not be the answer to your original question, but the truth is that if you still use PrestaShop 1.5, you should upgrade as soon as possible.

Related

PageNumber in Scripts for ActiveReports 7

I'm not very used to Active Reports and I got an old software using those. The software provide some kind of stripped version of Active Reports Designer 7.
I got a PageFooter section with some fields and I want to remove one to display it only when it's the last page.
Basically, what I want to do is this in scripts :
if (this.PageNumber == this.PageCount) {
Field.Visible = true;
}
I only find one post here that say this.PageNumber should work, but it dosent.
So I tried to use the ReportInfo using the FormatString as {PageNumber}, but I don't seems to be able to read the value using this.ReportInfo.Value or this.ReportInfo.Text
I also tried to make a TextBox, using SummaryType : PageCount. But I'm still unable to read the Value.
So the question is :
How can I know the Page Number and Page Count in the script section?
Or how can I read the value of those textbox I created ?
Thanks a lot!
I think these docs cover what you are looking for:
https://help.grapecity.com/activereports/webhelp/Legacy/AR7Help/OnlineEN/AddPageNumbering.html
https://help.grapecity.com/activereports/webhelp/Legacy/AR7Help/OnlineEN/index.html

Magento 2 API removes spaces within variables

I am working with orders and invoices.
I noticed M2 (2.4.4) removes lots of spaces in almost all variables eg. for:
order['billing_address']:
'city': 'CHAMPIGNYSURMARNE'
In backend, it's well written 'CHAMPIGNY SUR MARNE'
Idem for :
order['billing_address']
'additional_information': [
'Virementbancaire',
'Votrecommandeseraexpédiéelorsquelevirementdesonmontantseraconfirméparnotreorganismebancaire.\r\nVoustrouvereznoscoordonnéesbancairesdanslaconfirmationdecommandeenvoyéesurvotreboîteemail.'
],
I also noticed that issue doesn't happen in all variables. Even if for the time, I can only see ONE value on witch it doesn't happen :
order['status_histories']
'comment': "Remboursement de 6,00\xa0€ hors ligne. <span style='color:deeppink'>(By Axel B)</span>",
Did anyone else ever noticed this ?
My bad ! I post this answer because maybe, somebody one day could be as dizzy as me.
The reason is I use a new tool for formatting - among others - JSON and XML.
I recommend it to those who do not know it yet : DevToys (Mac an Win).
But it is responsible for my misfortunes because is't it that removes spaces when beautifying. As the file was long, I didn't even have a look a the row file. I've searched in the soft an option that could avoid this behaviour ... without success.

How to generate username of specific pattern in drupal during registration

I want to generate a usernames st + first two initials of their first name + their last name.
There are few modules to create username of specific pattern but none of them can accomplish my requirement. I am not Drupal module expert.
What you can do is to install the automatic username module:
Navigate to the configuration page of this module: admin/config/people/accounts/patterns
Then, in the "Other settings" section you can check the option "Evaluate PHP in pattern."
This allows you to execute PHP in the "Pattern for username" field. Two things to consider:
PHP is executed after the token replacement, this allows you to actually manipulate the strings.
You need to echo the final result.
Make sure that the php is wrapped with <?php ?> tags. Also, if you make a syntax error, it will only be seen upon registration (Or whenever the script is executed.)
Now let's say you configured your users to have a first_name field and a last_name field (with those specific field names)
Your PHP could look something like this:
<?php
$initials = substr("[user:field-first-name]", 0, 2);
echo 'str' . $initials . "[user:field-last-name]";
?>
First, Note that the token are between double quotes to make sure that what is outputted by the token is considered a string by PHP
Second, the php function substr is used to get the 2 first letters of the first name.
Now, things I don't know
I have no idea what happens if two users happen to have the same resulting username
I don't know what happen if a user enters a double quote in his name, might be dangerous, you might want to escape it with a str_replace or something like that

theming price format in drupal ubercart

What I am trying to achieve is to theme the price format the following way. I only want to remove the decimals when they are 00.
For example €5,00 should be €5, but €5,50 should remain the same, not €5,5.
I found a forum about this problem but I dont know how to implement it, especially overriding theme_uc_product_price() as suggested here.
Those links suggest using either the Computed Field Module or a Preprocess function but it would be simple with a bit of JQuery:
Let's say you have a div like so:
<div class="field-price">€ 5,00</div>
You could then target that element with a replace:
$('.field-price:contains(",00")').html(function(i, h) {
return h.replace(/00/g, '');
});​
I wrote a demo here:
http://jsfiddle.net/JySHQ/1/
Note please indicate what version of Drupal you have and then I give give you some hints as how to implement as Javascript is different in Drupal 6 vs. Drupal 7

Automatically Convert Prices on a Web Page to A Different Currency

I am interested in possible methods of automatically converting the prices given when a web page is loaded from the currency given to a specified currency. Ideally, the conversion would also make use of the current exchange rate to give valid prices.
For example, in my specific case, I would like to convert the prices given in Euros (€) on this web site to Sterling (£).
I am looking at using a GreaseMonkey script for this conversion, but can anyone suggest other methods?
Thanks, MagicAndi.
Try the API: http://thecurrencygraph.com
It uses Geo Location scripts to detect the user's country and through that their native currency. It then converts your prices into their currency using the latest exchange rates
Hope this this helps!
W.
Since I dabble in AutoHotkey here's a potential solution using that scripting language, it retrieves the page source from a webpage that does the conversion and parses out the converted value. This requires the httpQuery library to be included:
#Include httpQuery.ahk
InputBox, n, EUR to GBP, Enter the number., , 150, 120
if (ErrorLevel || !n)
return
url := "http://www.xe.com/ucc/convert.cgi?Amount=" n "&From=EUR&To=GBP&image.x=55&image.y=8"
html := URLDownloadToVar(url)
Gui, Add, Edit, w125, % RegExMatch(html,"[\d\.]+(?= GBP)",m) ? m "£" : "The value could not be retrieved."
Gui, Show, AutoSize Center, GBP
VarSetCapacity(html,0)
Return
GuiClose:
GuiEscape:
Gui, Destroy
return
URLDownloadToVar(url){
if !RegExMatch(url,"^http://")
url := "http://" url
httpQuery(html,url)
VarSetCapacity(html, -1)
Return html
}
There are obviously more thorough (and complex) methods for solving this problem but this at least solves it with minimal effort.
The quick and easy answer is to make use of a Firefox add-on. There are a number of currency converters available as add-ons, but I ended up using Exch, as it suited my needs best.