How to detect visitor country? [duplicate] - php

This question already has answers here:
How to detect country / location of visitor? [duplicate]
(4 answers)
Closed 9 years ago.
What's the easiest way to detect the visitor country via IP address? What's the common and recommended approach to solve this problem?

You could you use HTML5 Geolocation to detect a users location. There are loads of API already built for you to take advantage off.
Some developers use this change the language of their site to suit the location of the user. Ie. The site is in English, but the visitor is in Ukraine. The site, if the developer has permitted so, the text would translate to Ukrainian without having to let the browser do it.
http://html5demos.com/geo
http://msdn.microsoft.com/en-us/magazine/hh563893.aspx

I do not know the common approach... but i think that sticking to php.net will be fine.
http://www.php.net/manual/en/book.geoip.php

Related

How can I can detect and replace a portion of an image using php? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Face detection in PHP
I want to be able to detect a portion of an image like a person's face in image $filetoReplace and then
replace it by another face in image $fileReplaceWith. Is there any way this can be done in php?
$filetoReplace = 'image/person.jpg';
$fileReplaceWith = 'image/anotherperson.jpg';
Short answer: Yes
Long answer: Yes, it's possible (how was already mentioned in comments: basically everything is possible), but you won't be able to write the algorithm without knowledge of image processing & pattern recognition; it's actually kinda rocket science :)
So that means, that you'll need to use some library. I would recommend OpenCV which is quite mature open source library built for this purpose (any many others). There is already built-in detector of faces.
I suggest to search for "OpenCV in PHP" to find PHP wrapper for this library and then you'll need to figure out how to pass the image properly to find face(s) in OpenCV in $filetoReplace and how to replace rectange/oval with $fileReplaceWith.

Javascript for browser language detection? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
JavaScript for detecting browser language preference
How to getting browser current locale preference using javascript?
I have a wordpress website that I am in the works of localizing. I don't really have much php or javascript knowledge, and don't really know what I am looking for in terms of doing this.
I have a support tab that users can click to go to my helpdesk. I can create multiple tabs for different languages and get the code to display it.
So my question is: Is their an if then statement in javascript that I can use to help detect the language of the browser and display the correct tab? Or is their a better way of doing this? Since my localized domains format is "ru.domain.com" I could even have the if then statement check for the language code in the current page url. Any help would be appreciated.

Is there an easy script which will display script 1 to US/ Canadian visitors and script 2 to the rest [duplicate]

This question already has answers here:
What's the best solution to check a users country?
(5 answers)
Closed 8 years ago.
I would like to know if there is an easy script which will display script 1 to US/ Canadian visitors and script 2 to the rest.
Does not need to be that accurate but using a service like http://freegeoip.net/json/18.8.8.82 is to complicated for me
Is there an easy way
a script example would greatly be appreciated
You may try: GEO Plugin
The PHP web service allows you to directly program your back-end PHP scripts to deliver dynamic geo-localized pages using the PHP array provided by geoPlugin.
GEO Plugin PHP Web Service
It is easy to use.
See Demo: http://jsfiddle.net/akhurshid/WktTV/

Creating a screenshot image of a website if given nothing other than a url? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Website screenshots using PHP
I was wondering if it is possible to create a screen-shot-like preview of a website if given nothing other than a url?
Yes, you can, please read the following stackoverflow questions:
generating-a-screenshot-of-a-website-using-jquery
website-screenshots-using-php
There are some tools with the goal of snapshotting the website to an image, so, using Jquery in conjunction with PHP you can achieve your goal!
Using only JavaScript/jQuery? Likely not, as that would violate the same origin policy. And even if you could, it's be challenging in JavaScript to make it into an image.
You can use a service like BitPixels as well. Use JSONP if there are any same origin issues and it should be easy enough.

What does /#!/ mean in URL? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
What's the shebang (#!) in Facebook and new Twitter URLs for?
It usually comes straight after the domain name.
I see it all the time, like in Twitter and Facebook urls.
Is it some special sort of routing?
# is the fragment separator. Everything before it is handled by the server, and everything after it is handled by the client, usually in JavaScript (although it will advance the page to an anchor with the same name as the fragment).
after # is the hash of the location; the ! the follows is used by search engines to help index ajax content. After that can be anything, but is usually rendered to look as a path (hence the /). If you want to know more, read this.

Categories