‘ PHP Scripting ’ category archive

PHP – A Vastly Superior Scripting Language

March 10, 06 by kenrich

I am continually amazed at the simplicity of web scripting using . Unlike Active Server Pages, you can perform complex tasks using only 1/3 the amount of code. Not only does this make the code easier to write, it is easier to read and maintain as well. When I first started Orvado, I wanted to develop all our code under PHP – I sure wish that we had gone that route now!

As an example, I had to write some code to load a template into a variable. Although file_get_contents() exists in PHP 5, I wanted something more portable so I used the function file. Using one function, I did the work that would take at least three lines in Active Server Pages. As I’m writing PHP, I find that the code is much easier to understand and maintain than the best ASP.

Another advantage of PHP is the huge variety of functions available to you. Unlike ASP which has somewhere around 200, PHP must have more than 1000. Many of the problems facing web developers have already been tackled by other PHP developers. I often find useful algorithms in the comments section of the PHP documentation. Common tasks such as “file upload” that require a specialized ActiveX component in ASP, are part of the core PHP language.

This brings me to one of the downsides of PHP – keeping track of which functions are supported in each version of PHP. If you want to make your code portable between many different servers, you will probably want to have compatibility with the lowest version of PHP (version 3.0 is probably as low as you want to go.) The good thing is that the PHP documentation site indicates the compatibility for each function. You can even write code that checks the PHP environment the script is running under and account for the functions that are available in that version.

ASP to PHP Script Conversion

March 01, 05 by kenrich

I’ve been plugging away getting my Intranet code ported to PHP. Currently, I have most of the COM objects and script libraries completed. Also, I have mastered some of the inconsistencies between the way PHP and ASP work.

For example, I was suprised to learn that PHP doesn’t have “application-scoped” variables that persist across the entire site (for all users.) I was able to find an informative article through Google that explained how to accomplish this using the shared memory module that is available for PHP.

So I think I finally have all of the major hurdles cleared. It should just be a simple matter of converting all of the scripts. I’ve made some improvements to my “ASP-To-PHP” conversion tool which will speed up the work. I’ve still got a long way to go to make this tool very powerful. My business partner believes this would be some software we could sell for a profit. If there’s one thing we could use right now, it would be profits!

Converting Web Pages from ASP to PHP

January 01, 05 by kenrich

Currently, I am working on a script that will convert an ASP web script into a PHP script. My company is seriously considering moving all of our servers to a Unix environment. While we could just go out and buy an ASP processor for Unix (like Sun’s), I think it would be better to use PHP since it is a much more powerful scripting language.

So I have started writing a script that will do some intelligent search-and-replace using regular expressions. Right now I have about 100 regular expressions written and it is quite slow in processing a single script. I really should have used a parsing tool such as Lex and Yacc to do an efficient processing of the source script.

I chose a script instead because I am more familiar with that and it eliminates the time-consuming process of writing conversion routines in C. Right now it seems like I will never be able to get this thing perfected 100%, but 99% would be really good right now. This could be a very useful tool that I might be able to sell to .other web site developers.

Wiki Web Site Authoring

December 29, 04 by kenrich

Today I tried out a new Wiki authoring software called PmWiki. For those of you who don’t know Wiki is a web site authoring tool that allows you to create pages, update or delete pages by using nothing more than a web browser. It is intended to be open for anyone to make changes or additions to the content in a quick and efficient manner.

With PmWiki, I believe I have found one of the most efficient Wiki platforms. While it is small, it still manages to provide a great set of features to make it a valuable platform for a new site or an addition to an existing site.

I have a Linux resource site that I need to modify to use this Wiki software. In combination with PmWiki, I am going to add the Phorums PHP message board software to make a community-supported documentation site. More details on this when I get ready to launch.

PHP BB Forum Vulnerability

December 23, 04 by kenrich

A news report on the Internet mentioned that a lot of sites were being hacked due to vulnerabilities in phpBB forum software. I believe that I have been a victim of this malicious virus. Somebody broke into our server about 8 months ago and wiped out a lot of our files. Specifically, they targetted all “index.html” and “index.php” files on the server.

It really makes me angry to see poorly written code such as this on software that was so widely used. Open-source software writers should work harder to maintain security in their products in order to promote industry acceptance. It’s events like these that give Microsoft another good excuse to badmouth Open Source and free software.

I’m glad that I have switched to Phorum instead of phpBB. It runs a lot faster than phpBB and has a large number of plug-ins to extend the functionality. I converted my forum site: WinXP Forum to this software just last month.

Phorum Message Board Software

December 09, 04 by kenrich

I’ve just been poring over the code for Phorum, the php message board
code. The code is easy to follow and well written. I commend the folks
who put this together. In addition to using this forum code to run my
site (http://www.winxpforum.com),
I have also planning on porting a lot of code from ASP to PHP. This code
is an excellent primer for how to write a PHP application for the
Web.

In particular, it excels at creating a modular architecture
with templates for each page on the site. You can change the site by
simply editting the templates. By keeping the code and the templates
separate, it makes it a heckuva lot easer on the HTML developer to mold
the forum to fit their site’s template.

Another thing the code does
well is to provide common “hooks” which you can attach events to. An
event can be either a PHP script to include at the appropriate location,
or a PHP function to be called. Using this system, it allows others to
create plug-ins that can easily be integrated into the system. I will
definitely be using this architecture when porting my site administration
tools from ASP to PHP.