Tuesday 17 December 2013

Get date of seventh day from today using javascript

Here, i posted the code below to get the date of seventh day from today using javascript.

Code:

 step:1
 var date = new Date();   //to get current day's date with GMT
//i.e, the variable date outputs as Tue Dec 17 2013 00:48:41 GMT+0530 (India Standard Time)

 step:2 
 date.setDate(date.getDate() + 7);
//Now the variable date holds the timestamp of the seventh'day from today i.e, 1387826522433

  step:3
 var dateMsg = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
alert(dateMsg); 
 //just checking with a alert , 
 alert(dateMsg); 
//Now variable  dateMsg outputs with format as 2013-12-24,

Finally ,we displayed the date of the seventh day from today using javascript.
 
 alert(dateMsg);


Monday 9 December 2013

Creating Skeleton App for Yii in Ubuntu

To install Yii, you need to get the latest version and extract it somewhere in your  server’s web root,

 probably here i extract it in  /opt/lampp/htdocs/

here i renamed the extract folder name as yii-1.1.14, after that you have to change the permission of the folder as 0755 to execute yiic file, so that it is executable.


root@mindzls002-desktop:/home/mindzls002# sudo chmod -R 0755 /opt/lampp/htdocs/yii-1.1.14/

Before creating your skeleton app , we want to verify that your server satisfies Yii's requirements.
Yii requires PHP 5.1, so the server must have PHP 5.1 or above installed and available to the web server.

 To check that your server meets the requirements, simply run the below url in your web browser,

      http://localhost/yii-1.1.14/requirements/
 If your server the passes the requirements, then the run the below command in your terminal,

root@mindzls002-desktop:/home/mindzls002#  /opt/lampp/bin/php  /opt/lampp/htdocs/yii-1.1.14/framework/yiic.php  webapp  /opt/lampp/htdocs/cabel

In the above code,

i) first path refers to location of php,
ii)  second path refers to the location of yiic.php (i.e. the file located in the folder         that we extract in your web root initially)
iii) third path refers to where we want to create a skeleton app. Here i created a skeleton app named cabel.

After you run the above code in terminal , a message is prompted in terminal for verification as

  Create a Web application under '/opt/lampp/htdocs/cabel'? (yes|no) [no]:

  type yes and hit enter. The terminal runs the following codes,

mkdir /opt/lampp/htdocs/cabel
   generate index.php
      mkdir /opt/lampp/htdocs/cabel/css
   generate css/main.css
   generate css/form.css
   generate css/screen.css
   generate css/ie.css
   generate css/bg.gif
   generate css/print.css
      mkdir /opt/lampp/htdocs/cabel/images
      mkdir /opt/lampp/htdocs/cabel/protected
   generate protected/yiic
      mkdir /opt/lampp/htdocs/cabel/protected/tests
      mkdir /opt/lampp/htdocs/cabel/protected/tests/unit
      mkdir /opt/lampp/htdocs/cabel/protected/tests/report
   generate protected/tests/phpunit.xml
      mkdir /opt/lampp/htdocs/cabel/protected/tests/functional
   generate protected/tests/functional/SiteTest.php
   generate protected/tests/WebTestCase.php
      mkdir /opt/lampp/htdocs/cabel/protected/tests/fixtures
   generate protected/tests/bootstrap.php
      mkdir /opt/lampp/htdocs/cabel/protected/runtime
   generate protected/yiic.php
      mkdir /opt/lampp/htdocs/cabel/protected/data
   generate protected/data/schema.sqlite.sql
   generate protected/data/testdrive.db
   generate protected/data/schema.mysql.sql
      mkdir /opt/lampp/htdocs/cabel/protected/vendor
      mkdir /opt/lampp/htdocs/cabel/protected/components
   generate protected/components/Controller.php
   generate protected/components/UserIdentity.php
   generate protected/.htaccess
      mkdir /opt/lampp/htdocs/cabel/protected/views
      mkdir /opt/lampp/htdocs/cabel/protected/views/layouts
   generate protected/views/layouts/main.php
   generate protected/views/layouts/column1.php
   generate protected/views/layouts/column2.php
      mkdir /opt/lampp/htdocs/cabel/protected/views/site
   generate protected/views/site/index.php
      mkdir /opt/lampp/htdocs/cabel/protected/views/site/pages
   generate protected/views/site/pages/about.php
   generate protected/views/site/contact.php
   generate protected/views/site/error.php
   generate protected/views/site/login.php
      mkdir /opt/lampp/htdocs/cabel/protected/commands
      mkdir /opt/lampp/htdocs/cabel/protected/commands/shell
      mkdir /opt/lampp/htdocs/cabel/protected/migrations
      mkdir /opt/lampp/htdocs/cabel/protected/config
   generate protected/config/console.php
   generate protected/config/main.php
   generate protected/config/test.php
      mkdir /opt/lampp/htdocs/cabel/protected/extensions
      mkdir /opt/lampp/htdocs/cabel/protected/controllers
   generate protected/controllers/SiteController.php
   generate protected/yiic.bat
      mkdir /opt/lampp/htdocs/cabel/protected/messages
      mkdir /opt/lampp/htdocs/cabel/protected/models
   generate protected/models/LoginForm.php
   generate protected/models/ContactForm.php
      mkdir /opt/lampp/htdocs/cabel/themes
      mkdir /opt/lampp/htdocs/cabel/themes/classic
      mkdir /opt/lampp/htdocs/cabel/themes/classic/views
   generate themes/classic/views/.htaccess
      mkdir /opt/lampp/htdocs/cabel/themes/classic/views/system
      mkdir /opt/lampp/htdocs/cabel/themes/classic/views/layouts
      mkdir /opt/lampp/htdocs/cabel/themes/classic/views/site
      mkdir /opt/lampp/htdocs/cabel/assets
   generate index-test.php

Your application has been created successfully under /opt/lampp/htdocs/cabel.

 Then Bingo, yii has successfully created the skeleton app for your project.
 Now you have to change the folder permission of the created skeleton app folder(cabel) to run it on browser.

run the below code in terminal,
root@mindzls002-desktop:/home/mindzls002# chmod -R 0555 /opt/lampp/htdocs/cabel/
root@mindzls002-desktop:/home/mindzls002# chmod -R 0777 /opt/lampp/htdocs/cabel/protected/

Finally you have created the yii skeleton app, now run the below url in your web browser to view the welcome screen,

    http://localhost/cable/

 that's it, 




    

   
   














Saturday 2 November 2013

Simple FAQ System Using Php


This is a basic and simple faq like Q&A application developed using php and Codeigniter.

For design twitter bootstrap is used.

Features Included, below are some,

Admin can Manage
1) Users
2) Question categories
3) User posted questions and answers
4) Users

User can
1) Ask a question
2) Post an answer to question others posted.
3) also add an comment to answer.
4) View the list of question and answers posted by him

General
1) Only logged in user can post a question or answer.
2) Pagination included.

This is only a minimal version not yet a completed version.
You can download it from here,  FAQ System Using Php

Friday 24 May 2013

Install Laravel 4 on Ubuntu


Recently i willing to learn laravel framework because of its rich features towards web development and that borrows a lot from Rails.In previous i have used the CodeIgniter for my projects.

This post is mainly for beginners, To Install laravel 4 on ubuntu 12.04

Installing Composer:

To install composer via terminal , type the command

# curl -sS https://getcomposer.org/installer | php

Move the composer to usr/local/bin to access composer globally

# mv composer.phar /usr/local/bin/composer
check if the composer is available globally by simply type
#  composer

Installing Laravel:

To install laravel via Git Clone repository first you have to install Git on your machine , if Git is installed in your machine then clone Laravel git repository as

# git clone https://github.com/laravel/laravel.git /opt/lampp/htdocs/lara_test1
 here lara_test1 our newly created project directory for installing laravel , To view the files inside the newly created project folder
#  cd  /opt/lampp/htdocs/lara_test1
#  ls
 To install composer to our project directory
#  composer install
while installing composer if the error thrown such as 
               Laravel requires the Mcrypt PHP extension.
 then you have to install the mycript library , for that simply use
# sudo apt-get install php5-mcrypt
and after that again re-install composer , it may fix issues.

And finally  open your web browser and simply go to
  http://localhost/lara_test1/public/
 Also , dont forget to change the persmission of folders within app/storage .
 

 Every thing goes fine, you welcome with laravel's  default message with Logo.


You have arrived.