Android - Match contacts with phone numbers from DataBase - php

I have a few little questions concerning contacts from Android.
I have a MySQL databases with users and their phone numbers and I want to retrieve the contacts from the contact list of the user phone which are matching with phone numbers in the database (-> users using the app in other words, a bit like whatsapp is doing when you see the contacts which are using the app..)
I was wondering how I could achieve that in an easy and rapid way.. I was guessing I could do as follow:
asynctask class which is retrieving all the contact list with a cursor
get the phone number of the current item in the cursor
execute a sql query to see if contact exist .. with LIKE %phonenumber% (through php script)
if exist, add the contact name to a list view
But this means that every times the user wants to see the list, there are a lot of requests that need to be done.
Does anyone have an idea of a better way to do it? An easier way ?

Related

Mobile registration system. How to handle E164 and national mobile number login?

I'm implementing a mobile registration system in PHP where by the user can register with their mobile number. They can also log in with that number and receive SMS notices/verification etc.
Let me explain the system before moving onto the problem as its easier to explain that way.
My current system works like this:
User signs up with 07733333333
Phone number is converted to E164 format and stored as +44773333333
SMS validation is sent
This works great and ensures the user can't sign up twice with the same number. It's also the format our SMS service provider requires.
The way I convert to E164 is using Google's LibPhoneNumber library. It requires a country code to convert the number so I take that from the IP address. The user is able to change the country code if our guess is wrong. On the page after registration they will see a page that says "We've sent an SMS to this number: +44773333333". The user can change this number/country code at this point.
The problem arises when logging in.
If a user logs in with +44773333333 it's easy to grab this from the database. It's already stored in this format.
But, if they log in with 0773333333 I need to make a guess at what region that mobile number is to convert it to E164 format to run the query. There is no way I can query this number in the database because it doesn't exist in that form. I can guess that it's +44 from the IP address but this is unreliable. What if the user is on holiday? Or using a VPN? That guess can't be made.
What is the best way to handle this?
My only thought is to have two fields in the database. One is national_mobile_number and the other is e164_mobile_number. That way I can query either fields to see if the numbers match. I don't know what impact this would have on performance with many users (500,000+).

Preventing Duplicate Form Submissions using 2FA

My problem is this:
I have a survey that is taken by people that they're paid for. I want to avoid the same person submitting the form multiple times. It is a web application.
What I have tried:
I have tried recognizing the IP address from which they try to submit the survey but it hasn't worked.(They could just change devices and so, IP changes) I could try 2FA (where I authenticate using SMS/Voice to phone numbers) but free phone services like Google Voice/Twilio will render that useless. Using a SHA/MD5 hash on a combined key such as phone number and email address still faces the same multiple emails/phone numbers problem. Uber has recently covered up its tracks and devised a way (or a partnership) to recognize Google Voice Numbers. I have gone through the Google Voice API and haven't found a way to find the actual phone number linked to the Voice number.
Is there any full-proof way of doing this?
PS: I am NOT talking about multiple form submissions on a form (say a ecommerce website) which causes multiple charges to a credit card. Please do NOT suggest CAPTCHA.

encrypting messages in php codiegniter

I am working on an educational website in PHP Condeigniter. The project includes an option where students can sent private messages to tutors and vice versa but they are not allowed to share their contact details with each other, like phone number, skype id, home address, email etc. Is there any way in which I can control this? For example, if a user writes his phone number like 12345677, the algorithm should automatically replace it with xxxxxxxx so that the other user should not be able to view the number..
You can attempt to censor some of the text patterns with regular expressions but don't expect to get 100% of them. I don't think you can reliably censor things like skype IDs and addresses.
Also note that if they'll really want to share contact information they are going to find a way to get around your filters.

Can I have a user database synced with SugarCRM and use it mostly for emailing?

I work for a company that has a website with about 700,000 users, it would need a tool that would:
List all users
Email users, create templates, send a newsletter
Show products a user has purchased
If you find a user, show which emails have been sent to the user
Create automated tasks, example: send an email to every user that has a product expiring in 30 days
I'm not sure a CRM can do all theses things, I wanted to try a CRM to figure out how close can I get to having a tool that can do all this. I read that SugarCRM is pretty good, and its free so I'm going to try it out.
What I wanted to know is, using the REST or SOAP api of SugarCRM, can I synchronise all my users with the SugarCRM database ? Or for example each time a user is created on our website, insert it in the database.
And then each time we send an email with our website, use SugarCRM instead to send a mail, and store the data. So that we can view which emails have been sent to specific users.
Thank you
Yes you can do all that but it may require some customisation to suit it exactly to your needs. By 'users' I assume you are referring to Customer 'Accounts' as known on the SugarCRM?
Add custom fields to the Contacts module using Studio. The easiest and quickest way to get your data in will be directly to the database.
The standard fields in Sugar Contacts go in the contacts table. Your custom fields will have "_c" appended to their names and be created in the contacts_cstm table. The two tables are related by contacts.id = contacts_cstm.id_c, which is generally a GUID field (but can be any string value if you need it to be).
Then you need to have a process to add new users in your website into sugar. I suggest polling your user db periodically to look for new records and using the SOAP/REST API (good luck though, it's fairly horrible) to insert them into Sugar.
Other than that your use case is pretty much standard Sugar. For automated tasks which happen whenever an email is sent/received or when a new contact is created, you'll want to look at logic hooks, search for logic_hooks.php in the Sugar documentation.

Receiving database query results on mobile devices

I have created a MySQL database that contains information about patients and their current state of treatment along with other relevant information. Preliminary i manged to create a website where you can query about patients(using either their name or room no) and it'll display the requested information.But now i need to find a way so that when someone writes a relevant query (like patient name or room no) in a SMS and sends it to a predefined number they'l receive the requested information about that patient on their mobile in an SMS.Kindly guide me how to deal with this?

Categories