Freelance Jobs Freelance Jobs

Sunday, May 23, 2010

Twiter Blocked in Pakistan

Twitter is now blocked in the Pakisatan. Pakistani authorities already blocked facebook, and Youtube in Pakistan.


It mean now Pakistani users cannot log in to Twitter. The browser displayed a message “this site is restricated.”, when users tried to browse the site.

Pakistani Telecommunication Authority said that due to “sacrilegious contents”, Twitter is blocked in the Pakistan.Pakistani Authorities has been blocked more thatn 450 url in Pakistan.

Sunday, May 9, 2010

Installation of CakePHP


System Requirement

  • Http Server should be enabled
  • mod_rewrite should be enabled

Installation of cakephp

Follow the following step to install the cakephp:
  • Download the zip file from cakephp.org site
  • Create a new folder, which has same name as your site's name, in xampp/htdocs folder in your local drive
  • Extract the zip file in this folder


Database configuration in cakephp

Follow the following step to database configuration in cakephp
Create a new database in mysql or in database engine which you want to use.
Open the file xampp\htdocs\your_ site's_name\app\config\database.php
In this file there is two variable $default and $test are defined in class DATABASE_CONFIG
$default is used unless user does not specify another connection by $useDbConfig  property of a model.

Change the following code
'driver' => 'mysql',
  'persistent' => false,
  'host' => 'localhost',
  'login' => 'root',
  'password' => '',
  'database' => ' ',
  'prefix' => '',

driver: The name of database driver which is used to create database. You can use mysql, oracle, odbc etc. If you want to use datasource leave this field blank.

persistent : This is used to set database connection be persistent or not. If we set it true, the connection be persistent and if we set if false, the connection be non-persistent.

host: This is  host name of database's server.

login: This is login name of the database's server.

password : This is password of the database's server.

database: This is name of the database.

prefix: If the database tables has prefix, then set the prefix value here otherwise leave it blank

Wednesday, May 5, 2010

Content Management System

CMS, stands for content management system, is an application that makes content authoring and deploying easy. It allow multiple user to manage, deploy, edit, content on the base of their role.

CMS is based on the content. The content can be anything which is used to display data into application. For example, in a website, content can be text, menus, images, banner, block, etc which are used to display the site to end user. The content can be as per the requirement of the application. For example, a sports site contains different content rather than movie's web site. CMS is used for storing, managing, publishing, deploying of all type of content.

Using CMS, a person who does not have the knowledge of web developing, can work on the site. Basically, in cms the developer and content writer work differently. The developer develop the application and content writer modify, publish, edit the content of the application. Thus, the developer and content write work on the same application without interfering each other's work.

There are number of CMS available:

CMS in PHP
  • Joomla
  • Drupal
  • Wordperss
  • PHP-fusion
  • PHP-Nuke
  • Mambo

CMS in java
  • Dspace
  • Fedora
  • dotcms
  • japs
CMS in .net

  • dotnetnuke
  • umbraco
  • mojoportal

Tuesday, April 27, 2010

Introduction to CakePHP

CakePHP is open source web developing framework of PHP for creating web applications. It provides programmer a foundational structure to create a web applications.

CakePHP is based on the MVC architecture to create a web applications. It means that business logic(Model), user action(controller) and data presentation to user(View) are different from each other.

Controller: Controller contains the logic of user's application. The different functionality are contained by each controller. It used models to retrieve data from database or save data to database. It also set variable which is used to render data in view file.

Models: Models directly connected to database tables. It retrieve data from database and send it to controller, get data from controller and save it to database. Models behave like medium between controller and database tables. The models is interact with controller but not interact with view.

Views: view is used to present data to end user. It gets the variable from controller and display it to end user. View contains layout, element, for data presentation but no logic to retrieve data from database.

Since cakephp is open source so any body can download it from www.cakephp.org and install it and can work. There is no need of license fee to work in cakephp. You have to knowledge of PHP to start work in cakephp.


Folder Structure

When we download the cakephp from site, it is a zip file. After extracting it, the following files and folder you should see:

  1. app
  2. cake
  3. vendors
  4. .htaccess
  5. index.php
  6. README

All the applications file of the user are placed in app folder.
All the file of cakephp are placed in cake folder.
The third party files are placed in vendors folder.


App folder:

The app folder contains following files and folder:

config :
The config folder contains the following files and folder

database.php : It is used to database configuration.

routes.php : It is used to set up routes to user controllers and their actions. The routes is a mechanism which allow user to freely connect different urls to chosen controllers and their actions.

bootstrap.php: This file is automatically loaded by the app/webroot/index.php file after the core bootstrap.php. This file is used to include or require any files in user's application. This is application wide file that is used to load any function that is not used within a class define.

core.php : It is used to configure core behavior of cake.

controllers: It contains the controller of the user's application.

locale: It contains the files that is used for internationalization.

models: It contains models, behavior of the user's application

plugins: It contains plugin package of user's application.

tmp: It contains temporary file of user's application. This folder is used to store model descriptions,
log, caching, session information.

vendors: It contains the third party files to used in user's application. The file placed in this folder can be accessed in application using App::import('vendors','name');. The vendors folder is placed also at top level. The top level vendors folder contains third party file for user's all application but if user is creating multiple applications then he can placed third party files in this folder to use for specific application.

views: It contains view file, layout file, elements, error page of user's application.

webroot: This folder serve as document root for user's application. It contians css stylesheet, javascript file, image for user's application.

Monday, April 26, 2010

Validation in CakePHP

In a website, some time user need to insert data into database. User can insert inappropriate data to database, different from the database data type or requirement of the site. So, we need to use validate data before inserting it into database.
Suppose in user registration form, there is field like user name, password, confirm password, first name, last name, email id. User name require only alphanumeric character and not empty field, email should be valid email address and not empty field, password should be at least 8 character and not empty field, confirm password should match with the password field, first name and last name should be alpha character and not empty field.
If we will not validate data according to condition of certain field, then whatever user insert, it will store into database. This is not a good programming practice.

Validation is require to check user's data before storing in database. For validation, we check user's data according to condition specific to field.

As we know, cakephp is a framework of php which is a model-view-controller architecture. If you don't have basic knowledge of cakephp, first you have to learn about it.
In cakephp, we use validate variable to set the condition for validating user's data. We write this variable in our model. Suppose we want to validate user registration form, then there will be user model, users controller, registration view file in our cake php.


In user model

var $validate=arra('uname'=>array('notEmpty'=>array(
'rule' => 'notEmpty',
'required' => true,
'message'=>'could not be empty',
'last' => true
),
'alphaNumeric'=>array(
'rule' => 'alphaNumeric',
'required' => true,
'message'=>'only alpha and number are allowed',
'last' => true
),
),
'passwd'=>array('notEmpty' => array(
'rule' => 'notEmpty',
'required' => true,
'message'=>'could not be empty',
'last' => true
)),
'email'=>array('notEmpty' => array(
'rule' => 'notEmpty',
'required' => true,
'message'=>'could not be empty',
'last' => true
)),
'fname'=>array('notEmpty' => array(
'rule' => 'notEmpty',
'required' => true,
'message'=>'could not be empty',
'last' => true
)),
'lname'=>array('notEmpty' => array(
'rule' => 'notEmpty',
'required' => true,
'message'=>'could not be empty',
'last' => true
)),
);




In users controller, register function

function register() {

if(isset($this->data))
{
$this->User->set($this->data);

/*$this->User->validates() use to validate user's data according to validate variable in user model*/
if($this->User->validates())
{
$this->User->save($this->data);
$this->Session->setFlash('Data has been saved');
$this->autoRender=false;
$this->redirect('index');
}
else
{
$this->set('errorMessage','Please correct below error');

}
}
}


Register view

$form->create('User',array('action'=>'register'));
print ""; print $form->label('User Name'); print $form->text('uname',true).$form->error('uname'); print $form->label('Password'); print $form->password('passwd').$form->error('passwd'); print $form->label('Email'); print $form->text('email').$form->error('email'); print $form->label('First Name'); print $form->text('fname').$form->error('fname') print $form->label('Last Name'); print $form->text('lname').$form->error('lname'); print $form->end('Register'); ?>


$form->error('uname') is used to display error in the output. If we are using $form->input then we don't need to use this variable to show error. But if we are using $form->text, then we need to use $form->error to show the error in the output.
In $form->error('fieldname'), fieldname is your database field name as model is automatically connected to database table in cakephp.

Saturday, April 10, 2010

MVC(Model-View-Controller)

MVC(Model-View-Controller) is an architecture which separate data presentation(View), domain logic(Model) and user interaction and processing(Controller) with each other. The concept behind this is to changing the data presentation does not affect the business logic and processing, changing the business logic does not affect the user presentation and processing.

Now days, the software engineer is using MVC architecture to develop the program. MVC architecture allow the programmer to reuse object code.

Model:

In MVC, model means the domain logic of the data. It encapsulates data and functionality domain logic. While creating model, its no concern that how data be look and feel to the user. Its contains the functions which process on the data. These functions be public which accessed in view and controller.

View:

In MVC, view means data presentation to the user. View obtains data result set from model and render it to user. The output of any application be generated in view. View can access the model but can not change the state of the model.

Controller:

In MVC, controller receives the input from user, call responsible model. The controller is not act like bridge between the model and view. Its only responsible to calling responsible model to user input and informs the view that state of model has been changed.

Tuesday, April 6, 2010

Image Hosting Site

Since the popularity of the online auction, blogs, forums are increasing day by day in the internet, the demand of the image hosting service are increasing.

The web hosting service offer user to uploaded image and provide a url of the image. The user can use image in anywhere in the internet using this url of the image.

Now days, Image hosting business has been expanded well and attracted almost 85% of the audience market around the world.

The image hosting site offer free user to upload limited images while premium members to upload unlimited images. There are number of image hosting site which are providing the service to the user. 

The process of uploading image is very simple and easy.  User need to only browse image from his computer and upload the image into website server. The server provides the url of the image to user. The site allow user to upload image in many format like jpeg, png, gif.

The list of image hosting site:




Here is list of some image hosting site. Its very easy to search free image hosting site through Google. Anyone can find the site through the Google. Choose any image hosting site and plan as per your requirement. For limited image upload, choose free membership and for unlimited upload of image choose premium membership of the site