Been looking into some of the facebook “magic”. I decided to add the recommendations on the right hand side here. I have also implemented some of the like buttons on bowlingball.com.
Month: March 2011
I am a member of two PHP user groups. Each one runs a little bit differently. I am looking for feedback from other people in other PHP user groups to find ways we may be able to make these better.
The East Central Florida PHP User Group (Daytona Beach area) is new/restarting. They have only had one meeting so far, and finally scheduled another a few months later. They seem to be more geared towards teaching new PHP developers. While we haven’t done anything so far, they are leaning towards a mentor/student type of group.
The Orlando PHP User Group is quite different. They lean towards more presentation style meetings. Someone proposes a topic, and then someone volunteers to be the presenter. If there isn’t a presentation, then they do some coding in DjangoDojo. I have not been to a meeting without a topic yet, so I am not sure how those go. I probably should since I am not very familiar with Django (or Dojo for that matter) at all.
Of the two, I prefer the Orlando version because I am growing my skills. However, I may like the mentor version because I feel I am a decent programmer and love teaching.
I am looking forward to doing a presentation sometime, because I really want to improve my speaking skills.
How does your user group run? What is your preference?
Multiple WordPress Blogs in One Installation
I have been hosting multiple wordpress blogs in one installation for a few years now. I like that I can upgrade one installation, and they all upgrade. I don’t have to go through 10 different installs/upgrades.
There are a few things that can be considered either a pro or a con based on your point of view. If one blog uploads a theme or a plugin, it is available to all the others. This doesn’t mean that if one enables it, they all have to have it enabled. It’s just there, so each can install if they need to.
One serious downside is customization. If one blog customizes a template, another blog can’t use it unless they too want that customization.
On to the nitty-gritty, all I do is change the wp-load.php file and copy the wp-config.php file. I copy the wp-config.php to wp-config-DOMAINNAME.php (example wp-config-www.johncongdon.com.php). Each config file changes the database table prefix.
Here is a diff for the wp-load.php file. It just changes an if statement to load our individual config, if it doesn’t exist, it loads the original wp-load.php.
--- wp-load-orig.php 2011-03-07 15:18:12.000000000 -0500 +++ wp-load.php 2011-03-07 10:30:04.000000000 -0500 @@ -24,7 +24,12 @@ else error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING); -if ( file_exists( ABSPATH . 'wp-config.php') ) { +if ( file_exists( ABSPATH . 'wp-config-'.$_SERVER['SERVER_NAME'].'.php') ) { + + /** The config file resides in ABSPATH */ + require_once( ABSPATH . 'wp-config-'.$_SERVER['SERVER_NAME'].'.php' ); + +} elseif ( file_exists( ABSPATH . 'wp-config.php') ) { /** The config file resides in ABSPATH */ require_once( ABSPATH . 'wp-config.php' );
Patching osticket for PHP 5.3
OSTicket is a decent piece of software for customer service. I upgraded to PHP 5.3 and had some problems because they are trying to keep it working all the way back to PHP 4. 🙁
Here is a patch to fix the eregi_replace deprecated errors.
diff --git a/osticket/include/class.format.php b/osticket/include/class.format.php index 6cbb414..0380268 100644 --- a/osticket/include/class.format.php +++ b/osticket/include/class.format.php @@ -78,10 +78,10 @@ class Format { //make urls clickable. Mainly for display function clickableurls($text) { - $text=eregi_replace('(((f|ht){1}tp(s?)://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)','\\1', $text); - $text=eregi_replace("(^|[ \n\r\t])(www\.([a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+)(/[^/ \n\r]*)*)", + $text=preg_replace('#(((f|ht){1}tp(s?)://)[-a-zA-Z0-9@:%_\+.~\#?&//=]+)#','\\1', $text); + $text=preg_replace("#(^|[ \n\r\t])(www\.([a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+)(/[^/ \n\r]*)*)#", '\\1\\2', $text); - $text=eregi_replace("(^|[ \n\r\t])([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4})",'\\1\\2', $text); + $text=preg_replace("#(^|[ \n\r\t])([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4})#",'\\1\\2', $text); return $text; }
diff --git a/osticket/include/class.validator.php b/osticket/include/class.validator.php index 284d7c7..697d99c 100644 --- a/osticket/include/class.validator.php +++ b/osticket/include/class.validator.php @@ -126,15 +126,15 @@ class Validator { /* Functione below can be called directly without class instance. Validator::func(var..); */ function is_email($email) { - return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$",trim($email)); + return preg_match("#^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$#",trim($email)); } function is_phone($phone) { - $stripped=eregi_replace("(\(|\)|\-|\+)","",ereg_replace("([ ]+)","",$phone)); + $stripped=preg_replace("#(\(|\)|\-|\+)","",preg_replace("/([ ]+)#/","",$phone)); return (!is_numeric($stripped) || ((strlen($stripped)<7) || (strlen($stripped)>13)))?false:true; } function is_url($url) { //Thanks to 4ice for the fix. - $urlregex = "^(https?)\:\/\/"; + $urlregex = "#^(https?)\:\/\/"; // USER AND PASS (optional) $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?"; // HOSTNAME OR IP @@ -149,9 +149,9 @@ class Validator { // GET Query (optional) $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?"; // ANCHOR (optional) - $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?\$"; + $urlregex .= "(\#[a-z_.-][a-z0-9+\$_.-]*)?\$#"; - return eregi($urlregex, $url)?true:false; + return preg_match($urlregex, $url)?true:false; } @@ -161,7 +161,7 @@ class Validator { return false; $ip=trim($ip); - if(ereg("^[0-9]{1,3}(.[0-9]{1,3}){3}$",$ip)) { + if(preg_match("#^[0-9]{1,3}(.[0-9]{1,3}){3}$#",$ip)) { foreach(explode(".", $ip) as $block) if($block<0 || $block>255 ) return false;