Md. K. A. Nayeem

Team Leader (Software Engineer)

Dhaka, Bangladesh

Seeking for a challenging leadership position in an advanced IT company where I can utilize my strengths to contribute in a simulating environment to make business strategy.

My Social Profiles
  • profile
  • resume
  • Gallery
  • blog
  • contact

Profile - About Me

md. khurshed alam nayeem

Welcome to MD. K. A. NAYEEM's WORLD

Over the last 9 years, I have developed a wide range of web sites back-end development using Laravel 5.7, VueJS, CakePHP 3.6, CodeIgniter 3.1, Ionic 4, Magento 1.7, Wordpress, Joomla, Raw PHP, e-Commerce site, jQuery, Ajax, Ext JS, MySql, git, MacBook Pro, VPS, Ubuntu, DigitalOcean.

LAMP, MAMP environment

Web Administrator Programming Core Strenth
My Portfolio
Core Strenth
TheTutorsDirectory.com

TheTutorsDirectory.com is an online private tuition advertising and marketing service offering admittance to the greatest selection of home tutors and private tutors across the UK and USA locations. Read more...

Core Strenth
EASTERNSPICES.CO.UK

For over 20 years Eastern Spices has maintained its excellent reputation. Consistency means everything to our discerning clientele and on that criteria and more - Eastern Spices delivers!

Read more...

Core Strenth
RARAR.COM.BD

We are new in this arena but we assure you RARAR is one the most honest places to put your trust on. You will get quality products at reasonable prices in sha allah.

Read more...

Core Strenth
VIDEO.MOBI2FUN.COM

Video Streaming portal with VAS functionality. Which is live in Banglalink, Robi and Airtel operators.

Read more...

Core Strenth
MUSIC.MOBI2FUN.COM

Audio Streaming portal with VAS functionality. Which is live in Banglalink, Robi and Airtel operators.

Read more...

Resume - Personal Info

Development skills
Back-End Development
95%
Custom CMS
90%
POS
65%
Team Lead
95%
VAS
55%
Programming Skills
Laravel 5.7
95%
VueJS
95%
Ionic 4
95%
CakePHP
95%
CodeIgniter
90%
Woocommerce
65%
Ajax/ jQuery
95%
MySql
95%
Office Skills
Project Management
85%
MS Word
95%
Powerpoint
60%
Visio
90%
Hobbies Skills
Music
60%
Sport
95%
Reading
85%
Travelling
70%
Language Skills
English
100%
Hindi
80%
Bangla
100%
My Resume
Download My Resume
Experience
  • Sr. Software Engineer 2018 - Continue
    Axilweb Ltd.
  • Chief Web Developer 2016 - 2018
    NTV (International Television Channel Ltd.)
  • Sr. Software Engineer 2014 - 2015
    bGlobal Interactive Ltd.
  • Sr. Software Programmer 2011 - 2014
    Softworks Ltd.
  • Sr. Software Programmer 2009 - 2011
    G Microsystem Ltd.

Education
  • Master of Science in Computer Science (MSCS)

    2012 - 2014
    American International University-Bangladesh (AIUB)
  • B. Sc in Computer Science & Engineering

    2010 - 2011
    Stamford University Bangladesh

Professional Courses
  • PMP (Project Management Professional) 2017
    ibcs-primax

Research Activities in M. Sc. in Computer Science
  • “Amplifying Geo-Spatio-Temporal Data Visualization on Large Dataset ” 2014
    AIUB

    (Earth-Quake Spatio- Temporal Data analyzing, Timeline Navigation Band)


Gallery - My pictures

Coming soon...

Blog - My Blog


  @Author Md. Khurshed Alam Nayeem
Virtualmin Control Panel Setup in CentOS 6
SL No Description
1 cat /proc/version
2
yum install wget
3
wget http://software.virtualmin.com/gpl/scripts/install.sh
4
sh ./install.sh
5 yum provides */scp
6 yum -y install openssh-clients
Directory Size
SL No Description
1
du -ch | grep total
Cron Job in CentOS 6
SL No Description
1 crontab -l [to see the existing schedule list]
2 crontab -e [to edit with the existing schedule list]
3
*/5  *  *  *  *  /usr/bin/php -q /var/www/vhosts/icatalogbd.com/httpdocs/iCatalog/cron/isNewController.php
4
*/5  *  *  *  *  [Minute  Hour  Day of Month  Month  Day of Week]
5
*/5  *  *  *  *  /usr/bin/php -q /var/www/vhosts/icatalogbd.com/httpdocs/iCatalog/cron/isNewController.php > /dev/null 2>&1
[Remove email notification to the admin]
6 /etc/init.d/crond status
7 /etc/init.d/crond stop
8 /etc/init.d/crond start
Install MongoDB in CentOS 6 Using pecl
SL No Description
1 yum remove mongo-10gen mongo-10gen-server [removing previous mongoDB]
2 yum install gcc [install C compiler]
3 yum -y install gcc automake autoconf libtool make [install libtool make]
4 yum install php-devel [install package for phpize command]
5 pecl version [check pecl version]
6
PEAR Version: 1.9.4PHP Version: 5.3.3Zend Engine Version: 2.3.0Running on: Linux u15972483.onlinehome-server.com 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64
7
pecl install mongo
8 vi /etc/php.ini
9
extension=mongo.so
10
/etc/init.d/httpd status [Note: Check apache status]
11
/etc/init.d/httpd stop [Note: stop apache]
12
/etc/init.d/httpd start [Note: start apache]
Install MongoDB in Windows[Xampp/Wampp Server]
SL No Description
1 Downloads for win32 - MongoDB
2 Extract the archive to the directory as c:\mongodb
3 Create a file as mongodb.config to the directory c:\mongodb\bin [ie, c:\mongodb\bin\mongodb.config]
4 make sure you have data folder as c:\mongodb\data
5 Write a path in mongodb.config file as
dbpath=c:\mongodb\data
6 now write in your command promt(Start->Run->cmd) as
cd c:\mongodb\bin
mongod --config c:\mongodb\bin\mongodb.config
7 MongoDB is now connected. now you have to install php driver as follows
8 Download MongoDB dll file [Considering you are using PHP 5.2.9 or PHP 5.3.1]
9 Extract the zip file & place php_mongo.dll to the server derectory as "/xampp/php/ext"
10 configure the php.ini
extension=php_mongo.dll
11 Finally restart the apache
Install CouchDB in CentOS 6
SL No Description
1 [root@u15972483 ~]#
2 yum info couchdb
3 yum install couchdb
4 /etc/init.d/couchdb status
5 /etc/init.d/couchdb start
6 vi /etc/couchdb/local.ini
7 bind_address=your.ip.address
8 ZZ
:q for close without saving & ZZ for close with saving
9 /etc/init.d/couchdb stop
10 /etc/init.d/couchdb start
11 /etc/init.d/couchdb status
Install EPEL Repo in CentOS 6
SL No Description
1 [root@u15972483 ~]#
2 yum repolist
[(6,740)]
3 cd /tmp
4 wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
5 rpm -ivh epel-release-6-7.noarch.rpm
6 yum repolist
[(14,441)]
7 yum update
Re-Boot the Plesk Server
SL No Description
1 /etc/init.d/psa status
2 /etc/init.d/psa stop (Removing 500 Internal server error)
3 /etc/init.d/psa start
4 /etc/init.d/psa status
Install MongoDB in CentOS 6 Using yum
SL No Description
1 login as: root
2 root@74.208.79.80This email address is being protected from spambots. You need JavaScript enabled to view it. 's password:
3 Last login: Sat July 29 01:19:39 2012 from 203.83.172.78
4 [root@u15972483 ~]#
5 vi /etc/yum.repos.d/10gen.repo
6
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1
7 ZZ (exit vi , saving changes)
8
yum update
9
yum install mongo-10gen mongo-10gen-server
10
/etc/init.d/mongod status
11
/etc/init.d/mongod start
12
/etc/init.d/mongod status
Install APC in CentOS 6
SL No Description
1 login as: root
2 root@74.208.79.80This email address is being protected from spambots. You need JavaScript enabled to view it. 's password:
3 Last login: Sat Apr 28 01:19:39 2012 from 203.83.172.78
4 [root@u15972483 ~]#
5 yum -y install php-pecl-apc
6 vi /etc/php.d/apc.ini [Note: http://www.server-world.info/en/note?os=CentOS_6&p=httpd&f=8]
7 I (insert text at beginning of current line, until hit) [Note: http://www.cs.colostate.edu/helpdocs/vi.html]
8 I (insert text at beginning of current line, until hit) [Note: http://www.cs.colostate.edu/helpdocs/vi.html]
9 :wq (quit vi, writing out modified file to file named in original invocation)
10 /etc/init.d/httpd status [Note: Check apache status]
11 /etc/init.d/httpd restart [Note: restart apache]
12 /etc/init.d/httpd status [Note: Check apache status]
13 [root@www ~]# mkdir /var/www/html/apc
14 cp /usr/share/doc/php-pecl-apc-*/apc.php /var/www/vhosts/softworksbd.com/httpdocs/apc
Install APC in Windows[Xampp/Wampp Server]
SL No Description
1 Download APC dll file [Considering you are using or PHP 5.3.1]
2 Extract the zip file & place php_apc.dll to the server derectory as "/xampp/php/ext"
3 configure the php.ini
extension=php_apc.dll
4 Finally restart the apache
Configure Memcached Server?
SL No Description
1 login as: root
2 root@74.208.79.80This email address is being protected from spambots. You need JavaScript enabled to view it. 's password:
3 Last login: Sat Apr 28 01:19:39 2012 from 203.83.172.78
4 [root@u15972483 ~]#
5 vi /etc/sysconfig/memcached
Install memcached in Centos 6
SL No Description
1 login as: root
2 root@74.208.44.241This email address is being protected from spambots. You need JavaScript enabled to view it. 's password:
3 yum install memcached.x86_64 php-pecl-memcache.x86_64
4 # vi /etc/sysconfig/memcached
5 # /etc/init.d/memcached start
6 # /etc/init.d/memcached stop
7 # /etc/init.d/memcached restart
8 # /etc/init.d/memcached status
Install Memcache in Windows[Xampp/Wampp Server]
SL No Description
1 Download Memcache dll file [Considering you are using PHP 5.3.1]
2 Extract the zip file & place php_memcache.dll to the server derectory as "/xampp/php/ext"
3 configure the php.ini
extension=php_memcache.dll
4 Finally restart the apache
Dumping & Restoring Database into Server
SL No Description
1 login as: root
2 root@74.208.44.241This email address is being protected from spambots. You need JavaScript enabled to view it. 's password:
3 Last login: Fri Feb 10 03:35:37 2012 from 103.10.78.153
4 [root@u15980126 ~]# mysqldump -u lmisdemo -pmlcgjnwc9a sciplmisdb > /var/www/vhosts/scipdemo.com/httpdocs/sciplmisdb.sql
5 [root@u15980126 ~]# mysql -u lmisdemo -pmlcgjnwc9a sciplmisdb < /var/www/vhosts/scipdemo.com/httpdocs/sciplmisdb.sql
Copy zip file Centos 6 server to other Linux server
SL No Description
1 # scp /var/www/vhosts/softworksbd.com/httpdocs/rockmongo.zip root@74.208.44.241This email address is being protected from spambots. You need JavaScript enabled to view it. :/var/www/vhosts/mohfwscmp.org/httpdocs/
2 root@74.208.44.241This email address is being protected from spambots. You need JavaScript enabled to view it. 's password:
3
rockmongo.zip                                 100%  389KB 389.0KB/s   00:00
Local Joomla Site Upload to Server
SL No Description
1 Make sure you have installed com_akeeba-3.3.8-core.zip components into your local joomla site[using Extension Manager]
2 After installed, set akeeba configuration as follows, destination the backup files, backup file format as zip
3 Start Backup now. [Akeeba will backup your full local site+joomla database] (note: if you have some other database, you have to import into server differently)
4 After backup completion, you may find your zip file into the following directory :/local joomla administrator/components/com_akeeba/backup/yourbackup.zip
5 Make sure you have pscp.exe (example: C:\Program Files\ExtraPutty 0.22\Bin\pscp.exe)
6 Start=>Run=>cmd=>enter=>cd C:\Program Files\ExtraPutty 0.22\Bin(Enter)
7 pscp.exe(Enter)
8 Assume that my akeba backup file located as E:\yourbackup.zip because I changed my current location of my backup zip file
9 pscp E:\yourbackup.zip root@74.208.79.80This email address is being protected from spambots. You need JavaScript enabled to view it. :/var/www/vhosts/softworksbd.com/httpdocs/szlmis [Assume for softworksbd.com]
10 Now, go to plesk panel as httpdocs/szlmis, choose yourbackup.zip and Extract file
11 Make sure you have putty.exe open the server as SSH mode using User: root password: initial password
12 Now, you have to set some chmod for your server site,
13 [root@u15972483 ~]# cd /var/www/vhosts/softworksbd.com/httpdocs/ szlmis
14 [root@u15972483 szlmis]# chmod 0777 configuration.php
15 [root@u15972483 szlmis]# chmod 0777 installation
16 Then http://softworksbd.com/szlmis from your browser then enter
17 Setup the installation
18 Done
Partition CentOS 6 Server
SL No Description
1
df -h
[to check the partition and logical volume sizes of the mounted space ]
2
fdisk -l
[to check the logical space of the total partitions]
3
pvs
[to check the actual physical space remaining]
4
lvextend -L +50G /dev/mapper/vg00-var
[to extend the partition for var]
5
mount
6
resize2fs /dev/mapper/vg00-var
[resize the partition]
7
df -h
Some Important command for CentOS 6 Server
SL No Description
1
unzip demo.zip
[unzip any file into current directory]
2
mv * ../
[move all files to previous directory]
3
scp root@sourcehost:/var/www/vhosts/demo1.com/demo.zip /var/www/vhosts/demo2.org/httpdocs
[move all files to previous directory]


© 2012-13 Md. Khurshed Alam Nayeem


  @Author Md. Khurshed Alam Nayeem
Linux Commands
Command Name Description Example
File/Directory
ls List files ls -l
ls -alrt *.html
ls -al formatted listing with hidden files ls -al file.htm
cp Copy files cp sourcefile destinationfile
cp -r Copy directory, create destination directory if it doesn't exist cp -r sourcedir destinationdir
cp -r file* subdir/
mv Move/rename files mv sourcefile destination file
mv file* ubdir/
rm Remove/delete files rm filename
rm -r Remove/delete directory rm -r directory
rm -f Force to remove file rm -f *.aux
rm -rf Force to remove directory rm -rf subdir/
ln Link files ln
ln -s Create symbolic link to file ln -s file link
cd Change Directory to home cd
cd dir Change directory to directory cd ~/2350/hw cd bin
pwd show Present Working Directory pwd
mkdir Make new Directory mkdir 2005fall
rmdir Remove/delete Directory rmdir 1995fall
touch create or update file touch file.txt
File Viewing
cat Display text contents cat file1.txt file2.txt file3.txt
less page through files less
head output first few lines of file head -5 file.txt
tail output last few lines of file tail -5 file.txt
tail -f output the contents of files as it grows, starting with last 10 lines tail -f filename
nl Number Lines nl
od view binary data od
xxd view binary data xxd
gv view postscript/pdf files gv
xdvi view TeX DVI files xdvi
more output the contents of the file more filename
echo Print to screen echo "This is output"
strings Text embedded in binary strings a.out
File Creation and Edition
emacs Text editor emacs file.tex
vim Text editor vim file.tex
vi Text editor vi file.txt
nedit Text editor nedit file.txt
pico Text editor pico file.txt
latex Compiles DVI documents
pdflatex Compiles PDF documents
umask set default file protections umask
soffice edit word/excel/powerpoint docs soffice
abiword edit word documents abiword
gnumeric edit excel documents gnumeric
File Properties
stat Display file attribute stat
wc Word Count - count bytes/words/lines wc file.txt
file identify File Types file *
touch Change file timestamps touch
File Permission
chown Change file Owner chown
chgrp Change group ownership chgrp appm2350 index.htm
chmod OwnerGroupWorld Change file permissions (4-read, 2-write, 1-execute) chmod 754 file.htm (rwx for Owner, rx for Group and r for
chattr Change advanced file Attributes chattr
lsattr List advanced file Attributes lsattr
File Location
find locate files find
locate find all instances of filename locate filename
slocate locate files via index slocate
which show which application or file will be run by default which application/filename
whereis show possible locations of apps/files whereis application/filename
grep pattern search for 'pattern' in files grep pattern files
grep -r pattern search recursively for pattern in dir grep -r pattern dir
command | grep pattern search for pattern in the output of command
System Information
date show the current date and time date
cal show this month's calendar cal 12 2005
uptime show current uptime
w display who is online w
uname -a show kernel information
cat /proc/cpuinfo show cpu information
cat /proc/meminfo show memory infomation
man show manual for command man ls man -k editor
free show memory and swap usage free
File/Text Manipulation
grep Find word/string grep keyword file1 file2 file3
cut extract columns cut
paste append columns paste
tr Translate characters tr
sort Sort lines sort -r -n file.txt
uniq locate identical lines uniq
tee copy stdin to a file and to stdout simultaneously tee
File Compression and Compilers
gzip compress GNU files & rename it gzip file.tar (new name file.gz)
gzip -d decompress file.gz back to file gzip -d file.gz
gunzip Uncompres files gunzip file.tar.gz
compress Compress Unix files compress
bzip2 compress BZip2 files bzip2
zip compress Windows files zip
tar cf Creates a tar named file.tar contains files tar cf file.tar file1 file2 file3 file4
tar xf Extract the files from file.tar tar xf file.tar
tar czf Create a tar with Gzip compression tar czf file.tar.gz files
tar xzf Extract a tar using Gzip tar xzf file.tar.gz
tar cjf Create a tar with Bzip2 compression tar cjffile.tar.bz2
tar xjf Extract a tar using Bzip2 tar xjffile.tar.bz2
cc c++ gcc g++ C and C++ compilers cc -o myprogramprogA.c
f77 f90 f95 Fortran compilers f90 -o myprogram progA.f90
File Comparision
diff compare files line by line diff file1.txt file2.txt
comm Compare sorted files comm
cmp Compare files byte by byte cmp
md5sum compute checksums md5sum
Disks and File Systems
df show Disk Free space df
mount make disk accessible mount
fsck Check a disk for errors fsck
sync flush disk caches sync
du measure Disk Usage du -k
Backup and Remote Storage
mt Control a tape drive mt
dump back up a disk dump
restore Restore a dump restore
tar read/write Tape Archives tar
cdrecord burn a CD cdrecord
rsync mirror a set of files rsync
Printing
lpr Print files lpr
lpq view Print Queue lpq
lprm Remove Print jobs lprm
Spelling Operations
look Look up spelling lookstri
aspell check Spelling interactively aspell
spell Find misspelled words spell file.txt
Process Management
ps list all Processes ps -ef
w list user’s processes w
uptime view the system load uptime
top display/monitor running processes top
xload monitor system Load xload
free display Free memory free
kill Terminate processes killpid (pid=process id/no.)
kill all Kill All process by same name kill all ProcessName
nice set process priorities nice ./a.out
renice Change process priorities renice
bg lists stopped or Background jobs
fg brings the most recent job to foregrond fg n (n=job name/no.)
jobs In current shell jobs
Job Scheduling
sleep wait for some time sleep
watch run programs at set intervals watch
at schedule a job at
crontab schedule repeated jobs crontab
adduser Adds a new user to the system adduser username
Hosts/Users
uname print system information uname
hostname print the system’s Hostname hostname
whoami Who you are logged in as whoami
finger Display information about user finger username
passwd Change password passwd
w who whoami User identities w who whoami
Networking
ifconfig set/display network information ifconfig
host look up DNS host
whois look up domain registrants whois domainname
dig get DNS information dig domainname
Reverse lookup host dig -x hostname
ping Check if host is reachable ping hostname
traceroute view network path to a host traceroute
ssh Securely log into remote hosts ssh user@host.comThis email address is being protected from spambots. You need JavaScript enabled to view it.
Connect to host on 'port' as user ssh -p port user@host.comThis email address is being protected from spambots. You need JavaScript enabled to view it.
Add your key to host for user to enable a keyed/passwordless login ssh -copy -iduser@host.comThis email address is being protected from spambots. You need JavaScript enabled to view it.
ssh ssa.ccny.cuny.edu -l username
telnet log into remote hosts telnet
scp Securely Copy files between hosts scp myfile ssa.ccny.cuny.edu:subdir/file8
sftp Securely copy files between hosts sftp
ftp copy files between hosts ftp
evolution GUI email client evolution
mutt text based email client mutt
mail minimal email client mail
mozilla web browser mozilla
lynx text only web browser lynx
wget retrieve/download web pages/files wget filename
Continue a stopped download wget -c filename
slrn read Usenet news slrn
gaim instant messaging/IRC gaim
talk Linux/Unix chat talk
write send messages to terminal write
mesg prohibit talk/write mesg
pine Email pine
mailx Email mailx abc@def.comThis email address is being protected from spambots. You need JavaScript enabled to view it.
Audio/Video
grip play CDs and Rip MP3s grip
xmms play audio files xmms
cdparanoia rip audios cdparanoia
audacity edit audios audacity
xcdroast burn CDs xcdroast
Installation
./configure ./configure
make install Install from source
dpkg -i Install a package (Debian) dpkg -i pkg.deb
rpm -Uvh Install a package (RPM) rpm -Uvhpkg.rpm
Shortcuts
Ctrl+C halts the current command
Ctrl+Z stops the current command, resume with fgin the foreground or bg in the background.
Ctrl+D log out of current session, similar to exit
Ctrl+W erases one word in the current line
Ctrl+U erases the whole line
Ctrl+R brings up a recent command
exit log out of current session
!! repeats the last command
alias Allows you to substitute a new name for a command alias help=man, alias long=ls -al
alias dir '/bin/ls -al \!* | more;'
& Run in background nice ./a.out&
> Redirect to file nice ./a.out>results.out&
>> Append to file nice ./a.out>>more.out&
< Input from file nice ./a.out< input.dat >results.out&
| Pipe to another program cat *.dat| more
; Separates commands ./a.out< input1.dat ; /a.out< input2.dat ; ls
$ Define variable set echco $variablename
* ? Wildcard characters ls *.tex ; lsa* ; ls *.???; lsfile?.txt
!! $! Last command, last word echo "!!"
~/.cshrc Initialization file Define shell variables and aliases
~/.login Initialization file Set 1-time login information
~/.ssh/known_hosts ssh keys file Keys accepted from other hosts; sometimes needs editing.


© 2012 Md. Khurshed Alam Nayeem


  @Author Md. Khurshed Alam Nayeem
Memcached Working with PHP
Description
<?php

/*=======connect Memcache===============*/ 
 
        $m = new Memcache;     
 
  $m->connect('localhost', 11211) or die ("Could not connect"); 
 
  $expires = 60*60*24*30; // seconds, minutes, hours, days 
 
     
 
  $data[] = (object) array('UnitId'=>'1', 'UnitName'=>'pic'); 
 
  $data[] = (object) array('UnitId'=>'2', 'UnitName'=>'bundle'); 
 
  $arr['rows']=$data; 
 
   
 
  $str=json_encode($arr);  
 
   
 
  /*=======Memcache Object Ready=========*/ 
 
  //echo $str; 
 
  $obj = new stdClass;   
 
  $obj->str = $str; 
 
       
 
  /*=======Set Memcache Obj==============*/ 
 
  $m->set('key', $obj, false, $expires );     
 
   
 
  /*=======Delete Memcache Obj===========*/ 
 
  //$m->delete('key');             
 
   
 
  /*=======Fetch Memcache Obj============*/ 
 
  $get_result = $m->get('key');         
 
   
 
  /*=======Print Memcache JSON obj=======*/ 
 
  echo $get_result->str;     
 
    
?>
List of all Column in a MySql Table
Description
<?php

  $host_name='localhost'; 
 
  $db_name="dgfplmis_db"; 
 
  $UserID="root"; 
 
  $Password=""; 
 
 
 
  $connection=mysql_connect($host_name,$UserID,$Password) or die("Could not connect to server"); 
 
  $db=mysql_select_db($db_name,$connection) or die("Could not select database"); 
 
   
 
  $sql="SHOW COLUMNS FROM `2012_f7_tab` "; 
 
   
 
  $result=mysql_query($sql,$connection); 
 
   
 
  while($row=mysql_fetch_assoc($result)){     
 
    $arr[]=$row['Field']; 
 
    //print_r($row); 
 
  } 
 
  echo json_encode($arr); 
 
    
?>
List of All Files in a Directory
Description
<?php

//path to directory to scan 
 
$directory = "images/project1/620x378/"; 
 
  
 
//get all image files with a .jpg extension. 
 
$images = glob($directory . "*.jpg"); 
 
  
 
//print each file name 
 
foreach($images as $image) 
 
{ 
 
echo $image; 
 
} 
 
    
?>
XML Generation
Description
<?php

header("Content-type: text/xml");
$str= "<?xml version='1.0' encoding='ISO-8859-1'?>";
$str.= "<note>";
$str.= "<from>Nayeem</from>";
$str.= "<to>Fariha</to>";
$str.= "<message>Remember me this weekend</message>";
$str.= "</note>";

echo $str;

?>
PHP E-mail Sending
Description
<?php
$to .= ' csenayeem025@gmail.comThis email address is being protected from spambots. You need JavaScript enabled to view it. ';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html> <head> <title>Birthday Reminders for August </head>
<body> <p>Here are the birthdays upcoming in August!</p> <table> <tr> <th>Person</th><th>Day</th><th>Month</th><th>Year</th> </tr> <tr> <td>Joe</td><td>3rd</td><td>August</td><td>1970</td> </tr> </table>
</body> </html> ';

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary < mary@example.comThis email address is being protected from spambots. You need JavaScript enabled to view it. >, Kelly < kelly@example.comThis email address is being protected from spambots. You need JavaScript enabled to view it. >' . "\r\n";
$headers .= 'From: Birthday Reminder < birthday@example.comThis email address is being protected from spambots. You need JavaScript enabled to view it. >' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.comThis email address is being protected from spambots. You need JavaScript enabled to view it. ' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.comThis email address is being protected from spambots. You need JavaScript enabled to view it. ' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?> \n This email address is being protected from spambots. You need JavaScript enabled to view it. > \n This email address is being protected from spambots. You need JavaScript enabled to view it. > \n This email address is being protected from spambots. You need JavaScript enabled to view it. >
MySql Connection
Description
<?php
    require("define.inc");

    $conn=mysql_connect(HOSTNAME, DBUSER, DBPWD) or die('Could not connect: ' . mysql_error());
    mysql_select_db(DBNAME, $conn) or die('Could not connect: ' . mysql_error());

    $task='';
    if(isset($_POST['action'])){
        $task=$_POST['action'];
    }else if(isset($_GET['action'])){
        $task=$_GET['action'];
    }

   switch($task){
       case 'getElectionDays':
          getElectionDays($conn);
       break;
    default :
       echo "{failure:true}";
    break;
   }

?>

<?php
// "define.inc"
   define('HOSTNAME',"localhost");
   define('DBNAME',"dccelection");
   define('DBUSER',"dccelection");
   define('DBPWD', "mlcgjnwc9a");
?>
PHP Sub String
Description
<?php
$rest = substr("abcdef", 0, -1); // returns "abcde"
$rest = substr("abcdef", 2, -1); // returns "cde"
$rest = substr("abcdef", 4, -4); // returns false
$rest = substr("abcdef", -3, -1); // returns "de"
$rest = substr("abcdef", -2); // returns "ef"
$rest = substr("abcdef", -3, 1); // returns "d"
?>
PHP Date Formate
SL No Description
1 if(function_exists('date_default_timezone_set')) { date_default_timezone_set('Asia/Almaty'); } else{ putenv("TZ=Asia/Almaty"); }
2 $transactionDateLocal=date("Y-m-d H:i:s",time());
3 $transactionDateLocal=date("Y-m-d g:i:s a",time());
4 <?php

$date = "2012-05-19 13:00";

echo $stamp = strtotime($date) . "<br />"; // outputs 1337432400

echo date("Y-m-d g:i:s a",strtotime($date)); // outputs 2012-05-19 1:00:00 pm

?>
MySql Query
SL No Description
1 INSERT INTO table_name VALUES (value1, value2, value3);
2 UPDATE table_name SET column1=value, column2=value2 WHERE some_column=some_value
3 DELETE FROM table_name WHERE some_column = some_value
SQL FOREIGN KEY
SL No Description
1
ALTER TABLE t_orderitems 
 
ADD CONSTRAINT fk_UserId 
 
FOREIGN KEY (UserId) 
 
REFERENCES icat_users(id)
Primary KEY with two fields
SL No Description
1
ALTER TABLE sdp_product_mapADD CONSTRAINT ProductMap PRIMARY KEY (`SDPMapId`,`UpazilaCode`)
Remove a File/Directory
SL No Description
1
$filePath2=SITEDOCUMENT.'scode/assets/'.$LanguageId.'/svg/word_'.$GlyphId.'.svg'; 
    if (file_exists($filePath2)){       
      unlink($filePath2);       
    }
2
rrmdir(SITEDOCUMENT.'scode/assets/'.$LanguageId); 
    function rrmdir($dir) {  
  foreach(glob($dir . '/*') as $file) {  
    if(is_dir($file)) rrmdir($file); else unlink($file);  
  } rmdir($dir);  
}


© 2012-13 Md. Khurshed Alam Nayeem


  @Author Md. Khurshed Alam Nayeem
CakePHP Debug
SL No Description
 
// core.php 
Configure::write('debug', 0);    // 0=production state; 1,2=debug state 
    
CakePHP Routes
SL No Description
 
// routes.php 
Router::connect('/pricecomparison', array('controller' => 'priceComparison', 'action' => 'index')); 
Router::connect('/profile', array('plugin' => false, 'controller' => 'user_profiles','action' => 'index')); 
    
Controller
SL No Description
 
// controller 
 
App::uses('Folder', 'Utility'); 
App::uses('File', 'Utility'); 
 
class PriceComparisonController extends AppController{ 
    public $name = 'PriceComparison'; 
    public $helpers = array('Html', 'Form', 'Session'); 
    public $components = array('Session', 'CsvRead'); 
    public $uses = array('Product');         // models for plugin 'Communities.Community', 
     
    public function beforeFilter() { 
        parent::beforeFilter(); 
        // if an admin action has been called 
        if ($this->Session->check('Auth.User.id') == true) { 
            $this->Auth->allow('index'); 
        } 
    } 
     
    public function index() { 
        $this->paginate = array(             
            'limit' => 3, 
            'order' => array('Product.id' => 'asc') 
        ); 
         
        $products = $this->paginate('Product'); 
         
        $this->set('products', $products); 
    } 
} 
 
 
    
CakePHP Paginator
SL No Description
 
// paginator 
$this->Paginator->settings = array( 
            'Stock' => array( 
                'conditions' => array('Stock.product_id' => $id),                 
                'limit' => 3, 
                'order' => array('Stock.expired_date' => 'desc'), 
                'recursive' => 2 
            ) 
        ); 
        $lot_data = $this->Paginator->paginate('Stock'); 
    
CakePHP HTML render
SL No Description
 
// html render 
$this->autoRender = false;   
  $this->layout = 'ajax';         
        $filter['product_name']=$this->request->data['productname'];  
        $data=$this->CsvRead->getByProduct_InventorySalesbySite($this->request->data['productname'], TRUE); 
         
         
        $quantity= $this->retail_details($data, $this->request->data['sitename'], $filter); 
        echo  $this->_getViewObject()->element('Products/product_retail_detail', array('sitename'=>$this->request->data["sitename"], 'data'=>$data)); 
    
CakePHP Fetch data
SL No Description
 
// fetch data 
if (!$id) { 
            throw new NotFoundException(__('Invalid product')); 
        } 
        $single_product = $this->Product->findById($id); 
        if (!$single_product) { 
            throw new NotFoundException(__('Invalid product')); 
        } 
        $this->set('single_product', $single_product); 
    
CakePHP Save
SL No Description
 
// save 
public function add_lot($id=null) { 
        if (!$id) { 
            throw new NotFoundException(__('Invalid product')); 
        } 
        $single_product = $this->Product->findById($id); 
        if (!$single_product) { 
            throw new NotFoundException(__('Invalid product')); 
        } 
        $this->set('single_product', $single_product); 
        if ($this->request->is('post')) {             
            $this->Stock->create(); 
            if ($this->Stock->save($this->request->data)) { 
                $this->Session->setFlash(__('Your product Lot has been saved.')); 
                return $this->redirect(array('action' => 'lot/'.$id)); 
            } 
            $this->Session->setFlash(__('Unable to add your Lot information.'));             
        } 
        $o_data = $this->Outlet->find('all'); 
        $outlet_data = array(); 
        foreach ($o_data as $key => $_value): 
            $outlet_data[$_value['Outlet']['id']] = $_value['Outlet']['name']; 
        endforeach; 
        $this->set('outlet_data', $outlet_data); 
    } 
    
CakePHP Edit
SL No Description
 
// edit 
$single_product = $this->Product->findById($single_stock['Stock']['product_id']); 
        if (!$single_product) { 
            throw new NotFoundException(__('Invalid product')); 
        } 
        $this->set('single_product', $single_product); 
        if ($this->request->is(array('post', 'put'))) { 
 
            $this->Stock->id = $id; 
            if ($this->Stock->save($this->request->data)) { 
                $this->Session->setFlash(__('Your product Lot has been updated.')); 
                return $this->redirect(array('action' => 'lot/'.$single_stock['Stock']['product_id'])); 
            }             
 
            $this->Session->setFlash(__('Unable to update your product Lot.')); 
        } 
        if (!$this->request->data) { 
            $this->request->data = $single_stock; 
        } 
    
CakePHP Delete
SL No Description
 
// delete 
 if ($this->Stock->delete($id)) { 
            $this->Session->setFlash( 
                    __('The product Lot with id: %s has been deleted.', h($id)) 
            ); 
            return $this->redirect(array('action' => 'lot/'.$single_stock['Stock']['product_id'])); 
        } 
    
CakePHP Upload
SL No Description
 
// upload 
public function upload() { 
  $this->layout = 'ajax'; 
  //$this->beforeRender(); 
  $this->autoRender = false; 
  $targetFolder = realpath('files/products'); 
  if (!empty($_FILES)) { 
      $tempFile = $_FILES ['Filedata'] ['tmp_name']; 
      $targetPath = $targetFolder; 
      $filename = $_FILES ['Filedata'] ['name']; 
            $exploded = explode('.', $filename);  
            $ext = end($exploded); 
      //$ext = end(explode(".", $filename)); 
      $name = basename($filename, "." . $ext); 
      $time = strtotime(date('Y-m-d H:i:s')); 
      $targetFile = rtrim($targetFolder) . DS . $name . $time . '.' . $ext; 
            $targetFile=  str_replace(' ','_',$targetFile); 
      $logical_file = $name . $time . '.' . $ext; 
            $logical_file=  str_replace(' ','_',$logical_file); 
      move_uploaded_file($tempFile, $targetFile); 
            $supportedFileArray = array("jpg", "jpeg", "png", "gif", "bmp"); 
            $isSupport=in_array($ext, $supportedFileArray)?1:0;             
      return $logical_file . "*" . $filename . '*' . $ext .'*'.$isSupport; 
  } 
    }  
    
CakePHP paginator view
SL No Description
 
// paginator view 
<_php echo  $this->element('pagination'); ?>  
    
CakePHP Default Layout
SL No Description
 
// Route 
  <_script> 
        var baseUrl = '<_php echo Router::url('/', true); ?>'; 
        var webRoot = '<_php echo $this->webroot; ?>'; 
    <_script> 
    
CakePHP load script
SL No Description
 
// load script 
echo $this->Html->script('npo/npo', array('inline' => false)); 
    
CakePHP layout
SL No Description
 
// layout 
$this->layout = "backstage"; 
  $uId = $this->Session->read('Auth.User.id'); 
  if (empty($uId)) { 
      $this->layout = "default"; 
      $this->render('/Homes/404_page'); 
      return; 
  } 
    
CakePHP query
SL No Description
 
// query 
$user = $this->UserProfile->find('first', array('conditions' => array('UserProfile.user_id' => $npoInfo['NpoInfo']['user_id']), 
                        'joins' => array( 
                            array('table' => 'users', 
                                'alias' => 'AppUserNew', 
                                'type' => 'INNER', 
                                'conditions' => array( 
                                    'UserProfile.user_id = AppUserNew.id', 
                                    'AppUserNew.active' => 1 
                        ))) 
                    )); 
    
CakePHP Model
SL No Description
 
// model 
class Damage extends AppModel { 
    var $name = 'Damage'; 
    public $useTable = 'damages'; 
    public $belongsTo = array( 
        'Product' => array( 
            'className' => 'Product', 
            'foreignKey' => 'product_id', 
            'conditions' => array(), 
            'fields' => array(), 
            'order' => '' 
        ) 
    );    
    public $validate = array( 
        'product_id' => array( 
            'required' => true, 
            'rule' => 'notEmpty' 
        ),              
        'quantity' => array( 
            'required' => true, 
            'rule' => 'notEmpty' 
        ),        
        'sku' => array( 
            'required' => true, 
            'rule' => 'notEmpty' 
        ),        
        'remarks' => array( 
            'required' => true, 
            'rule' => 'notEmpty' 
        ),        
        'damage_date' => array(             
            'required' => true, 
            'rule' => 'notEmpty' 
        ), 
    ); 
} 
 
var $hasMany = array( 
        'NewsFeed' => array( 
            'className' => 'NewsFeed', 
            'foreignKey' => 'foreign_id', 
            'conditions' => array('NewsFeed.type' => self::type) 
        ) 
    ); 
     
    public function afterSave($created, $options = array()) { 
        $modelClassName = get_class($this); 
        $npoInfo = ClassRegistry::init('NpoInfo'); 
         
    } 
    public function beforeSave($options = array()) { 
  $modelClassName = get_class($this); 
   
    } 
 public $filterArgs = array( 
        //'username' => array('type' => 'like'), 
        'name' => array( 
            'type' => 'like', 
            'field' => array( 
                'Community.name', 
                'AppUser.first_name', 
                'UserProfile.organization' 
            ), 
            'conditions'=>array('AppUser.groupid'=>3) 
        ), 
        'search_type'=> array( 
            'type' => 'query', 
            'method' => 'findByType'             
        ), 
        'nameall'=> array( 
            'type' => 'query', 
            'method' => 'findBynameall'             
        ), 
        'nameexact'=> array( 
            'type' => 'query', 
            'method' => 'findBynameexact'             
        ), 
        'nameany'=> array( 
            'type' => 'query', 
            'method' => 'findBynameany'             
        ), 
        'namenoneof'=> array( 
            'type' => 'query', 
            'method' => 'findBynamenoneof'             
        ) 
    ); 
     
    public function findByType($data = array()) { 
        $condition = array(); 
         
        $search_type = $data['search_type'];  
         
        return $condition; 
    } 
     
    public function findBynameall($data = array()){ 
        $condition = array();         
        $nameall = (isset($data['nameall'])) ? $data['nameall'] : ""; 
        if(!empty($nameall)): 
            $condition = array( 
                'AND' => array( 
                    "Community.name Like"=> "%" . $nameall . "%" 
                ) 
            ); 
        endif;           
        return $condition; 
    } 
     
    public function findBynameexact($data = array()){ 
        $condition = array();                 
        $nameexact = (isset($data['nameexact'])) ? $data['nameexact'] : ""; 
        if(!empty($nameexact)): 
            $condition = array( 
                'AND' => array( 
                    "Community.name "=> $nameexact  
                ) 
            ); 
        endif;           
        return $condition; 
    } 
     
    public function findBynameany($data = array()){ 
        $condition = array();                 
        $nameany = (isset($data['nameany'])) ? $data['nameany'] : ""; 
        if(!empty($nameany)): 
            $condition = array( 
                'AND' => array( 
                    "Community.name REGEXP  "=> "[[:<:]]".$nameany."[[:>:]]" 
                ) 
            ); 
        endif;           
        return $condition; 
    } 
     
    public function findBynamenoneof($data = array()){ 
        $condition = array();         
        $namenoneof = (isset($data['namenoneof'])) ? $data['namenoneof'] : ""; 
        if(!empty($namenoneof)): 
            $condition = array( 
                'AND' => array( 
                    "Community.name NOT REGEXP  "=> "[[:<:]]".$namenoneof."[[:>:]]" 
                ) 
            ); 
        endif;           
        return $condition; 
    } 
    
CakePHP Inner Controller
SL No Description
 
$pageData=$this->totalLandedCost($data, $filter);   
 
 
public function getProductInfo(){ 
        $this->autoRender = false;   
        $this->layout = 'ajax';   
        //echo 1; 
    } 
 
$this->set('dataRetail', $dataRetail);     
$fred = 'Fred Flinstone'; 
$barney = 'Barney Rubble'; 
$names = compact('fred', 'barney'); 
$this->set(compact('variable_to_pass')); 
    
CakePHP Redirect
SL No Description
 
// redirect 
return $this->redirect(array('action' => 'index')); 
 
// request 
if (!$this->request->data) { 
            $this->request->data = $product; 
        } 
    
CakePHP Form
SL No Description
 
// form 
<_php echo $this->Form->create('UserProfile', array('id' => 'profile_id')); ?> 
 
echo $this->Form->input('user_id', array('type' => 'hidden', 'class' => '', 'label' => false, 'div' => false)); 
                    echo $this->Form->input('public_id', array('type' => 'hidden', 'value'=>$public_id)); 
 
$_cuntry = ($user['UserProfile']['country']) ? $user['UserProfile']['country'] : "US"; 
        $cuntryText = 'Select Country'; 
        $attributes = array('empty' => $cuntryText, 'value' => $_cuntry, 'class' => 'selectpicker validate[required]', 'data-size' => 7); 
        $countrylist = array('US' => 'United States'); 
        echo $this->Form->select('country', $countrylist, $attributes); 
 
 
 <_php echo $this->Form->input('outlet_id', array('options'=>$outlet_data, 'label'=>'Outlet:','class'=>'form-control','id'=>'outlet_id','type'=>'select')); ?> 
 
<_php $options = array('label' => 'Save', 'class' => 'submit btn btn-info', 'div' => false); 
         echo $this->Form->end($options);                
   ?> 
 
<_php $options = array('label' => 'Save', 'class' => 'submit btn btn-info', 'div' => false); 
         echo $this->Form->end($options);                
   ?> 
 
echo $this->Html->link(__('Total Retail sales'), array('controller' => 'products', 'action' => 'retail_sales',  $single_product['Product']['sku']), array('class'=>'lrg-btn checkPatron')) ;  
 
$this->response->download("export.csv"); 
    
CakePHP Component
SL No Description
 
// component 
 
App::uses('Component', 'Controller'); 
class CsvReadComponent extends Component { 
    protected $_controller; 
    public $model; 
 
    public function __construct(ComponentCollection $collection, $csv = array()) { 
        parent::__construct($collection, $csv = array()); 
    } 
    public function readCsv($name = NULL){ 
  } 
} 
    
CakePHP ClassRegistry
SL No Description
 
 ClassRegistry::init('UserProfile'); 
    
© 2015 Md. Khurshed Alam Nayeem


  @Author Md. Khurshed Alam Nayeem
MongoDB API Working with PHP
Description
<?php

// Getting connection to MongoDB 
 
     
 
$connection = new Mongo(); 
 
$database   = $connection->selectDB('auditlog'); 
 
$collection = $database->selectCollection('t_audit_log'); 
 
 
 
// insert to MongoDB 
 
 
 
$article = array( 
 
        'UserName' => 'nayeem',  
 
        'UserEmail' => '
 csenayeem025@gmail.comThis email address is being protected from spambots. You need JavaScript enabled to view it.
 ', 
 
        'TableName' => $tableName,  
 
        'FieldName' => $fieldName,  
 
        'OldValue' => $oldValue,  
 
        'NewValue' => $newValue, 
 
        'TransactionDate' => $dateTime, 
 
        'Action' => $type 
 
        ); 
 
 
 
$collection->insert($article); 
 
   
 
// Fetch collection from MongoDB 
 
 
 
$preg = new MongoRegex("/^$query/i"); 
 
$find = $collection->find(array('UserName' => $UserName, "Action" => $preg)); 
 
    
?>
CouchDB API Working with PHP
Description
<?php

$couch_dsn = "http://localhost:5984/"; 
 
$couch_db = "auditlog"; 
 
 
 
require_once "lib/couch.php"; 
 
require_once "lib/couchClient.php"; 
 
require_once "lib/couchDocument.php"; 
 
 
 
// Getting connection to CouchDB 
 
 
 
$client = new couchClient($couch_dsn,$couch_db); 
 
 
 
// Fetch CouchDB using PHP 
 
 
 
try { 
 
  $doc = $client->getDoc('e8c945971967fd1944567e9906000b7e'); 
 
} catch (Exception $e) { 
 
  if ( $e->code() == 404 ) { 
 
    echo "Document not found\n"; 
 
  } else { 
 
    echo "Error: ".$e->getMessage()." (errcode=".$e->getCode().")\n"; 
 
  } 
 
  exit(1); 
 
} 
 
 
 
// Insertion in CouchDB through PHP 
 
 
 
$song = new stdClass(); 
 
/*$song->_id = "in_the_meantime";*/ 
 
$song->DateTime = "In the Meantime"; 
 
$song->UserId = "TU-21"; 
 
$song->TableName = "Space Hog"; 
 
$song->FieldName = "Alternative"; 
 
$song->OldValue = 1995; 
 
$song->NewValue = 1995; 
 
 
 
try { 
 
  $response = $client->storeDoc($song); 
 
} catch (Exception $e) { 
 
  echo "Error: ".$e->getMessage()." (errcode=".$e->getCode().")\n"; 
 
  exit(1); 
 
} 
 
print_r($response); 
 
    
?>


© 2012 Md. Khurshed Alam Nayeem


  @Author Md. Khurshed Alam Nayeem


OOP(Object Oriented Programming)
SL No Description
Features of OOP(Object Oriented Programming)
Encapsulation, Inheritance, Polymorphism
Encapsulation:
* It links code and data together
* It is achieved through object that contains same data and the functions to manipulate them
* It provides certin level of security to the data
* It provides information hiding
Inheritance:
* It supports reuseability
* It is a mechanism where use an existing object with a new object that has some unique characteristics
* It reduces complexity by using existing errorfree objects.
* Using inheritance we can create a general class that defines common properties. This class may be then inherited by other more specific classes each adding only those things that unique to the inheriting class
* A class that is inherited is known as base class
* A class that does inheriting is known as derived class
Polymorphysm:
* It is a mechanism that allows one interface to be used implement a number of task
* The specific action is detaermine by exact nature of the situation by the compiler
* There are two types of polymorphism occur
a) compile time polymorphism- types of arguments
b) run time polymorphism- same function can be execute
* classes have different functionality while sharing a common interface.
Class:
* It is the basic unit of Encapsulation
* It is a user defined data type that contains some data and function needed to manipulate the data
* Class is used to declare objects at that class
Object:
* It is variable of type class
* Class has no plysical existance but object has physical existance
* It is an instance of a class
Access Specifiers:
* Private- Local variable
* Public- Global variable
* Protected
Private:
* All the public and protected member of base become the private member of derived
* By default access is private
* Private cannot inherit without private and protected
Public:
* All the public member of base become public member of derived and all the protected member of base become protected member of derived
Protected:
* All the public and protected member of base become protected member of derived
Static Data member:
* A data member can be made a static member by adding the keyword static before variable declaration
* It is initialized to zero when first object is created
* Only one copy of the static data member exists and it is shared all the common objects of the same class
* It is used to maintain common data within the entire class
* We have to provide a global defination for the static data member outside the class
* A static data member exists before any object at its class is created
* Private members doesnot access
static int i;
Constructor:
* It is a special member function of a class where task is to initialize the objects of a class
* It is called automatically when an object of a class is created
- They have the same name as the class
- They donot have any return type not even void
- They should be declared in the public section
* In java initialize=0 and in C++ garvage
Default Construction:
* A constructor that doesnot accept any parameter is called default constructor
Parameterized Construction:
* By calling the constructor explicitly
* By calling the constructor implecitly
Destructor:
* Special type of member function whose tsk is to destroy the objects
* never takes any arguments and never returns any value
* Called automatically by the compiler
Difference between function overloading and function overriding:
* In function overloading the over loaded function should differ in the type or the number of parameters
* In function overridings the base class contain the virtual function and the derived classes redefined the same function till the function have same prototype
* A class containing virtual function is know as polymorphic class
Abstruct Class:
* Abstract classes are classes that contain one or more abstract methods
* An abstract method is a method that is declared, but contains no implementation
* Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods
- Abstruction: a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency
Interface:
* It is a collection of abstract methods
* It allows the computer to enforce certain properties on an object (class).
* A class implements an interface, thereby inheriting the abstract methods of the interface
* Along with abstract methods, an interface may also contain constants, default methods, static methods, and nested types.
MVC(Model, View & Controller)
SL No Description
Model:
* The model defines the rules for the process an application
* Responsible for both the application data and its behaviour
View:
* The view is responsible for formating the data returned by the model and presenting it to the user.
Controller:
* Responsible for determining how the application should respond based on events occuring typically user actions
PHP(Hypertext Preprocessor) and MySQL
SL No Description
Current PHP version: 7.2 but for server 5.6.30
* include(); (if not found) generated a warning, script will continue to execution
* require(); (if missing) generate a fatal error and script will stop
* These two function are used to create functions, header and footers or elements that will be reused on multiple pages
COOKIE: A cookie is a small file that server embeds on the users computer.
setcookie("user","Nayeem",time+3600);
SESSION: A session variable hold information about one single user in one application
unlink — Deletes a file, image, pdf etc
unlink — Deletes a file, image, pdf etc
PDO (PHP Data Object)
 
try{ 
$db = new PDO("dbtype:host=yourhost;dbname=yourdbname;charset=utf8","username","password"); 
$myinsecuredata=$_GET["id"]; 
$query=$db->prepare("Select * from table where id=?"); 
$query->excute(array($myinsecuredata)); 
}catch(PDOException  $e ){ 
echo "Error: ".$e; 
} 
$servername = "mysql.hostinger.com"; 
$database = "u266072517_name"; 
$username = "u266072517_user"; 
$password = "buystuffpwd"; 
 
// Create connection 
 
$conn = mysqli_connect($servername, $username, $password, $database); 
 
// Check connection 
 
if (!$conn) { 
 
    die("Connection failed: " . mysqli_connect_error()); 
 
} 
echo "Connected successfully"; 
mysqli_close($conn);
The mysqli extension has a number of benefits, the key enhancements over the mysql extension being:
-Prepared statements.
-Object oriented interface.
-Support for multiple statements.
-Embedded server support.
ORM framework:
Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language. There are both free and commercial packages available that perform object-relational mapping, although some programmers opt to create their own ORM tools
* CakePHP’s built-in ORM specializes in relational databases
SQL Injection (SQLi) refers to an injection attack wherein an attacker can execute malicious SQL statements (also commonly referred to as a malicious payload) that control a web application's database server
* SQL injection is a code injection technique, used to attack data-driven applications, in which nefarious SQL statements are inserted into an entry field for execution
* An SQL injection is a computer attack in which malicious code is embedded in a poorly-designed application and then passed to the backend database. The malicious data then produces database query results or actions that should never have been executed.
* A hacker might get access to user names and passwords in a database by simply inserting " OR ""=" into the user name or password text box: " or ""="
SELECT * FROM Users WHERE Name ="" or ""="" AND Pass ="" or ""=""
Option 1: Use of Prepared Statements (with Parameterized Queries)
Option 2: Use of Stored Procedures
Option 3: White List Input Validation
Option 4: Escaping All User Supplied Input
UNION removes duplicate records (where all columns in the results are the same), UNION ALL does not.
* npm , short for Node Package Manager, is two things: first and foremost, it is an online repository for the publishing of open-source Node.js projects; second, it is a command-line utility for interacting with said repository that aids in package
* npm is the package manager for JavaScript. It's also the world's largest software registry.
* The $_SERVER["PHP_SELF"] is a super global variable that returns the filename of the currently executing script.
* The htmlspecialchars() function converts special characters to HTML entities.
Design Patterns
SL No Description
Singleton Pattern:
* Ensure that only one instance of a class is created.
* Provide a global point of access to the object
Factory Method Pattern:
* Defines an interface for creating objects, but let subclasses to decide which class to instantiate
* Refers to the newly created object through a common interface
Observer Pattern:
* Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Git
SL No Description
 
          $git config --global user.name "John Doe" 
          $git config --global user.email 
 johndoe@example.comThis email address is being protected from spambots. You need JavaScript enabled to view it.
  
          $git add .    [$git add -A][all removals, additions, and modifications in the working tree] 
           
          $git checkout -b nayeem  //create brunch 
          $git checkout nayeem 
          $git branch nayeem 
          $git branch -a 
           
          $git commit -m 'fixed some code' 
          $git checkout master 
          $git merge nayeem 
          $git push origin master 
           
          ctrl+O-------ctrl+C----------ctrl+X 
           
          /*=========working in master=============*/ 
            $git stash  // save local copy 
            $git pull origin master 
            $git stash pop            // merge local & server 
            $git add . 
            $git commit -m 'initial project version' 
            $git push origin master 
            /*=========working in master=============*/ 
            $git remote -v 
            $git remote rm origin 
            $git remote add staging ssh://
 APKAJYOG3TA4S2ZTG67A@git-codecommit.us-east-1.amazonaws.comThis email address is being protected from spambots. You need JavaScript enabled to view it.
 /v1/repos/ntv_bn_web_staging 
            $git pull staging master 
            $git fetch staging master 
            $git push staging master 
          
tail -f /var/log/messages


© 2017 Md. Khurshed Alam Nayeem


	@Author Md. Khurshed Alam Nayeem



Odesk

Second Innings






First Innings








© 2012 Md. Khurshed Alam Nayeem



Contact - Contact Me

Contact info
  • Adress: Section-6, Mirpur, Dhaka

  • Email: csenayeem025@gmail.com
  • Phone: +88 01738 912894
  • Skype: nayeem.cse
Follow me
Let's keep in touch