How can I allow email addresses from two different domains using Regex? - php

I've got an small form to download some stuff. But I don't want every buddy to download it. Only from 2 specific domains you can download the stuff. So I made an form with an email validation. But How can I add two Domains in the test of the email?
What I was trying was:
$test = array(
'email' => '/^[\w.+-]{2,}\#[DOMAIN1][DOMAIN2]\.[a-z]{2,6}$/',
}
But that didn't worked …
Thanks for any help.

By grouping the evaluation () and placing an or operator in it | you'll be able to handle either domain. See the below modified regex:
'email' => '/^[\w.+-]{2,}\#(DOMAIN1|DOMAIN2)\.[a-z]{2,6}$/',

Related

how to add phone numbers to telegram account by using contacts_ImportedContacts method in MadelineProto and php?

I have a list of phone numbers in an Excel file.
I just want to determine which phone numbers have the telegram accounts?
perhaps somebody would say that it is possible by importring the numbers list to my mobile audience by contact to excel app and then The telegram itself automatically sync the audience's list.
But I have to say that It's not the right way to do it.
After the research, I found that by madelineproto and using the contacts _ ImportedContacts method, this can be done
This is the document link :
https://docs.madelineproto.xyz/API_docs/methods/contacts_importContacts.html
So I installed madelineproto first and activated it and I wrote the following script :
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';
$MadelineProto = new \danog\MadelineProto\API('session.madeline');
$MadelineProto->async(true);
$MadelineProto->loop(function () use ($MadelineProto) {
yield $MadelineProto->start();
$me = yield $MadelineProto->get_self();
$MadelineProto->logger($me);
if (!$me['bot']) {
yield $MadelineProto->messages->sendMessage(['peer' => '#FS10218', 'message' => "hi my dear friend"]);
yield $MadelineProto->channels->joinChannel(['channel' => '#Akhbar_Fori_Ir']);
yield $MadelineProto->contacts->importContacts(['contacts' => [ [ '_'=>[ 'client_id'=>0, 'phone'=>'+12106606046', 'first_name'=>'Ccc', 'last_name'=>'Fff' ] ] ], ]);
}
yield $MadelineProto->echo('OK, done!');
});
It works correctly to send messages and join to channel.
but doesn't add the phone number to my telegram account.why?
Is this a limit created by the telegram or my code is wrong?
I beforehand apologize for the existence of grammatical mistakes and that my English is weak
Your code seems to be correct. Telegram has announced a new privacy setting "Who Can See My Phone Number" here. If this option is set to "Nobody" you can't import the number. The phone number in your code has either enabled this option or is not associated with a Telegram account (I tried to import it myself). Your code should work with another phone number.

How to to implement a forgot password feature using the Google Identity Toolkit in php

I am trying to add google identity toolkit in php. Signin option is working correctly but when i am clicking on problem in sign in link it is showing capthca after submitting captcha it is not navigating to any url.
email.php
<?php
include "identity-toolkit-php-client-master/src/GitkitClient.php";
$gitkitClient=new Gitkit_Client();
$oob_response = $gitkitClient->getOobResults($_POST);
$oob_link = $oob_response['oobLink'];
echo json_encode($oob_response);
?>
email.php is the oobactionurl file. when i am using this code I am getting this error .image
You need to create a php file to retrieve and send the reset link to the user. Make sure the oobActionUrl widget option points to this file. Within the file, you'll get the generated link and additional information by calling $gitkitClient->getOobResults($_POST). It should also work if you exclude $_POST, as the function will check the post contents if no arguments are passed. Then, you can get the link itself like this:
$oob_response = $gitkitClient->getOobResults($_POST);
$oob_link = $oob_response['oobLink'];
From there, you can use your email function of choice to send it to the user. The returned array should contain the following.
'email' => email of the user,
'oldEmail' => old email (for ChangeEmail only),
'newEmail' => new email (for ChangeEmail only),
'oobLink' => url for user click to finish the operation,
'action' => 'RESET_PASSWORD', or 'CHANGE_EMAIL',
'response_body' => http response to be sent back to Gitkit widget
Let me know if you have any further questions.

Drupal email variables not appearing

Whenever a user registers an account, the automated emails (which I can set in admin/config/people/accounts) are not carrying over the defined variables for username, email, etc.
For example. Here's what I have set for one email:
[user:name],
Thank you for registering at [site:name]. Your application for an account is currently pending approval. Once it has been approved, you will receive another e-mail containing information about how to log in, set your password, and other details.
-- [site:name] team
Those variables in brackets just aren't appearing. The email sends as usual, but where those variables are, nothing gets inserted. Is there something I have to enable first?
The token replacement in mails happen in line 2815 of user.module (modules/user/user.module). You can add the following line of code
drupal_set_message("Text: $text, Variables: " . print_r($variables, TRUE) . ", Language: $language);
before the line that says
return token_replace($text, $variables, array('language' => $language, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
That will tell you as messages what is happening with the token replacement issue. If you can post the messages that you see back here I can help solve the issue.
It seems that you have misconfiguration issues or losing sth .for seeing configs with html mail in here ,
see here
also try updating it using update.php!
-- READ FROM PHP.NET SPECIFICATIONS --,
I THINK THAT BY DEFAULT, SOME HOST PROVIDERS DO NOT SUPPORT FEW PHP FILTERS (OR LIKEWISE), SO (ITS JUST AN ASSUMPTION !) MAY BE, FILTER_SANITIZE_EMAIL THAT IS USED TO REMOVE ALL CHARACTERS EXCEPT LETTERS, DIGITS AND !#$%&'*+-/=?^_`{|}~#.[], IS TURNED ON.
SO JUST CHECK IT OUT !

Validate email and ban certain domains

I have this code I currently use to validate emails:
return (bool) preg_match('/^([a-z0-9\+\_\-\.]+)#([a-z0-9\+\_\-\.]{2,})(\.[a-z]{2,4})$/i', $arg0);
How can I modify that code so I can ban several domains? I don't want any extra files to add, just to modify this code.
Thank you.
The easiest way would be to have an array with banned providers:
$providers = Array ( 'gmail.com', 'yahoo.com' );
and then just loop trough that array and check if provided email contains '#' . $provider.

How to mail to a static list segment with mailchimp API

Once I've identified identified the email addresses of my list segment (using get_emails() custom function, I am setting up my list segment as follows:
$batch = get_emails();
//now create my list segment:
$api->listStaticSegmentAdd(WEDDING_LIST_ID, 'new_wedding_guests');
$api->listStaticSegmentMembersAdd(WEDDING_LIST_ID, 'new_wedding_guests', $batch);
//do I build vars for a campaign?
$options = array (
'list_id' => WEDDING_LIST_ID, //What value id's my list segment?
'subject' => 'Alpha testing.',
'from_email' => 'wedding#juicywatermelon.com',
'from_name' => 'Pam & Kellzo',
'to_name' => $account->name,
);
From here can I use a basic campaign and send it?
$content['text'] = "Some text.";
$content['html'] = get_link($account);
$cid = $api->campaignCreate('regular', $options, $content);
$result = $api->campaignSendNow($cid);
I'm not sure if I'm understanding the api documentation correctly. I also tried 'list_id' => 'new_wedding_guests'; which failed to create a campaign.
Thanks!
I'll assume this is test code and just make the cursory mention of how you probably don't need to be creating a new Static Segment every time. However, your call to add members is not going to work. Per the listStaticSegmentMembersAdd documentation, you should be passing the static segment id, not the name of it. Also note that the docs cross-reference themselves when input params can come from other calls - that parameter there is a good example (it also happens to be returned by listStaticSegmentAdd).
Your options for campaignCreate look like a good start. The documentation for it has examples below - those examples are included in the PHP MCAPI wrapper you likely downloaded. As per above, the list_id you need is the one for the list you used in the listStaticSegment calls (also linked in the documentation).
Now the real key - further down in the campaignCreate docs is the segment_opts parameter - that is how you control segmentation. Follow the link it gives you and you'll find tons of info on the ways you can do segmentation, including using a static_segment.
Hopefully all of that made sense, if not, take a step back and check out these links (and play with segmentation in the app), then it should:
Introduction to MailChimp List Management
How can I send to a segment of my list?
Our Release Info on how Static Segments are used

Categories