5.2 Other PHP Utilities: ADODB (Active Data Objects Data Base)
5.2 Other PHP Utilities: ADODB (Active Data Objects Data Base)
• ADODB (Active Data Objects Data Base) http://php.weblogs.com/ADODB : PHP's database access
functions are not standardised. Every database extension uses a different and incompatibile API. This
creates a need for a database class library to hide the differences between the different databases
(encapsulate the differences) so we can easily switch databases. ADODB currently support MySQL,
PostgreSQL , Interbase, Oracle, MS SQL 7, Foxpro, Access, ADO, Sybase and generic ODBC. See
also ADODB−manual. The PhpLens is based on ADODB.
• Metabase (Database independent access and management)
http://phpclasses.upperdesign.com/browse.html/package/20
• phpPDFtable is a class written in php to ease the creation of tables in PDF files. It requires php (4.0
but should run with 3.x too), and pdflib http://sourceforge.net/projects/phppdftable
• Data−Admin aims to provide a PHP based interface to Database Administration. This will not be
limited to just one or two databases. Also, the underlying class library encapsulates the native PHP
database calls allowing the programmer to use one set of fu http://sourceforge.net/projects/dadmin
• PSlib is a PHP library for generating PostScript files. It offers an easy way of generating PostScript
files: simple call PSlib functions from within your PHP script and the PS files are created on the fly
http://sourceforge.net/projects/pslib
• A complete collection of php scripts that work tightly together to create a highly customizable,
dynamic and module oriented website http://sourceforge.net/projects/twebs
• phpOpenTracker is a comprehensive solution for your site− and visitor−tracking needs. The collected
data is stored in a SQL database, allowing complex, yet easy analysis. A powerful API for analysis
and report generation (HTML or PDF output) is included. http://www.phpopentracker.de
• PHPShopCart is a shopping−cart web application demo written in PHP and designed to connect to a
MySQL database. It was written for the book, "A Guide to Databases under Linux" (Syngress Media)
but is available under the GNU Public License. http://sourceforge.net/projects/phpshopcart
• PHP Lens http://phplens.com is a rapid application development component which allows PHP
developers to dynamically and quickly create web applications that retrieve information from
databases. With phpLens, data can be presented as html tables with facilities to create, edit, paginate,
search and delete records. PHPLens uses ADODB. See also ADODB.
• ADODB (Active Data Objects Data Base) http://php.weblogs.com/ADODB : PHP's database access
functions are not standardised. Every database extension uses a different and incompatibile API. This
creates a need for a database class library to hide the differences between the different databases
(encapsulate the differences) so we can easily switch databases. ADODB currently support MySQL,
PostgreSQL , Interbase, Oracle, MS SQL 7, Foxpro, Access, ADO, Sybase and generic ODBC. See
also ADODB−manual.
• Metabase (Database independent access and management)
http://phpclasses.upperdesign.com/browse.html/package/20
• PEAR (PHP Extension and Application Repository) is a code repository for PHP extensions and PHP
library code similar to Perl's CPAN and is at http://lxr.php.net/source/php4/pear and pear−tutorials.
• Midgard is Content management system is based on Apache and uses the PHP scripting language
The main site of Midgard is at http://www.midgard−project.org PHP can be compiled with Zend
compiler and optimizer http://www.zend.com. PHP runs very fast and is about 5 to 10 times faster
than Java. See Midgard Installation
• Group IT Engine http://groupit.org is a turnkey group collaboration and content management engine.
It presently runs on Unix machines using PHP and Apache. Using GroupIT you can "Categorize your
content", "Organize your contents into sections", "Control access to your content" and many more
additional features.
• Smarty Template Engine − is a template engine for PHP. One of the unique aspects about Smarty that
sets it apart from other templating solutions is that it compiles the templates into native PHP scripts
upon the first invocation. After that, it merely executes the compiled PHP scripts. Therefore, there is
no costly template file parsing for each request. See Smarty QuickStart and docs about Smarty are at
http://www.phpinsider.com/php/code/Smarty/docs. Get it from download−smarty.
• DarkPortal is a Web portal system similar to PHPNuke. It is based on the user interface style of
Slashdot and other news/portal systems. It uses a modular core as a base for adding pluggable
modules to facilitate content creation and management. Its primary goals are full separation of
content from code, fully modular portal plugins with standardized APIs, portability and database
abstraction, user level theme selection and plugin module selection, and a modular user/group
hierarchy with multiple levels of moderation and admin capabilities. Visit DarkPortal
1. All private variables and functions always start with underscore "_" followed by lowercase letters
like var $_myvar;
2. All Protected variables and functions always start with "_T" followed by lowercase letters like var
$_Tmyvar;
3. All Public variables and functions do not start with underscore "_" like var $myvar;
4. All variables and functions always start with lowercase letter (no uppercase) like var $_myvar; and
NOT like var $_Myvar;
class someabc {
var $_conn; // Private variable
var $_Tmyvar; // Protected variable
var $connMYCONNECTION; // Public variable
var $connToDb; // Public variable
var $myvar3; // Public variable
var $myvarTHISTEST; // Public variable
The private, protected declarations provide the encapsulation and data−hiding. But you must consider the
following disadvantages of encapsulation:
• Encapsulation usually requires more code, hence it sacrifices performance especially for scripting
languages like PHP
• Since encapsulation unneccessarily increases the code size, it is not recommended for scripting
language like PHP.
• You can enforce a good degree of encapsulation by using the coding convention suggested in this
section.
8. HTML Editor
HTML editors for PHP on Windows 95/NT/2000 are:
• 1st Page 2000 − Rated 1st (the best HTML editor) http://www.evrsoft.com
• Cool Page − Rated 2nd http://www.coolpage.com
• Coffeecup − Rated 3rd http://www.coffeecup.com/editor
• Arachnophilia − Rated 4th http://www.arachnoid.com/arachnophilia/index.html
• Textpad http://www.textpad.com and textpad−php−add−ons
The best HTML editor is 1st Page 2000, and it is a excellent HTML editor.
You will notice that some of the PHP editors run only on MS Windows. Yes!! there are millions of PHP
developers on MS Windows platform. PHP is IMMENSELY POPULAR on Microsoft Windows platform
and is surprisingly more popular than Microsoft's own ASP web scripting language!! PHP runs lot faster
than ASP on MS Windows and has more features and functionalities than Microsoft ASP. PHP is much more
robust, reliable and powerful than ASP. There are more PHP users under MS Windows98/NT/2000 than on
any other operating system!! PHP initially started on Linux/unix environment but today there are more PHP
developers on MS Windows platform as compared to unix.
8. HTML Editor 11
PHP HOW−TO
• PHPAktThe PHP support in Macromedia Dreamweaver UltraDev that allows Ultradev Developers
to create PHP sites PHPAkt
• PHP Lens http://phplens.com is a rapid application development component which allows PHP
developers to dynamically and quickly create web applications that retrieve information from
databases. With phpLens, data can be presented as html tables with facilities to create, edit, paginate,
search and delete records. PHPLens uses ADODB. See also ADODB.
• PHP IDE and Editor "PHP Coder" http://www.phpide.de and mirror
• Zend PHP IDE http://zend.com/store/products/zend−ide.php
• IDE for PHP scripting (Web Browser) : http://www.ekenberg.se/php/ide
• Nexidion PHP IDE http://www.nexidion.org
• Enter in Search keyword 'PHP IDE' in Source Forge http://sourceforge.net
• Color editor gvim for PHP (Win and linux) at
http://metalab.unc.edu/LDP/HOWTO/Vim−HOWTO.html and see also ptags of PHP
• Rated 1st (the best PHP tool on MS Windows) : PHPTriad is a complete PHP development and
server environment for Windows. It installs PHP, Apache, MySQL, and PHPMyAdmin, both
installing and setting up the environment. PHPTriad is at http://www.phpgeek.com/phptriad.php and
at mirrorsite
• Rated 2nd : PHP Coder http://www.php−ide.com
• Rated 3rd: PHPEd (Soyal), an excellent PHP editor (MS Windows) http://soysal.free.fr/PHPEd
The ptags program for PHP is given below, which you can use to create the tags for PHP source code. Your
productivity will improve 3 to 4 times if you use ptags.
See also Vim color text editor for PHP, C, C++ at http://metalab.unc.edu/LDP/HOWTO/Vim−HOWTO.html
//*****************************************************************
// Copyright policy is GNU/GPL but additional request is
// that you include author's name and email on all copies
// Author : Al Dev Email: [email protected]
// Usage : ptags *.php3 *.inc
// This will generate a file called tags
//*****************************************************************
#include <iostream.h>
#include <fstream>
#include <stdio.h> // for sprintf
#include <stdlib.h> // for system
#include <string.h> // for memset
#include <ctype.h> // for isspace
system(buff);
fclose(fp);
*/
FILE *fpin = NULL;
fpin = fopen(argv[ii], "r");
if (fpin == NULL)
{
cerr << "\nError opening file : " << argv[ii] << endl;
exit(−1);
}
char buff[BUFF_LEN + 100];
memset(buff, 0, BUFF_LEN +10);
for ( ; fgets(buff, BUFF_LEN, fpin) != NULL; )
{
char aa[BUFF_LEN + 100];
char aapointer[BUFF_LEN + 100];
while (isspace(*dd))
dd++;
return dd;
}
{
if (ee == NULL)
return NULL;
<?php
?>
In your PHP source code initial page which is generally index.php3, put a line like
<?php
include ("debug2.inc");
init_debug_file();
// all other commands follows here ...
// ...........
?>
To output debug values, in your PHP source code files, put debug2_() calls as illustrated below:
<?php
include ("debug2.inc");
debug2_(__FILE__, __LINE__, "f_somevariable", $f_somevariable);
function aa()
{
$aa = 8;
debug2_(__FILE__, __LINE__, "aa", $aa);
}
?>
When you run the PHP program the output will be traced in the file called debug.out giving the filename,
linenumber, variable name and it's value.
Use the debug2_() generously in your code. The usage of debug2_() calls in your program will NOT have
any impact on the final production code and also has no impact on the performance because they will be
filtered out as described below. You can use copy and paste to save time of typing debug2() calls or use the
'yank to buffer' feature of Vi editor and paste.
When you are done development and testing and when you are ready to deploy on the production server,
filter out the debug2_ calls from your source code. At unix prompt −
And now copy the files from production to the deployment area.
The object oriented features of PHP is developing very rapidly and in near future will surpass the object
oriented features of Java language. All the object oriented features are implemented in PHP via
class keyword just like in Java.
If you want to use PHP as a stand−alone program, just like a shell script, "C" or perl program, then use this
technique:
The command php filename.php will execute the file filename.php. You are invoking the php program which
you wrote in filename.php from the bash commmandline instead of from the web−browser.
On Microsoft Windows platform you will bringup a MSDOS prompt from Start−>Run−>cmd and put
C:\Program Files\php\bin in your path environment and
PHP can also be used for developing standalone GUI applications for Linux/Unixes.
The Zdnet did a evaluation and benchmarking of 4 web scripting languages. During benchmarking, the same
spec and identical cpu, memory boxes were used. Under identical conditions, it was found that PHP was the
fastest − about 3.7 times faster than JSP and about 1.2 times faster than ASP. Read the report at eWeek and
mirror−site The benchmark results are −
Whenever you design a web site, give attention to these important points:
• Speed of web scripting engine − how many pages per second it can pump out.
• KISS policy (Keep It Simple Stupid!!) − your web page should be very simple without any fancy
graphics (because web users do not want to wait for long and they want the information very fast).
And information they read is just plain text!!
1. PHP is NOT 100 % pure Object Oriented scripting language. But in near future PHP may support
100% object oriented scripting (PHP may imitate most of the syntax of Java language). PHP already
imitates some features of Java language. (In future PHP language will imitate most features of Java
language and Java programmers will love PHP. And PHP will have java keywords like class,
extends, interface, implements, public, protected, private etc..).
2. PHP will NOT give the performance of "C" or "C++" language. Because it is scripting language and
is interpreted it will be a bit slower than the optimized "C++" programs. For top performance, you
should use "C++" and fast−CGI with database/webserver connection pooling and use C++ compiler
optimizer "−O3" options. Zend optimizer in PHP 4 will speed up the performance of PHP and bring
it very close to optimized "C" code .
3. But note a point that PHP was designed for very Rapid Web−Application Development tool. If it
takes about 3 months to code a web application in C++, then using PHP you can develop the same
web application in just 4 days!! And with zend optimizer, the speed of execution of PHP will be very
close to that of equivalent C++ program!! Hence, there is really no advantage in using C/C++ for web
development. PHP itself is written in 100% "C" language.
On the other hand, PHP has lot of advantages and it's advantages outweigh it's limitations −
1. You can very rapidly develop web applications in PHP as compile and link is eliminated in PHP
scripting language.
2. PHP applications are very stable and do not depend on the browser technologies unlike Javascript
applications which depend on browsers. PHP will give you the freedom to select any server platform.
The browser does not know that the HTML page is generated by PHP !!
3. PHP has excellent database conectivity to all SQL database servers.
4. PHP has partial support for Object oriented features
5. PHP has C++, Perl, Javascript like syntax features and has programs like 'ptags/ctags' to navigate the
source code
6. PHP has Zend optimizer which speeds up the performance
7. PHP runs on all unixes, linux, Windows 95/NT/2000 and is more powerful than ASP, JSP and others.
8. PHP has a very large user base and developer base.
See also Python: If you want 100% pure Object Oriented scripting language than you MUST consider
Python. The 'Python' is a object oriented scripting language from ground up. You would be using the Python
Web Application server called 'Zope' which is available at − http://www.zope.org and python is at
• PHP Resource index − important PHP site − has complete scripts, Functions, classes, documentation,
examples and tutorials http://php.resourceindex.com
• PHP portal http://zend.com
In this tutorial we assume that your server has support for PHP activated and that all files ending in .php3 are
handled by PHP.
Your first PHP−enabled page: Create a file named hello.php3 and in it put the following lines:
Note that this is not like a CGI script. Think of it as a normal HTML file which happens to have a set of
special tags available to you.
If you tried this example and it didn't output anything, chances are that the server you are on does not have
PHP enabled. Ask your administrator to enable it for you.
The point of the example is to show the special PHP tag format. In this example we used < ?php to indicate
the start of a PHP tag. Then we put the PHP statement and left PHP mode by adding the closing tag, ? > .
You may jump in and out of PHP mode in an HTML file like this all you want.
We are going to check what sort of browser the person viewing the page is using. In order to do that we check
the user agent string that the browser sends as part of its request. This information is stored in a variable.
Variables always start with a dollar−sign in PHP. The variable we are interested in is
$HTTP_USER_AGENT. To display this variable we can simply do:
For the browser that you are using right now to view this page, this displays:
There are many other variables that are automatically set by your web server. You can get a complete list of
them by creating a file that looks like this:
<?php phpinfo()?>
Then load up this file in your browser and you will see a page full of information about PHP along with a list
of all the variables available to you.
You can put multiple PHP statements inside a PHP tag and create little blocks of code that do more than just
a single echo.
<?php
if(strstr($HTTP_USER_AGENT,"MSIE")) {
echo "You are using Internet Explorer<br>";
}
?>
We can take this a step further and show how you can jump in and out of PHP mode even in the middle of a
PHP block:
<?php
if(strstr($HTTP_USER_AGENT,"MSIE"))
{
?>
< center>< b>You are using Internet Explorer< /b>< /center>
<?
}
else
{
?>
< center>< b>You are not using Internet Explorer< /b>< /center>
<?
}
?>
Instead of using a PHP echo statement to output something, we jumped out of PHP mode and just sent
straight HTML. The important and powerful point to note here is that the logical flow of the script remain
intact. Only one of the HTML blocks will end up getting sent to the viewer. Running this script right now
results in:
One of the most powerful features of PHP is the way it handles HTML forms. The basic concept that is
important to understand is that any form element in a form will automatically result in a variable with the
same name as the element being created on the target page. This probably sounds confusing, so here is a
simple example. Assume you have a page with a form like this on it:
There is nothing special about this form. It is a straight HTML form with no special tags of any kind. When
the user fills in this form and hits the submit button, the action.php3 page is called. In this file you would
have something like this:
Hi <?php echo $name?>. You are <?php echo $age?> years old.
Surprise!! The $name and $age variables are automatically set for you by PHP !!
Before we begin, let's quickly go over the concept of a session and the reason we need it. It's hard (for me) to
define what a session is exactly, so let's use an example that should be very familiar to you −− logging in to
your computer and using it every day. After you log in, your computer knows who you are. Every action that
you perform is done so with your name.
So what's so special about that −− we take it for granted every time we have to login to any system. What's
the big deal with doing this on the web? Well, the web (or specifically, the HTTP protocol) is connectionless.
That means each request made to a web server is independent of all the other requests. Whereas your
computer keeps information about you in memory and knows when you log in and out, a web server doesn't.
A web server simply waits for requests and sends responses.
Let's say we only have two people, John Doe and Jane Doe, accessing MyMarket, and their actions are like
this:
Since HTTP is connectionless, each request is completely isolated from the other requests. So how does the
server know who's doing what? How does the server know that actions 1, 3, 5 are from John, and actions 2, 4,
6 are from Jane? Well, to make a long story short, the web server doesn't have to know. It can continue on
happily responding to requests, session management has to be done with the backend scripting language.
What we need is a way to group together requests by the same person into the same session. This is where
PHP4's session management capabilities come in. It can group together requests made from the same source
(eg. client's browser) into the same session, we have to provide the smarts to associate users with sessions.
In other words, PHP4's session management can tell us requests 1, 3, and 5 belong to the same session (call it
session A). Our application has to know that session A is owned by John Doe.
session_start();
session_register();
session_start() is used to start up PHP4's session management capabilities; you need to call it before you use
any of the other session functions. session_register() is used to tell PHP which variables to track in the
session. A typical call to these functions would look like this:
session_register("SESSION");
This tells PHP to start up the session manager, and tells PHP that the variable called SESSION is a session
variable. You can register as many session variables as you like, but I prefer to only register one session
variable called SESSION, and anything I need persistent I put into this variable. For example, I like to say:
session_register("SESSION");
$SESSION["var1"] = 5;
$SESSION["var2"] = 6;
instead of
session_register("var1");
session_register("var2");
$var1 = 5;
$var2 = 6;
because after you register lots of session variables, you tend to forget what they were, well, at least I do :).
Anyhow, by now you probably want to see some code in action, so create a script called session_test.php
somewhere accessible, and put into it:
<?
session_start();
session_register("SESSION");
if (! isset($SESSION)) {
$SESSION["count"] = 0;
echo "<li>Counter initialized, please reload this page to see it increment";
} else {
echo "<li>Waking up session $PHPSESSID";
$SESSION["count"]++;
}
echo "<li>The counter is now $SESSION[count] ";
?>
Fire that up in your browser, the first time you hit the page, it should say " Counter initialized, please reload
this page to see it increment". Each time you reload it, the counter value should increment by one. You will
also see the session ID. If it does, then hurray, your PHP4 session manager works :)
So how does this work? Well, when you call session_start(), PHP4 determines a unique session ID for the
client. This session ID is an MD5 hash of something (not sure what), and it is stored as a cookie on the
client's PC.
Now each time that client makes a request, PHP4 will read this session ID and load up the data for the
session. When you call session_register(), you are telling PHP4 which variables you want kept in the session.
Each page that loads up, the previous values for the registered variables will be reloaded, and each time the
page ends PHP4 will save the values of the registered variables.
By default, PHP keeps track of the sessions in temporary files in the /tmp directory, take a listings and see for
yourself:
Each one of those files is a session, let's take a look at one of them (note, you probably have to su to root to
peek inside a session file). Tip: don't just cut and paste the following commands, you need to specify the
name of a real file:
# more /tmp/sess_a3058a6bb1baf57f565c3844c8810f4b
SESSION|a:1:{s:5:"count";i:234;}
Does that look familiar? It should if you've ever used the serialize() and unserialize() functions in PHP. If not,
don't worry about it. Anyhow, I just wanted to illustrate how sessions were stored. You can rewrite the PHP
session handlers to store sessions into a database or whatever else, but that's beyond the scope of this tutorial
(but it's not hard at all).
PHP can help us keep track of sessions, and group requests from the same session together. Now, we have to
do our part and associate user accounts with these sessions. We will use a variable called SESSION["user"]
to keep track of user information. When a user logs in, we will put their information into this variable. As
long as this variable is defined, we will assume that a user has logged in. When a user logs off, we will clear
out this variable.
SESSION["user"]["username"] This is the user's login ID (their nick name if you will), and it is
SESSION["user"]["firstname"] The user's firstname.
SESSION["user"]["lastname"] The user's lastname.
SESSION["user"]["email"] The user's email address.
SESSION["user"]["priv"] The user's privilege level.
Let's talk a bit about the privilege levels. We are going to have two levels of security: (1) normal customers
and (2) administrative users. Normal customers can use the system, browse through the catalog, and do other
customer functions. Administrators can do everything a normal user can do, but also has the ability to
perform system administrative functions. In real life, there are probably many more privilege levels that you
want defined but we are going to keep things simple here.
This is all fine and dandy, but where do we get this user information from? We need to have a way to store all
the users on the system, and the perfect place for that would be in the database. We're going to create a users
Notice the constraints we've put on the users table, the username is the primary key (which makes sense, you
should be able to identify a user record based on the username). The email address has a unique constraint as
well because we don't want duplicate email addresses.
Now let's add a record to create the root user with the password password:
Notice the password looks a bit wierd, 5f4dcc3b5aa765d61d8327deb882cf99. This is the MD5 hash of the
the word "password", I won't go into details here, but the important thing to note is that it's a one−way
algorithm and it always produces a 32 character string.
That's it, we have a users table to track our users, and one administrative account so we can try logging in and
out of the system using the example tar file (download the example tar file from
http://www.devshed.com/Server_Side/PHP/Commerce1 ).
• http://www.linuxdoc.org and click on HOWTOs and search for howto document name using
CTRL+f or ALT+f within the web−browser.
You can also find this document at the following mirrors sites −
• http://www.caldera.com/LDP/HOWTO
• http://www.linux.ucla.edu/LDP
• http://www.cc.gatech.edu/linux/LDP
• http://www.redhat.com/mirrors/LDP
• Other mirror sites near you (network−address−wise) can be found at
http://www.linuxdoc.org/mirrors.html select a site and go to directory
/LDP/HOWTO/xxxxx−HOWTO.html
• You can get this HOWTO document as a single file tar ball in HTML, DVI, Postscript or SGML
formats from − ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO/other−formats/ and
http://www.linuxdoc.org/docs.html#howto
Single HTML file can be created with command (see man sgml2html) − sgml2html −split 0
xxxxhowto.sgml
• Translations to other languages like French, German, Spanish, Chinese, Japanese are in
ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO and
http://www.linuxdoc.org/docs.html#howto Any help from you to translate to other languages is
welcome.
The document is written using a tool called "SGML−Tools" which can be got from −
http://www.sgmltools.org Compiling the source you will get the following commands like
• sgml2html xxxxhowto.sgml (to generate html file)
• sgml2html −split 0 xxxxhowto.sgml (to generate a single page html file)
Or you can use Ghostscript command ps2pdf. ps2pdf is a work−alike for nearly all the functionality of
Adobe's Acrobat Distiller product: it converts PostScript files to Portable Document Format (PDF) files.
ps2pdf is implemented as a very small command script (batch file) that invokes Ghostscript, selecting a
special "output device" called pdfwrite. In order to use ps2pdf, the pdfwrite device must be included in the
makefile when Ghostscript was compiled; see the documentation on building Ghostscript for details.
And you may have to manually edit some of the minor errors after running the perl script. For e.g. you may
need to put closing tag < /Para> for each < Listitem>
Then use the tool HtmlToHlp. You can also use sgml2rtf and then use the RTF files for generating winhelp
files.
And resize the window with mouse. To navigate use Arrow keys, Page Up, Page Down keys, also you can
use 'f', 'd', 'u', 'c', 'l', 'r', 'p', 'n' letter keys to move up, down, center, next page, previous page etc. To turn off
expert menu press 'x'.
You can read postscript file using the program 'gv' (ghostview) or 'ghostscript'. The ghostscript program is in
ghostscript*.rpm package and gv program is in gv*.rpm package in Redhat Linux which can be located
through ControlPanel | Applications | Graphics menu buttons. The gv program is much more user friendly
than ghostscript. Also ghostscript and gv are available on other platforms like OS/2, Windows 95 and NT,
you view this document even on those platforms.
• Get ghostscript for Windows 95, OS/2, and for all OSes from http://www.cs.wisc.edu/~ghost
gv howto.ps
ghostscript howto.ps
You can read HTML format document using Netscape Navigator, Microsoft Internet explorer, Redhat Baron
Web browser or any of the 10 other web browsers.
You can read the latex, LyX output using LyX a X−Windows front end to latex.
18. Copyright
Copyright policy is GNU/GPL as per LDP (Linux Documentation project). LDP is a GNU/GPL project.
Additional requests are − Please retain the author's name, email address and this copyright notice on all the
copies. If you make any changes or additions to this document then you please intimate all the authors of this
document.
<?
$database = pg_Connect ( "", "", "", "", "jacarta");
pg_exec ($database, "BEGIN");
$oid = pg_locreate ($database);
echo ( "$oid\n");
$handle = pg_loopen ($database, $oid, "w");
echo ( "$handle\n");
pg_lowrite ($handle, "foo");
pg_loclose ($handle);
pg_exec ($database, "COMMIT");
pg_close ($database);
?>
From the PHP 3 Manual: Works only if PHP is an Apache module. Instead of simply printing out the
$PHP_AUTH_USER and $PHP_AUTH_PW, you would probably want to check the username and password
for validity. Perhaps by sending a query to a database, or by looking up the user in a dbm file.
<?php
if (!$PHP_AUTH_USER)
{
Header("WWW−authenticate: basic realm=\"My Realm\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Text to send if user hits Cancel button\n";
exit;
}
else
{
echo "Hello $PHP_AUTH_USER.<P>";
echo "You entered $PHP_AUTH_PW as your password.<P>";
}
?>
As a web−developer, you're probably used to such lovely tools as ping, whois, nslookup etc. But what when
you need one of those utilities at a client's office and have no access to telnet? Good guess. Time to look up
the functions in the "Network" section of the PHP manual.
Socket operations:
The most important function there is fsockopen(). Using this function, you can connect to any open port on a
server and establish a socket connection with it. The function's syntax is as following:
The first two arguments are obvious, the next two are optional and used for error handling. The "errno" and
"errstr" should be passed by reference. "Passing by reference" means that the original variable will get
modified. Normally, the content of a variable passed to a function wouldn't be modified.
So, you could use this function to open a connection to a webserver and print out the headers:
In this example you see that you can apply any file operations (fread, fwrite etc) to the the pointer you got
using the fsockopen() call. Note that the example realizes a HTTP/1.0 client − it won't work with
name−based virtual hosts.
Finger: Naturally, you can also open connections to other ports. Writing a small finger client with PHP is
trivial therefore. Let's change the example from above to query a finger daemon:
fputs($fp, "$user\n");
while (!feof($fp))
echo fgets($fp, 128);
fclose($fp);
}
Blocking and non−blocking operations: But there's a problem with all those functions. They work fine if
Modifying these 3 functions to use non−blocking socket calls is left as an exercise for you.
Download the Midgard source tarball and read the INSTALL.REDHAT file −
bash# cd midgard−lib−1.4beta6
bash# ./configure −−prefix=/usr/local −−with−mysql=/usr/local −−includedir=/usr/include/mysql −−w
bash# make
bash# make install
bash# ldconfig −v | grep −i midga
Copy the header files, just in case make install did not do that..
bash# cp *.h /usr/local/include
bash# cd ../mod_midgard−1.4beta5c
bash# ./configure −−prefix=/usr/local −−with−mysql=/usr/local −−includedir=/usr/include/mysql −−w
bash# make
bash# make install
#modify apache line to correct /usr/.....
bash# vi /etc/httpd/conf/httpd.conf (or it is /etc/apache/httpd.conf)
bash# /etc/init.d/apache restart
#apache should restart!!!
bash# cd ../midgard−php−1.4beta6
bash# ./configure '−−with−apxs' '−−with−mysql' '−−with−pgsql' '−−with−midgard' −−prefix=/usr/loca
bash# make
bash# make install
#modify apache line to correct /usr/.....
# and add lines like these −
LoadModule php4_module modules/libphp4.so
AddModule mod_php4.c
LoadModule php4_module lib/apache/libphp4.so
<IfModule mod_php4.c>
AddType application/x−httpd−php4 .php4
AddType application/x−httpd−php4 .php
AddType application/x−httpd−php4−source .phps
AddType application/x−httpd−php .php
</IfModule>
<?phpinfo()?>
You should see a nice summary page showing all sorts of information about your setup. You probably
shouldn't leave this file around on a production server, but for debugging and general info during
development, it is very handy.
If you do not want the SSL to be enabled (or if you face any problem), then download the source RPM of
Apache−Midgard and edit the *.spec file and comment out SSL and rebuild the RPM.
<
?php
/* phpCodeSite (Idea from CodeSite − Raize Software)
* @version 0.1b − 20001125
* @author Sébastien Hordeaux − <
[email protected]>
* @licence GNU Public Licence
* Main site : http://phpcodesite.phpedit.com
*/
/*
** How does it work ?
Place a CS_EnterMethod() at the beginning of each method/function
Place a CS_ExitMethod() at the beginning of each method/function
Use CS_SendError() to log an error message
Use CS_SendNote() to log a simple note message
Use CS_SendMessage() to log a message
To log variables: CS_SendVar & CS_SendArray()
To see input data (global PHP variables) use CS_SendInputData()
*/
CS_SetEnabled(TRUE);
// CS_SetEnabled(FALSE);
CS_Write($CS_Enabled?"<
pre>":"<
/pre>");
}
// Log an item
function CS_Log($msg){
global $CS_Step;
for($i = 0; $i <
$CS_Step; $i++)
CS_WriteIndent();
CS_Write($msg);
}
// Exit a method
function CS_ExitMethod($methodName){
CS_DecStep();
CS_Log("<
−− $methodName\n");
}
// Log a note
function CS_SendNote($note){
CS_Log("[O] $note\n");
}
// Log an error
function CS_SendError($msg){
CS_Log("<
b>[E] $msg<
/b>\n");
}
// Log a variable
function CS_SendVar($varName, $value){
if(is_array($value)){
CS_SendArray($value, $varName);
}else{
CS_Log("[L] $varName = \"$value\"\n");
}
}
// Log an array
function CS_SendArray($array, $arrayStr = ""){
if(!empty($arrayStr))
CS_Log("\$$arrayStr");
if(count($array) == 0){
CS_Log(" = Array()\n");
}else{
CS_Write(" = Array(\n");
while(list($key2, $value2) = each($array)){
CS_WriteIndent();
if(empty($arrayStr))
CS_WriteIndent();
CS_Log("$key2");
if(!is_array($value2))
CS_Write(" => ".htmlentities($value2)."\n");
else
CS_SendArray($value2);
}
CS_WriteIndent();
if(empty($arrayStr))
CS_WriteIndent();
CS_Log(")\n");
}
}
?>