Is there anyway to get Perl Cgi session information within PHP? Most of the site I'm working on is programmed in Perl, except for a small portion. This portion uses PHP instead, and I was wondering how I could use the Perl CGI Session information from within PHP.
I was thinking of executing a perl script upon entering the page through exec that verified the session information, but I was hoping there was a better way to access the session variables, preferably one that would work without the use of exec.
Any suggestions?
If it helps, the segment that's in PHP is loaded within an iframe on the page. I'm using Perl's CGI:Session module to create the sessions.
If you need anymore information, just let me know.
https://metacpan.org/module/CGI::Session::Serialize::php
You init call would be something like this:
my $session = CGI::Session->new( 'serializer:php' );
I am not 100% sure on the php side. CGI::Session::Serialize::php uses https://metacpan.org/module/PHP::Session so it may just work automatically with php. If not you will have to point php to the perl session file.
One more edit.
If that does not work you could use https://metacpan.org/module/CGI::Session::Serialize::yaml
Then have php parse it http://php.net/manual/en/book.yaml.php
Related
If I put PHP script in the "data" directory can I use it in my Firefox add-on?
Firefox add-ons can only execute JavaScript. This still leaves you with a few options:
Rewrite the PHP code in javascript by hand
Rewrite the PHP code in javascript by hand, using a library like phpjs which emulate PHPfunctions in javascript
Use a PHP-to-JavaScript transpiler to convert the code (might only work for simple code)
use a PHP interpreter that is written in JavaScript, like this one and execute the PHP script
(I just googled those links and have no idea how well they work, there probably are better alternatives)
A rewrite of the PHP code is the only clean way in my opinion. Carefully migrating the most basic code with a transpiler might save some time though.
Firefox CANNOT use php in extension directly, unless you indirectly call your php code via XPCOM or other workaround.
My main app is written using PHP, but I'm using a Perl script to process a request, and I want to pass information to the PHP app using apache_notes. I would prefer not to use query parameters.
Here's the documentation on apache notes I found
for PHP
for Perl
On the PHP documentation, there is an example of how to use apache notes from PHP->Perl. Does anyone have an example of how to go from Perl->PHP, or suggest another way to securely communicate from Perl to PHP without having to go through query parameters?
You can use $r->subprocess_env("foo", $value), which from PHP will be visible as $_SERVER["REDIRECT_foo"].
How can I access my php script from a Python script?
I need my Python script to be able to access the variables within the php script. (By the way, I'm new to php and Python.)
Thanks in advance.
If I understand it correctly, you have a service in PHP, and want to communicate with another one in Python.
Now, this is not really related to PHP or Python: this is quite a classic issue of integration and there are several ways to accomplish it; without more details about your problem, it may be very difficult to be specific about a solution and what kind of approach could be the better for you, but below you can find some ideas.
You could for instance save the status from PHP service in an ad-hoc table in the database, and then query it from the Python service.
Another way could be to use a RESTful approach: the information is available as a resource, accessible via a GET query; in PHP you would have a small handler that would just return a small JSON (or XML, if you like that kind of stuff), and in Python you would have instead the client. Of course, there are security issues to consider, but I think you got the idea.
For more information, I recommend you having a look at an interesting series written some time ago by Paul Stovell about integration. It is very accessible, and shows several approaches - although not all of them apply to your current issue.
Elaborate. Is the PHP file local? On a webserver? Where's the python file?
If the php file is on a server with the python file, use an exec statement.
If the python file is local and the php file is on a server, then you need to use urllib.
If both are local, write an interpreter...
I'm writing some scripts that are free, but only to members within my teaching program. What I want to do is check what sites have installed the script.
I was thinking of obfuscating some PHP that posts back to my server when installed so I can see the domain it's used on. Obviously the user could remove this, but if I was to put a few application variables in with the code it might stop them removing because doing so would break the script.
Any comments on this approach?
if you really want to be sure, use something like Zend Guard (aka Zend Encoder) to encode the php file.
If you want some of it to be user-editable, just encode the core functions (along with your security check) in a separate file and then leave the higher level code open for them to tinker with/modify as required.
I am writing a small web server, nothing fancy, I basically just want to be able to show some files. I would like to use PHP though, and im wondering if just putting the php code inside of the html will be fine, or if I need to actually use some type of PHP library?
http://www.adp-gmbh.ch/win/misc/webserver.html
I just downloaded that and I am going to use that to work off of. Basically I am writing a serverside game plugin that will allow game server owners to access a web control panel for their server. Some features would be possible with PHP so this is my goal. Any help would be appreciated, thanks!
The PHP won't serve itself. What happens in a web server like Apache is before the PHP is served to the user it is passed through a PHP parser. That PHP parser reads, understands and executes anything between (or even ) tags depending on configuration. The resultant output, usually still HTML, is served by the web server.
There are a number of ways to achieve this. Modules to process PHP have been written by Apache but you do not have to use these. PHP.exe on windows, installed from windows.php.net, will do this for you. Given a PHP file as an argument it will parse the PHP and spit the result back out on the standard output.
So, one option for you is to start PHP.exe from within your web server with a re-directed standard output to your program, and serve the result.
How to create a child process with re-directed IO: http://msdn.microsoft.com/en-us/library/ms682499%28VS.85%29.aspx however, you won't be writing the child process, that'll be PHP.exe
Caveat: I am not sure from a security / in production use perspective if this is the most secure approach, but it would work.
PHP needs to be processed by the PHP runtime. I'm assuming the case you're talking about is that you have a C++ server answering HTTP queries, and you want to write PHP code out with the HTML when you respond to clients.
I'm not aware of any general-purpose PHP library. The most straightforward solution is probably to use PHP as a CGI program.
Here's a link that might be useful for that: http://osdir.com/ml/php-general/2009-06/msg00473.html
This method is nice because you don't need to write the HTML+PHP out to a file first; you can stream it to PHP.
You need execute the PHP page to serve the page it generates.
The easiest thing for you to do would be to add CGI support to your webserver in some basic form. This is non-trivial, but not too difficult. Basically you need to pass PHP an environment and input, and retrieve the output.
Once you have CGI support you can just use any executable, including PHP, to generate webpages.