Monthly Archives: May 2012


Cpanel email add forwarder missing 1

I setup a new site and added a few email accounts this evening. In Cpanel, I clicked add forwarder and for some reason I could only select “add domain fowarder”, which is not what I wanted to do. The ability to add an email fowarder was not there. The solution is to go into WHM and click “Feature Manager”, then “Edit a feature list”, and select “disabled” from the drop down box. Find the function named “forwarder manager” and check the checkbox, then click the save button. If you don’t have access to WHM then you’ll need to contact your hosting provider and have them do it.


Doctrine 1.2 on duplicate key update

Doctrine 1.2 doesn’t provide a way to do “on duplicate key update” query unless you do raw sql. However, they do provide a “replace” method that will get the job done. Your table will need a unique key or unique index on multiple columns for this to work, just like on duplicate key update. The different is that replace will delete the existing record and then insert a new one if the key is already found, so this might cause trouble if the table has an auto increment key.

Here is an example on how to use doctrine’s replace method

$obj = new Obj();
$obj->content_uuid = $content_uuid;
$obj->file_id = $fileId;
$obj->sort_order = $sortOrder;
$obj->replace();

Zend_Form Recaptcha doesn’t work with SSL 1

I was able to get a recaptcha working on my Zend Framwork application, but as soon as I added the “‘ssl’ => true” to my zend_form, the captcha disappeared. Here is the code used in zend_form:

//captcha
$this->addElement('captcha', 'captcha', array(
	'label' => 'Please Type:',
	'required' => true,
	'captcha' => array(
		'pubkey' => RECAPTCHA_PUBLIC_KEY,
		'privkey' => RECAPTCHA_PRIVATE_KEY,
		'captcha' => 'reCaptcha',
		'ssl'	=> true
	)
));

The reason ssl didn’t work with recaptcha is because the secure URL was out of date in my zend framework library. To update, open /Zend/Service/ReCaptcha.php and update the server constants at the top to

/**
 * URI to the regular API
 *
 * @var string
 */
const API_SERVER = 'http://www.google.com/recaptcha/api';
 
/**
 * URI to the secure API
 *
 * @var string
 */
const API_SECURE_SERVER = 'https://www.google.com/recaptcha/api';
 
/**
 * URI to the verify server
 *
 * @var string
 */
const VERIFY_SERVER = 'http://www.google.com/recaptcha/api/verify';