Phone Number RegExp - PHP
Jul 30th
Matching a phone number, with a regular expression, and disregarding any extraneous characters.
Useful for searches, not validation.
<?php
$aPhoneNumbers=array(
'7085556232',
'1(708)555-6232',
'(708)555-6232',
'708.555.6232',
'1.708.555.6232',
'1.708.555.6232 ext. 123',
'17085556232',
'7215556232',
'1(721)555-6232',
'(721)555-6232',
'721.555.6232',
'1.721.555.6232',
'17215556232'
);
$sPhone='7085556232';
$rPattern='/(\d)/';
$rReplace='\D*${1}';
$sRegExp='/'.preg_replace($rPattern,$rReplace,$sPhone).'/';
echo 'Regular Expression: '.$sRegExp."\n";
foreach ($aPhoneNumbers as $k => $v)
check($sRegExp,$v);
function check($sRegExp,$sPhone)
{
echo '$sPhone: '.$sPhone.' ? '.preg_match($sRegExp,$sPhone)."\n";
}
?>
Output
Regular Expression: /\D*7\D*0\D*8\D*5\D*5\D*5\D*6\D*2\D*3\D*2/
$sPhone: 7085556232 ? 1
$sPhone: 1(708)555-6232 ? 1
$sPhone: (708)555-6232 ? 1
$sPhone: 708.555.6232 ? 1
$sPhone: 1.708.555.6232 ? 1
$sPhone: 1.708.555.6232 ext. 123 ? 1
$sPhone: 17085556232 ? 1
$sPhone: 7215556232 ? 0
$sPhone: 1(721)555-6232 ? 0
$sPhone: (721)555-6232 ? 0
$sPhone: 721.555.6232 ? 0
$sPhone: 1.721.555.6232 ? 0
$sPhone: 17215556232 ? 0
SugarCRM Extension/Modules/Integration Notes
Jul 24th
- Under custom/Extension/modules/[module to extend/modify]/Ext/Menus add a [new module].ext.php file with the additional menu options.
- If you want to change a menu option, loop through the menu array and replace that option with the new one, in the menu.ext.php file.
- Be sure to rebuild/repair the module before testing changes.
- Spend a good amount of time looking at the Sugar code as you’re working. It’s very powerful, and the less code you write, the better the solution will be.
- If you’re just modifying existing functionality, copy as much code as possible, the update it.
- Understand PHP classes and extensions.
- Never modify the distributed code.
Rebuilding PHP Under CentOS5
Jul 7th
-
Configure firewall to allow httpd requests: system-config-securitylevel
-
Get PHP development RPM: http://rpm.pbone.net/index.php3/stat/4/idpl/8077900/com/php-devel-5.1.6-20.el5.i386.rpm.html
-
Get PHP source RPM: ftp://ftp.pbone.net/mirror/ftp.centos.org/5.3/os/SRPMS/php-5.1.6-23.el5.src.rpm
- Use yum to handle RPM dependencies. yum install php-5.1.6-23.el5.src.rpm
- Update SPECS/php.spec and enable/disable options as necessary.
- rpmbuild -bb –target=i386 SPECS/php.spec - It’s good to specify the target, since otherwise, the RPM build may take a very long time.
- Force the installation of the updated RPMs. I did an ls of the RPMS directory and forced them all.
rpm -i –force php-5.1.6-23.i386.rpm php-bcmath-5.1.6-23.i386.rpm php-cli-5.1.6-23.i386.rpm php-common-5.1.6-23.i386.rpm php-dba-5.1.6-23.i38
6.rpm php-debuginfo-5.1.6-23.i386.rpm php-devel-5.1.6-23.i386.rpm php-gd-5.1.6-23.i386.rpm php-imap-5.1.6-23.i386.rpm php-ldap-5.1.6-23.i386.
rpm php-mbstring-5.1.6-23.i386.rpm php-mysql-5.1.6-23.i386.rpm php-ncurses-5.1.6-23.i386.rpm php-odbc-5.1.6-23.i386.rpm php-pdo-5.1.6-23.i386
.rpm php-pgsql-5.1.6-23.i386.rpm php-snmp-5.1.6-23.i386.rpm php-soap-5.1.6-23.i386.rpm php-xml-5.1.6-23.i386.rpm php-xmlrpc-5.1.6-23.i386.rpm
Round Image Corners - ImageMagick
Jun 27th
Banner builder has been extended to allow you to check a box to round the corners of the banner.