As strange as I find this, I have not been able to find a good PHP function anywhere which will do an intelligent parse of a user agent string? Googled it for about 20 minutes now.
I have the string already, I just need something that will chop it up and give me at least browser/ver/os.
Know of a good snippet anywhere?
The get_browser() function has been available in PHP for quite a long a time.
The PHP manual is free, can be downloaded in various formats and viewed online (with comments)
https://github.com/browscap/browscap-php - this is a standalone library that aims to replace get_browser function. For shared hostings it seems to be a better option.
Works on: PHP 5
You can try to use: https://github.com/tobie/ua-parser. This is multi-language tool to parsing user agent string. For PHP is here: https://github.com/tobie/ua-parser/tree/master/php
Try out ThaDafinser/UserAgentParser it's an abstraction for many available user agent parsers.
So if you are not happy with one - just switch to another (or combine them)
You can try it out here
There is a PHP class library i found out, and it has worked so well for me. It is in the link below.
https://www.toms-world.org/blog/parseuseragentstring
It is lightweight and just does what I wanted (Browser, Version, OS, Mobile/PC, and much more) in a memory-friendy manner.
Related
I wonder if it's possible to view a PHP code source in a way that https://j11y.io/jquery/ shows a JQ code. Of course I mean reading code from a given file, not from websites code.
I'm not looking for programs like the PHPdocumentor.
Thank you in advance for any reasonable reply.
P.S. For perfectionists - I'm searching for a nice website or software (and I would prefer that option, so that I can be quite sure about the security), which will give me such a useful ability. I'm disturbed after using CTRL-F all the time ;)
I came across EtherPad but found out shortly afterwards that it has been shelved by Google.
Is there something else that I could use that allows people to collaborate on an online document? It must have version control.
Should I redevelop something instead?
Andre
Try Etherpad Lite, its much leighter than the original Etherpad
TypeWithMe is a slightly modified version of Etherpad. It's pretty darn good. Oh but, you need to view the document every once in a while or itll get wiped.
I'd recommend Google Docs. You can create new, upload existing, and collaborate online on files like documents, spreadsheets, presentations and drawings. Take a look at their Youtube page for a demonstration.
It seems like MobWrite http://code.google.com/p/google-mobwrite/ is a good solution. Just wish it had the versioning information etc that EtherPad had. Does anyone agree or have something better to embed in a PHP and mySQL website?
EtherPad is still available for buidling and deploying and it even have some seldom commits. If you want to use as an user, there are a few deployments of Etherpad (or perhaps modified versions of it) such as:
PiratePad
MoPad
Besides that, there is a quite comprehensive list of possibilities in this wikipedia entry for collaborative text editing software
The situation is next:
I have php file, which parses a web-page. on that web-page is a phone number and it's digits are mixed with each other. The only way to put each digit on the correct place is to use some JS functions (on the client side). So, when I execute that php file in linux console, it gives me all that I need, except js function's result (no wonder - JavaScript is not a server-side language). So all I see from JS - only a code, that I have written.
The question: can I execute js files via php and how?
Results of a quick google search (terms = javascript engine php)
J4P5 -- not developed since 2005 [BAD](according to its News)
PECL package spidermonkey
a 2008 post by jeresig points to PHPJS but can't see when it was last updated.
I'm sure you'll find many more links on that google search.
Alternatively:
you say that the digits are scrambled and you need to "unscramble" them using js. Can you code that unscrambling logic into a PHP function and just use it? Will sure save you a lot of trouble, but if learning to use js in php is what you're after, then its a whole different story...
Zend tutorial: "Using javascript in PHP with PECL and spidermonkey"?
http://en.wikipedia.org/wiki/Comparison_of_Server-side_JavaScript_solutions
Alternatively, PHP has simple functions for executing other programs and retrieving their output (I used this along with GPG once to create a PHP file manager which could live-encrypt files as you were uploading them and live-decrypt as you were downloading them)
Using those functions along with http://code.google.com/p/v8/ you should be able to interpret any javascript.
Not unless you know someone who's implemented a Javascript engine in PHP.
In other words, probably not.
Without some sort of browser emulation or passing the unparsed js off to a server side implementation of javascript (maybe node.js?), you won't be able to execute it.
However, does the page use the same js function to unscramble the phone number every time? You should be able to read the incorrect digits and shuffle them with PHP.
If you're prepared to do a bit of work building your own JS runtime to work with it, Tim Whitlock has written a javascript tokenizer and parser in pure PHP
node.js is server-side... but full JS :) no PHP in it so I don't it answer your needs...
Anyway, here is an example : a chat in JS both client & server-side : http://chat.nodejs.org/
Plus, not every host allows you to use the v8 engine...
If you have Javascript data objects, and you need to convert them to/from PHP arrays, that's quite easy using PHP's json_encode() and json_decode() functions.
But actually running Javascript code? No. You can't. You might be able to find a JS interpreter written in PHP (a few other answers have pointed a links that may or may not help you here), or more likely execute the JS using a stand-alone JS interpreter on your server which you call out to from PHP. However if the JS code includes references to the browser's DOM (which is highly likely), that's a whole other set of issues which will almost certainly make it impossible.
Given the way you describe the question, I'd say the easiest solution for you would just be to re-implement the JS code as PHP code; it's unlikely that all the work arounds being suggested would be appropriate for what sounds like a fairly simple bit of utility code.
At the moment it seems I've tried every trick in the book trying to get this to work. I need some way of encoding AMF requests and then decoding the responses. At this point I don't care what language it's in, as long as it's doable and free (as in to me), however I would prefer PHP.
I don't know what other information is needed, but I'm happy to supply more info - just comment this!
Thanks.
EDIT:
It seems the version of AMFPHP I was using was broken. Using a different version that I extracted from somewhere worked.
You can use amfphp for PHP side or from the zend framework or weborb for PHP who is also free
Although this question is very old, but still if someone is searching like me.
Checkout the answer over here
SabreAMF has a decoder. Check http://code.google.com/p/sabreamf/
I'm writing a WordPress plugin to create an eBook from a selected category in most major eBook formats. I would like to support MobiPocket since that's the format used by the Kindle but I'm not sure how to go about it. From what I've read .mobi files are actually Palm Resource Databases (PRC) but I haven't been able to find a PHP class to work with these.
I thought about using exec along with KindleGen but that would be undesirable as it would complicate initial setup. I've also thought about hosting a web service somewhere and using XML-RPC to accomplish this but that also complicates things.
My question is: is there a PHP class/library (PHP-only preferred) that can work with PRC or even better, a class that specialises in creating MobiPocket ebooks? (needs to be open source since I'm releasing under the GPL)
I've tried searching but haven't been able to find anything.
I don't know whether you're still looking for this PHP library, but just in case: https://github.com/raiju/phpMobi. This is a library that creates mobi files from html files.
It's should still be seen as an experimental version, but it should work without a problem for basic document with a few images.
Unfortunately not; however, the binary compiled format is an open specification available at:
http://www.mobipocket.com/dev/article.asp?BaseFolder=prcgen
The only direct way of transforming the uncompiled format is using the native XML functionality of PHP to create them and then invoking a compiler with exec, which I understand you don't want to do. If you go with this route, the link above also has details about this XML format.
You might want to try the mobiperl tools,
https://dev.mobileread.com/trac/mobiperl/wiki
Please note I haven't tested them yet. But they have been
around since at least 2007 so they should work well by now.
google "Mobiperl - Perl tools for handling MobiPocket files" to
find a thread on mobileread board discussing it. As a new
poster I can't put 2 hyperlinks into my reply.
Another tool I have recently found (but not yet tested), is: http://www.phpclasses.org/package/8173-PHP-Generate-Kindle-ebook-file-in-mobi-format.html#files
It is based upon KindleGen, and looks pretty straight forward to implement.