‘ ASP Scripting ’ category archive

Comparing ASP to PHP Includes

September 10, 06 by kenrich

When comparing PHP scripts to Active Server Pages, there is a huge difference between the way you use include files. When using ASP, you either have to use Server-Side Includes or the Server.Execute statement to include one script inside another. In PHP, you have a lot more options. You can use “include”, “require” or “require_once” to include a file.

One of the shortcomings of Server-Sidie includes is that you cannot include a file more than once. This causes problems when you want to do a conditional include. In most cases, you will only need to include a filie once. One case where you might want to include a file twice is an admin login check. With such a script, you would check to see if the user is logged in and if not, you would display the login form. Because you want to include a header and footer in the login include and also include the header and footer on any admin page that includes the login check, you will need to include the header and footer twice.

If you declare any variables, constants, classes or functions in the header or footer, you won’t be allowed to include the file more than once. This would give you a “variable already declared” error. Even if the code is contained in a conditiona “if-then” statement, the parser will still process all of the code statements and recognize the duplicate variable declaration. You could used the Server.Execute statement but when you do this, the file is not truly included within the context of the current script. Instead, the script is executed standalone, and the output from that script is inserted into the current script.

PHP eliminates a lot of these problems by providing truly conditional includes. When you put an include statement within an “If then” statement, the code will not be processed until the script is evaluated and the condition is met. This eliminates the problem with redeclaring variabels inside header and footer. Additionally, PHP provides a new statement called “require_once”. This statement ensures that an include statement is only included once. Only when the require_once statement is first encountered, does each unique include file get included.

Using CDO to Build a Mailing List

June 07, 05 by kenrich

Last night I figured out to use CDO in Active Server Pages to use a remote server to send out e-mail through. This allows us to build web applications on a dedicated web server and send out mail through our “trusted” mail server.

This is most useful for mail servers like “AOL” which only allow mail from SMTP servers which have a “reverse DNS” setup. If you don’t use a trusted SMTP server, AOL will reject all of the mail that you send to it. This is a known security measure that AOL has had in place for many years.

On a positive note, I did make some improvements to our mailing list application. We can now send multi-part e-mails containing both an HTML and text message. Depending on the mail reader that the client uses, the proper format will be shown to the user. This should go a long ways towards creating and maintaining powerful e-mail campaigns.

Database Reporting Module

June 01, 05 by kenrich

Currently, I’m in the process of writing a reporting module for the Orvado Intranet. When designing the project, I did my best to try and keep things simple so development time would be short, but as these things tend to do, it ended up taking a lot longer than I thought.

The good thing is that it will be flexible enough to handle many different types of reports. Basically, a report is based on a series of SQL (database) statements that generate recordsets. These recordsets can be manipulated using a report template which will convert the data into a nice friendly human-readble format like HTML.

Most of the work has been creating a library to parse the macros in the report template. I’ve just about got a handle on it, but it still needs a little bit more work before I begin testing. The good news is: once that I’m done, I’ll have a nice framework for supporting macro substitution using template files which I can apply to lots of other projects.

Another Version of ASP Nuke is Launched

March 14, 05 by kenrich

A new release of ASP Nuke has just launched today. A few people were complaining about some bugs in the code so I went in and did some extensive testing and debugging. Usually, I like to add a lot of new features before releasing a new version, but this one really warranted a complete overhaul.

It’s hard to say what type of role this (my only) open source project will play in the future. Classic “Active Server Pages” is being phased out by Microsoft in favor of .NET. My focus is tilting more towards Linux and open source since I would rather benefit that community than the commercial Microsoft product.

One thing is for sure… development on ASP Nuke is bound to slow down considerably since I have a lot of work to do on PHP development. Now that this release is published, I can put all my efforts into finishing the porting of our Intranet code into PHP (and also related – my ASP-to-PHP conversion tool.)

Simple XML Parsing Library for ASP Nuke

January 28, 05 by kenrich

In preparation for adding theme support to ASP Nuke, I put together an ASP class that will parse an XML document and put it in a neatly organized class hierarchy. You can then query the document for a specific node or nodes and iterate over the results. This will be used to manage the configuration files for each ASP Nuke theme. The contents of which will be parsed and placed in the database.

The parser will handle multiple elements each with their own attributes. It can handle regular and self-closing elements and has no problems handling multiple elements with the same name. By using Microsoft’s regular expression parser I was able to make the entire process very efficient. The XML configuration files are not very big so it wasn’t too critical to make it efficient.

One thing I haven’t solved yet is what to do with content between an open and closing element which is embedded with sub-elements. My parser will parse the sub-elements just fine, but I haven’t worked out any way to handle content that is intermixed around the child elements. Maybe I will just wait until I absolutely need this functionality before I solve the problem.

Of course, I could have used Microsoft’s SAX XMLReader object to do the parsing. But I am always trying to keep the requirements for my Nuke software to a minimum so it is easy-to-install as possible.

Object-Oriented Programming is Cool!

January 26, 05 by kenrich

Here at work we have very little standards as far as “good coding practices” or general guidelines for architecting our web applications. Everyone pretty much does what they want to. This causes all sorts of headaches when someone else (namely me) has to go in and use their code or add on an additional feature.

As an example, one of our coders has decided that they wanted to do a totally approach to ASP () programming and place everything in class objects. Every query from the database is parsed and stored in a class or even a dictionary (hashtable) of classes. After which, we can begin doing the real work on the page.

Don’t get me wrong! I am all for object-oriented programming and understand the benefits it can offer, but ASP has such weak support for OOP that the benefits aren’t really worth the extra time it takes to program pages that way. It is just a lot of extra code that takes more of my time to maintain. Maybe our programmer here is looking forward to the day when we convert all of our ASP web pages into Dot NET. Either that or they just like to see the “auto-completion” feature in Visual Studio .NET.

New Version of ASP Nuke Released

September 17, 04 by kenrich

Today I finished packaging and launching the latest version of ASP Nuke. It is available for download off of the home page (ASP Nuke Home Page) This version adds support for MySQL which is an open source database server which can be obtained free of charge.

This week will mark the 1 year anniversary of the project that I have
developed solely on my own in my free time. I have placed a link for
donations on the site but so far have not received a single penny in
donations. It’s okay though because I really wasn’t trying to make a lot of money with this project. It’s more to showcase my skills and help out others who want a powerful and dynamic web site but don’t have the time or motivation to build it.

With the new support for two different databases, it should expand the audience of people who use my software and allow me to make further enhancements along the way. A large majority of the major bugs have already been fixed since the site has been in use for a year and I get instant notification of scripting errors that occur on the site.

One of my next steps for the project will be to create a “snapshot” of the database structure so that I can build a “database migration script” when I launch the next version of ASP Nuke. But first I will probably relax and work on some other projects that I have been neglecting.

Working Towards a New ASP Nuke Release

September 16, 04 by kenrich

Life is good, the boss just left town this morning and is headed out of the state. This gives me a little time to relax and recharge my
batteries. Don’t get me wrong, I still have plenty of work to do. It’s just that working a lot of overtime tends to burn you out pretty quick.

I am working toward wrapping up my new release of ASP Nuke (as I mentioned before). Today, I finished up the initial implementation of a MySQL database management tool that allows operators to create and alter tables as well as manipulate the data rows stored in each table. I finished the scripts to add, edit and delete records from a table today and I was happy with how smoothly the work progressed. Hopefully I can get this pig launched soon and start working on my next project.

I watched the movie “Hero” last night starring Jet Li. This was the
second time I have seen it and I must say that the story is very original. Of course, the story is based on Chinese history/legend so it had a lot of help there. There is a lot of fantasy in that movie much like the earlier success: “Crouching Tiger, Hidden Dragon”. The performances by Tony Leung Chiu Wai (Broken Sword) and Maggie Cheung (Flying Snow) were exceptionally good. Check this movie out if you get a chance.

The weather has finally cooled off quite a bit down here signaling the end of summer. It is really nice now, especially since I don’t have air conditioning in my house. I ordered a new hard drive for my laptop computer (60GB for only $60). Someone suspects this was a price error, but my order went through fine and I haven’t received any email telling me the item is a price error. “Party on Wayne, Party on Garth”!

Bye Bye ASP Nut, Hello ASP Nuke

September 01, 04 by kenrich

Well, today finds me in my new role as e-mail blast administrator. This will be my role on every Wednesday from now on. Since a friend of mine just left the company to works somewhere else, the task has fallen upon me now. I can’t say it’s all that difficult. It simply involved cutting and pasting text from a Word file to an HTML and text e-mail and then cleaning up the formatting. I have most of the work done already. Currently, I am delayed because our mail server has gone down and I can’t get the information I need to finish the setup and mail the next person in the chain.

On the personal side, I have switched my attention from ASP Nut
temporarily to ASP Nuke (yeah, funny how my sites have a similar name
huh?) I haven’t made any updates to ASP Nuke (an open-source web portal application) in over a year and there are some major fixed that need to be made. Also, this new version will see the introduction of support for the MySQL database (a free database server for Windows and Linux).

I am going to give ASP Nuke a quick “once-over” and then build a package for Source Forge. It should generate a lot more traffic and attention for my site since the main drawback it currently has is that it only supports Microsoft SQL Server which costs quite a bit of money. Not exactly the type of thing you want to tie a free software project to.

ASP Nut Script Archive

August 31, 04 by kenrich

I have just opened up a brand new script archive for ASP Nut that will allow users to find useful code for Active Server Pages. In one day, I built the administration and the front-end and although it is not complete, it does have the following features:

  • title, meta keywords and meta description
  • Syntax highlighting for ASP code
  • Dynamic categories allowing one script to be placed in 1 or multiple categories
  • Author information coming from an admin
    user or site member

At some point in the future I will be adding a search facility to make locating scripts easier and also a way for site members to submit code samples. This is not too high a priority since I haven’t received any contributions to the site to date.

I will gradually be adding scripts to this repository with the goal of providing a valuable resource to the ASP development community. If you would like to check it out, you can go to ASP Nut Scripts now to view the script archive.