Getting include files to work on Windows 2003

I recently been playing around with Windows 2003 because we are still running Windows 2000 Server at work and may be upgrading soon. Our ASP pages are using includes to our database connection page…

<!–#include file="some_folder/db_connection_file.asp" >

If you were to run a page with that code on a Windows 2003 server, you may get an error similar to…

Active Server Pages error ASP 0131
Disallowed Parent Path

To fix this error, I had to do the following:

  1. Create a new virtual directory of the folder that contains the files. We’ll call the virtual directory “example”.
  2. Update the include syntax to use virtual instead. So you’ll have something like
    <! #include virtual=example/some_folder/db_connection_file.asp >
    

You may get this error with javascripts as well if you have something like…

<script language=javascript src="../some_folder/my_script.js"></script>

You should update that syntax to something like…

<script language=javascript src=/example/some_folder/my_script.js></script>

I’m not a big Windows user anymore so I don’t know why it has to be done this way or know of a setting so that the old method still works. But those are the 2 changes I had to make on some of our websites to make them compatible with Windows 2003.

Installing PEAR on Godaddy shared accounts

I recently found out how to install PEAR on a Godaddy shared hosting account.

  1. Visit http://pear.php.net/go-pear. Save the text displayed onto your desktop and name it go-pear.php. Upload this to your server. If you’re hosting multiple domains on the account, it’s best that you should upload this file in your root folder. Run this file on your browser and follow the on-screen instructions.
  2. After completing the installation, it is time to edit your php.ini file. If you are running PHP4, there should be a file in the root directory called php.ini. If you are running PHP5, there should be a file in the root directory called php5.ini. If not, create one and add the following: include_path = “.:/usr/local/php5/lib/php:/home/content/s/a/m/sample/html/PEAR”. Keep in mind that /s/a/m/sample is just an example. Doing this will ensure that every page, you create, will look in the PEAR directory so that you it will use the installed packages.
  3. This installation will include Pear_Frontend_Web which is the web-based admin interface. It may have created an index.php file in the directory where PEAR is installed (root). If not you can get a copy from PEAR/docs/PEAR_Frontend_Web/docs/index.php.txt. I would suggest creating a folder called pear_admin in the root directory and storing this file there. If you didn’t install PEAR in the root directory, you may need to edit this file accordingly.
  4. You will need to create a .htaccess and .htpasswd file in the same directory as the index.php file. An example of how the .htaccess file should look as follows:
    AuthUserFile /home/content/s/a/m/sample/html/pear_admin/.htpasswd
    AuthType Basic
    AuthName “Web-based PEAR Frontend”
    Require valid-user

    An example of how the .htpasswd file should look as follows:

    admin:cGyUX9QugYMgE

    This will create “admin” as the user name and “password” as the password. You can generate your own by going to this link – http://www.htaccesstools.com/htpasswd-generator/

    Be aware that files beginning with a dot are invisible. You may have to edit your settings on the FTP app you’re using so that you can see them.

Once the files are created and saved, you can now go to http://your-domain.com/pear_admin/index.php. It will ask for the user name and password. Once you are logged in, you can now manage Pear via web browser. That’s it! Now you can run PEAR on a shared account from Godaddy. One less complaint 🙂

Started playing with .Net

I’ve tried in the past to get .Net installed on one of my PCs. I always got errors after the install and just gave up. It’s only to get familiar with it. I usually have a Linux box as a web server anyway and we’re still using classic ASP at work. But as more projects come my way at work, I found using PHP to create different things that classic ASP can’t do. It’s not recommended but it’s a quick fix since many of the projects need to be finished ASAP. All of the sites we develop at work is written using ASP 3.0. But things like handling emails, exporting records to Excel, and uploading files can be created with more features using PHP. The transition between an ASP to PHP page isn’t something that you should do but was necessary for us to complete the project in time.

Why don’t we just develop in PHP or .Net? Well there’s a couple of reasons for that.

  • Majority of our servers are Windows. In the beginning, the IT department wouldn’t support anything but Windows servers. But since they don’t support us anyway, and we do our own support, we can use pretty much any server OS we want. We do have 3 OS X servers that can run Apache.
  • It would take a longer time to re-code already working web sites running ASP and MSSQL Server 2000 to PHP5 and MySQL or .Net. Not only do we have to re-code them, the testing would take just as long. We have to ensure that the sites work on both Windows and OS X platform and their supported browsers. It pisses me off so much going to a site that doesn’t work on the browser I use. So I make sure it doesn’t happen to any of the visitors going to the sites I develop.
  • No money to purchase new Windows hardware/software. Although, our current Windows servers are running fine, if we were to start using .Net, it would be best to run it using the Windows Server 2003 and more hard drive space. We currently are running Windows 2000 Server and MSSQL Server 2000.

So I started to play with .Net again. Luckily we got our hands on Parallels for our iMacs. We can now test on different OS and server environments. I finally got to install .Net 2.0. I know there’s 3.0 and 3.5 releasing in the near future. But I want to do baby steps. So far I have been impressed. I have been having trouble converting a site from ASP to .Net. Particularly with the user authentication. I still have to figure out how the login page will query the database.

For now, I may just try to convert features I wrote on PHP to .Net and add them to the existing ASP sites so that the transition between the pages will be smoother, less of a security risk, and easier to manage.