Friday, May 6, 2016

Windows 10: repair "Failed to connect to Windows service. "

PC Base:
  • OS Name Microsoft Windows 10 Pro
  • Version 10.0.10586 Build 10586
  • System Type x64-based PC
  • Processor AMD A4-4020 APU with Radeon(tm) HD Graphics, 3200 Mhz, 1 Core(s), 2 Logical Processor(s)
  • System Model A55F2-M4
  • BIOS Version/Date American Megatrends Inc. 4.6.5, 2013-06-03
  • Installed Physical Memory (RAM) 2.00 GB
  • Total Virtual Memory 5.44 GB
This error, "Failed to connect to Windows service. ", happened frequently in my PC. These suggestions take longer time to accomplish:
  1. chkdsk c: /f
  2. sfc /scannow 
All you have to do is:
  1. run cmd as "Run as administrator"
  2. type >netsh winsock reset
  3. restart/reboot your PC
This is for fast solution to fix connection to Windows service, not intended to fix real problem in your Windows. After restart/reboot your PC, you may take another action in Troubleshooting -> View all:
  • Background Intelligent Transfer Service
  • Windows Update
This problem may reoccurred in your PC.

Wednesday, May 4, 2016

How to integrated web template into codeigniter 3.0.6 (with upgrade to 3.1.2)

Prerequistes:

After you extract codeigniter 3.1.2 you may have these structure directory:
[root codeigniter]
application
system
userguide
To upgrade codeigniter 3.0.6 to 3.1.2, extract codeigniter 3.1.2 and copy/replace system folder into [root codeigniter] folder. To upgrade from other version read this guide.
Extract your template into codeigniter folder [root codeigniter].
[root codeigniter]
application
system
userguide
fft--css
--fonts
--images
--js
--video
--index.html
--w3layouts-License.txt
Create file test.php file in folder controller.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Test extends CI_Controller {
  public function __construct() {
    parent::__construct();
  }
  public function view($page = 'Test')
  {
    $this->load->helper('html');
    $this->load->helper('url');
    if ( ! file_exists(APPPATH.'views/fft/'.$page.'.php'))
    {
      show_404();
    }
    $data['title'] = $page; // Capitalize the first letter

    $this->load->view('fft/templates/pageheader',$data);
    $this->load->view('fft/'.$page, $data);
    $this->load->view('fft/templates/pagefooter');
  }
}

?>
At folder views, create folder fft.
application
--------bodymenu.php

--------pageheader.php
------test.php
We split file views->test.php. The other supporting files we put them into folder  [root codeigniter]->application->templates.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!-- banner -->
  <div data-vide-bg="<?php echo base_url(); ?>fft/video/sea">
    <div class="center-container">
      <div class="container">
        <!-- load body header -->
        <?php $this->load->view('fft/templates/bodyheader'); ?>
        <div class="logo animated wow zoomIn" data-wow-delay="900ms">
          <h1><a href="/web/joomla/index.html">Frequent <span>flyer</span><i>take me anywhere</i></a></h1>
        </div>
        <div class="start animated wow bounce" data-wow-delay="700ms">
          <a href="#about" class="hvr-bounce-to-bottom scroll">Get Started</a>
        </div>
      </div>
    </div>
  </div>
Final directory will like this:
[root codeigniter]
------views
------templates
--------bodyheader.php
--------pagefooter.php
------about.php
------test.php
--system
--userguide
--fft
----css
----fonts
----images
----js
----video
----index.html
----w3layouts-License.txt

You can download zip file from http://www.garasiku.web.id/fft.zip and extract it into [root codeigniter]

References:

Saturday, April 30, 2016

Install Composer in XAMPP 1.8.1 and Windows 10 (x64)

Prerequisites:
  • Windows 10 
  • XAMPP work
Make sure openssl extension is enable in php.ini:
extension=php_openssl.dll

Follow this step to install composer
  1. Open cmd Windows
  2. Donwload installer by running this command
    php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php
    for example*
    D:\xampp\php>php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php
  3. Validate your composer-setup.php by running 
    php -r "if (hash_file('SHA384', 'composer-setup.php') === 'a52be7b8724e47499b039d53415953cc3d5b459b9d9c0308301f867921c19efc623b81dfef8fc2be194a5cf56945d223') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    for example*:
    D:\xampp\php>php -r "if (hash_file('SHA384', 'composer-setup.php') === 'a52be7b8724e47499b039d53415953cc3d5b459b9d9c0308301f867921c19efc623b81dfef8fc2be194a5cf56945d223') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    Installer verified
  4. Install your composer by running
    php composer-setup.php
    for example*:
    D:\xampp\php>php composer-setup.php
    Some settings on your machine may cause stability issues with Composer.
    If you encounter issues, try to change the following:
    The OpenSSL library (0.9.8x) used by PHP does not support TLSv1.2 or TLSv1.1.
    If possible you should upgrade OpenSSL to version 1.0.1 or above.
    Downloading 1.0.3...
    Composer successfully installed to: D:\xampp\php\composer.phar
    Use it: php composer.phar
  5. Remove composer-setup.php** by running:
    php -r "unlink('composer-setup.php');"
    for example*:
    D:\xampp\php>php -r "unlink('composer-setup.php');"
Note:
* in my case I use stand alone xampp in directory d:
** you do not have to save any composer-setup.php, it may change for a new version
 
References:

  • http://i.justrealized.com/2013/install-composer-windows/
  • https://getcomposer.org/download/

Saturday, April 23, 2016

WHM/CPanel Centos 7: enabling ipset in csf

Prerequisite:
  • Iptables & Ipset
  • Serverconfig v7.54 or later
Follow WHM/CPanel centos 7: blocking brute force attack to replace firewalld with iptables and ipset.

Download and Install serverconfig:

# wget http://configserver.com/free/csf.tgz# tar -xzf csf.tgz# cd csf & ./install.cpanel.sh

To enable ipset in csf, edit file /etc/csf/csf.conf or edit it via WHM/CPanel:

TESTING = “0”
LF_IPSET = 1
TCP_IN= “22,80,53,443” 
TCP_OUT=”22,80,53,443″
UDP_IN=”53″
UDP_OUT=”53″
NOTE: don't forget to add your port services

Restart your csf

# service csf restart
Or via WHM/CPanel click Restart CSF+LFD

References:

Sunday, April 17, 2016

WHM/CPanel Centos 7: blocking brute force attack

By default, Centos 7 use firewalld to manages net filter rules. Just like iptables, adding new rules may increase your cpu load. This is my notes to optimize net filtering ipset to block brute force attack.

Disable firewalld and enable iptables/ipset

Stop and mask the firewalld service:
# systemctl stop firewalld# systemctl mask firewalld
Install the iptables-services package:
# yum install iptables-services
Enable the service at boot-time:
# systemctl enable iptables
# systemctl enable ip6tables
Start iptables service
# systemctl start iptables
# systemctl start ip6tables
Install ipset
# yum install ipset

Install & Configure fail2ban (Optional)

Installing fail2ban
# yum install fail2ban
Enable fail2ban
# systemctl enable fail2ban
Start fail2ban
# systemctl start fail2ban
or
# service fail2ban start
Fix firewall run
# /scripts/configure_firewall_for_cpanel
Open some port for examples 12345
# iptables -I INPUT -p tcp --dport 12345 -m state --state NEW,ESTABLISHED -j ACCEPT
To disable fail2ban service
# systemctl stop firewalld
# systemctl disable fail2ban
If you prefered to use CSF (ConfigServer Sercurity & Firewall) follow WHM/CPanel Centos 7: enabling ipset in csf
Preferences: