CORS codeigniter rest server phil sturgeon.

Configure this file.

First Step :
Locate and edit
/application/libraries/REST_Controller.php

change from this :

protected $allowed_http_methods = array('get', 'delete', 'post', 'put', 'options', 'patch', 'head');

to this :
protected $allowed_http_methods = array('get',  'delete', 'post', 'put', 'patch', 'head');

Second Step :
Locate and edit your httpd.conf / apache.conf
In <Directory “*html*”> add this line

Dav On
Options FollowSymLinks
AllowOverride All
Header always set Access-Control-Allow-Origin: "*"
Header always set Access-Control-Allow-Methods "POST, GET, PUT, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "origin, x-requested-with, content-type"

Ubuntu Brengset

//location apache conf /etc/apache2/apache2.conf

<Directory /var/www/>
    Options Indexes FollowSymLinks
	AllowOverride All
	Require all granted
</Directory>


//phpmyadmin
sudo add-apt-repository ppa:nijel/phpmyadmin
sudo apt-get update
sudo apt-get install phpmyadmin

sudo ln -s /etc/phpmyadmin /var/www/html/segidb
sudo php5enmod mcrypt


//ssl

sudo a2enmod ssl
sudo mkdir /etc/apache2/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
sudo nano /etc/apache2/sites-available/default-ssl.conf
sudo a2ensite default-ssl.conf

// tool

apache2ctl -M
cat /etc/motd.tail
mysql_secure_installation

sudo htpasswd -c /etc/apache2/.phpmyadmin.htpasswd USERNAME

Samba conf

Here the successfully config setting for samba

http://www.golinuxhub.com/2012/08/creating-samba-share.html

# vi /etc/samba/smb.conf

security = share
workgroup = WORKGROUP
netbios name = centos
name resolve order = wins bcast lmhosts host
client lanman auth = yes
client ntlmv2 auth = no
hosts allow 127. 10.10.10. 192.168.0.

[Share]
path = /home/share
browseable = yes
share modes = yes
guest only = yes
browseable = yes
writable = yes
guest ok = yes
create mode = 0777
directory mode = 0777

Mykad APDU Information

There will be 5 APDU commands that I’ll introduce. I name them as
1) Select Application
2) Get Response
3) Set Length
4) Select Info
5) Read Info

Instead of viewing a particular command to read “Name”, another command to read “IC no.”, it is better to interpret a sequence of 3 commands (Set Length, Select Info, Read Info) as “reading a section (or the whole) file”. The fact is “Name”, “IC no.” etc are stored in fixed-length fields (padded on the right), and concatenated together (without separator) to form files.
For example,
“Name” stored in file jpn-1-1, offset 0x00E9, length 0x28
“IC no.” stored in file jpn-1-1, offset 0x0111, length 0x0D
When you want to read “Name”, you read jpn-1-1, offset 0x00E9, length 0x28.
When you want to read “IC no.”, you read jpn-1-1, offset 0x0111, length 0x0D.
When you want to read both “Name” and “IC no.”, you read jpn-1-1, offset 0x00E9, length 0x35.
Conversely, you can read only part of the field; if you want only first 6 digits of “IC no.”, read jpn-1-1, offset 0x111, length 6.

Now, the first 2 commands, “Select Application” and “Get Response”, are used to select either one of JPN, JPJ, IMM appplication. (Actually you can have 2 active at the same time by using logical channels, but that’s a little bit advanced at this stage.) You must select an application after reset, and you’ll do it only once except you want to change application.

Reader: 00 A4 04 00 0A A0 00 00 00 74 4A 50 4E 00 10 (Send 10 bytes data, expect receive 0 bytes)
Card : 61 05
Reader: 00 C0 00 00 05 (Send 0 bytes data, expect receive 5 bytes)
Card : 6F 03 82 01 38 90 00

“00 A4 04 00 0A” is the “CLA INS P1 P2 P3″ for “Select Application”. The data part of the APDU consists of 10 bytes: “A0 00 00 00 74 4A 50 4E 00 10″. The “A0 00 00 00 74″ and “00 10″ parts are constant. “4A 50 4E” represents “JPN”. Change to “JPJ” or “IMM” for those applications.
“00 C0 00 00 05″ is the “CLA INS P1 P2 P3″ for “Get Response”. The 5 data bytes received is not significant, but you can verify whether it is successful.

That’s the end of description of “Select Application” and “Get Response”. Now move on to the 3 commands to read a section of file.

Example: read jpn-1-1, offset 0x00E9, length 0x28.
Reader: C8 32 00 00 05 08 00 00 28 00
Card : 91 08
Reader: CC 00 00 00 08 01 00 01 00 E9 00 28 00
Card : 94 28
Reader: CC 06 00 00 28
Card : 4D 59 20 4E 41 4D 45 20 20 20 20… 90 00

The 3 commands “Set Length”, “Select Info”, and “Read Info” are shown above. The colored parts are those which varies.
It seems from above that the maximum length will be 0xFF, so you’ll have to break long file section (particularly when reading JPEG) into multiple reads (repeat the 3 commands with different length and offset). But actually, for advanced users, you can specify a length >= 0x0100, (provided you don’t read past the end of file which results in no bytes returned,) in the “Set Length” and “Select Info”. You only need multiple “Read Info”, with the single byte length set to big a number (eg. 0xFF or 0xFC), except the last read. “Read Info” is just like retrieving out from a FIFO buffer, you can read however you want, but don’t over-read it.

To read jpn-1-4, replace 01 00 01 00 to 04 00 01 00.

Those double byte “Offset” and “Length” are in little endian.

 

JPN

jpn-1-1
Offset  Length  Length  SDK Function Name        Description
       (Hex)   (Dec)
0000     03        3                          01 04 24
0003     96      150    JPN_OrgName              original name
0099     50   30+30+20  JPN_GMPCName             GMPC name
00E9     28     20+20   JPN_KPTName              KPT name
0111     0D       13    JPN_IDNum                ID number
011E     01        1    JPN_Gender               gender
011F     08        8    JPN_OldIDNum             old ID number
0127     04        4    JPN_BirthDate            date of birth
012B     19       25    JPN_BirthPlace           place of birth
0144     04        4    JPN_DateIssued           date issued
0148     12       18    JPN_Citizenship          citizenship
015A     19       25    JPN_Race                 race
0173     0B       11    JPN_Religion             religion
017E     01        1    JPN_EastMalaysian        East Malaysian
017F     02        2    JPN_RJ                   RJ?
0181     02        2    JPN_KT                   KT?
0183     0B       11    JPN_OtherID              other ID
018E     01        1    JPN_Category             category
018F     01        1    JPN_CardVer              card version
0190     04        4    JPN_GreenCardExpiry      green card expiry date
0194     14       20    JPN_GreenCardNationality green card nationality
01A8     23       35                             All 00

jpn-1-2
0000     03        3                             01 40 03
0003    FA0     4000    JPN_Photo                JPEG photo
0FA3     08        8                             All 00

jpn-1-3
0000     03        3                             01 12 03
0003     14       20                             "R1L1",0,0...
0017    256      598    JPN_Thumb1               thumprint 1 (right thumb)
026D    256      598    JPN_Thumb2               thumprint 2 (left thumb)
04C3     08        8                             All 00

jpn-1-4
0000     03        3                             01 01 52
0003     1E       30    JPN_Address1             address line 1
0021     1E       30    JPN_Address2             address line 2
003F     1E       30    JPN_Address3             address line 3
005D     03        3    JPN_Postcode             postcode
0060     19       25    JPN_City                 city
0079     1E       30    JPN_State                state
0097     14       20                             FF 00 00...

jpn-1-5
0000     03        3                             01 12 00
0003     09        9    JPN_SocsoNum             socso number
000C     1F       31                             All 00

jpn-1-6
0000     03        3                             01 17 00
0003     0A       10    JPN_Locality             locality
000D     1E       30                             All 00

 

JPJ

jpj-1-1
Offset  Length  Length  SDK Function Name        Description
       (Hex)   (Dec)
0000     03        3                             01 04 16
0003     01        1    JPJ_OwnerCategory        owner category
0004     0C       12    JPJ_LicenseType          licence type
0010     1E       30    JPJ_VehicleClass         vehicle class
002E     06        6    JPJ_PSVUsage             PSV usage
0034     96      150    JPJ_PSVDesc              PSV description
00CA     06        6    JPJ_GDLUsage             GDL usage
00D0     96      150    JPJ_GDLDesc              GDL description
0166     20       32    JPJ_ValidityPeriod       validity period
0186     14       20    JPJ_HandicappedReg       handicapped registration
019A     01        1    JPJ_KejaraPoints         kejara points
019B     01        1    JPJ_SuspensionNum        suspension number
019C     04        4    JPJ_LastKejaraUpdate     last kejara update
01A0     0B       11                             All 00

 

IMM

imm-1-1
0000     03        3                             01 22 00
0003     0C       12    IMM_PMAPassportNum       PMA passport number
000F     03        3    IMM_PMADocType           PMA document type
0012     04        4    IMM_PMAExpiryDate        PMA expiry date
0016     15       21                             All 00

imm-1-2
0000     03        3                             01 22 00
0003     0C       12    IMM_PMTSporePassportNum  PMT S'pore passport no
000F     03        3    IMM_PMTSporeDocType      PMT S'pore doc type
0012     04        4    IMM_PMTSporeExpiryDate   PMT S'pore expiry date
0016     15       21                             All 00

imm-1-3
0000     03        3                             01 22 00
0003     0C       12    IMM_PMTBruneiPassportNum PMT Brunei passport no
000F     03        3    IMM_PMTBruneiDocType     PMT Brunei doc type
0012     04        4    IMM_PMTBruneiExpiryDate  PMT Brunei expiry date
0016     15       21                             All 00

imm-1-4
0000     03        3                             01 22 00
0003     0C       12    IMM_PMTResvPassportNum   PMT Resv passport no
000F     03        3    IMM_PMTResvDocType       PMT Resv doc type
0012     04        4    IMM_PMTResvExpiryDate    PMT Resv expiry date
0016     15       21                             All 00

 

Credit to xenon – forum.lowyat.net

How CentOS + LEMP + CodeIgniter ?

How to make your codeigniter framework project can be run in the LEMP server ?

OS – CentOS 7.0

What is LEMP?
Linux Operating System
ENginx web server
MySQL
PHP

I’ve created this server following Mitchell Anicas tutorial regarding installation of LEMP server in centos. So this one is the nginx config to make your codeigniter can be working.

server {
    listen       80;
    server_name  YOURIP/YOURDOMAIN;

    root   /var/www/html;
    autoindex on;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Where to apply this?
/etc/nginx/conf.d/default.conf

*Make sure you backup the original files.

Fixed name to dynamic IP with CNAME

Notice: this is not an advanced nor secret trickery. This is just something I’ve found even techsavvy people in my surrounding not having done so its worth being highlighted.

When I upgraded to fiber from ADSL, I had to give up my fixed IPv4 address that I’ve been using for around 10 years and switch to a dynamic DNS service .

Continue reading