I was working on a verification system for Mobiopush, it’s gonna help the customers to verify whether they have installed the code to use Push Notifications for their registered domain properly or not. .
We use a single line JavaScript code with the site Identification part at the end of src
. I had managed to extract the JS code they might have installed on their website and have them in a string its simple just check whether the src
point to correct domain or not, But now a new problem is set because of the method we practiced. ( I will share how I extracted the code from customer website soon)
Sample installation code for Mobiopush
Since we use the identification ID at end of src
tag of java script all website will have a unique src
, It’s just another String Manipulation task to be done.
If you have been a Computer Science Major or had opted Computer Science in high School this is a piece of cake. You probably might have solved a similar problem. An example will be Find how many vowels are present in “MISSISSIPPI” or some other word, if you had a professor who wants to push his students to limit might ask you to count number of ‘s’ in word. It would have been in C or C++ where strings are easy to handle just for the fact they are used in basic forms, I didn’t mean its difficult in PHP its simple as its there, but you were not spoon feed’ed in C or C++ where as in PHP you are.
I do have an advantage here, the ID is present only at the end of the string and the size of ID is constant for all customers which allows me to use a combination of strpos()
and substr()
. But your problem can be different the ID could either be at the end of the URL string or in the middle (any way it not the begin for sure :p ). I just thought to make a snippet for the worst case.
$string = "cdn.mobiopush.com/mobio.js?mobio_sitekey=e667bf06f6f57ca1bc68b9418173631b";
for ($i=0; $i < strlen($string); $i++){
if(strcmp($string{$i},"=") == 0){
for($k=$i+1;$k<($i+33);$k++)
$key= $site_key.$string{$k};
$i = $k;
}else{
$url = $url.$string{$i};
}
}
At the end of the run you will have the key in $key
and rest of the string in $url
. If you don't want the part after the ID you been looking for replace $i = $k
by a break
its gonna break the parent form traversing further and exit.
With the two key done I am ready to move with my verification processes, hope you too are gonna be ready open doors after this.