Archive for the 'php' Category

PHP and stuff

Lately I have been working so hard that I haven’t even had any desire to do any fun computering at home. Today that changed a bit.

I decided this morning that it was high time I upgraded my all time favorite rss feed reader, tiny tiny rss. Well, wouldn’t you know it, after I did the install I found it required a version of php higher than I had available on my server. Time to upgrade.

I run Centos 5 on my main server and, by default, that carries a php 5.1.x. I needed 5.2 or greater. As it happens, php 5.3 is available in the repos, so I did the upgrade. For the uninitiated, that entails doing a “yum list installed | grep php”, which gives you a list of what you *have* installed. Next you remove php by doing “yum remove <and name all the packages in the prior list here>”. This, followed by “yum install <list of files for php 5.3>”. For example, I had php-common.i386 and php.i386 installed, so I did a “yum remove php-common php” and then “yum install php53-common php53″ to get all my php 5.3 packages on there. This was followed by a quick “service httpd restart” to make sure my webserver was using the new version.

Murphy’s law states that “something will go wrong if it can”. Well, *MY* law states that “something will go wrong”, and it did. As it turns out, I had built a whole bunch of php applications maybe 7 years ago that my wife uses almost daily. In the olden days of php, you could declare a php script at the top by doing a “<?”. NOW, you need to declare it by doing “<?php”. Consequently, nothing I had written worked. It only took me a minute or two to identify why the problem was occurring, but fixing it was another story.

So, how do you find all the files you have to fix? Well, I used the “grep” command. More specifically, egrep. I went to my html root directory and searched by doing “egrep -r “<\?” * | egrep -vi “<\?php” | egrep -vi “<\?xml” | grep -v inary”. What does all that do? The first stanza looks recursively through the directory structure at every file and outputs the ones that have any “<?”‘s in them. The second takes that output but does NOT pass through any that are “<?php”. Why, because they would already be ok! The third takes the results and doesn’t pass through any that contain “<?xml”. The last one doesn’t pass through results from binary files. The end result is I had a list of directory / file / line information of all the files I had to change / update. A few minutes later, after using vim, the best text editor around, I was back up and running!

PHP 5.3.X on RHEL 5 / CentOS 5

PHP

PHP

Another one for posterity here. I was asked to find out how to upgrade on PHP RHEL 5 / CentOS 5 to v 5.3.x and to test the procedure. It turns out to work pretty well and is not as difficult as you might think as long as you have the right repositories enabled:

wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh epel-release-5-4.noarch.rpm
rpm -Uvh remi-release-5.rpm
yum –enablerepo=remi update php php-* mysql

This, of course, assumes that your LAMP stack is already installed. If not, you would change the “update” to “install” and away you go. This will currently set you to php v 5.3.3 and mysql 5.1.51..

Coding FLB style.

In between bouts of making Linc’s World Famous Potato Soup, I had a few minutes to do some catch-up coding today on FreeLinuxBox. It desperately needed an rss feed, so that is what I coded up. How else are you supposed to know there is new stuff there right? Well, all finished and added the feed to LinuxPlanet.org, which you should be subscribing to if you aren’t already :-) If you are just looking for the FLB feed, you can find it at http://freelinuxbox.org/rss/rss.php.

Speaking of Free Linux Boxes, Russ, The Techie Geek, was the latest person to put a box up on FLB and he has a GREAT idea. He wants local pickup (because of weight no doubt), but he said he’d be wiling of delivering to the Ohio Linux Fest. Outstanding idea. If you, like me, have some boxes you are putting off giving out because of the hassle in shipping, perhaps following Russ’ example could be the answer!

Php Twitter Identica Laconica

ptl
A while back I wrote a little bash script called IdentiBash, which, oddly enough, let me post and read to/from my lacomica account via the bash command line. Well, as of late I decided that that script really didn’t work very well with the xml/rss style feeds. It needed updating. Instead of turning to bash again it occurred to me that php5 has simplexml built in now. Well, that makes things really easy! In just a few minutes I cranked out a command line php script that will let me grab posts from Twitter, Identica, and Laconica servers. It works like a top too. The script is not complete yet as I am not sure quite yet what else I really want it to do and how I want it to handle those things, but it is a great start to any such project and I thought I would share. Especially for those people still using IdentiBash, this reader works much better and it’s really easy to expand upon if you are at all familiar with php. So here you have it, “ptil.sh”..

By the way, if you do anything wonderful with it, let me know, I’d like to see!


#!/usr/bin/php
$user="your_user_name";
$passwd="your_password";
#$puburl="http://stream.tllts.org/identica/api/statuses/friends_timeline/$user.rss";
$puburl="http://twitter.com/statuses/friends_timeline/60602470.rss";
system("curl -s -u $user:$passwd $puburl > /tmp/tweet.tmp”);
$rss = simplexml_load_file(”/tmp/tweet.tmp”);
foreach ($rss->channel->item as $item)
{
echo “———————————\n”;
echo $item->pubDate.”\n”;
echo $item->title.”\n”;
}
?>

You’ll notice 2 puburl lines in there. The first is how I access my account in laconica/identica and the second is for twitter. They are given as examples and you’ll have to replace with your own urls. Simply put your info on the appropriate spots, make it executable and run it from the command line.