Javascript for browser language detection? [duplicate] - php

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.

Related

Is there any way to hide css code from source code [duplicate]

This question already has answers here:
Hiding the source CSS code
(3 answers)
How to protect css files [closed]
(1 answer)
Closed 4 years ago.
Is there anyway to hide css code from source code. So, no anyone can copy my code. Or, any other language is available for styling like css and it is not visible in source code. I know it's silly question.
Here I am also asking about alternate language of css which is not visible in source code.
Is there anyway to hide css code from source code. So, no anyone can copy my code.
Short answer: No. CSS must be sent as plain text to your clients' computers if you want your page to be rendered.
I hide my Javascript code from source code by implementing between PHP.
What? No, you cannot hide Javascript either, for the same reason.
You can minify or obfuscate this code, but you cannot avoid sending it (if you want it to be used).
There is NO way to hide the client side components like CSS.
you can check it here

How to detect visitor country? [duplicate]

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

Php copy website table [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
HTML Scraping in Php
Far from being web developer expert, so sorry in advance if I'm missing something basic:
I need to copy a table into mySql database using PHP; the table resides in a website which I don't own, however I have permission to copy and publish.
Manually when I watch this website in my web-browser I need to click on a link in the main website URL (I can't reach the final destination page link since it changes all time, however the main page link is static and the link to click is also static).
Example to such a content I need to copy from (just an example, this is not the real content):
http://www.flightstats.com/go/FlightStatus/flightStatusByAirport.do?airportCode=JFK&airportQueryType=0
Most people are going to ask what have you tried. Since you mentioned that you don't have much development experience, here are some tips on how to go about it - have to put it as an answer so it is easier to read.
What you're going to need to do is scraping.
Using PHP, you'd use the following functions at the very least
file_get_contents() - this function will read the data in the URL
preg_match_all - use of regular expressions will let you get the data you are looking for. Though some/many people will say that you should go through the DOM.
The data that is returned with preg_match_all can be stored into your MySQL table. Though because the data changes so frequently, you might be better off just scraping that section and storing the entire table as cache (though I do have to say I have no idea what you are trying to do on your site - so I could well be wrong).

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.

How to scrape a javascript site using PHP, CURL [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do I render javascript from another site, inside a PHP application?
This is the site http://www.oferta.pl/strona_v2/gazeta_v2/ . This site is built totally on JavaScript. I want to scrape using PHP and curl. Currently I use DOMXPath. In the left menu there are some category to be selected. I see no 'form' there. How can I use curl to submit that form and scrap the output page?
I have used file_get_contents() only. It doesn't get all of the page. How can I proceed?
N.B : http://www.html-form-guide.com/php-form/php-form-submit.html I have found this example which have a 'form'. But my specified site has no 'form'.
You can not scrape it. Its possible. But its way too hard.
Simulate the http request by curl. Check every request it makes by ajax and try to simulate it.
Simulate Javascript executions (this part is almost impossible). Some requests contains values which are generated by Javascript. You need to do it in php. If they has some complicated algorithm implemented in JS you can invoke v8 javascript engine.

Categories