Monday, 11 April 2016
'Paypal hacked!!' Avoid Getting Hacked | Protection against Keyloggers
Keylogger have also been popular, still are!
I don't know how many of you are aware of this but I'll go ahead and share it with you all. First things first, if you've been infected by a keylogger program your actions will be recorded, hacker usually receives the logs by email through a little SMTP or similar program that is usually setup in keylogger during the development process. In other words, typing your password into input password field will be recorded and stored into a file in usually 'appdata' or 'temp' folder. Which then is periodically sent to hacker's email address. Next thing you know your passwords have been changed and Paypal money transferred. Being infected and changing passwords won't do any good since keystrokes are will still be recoded.
One way to stay somewhat safe against this malicious act is to encrypt your keystrokes. Imaging your password is '123456789', if it's encrypted it will be completely converted to a encrypted characters, making hacker almost impossible to revert it. So when they get email with passwords, they will be unable to read it.
Here's an example of '123456789' text hashed using SHA-256.
15e2b0d3c33891ebb0f1ef609ec419420c20e320ce94c65fbc8c3312448eb225
I'm on Linux right now, but when I was on windows I used to use a program called https://www.qfxsoftware.com/
Those who're keen to test it out you can setup any keylogger on your own PC and and check the data whether it's readable.
Monday, 14 March 2016
How to become a web developer complete guide
You ask how do I become a web developer? Lets get straight to it, shall we? please don't be discourage if there's things you don't know or heard about.
Noob Level:
- HTML 5
- CSS 3
- Javascript
Learn just the basics. Should be able to create basics styling, make HMTL elements. Know few thing about Javascript like changing element ID using it or its color, know what a variable is etc.. Not much just a few things. Don't stress too much. This phase is about having fun! creating random stuff, show off to your buddies and going crazy!
Intermediate Level:
- HTML 5
- CSS 3
- Javascript/jQuery
- How internet works
- How servers work
- Setting up a domain and DNS
- Buying a Hosting
- FTP
- PHP
- DOM
Should be able to create simple websites. Validate user input, know how functions work, conditions, loops. Should also be able to connect to database and insert or retrieve data. Have good understanding of what a client side language can and can not do. Also understand what DOM Document object model is.. This phrase is about building foundation and have good understanding of technologies, don't necessarily need to be that good but good enough to look at a websites code and not be too afraid to mess around.
Expert Level(Front end developer):
- HTML 5(Expert)
- CSS 3(Expert)
- Javascript(Expert)
- How internet works(Must know)
- How servers work(Must know but don't waste your time too much on it)
- Setting up a domain and DNS(Must know)
- Buying a Hosting(Must know)
- FTP(Must know. You'll mainly using program like filezilla)
- PHP(Basics)
- DOM(Must know)
- JSON/XML(Don't stress too much)
- Git(Must know)
- Terminal/CLI(Don't stress too much but know a few thing)
- Photoshop(Expert)
- Wordpress(Good to know, should be able to design layouts)
- Atleast one front end framework, for example jQuery.(Must know)
- Bootstrap(Must know)
- At-least one open source editing program(Must know. Not every company will have budget for Photoshop)
- Sense of layouts/User Experience and colors(Expert)
- Graphics designing skills(Expert. Should be able to design stuff from scratch or take existing work and incorporate it into pre existing graphics)
This is for someone who wants to get into front end. This are the thing you'll be messing with everyday. This indeed is alot of stuff, but as far as it's fun to learn there should be no issue. Just keep grinding and working on new stuff. This phase is were you will get better at stuff you learn. For example, you won't be very good understanding XML/JSON code that server might throw at you, but you will eventually learn ways to make things easier for yourself.
Expert Level(Back end developer)
- AJAX(Be okay)
- How internet works(Solid understanding required)
- How servers work(Solid understanding required)
- How DNS work(Solid understanding required)
- Setting up a domain and DNS(Must know)
- Buying a Hosting(Must know
- Should be able to choose hosting dependong on your needs. See whether they will allow certain version of PHP, will enable modules. Data usage limits, uptime, support etc etc..)
- FTP(Must know using both GUI and CLI)
- OOP(Must know Object orignted programming - style of programming heavily used)
- Web application security(Be very good)
- PHP(Be very good)
- Atleast one backend framework(Be okay. For exmaple, Laravel, codeigniter etc..)
- SQL(Be good language itself and also using extensions like sql, sqli, pdo).
- API(Must know Application programming interface)
- Apache(Must know Should be able to install on fresh server and get necessary modules. Should also know how to use modules like mod_rewrite)
- Little bit of server administration, like changing permissions. Installing software necessary etc..(Be okay)
- HTML 5(Not as good as front end developer)
- CSS 3(Not as good as front end developer)
- Javascript/jQuery(Not as good as front end developer)
- How TCP/IP work(Be okay)
- Other server side language(Learn if required)
- Regex(Be okay. You will be using this alot when messing with apache modules)
- DOM(Be okay)
- JSON/XML(Be okay)
- Wordpress(Be okay)
- Git(Be okay)
- Understanding of HTTP(Be okay. Headers, requests responses)
- Terminal/CLI(Be okay)
- SSH(Be okay. Secure shell to access your server. Could use PuTTy too)
- Linux(Be okay. any one Distro)
- Photoshop(Be okay).
Expert doesn't mean you're done. You're still in process of learning and as you go you'll learn new stuff every day. At this stage you're just sharpening your skills.
Remember, web development is a very complex field and is an ongoing process. You're never too good. For example, you could learn how to build and fix PC and start your own business, however when it comes to website development it's big mixture of skills you need to be good at, just one thing doesn't cut it.
Last buy not least, always remember that people pay for solutions not skills.
Noob Level:
- HTML 5
- CSS 3
- Javascript
Learn just the basics. Should be able to create basics styling, make HMTL elements. Know few thing about Javascript like changing element ID using it or its color, know what a variable is etc.. Not much just a few things. Don't stress too much. This phase is about having fun! creating random stuff, show off to your buddies and going crazy!
Intermediate Level:
- HTML 5
- CSS 3
- Javascript/jQuery
- How internet works
- How servers work
- Setting up a domain and DNS
- Buying a Hosting
- FTP
- PHP
- DOM
Should be able to create simple websites. Validate user input, know how functions work, conditions, loops. Should also be able to connect to database and insert or retrieve data. Have good understanding of what a client side language can and can not do. Also understand what DOM Document object model is.. This phrase is about building foundation and have good understanding of technologies, don't necessarily need to be that good but good enough to look at a websites code and not be too afraid to mess around.
Expert Level(Front end developer):
- HTML 5(Expert)
- CSS 3(Expert)
- Javascript(Expert)
- How internet works(Must know)
- How servers work(Must know but don't waste your time too much on it)
- Setting up a domain and DNS(Must know)
- Buying a Hosting(Must know)
- FTP(Must know. You'll mainly using program like filezilla)
- PHP(Basics)
- DOM(Must know)
- JSON/XML(Don't stress too much)
- Git(Must know)
- Terminal/CLI(Don't stress too much but know a few thing)
- Photoshop(Expert)
- Wordpress(Good to know, should be able to design layouts)
- Atleast one front end framework, for example jQuery.(Must know)
- Bootstrap(Must know)
- At-least one open source editing program(Must know. Not every company will have budget for Photoshop)
- Sense of layouts/User Experience and colors(Expert)
- Graphics designing skills(Expert. Should be able to design stuff from scratch or take existing work and incorporate it into pre existing graphics)
This is for someone who wants to get into front end. This are the thing you'll be messing with everyday. This indeed is alot of stuff, but as far as it's fun to learn there should be no issue. Just keep grinding and working on new stuff. This phase is were you will get better at stuff you learn. For example, you won't be very good understanding XML/JSON code that server might throw at you, but you will eventually learn ways to make things easier for yourself.
Expert Level(Back end developer)
- AJAX(Be okay)
- How internet works(Solid understanding required)
- How servers work(Solid understanding required)
- How DNS work(Solid understanding required)
- Setting up a domain and DNS(Must know)
- Buying a Hosting(Must know
- Should be able to choose hosting dependong on your needs. See whether they will allow certain version of PHP, will enable modules. Data usage limits, uptime, support etc etc..)
- FTP(Must know using both GUI and CLI)
- OOP(Must know Object orignted programming - style of programming heavily used)
- Web application security(Be very good)
- PHP(Be very good)
- Atleast one backend framework(Be okay. For exmaple, Laravel, codeigniter etc..)
- SQL(Be good language itself and also using extensions like sql, sqli, pdo).
- API(Must know Application programming interface)
- Apache(Must know Should be able to install on fresh server and get necessary modules. Should also know how to use modules like mod_rewrite)
- Little bit of server administration, like changing permissions. Installing software necessary etc..(Be okay)
- HTML 5(Not as good as front end developer)
- CSS 3(Not as good as front end developer)
- Javascript/jQuery(Not as good as front end developer)
- How TCP/IP work(Be okay)
- Other server side language(Learn if required)
- Regex(Be okay. You will be using this alot when messing with apache modules)
- DOM(Be okay)
- JSON/XML(Be okay)
- Wordpress(Be okay)
- Git(Be okay)
- Understanding of HTTP(Be okay. Headers, requests responses)
- Terminal/CLI(Be okay)
- SSH(Be okay. Secure shell to access your server. Could use PuTTy too)
- Linux(Be okay. any one Distro)
- Photoshop(Be okay).
Expert doesn't mean you're done. You're still in process of learning and as you go you'll learn new stuff every day. At this stage you're just sharpening your skills.
Remember, web development is a very complex field and is an ongoing process. You're never too good. For example, you could learn how to build and fix PC and start your own business, however when it comes to website development it's big mixture of skills you need to be good at, just one thing doesn't cut it.
Last buy not least, always remember that people pay for solutions not skills.
Ip hacked! what can they do with it? How to prevent it in future?
Fact than most can't do shit after obtaining IP address is hilarious really.
If you don't already know about this way of obtaining peoples IP you're still living in stone age, and should really learn not to click any link your online buddies send you. Actually your buddy is just wannabe hacker who wanna get your IP to scare you. So please click on the link he sends you next time to not spoil their dreams of becoming next Adrian lamo.
Thanks.
![[IMG]](http://s2.quickmeme.com/img/9c/9ccb6a3aa78171a11e807ccefd5949d6100fb3b18d3db441b85576156908b4be.jpg)
Proceeding..
I'm talking about all known http://whatstheirip.com/ Basically they would put email on this site and click "get link".
![[IMG]](http://i.imgur.com/IVbFpLZ.png)
After that redirection to different page happens where it provided with link to get other peoples IP.
![[IMG]](http://i.imgur.com/Dn7KH67.png)
Generally these people who're trying to get IP will email the link to you saying, "This is so sad..!!!".. as if your life has been any different. Some will go as far as masking the link and make it appear like its legit site. Fucking. Bastards.
![[IMG]](https://s-media-cache-ak0.pinimg.com/564x/3a/83/d4/3a83d450697f9b743dd1999f3bc5142a.jpg)
Friendship whent down the drain after couple months.. and guess what your friend has? dat IP address!!
![[IMG]](http://remycarreiro.com/wp-content/uploads/2013/03/slapface-5000.jpg)
"You pussy you scared, I can hear your heart beat" Yeah 50 cent rocks! But really what can he really do with it? Nothing. Most average Joe cant do shit except for pinging your address with 64 bits haha lol'd.
![[IMG]](http://i.imgur.com/did9bXG.png)
But wait apparently your friend has taken a networking course called CCNA and probably knows a shit or two.. what's the most he can do? He can go buy a "Booter" and lit your ass up, not literally. He can probably take your cute internet connection down and null a port. So you cant visit facebook no more.
![[IMG]](http://cdn.meme.am/instances/60998065.jpg)
What else can he do?
- He can DOX you, using your IP address to filter information.
- He can search old hacked databases for your IP address and hack for email and shit if that site had not hashed data.
- He can post on online forums to DDOS that IP.
- He can do some port scanning shit.
How do I prevent all this?
- Don't signup on BS sites.
- Don't click shit links.
- Don't talk to strangers.
- Don't install bullshit.
- Don't ever use common sense. jk. But seriously avoid using common sense at all costs. It's expensive.
If you don't already know about this way of obtaining peoples IP you're still living in stone age, and should really learn not to click any link your online buddies send you. Actually your buddy is just wannabe hacker who wanna get your IP to scare you. So please click on the link he sends you next time to not spoil their dreams of becoming next Adrian lamo.
Thanks.![[IMG]](http://s2.quickmeme.com/img/9c/9ccb6a3aa78171a11e807ccefd5949d6100fb3b18d3db441b85576156908b4be.jpg)
Proceeding..
I'm talking about all known http://whatstheirip.com/ Basically they would put email on this site and click "get link".
![[IMG]](http://i.imgur.com/IVbFpLZ.png)
After that redirection to different page happens where it provided with link to get other peoples IP.
![[IMG]](http://i.imgur.com/Dn7KH67.png)
Generally these people who're trying to get IP will email the link to you saying, "This is so sad..!!!".. as if your life has been any different. Some will go as far as masking the link and make it appear like its legit site. Fucking. Bastards.
![[IMG]](https://s-media-cache-ak0.pinimg.com/564x/3a/83/d4/3a83d450697f9b743dd1999f3bc5142a.jpg)
Friendship whent down the drain after couple months.. and guess what your friend has? dat IP address!!
![[IMG]](http://remycarreiro.com/wp-content/uploads/2013/03/slapface-5000.jpg)
"You pussy you scared, I can hear your heart beat" Yeah 50 cent rocks! But really what can he really do with it? Nothing. Most average Joe cant do shit except for pinging your address with 64 bits haha lol'd.

![[IMG]](http://i.imgur.com/did9bXG.png)
But wait apparently your friend has taken a networking course called CCNA and probably knows a shit or two.. what's the most he can do? He can go buy a "Booter" and lit your ass up, not literally. He can probably take your cute internet connection down and null a port. So you cant visit facebook no more.
![[IMG]](http://cdn.meme.am/instances/60998065.jpg)
What else can he do?
- He can DOX you, using your IP address to filter information.
- He can search old hacked databases for your IP address and hack for email and shit if that site had not hashed data.
- He can post on online forums to DDOS that IP.
- He can do some port scanning shit.
How do I prevent all this?
- Don't signup on BS sites.
- Don't click shit links.
- Don't talk to strangers.
- Don't install bullshit.
- Don't ever use common sense. jk. But seriously avoid using common sense at all costs. It's expensive.
Blocking websites
So you clicked this somewhat bait title 'Blocking websites for noobs'
because you want to block certain websites... isn't? and perhaps
wondering if you already know what this dude chillin is about to teach
you. Wonder didn't Firefox or Chrome have that function? Yes it
certainly does.
But wait since it's a bait thread I'll teach you something else.
Obama care for good measure incase title hurt your butt.
Business time
Ever heard of Hosts file? no? then you're at a right place god dammit! Hosts file is like a pipeline where you add a filter in the middle to making sure what's allowed to flow and what is not. You can also Redirect user to different websites.
So if you open hosts file this is the format you put data in:
127.0.0.1 localhosts
'localhosts' is the URL a user would open. '127.0.0.1' is the URL 'localhosts' URL would be redirected to.
So for example if I have, 'www.google.com www.youtube.com' user would be redirected to www.google.com whenever he tried to open www.youtube.com. Isn't that interesting? You've just learned a new way to fuck your friend up!
You ask how do I block a website. Well just redirect website you want to block to 127.0.0.1 or any html that that you may have on your PC.
Not interesting enough?
Wait I heard Microsoft's new, windows 10 secretly sends data back and forth to some sites? We needa block that shit. RESPECT MY PRIVACY MOTHERFU*CKER.
What about blocking all the damn sites Microsoft windows 10 contacts? You could do that? you already know how to block shit using Hosts file, didn't you? all your have to do is find websites windows accesses.
If you like it. You must share it!
But wait since it's a bait thread I'll teach you something else.

Obama care for good measure incase title hurt your butt.
Business time
Ever heard of Hosts file? no? then you're at a right place god dammit! Hosts file is like a pipeline where you add a filter in the middle to making sure what's allowed to flow and what is not. You can also Redirect user to different websites.
So if you open hosts file this is the format you put data in:
127.0.0.1 localhosts
'localhosts' is the URL a user would open. '127.0.0.1' is the URL 'localhosts' URL would be redirected to.
So for example if I have, 'www.google.com www.youtube.com' user would be redirected to www.google.com whenever he tried to open www.youtube.com. Isn't that interesting? You've just learned a new way to fuck your friend up!

You ask how do I block a website. Well just redirect website you want to block to 127.0.0.1 or any html that that you may have on your PC.
Not interesting enough?
Wait I heard Microsoft's new, windows 10 secretly sends data back and forth to some sites? We needa block that shit. RESPECT MY PRIVACY MOTHERFU*CKER.
What about blocking all the damn sites Microsoft windows 10 contacts? You could do that? you already know how to block shit using Hosts file, didn't you? all your have to do is find websites windows accesses.
If you like it. You must share it!
Start your own online store with opencart
So you want to start online store, sell a few items and make profit?
![[IMG]](http://vignette1.wikia.nocookie.net/vsbattles/images/3/31/Meme-face-thinking.jpg/revision/latest?cb=20160207175639)
Opencart to rescue
If you haven't heard of opencart then you should learn a bit about it. It's an online eCommerce store to sell your products, accepts plenty of different payment options is pretty damn easy to setup and really make everything easy as hell through GUI.
Basically installation takes no more than 5 minutes. Create SQL database, download and extract opencart, put Upload folder files onto your host directory. Open your website root in browser and follow the instructions to setup admin login.
Sorry. PHP had to spoil the party!
![[IMG]](http://png-2.findicons.com/files/icons/2420/coded/256/page_php.png)
The only thing that may cause trouble while installing is not having modules enabled or having wrong PHP version, other that it's all easy.
Linux! Cant use Terminal, learn it? It seems useful.
![[IMG]](http://img.memecdn.com/update_o_986903.jpg)
If you're on Linux server just login and install modules typing sudo apt-get install php5-mcrypt for example. Or sudo apt-get install php5-curl. When going through wizard it should tell you what extensions to enable. Once installed you can enabled it by typing phpenmod Module_name.
You can also check manually what's installed that related to PHP. For instance use dpkg command with option --list and pipe the output to grep search command and search php. Like this. dpkg --list | grep php.
It's also necessary that you give certain file write permission. If you don't know how to do that, learn about linux permissions
![[IMG]](http://cdn.meme.am/instances/500x/64688451.jpg)
Naoooo it's actually that easy!
Once installed you can login to admin by going to www.your_site.com/admin and start adding or deleting products, set price, quantity, payment options, create categories.
![[IMG]](http://i.imgur.com/FfETpqU.png)
![[IMG]](http://i.imgur.com/UxBZgKx.png)
If you're setting up paypal as payment you can go to paypal developer account and get your data off there.
That's all there's to it guys. Using opencart is pretty easy as an end user.
![[IMG]](http://vignette1.wikia.nocookie.net/vsbattles/images/3/31/Meme-face-thinking.jpg/revision/latest?cb=20160207175639)
Opencart to rescue
If you haven't heard of opencart then you should learn a bit about it. It's an online eCommerce store to sell your products, accepts plenty of different payment options is pretty damn easy to setup and really make everything easy as hell through GUI.
Basically installation takes no more than 5 minutes. Create SQL database, download and extract opencart, put Upload folder files onto your host directory. Open your website root in browser and follow the instructions to setup admin login.
Sorry. PHP had to spoil the party!
The only thing that may cause trouble while installing is not having modules enabled or having wrong PHP version, other that it's all easy.
Linux! Cant use Terminal, learn it? It seems useful.
![[IMG]](http://img.memecdn.com/update_o_986903.jpg)
If you're on Linux server just login and install modules typing sudo apt-get install php5-mcrypt for example. Or sudo apt-get install php5-curl. When going through wizard it should tell you what extensions to enable. Once installed you can enabled it by typing phpenmod Module_name.
You can also check manually what's installed that related to PHP. For instance use dpkg command with option --list and pipe the output to grep search command and search php. Like this. dpkg --list | grep php.
It's also necessary that you give certain file write permission. If you don't know how to do that, learn about linux permissions
![[IMG]](http://cdn.meme.am/instances/500x/64688451.jpg)
Naoooo it's actually that easy!
Once installed you can login to admin by going to www.your_site.com/admin and start adding or deleting products, set price, quantity, payment options, create categories.
![[IMG]](http://i.imgur.com/FfETpqU.png)
![[IMG]](http://i.imgur.com/UxBZgKx.png)
If you're setting up paypal as payment you can go to paypal developer account and get your data off there.
That's all there's to it guys. Using opencart is pretty easy as an end user.
Tuesday, 8 March 2016
Port scanner, TCP/IP, Firewall & the Bouncer
Thought writing little something about what port scanners, TCP/IP and Firewall in general.
Read this. Don't skip!
When we talk about port it's necessary we also know what packet is. A pack it a little portion of a file that's transferred from one computer to another, and when this pack is transferred it's given destination and source IP address along with a port number. When a computer on receiving end receives this packet their firewall checks for rules set for that port or the IP. Firewall basically is like an entry point on your computer, everything that goes in or out goes through it.
See every app runs on different port. Must've heard of HTTP and FTP? no? Joined internet today or what?
FTP (File Transfer Protocol) - Port 21
SMTP (Simple Mail Transfer Protocol) - Port 25
Login (Login Host Protocol) - Port 49
HTTP (Hypertext Transfer Protocol) - Port 80 But I still don't understand??!

Right that's expected. Lets get a little more practical now. Your friend's computer wont open any webpage. He brings the computer to you and asks if you can fix. You check if it has internet. You do some other check but still cant figure out the problem.
--
What about checking whether firewall has port 80 opened? as you see, port 80 is used to make HTTP connections. It's possible that firewall is blocking it. Did you guys notice how workplace restricts your access to pornographic websites? Yes, firewalls list of rules are blocking those IP addresses.
So what's firewall again?

It's just a dude with list check-list in hand making sure who can come in, and how can go out. Understood? right! get a snicker!
TCP/IP(that's on scary acronym.. gonna drive me sane!) Don't worry.
Transmission control Protocol(TCP) is a language/protocol that ensures your packets are sent from one computer to another securely. You know when data is broken into packets it's a mess! thanks to TCP it's pasted back together into same order it when it goes to receiving end.
Okay..

This almighty TCP seem to know it all.. how does it know where to send data to? Well its friend Internet Protocol does! It contains the destination and source address and knows where the packet goes.
Alright? what's my IP address then? Click here to find out your IP address http://ipchicken.com/
Hmm.. What about TCP, can I see it too? Nop. But you can make sure it's running. If you send a packet using ping command followed by loopback address(this is virtual address for testing) it should return responses. Meaning TCP/IP is working properly. But you really shouldn't worry much about it because computers already comes with this stack installed.
What's port scanner?
As you seen above, different programs run on different protocol. If someone creates a program that checks for open ports on your computer and finds a vulnerability for that port then you're screwed isn't it. That's why people tell to keep un-used ports closed all the time. Check this PDF to find out common vulnerabilities on ports. http://www.tenable.com/sites/drupal...s/Vulnerability Reporting by Common Ports.pdf
Didn't understand anything? Well atleast you put some effort I guess? It's time you learn "basics of how Internet works".
Goodluck! any questions feel free to ask!
Monday, 7 March 2016
Codeigniter - How to fetch data from database and display
Show Data form Database to user
http://www.webdevtown.com/2016/02/mvc-model-view-controller-seriously.html
http://www.webdevtown.com/2016/02/codeigniter-beginners-series-lesson-2.html
Once you've gone through these two tutorials it's time to learn to retrieve information from database and show it on page. We'll just get all the records off database and show it.
Connect
First make sure to connect to database in '/var/www/application/config/database.php'
Set route
Once you've connected lets set default route to 'show_data'. Write $route['default_controller'] = 'show_data'. So whenever use loads your website default controller will run.
Create controller
Create a file named /var/www/application/application/Show_data.php make sure it starts with capital letter. Lets create a controller class. This class will run when user opens your site main page, if no method name is given in URL index method will be called.
PHP:
class Show_stats extends CI_Controller{
// This is default method that will run if no method name is given in url.
public function index(){
}
}
// This is default method that will run if no method name is given in url.
public function index(){
}
}
Model
Lets create model which will retrieve data from database. Create file /var/www/application/models/Stats_model.php and create a new model class and load database using constructor so it's loaded as soon as class is instantiated.
PHP:
class Stats_model extends CI_Model{
// We're loading database connection here.
function __construct(){
$this->load->database();
}
}
// We're loading database connection here.
function __construct(){
$this->load->database();
}
}
View
Create new file /var/www/application/views/show_data.php. This will is where we will pass data from that we get from model class.
Retrieve data in model.
We created model class earlier but didn't retrieve any data. Lets do it now. Create new function and retrieve all data from database.
PHP:
class Stats_model extends CI_Model{
function __construct(){
$this->load->database();
}
public function get_stats(){
// $this->db is an Object that has get method which accepts table name.
$query = $this->db->get('site_stats');
// We're returning all the data using $query->result_array();
return $query->result_array();
}
}
function __construct(){
$this->load->database();
}
public function get_stats(){
// $this->db is an Object that has get method which accepts table name.
$query = $this->db->get('site_stats');
// We're returning all the data using $query->result_array();
return $query->result_array();
}
}
Loading model into Controller
We created controller earlier but it doesn't do anything. We need to load model, invoke it's method to get the data and the pass it to views to show it to user.
PHP:
class Show_stats extends CI_Controller{
function __construct(){
// Running class CI_Controllers constructor.
parent::__construct();
// We load the model class.
$this->load->model('stats_model');
}
public function index(){
// We invoke get_stats method of stats_model class which retrieves data from database, and put them into an associative array $data[].
$data['stats'] = $this->stats_model->get_stats();
// We load view and pass it the $data array where we just put the retrieved values.
$this->load->view('stats', $data);
}
}
function __construct(){
// Running class CI_Controllers constructor.
parent::__construct();
// We load the model class.
$this->load->model('stats_model');
}
public function index(){
// We invoke get_stats method of stats_model class which retrieves data from database, and put them into an associative array $data[].
$data['stats'] = $this->stats_model->get_stats();
// We load view and pass it the $data array where we just put the retrieved values.
$this->load->view('stats', $data);
}
}
Show data in views
Go back to views and run simple foreach statement to show the data to user.
PHP:
<?PHP foreach($stats as $all_stats): ?>
<b>
<?PHP echo $all_stats['title']; ?>
</b>
<?PHP endforeach; ?>
<b>
<?PHP echo $all_stats['title']; ?>
</b>
<?PHP endforeach; ?>
Friday, 26 February 2016
CodeIgniter Beginners Series - Lesson 2 Controller | Routes and View
Welcome to codeigniter beginners series day 2. Today we'll be installing codeIgniter, go over some very basic codeigniter concepts, we'll try loading some basic pages and make changes to it then learn about routes, passing data and setup a route for our new page aswell.
Lets get started. First go head and install codeIgniter, here's a tutorial I wrote on installing codeIgniter on linux. http://www.webdevtown.com/2016/02/installing-codeigniter-on-linux-ubuntu.html If you're on windows it's still the same steps you'll follow to install. Here's codeIgniter official documentation its installation. http://www.codeigniter.com/user_guide/installation/index.html
With that aside, lets move on to more useful stuff. Open 'localhost' on your browser, make sure apache server is running. You should see a basic welcome page. This is codeigniter's default route. Means anyone who loads localhost will see this page.
Some code!
Lets open our controller folder and see what's inside Welcome.php controller file. I'm assuming you've read MVC if you haven't then you should do so to understand this tutorial. Read it here http://www.webdevtown.com/2016/02/mvc-model-view-controller-seriously.html Alright, we're in Welcome.php file, this a a file that is loaded by default. Whenever someone opens localhost, this file is run. This file contains a class that extends from CI_Controller class, means all CI_Controller's method and properies are available to this class. If we want to create a controller we just give our class a name and extend it form CI_Controller class.
General URL structure is like this. domain/CONTROLLER_CLASS/CONTROLLER_CLASS_METHOD/PARAMETERS. In our case controller class is Welcome, method is index and parameter is welcome by default unless user gives one.
class Welcome extends CI_Controller{
function index($page = 'welcome'){
$this->load->view($page);
}
}
Proceeding, we're $this->load->view('welcome'), when the index method is run, it will run the view method giving it welcome argument, welcome is name of our view page which is inside view folder. If user provided no argument in URL welcomepage would be loaded by default, else whatever page user asked for in argument.
What're routes?
Route is a the route to controller. It means what controller to load depending on what information user provides in URL. As I mentioned about typical URL consists on following division domain/CONTROLLER_CLASS/CONTROLLER_CLASS_METHOD/PARAMETERS. Lets create an test URL. http://localhost/index.php/data/names/jon. Now this url is suppose to return information about user jon. As, jon being parameter, names the method and data the controller class name. Lets say you don't like this long URL you want jon's information when user types http://localhost/user/jon this is where routes will come into play. We'll tell our route file, whenever use types /user/USERNAME in URL, run the data class, username method and give it arguement. Note you can put your data into $data() array and pass it to view like so, first put data in $data array, $data['some_info] = $information; then pass it to view, $this->load->view('page_name', $some_info), and then in view file 'page_name' you can show that variable's value like echo $some_info.So here's my controller, that takes runs data controller, username method in it and passes it brown argument. Then we pass that brown argument to view to display it. Not that in real sanario we'd also get user info off data base. But since it's just 2nd lesson we'll just pass users' name to view. http://localhost/index.php/data/username/brown.

Lets back off a little and see how we can just use http://localhost/user/jon and still get this working. Switch to routes.php file scroll down and delete pre existing entries. They're at the very bottom after all the commentary. They look like $route['default_controller'] = 'welcome.php'; Delete that too lets create an entry. Note that codeigniter uses *wildcard symbols or keywords for url matching. For example, (:any) means any URL. jon/brown will mean one or another in URL.. if any of it matches, direct user to specified URL.
Our route will look like this $route['user/(:any)'] = "data/username/$1"; It says, whenever user types user/ANY_USERNAME redirect user to data/username/$1 $1 being the argument's value. When user is directed to that page, our controller takes over and process the information showing us the view page.
This is really important content used in almost all frameworks, being as important as it is it requires quite a bit of practice. Best way to practice is to look at different website URL, and make them user friendly using routes.
In next tutorial we'll be learning about model.
Thursday, 25 February 2016
How to hire a good coder/programmer
Coding as we all are well aware is a complex stressful and time
consuming process for any coder out there which is why it's extremely
important that both coders and the client work together. Hiring someone
and let them do the job is never the route to follow, whether it's a
retail, pest control, site administration or anything for that matter
requires both parties to work together to develop a good end product.
If you're a coder it's really important that you know exactly what you're capable of(never sell yourself short though) and what you're not. Being greedy, taking client's money and NOT delivering the product on time is nothing but a reputation destroyer, just as good word spreads quick bad word spreads quicker. The important factor that we all can agree upon here is communication, as tiring and time consuming coding is, it as a coder is your responsibility to be the first one to get the conversation started and update the client as often as possible so if there's any issue or change in plans the client wont be as surprised. The client too will think twice before telling you to make major changes.
Here's a few thing to ask the coder before you hire him:
- Portfolio
- If worked on similar project
- Rough deadline
- TOS(Extremely important, discuss what they intend to do if project is not finished on time, how they plan on making changes, if there's an additional fee etc..).
- Logical process coder plans on taking. How to plan on achieving what you require.
- Name
- Phone number
- Address
Here's a few thing to ask the client as coder:
- Name
- Phone number
- Address
- NDA(Non disclosure agreement, if there's any)
- Availability(times they're available for discussion)
- Budget(Make it clear what they pay in advance and what after project completion).
It's also very important that you have clear idea of your own project. Being totally illiterate to technology wont help. You should almost always ask the coder certain somewhat technical questions. They should be able to answer it in a simple way that you understand, If you're having trouble understanding it's either you didn't study about your own project or this coder's not the right person that will update you frequently in non technical manner that you understand and make decisions if necessary.
Pricing is an interesting yes quite simple to guess, all it takes is a word with different coders asking for price and figure out whichever makes most sense to you. Do note that there's hundreds of things that determine the price for example coding style, deadline, experience(even shitty coders but with lots of experience can charge you alot), maintenance and whatnot..
Last thing's just like everything if you plan properly everything will go right, hurrying in any investment is never a good idea. Luck aside, most of the you'll end up losing money and time and give up, not because coder didn't do the job properly but because you chose the wrong service that wasn't really suitable for your project.
If you're a coder it's really important that you know exactly what you're capable of(never sell yourself short though) and what you're not. Being greedy, taking client's money and NOT delivering the product on time is nothing but a reputation destroyer, just as good word spreads quick bad word spreads quicker. The important factor that we all can agree upon here is communication, as tiring and time consuming coding is, it as a coder is your responsibility to be the first one to get the conversation started and update the client as often as possible so if there's any issue or change in plans the client wont be as surprised. The client too will think twice before telling you to make major changes.
Here's a few thing to ask the coder before you hire him:
- Portfolio
- If worked on similar project
- Rough deadline
- TOS(Extremely important, discuss what they intend to do if project is not finished on time, how they plan on making changes, if there's an additional fee etc..).
- Logical process coder plans on taking. How to plan on achieving what you require.
- Name
- Phone number
- Address
Here's a few thing to ask the client as coder:
- Name
- Phone number
- Address
- NDA(Non disclosure agreement, if there's any)
- Availability(times they're available for discussion)
- Budget(Make it clear what they pay in advance and what after project completion).
It's also very important that you have clear idea of your own project. Being totally illiterate to technology wont help. You should almost always ask the coder certain somewhat technical questions. They should be able to answer it in a simple way that you understand, If you're having trouble understanding it's either you didn't study about your own project or this coder's not the right person that will update you frequently in non technical manner that you understand and make decisions if necessary.
Pricing is an interesting yes quite simple to guess, all it takes is a word with different coders asking for price and figure out whichever makes most sense to you. Do note that there's hundreds of things that determine the price for example coding style, deadline, experience(even shitty coders but with lots of experience can charge you alot), maintenance and whatnot..
Last thing's just like everything if you plan properly everything will go right, hurrying in any investment is never a good idea. Luck aside, most of the you'll end up losing money and time and give up, not because coder didn't do the job properly but because you chose the wrong service that wasn't really suitable for your project.
CodeIgniter Beginners Series - Starting up
CodeIgniter Beginner Series - Starting up
If you've been developing web application in PHP for a while now and have a good working knowledge of OOP this may be the right time to pick up a framework that makes you life easier. If your goal is to learn then forget about framework and keep focusing on developing stuff from scratch but if you're past that point where you feel tired rewriting code and just want to be super productive and make money then you got to use a framework. Learning curve is everywhere so don't expect it to like writing your 'Hello world!".
This is a Codeigniter tutorial series and in this series I'll from beginner to intermediate tutorials covering almost everything that you need to know. Things that are not so important, I won't even touch. If you're past intermediate projects and feel the need to learn it advanced concepts, you're free to as you'll have solid foundation to understand any new concept or pick any new framework.
Before we proceed it's important that you understand what MVC is because Codeigniter is based on it. You can read about MVC here http://www.webdevtown.com/2016/02/mvc-model-view-controller-seriously.html. Today's task is nothing more than reading and understanding MVC, I won't teach you anything, we won't do any code. It's all MVC, search and read till you understand. Once MVC concept is somewhat clear then come back here tomorrow. I'll be teaching some basic stuff like CodeIgniter installation, loading pages and understand what routes are and how they work.
See you tomorrow! We'll ignite some code!
Monday, 22 February 2016
How to Block Tor Traffic
How to block Tor Traffic
Blocking Tor Ip's is pretty straight forward. I'll give you step by step process to follow to block Tor IP's but before that I'll give you guys a break description of how Tor Network work.Tor is a network of relays/servers. When you try connecting to a certain website it goes through these replays, your computer knows about the first replay it's connected to, and the website you're connecting to knows about the last relay. These relays are other people's computers, they install the software and become relay.
Exit relay is the last relay that your data goes through before the request is sent to the site you're trying to connect. ALL THESE EXIT RELAY IPs ARE PUBLISHED.
To detect Tor IP all you need to do is check whether the IP connecting to your server matched any IP in that Tor exit relay list. If it does match, means it's coming off a Tor exist relay.
For example, here's a TOR relay https://globe.torproject.org/#/relay/1C90D3AEADFF3BCD079810632C8B85637924A58E and its IP address is 62.210.82.44 which mean if you query Relay database with that IP you should get positive response back with some data. If it returns negative response, means it's not a Tor IP address.
Lets get practical. Visit this website and put a random IP address. You can put your too and press enter. https://check.torproject.org/cgi-bin/TorBulkExitList.py It will show the list of Exit nodes that are allowed to connect to your computer/server. Generally you'd send your server's IP address to this website with port and it will show you the list of exit relays that can cannot to your server. Then just iterate through these IPs and if the suspicious IP/IP address trying to connect to your server exists in that list. It means it's a Tor computer address.
Here's an example.
https://check.torproject.org/cgi-bi/TorBulkExitList.py?ip=IP_ADDRESS&port=PORT_NUMBER
Example with info:
https://check.torproject.org/cgi-bi/TorBulkExitList.py?ip=216.239.34.10&port=80
That said and explained do make sure that you aren't blocking the legit user, someone using Tor network doesn't automatically make them an abuser, and it's important to keep in mind that someone could be using their PC to connect to website in general way but also use the same IP for Tor, meaning if you query their IP in Tor relay IP's it will say it's a Tor IP even though user is visiting your site without going through Tor relays.
Wednesday, 17 February 2016
CodeIgniter Documentation Example Code Error | Explained and Fixed
CodeIgniter Documentation sample code error. 404 Page Not Found The page you requested was not found.
First of all go have a look at CodeIgniter Static pages documentation.
http://www.codeigniter.com/user_guide/tutorial/static_pages.html
Here's their Example of Controller class Pages:
class Pages extends CI_Controller {
public function view($page = 'home')
{
if ( ! file_exists(APPPATH.'/views/pages/'.$page.'.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$data['title'] = ucfirst($page); // Capitalize the first letter
$this->load->view('templates/header', $data);
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);
}
}
Now as you can see the 'APPPATH' CONSTANT on line 3 is path to the 'application' folder and it's defined in our main index.php file.
If you go and create template folder, put files in, same with pages and whatnot and run it, it wont run. It'll instead invoke show_404() function saying page doesn't exist. Specifically tell us, "APPPATH.'/views/pages/'.$page.'.php'" doesn't exist. It's really a pain because it does indeed exist even after setting up everything correctly and granting full perms.
So after searching in Google for about 4-5 hours and trying to resolve it myself I decided to check the exact value of that 'APPPATH' CONSTANT. That's how it's defined: "define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);".
if ( ! is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
{
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
echo 'Your application folder path does not appear to b$
exit(3); // EXIT_CONFIG
}
It seem perfectly fine at first glance but what's that 'DIRECTORY_SEPERATOR' CONSTANT doing there? well I guess it's just adding a directory separator '/'. Perfectly fine, right? Now if you've been following their documentation they've a Directory separator '/' before 'views' aswell, '! file_exists(APPPATH.'/views/pages/'.$page.'.php'', which means APPPATH will add one directory separator, and if you follow the documentation they've added another directory separator in total two separators, making file_exist function return false and thence error message!!
This is what we're basically asking file_exists() function to check. Does /var/www/application/.'/views/pages/'.$page.'.php'. exist? It'll always return false due to 2 slashes! To fix the issue you need to remove the clash before views.
Monday, 15 February 2016
MVC Model View Controller | Seriously Simplified Version
Model View Controller Seriously Simplified
I've written about MVC in past..
http://www.webdevtown.com/2015/04/model-view-and-controller-with-example.html
http://www.webdevtown.com/2015/04/model-view-and-controller-with-example.html
So, recently I was going through that past tutorial and
decided to re-read it, to my surprise it came across as not very easy to
understand, so here's another quick attempt. Hope this one helps it understand.
Okay. You're a web developer who develops everything by himself, from design to complex coding, it's all done by you. No big deal, you get the idea of what you want to develop and start writing the code, function by function, time comes when you've got 100s of files thousands of functions and it's a freaking mess, isn't it? where do I change code to update row in table? I want to make sure data is cleaned. Wait, what's this HTML doing here? hmm I need to make it easier to get usernames and other data from DB.. okay I might update the code, but it'll require my to update the logic too.. hmm it's a freaking mess.. wait hmm.. I'll be selling this product to a fellow developer.. I wonder how he's gonna deal with all this tight coupling.. I've glued everything together.. Hope he doesn't hire designer to update the template.. it'll be nightmare, he might come back to my saying code's a crap.
That's why you need MVC. Writing code alone or with someone, it it isn't clean it's just.. pain..
Whole purpose of this MVC pattern is to simplify(Ahm! OOP) things up and make it easy to manage the code in future. Before you start with MVC it's necessary you understand OOP and have created an app or two using it's fundamentals. MVC isn't really a need per say, but someone who's just writing couple hundred lines of basic code it's good to know that MVC exists so when you feel your code's getting messy, you know what to do about it!
Okay. You're a web developer who develops everything by himself, from design to complex coding, it's all done by you. No big deal, you get the idea of what you want to develop and start writing the code, function by function, time comes when you've got 100s of files thousands of functions and it's a freaking mess, isn't it? where do I change code to update row in table? I want to make sure data is cleaned. Wait, what's this HTML doing here? hmm I need to make it easier to get usernames and other data from DB.. okay I might update the code, but it'll require my to update the logic too.. hmm it's a freaking mess.. wait hmm.. I'll be selling this product to a fellow developer.. I wonder how he's gonna deal with all this tight coupling.. I've glued everything together.. Hope he doesn't hire designer to update the template.. it'll be nightmare, he might come back to my saying code's a crap.
That's why you need MVC. Writing code alone or with someone, it it isn't clean it's just.. pain..
There's three things you need to know and know it well enough. Here's the start:
Model
Model's a class that represents all your data. It has methods that update, delete, retrieve data from DB. You could have class that'd retrieve recently signed-up users from DB, or any other data. You want data, create object and get it. You want to delete user, pass user name and it deletes user. Everything nice and tidy. It's mostly about the DATA!! Not manipulation or other stuff but about Data!View
View is what you see on webpage, HTML, forms, titles, tables, buttons. It all belongs to View page. It has minimal script. It's mostly HTML. Don't add bunch of code to View unless you want to piss yourself or designers in future and hear them telling others your code sucks!Controller:
It's piece of code that sits between View and Model. User hits Submit button from View, Data goes through Controller, you know, you might want to do some validation, manipulate, twist it and whatnot. It all happens here, once controller's job's done. It can send data to model if it requires database manipulation or information retrieval, or it can return data back to View, where View will present it to user. If app required data from Model or needed to make some changes to data, it will be sent to Model and then Model class would send it back to Controller, then Controller to View for Presentation. View wont interact with Model directly, it has no business to do so..Whole purpose of this MVC pattern is to simplify(Ahm! OOP) things up and make it easy to manage the code in future. Before you start with MVC it's necessary you understand OOP and have created an app or two using it's fundamentals. MVC isn't really a need per say, but someone who's just writing couple hundred lines of basic code it's good to know that MVC exists so when you feel your code's getting messy, you know what to do about it!
Friday, 12 February 2016
Installing CodeIgniter on Linux Ubuntu Server for Beginners
Installing CodeIgniter on linux
*Basic Linux CLI knowledge required*
CodeIgiter is a PHP Framework or tool-kit to develop full featured or simple application. If you've been working with PHP for a while now you should definitely try new frameworks now, though today we'll be learning how to install Codeigniter framework on Linux.
To download CodeIgniter navigate to Apache public/root directory and run the following command in Terminal. You can also use SSH to connect to your server shell and follow the exact same steps. Once you're in 'var/www/html' directory(root), run 'wget https://github.com/bcit-ci/CodeIgniter/archive/3.0.4.zip' in Teminal to download the Framework.
When the download is done. Stay in same directory and extract the file using command 'unzip CodeIgniter-3.0.4'. Make sure though that you've got unzip program installed to unzip the file. You can check if you've command installed using command 'whereis', 'whereis unzip'. It should show the bin directory path where command code is.
Now lets move index.php file out of CodeIgniter folder to our root using mv command 'sudo mv CodeIgniter-3.0.4/index.php /var/www/html'. Remember that there's only two main folders, 'application' and 'system', and we need to move these outside the root folder 'html' to 'www' so user cannot access them. We move those two folders to www using mv command again. 'sudo mv CodeIgniter-3.0.4/system CodeIgniter-3.0.4/application /var/www'.
That's our main job done, we can now delete codeIgniter folder as it's no longer needed. To delete the folder use 'rm' command with '-r' options, r stands for recursive. 'sudo rm -r CodeIgniter-3.0.4/'.
Lastly we need to tell CodeIgniter where our 'system' and 'application' folder is. This requires full path. Open index.php file and edit following variables $system_path, $application_folder and $view_folder. For example, my 'application' folder is inside var/www so I do 'gedit index.php' to start editing it, and replace '$application_folder''s value to /var/www/application.
Remember that permissions to edit, read and execute are required for root folder and read and write permissions for 'application' and 'system' folder and its subdirectories. You can learn more about in my permissions introductory tutorial. http://www.webdevtown.com/2016/02/what-is-file-permission-in-linux-and.html
So that's all you do to install CodeIgniter on linux! If there's any questions feel free to ask in comments.
You can read more about codeIgniter framework on their official website.
http://www.codeigniter.com/
*Basic Linux CLI knowledge required*
CodeIgiter is a PHP Framework or tool-kit to develop full featured or simple application. If you've been working with PHP for a while now you should definitely try new frameworks now, though today we'll be learning how to install Codeigniter framework on Linux.
To download CodeIgniter navigate to Apache public/root directory and run the following command in Terminal. You can also use SSH to connect to your server shell and follow the exact same steps. Once you're in 'var/www/html' directory(root), run 'wget https://github.com/bcit-ci/CodeIgniter/archive/3.0.4.zip' in Teminal to download the Framework.
When the download is done. Stay in same directory and extract the file using command 'unzip CodeIgniter-3.0.4'. Make sure though that you've got unzip program installed to unzip the file. You can check if you've command installed using command 'whereis', 'whereis unzip'. It should show the bin directory path where command code is.
Now lets move index.php file out of CodeIgniter folder to our root using mv command 'sudo mv CodeIgniter-3.0.4/index.php /var/www/html'. Remember that there's only two main folders, 'application' and 'system', and we need to move these outside the root folder 'html' to 'www' so user cannot access them. We move those two folders to www using mv command again. 'sudo mv CodeIgniter-3.0.4/system CodeIgniter-3.0.4/application /var/www'.
That's our main job done, we can now delete codeIgniter folder as it's no longer needed. To delete the folder use 'rm' command with '-r' options, r stands for recursive. 'sudo rm -r CodeIgniter-3.0.4/'.
Lastly we need to tell CodeIgniter where our 'system' and 'application' folder is. This requires full path. Open index.php file and edit following variables $system_path, $application_folder and $view_folder. For example, my 'application' folder is inside var/www so I do 'gedit index.php' to start editing it, and replace '$application_folder''s value to /var/www/application.
Remember that permissions to edit, read and execute are required for root folder and read and write permissions for 'application' and 'system' folder and its subdirectories. You can learn more about in my permissions introductory tutorial. http://www.webdevtown.com/2016/02/what-is-file-permission-in-linux-and.html
So that's all you do to install CodeIgniter on linux! If there's any questions feel free to ask in comments.
You can read more about codeIgniter framework on their official website.
http://www.codeigniter.com/
Thursday, 11 February 2016
Learn new technologies daily
Learn new programming stuff daily
If you're a very beginner programmer and regularly asking advanced coders for help then I'm sure you must've noticed the wisdom these coders have where they tell you something that makes you wonder how does he knew this.. I wish I knew it. They seem to know stuff you never heard off, most of which is gained from experience. But as a beginner coder you too can learn new stuff. Most coders live in their own world and miss on plenty of stuff.What you do is search for computer science dictionary online and read couple words daily, whatever is related to your field read more about it and explore more about that subject on google. This is a really good way to learn about new stuff for people who don't know many coders. Keep in mind though dictionaries contain thousands of words, you don't necessarly need to go from 1 to x. Read what ever interests you and apply it to your new projects. If it's all read it's a waste of time. Make sure to put everything to practice.
Sunday, 7 February 2016
Steel Plate user management system | Free | Git link
User management system script
I'm dropping this incomplete project I'd been working on to switch to something better that'd bring positive return of investment. So here it is for everyone, I've uploaded the whole project on github. It's obviously not completed but I'm sure people will reuse stuff in their projects. So goodluck everyone! and obviously if you've any questions about the code feel free to ask me I'd be happy to help you. Oh and if you've got any work feel free to message me.Contains:
- Login
- Registration
- Email confirmation
- Bot detection
- Mail to Inbot not spam
- HTML mail support
- Admin CP
- Ban user
- Ban IP
- Add Captcha info
- Update user details
- IP ban check
- Blacklisted IP's check
- User ban
- Multi check
- Multi allow on IP feature
- Google captcha support
- Token use for secure submits
- Secure form validation
- BCrypt Support
- Mobile friendly(Bootstrap)
- Social login(Google) support
- OOP clean code
Thursday, 4 February 2016
What is File Permission in Linux and what's necessary to know as a programmer or developer
What is File Permissions in Linux and why I need to know about it as a programmer or Develope
Permission is a very important function to keep things organized and secure. Even as the owner you do not want to have full permissions over certain files. Imagine you're working on a project and somehow accidentally deleted the file before you'd the change to upload it to git or to some secure place. Same with other users, you do not want them to be able to accidentally or deliberately delete, write or execute particular files.Permission modes
There exist 3 permissions or modes, and 3 type of people whom you may grant them.Three permissions are: Read, Write and Execute and they're represented by r, w, x. They're always in the same order(you'll see when we use terminal). Read is where system will allow them to read/open the file. Write is permission to write/edit the file, and last buy not least Execute is permission to execute or run a file.
The 3 type of people I mentioned above are: Owner/User, Group and Other. Represented by u, g, o. Also there's All, means everyone indicated by letter a. Owner is the person/user who created the file, Group is collection of users, others is everyone else.
ls -l to see permissions
To check permission details just navigate to directory and type ls -l. The -l argument shows detailed information about the file including it's permissions. I typed the command and here's the permission it returned. drwxr-xr-xStarting to read from very left to right, the d even dumbest person can can represents directory. Now lets go 3 letters at a time, keep the order in mind(u, g, o) first 3 letters rwx are for Owner, that's the permissions the owner has, he can read, write and execute. Next 3 letters are r-x, and they're for group, users in group can read, - means the permission is not set, ad execute. Lastly we've permissions for Others r-x, they can read, - permission is not set, and execute.
Along with permissions you'll also have other rows, next to permission will be number of files or links in that directory, then then of the owner or user who owns the file, then the group the file belongs to.
nautilus
Permissions on ubuntu can also be set or changed using the Gui program nautilus, but only if you execute it as administrator. If you type sudo nautilus in terminal a new window file manager/exporer window will pop up where you can navigate to desired directory, right click on file or folder and set the permissions or each individual person.chmod
chmod means change mode, it allow you to change permissions/modes on files and directories. The format for this command is "chmod options permissions filename". Options are arguments it can take, permissions are as usual r, w, x and filename you should already know. Note that options aren't always necessary.Options for chmod
-f, --silent, --quiet suppress most error messages-v, --verbose output a diagnostic for every file processed
-c, --changes like verbose but report only when a change is made --reference=RFile use RFile's mode instead of MODE values
-R, --recursive change files and directories recursively
--help display help and exit --version output version information and exit
Permission setting Example
Lets say I want to grant whichever group Documents directory belong to permissions to read, write and execute. Note that all the users will then be able to read, write and execute.Here's what we do:
1. Enter chmod command first of all.
2. For permissions we tell who we want to grant permissions to , u, g, or o.
3. We use + or - symbol letting the command know whether we're setting or removing permissions. For example, if you want to give user permission to only read and execute, but not edit. We do +r-w+x.
4. We type the permissions.
5. Write file name at the end.
1. chmod | 2. g | 3. + | 4. rwx | 5. Documents
Here's my permissions for Documents folder "dr-xr-xr-x". Lets say I want to give:
- User permission to read, write and execute.
- Group permission to only read.
- Other permissive to only read aswell.
chmod u+rwx,g+r-w-x,o+r-w-x Documents
This will change the permissions as we needed. If you go ahead and do ls -l you should see these permissions for Document directory "drwxr--r--"
If you'd like to know more about chmod I suggest learning about using shorthand numeric values as permissions instead of messy -rwx+rx letters.
I hope this guide's been information. See you guys next time.
Saturday, 23 January 2016
Learn linux interactively for beginners
Knowing how linux works is really an important skill to have, as a website developer you'll often have to use linux operating system, install GUI, setup web development or general environment where you can run a web server, we all know majority of servers run on linux OS so keep that in mind too.
Website I'm about to introduce to you really makes learning linux commands and get basic idea of OS pretty simple for beginners. Linux might seem complex but you'll really be using same commands over and over again. The most important thing to understand how it work and differ from yur day to day operating system, once you understand that, it'll just come down to googling for commands and executing them.
You gotta know what Kernel is.
Kernel is a nothing but a program that helps hardware interact with software. So basically there's applications, then Kernel in the middle and hardware and other devices at the bottom. It's a basic layer model.
Do you know what a shell is in linux?
Shell is just an interface like you've in windows, it's basic screen with text written on it where you can enter commands. If you don't like shell you can just install some interface and use it instead. But shell give you more flexibility and it's must you know how to use it. There's plenty of shell softwares available for linux, common one is BASH.
You'll keep hearing about UNIX
Unix is an old operating system that linux is based on.You could say Linux OS is version of Unix OS. That's pretty much all you need to know.
That's basic info there, you can learn more about linux here interactively
http://linuxsurvival.com/wp/?page_id=5&id=0
Website I'm about to introduce to you really makes learning linux commands and get basic idea of OS pretty simple for beginners. Linux might seem complex but you'll really be using same commands over and over again. The most important thing to understand how it work and differ from yur day to day operating system, once you understand that, it'll just come down to googling for commands and executing them.
You gotta know what Kernel is.
Kernel is a nothing but a program that helps hardware interact with software. So basically there's applications, then Kernel in the middle and hardware and other devices at the bottom. It's a basic layer model.
Do you know what a shell is in linux?
Shell is just an interface like you've in windows, it's basic screen with text written on it where you can enter commands. If you don't like shell you can just install some interface and use it instead. But shell give you more flexibility and it's must you know how to use it. There's plenty of shell softwares available for linux, common one is BASH.
You'll keep hearing about UNIX
Unix is an old operating system that linux is based on.You could say Linux OS is version of Unix OS. That's pretty much all you need to know.
That's basic info there, you can learn more about linux here interactively
http://linuxsurvival.com/wp/?page_id=5&id=0
Writing clean code PSR standards
Writing clean code is all about following conventions and standards that are generally understood by others. Imagine writing a program and sharing the source code with other developers out there, they will often go through your code and start scratching their head wondering what the hell this chunk of code does, trying to fix something they break everything else. Writing clean and tidy code is all about not making them tightly coupled(shouldn't depend on each other so badly that it breaks entire program if something's missing), write clean code that a somewhat experienced program should be easier able to read and undnerstand, and finally follow coding standards. I personally follow PSR 0, 1 and 2 standards.
PSR 0 is about auto loading and class names
PSR 1 is basic coding standards
PSR 2 extend and contrinues talking about standards.
Before you start reading PSR standards it's important you know what you must do, what's just a recommendation etc.. generally most standards use certain words what they mean is defined in RFC 2119 document http://www.ietf.org/rfc/rfc2119.txt
Once that read you should start reading the standards starting from 0. It's upto individual needed but those first 3 are must for anyone.
Example(Code must not product side effects, it should either declare class/functions or produce side effects - change variable value, echo something etc), if you're including a file it shouldn't just run and echo stuff on screen and run methods etc.. it should do one or another.
What you shouldn't do:
// side effect: change ini settings
ini_set('error_reporting', E_ALL);
// side effect: loads a file
include "file.php";
// side effect: generates output
echo "<html>\n";
// declaration function foo() {
// function body
}
Declare function is okay but echoing HTML in same file is not. Should only have function declaration in one file and other stuff in another. Upon including the file, your class shouldn't start executing unrelated logic that affects other code on page.
// declaration
function foo() {
// function body }
// conditional declaration is *not* a side effect
if (! function_exists('bar')) {
function bar() {
// function body
}
}
You can read more about accepted PSR standards
https://github.com/php-fig/fig-standards/tree/master/accepted
PSR 0 is about auto loading and class names
PSR 1 is basic coding standards
PSR 2 extend and contrinues talking about standards.
Before you start reading PSR standards it's important you know what you must do, what's just a recommendation etc.. generally most standards use certain words what they mean is defined in RFC 2119 document http://www.ietf.org/rfc/rfc2119.txt
Once that read you should start reading the standards starting from 0. It's upto individual needed but those first 3 are must for anyone.
Example(Code must not product side effects, it should either declare class/functions or produce side effects - change variable value, echo something etc), if you're including a file it shouldn't just run and echo stuff on screen and run methods etc.. it should do one or another.
What you shouldn't do:
// side effect: change ini settings
ini_set('error_reporting', E_ALL);
// side effect: loads a file
include "file.php";
// side effect: generates output
echo "<html>\n";
// declaration function foo() {
// function body
}
Declare function is okay but echoing HTML in same file is not. Should only have function declaration in one file and other stuff in another. Upon including the file, your class shouldn't start executing unrelated logic that affects other code on page.
// declaration
function foo() {
// function body }
// conditional declaration is *not* a side effect
if (! function_exists('bar')) {
function bar() {
// function body
}
}
You can read more about accepted PSR standards
https://github.com/php-fig/fig-standards/tree/master/accepted
Wednesday, 13 January 2016
How to get a domain name almost for free
Get discount on domain names
Web developers often create website for themselves when starting up a new project, it can be pretty expensive if you're working on projects one after another and buying new domain names. One of the way to get a cheap domain names is to find and test best coupon for maximum discount.It's not always that easy to search web and find best promotional codes. More often than not it's a complete waste of time.
JoinHoney is a free plugin that finds and gives the best coupon code that you can use withing a few seconds. Say you're using godaddy for new domain, just choose whatever domain name you'd like and open the basket. It will show you the total, form there you can either add a promotional code or proceed to checkout. Now click on JoinHoney icon on top right of screen and click 'Try Codes'. Once that's done you should get the best working coupon for discount. Just apply the coupon and discount will be applied.
Click on 'Add' to add a promotional code/coupon.
Tuesday, 12 January 2016
How to install a program on Linux VPS
Install third party program on VPS
Installing programs on linux really isn't a big deal, just like windows OS if you understand Linux it's a piece of cake, don't let linux command line Shell intimidate you!Here's basic steps you would need to follow to install a software on linux VPS.
- Login to your server using Putty. It's a software for windows that gives you access to Shell. Shell's is just a command line for linux where you can execute commands, except it encrypted all the data.
- You can find your login info in hositing access panel.
- Next download PSCP, Putty Secure Copy. It's a file transfer software.
- SET environment variable so PSCP can be called from command line. Read how to set environemnt variable http://www.computerhope.com/issues/ch000549.htm
- Now run just run pscp.exe PATH_WHERE_FILE_IS_IN_YOUR_PC LINUX_USERNAME@HOSTNAME WHERE_SAVE_ON_LINUX
Ex. pscp.exe c:\files\file.exe webdevtown@my-ipaddress:/home/webdevtown
From here you should follow Author's instructions. You might be required to install java or extract file and run make file command etc..
Thursday, 7 January 2016
OAuth Explained with real world example
OAuth's an authorization standard to access user information from a website that user is member on, without the need to know that user's password.
Problem
Imagine your friend comes up with a website where users post their pictures so others can rate them. He wants users to be able to get all their Facebook picture so they can be processed and uploaded onto his server or linked on his website for others to rate.
Facebook API allows website like this to have access to LIMITED information about user that he/she has granted, but due obvious security reasons facebook cannot allow everyone to access anyone's information. This information's only accessable when user himself grants you access to it.
To get access to user information you would need access to particular facebook API code to which you've been granted access.
Here's a general flow.
1. Your server/client application communicates with OAuth endpoint to make sure you're who you say you are. During this process your client id is being checked. If same client is used on different website google will throw an error. This process doesn't require any action from user side.
2. You send user to authorization page where user allows or denys permission you're asking for. If user allows it, you're sent back to redirect uri with 'Authorization code'.
3. 'Authorization code' now can used to get an 'access token' that you can exchange with server to get user info. Auth code is not sent alone, it's sent along with your secret ID, scope(info you want access to) and redirect URI..
4. Now if you asked user to give permission to access their pictures in step 2. You can use 'access token' to get their pictures and use them on your website for users to rate.
Wednesday, 6 January 2016
How to add google map to website
Embed Google Map to your website
Google map's something that business websites must always have. It's much more convinenent for users to look at map and find where you're located than to get the address, copy paste in google maps and try figuring out if it's the right place. All this is a hassle, if a customer likes your product, there's chances that'd want to visit your place. Don't forget the fact not everyone knows about google maps, or how to check address on online maps.We're going to use 'Google Maps Embed API' to create a map follow these steps:
1. Get your key for google Maps API. To get the key create a new Google Developer project and follow the instructions. When done you should get the Api key. Copy that.
Developer console https://console.developers.google.com/
2. Visit map building area and choose and fill necessary information
https://developers.google.com/maps/documentation/embed/start
3. When done click on 'Looks good', enter your API key and press 'Okay.
3. Google then will give you some HTML code that you'd paste into your website.
4. Copy paste the code in to your website and you should have your own map on your website
Monday, 4 January 2016
Check the Apps that have access to your information and revoke access
Revoke access to app
Just a quick little info about websites storing your details. OAuth gives web developer access token that can be used to access your information that you granted access to when trying to access an app online, sometimes you want to revoke the access as you no longer use their service. Note that you're just revoke that app access, usually developers store all your information in DB on your first login.To check who you're sharing info with:
1. Go to https://myaccount.google.com/
2. In 'Sign in & Security' Tab click 'Connected apps & sites'
3. Under the 'Apps connected to your account' section click on 'Manage apps'.
4. Now you can click on any app and revoke the access. When you click it will also show you the stuff that the app can do on your behalf.
For example, here fiverr app has access to:
-My basic account info
- Age
- Language
- List of people from circle
- Basic profile info
Sunday, 3 January 2016
Decision making if/else in batch programming
Decision making's very important in any programming, not just batch. It allows your program to decide what to do. Here we're going to create a small program where it asks user for password and allows of denies access depending on whether password's right or not.
Here's if statement structure in batch
if CONDITION (
do this
) else (
do this
)
To compare two numbers we use double equal signs '=='. Lets ask our program if 1 is equal to 2.
if 1 == 2 (
echo 1 is equal to 2
) else (
echo 1 is not equal to 2
)
It returns whatever we put in else because 1 is obviously not equal to 2.
Here's our complete script where
1. Turn command display off
2. Get user input and store it in password variable
3. Use if/else statement you just learned. It will only allow access if password is 'webdevtown', anything else it wil echo 'access denied'.
4. Pause so program doesn't exit.
@echo off
SET /p name="Please enter password "
if %name%==webdevtown (
echo Access granted
) else (
echo Access deinied
)
pause
Here's if statement structure in batch
if CONDITION (
do this
) else (
do this
)
To compare two numbers we use double equal signs '=='. Lets ask our program if 1 is equal to 2.
if 1 == 2 (
echo 1 is equal to 2
) else (
echo 1 is not equal to 2
)
It returns whatever we put in else because 1 is obviously not equal to 2.
Here's our complete script where
1. Turn command display off
2. Get user input and store it in password variable
3. Use if/else statement you just learned. It will only allow access if password is 'webdevtown', anything else it wil echo 'access denied'.
4. Pause so program doesn't exit.
@echo off
SET /p name="Please enter password "
if %name%==webdevtown (
echo Access granted
) else (
echo Access deinied
)
pause
How to get user input in batch
Get user input
You'll often need to get some soft of input from user that you can process and perhaps return some data back to user.To syntax to get user input is 'SET /p yourName=[PROMPT MESSAGE]'
Type that in CMD and press enter, then type your name in and press enter again. Now as you'd expect, your name's been stored in 'yourName' vairable, now you can retrieve it.
To see that name user enter. echo the variable 'yourName', note that variable name must between % percent sign, like %variableName%.
Alright, lets ask user for his name and tell him nice to meet you with his name at the end.
Here's how we'd go about it.
1. First off lets disable commands from appearing on screen using command '@alerts off'
2. Prompt user to enter his name using 'SET /p yourName="Enter your username "'. The reason I've surrounded Enter your name with double quote is to add little bit of space after 'username' to when user enter his name there's space between 'username' and his name.
3. Write back to user 'Nice to meet you HIS NAME' by calling the variable 'yourName'
4. Pause so it doesn't exit
@echo off
SET /p name="Please enter your name "
echo Nice to meet you %name%
pause
How to loop in batch programing
What is loop and how it works
Loopping is when you need to do a certain task again and again.Lets say your friend's been pissing you off lately and you decide to annoy him by creating a little prank virus that open a program again and again until the process is terminated.
Lets start, lets open notepad once.
You can open any program in your computer by using start command. 'start' command executes a program that's in front of it. You can also use full path to that program. If you save following code in batch file and run it you will see notepad opening.
start notepad.exe
Goto loop
Go to loop uses label to repeat itself. What's inside loop commands will execute. Having notepad.exe inside 'goto' loop will make notepad.exe open again and again.To start loop we define a label. Label's a part of code where loop starts, and goto is a command that tells CMD to go back to where the label is. Let me give an example to make it clear:
1. We define ':label'. Note label must have ':' color before it's name, and it can be named anything.
2. We tell it what to do while it's looping(loop body)
3. We tell it to go back to label.
:thisIsLabel
echo hi
goto thisIsLabel
Above code will echo 'hi' until CMD is closed.
Same thing can be done for our little notepad.exe prank. We replace 'echo hi' command with our start command and name of program that you'd want to open.
Back to batch basics
Saturday, 2 January 2016
Favorite websites opener
Quickly load your favorite websites with one click only
Well this is a little bot I created for myself, thought this may be useful for others too. Basically I often create threads on different forums about certain stuff, and when I come back from work or something I wanna open all those threads quickly as possible. So I wrote this little batch script this will open all the links in the file.
Source code
@echo off
echo For more bots or website development tutorials visit www.webdevtown.com
color 05
start firefox.exe
TIMEOUT 5
start www.google.com
start www.youtube.com/feed/subscriptions
start www.codernation.net
pause
How to use(firefox needed*)
Download
https://dl.dropboxusercontent.com/u/28490184/webdevtown/Favorite websites opener.bat
Virus scan
https://www.virustotal.com/en/file/f5a6c646d83ca926ca0eb2590fae57902be90142a8a02c94f3615f32c4c73736/analysis/1451781744/
https://www.hybrid-analysis.com/sample/f5a6c646d83ca926ca0eb2590fae57902be90142a8a02c94f3615f32c4c73736?environmentId=4
Well this is a little bot I created for myself, thought this may be useful for others too. Basically I often create threads on different forums about certain stuff, and when I come back from work or something I wanna open all those threads quickly as possible. So I wrote this little batch script this will open all the links in the file.
Source code
@echo off
echo For more bots or website development tutorials visit www.webdevtown.com
color 05
start firefox.exe
TIMEOUT 5
start www.google.com
start www.youtube.com/feed/subscriptions
start www.codernation.net
pause
Download the program, right click and edit.
Download the program, right click and edit.
Download the program, right click and edit. Write 'start WEBSITE' where WEBSITE is URL of site you want to open. One URL in each line.Download
https://dl.dropboxusercontent.com/u/28490184/webdevtown/Favorite websites opener.bat
Virus scan
https://www.virustotal.com/en/file/f5a6c646d83ca926ca0eb2590fae57902be90142a8a02c94f3615f32c4c73736/analysis/1451781744/
https://www.hybrid-analysis.com/sample/f5a6c646d83ca926ca0eb2590fae57902be90142a8a02c94f3615f32c4c73736?environmentId=4
Subscribe to:
Comments (Atom)



