Tag Archives: php

PHP Authentication and Encryption the right way

PHP Authentication and Encryption the right way (hint dont use mcrypt)

Paragonie

PHP libraries

ubuntu aptitude doesnt install #php php5-mcrypt correctly but its a known bug

ubuntu aptitude doesnt install php5-mcrypt correctly and breaks php cli and nginx php fpm but its a known bug

bug

workaround

or

# cd cli/conf.d/
# ln -s ../../mods-available/mcrypt.ini 20-mcrypt.ini
# cd fpm/conf.d/
# ln -s ../../mods-available/mcrypt.ini 20-mcrypt.ini

					

PHP ZEND autoloader code for Zend and Your classes

Simplest PHP ZEND autoloader code to autoload Zend classes and Your classes

<?php
require_once '/usr/lib/Zend/Loader/AutoloaderFactory.php';
require_once '/usr/lib/Zend/Loader/ClassMapAutoloader.php';

// ZEND CLASSES

$config = array(
    'Zend\Loader\StandardAutoloader' => array(
        'namespaces' => array(
            'Zend'      => '/usr/lib/Zend',
            'ZendXml'   => '/usr/lib/ZendXml',
        ),
    ),
);

Zend\Loader\AutoloaderFactory::factory($config);

// YOUR CLASSES

$loader = new Zend\Loader\ClassMapAutoloader();

// Register the class map:
$loader->registerAutoloadMap(__DIR__ . '/autoload_classmap.php');

// Register with spl_autoload:
$loader->register();

GNU/Linux PHP PDO MS SqlServer & ODBC connectors and drivers

GNU/Linux PHP PDO MS SqlServer & ODBC connectors and drivers

HTTPD #PHP #PDO error caused by #SELinux

The HTTPD PHP PDO connect error “SQLSTATE[HY000] [2002] Permission denied” can be caused by SELinux on Centos & Red Hat 5 & 6

Quick Fix

# setenforce 0
# sestatus

See

#phpfig and #zend #php #webdev abstract class naming convention confusion

it seems that phpfig says the opposite of zend when it comes to abstract class naming conventions

PHPFIG say prefix abstract classes

ZEND say suffix abstract classes

#php #mysql #pdo prepare and single quotes #gotcha

i suspect that php pdo prepare may be double escaping single quotes in your sql string so replace single quotes with double quotes

FAILS

$sql = <<<EOT
    select * from cars where colour='red'
EOT;
$stm = $db->prepare($sql);

WORKS

$sql = <<<EOT
    select * from cars where colour="red"
EOT;
$stm = $db->prepare($sql);