In this article we will pass a parameter to a PHP script via a URL, and we will get a little more sophisticated in our conditionals and regular expressions. One problem with accepting parameters is that there are often security issues. It is very important to ensure that the parameters passed by the user conform […]
Programming With PHP – Part 3
Parsing Web Logs Into Calendar Text/Stats
We aren’t quite happy with the web stats software we use. The information is not brief enough. Mostly, we want to see the last couple months, with the weekends visible, and the unique hosts and pages viewed. Also, we have a lot of content that gets snagged that isn’t really what we consider a valid […]
Apache Tip – Take Clues Away from Bad Guys
Like the needy stranger who tells us his or her entire life story on the occassion of our first meeting, Apache spews out way too much information in every HTTP header. And like the unscrupulous sharpies who take advantage of lonely folks they meet on buses, there are those who would use this information to […]
Having Fun With Forums and RedirectPermanent
One thing that is quite prevalent in forums is sharing images as postings or as avatars. We saw that our RoboCoop was getting some hits, and wondered what was up. Well, there is a forum that has a daily discussion in Texas here that had put up a link to the image of our chicken […]
Using Tab2space to Convert Tabs to Spaces in Source Code
We often need to convert source code into html format. We use the pre tag; however, the default tab values are to wide. For instance: this is one tab this is another If we were to put some of our funner source code up, it would push the right margin over too far. Well, we […]
Installing and Configuring the Java SDK
Grab the sdk from java.com. For us, we are going to install this on Lobstora, which is a GNU/Linux box. Just make the binary executable and run it: [root@srv-1 opt]# chmod 700 j2*.bin [root@srv-1 opt]# ./j2sdk-1_4_2_03-linux-i586.bin We like putting this in /opt with a symlink to j2sdk. [root@srv-1 opt]# ln -s j2sdk1.4.2_03 j2sdk [root@srv-1 opt]# […]
Installing Tomcat
Tomcat is part of the Apache Project. Tomcat, which is free and open-source, can serve up JavaServer Pages (JSP). For more info on this, see J2EE JavaServer Pages Technology. The JavaServer Pages FAQ is here. We were a bit lazy, and grabbed a binary from here. Make sure you have Java installed. We installed Java […]
Creating a JavaServer Pages Application
In this article we installed Tomcat so that we could serve JavaServer Pages (JSP). JSP is pretty easy to start off with, since you merely add the script parts to regular HTML, much like PHP. For instance, we could call this HTML hellow.jsp: <html> <body> Hello </body> </html> If we browse to our JSP server, […]
Setting up Initial Tomcat Administration
There are a couple web-based administration tools that come with Tomcat, but you have to set up the admin and manager access first. This is done by adding a line to tomcat-users.xml: [root@srv-1 conf]# pwd /opt/tomcat/conf [root@srv-1 conf]# vi tomcat-users.xml Add the line with admin,manager in it: <?xml version=’1.0′ encoding=’utf-8′?> <tomcat-users> <role rolename=”tomcat”/> <role rolename=”role1″/> […]
Compiling Java Telnet (jta25b)
There is an applet that can be used to serve up telnet sessions via a Java applet at Javatelnet.org. Note that this site is often down, although it is the current main site. There is an older version available here. Now, we have been trying to use this to provide a web interface for a […]
Upgrading Tomcat
In our article on installing Tomcat, we used version 5.0.18. Well, it has been awhile, and we want to upgrade our system. First, we download the new binary from here. On our system, we put this all in opt. Let’s remove the old symbolic link and extract the tarball: [root@srv-1 opt]# rm tomcat rm: remove […]
Using Whois With PHP
If you would like to provide whois queries via PHP, a good package to use is available here. An example script that uses this package is: <?php include(“whois/main.whois”); $whois = new Whois($_GET[‘query’]); $result = $whois->Lookup(); echo “<pre>”; for($i=0;$i<count($result[rawdata]);$i++) { $row = each($result[rawdata]); echo $row[“value”].”\n”; } echo “</pre>”; ?> The query variable is arbitrary. You can […]
Adding Modules to httpd.conf With Apache 2
We recently converted from a source version of Apache 2 to an RPM version. We wanted all of the PHP/MySQL stuff compiled in and working quickly. Yes, we were very lazy. Now, we tried to use our old httpd.conf file; however, since the compiled version had many of the options built in, our httpd.conf file […]
Installing XAMPP on a Minimal System
What would you say if I told you that you could bring up a system that provided LAMP with two files: [usr-1@srv-1 Desktop]$ ls -l total 127720 -rw-rw-r– 1 usr-1 usr-1 88861055 Jul 2 03:37 stage3-i686-2004.3.tar.bz2 -rw-rw-r– 1 usr-1 usr-1 41779457 Jul 2 02:51 xampp-linux-1.4.14.tar.gz [usr-1@srv-1 Desktop]$ I’m talking bare metal here. Do I have […]
Compiling Built in Modules with Apache2
If you know exactly what modules you plan to use with a website, and you are sure you don’t need the flexibility of adding in those modules later, you can compile Apache with the modules built in. Here is the configuration statement for a minimal Apache compile with server side includes. This was for an […]
Redirecting a Web Page With Javascript
If you need to redirect a web site, just put the following html in place of the page you want to redirect: <head> <script type=”text/javascript”> <!– setTimeout(‘Redirect()’,2000); function Redirect() { location.href=’http://newdomain.com/’; } //–> </script> <html> <body> This site is no longer located here. <br /> You will be redirected in 2 seconds. Please update your […]
Using SSI and Javascript to Report Client IP Address
To set a variable to the remote IP address of the client, use this: var ip = ‘<!–#echo var=”REMOTE_ADDR”–>’; Apache needs the include module either loaded or compiled in. Also, these options need to be specified in httpd.conf: AddHandler server-parsed .shtml AddOutputFilter INCLUDES .shtml Options Includes Check out this page for more information about SSI.
Geronimo Initial Install
Geronimo is an open-source, certified J2EE server. The installation is really quite simple. The first thing we did was to make sure we had the latest Sun JDK from here and got rid of our included GCC Java: # rpm -e java-1.4.2-gcj-compat-1.4.2.0-27jpp # rpm -e gcc-java-3.4.3-22.1 [root@srv-1 java]# ls jdk-1_5_0_05-linux-i586-rpm.bin jre-1_5_0_04-linux-i586.rpm jre-1_5_0_04-linux-i586-rpm.bin [root@srv-1 java]# chmod […]
Using Magic Quotes in PHP to Convert Quotes From Files
To load up a variable with the contents of a file with PHP, you can use this command: $filecontents=file_get_contents(“path to file”); One problem is that we had for this in our application was quotes. The text in the file had both ‘ and “. Magic quotes automatically convert quotes to escaped quotes so that when […]
Using XAMPP for Cross Platform GNU/Linux Mac OS X PHP/MySQL
We wrote about the XAMPP project in this article. This project is perfect for maintaining a cross platform dev environment for an application we are currently working on. Most of the work is done on OS X, but we also do some work on GNU/Linux. Further, the target audience for this may very well use […]