Monday, December 2, 2013

Numeric Drop-down With PHP ranges

Here is an easy way to generate form numeric drop-down with ranges.
       $form = new Zend_Form();

        $ranges = array( 
            range(1, 20, 1) , 
            range(30, 100, 10) , 
            range(200, 1000, 100) 
        $a = array();
        foreach ( $ranges as $range ) {
            foreach ( $range as $r ) {
                $a[$r] = $r;
        $form->addElement('select', 'quantity', array( 
            'label' => 'Quantity' , 
            'required' => false , 
            'class' => 'form-control' , 
            'multiOptions' => array( 
                '' => '--Select--' 
            ) + $a 

Please note that the ranges are with different steps. Here is the result:

Wednesday, March 20, 2013

Enable pgpass under Windows XP

These are the steps I used to enable pgpass under Windows XP.
  1. Create file with name: pgpass.conf with this information in it: hostname:port:database:username:password

    see this for file data format

  2. Move the file to the %APP_DATA%\postgresql directory of the user running the backup ( not the db server user - postgres). In my case it was: C:\Documents and Settings\Windows User Name\Application Data\postgresql.
  3. Add --no-password option to the backup statement like this: "C:\Program Files\PostgreSQL\9.X\bin\pg_dump.exe" -h localhost -U postgres --no-password -C -f "database_name_dump.sql" database_name_db

Tuesday, January 15, 2013

SSL certificate problem, verify that the CA cert is OK

This is a followup post related to this issue. I have proposed a solution to this problem in a previous post. In short the solution was to download a certificate file from Mozilla and add this information to $CURL_OPTS array in base_facebook.php file.

Today I have found this blog post suggesting using this certificate file. Either one should work.

The second point I want to make is this. Previously I suggested appending CURLOPT_CAINFO to $CURL_OPTS array in base_facebook.php file. Now I think it will be better if I change the location information from my client code and not touch facebook.php library code. Here is how I did it:

In my client code:

require 'Facebook/src/facebook.php';

$facebook = new Facebook(array( 'appId' => 'some app id', 'secret' => 'some secret', 'cookie' => true, ));


That way you can update facebook sdk library code without worrying that will have to update the certificate file path every time.

Friday, March 23, 2012

Adding Google Analytics Account to Chrome Web Store Application

For an useful explanation of how to add Google Analytics Account to your Chrome Web Store application follow these instructions. Note that is a good idea to have a separate account property for your main web site and the chrome hosted application detail page.

Saturday, February 18, 2012

Vasil Levski

Yesterday, Feb 18th, was the 139th anniversary from the death of Vasil Levski - the brightest figure in the Bulgarian history. May his name and deeds are remembered forever!

More about him from Wikipedia

Sunday, January 15, 2012

Insert processing istruction to Zend View Helper Navigation Sitemap domobject

What if you want to associate a xslt stylesheet to the sitemap generated by Zend_View_Helper_Navigation_Sitemap. I did it by adding a xml-stylesheet processing instruction to the view helper dom object. Here is the code:

class SitemapController extends Zend_Controller_Action
public function indexAction ()

$pages = array();

// generate the pages array somehow
$someservice = new My_Serivce_PageGenerator();
$pages = $someservice->fetchAllMyWebsitePages();

// generate sitemap xml
$xml = $this->_generateSitemapXml($pages);

$response = $this->getResponse();
$response->setHeader('Cache-Control', 'public', true);
$response->setHeader('Content-Type', 'text/xml', true);


private function _generateSitemapXml ($pages)

$sitemap = new Zend_View_Helper_Navigation_Sitemap();


$container = new Zend_Navigation();


// get the dom object
$dom = $sitemap->getDomSitemap();

// define path to xslt stylesheet
$xslt_file_path = '/sitemap_style.xsl';

// create processing instruction
$xslt = $dom->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="' . $xslt_file_path . '"');

// add it to the dom
$urlset = $dom->getElementsByTagName('urlset');
$dom->insertBefore($xslt, $urlset->item(0));

// instead of using the render method we use this:
$xml = $sitemap->getUseXmlDeclaration() ? $dom->saveXML() : $dom->saveXML($dom->documentElement);

return rtrim($xml, PHP_EOL);



Wednesday, November 2, 2011

Apache Http Server, SSL and IIS On Windows XP

Windows XP with the following servers installed

Apache 2.2 installed and running
IIS 5.1 Installed and running

Whenever I add the following directive to the Apache configuration to enable ssl:
Listen 443 and try to restart Apache, I get the following error:

(OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address

My solution:
1. Stop the IIS server
2. Change the Apache configuration
3. Start Apache http server
4. Start IIS server

Good luck!