Thursday, August 1, 2013

How To Install Mod_Cloudflare On Apache For Ubuntu

sudo apt-get install apache2-prefork-dev
wget https://raw.github.com/cloudflare/CloudFlare-Tools/master/mod_cloudflare.c
apxs2 -iac mod_cloudflare.c
sudo service apache2 restart

Monday, July 8, 2013

Ubuntu remove sendmail

sudo apt-get remove sendmail sendmail-bin postfix
sudo apt-get purge postfix exim4 sendmail sendmail-bin
sudo reboot

VirtualHost 127.0.0.1:8080 overlaps with VirtualHost 127.0.0.1:8080

[warn] VirtualHost 127.0.0.1:8080 overlaps with VirtualHost 127.0.0.1:8080, the first has precedence, perhaps you need a NameVirtualHost directive

Apache listen only on 127.0.0.1 (Nginx front-end etc.) and host multiple subdomains in Apache
vi /etc/apache2/ports.conf

NameVirtualHost 127.0.0.1
Listen 127.0.0.1:80
Use this on vhosts
<virtualhost 127.0.0.1>
</virtualhost>

Thursday, May 30, 2013

Hide Apache Version in Ubuntu

edit /etc/apache2/conf.d/security
1)
ServerTokens OS
to
ServerTokens Prod

2)
ServerSignature On
to
ServerSignature Off

Tuesday, February 19, 2013

How do I add a decimal field in a Codeigniter Migration

public function up()
 {
  $this->dbforge->add_field(array(
   'Price' => array(
    'type' => 'DECIMAL',
    'constraint' => '10,2',
    'unsigned' => FALSE
   )
  ));

  $this->dbforge->create_table('ads');
 }

Tuesday, February 12, 2013

Wamp virtual hosts

Open C:\wamp\bin\apache\apache2.2.22\conf\httpd.conf
Uncomment
#Include conf/extra/httpd-vhosts.conf
it will be
Include conf/extra/httpd-vhosts.conf

Open C:\wamp\bin\apache\apache2.2.22\conf\extra\httpd-vhosts.conf to add/edit virtual hosts

Sample
NameVirtualHost *:80


    DocumentRoot "c:/wamp/www/"
    ServerName localhost
    ServerAlias www.localhost

Windows how to switch php version between 5.2 and 5.3



now you can switch php version




** WARNING : You must install Visual C++ 2010 SP1 Redistributable Package x86 or x64

VC10 SP1 vcredist_x86.exe 32 bits : http://www.microsoft.com/download/en/details.aspx?id=8328

Codeigniter cache model sample

model
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Countries_model extends CI_Model {

public function get_countries()
 {
  $query = $this->db->get('countries');

  if ($query->num_rows() > 0) {
   return $query->result();
  } else {
   return FALSE;
  }
  
 }

public function get_cache()
 {
  if ( ! $countries = $this->cache->get('countries')) {
   $countries = $this->get_countries();
   $this->cache->save('countries', $countries, 86400);
  }

  return $countries;
 }
}
controller
$this->countries_model->get_cache();

Wednesday, January 2, 2013

Wednesday, June 27, 2012

Minify Output Codeigniter 3.0

With latest dev version of 3.0, they have option for minify output. In /application/config/config.php just change it to TRUE

Show 404 error page instead "The URI you submitted has disallowed characters" error

it's really annoyed with this error page. I think show 404 error page is more clean

 Create a file named MY_URI.php in application/core/ and paste below code

Saturday, December 4, 2010

Codeigniter 2.0 Controller

class Welcome extends CI_Controller
{
function __construct()
{
parent::__construct();
}
}

Friday, August 6, 2010

Bit.ly Codeigniter

as simple as
$this->load->library('bitly');

then echo.simple!
echo $this->bitly->shorten('http://aizuddinmanap.blogspot.com/'); 

http://github.com/patrickpopowicz/bit.ly-Library-for-CodeIgniter/

Sunday, July 25, 2010

Form Validation Callbacks in HMVC in Codeigniter problem

create a file name MY_Form_validation.php and put it in the application/libraries folder
< ?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class MY_Form_validation extends CI_Form_validation
{
 function run($module = '', $group = '') {
 (is_object($module)) AND $this->CI =& $module;
 return parent::run($group);
 }
}
/* End of file MY_Form_validation.php */
/* Location: ./application/libraries/MY_Form_validation.php */  

when using validation, put $this into the $this->form_validation->run()
example
if($this->form_validation->run($this)) {
//your code down there 
}

Thursday, July 1, 2010

Saturday, June 19, 2010

Codeigniter Route Everything, except these Controllers

another Codeigniter routes, Codeigniter Route Everything, except these Controllers

There was a recent post on the codeigniter forums trying to get urls like these:
http://yoursite.com/your-slug
This problem could have been easily resolved using this route:
$route['(:any)'] = 'articles/$1';

In this route, all characters after the domain will be passed to the controller, 'article'.

However, the problem was he also had some controllers that he didn't want to use the route for. A quick fix for the route was to use a 'simple' regex using negative lookahead
$route['^(?!controller|controller|controller)\S*'] = "article/$1";


p/s:original post from here

codeigniter routes

how to use http://localhost/receipt/view/1 as http://localhost/receipt/1 ?
routes is the solution.

1)edit /application/config/routes.php

2)
$route['receipt/(:num)'] = "receipt/view/$1";