POLi Payment Gateway: Why you shouldn’t use this option…

Info.Tech, Security Concerns, Web Development 2 Comments »

poli_1

 

 

 

 

 

The first time I saw POLi payments was in Qantas Airlines New Zealand. The moment I saw asking for my Bank Credentials, I click back button ripoli_3ght away.

Why? Because POLi is asking your Access Code/Username and Password of your bank, your BANK CREDENTIALS! Imagine your hosts file has been altered by malware or any virus or your network has been hacked or exploited or your ISP has been hacked or whatever above your internet line has been altered pointing POLi payment gateway’s DNS to different server, you will be giving your bank access to the hackers. And POLi is a direct access to your bank account (your entire assets in your bank) and initiate the transaction right away. Unlike credit cards, if your card has been expospoli_2ed, then the risk is JUST your card, not your whole account in the bank then you still have time to call the bank the close it right away.

So my advise never use POLi payments. I’m not against the company or the people who created it but I am just against how the implementation or how it works.

MySQL + Percona XtraDB Cluster 5.6

Administration, Info.Tech, Linux System Administration, SQL: Structured Query Language Comments Off on MySQL + Percona XtraDB Cluster 5.6

I have been experimenting on MySQL + Percona XtraDB Cluster (version 5.6). In my case, I used VMWare/VirtualBox. I created two images and label as DB1 and DB2 using Ubuntu 14.04.2 32bit (Trusty Tahr). My goal is to replicate the database from DB1 to DB2. If DB1 will be down, then DB2 will take over DB1. While fixing DB1, DB2 will serve then if DB1 is back online, DB1 will be the “Joiner” to the “Donor” (DB2). …and vice versa.

Installation

First thing you need is to prepare the installation of Percona XtraDB Cluster. (must be root or right high privileges on performing this installation)

root@db1:~# apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A

One thing you need to ensure is you have all Ubuntu official repositories plus Percona APT repository. So what I did is replace /etc/apt/source.list with:

# deb cdrom:[Ubuntu-Server 14.04.2 LTS _Trusty Tahr_ - Release i386 (20150218.1)]/ trusty main restricted

###### Ubuntu Main Repos
deb http://us.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse

## Ubuntu Security Updates
deb http://security.ubuntu.com/ubuntu trusty-security main
deb-src http://security.ubuntu.com/ubuntu trusty-security main
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner

## Uncomment the following two lines to add software from Ubuntu's
## 'extras' repository.
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu trusty main
deb-src http://extras.ubuntu.com/ubuntu trusty main

###### Ubuntu Update Repos
deb http://us.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

# Percona XtraDB Cluster
deb http://repo.percona.com/apt trusty main
deb-src http://repo.percona.com/apt trusty main

After updating the APT source list, execute:

root@db1:~# apt-get update

After that, you can install Percona XtraDB Cluster server and client packages:

root@db1:~# apt-get install percona-server-server-5.6 percona-server-client-5.6

This is where I got stuck when trying to connect the nodes. Remove apparmor!!! You can check first if apparmor is running:

root@db1:~# apparmor_status

If its running, remove it before causing problems to Percona.

root@db1:~# apt-get remove apparmor

Important Notes: Do the same installation in the 2nd node or DB2.

Then to run the primary node (donor), DB1 in our case:

root@db1:~# service mysql bootstrap-pxc
 * Bootstrapping Percona XtraDB Cluster database server mysqld                       [ OK ]
root@db1:~#

Then run the 2nd node or joiner (DB2):

root@db2:~# service mysql start
mysql start/running, process 1550
root@db2:~#

~ or ~

root@db2:~# service mysql restart
mysql stop/waiting
mysql start/running, process 1550
root@db2:~#

Note: Always start first the primary node (DB1) then the next node (DB2)

Testing

Check if primary node (DB1) is working…

root@db1:~# mysql -u root -p -e "show status where Variable_name like '%wsrep_cluster%' OR Variable_name like '%wsrep_ready%';"
Enter password:
+--------------------------+--------------------------------------+
| Variable_name            | Value                                |
+--------------------------+--------------------------------------+
| wsrep_cluster_conf_id    | 5                                    |
| wsrep_cluster_size       | 1                                    |
| wsrep_cluster_state_uuid | 1fa1e1fc-cf8e-11e4-9664-3ea415c4a429 |
| wsrep_cluster_status     | Primary                              |
| wsrep_ready              | ON                                   |
+--------------------------+--------------------------------------+

root@db1:~# mysql -u root -p -e "show binary logs;"
Enter password:
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000001 |       120 |
+------------------+-----------+

Next, check the 2nd node (DB2)…

root@db2:/etc/mysql# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.22-72.0-56-log Percona XtraDB Cluster (GPL), Release rel72.0, Revision 978, WSREP version 25.8, wsrep_25.8.r4150

Copyright (coffee) 2009-2014 Percona LLC and/or its affiliates
Copyright (coffee) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

More TEST: I created a PHP script for DB1 and DB2 to test the replication.

DB1 PHP Script (test_percona.php):

<?php

$connect = mysql_connect('localhost','root','secret');

mysql_select_db('test', $connect);

// insert if table not exists...
@mysql_query("create table if not exists data_test(
 id bigint(20) unsigned not null auto_increment primary key,
 data varchar(128),
 created datetime
);");

// inject data infinitely
while (true) {
        $data = sha1(time().rand(100,99999));
        echo $data." -> ".date("j M Y g:i.s a - l\n");
        @mysql_query("INSERT INTO data_test (data,created) VALUES ('".$data."', NOW())");
}

?>

DB2 PHP Script (monitor_percona.php):

<?php

$connect = mysql_connect('localhost','root','secret');

mysql_select_db('test', $connect);

$last_id = 0;

while (true) {
        $result = mysql_query("SELECT * FROM data_test WHERE id > ".$last_id." ORDER BY id ASC");
        $max = mysql_num_rows($result);
        if ($max > 0) {
                for ($i = 0; $i < $max; $i++) {
                        echo mysql_result($result,$i,"data")." -> ".date("j M Y g:i.s a - l", strtotime(mysql_result($result,$i,"created")))."\n";
                        $last_id = mysql_result($result,$i,"id");
                }
        }
}

?>

Then you can run the script on both nodes. To run in DB1 node, do:

root@db1:~# php test_percona.php

Then for the 2nd node:

root@db2:~# php monitor_percona.php

After that, you must see same output both nodes.

percona_xc_test_result2

percona_xc_test_result

 Encountered Issues (tail -f /var/log/mysql/error.log):

2015-03-21 20:19:11 6613 [Warning] WSREP: Gap in state sequence. Need state transfer.
2015-03-21 20:19:11 6613 [Note] WSREP: Running: 'wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.9.103' --auth 'sstuser:secret' --datadir '/var/lib/mysql/' --defaults-file '/etc/mysql/my.cnf' --parent '6613'  '' '
2015-03-21 20:19:11 6613 [ERROR] execlp() failed: Permission denied
2015-03-21 20:19:11 6613 [ERROR] WSREP: Failed to read 'ready <addr>' from: wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.9.103' --auth 'sstuser:secret' --datadir '/var/lib/mysql/' --defaults-file '/etc/mysql/my.cnf' --parent '6613'  '' Read: '(null)'
2015-03-21 20:19:11 6613 [ERROR] WSREP: Process completed with error: wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.9.103' --auth 'sstuser:secret' --datadir '/var/lib/mysql/' --defaults-file '/etc/mysql/my.cnf' --parent '6613'  '' : 1 (Operation not permitted)
2015-03-21 20:19:11 6613 [ERROR] WSREP: Failed to prepare for 'xtrabackup-v2' SST. Unrecoverable.
2015-03-21 20:19:11 6613 [ERROR] Aborting

To solve the issue is to remove the apparmor

Reference: 

  • http://www.percona.com/doc/percona-server/5.6/installation/apt_repo.html
  • http://www.percona.com/doc/percona-xtradb-cluster/5.5/howtos/ubuntu_howto.html
  • http://www.percona.com/doc/percona-xtrabackup/2.1/innobackupex/pit_recovery_ibk.html

MySQL Constraints: Import

Info.Tech, Linux System Administration, SQL: Structured Query Language, Web Development Comments Off on MySQL Constraints: Import

I stumbled down again of database constraints when importing SQL dump file.

ERROR 1217 (23000) at line 128: Cannot delete or update a parent row: a foreign key constraint fails

The solution is add the following line in the beginning of the SQL dump file:

SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0

That should work.

Prendstah.com got A+ grade from ssllabs.com

Administration, Info.Tech, PHP, Web Development Comments Off on Prendstah.com got A+ grade from ssllabs.com

I was curious how Sid Bachtiar got the high grade of his SSL Report. It challenge me and give me interest how to do it. So I did. Oh Yeah! Got the A+ SSL Report grade.

prendstah_Aplus_on_ssllabs

SSL Test: https://www.ssllabs.com/ssltest/analyze.html?d=prendstah.com

 

skype_a-ssl

Selwyn District Council Consents

Info.Tech, PHP, Web Development Comments Off on Selwyn District Council Consents

Wohooo… It is really good hearing this news. TRIAD { sid, michael, camilo3rd } is behind this online tool.

Online Building Consent System is powered by: Alpha 77 Limited (www.abcs.co.nz)

Legacy of Adam Jones of QCIT Ltd (www.qcit.co.nz)

PHP Deployment Tool: Mage

Info.Tech, PHP, Web Development Comments Off on PHP Deployment Tool: Mage

I’ve been using this php deployment tool called magallanes or mage php. It is pretty cool. For more details of this tool, visit http://magephp.com

I did a fork because its not working well on windows. My Fork: https://github.com/camilord/Magallanes

My fixes are issues on tarballing the the project and the rsync to the server.

mage

Code Igniter: Cannot get POST values

Administration, Code Igniter, Info.Tech, PHP, Web Development Comments Off on Code Igniter: Cannot get POST values

I encountered this issue in Code Igniter that I cannot get the POST values. Some says its the .htaccess issue. I used same .htaccess with all my application and works fine. I was working on my new environment, Kali Linux, and realised that its the mod_rewrite module wasn’t loaded and partly affects the .htaccess.

# cd /etc/apache2/mods-enabled/
# locate mod_rewrite
/usr/lib/apache2/modules/mod_rewrite.so
# touch rewrite.load
# nano rewrite.load

At the file:

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

Save the changes and restart apache.

Hope this will help you… Pee coding!

Allow postfix to send email with different sender from SMTP account

Administration, Info.Tech, Linux System Administration, PHP, Web Development Comments Off on Allow postfix to send email with different sender from SMTP account

Allow postfix  to send email with different sender from SMTP account…

Error:

postfix/smtpd[27402]: NOQUEUE: reject: RCPT from unknown[125.123.123.100]: 553 5.7.1 <user@xxx.co.nz>: Sender address rejected: not owned by user user@xxx.co.nz; from=<xxx@xxx.co.nz> to=<xxx@gmail.com> proto=ESMTP helo=<localhost>

Edit postfix configuration:

[root@mail ~]# nano /etc/postfix/main.cf

Change from:

smtpd_sender_restrictions = permit_mynetworks, reject_sender_login_mismatch, permit_sasl_authenticated

To:

smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated

Then restart postfix…

[root@mail ~]# postfix stop
postfix/postfix-script: stopping the Postfix mail system
postfix/postfix-script: waiting for the Postfix mail system to terminate
[root@mail ~]# postfix start
postfix/postfix-script: starting the Postfix mail system
[root@mail ~]#

That’s it.. You can now change your from or reply-to in your PHPMailer. 🙂

Hope this helps…

Symfony2: Install/Create Project

Info.Tech, Symfony Framework, Web Development Comments Off on Symfony2: Install/Create Project
C:\php>php composer.phar install
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "composer.phar self-update" to get the latest version.
Composer could not find a composer.json file in C:\php
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section

C:\php>php composer.phar self-update
Updating to version 0238aaf5ac565a5b896caa79e9ca7e71d2312343.
    Downloading: 100%

C:\php>php composer.phar install
Composer could not find a composer.json file in C:\php
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section

C:\php>composer install
'composer' is not recognized as an internal or external command,
operable program or batch file.

C:\php>php composer install
Could not open input file: composer

C:\php>php composer.phar
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 0238aaf5ac565a5b896caa79e9ca7e71d2312343 2014-01-29 09:12:19

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message.
  --quiet          -q Do not output any message.
  --verbose        -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
  --version        -V Display this application version.
  --ansi              Force ANSI output.
  --no-ansi           Disable ANSI output.
  --no-interaction -n Do not ask any interactive question.
  --profile           Display timing and memory usage information
  --working-dir    -d If specified, use the given directory as working directory.

Available commands:
  about            Short information about Composer
  archive          Create an archive of this composer package
  config           Set config options
  create-project   Create new project from a package into given directory.
  depends          Shows which packages depend on the given package
  diagnose         Diagnoses the system to identify common errors.
  dump-autoload    Dumps the autoloader
  dumpautoload     Dumps the autoloader
  global           Allows running commands in the global composer dir ($COMPOSER_HOME).
  help             Displays help for a command
  init             Creates a basic composer.json file in current directory.
  install          Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.
  licenses         Show information about licenses of dependencies
  list             Lists commands
  require          Adds required packages to your composer.json and installs them
  run-script       Run the scripts defined in composer.json.
  search           Search for packages
  self-update      Updates composer.phar to the latest version.
  selfupdate       Updates composer.phar to the latest version.
  show             Show information about packages
  status           Show a list of locally modified packages
  update           Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file.
  validate         Validates a composer.json

C:\php>php composer.phar install
Composer could not find a composer.json file in C:\php
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section

C:\php>php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Installing monolog/monolog (1.2.1)
    Downloading: 100%

monolog/monolog suggests installing mlehner/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
Writing lock file
Generating autoload files

C:\Workspace\localhost\symfony>php.exe c:\php\composer.phar create-project symfony/framework-standard-edition c:\workspace\localhost\symfony\Symfony 2.4.1
Installing symfony/framework-standard-edition (v2.4.1)
  - Installing symfony/framework-standard-edition (v2.4.1)
    Downloading: 100%

Created project in c:\workspace\localhost\symfony\Symfony
Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Installing jdorn/sql-formatter (v1.2.17)
    Downloading: 100%

  - Installing psr/log (1.0.0)
    Loading from cache

  - Installing twig/twig (v1.15.0)
    Downloading: 100%

  - Installing doctrine/lexer (v1.0)
    Downloading: 100%

  - Installing doctrine/annotations (v1.1.2)
    Downloading: 100%

  - Installing doctrine/collections (v1.1)
    Downloading: 100%

  - Installing doctrine/cache (v1.3.0)
    Downloading: 100%

  - Installing doctrine/inflector (v1.0)
    Downloading: 100%

  - Installing doctrine/common (v2.4.1)
    Downloading: 100%

  - Installing symfony/symfony (v2.4.1)
    Downloading: 100%

  - Installing symfony/icu (v1.0.0)
    Downloading: 100%

  - Installing doctrine/dbal (v2.4.2)
    Downloading: 100%

  - Installing doctrine/doctrine-bundle (v1.2.0)
    Downloading: 100%

  - Installing kriswallsmith/assetic (v1.1.2)
    Downloading: 100%

  - Installing symfony/assetic-bundle (v2.3.0)
    Downloading: 100%

  - Installing sensio/framework-extra-bundle (v3.0.0)
    Downloading: 100%

  - Installing doctrine/orm (v2.4.1)
    Downloading: 100%

  - Installing twig/extensions (v1.0.1)
    Downloading: 100%

  - Installing swiftmailer/swiftmailer (v5.0.3)
    Loading from cache

  - Installing symfony/swiftmailer-bundle (v2.3.5)
    Downloading: 100%

  - Installing monolog/monolog (1.7.0)
    Loading from cache

  - Installing symfony/monolog-bundle (v2.5.0)
    Downloading: 100%

  - Installing sensio/distribution-bundle (v2.3.4)
    Downloading: 100%

  - Installing sensio/generator-bundle (v2.3.4)
    Downloading: 100%

  - Installing incenteev/composer-parameter-handler (v2.1.0)
    Downloading: 100%

kriswallsmith/assetic suggests installing leafo/lessphp (Assetic provides the integration with the lessphp LESS compiler)
kriswallsmith/assetic suggests installing leafo/scssphp (Assetic provides the integration with the scssphp SCSS compiler)
kriswallsmith/assetic suggests installing ptachoire/cssembed (Assetic provides the integration with phpcssembed to embed data uris)
kriswallsmith/assetic suggests installing leafo/scssphp-compass (Assetic provides the integration with the SCSS compass plugin)
monolog/monolog suggests installing mlehner/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing raven/raven (Allow sending log messages to a Sentry server)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
Writing lock file
Generating autoload files
Creating the "app/config/parameters.yml" file
Some parameters are missing. Please provide them.
database_driver (pdo_mysql):
database_host (127.0.0.1):
database_port (null): 3306
database_name (symfony):
database_user (root):
database_password (null): secretkanding
mailer_transport (smtp):
mailer_host (127.0.0.1):
mailer_user (null):
mailer_password (null):
locale (en):
secret (ThisTokenIsNotSoSecretChangeIt): 123456987456321
Clearing the cache for the dev environment with debug true
Installing assets using the hard copy option
Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
Installing assets for Acme\DemoBundle into web/bundles/acmedemo
Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution

C:\Workspace\localhost\symfony>

Top PHP Frameworks

Info.Tech, PHP, Web Development Comments Off on Top PHP Frameworks
Top 5 PHP Frameworks Infographic
From: www.zfort.com

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in