Paul's blog..
Iphone website launched
I have finally managed to launch my own Iphone website. I incorporates new technology which is only usable on the iphone.
If you have an iphone, why not visit my site and you can see it in action. It uses some simple JavaScript to change the content dependent on what way you tilt the phone.... enjoy
Server log: 'Morfeus Fucking Scanner'
I have been recently have several problems with posts getting spammed by spam bots, and while looking through my server log, I notice several occurrences of a User Agent called 'Morfeus Fucking Scanner' (apologies for the bad language).
After a little investigation I found a website which had come across a solution...
The solution provided was to add the following lines into your .htaccess file
RewriteCond %{HTTP_USER_AGENT} ^Morfeus
RewriteRule ^.*$ - [F]
I have already setup anti-spam functionality for the website but you can never be too careful
Thanks to Rick and Haans for a solution
New RSS feed
I have finally added a RSS feed for my website ... check it out. It will feed my blog posts, which I do plan to update more often when I get more time.
Also you may have noticed that I have decided to remove the commenting feature from my website, this is mainly due to a high number of spam posts which I don't have time to moderate and review, and also, I'm sure if you have something important to say to me you can email me
Enjoy
adding an error class to form_input
I recently had to rework a small helper to recreate the form_input() function of CI so it would add a class on if there was an error called for that particular input.
Basically I created a small function like so...
function get_input($field_name)
{
$input = "<input type=\"text\" name=\"$field_name\" name=\"$field_name\"";
// $input .= (form_error($field_name)) ? ' class="formError"' : '';
form_error($field_name) : '';
$input .= "/>\n";
return $input;
}
and this would be used like so
//I presume here that you have set your variables above in arrays... echo get_input($somefieldname['id'])
And yes... this could have been easily achieved in Jquery however i would rather have a backend fallback in case..... This would save a lot of time instead of using bulk if statements to add a class cutting down you controller code :)
If you have any questions, let me know
Original code was provided by TheFuzzy0ne over at the CI forums
Installing postfix and sendmail
I had to recently install Postfix and Sendmail on my server to utilise the php mail function, fairly simple procedure to get going so I'd thought I would give a simple example.
Firstly install sendmail with the yum command
yum install sendmail
and make sure its install ok
/etc/rc.d/init.d/sendmail restart
Then its onto postfix
yum -y install postfix
we then need to configure a few thing
vi /etc/postfix/main.cf myhostname = mail.server-linux.info // line 70: specify hostname mydomain = server-linux.info // line 77: specify domain name myorigin = $mydomain // line 93: make valid inet_interfaces = all // line 110: change mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain // line 155: add mynetworks = 127.0.0.0/8, 192.168.0.0/24 // line 255: make valid and specify LAN home_mailbox = Maildir/ // line 410: make valid (use Maildir) header_checks = regexp:/etc/postfix/header_checks // line 536: make valid body_checks = regexp:/etc/postfix/body_checks // add
make sure everything is working
/etc/rc.d/init.d/postfix start /etc/rc.d/init.d/saslauthd start chkconfig postfix on chkconfig saslauthd on
that’s it, very simple but will allow you to use mail function, I haven’t bothered configuring mailboxes or limits as I’m not using this for anything apart from form submission
Automatic backup for Plesk
I was asked to create a automatic backup for our server which would ftp to an external location so i thought i would share it with you, although many people have done it before.. here goes.....
First you need to create the script which will run the backup, i have organised this into a neat folder which is given in CentOS as cron.weekly (cron job that run on a weekly basis, but you could put it anywhere)
vi etc/cron.weekly
#!/bin/sh /usr/local/psa/bin/pleskbackup all /root/ftpbackup/fullbackup`date '+%d-%B-%Y'`.bak ftp -n -v -i ftp.somewhere.com user username password mput /root/ftpbackup/* quit EOC exit 0 rm /root/ftpbackup/fullbackup`date '+%d-%B-%Y'`.bak
then we need to set is as a cron job, i have set this to happen every Sunday at 1:30
vi etc/crontab
and insert
54 1 * * 5 root /etc/cron.weekly/backup.cron.sh
This will set it to perform the script at 1am every fifth day (Sunday being the 1st). Simple
Php5 upgrading with litespeed
I recently upgraded my server to php5 and had a few problems along the way, therefore I thought I would share and let you how to avoid it.
Note* read below there is a quick fix
Firstly I tried to upgrade via the control panel of litespeed and got the following error
If configure fails try --with-jpeg-dir= configure: error: libpng.(a|so) not found.
This was due not to having the libxml2 and libxml2-devel rpm?s installed, easy fix
yum install libxml2 libxml2-devel
I managed to get php5 installed on my *nix box, test with;
fcgi-bin/lsphp -v
I then needed to create my external app, basically copying the php4 app but changing the address and command to include lsphp5
All good; however with php5 there is no MySQL support built in! Therefore my site with databases didn't work... doh. Also my system is 64 bit and can be a bit fiddly
Simple way around this is to add the following config parameters
--with-mysqli --with-zlib --with-gd --enable-shmop --enable-track-vars --enable-sockets --enable-sysvsem --enable-sysvshm --enable-magic-quotes --enable-mbstring --with-iconv --with-mysql=/usr --with-MySQL-sock=/var/lib/MySQL/mysql.sock --enable-simplexml --with-libdir=lib64
Taking note of the --with-MySQL=/usr, but not setting the exact path to MySQL is installed like a dream. A quick restart and adding the include path to my php.ini file I was off and flying.
Scotland on rails
I recently attended the scotland on rails talk, which was very good. Only able to make it for one day, but well worth it.
Never got to stay for the talk on Litespeed (which i use on my personal server), however the speakers and general vibe was very good.
Here's hoping that I get some more time to dive into RoR
Maybe I'll be there next year with my head screwed on about RoR?!







