MySQL ERROR 1819 (HY000): Your password does not satisfy the current policy requirements !!

First you login with mysql -u root -p and check the current policy rules by:

# SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password_dictionary_file    |        |
| validate_password_length             | 5      |
| validate_password_mixed_case_count   | 1      |
| validate_password_number_count       | 1      |
| validate_password_policy             | MEDIUM |
| validate_password_special_char_count | 1      |
+--------------------------------------+--------+

Then you can change any of the above variables at your will:

# SET GLOBAL validate_password_length = 5;
# SET GLOBAL validate_password_number_count = 0;
# SET GLOBAL validate_password_mixed_case_count = 0;
# SET GLOBAL validate_password_special_char_count = 0;

Finally you can create a database and a user accessing it with a simpler password:

# CREATE USER 'laravel'@'localhost' IDENTIFIED BY 'laravel';
# GRANT ALL PRIVILEGES ON *.* TO 'laravel'@'localhost' WITH GRANT OPTION;
# CREATE DATABASE laravel;
# FLUSH PRIVILEGES;

After that you can login with mysql -u user1 -p laravel using password laravel

How to Protect Linux Against the Shellshock Bash Vulnerability

The Shellshock vulnerability can be exploited on systems that are running Services or applications that allow unauthorized remote users to assign Bash environment variables.

Examples of exploitable systems include the following:

Apache HTTP Servers that use CGI scripts (via mod_cgi and mod_cgid) that are written in Bash or launch to Bash subshells
Certain DHCP clients
OpenSSH servers that use the ForceCommand capability
Various network-exposed services that use Bash

On each of your systems that run Bash, you may check for Shellshock vulnerability by running the following command at the bash prompt:

env VAR='() { :;}; echo Bash Linux has Bugs ' bash -c "echo Bash Linux is save"

The highlighted echo Bash is vulnerable! portion of the command represents where a remote attacker could inject malicious code; arbitrary code following a function definition within an environment variable assignment. Therefore, if you see the following output, your version of Bash is vulnerable and should be updated:

Bash Linux has Bugs
Bash Linux is save

Otherwise, if your output does not include the simulated attacker’s payload, i.e. “Bash Linux has Bugs ” is not printed as output, your version of bash is not vulnerable. It may look something like this:

bash: warning: VAR: ignoring function definition attempt
bash: error importing function definition for `VAR’
Bash Linux is save

If your version of Bash is vulnerable, read on to learn how to update Bash and fix the vulnerability.
Test Remote Sites

Debian / Ubuntu – Open a terminal and type in:

sudo apt-get update && sudo apt-get install --only-upgrade bash

CentOS / Red Hat / Fedora – Open a terminal and type in:

su
yum update bash

Now check your system vulnerability again by running this command :

env VAR='() { :;}; echo Bash Linux has Bugs ' bash -c "echo Bash Linux is save"

Be sure to update all of your affected servers to the latest version of Bash!

How to install Zend Framework 2 (ZF2) & ZFTool (Command Line Tool) in Linux Ubuntu 14.04

Introduction:

The Zend Framework 2 is a MVC Framework developped by the PHP developpers called Zend.

I am using an Ubuntu 14.04 Desktop with an installed Apache2 web server, php5 (5.3+ required for ZF2).


Installation Process:

Download Zend Framework 2

First you will have to download the Zend Framework you desire to install (version >= 2.0.0 for this tutorial)

Visit Zend Archive and download your Zend package. 
Extract it to /usr/share/php/ZendFramework2

Download ZFTool

Afterwards you will need to install ZFTool. It is a command line tool which gives you the ability to create projects, models, viewtemplates and so on.

Download ZFTool from GitHub.
Extract it now to /usr/share/php/ZFTool

Now you need to grab a file called zftool.phar.

Download it directly from Zend packages.
And then extract it to the previously created folder
/usr/share/php/ZFTool/bin/.

For the extraction process you are free to choose between handling it over the terminal or the graphical way.

Notice: You will need permission rights to add content to the /usr/share/php/ folder!

You can use sftp://root@localhost to get access to this folder with root permissions, but use this way carefully!

Now you have installed the ZFTool but it is a pity to write the whole path to the executable file to use this tool.
However, as linux gives us the possibility, we can make use of aliases (for the standard user).

Create Alias

cd /etc/php5/conf.d/
sudo touch zend-framework2.ini
sudo gedit zend-framework2.ini

Now you should be able to edit this recently created file. Add the following content to it:

[Zend]
php.include_path = "/usr/share/php/ZendFramework2/library"

Save and close the file afterwards.

Let’s define the alias now:

sudo gedit ~/.bashrc

Add the following lines to your bashrc if they aren’t already defined or uncomment them
(keep in mind to edit from you standard user!):

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
   . ~/.bash_aliases
fi

Save and close again.
Now we have to create the file we are looking for in the previous bashrc:

sudo touch ~/.bash_aliases
sudo gedit ~/.bash_aliases

We add the following line(s) to the file:

alias zf2='export ZF_CONFIG_FILE=/etc/php5/conf.d/zend-framework2.ini; sudo /usr/share/php/ZFTool/bin/zftool.phar'

Finally save and close it.
Now use following command to reload your bashrc file to make the changes taking effect:

. ~/.bashrc

Now you can try to use ZFtool:

zf2 --version

You should get something like this:

ZFTool - Zend Framework 2 command line Tool
The ZFTool is using Zend Framework 2.2.4

Basic usage

For the basic commands of this tool please check the manual / help.

zf2 --help

Debugging

If you get an error, for instance, you wouldn’t have the required permissions,
you could try to give your user the permissions to access the zend directory.

sudo -i
cd /usr/share/php/
chown -R yourUser:yourUser ZFTool/
chmod a+x ZFTool/*
exit

Afterwards try again zf2 --version while logged into the command line with yourUser.

Tutorials Export Excel file with Zend Framework

Class ExportExcelController extends Zend_Controller_Action{

public function exportexcelAction()
{
set_time_limit( 0 );

$model = new Default_Model_SomeModel();
$data = $model->getData();

$filename = APPLICATION_PATH . "/tmp/excel-" . date( "m-d-Y" ) . ".xls";

$realPath = realpath( $filename );

if ( false === $realPath )
{
touch( $filename );
chmod( $filename, 0777 );
}

$filename = realpath( $filename );
$handle = fopen( $filename, "w" );
$finalData = array();
foreach ( $data AS $row )
{
$finalData[] = array(
utf8_decode( $row["col1"] ), // For chars with accents.
utf8_decode( $row["col2"] ),
utf8_decode( $row["col3"] )
);
}

foreach ( $finalData AS $finalRow )
{
fputcsv( $handle, $finalRow, "\t" );
}

fclose( $handle );

$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();

$this->getResponse()->setRawHeader( "Content-Type: application/vnd.ms-excel; charset=UTF-8" )
->setRawHeader( "Content-Disposition: attachment; filename=excel.xls" )
->setRawHeader( "Content-Transfer-Encoding: binary" )
->setRawHeader( "Expires: 0" )
->setRawHeader( "Cache-Control: must-revalidate, post-check=0, pre-check=0" )
->setRawHeader( "Pragma: public" )
->setRawHeader( "Content-Length: " . filesize( $filename ) )
->sendResponse();

readfile( $filename ); unlink($filename); exit();
}

}

How To install PHP5 and OCI8 “oracle client for php” on Debian / Ubuntu Server

This tutorial covers how to compile oci8 lib with php5 on Ubuntu Server.

For this edition it is assumed that you are issuing these commands from the command line.

Open a Terminal “CTRL+ALT+T” and issue a sudo -i

    sudo -i 

Install Apache2

    apt-get install apache2 

Install required PHP5 modules and libraries

    apt-get install php5-common php5 php5-dev libapache2-mod-php5 php5-cli 

Install the build-essential and php-pear packages

    apt-get install build-essential php-pear 

IMPORTANT! Install libaio1 library. This is what I was having serious issues with originally.

    apt-get install libaio1 

Download the new Instantclient and SDK zip files from Oracle.

link

In my case the files are called Basic.zip and Sdk.zip Initially these files will be saved in my home directory under the Documents folder /home/ubuntu/Documents/

create a directory to house the zip files once they are uncompressed

    mkdir /opt/oracle 

move the .zip files in the “Documents” directory to the /opt/oracle directory

    mv /home/ubuntu/Documents/*.zip /opt/oracle 

Change to the /opt/oracle directory

    cd /opt/oracle 

Unzip the files

    unzip \*.zip 

rename instantclient directory

    mv instantclient_11_1 instantclient 

Change directory to instantclient, list the files

    cd instantclient 

Create symbolic links

    ln –s libclntsh.so.11.1 libclntsh.so
    ln –s libocci.so.11.1 libocci.so 

Create a source directory under /opt/oracle . This is where we will house the oci8 libraries.

    mkdir /opt/oracle/src 

Change the directory to /opt/oracle/src and download the oci8 tar using pecl

    cd /opt/oracle/src
    pecl download oci8 

Untar the oci8 libraries

    tar xvf oci8-1.2.4.tgz 

Change to the newly created oci8-1.2.4 directory and issue the following commands

    cd oci8-1.2.4
    phpize 

Set the ORACLE_HOME environment variable

    export ORACLE_HOME=/opt/oracle/instantclient
    echo $ORACLE_HOME 
    cd /opt/oracle/instantclient

Configure oci8 to install with the necessary parameters

    ./configure --with-oci8=share,instantclient,/opt/oracle/instantclient 

run make to compile

    make 

install oci8

    make install 

insert the extension=oci8.so into the php.ini and cli.ini files

    echo extension=oci8.so >> /etc/php5/apache2/php.ini
    echo extension=oci8.so >> /etc/php5/cli/php.ini 

restart apache

    /etc/init.d/apache2 restart or service apache2 restart 

create a phpinfo.php file in /var/www

    vi /var/www/phpinfo.php 

Now go to your browser and run the phpinfo file and look for the oci8 module

http://localhost/phpinfo.php

Download my oratest php template file and configure it with the needed settings.

Test the connection

php /home/ubuntu/oratest.php

Connection Succesful

IMPORTANT

add follwing lines to /etc/apache2/envvars

export LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 export ORACLE_HOME=/opt/oracle/instantclient_11_2 export TNS_ADMIN=/opt/oracle/tns/