Archive for April, 2009

Sample Configuration for mod_deflate

These conf settings will avoid compressing images (generally a bad thing) but will compress various text, xml, css and javascript files. This is better than minifying javascript because minified js must be decompressed by the client js and this is not as efficient as doing it with Apache’s mod_deflate. This goes in httpd.conf.
#
# Deflate conf
#
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no=gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

     

, ,

No Comments

Extending Zend_View to Implement a Concrete Function…

…without using a view helper*.

In a nutshell:

  1. Extend Zend_View
  2. Put your method in this extended class
  3. Instantiate the class (in your bootstrap for instance)
  4. Assign it to the ViewRenderer
  5. Pass that viewrenderer to Zend_Controller_Action_HelperBroker’s addHelper method
  6. Use it in your view

The details:

In /library/My/Zend/ create View.php:

class My_Zend_View extends Zend_View
{
public function _($string)
{
return Zend_Registry::get('translate')->_($string);
}
}

In your bootstrap:

require_once APPLICATION_PATH.'../library/My/Zend/View.php';

$view = new My_Zend_View();

$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

In your view:

echo $this->_("Hello");

Some extras. I have APPLICATION_PATH defined in index.php as:

define('APPLICATION_PATH', realpath(dirname(__FILE__)).'/application/');

and I have Zend_Translate instantiated in bootstrap.php like:

$translate = new Zend_Translate('csv', APPLICATION_PATH.'../library/Mine/source-en.csv', 'en');

and lastly, don’t forget to register $translate with the registry or that echo in the view file won’t work:

$registry->translate = $translate;

*Why not use a view helper? Well, you should, actually. The only reason for this solution is that the original need was for something that would work with the underscore notation used by Poedit. Apparently implementing a method named “_” doesn’t work in a helper so this solution extends Zend_View… adding an underscore method.

Sooo… if you should use a view helper what does that look like?
In /library/My/Helper/Translate.php

class My_Helper_Translate extends Zend_View_Helper_Abstract
{
public function translate($string)
{
return Zend_Registry::get('translate')->_($string);
}
}

In your bootstrap:

$view->addHelperPath("../library/My/Helper/", "My_Helper");

In the view:

echo $this->translate("Hello");
     

, ,

No Comments

Mail Box Full But Quota Not Met! Why?

Problem:

A client received the following message when trying to send email:

“ERROR:
ERROR: Could not append message to INBOX.Sent.
Server responded: [ALERT] You exceeded your mail quota.
Solution: Remove unnecessary messages from your folders. Start with your
Trash folder.”

and mailings to him resulted in:

—– The following addresses had permanent fatal errors —–
<sample@sample.com>

(reason: 550 Mailbox quota exceeded)

This person had a 20MB queue and only a handful of small messages with no attachments in their mailbox so obviously it wasn’t that their quota was exceeded. The problem was a file called maildirsize that was, for whatever reason, reporting the wrong quota.

Solution:

Delete the maildirsize file for that account.

  1. Login to your server via FTP
  2. Navigate to the following path /mail/yourdomain.com/userid
  3. Substitute yourdomain.com/userid with the correct email domain/user. (ex. /mail/widgets.com/bobforehead)
  4. From this directory, delete the file named maildirsize

Boo followed by Yah… problem solved!

     

, , , ,

No Comments