Alex Poole

Pragmatic PHP, MySQL, Marketing & Technology

Alex Poole header image 4

Ely Plumbers

July 27th, 2010 by alex
Respond

I like the Ely Plumbers search space because it acts as a sort of short-hand for the rest of the UK local search market. Although there are less than 100K competing pages for the Ely Plumber search and many other local searches, especially for bigger places (doing SEO in Cambridge, say, instead of Ely,) are easily into the millions for some professions, I do feel if you can’t crack the top 10 for Ely Plumbers, then you’re nowhere near the others.

So the Ely Plumbers term is like the “first hurdle” in local SEO.

Lucky, then, that ISVirtual has just been asked to create a new website for a plumber in Ely

SEO is all about time vs. return, so I’ve “primed the pumps” with a single optimised holding page and this post. Nothing more. I want to see how far that gets us.

Next up, if necessary, will be an article on EzineArticles of high quality, 500+ words, and containing all the LSI-related words to plumbing that you could dream of - references to taps, boilers, spanners and soldering irons will abound, as will mention of water pressures, tank capacity and other such pipe-related terms. That will carry a single backlink direct to the plumber’s site.

Frankly I’d be mildly surprised if the article is required. I would be very surprised if, with the article, the site is not lifted into the top 10 results for Ely Plumbing without any further backlinking activity. So wel shall see. I’ll report back!

Tags:   · · No Comments.

SugarCRM SOAP API - using the set_note_attachment method

June 17th, 2010 by alex
Respond

Docs are still a bit thin on the ground for the new Sugar SOAP API.

I dug around loads of legacy cr*p trying to get this working.

Then I ended up reading the WSDL, which might not be your idea of fun either.

Here’s the important bit:

$attachment = Array(
"id" => $note_id,
"filename" => "test.pdf",
"file" => $file,
);

$result = $soapclient->call("set_note_attachment", array('session' => $session_id, 'note' => $attachment));

Note please, that the params are passed through with the element name “note”, not “attachment”, “data” or some other such.
This way it, er works :)

You can get the rest of it here: https://www.sugarcrm.com/forums/showthread.php?t=56045

Tags:   No Comments.

I agree with Nick!

April 19th, 2010 by alex
Respond

nukenow

www.libdem2010.com

Tags: No Comments.

Remove “Smart” quotes, bullets, dashes and other junky characters from a string with PHP

March 31st, 2010 by alex
Respond

AAAAArgghh!
Why do some Word Processors spew out such a pile of bloated incompatible rubbish?!
If you’ve got any type of CMS and your web pages are showing “junk character” symbols (usually an incongruent question mark of some type,) likelihood is the string you are echoing contains some type of “smart” characters.
There’s a misnomer if ever there was one. Regardless. Onwards.
Try this function:

//replace smart quotes
function convert_smart_quotes($string)
{
$search = array(chr(145),
chr(146),
chr(147),
chr(148),
chr(151),
chr(150),
chr (133),
chr(149)

);

$replace = array("'",
"'",
'"',
'"',
'--',
'-',
'...',
"•"

);
return str_replace($search, $replace, $string);
}

I pinched bits of it from these pages:

http://www.keepandshare.com/doc2/3693/turning-off-microsoft-smart-quotes-or-stipping-programmatically

http://www.liamdelahunty.com/tips/remove_special_characters.php

Cheers.

Tags: 1 Comment

Unix Shell Backup Script for Web and DBs - FTP to off-site storage

March 24th, 2010 by alex
Respond

I’ve been putting off writing a proper backup script for ages but actually its not rocket science!

The goal was to keep a month of rolling backups, totally automatically. I decided, rather than fiddling around with date comparisions, to just name the backup after the day portion of the date, so a month’s worth of backups is always available (after the first month.)

The server is a Plesk server, so all sites sit below /var/www/vhosts/

Here’s the script, with comments:

#!/bin/sh

#create 2 filenames
SQLFILE=backup_`date '+%e'`.sql
TGZFILE=backup_`date '+%e'`.tgz

#get full db backup
cd /var/www/vhosts
#delete old one if there
rm /var/www/vhosts/$SQLFILE
mysqldump --opt --all-databases -uadmin -pMySQL_password > $SQLFILE

#backup web, including the DB backup we've just done
cd /var/www
#delete old one if its there
rm /var/www/$TGZFILE
#use --exclude to ignore big fat log files that you can cope without
tar -zcvf $TGZFILE --exclude '*statistic*' --exclude '*.log' vhosts

#ftp to backup server

#My FTP login is in /root/.netrc but you could add it here instead.
#You'd use this command instead: ftp -n

#Then you'd add "user $USERNAME $PASSWORD" straight below the <<EOF

ftp myftpserver.net <<EOF
del $TGZFILE
put $TGZFILE
quit
EOF

#now I just move them somewhere out of the way on the server, keeping a month's worth here too
rm /root/backups/$SQLFILE
mv /var/www/vhosts/$SQLFILE /root/backups/$SQLFILE
rm /root/backups/$TGZFILE
mv /var/www/$TGZFILE /root/backups/$TGZFILE

Tags: 3 Comments

Sugar Permissions / Cache unreadable / Ensim

February 5th, 2010 by alex
Respond

Took a while to sort this one out. The client was hosted on United Hosting, who use Ensim.

Sugar was successfully creating files in the cache directory (which itself was 0755) but it was then unable to read the files it had created. Which made for a less-than ideal end-user experience.  To say the least.

The fix was here: http://kb.sugarcrm.com/tag/permissions/

Edit config.php and change the permission defaults to:

'default_permissions' =>
array (
'dir_mode' => 511, //0777
'file_mode' => 511,
'user' => '',
'group' => '',
),

Job done. Sugar can now read what it writes. Cambridge CRM working again. Have a great weekend!

Tags:   No Comments.

mod_rewrite on Zeus for pretty URLs in Wordpress (namesco)

January 28th, 2010 by alex
Respond

Just been installing a Wordpress blog on a Namesco Zeus server. Zeus servers don’t use mod_rewrite, they use rewrite.scripts instead. The syntax is totally different. The solution is here at Adam Christie’s blog, but I’ll take the liberty of posting it here too in case that’s ever unavailable:

RULE_0_START:
# get the document root
map path into SCRATCH:DOCROOT from /
# initialize our variables
set SCRATCH:ORIG_URL = %{URL}
set SCRATCH:REQUEST_URI = %{URL}

# see if theres any queries in our URL
match URL into $ with ^(.*)\?(.*)$
if matched then
set SCRATCH:REQUEST_URI = $1
set SCRATCH:QUERY_STRING = $2
endif
RULE_0_END:

RULE_1_START:
# prepare to search for file, rewrite if its not found
set SCRATCH:REQUEST_FILENAME = %{SCRATCH:DOCROOT}
set SCRATCH:REQUEST_FILENAME . %{SCRATCH:REQUEST_URI}

# check to see if the file requested is an actual file or
# a directory with possibly an index.  don’t rewrite if so
look for file at %{SCRATCH:REQUEST_FILENAME}
if not exists then
look for dir at %{SCRATCH:REQUEST_FILENAME}
if not exists then
set URL = /index.php?q=%{SCRATCH:REQUEST_URI}
goto QSA_RULE_START
endif
endif

# if we made it here then its a file or dir and no rewrite
goto END
RULE_1_END:

QSA_RULE_START:
# append the query string if there was one originally
# the same as [QSA,L] for apache
match SCRATCH:ORIG_URL into % with \?(.*)$
if matched then
set URL = %{URL}&%{SCRATCH:QUERY_STRING}
endif
goto END
QSA_RULE_END:

Stick this in a file called rewrite.script in the root. Job done. Set up permalinks in the usual way. Cheers Adam. Saved me a world of pain :)

Tags:   1 Comment

Spin Backlink Link Text with PHP

January 26th, 2010 by alex
Respond

Quick one: if you’re placing backlinks on sites for SEO purposes and you’re at all worried about over-optimisation, this technique may be useful to you:


<a href="http://www.isvirtual.co.uk"><?php echo rand(0,1) ? "Website design" : "Web Site Design"; ?></a> and <a href="http://www.isvirtual.co.uk/seo-cambridge.php"><?php echo rand(0,1) ? "SEO Cambridge" : "Cambridge SEO"; ?></a> by <a href="http://www.isvirtual.co.uk"><?php echo rand(0,1) ? "ISVirtual" : "IS Virtual"; ?> </a>

You get the idea. Of course you could spin more than 2 varations of each.
You’ll want to “lock” the randomisation too.  Before the first call to rand() use:

<?php mt_srand(crc32($_SERVER['REQUEST_URI'])); ?>

If you’re very cautious or backlinking a big site, you might want to use “vanilla” variations like “click here” too ;)

Hope that’s useful to you.

Tags:   No Comments.

Local SEO - Cambridge

January 12th, 2010 by alex
Respond

Firstly, happy 2010!

Secondly, this is a blatant slice of self-promotion!

If you’re looking for SEO Cambridge specialists, you should be talking to ISVirtual!

We’ve been working with a number of local companies to raise their SERPs profiles and are already seeing good success rates with a number of clients’ sites raised from obscurity to page 1 positions for fairly competitive search terms.

Local search engine optimisation demands a slightly different methodology from the usual “build pages, get links” model, in that there are usually specific local directories where getting links are especially beneficial as they have been “awarded” a Cambridge theme by the search engines already.

Also of course, there’s the importance of submitting a good quality local search listing to Google. When done right this can literally get your company name to the top of page one within a day or two, and get you a pin on the map too.

As with any Search engine optimisation, its easy enough to over-optimise for local results too. Liberally peppering the word SEO Cambridge all over the shop (with or without links,) probably won’t do - its enough to tell the SEs what you’re aiming for without ramming it down their throats.

At the same time, some backlinks are a good thing. Why did you think I was writing this post exactly? :)

Incidentally, I’m not sure quite yet what Google thinks about text volume. Ezinearticles likes long articles - they’ve basically said anything shorter than about 400 words will probably be treated as spam unless its blinding. I try to go for 1000 words or above there (and luckily I can ramble without totally straying off-topic, so writing for EZA is quite cathartic!)

On the other hand, blogs are meant to have short, sweet, to-the-point posts. My previous post about SEO Ely was very short, yet it hit the #1 spot in less than an hour and, touch wood, hasn’t faltered yet (yes OK its hardly competitive!) Now we’re over 300 words on this post but I think I’ll try and get up to a nice round 400 before signing off.

To be quite honest I’m still only dabbling with local search, but its a bit like shooting fish in a barrel in many markets.  The local qualifiers just lower the bar to such an extent that it would be embarrassing not to hit page one straight away…

Cambridge is a slightly different kettle-of-fish though, as our Atlantically-challenged friends had the nerve to give somewhere in Massachusetts the same name and, when used in conjunction with any IT or web-related terms, that small seat of learning MIT rears its ugly head with all the related academic pages so beloved of the SEs. Then of course you have Cambridge University over here too. Big guns in Cambridge search terms!

Often, clicking the “search UK only” radio button gets us down from the multiple millions to a couple of hundred thousand, so optimising .co.uk sites, or those physically hosted here, can be a lot easier. (This blog is on a Slicehost slice, so no dice there.)

So anyway, local SEO is fun, and SEO Cambridge optimisation especially so :)

Now its time to stop drivelling and go and write a backup script in Bash, gasp!

Tags:   · · No Comments.

SugarCRM: Error: Query limit of 1000 reached for Calls / Lead module.

December 17th, 2009 by alex
Respond

This seems to happen when you convert a lead because Sugar updates every entry in the (contacts table) or something. Not entirely sure which tables are in play here to be honest, but the answer seems to simply be to go to admin->settings and set “vCal Updates Time Period” to 0 (zero).

Worked for one of our CRM Cambridge clients just now anyway ;)

There’s further explanation here: https://www.sugarcrm.com/forums/showthread.php?p=191467

Tags:   No Comments.