All AbelCam functionality has been terminated October 8th 2019
 
 
 
Navigation

Edit detail for How to use PHP revision 17 of 20

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Editor: MelvinG
Time: 2012/02/10 08:32:04 GMT+1
Note: PHP Sessions and Cookies

added:

From MelvinG Fri Feb 10 08:32:04 +0100 2012
From: MelvinG
Date: Fri, 10 Feb 2012 08:32:04 +0100
Subject: PHP Sessions and Cookies
Message-ID: <20120210083204+0100@www.abelcam.com>

<pre>
If you are trying to use PHP sessions or doing other things that use cookies, and it's not working for you, here is why. PHP wants the SessionID (and other cookies) to be in the superglobal $_COOKIE[] but AbelCam puts cookies in $_ENV["COOKIES"]. PHP does not understand. To solve the problem, put the following code at the beginning of each of your PHP pages. It examines $_ENV["COOKIES"] and loads all the cookies it finds into $_COOKIE[] in a way that PHP can understand.

foreach (explode(";", $_ENV["COOKIES"]) as $cookie)
{
    list($key, $val) = explode("=", $cookie);
    $_COOKIE[trim($key)] = trim($val);
}
</pre>

AbelCam supports the use of PHP.

To use PHP within AbelCam, install the PHP 5.3.3 zip package from www.php.net
download php-5.3.3-nts-Win32-VC9-x86.zip
5.3.3 is the current release - later versions are expected to work as well.

Install PHP

extract zip file to c:\php
AbelCam expects to find PHP in c:\php

copy c:\Program Files\AbelCam\wwwroot\php\c-php-php.ini to c:\php\php.ini
Changes to the default php.ini are marked with ;ABELCAM

PHP Logo Start AbelCam, the PHP Logo will be shown on the Web page

Once PHP is enabled, you can have a look at the PHP examples in wwwroot\php: http://localhost:8080/php
A small page counter example is included.

If you selected the PHP Image Gallery during the AbelCam installation, it will be available here:
http://localhost:8080/gallery

The following environment variables are set for PHP files
 

VariableMeaning,Value
ABELDATA%ALLUSERSPROFILE%\Seiz System Engineering\AbelCam
Location of configuration files
ACTIVECAMS active camera numbers, separated by commas
CAMFPS frame rate of the current camera
CAMNAME name of the current camera
CAMNAMES names of active cameras, separated by commas
CAMNR active cam number
CAMRESOLUTION active cam resolution, eg. 320x240
COOKIES cookies set for AbelCam, eg. cam="0"
DOC_ROOT AbelCam document root
HTTP_REFERER refering page, eg. http://localhost:8080/php/index.php
OUTPUTHEIGHT output height of current camera, eg. 240
OUTPUTWIDTH output width of current camera, eg. 320
REDIRECT_STATUS always set to 200
REMOTE_ADDR ip address of requestor, eg. 127.0.0.1
REQUEST_METHOD GET
SCRIPT_FILENAME script file name, eg. index.php
SCRIPT_NAME same as above
SERVER_CONFDIR installation folder, eg. C:\ProgramData?\Seiz System Engineering\AbelCam
SERVER_NAME AbelCam server name, eg. localhost
SERVER_PORT AbelCam server port, eg. 8080
SERVER_PROTOCOLL always HTTP/1.1
SERVER_SOFTWARE AbelCam version, eg. AbelCam 2.1.1 Pro
ORIG_PATH_INFO script relative to document root, eg. /php/index.php

other environment variables set by the operating system are available as well.
see http://localhost:8080/php/phpinfo.php
once you have configured PHP

comments:

Regarding PHP Sessions and Cookies --MelvinG?, Fri, 10 Feb 2012 08:24:23 +0100 reply

If you are trying to use PHP sessions or doing other things that use cookies, and it's not working for you, here is why. PHP wants the SessionID? (and other cookies) to be in the superglobal $_COOKIE[] but AbelCam puts cookies in $_ENV["COOKIES"]?. PHP does not understand. To solve the problem, put the following code at the beginning of each of your PHP pages. It examines $_ENV["COOKIES"]? and loads all the cookies it finds into $_COOKIE[] in a way that PHP can understand. foreach (explode(";", $_ENV["COOKIES"]?) as $cookie) { list($key, $val) = explode("=", $cookie); $_COOKIE[trim($key)]? = trim($val); } session_start();

Regarding PHP Sessions and Cookies --MelvinG?, Fri, 10 Feb 2012 08:26:19 +0100 reply

Beautiful. The software utterly mangled my post. Stefan please fix?

PHP Sessions and Cookies --MelvinG?, Fri, 10 Feb 2012 08:32:04 +0100 reply

If you are trying to use PHP sessions or doing other things that use cookies, and it's not working for you, here is why. PHP wants the SessionID (and other cookies) to be in the superglobal $_COOKIE[] but AbelCam puts cookies in $_ENV["COOKIES"]. PHP does not understand. To solve the problem, put the following code at the beginning of each of your PHP pages. It examines $_ENV["COOKIES"] and loads all the cookies it finds into $_COOKIE[] in a way that PHP can understand.

foreach (explode(";", $_ENV["COOKIES"]) as $cookie)
{
    list($key, $val) = explode("=", $cookie);
    $_COOKIE[trim($key)] = trim($val);
}