Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 1
PHP3 Guide
6 APPENDIX B - SHELL COMMANDS 32
6.1 C
7
7.1 S
OMMANDS 32
APPENDIX C - PHP3 SCRIPT EXAMPLES 35
CRIPT EXAMPLES 36
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 2
PHP3 Guide
1 Why PHP?
PHP, which stands for "PHP: Hypertext Preprocessor" was chosen as the scripting
language to use in some Axis Video products since:
! PHP is a well-known and widely used scripting language; in Feb 2001 an
estimate of 23% of all Internet web servers used PHP (nearest "competing" script
language was Perl with about 7%).
! The language syntax closely resembles Java, Perl and C, making it easy to learn
for anyone with basic programming skills.
! Version 3, PHP3 could easily be scaled down to a smaller footprint required for
embedded devices.
! PHP enables the creation of dynamic web pages quickly; the PHP code is simply
embedded into the HTML code. At the most basic level PHP can do anything
that any other scripting language or CGI program can do, such as collect html
form data and generate dynamic page content.
! PHP is a complete scripting language with functionality such as file operations,
network sockets, e-mail client (SMTP) and an FTP client. All very useful in
Network Camera applications.
The integration of event handling in Axis Video products, and a powerful scripting
language such as PHP, gives knowledgeable developers endless opportunities to tailor
the functionality of Axis Video products to fit their specific needs.
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 3
PHP3 Guide
1.1 What is PHP
PHP (officially "PHP: Hypertext Preprocessor") is a server-side HTML-embedded
scripting language.
Simple answer, but what does that mean? An example:
Notice how this is different from a CGI script written in other languages like Perl or C
-- instead of writing a program with lots of commands to output HTML, you write an
HTML script with some embedded code to do something (in this case, output some
text). The PHP code is enclosed in special start and end tags that allow you to jump
into and out of PHP mode.
What distinguishes PHP from something like client-side JavaScript is that the code is
executed on the server. If you were to have a script similar to the above on your
server, the client would receive the results of running that script, with no way of
determining what the underlying code may be. You can even configure your web
server to process all your HTML files with PHP, and then there's really no way that
users can tell what you have up your sleeve.
A lot of information about PHP can be found on the Internet:
http://www.PHP.net
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 4
PHP3 Guide
2 PHP3 and the Video Server
Axis has removed some functions from the standard PHP3, and created some
additional functions to suit our products. The name of Axis´ modified version of
PHP3 is called PHP3-Lite. The functions among others, that are removed are those
that handle:
! Database functions
! PDF functions
! Mathematic functions
Axis recommends checking that PHP3-Lite supports the functions required before
creating custom scripts. This can be checked by looking in the PHP3-Lite manual on
our Web site: http://www.axis.com
There are some applications that are shipped with the Axis 2400/2401 products;
besides these applications the additional PHP3-scripts that define extra functions are
explained in Appendix A at the end of this document.
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 5
PHP3 Guide
3 PHP3 script
Before making custom scripts Axis recommends looking at our PHP3-Lite manual
(short description about this on the previous page). You can find the manual on the
Axis Web site:
http://www.axis.com
Note: Axis Communications AB provides
shown here will work for a particular application.
Axis Communications AB
inflicted to any device as a result of the examples or instructions mentioned in this
document.
Axis Communications AB reserves the right to change this document without prior
notice.
cannot and will not be held liable for any damage
no guarantee that any of the examples
!!! WARNING !!!
Please keep in mind that the manufacturer of the flash chips estimates the
number of writes to the flash chips to about 100,000.
Writing a lot of temporary files to flash must thus be avoided.
Use the ram disk mounted on /tmp instead.
3.1 Limitations
For the moment it is not possible to activate more than one script at a time. So if many
scripts need to be running at the same time, then delay upgrading the Video Server
with Linux!
Note: It´s not possible to downgrade to OSYS again, after having
upgraded to Linux
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 6
PHP3 Guide
3.2 Requirements for getting started:
! Web browser
! FTP Client
! Text Editor
Recommended:
! FTP Server
! SMTP Server
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 7
PHP3 Guide
3.3 Scripts
Tip: A very useful program to fetch or upload a script to the product, is Ultra Edit;
This can be downloaded from the following Web site:
http://www.ultraedit.com/
Tip: To log all possible errors, include the row
error_reporting(E_ALL);
in the script.
Turn off this option with the row:
error_reporting(0);
3.3.1 Complete script examples
It´s possible to create scripts and put them inside the video server. In Appendix C of
this document are complete PHP3 scripts that can be used, which are customized for
the most common applications. To run these scripts a task.list file for each script is
attached (read more about task.list in section 3.3.3). Scripts for the following
applications are available:
! A script that will upload specified images buffers via FTP and the Ethernet
interface.
! A script that will upload specified image buffers via FTP and the Ethernet
interface, and also send a mail as specified
! A script that will upload specified sequential images via FTP and the Ethernet
interface. The uploaded images will be named according to the parameter $suffix.
! A script that will upload specified sequential images via FTP and the Ethernet
interface. The uploaded images will be ordered in a structure defined by their
date.
! A script that will upload specified image buffers via SMTP and the Ethernet
interface.
! A script that will upload specified sequential images via FTP and the Ethernet
interface. The uploaded images will be ordered in a structure defined by their
date. Upon alarm event (indicated by an existing file named according to
$alarm_file) images from the alarm buffers will be uploaded and a mail will be
sent as specified by the appropriate parameters.
How to upload a script to the video server and to run it is shown in section 3.3.4 and
3.3.5.
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 8
PHP3 Guide
3.3.2 Script generated by the Application Wizard
The wizard in the video server can generate the most basic scripts, and these can then
be extended and modified to fit a particular applications needs though Axis
recommends creating the scripts from scratch and putting them inside the video
server. How to accomplish the above, follow the instructions on the next page.
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 9
PHP3 Guide
3.3.2.1 Get the script that the wizard in the Video Server has created
Start by going through the wizards in the Video Server, then open an FTP session to
the Video Server. Follow the instructions below to see how this can be accomplished:
Open a DOS session and type the following commands:
1. Go to the path where the script is saved
Eg: c:\axis\php
2. ftp <ip-address to the camera>
Eg: ftp 10.13.9.73
3. Type the user name
Eg: user name: root
4. Type the password
Eg: password: pass
5. Type: bin
6. Type:hash
7. Type: cd etc
At startup, utask reads the file /etc/task.list and parses it for event entries.
Therefore, it must be fetched to be able to run the script in an automatic fashion.
(See also section 3.3.3 The task-Scheduler.)
8. Type: get task.list
9. Type: cd php
10. Type ls to see the file names for the files that the wizard has created:
Ex: ls
11. Type: get <the script that is to be changed>
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 10
PHP3 Guide
Note: After having created a script with the application wizard, push the
remove button or restart the unit before creating a new one! (This doesn't work
if it's a script that has been created from scratch, then the script has to be killed
by using telnet).
After following the steps on the previous page, it is possible to look at the script that
the wizard in the Video Server has created (use for example Notepad to open the
script).
Wizard Variables Explanation
$buffer_prefix=”“;
$source[] =
$image_format=““;
$file_format=““;
$pre = ;
$post = ;
$predelay = ;
$postdelay = ;
$host = "10.13.9.70";
The prefix of the name of the buffer(s)
started.
The index or the name(s) of the
buffer(s) started.
The value must match the bufferd
arguments.
The format of the images specified to
be taken according to the HTTP-API.
The name to be given to the local file,
excluding the extension.
Number of pre alarm images to be taken.
Number of post alarm images to be
taken.
Delay between pre images in
milliseconds.
Delay between post images in
milliseconds.
The server to upload to
$body = “”;
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
The body to insert into the mail. Note
that this must be specified and point
The user to login as.
The password to use for the user.
The port to connect to.
Choose passive mode on (“yes” or off
(“no”).
The time, in seconds, to stay in the
script. Specifies whether to leave the
FTP-function or not, after upload,
($time="0") leave the FTP function
($time="-1") continue uploading
Specifies the (approximate) delay in
milliseconds between image taken when
$time="-1".
The path to append to all uploads. This
path must exist on the server prior to
upload.
Do not change name of the file put on
the server, i.e. overwrite the old file
on server append the date to the name
of the file put on the server.
$suffix ="sequence";
Append a sequence number to the name
of the file put on the server.
$suffix ="sequence_max";
Append a sequence number to the name
of the file put on the server up to a
maximum number
$suffix_counter = 0"; $countermax ="";
Only used if $suffix ="sequence_max"
$startcount="";
shoot(2,30000);
Only used if suffix =
"sequence"|"sequence_max"
Set parameters for the image-format.
Compose the command to run for imagetaking.
3.3.3 The task-scheduler
The task-scheduler is used to start programs or scripts when certain events occur. The
scripts can be shell-scripts or PHP3-scripts, and can start the buffering of images or
upload files by using FTP or SMTP.
The task.list is the configuration file for utask which is a task-scheduler similar to
cron or at. The task.list features event-detection, based on date and time, a simple
socket for external events, and the ability to start any task and process management to
avoid runaway childs processes.
At start-up, utask reads the file /etc/task.list and parses it for event entries. If the file
/etc/task.list does not exist when utask is started, then utask goes into a stand-by
mode. When /etc/task.list has been created, or modified, a SIGUSR1 need to be sent
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 12
PHP3 Guide
to utask in order for it to reread /etc/task.list. This can be done by issuing the system
(Telnet) command 'kill -10 <utask-pid>'.
3.3.3.1 Syntax
An entry in /etc/task.list has the following syntax :
<event>%<program>:<args>;
<event> = is the event description
<program> = is the program to start
<args> = are the arguments to be passed to <program>.
<event>
The maximum number of events is 64. An event description should contain one or
more of the following definitions.
Definition Meaning
[hh:mm-hh:mm] - Time period
time( h(...) m(...) s(...) ) - Time(hours,minutes,seconds)
[dd/mm-dd/mm] - Date period
date( w(...) m(...) d(...) ) - Date(day,month,date)
pattern( (...) (...) ... ) - External events
once - Start only once
immune - Never interrupted
Time and Date values are given as a list of values (separated by a comma) and/or
intervals (separated by a minus sign):
Hour = 0-23
Minute = 0-59
Seconds = 0-59
Day of the week = 0-6 ('0' means Sunday)
Month = 1-12
Date = 1-31.
Patterns are defined as strings and follow the specific format <Client>:<Data>;
<Client>
Is the client application sending <Data> to utask. The Data has to be atomic i.e. if the
client wants to notify two events at the same time, it has to write
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 13
PHP3 Guide
<Client>:<Data1>;<Client>:<Data2>;.
These patterns are read from /tmp/utasksocket. By default, if an event is trigged, the
program runs, exits and starts again as long as the triggering event is valid.
utask start at most five (5) child-processes. When the maximum number of child
processes has been exceeded, utask has to decide how to proceed. utask usually kills
the process with the lowest priority (if the pending task has a higher priority than this
process). The entries in the configuration file (task.list) are ordered by growing
priority, i.e. later entries precede earlier entries.
'once'
Specifying 'once' tells utask to skip starting the program as long as the event has not
been invalidated. utask checks for events ten times every second (if not in stand-by
mode). Thus, if an event is specified to run at a certain point in time, say 'time(h(0)
m(0) s(0) )', then this would run the program up to ten times since the event is active
during a whole second.
'immune'
utask also provides the user with the possibility of protecting child processes to be
prematurely killed by using the 'immune' tag in the script entry. An 'immune' script
will always run until it terminates.
3.3.3.2 Examples
Here is an example of a task.list.
The first two entries uses PHP3 to execute scripts mentioned later in this document.
# FTP transfer once every 15 minutes uninterrupted.
time(m(0,15,30,45)) immune once % /bin/php : ./ftp.php;
# Mail the current syslog once every day.
time( h(0) m(0) s(0) ) once % /bin/php : ./mail_syslog.php;
# Sends and alert message every time I1 and I2 are high at the same time...
pattern((IO1:H)(IO2:H)) once % alert : "Input 1 and 2 detected";
3.3.4 Put a new or changed script inside the Video Server:
If a new script is created or something has been modified in the script that the wizard
has created, then the new file must be uploaded into the Video Server. To do this
follow the instructions below:
Note: When writing the scripts use for example Notepad.
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 14
PHP3 Guide
Upload a PHP3 file into the Video Server
1. Open a DOS session and open an FTP session from the path where the PHP3
file resides.
Eg: c:\axis\PHP
2. Check that the file exists by typing dir
Eg: c:\axis\PHP dir
3. If the file is to be executed as a link, then the file has to have the extension
PHP3. If the file doesn't have this then rename the file with the DOS command
ren.
Eg: c:\axis\PHP ren script.doc (the old filename) script.php3 (the new
filename)
4. If the file exists and has the correct filename, then open an FTP session to the
Video Server:
Eg: c:\axis\PHP ftp <the Video Server ip-address>
5. Then type the user name:
Eg: c:\axis\PHP user name: root
6. Then type the password:
Eg: c:\axis\PHP password: pass
7. Type:
Eg: c:\axis\PHP cd etc/httpd/html
8. Then upload the file to the Video Server with the command: put
Eg: c:\axis\PHP put <filnamn.php3>
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 15
PHP3 Guide
3.3.5 How to activate the scripts?
Important! Before activating a new script, restart the video server.
3.3.5.1 URL
This is the way Axis recommends to activate the scripts.
To activate the new script, follow the instructions below:
1. Open the browser (Tested browsers are Netscape and Internet Explorer)
2. Type the IP-address for the Video Server in the URL:
Eg: 10.13.9.75/local
3. If the file doesn’t appear click the Refresh button in the browser.
To activate the script select the file.
(If it still doesn’t happens anything look at the log file for errors)
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 16
PHP3 Guide
3.3.5.2 Telnet
For development it might be useful to connect to the Network Camera by Telnet.
Depending on what product is used, this is either enabled by default and have
authentication or can be enabled by editing the /etc/inittab. If the product require
editing of the /etc/inittab, there will be no authentication for the Telnet connection and
no password will be required for access.
Important: Enable this option for experimental use only. Never leave the Telnet
access enabled when having the Network Camera installed on a public site.
3.3.5.2.1 To enable Telnet support
Open an FTP session towards the Network Camera and type the commands viewed in
bold below:
C:\Axis >ftp <ip address of camera>
Connected to <ip address of camera>
220 Axis 2100 Network Camera 2.12 Feb 05 2001 ready.
User (<ip address of camera>:(none)): root
331 User name okay, need password.
Password: pass (if not changed from default)
230 User logged in, proceed.
ftp> ascii
ftp> cd /etc
ftp> get inittab
200 Command okay.
150 Opening data connection.
226 Transfer complete.
ftp: 1380 bytes received in 0,01Seconds 138,00Kbytes/sec.
At this stage, open the downloaded inittab file in an editor and find the following line:
#telnetd:3:respawn:/bin/telnetd
Remove the preceding ”#”:
telnetd:3:respawn:/bin/telnetd
Save the file
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 17
PHP3 Guide
Go back to the ftp session and continue:
ftp> put inittab
200 Command okay.
150 Opening data connection.
226 Transfer complete.
ftp: 1414 bytes sent in 0,00Seconds 1414000,00Kbytes/sec.
250 Command successful.
ftp> by
221 Goodbye.
Restart the camera and it will be possible to access with Telnet.
Activate the script through telnet
To activate the script through telnet, follow the instructions below:
1. Open a telnet connection to the Video Server.
2. Type the Video Server IP-address as the Host Name:
Eg: 10.13.9.73
3. Then log in with the cameras user name and password
Eg: user name: root
Eg: password: pass
4. Type: cd etc/httpd/html
5. check that the file exists with the command ls
Eg: ls
6. Then activate the script by typing:
Eg: php <filename>
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 18
PHP3 Guide
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 19
PHP3 Guide
4 Troubleshooting
Tip: To log all possible errors include the following row in the script:
error_reporting(E_ALL);
Turn off this option with the following row:
error_reporting(0);
4.1 PHP3 script related problems
Axis Communications AB does not provide support for application development of
any kind. The information here is provided "as is", and there is no guarantee that any
of the examples shown will work in your particular application.
4.2 Product related problems
If any problems occur, please try these steps first before contacting a local supplier:
1. Consult the Axis product Users Guide Appendix A - Troubleshooting.
2. Go to the AXIS product Support Web, available from www.axis.com and
verify that the product contains the latest available software version. Updated
trouble shooting information and the latest software for the unit can be found
here.
3. Consult the FAQ and technical notes on the Axis product support page for
additional help.
4. Contact the local supplier, from whom the product was purchased, for
assistance.
The Log file can prove a useful diagnostic tool when attempting to resolve any
problems that might occur: from the
records, events, and commands executed by the product since the last
system. Always attache the log file and parameter list when contacting Axis support.
Support menu, click Log File to display the latest
Restart of the
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.91 June 2001 20
Loading...
+ 46 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.