1 0 Tag Archives: ming
post icon

Compiling a custom php5 install with ming on dreamhost

Due to recent developing using php Ming library for creating Flash, I was forced to figure out how to do a custom php5 install on my Dreamhost account. It actually wasn’t hard at all considering they have well written instructions on the Dreamhost wiki. However this custom install described there doesn’t include the Ming component that I needed… so, if you need Ming here is the script I ran. I just added some lines to the script that’s listed on that page. I also upgraded the php version to 5.2.4. Everything else was the same. Here is a link to the file: custom php5.2.4 with ming library install on dreamhost, if you would like to download it.

#!/bin/sh
# Script updated 2006-12-25 by Carl McDade (hiveminds.co.uk) to allow memory limit and freetype
# Modified on 2008-02-18 by Darren Terhune (headfirstproductions.ca) to to include ming library
# Script updated 2007-11-24 by Andrew (ajmconsulting.net) to allow 3rd wget line to pass
# LIBMCRYPT version information (was set as static download file name previously.)
#
# Save the code to a file as *.sh
# Abort on any errors
#
set -e
# The domain in which to install the PHP CGI script.
export DOMAIN="headfirstproductions.ca"
# Where do you want all this stuff built? I'd recommend picking a local
# filesystem.
# ***Don't pick a directory that already exists!***  We clean up after
# ourselves at the end!
SRCDIR=${HOME}/source
# And where should it be installed?
INSTALLDIR=${HOME}/php5
# Set DISTDIR to somewhere persistent, if you plan to muck around with this
# script and run it several times!
DISTDIR=${HOME}/dist
# Pre-download clean up!!!!
rm -rf $SRCDIR $DISTDIR
# Update version information here.
PHP5="php-5.2.4"
LIBICONV="libiconv-1.11"
LIBMCRYPT="libmcrypt-2.5.7"
LIBXML2="libxml2-2.6.27"
LIBXSLT="libxslt-1.1.18"
MHASH="mhash-0.9.7.1"
ZLIB="zlib-1.2.3"
CURL="curl-7.14.0"
LIBIDN="libidn-0.6.8"
CCLIENT="imap-2004g"
CCLIENT_DIR="imap-2004g" # Another pest!
FREETYPE="freetype-2.2.1"
MING="ming-0.3.0"
# What PHP features do you want enabled?
PHPFEATURES="--prefix=${INSTALLDIR} \
--with-config-file-path=${INSTALLDIR}/etc/php5/${DOMAIN} \
--enable-fastcgi \
--enable-force-cgi-redirect \
--with-xml \
--with-libxml-dir=${INSTALLDIR} \
--with-freetype-dir=${INSTALLDIR} \
--enable-soap \
--with-openssl=/usr \
--with-mhash=${INSTALLDIR} \
--with-ming=${INSTALLDIR} \
--with-mcrypt=${INSTALLDIR} \
--with-zlib-dir=${INSTALLDIR} \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-gd \
--enable-gd-native-ttf \
--enable-memory-limit
--enable-ftp \
--enable-exif \
--enable-sockets \
--enable-wddx \
--with-iconv=${INSTALLDIR} \
--enable-sqlite-utf8 \
--enable-calendar \
--with-curl=${INSTALLDIR} \
--enable-mbstring \
--enable-mbregex \
--with-mysql=/usr \
--with-mysqli \
--without-pear \
--with-gettext \
--with-imap=${INSTALLDIR} \
--with-imap-ssl=/usr"
# ---- end of user-editable bits. Hopefully! ----
# Push the install dir's bin directory into the path
export PATH=${INSTALLDIR}/bin:$PATH
#setup directories
mkdir -p ${SRCDIR}
mkdir -p ${INSTALLDIR}
mkdir -p ${DISTDIR}
cd ${DISTDIR}
# Get all the required packages
wget -c http://us.php.net/distributions/${PHP5}.tar.gz
wget -c http://mirrors.usc.edu/pub/gnu/libiconv/${LIBICONV}.tar.gz
wget -c http://easynews.dl.sourceforge.net/sourceforge/mcrypt/${LIBMCRYPT}.tar.gz
wget -c ftp://xmlsoft.org/libxml2/${LIBXML2}.tar.gz
wget -c ftp://xmlsoft.org/libxml2/${LIBXSLT}.tar.gz
wget -c http://superb-west.dl.sourceforge.net/sourceforge/mhash/${MHASH}.tar.gz
wget -c http://www.zlib.net/${ZLIB}.tar.gz
wget -c http://curl.haxx.se/download/${CURL}.tar.gz
wget -c http://kent.dl.sourceforge.net/sourceforge/freetype/${FREETYPE}.tar.gz
wget -c ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz
wget -c ftp://ftp.cac.washington.edu/imap/old/${CCLIENT}.tar.Z
wget -c http://superb-east.dl.sourceforge.net/sourceforge/ming/${MING}.tar.gz
echo ---------- Unpacking downloaded archives. This process may take several minutes! ----------
cd ${SRCDIR}
# Unpack them all
echo Extracting ${PHP5}...
tar xzf ${DISTDIR}/${PHP5}.tar.gz
echo Done.
echo Extracting ${LIBICONV}...
tar xzf ${DISTDIR}/${LIBICONV}.tar.gz
echo Done.
echo Extracting ${LIBMCRYPT}...
tar xzf ${DISTDIR}/${LIBMCRYPT}.tar.gz
echo Done.
echo Extracting ${LIBXML2}...
tar xzf ${DISTDIR}/${LIBXML2}.tar.gz
echo Done.
echo Extracting ${LIBXSLT}...
tar xzf ${DISTDIR}/${LIBXSLT}.tar.gz
echo Done.
echo Extracting ${MHASH}...
tar xzf ${DISTDIR}/${MHASH}.tar.gz
echo Done.
echo Extracting ${ZLIB}...
tar xzf ${DISTDIR}/${ZLIB}.tar.gz
echo Done.
echo Extracting ${CURL}...
tar xzf ${DISTDIR}/${CURL}.tar.gz
echo Done.
echo Extracting ${LIBIDN}...
tar xzf ${DISTDIR}/${LIBIDN}.tar.gz
echo Done.
echo Extracting ${CCLIENT}...
uncompress -cd ${DISTDIR}/${CCLIENT}.tar.Z |tar x
echo Done.
echo Extracting ${FREETYPE}...
tar xzf ${DISTDIR}/${FREETYPE}.tar.gz
echo Done.
echo Extracting ${MING}...
tar xzf ${DISTDIR}/${MING}.tar.gz
echo Done.
# Build them in the required order to satisfy dependencies.
#libiconv
cd ${SRCDIR}/${LIBICONV}
./configure --enable-extra-encodings --prefix=${INSTALLDIR}
# make clean
make
make install
#libxml2
cd ${SRCDIR}/${LIBXML2}
./configure --with-iconv=${INSTALLDIR} --prefix=${INSTALLDIR}
# make clean
make
make install
#libxslt
cd ${SRCDIR}/${LIBXSLT}
./configure --prefix=${INSTALLDIR} \
--with-libxml-prefix=${INSTALLDIR} \
--with-libxml-include-prefix=${INSTALLDIR}/include/ \
--with-libxml-libs-prefix=${INSTALLDIR}/lib/
# make clean
make
make install
#zlib
cd ${SRCDIR}/${ZLIB}
./configure --shared --prefix=${INSTALLDIR}
# make clean
make
make install
#libmcrypt
cd ${SRCDIR}/${LIBMCRYPT}
./configure --disable-posix-threads --prefix=${INSTALLDIR}
# make clean
make
make install
#libmcrypt lltdl issue!!
cd  ${SRCDIR}/${LIBMCRYPT}/libltdl
./configure --prefix=${INSTALLDIR} --enable-ltdl-install
# make clean
make
make install
#mhash
cd ${SRCDIR}/${MHASH}
./configure --prefix=${INSTALLDIR}
# make clean
make
make install
#freetype
cd ${SRCDIR}/${FREETYPE}
./configure --prefix=${INSTALLDIR}
# make clean
make
make install
#libidn
cd ${SRCDIR}/${LIBIDN}
./configure --with-iconv-prefix=${INSTALLDIR} --prefix=${INSTALLDIR}
# make clean
make
make install
#cURL
cd ${SRCDIR}/${CURL}
./configure --with-ssl=${INSTALLDIR} --with-zlib=${INSTALLDIR} \
--with-libidn=${INSTALLDIR} --enable-ipv6 --enable-cookies \
--enable-crypto-auth --prefix=${INSTALLDIR}
# make clean
make
make install
# c-client
cd ${SRCDIR}/${CCLIENT_DIR}
make ldb
# Install targets are for wusses!
cp c-client/c-client.a ${INSTALLDIR}/lib/libc-client.a
cp c-client/*.h ${INSTALLDIR}/include
#ming
cd ${SRCDIR}/${MING}
./configure --with-ming-prefix=${INSTALLDIR} --prefix=${INSTALLDIR}
# make clean
make
make install
#PHP 5
cd ${SRCDIR}/${PHP5}
./configure ${PHPFEATURES}
# make clean
make
make install
#copy config file
mkdir -p ${INSTALLDIR}/etc/php5/${DOMAIN}
cp ${SRCDIR}/${PHP5}/php.ini-dist ${INSTALLDIR}/etc/php5/${DOMAIN}/php.ini
#copy PHP CGI
mkdir -p ${HOME}/${DOMAIN}/cgi-bin
chmod 0755 ${HOME}/${DOMAIN}/cgi-bin
cp ${INSTALLDIR}/bin/php-cgi ${HOME}/${DOMAIN}/cgi-bin/php.cgi
rm -rf $SRCDIR $DISTDIR
echo ---------- INSTALL COMPLETE! ----------
Leave a Comment
post icon

Securing your email forms using css or php’s ming library

I recently had a coverstation with my teacher from last year Jim Rutherford from Digital Media Minute about securing web forms that have email fields where the email address ends up going to an mail script. I’ve always busted my brain on how to do this. I’ve used math equations, but a bot could just loop through numbers easy, I’ve used captcha, but it’s kinda annoying, I’ve seen scripts that check if the refering page was from the same domain, but you could use curl to get around that, I’ve used flash to create the form then pass the variables to a script to do the handling, but that takes time and isn’t accessible (yet), and the list goes on. When talking with Jim, he said one of his previous employers used css. I was shocked at how easy it was. Although it doesn’t stop all spam, it can stop most of it. I’ve also done some stuff with php’s Ming. Ming is a library for creating flash. Here are 2 tutorials, one using Jim’s simple css, and two using Ming and php.

Using CSS/Simple Trickery (AkA Bastard Bots Blocker):

< input name="city" type="text">
< input name="email" class="hidden" type="text">

How it works:
Users don’t see the hidden name=”email” field, but bots do and they insert email addresses into it. Bots would insert a string like Vancouver into the name=”city”, (which is actually set up to be the email field for users) field and well obviously there’s not going to be any emails getting sent. This is really a simple way of stopping them bots to a point.

Using PHP and Ming (AkA Bastard Bots Blocker that’s a bastard to set up but easier than doing your own captcha):
First you will have to have Ming installed. I believe as of php5 ming is packaged in. Not too sure though. I know that if you install php5 using Marc Liyanage’s package it comes with it. Note: This is similar to captcha but easier.

<?php
 $font = new SWFFont("Bitstream Vera Serif.fdb");
 $text = new SWFText();
 $text->setFont($font);
 $text->moveTo(200, 400);
 $text->setColor(0, 0xff, 0);
 $text->setHeight(200);
 $random_string = (you'll have to create a random string, there are many ways);
 $text->addString($random_string);
 $movie = new SWFMovie();
 $movie->setDimension(6400, 4800);
 $movie->add($text);
 header('Content-type: application/x-shockwave-flash');
 $movie->output();
?>

How it works:
Basically this is php creating a flash file with a text string in it. The random string part isn’t part of this tutorial, but it’s not hard to do. Then once that small flash output has been created you can have a field that a user would have to input the random string into, then in your testing scripts just check that the string matches your $random_string variable. I haven’t done this but I have used Ming to create flash and this works. Also note that you will have to get your hands on a fdb font file and upload it to your server. Also another note: Not accessible = booo.

Here’s a great Ming resource

RELATED:

Jonathan Snook has a sweet write up on developing his own spam blocking system that was interesting to read.

Also Defensio has a really cool application that you can sign up for and include in your own sites. Oh and their Canadian too!

Leave a Comment