PHP Social Networking API written in PHP using XML-RPC for scalability

I have been going through my list of uncompleted projects and I’ve decided that I shall release my scalable Social Networking Platform API in hope that someone or a team would be willing enough to get it over the dip.

It is separated into the following components,

Server Fuction Class - This API handles all the social network database/processing fuctions

* XML-RPC Server - The XML-RPC Server takes requests and passes it to the Server Fuction Class, it returns any meta data that is returned back to the XML-RPC Client.

* XML-RPC Client - This Class is given to the Social Website, it takes requests from the Client Website and  communicates with the XML-RPC Server, returns meta data.

* Client Website - accepts user input, accepts server input, and stores data in arrays, all webserver side processing is done here.

* Smarty Template Engine - Prints out formatted HTML for the websites visitors.

The communication process can only go up or down one step at a time similar to the OSI layers.

I am going from memory here as I do not have the source code at hand right now, but it currently has support for the following fuctions.

* Add/Delete/Modify users

* Unlimited amount of dynamic meta data fields, if a meta field doesn’t exist it will create it.

* Tags

* Friends Functions, Add/Delete/Is online etc.

* File handling (text,image,video,etc)

I also have a very base setup of a functional demo site demonstrating all available functions.

Current problem is just time, I would love to see this operational just I can’t find enough time to get it complete. I will release it as soon as I read through the different Open Source licenses available as I would like some control over the direction of where this will end up.

Filed under: code - No Pointless Response

PHP Round number to Nearest X

I did a few google searches on rounding numbers using PHP, unfortunately the only thing I could find is the round() function that doesn’t allow you to round to the nearest specified number.

<?php
function roundnum ($num, $nearest)
{
   $ret = 0;
   $mod = $num % $nearest;

   if ($mod >= 0)
     $ret = ( $mod > ( $nearest / 2)) ? $num + ( $nearest - $mod) : $num - $mod;
    else
     $ret = ( $mod > (-$nearest / 2)) ? $num - $mod : $num + ( -$nearest - $mod);
    return $ret;
}

echo roundnum (1234, 15)// round to the nearest 15
echo roundnum (1234, 5); // round to the nearest 5
?>

Enjoy.

Filed under: code - 4 Pointless Responses

Regular Expressions made easy

one thing I can definately say I hate, is regular expression syntax, I do however like what Regular Expressions can do. In a quest to search for an easier better way of assembling regular expressions syntax I’ve stumbled across an awesome website named http://www.txt2re.com/

At first glimpse this website looks a bit complicated, but say we have an example string <a href=”foo.com/whatever”>blah</a>, and we want to extract the domain name, it’s as easy as entering the string, clicking Show Matches, and using the color coded chart to find the FDQN (full qualified domain name).

The beauty of this website is that it also generates the code required for you, they have a selection of a wide range of snippets including Perl, PHP, Python, Java, Javascript, ColdFusion, C, C++, Ruby, VB, VBScript, J#.net, C#.net ,C++.net, VB.net .. Nice.  At the end of the day I can just get on with my programming.

Filed under: code - No Pointless Response