Install Cordova/Phonegap on Window

Installing Cordova on Windows

This document describes how to install Apache Cordova and the Android SDK on a Windows machine. This is a quite complex process, which may take some time depending on your previous experience with installing SKDs and build tools. Care has been taken when writing this document to include all the essential steps needed to get you up and running with a successful install. Kindly let us know if there is something you are missing.
To develop Android apps, you need to install the Android SDK, and also Java if not already installed on your machine. Furthermore the build tool Ant is required.
For the Android SDK, you have the choice between installing the ADT bundle that incudes Eclipse (ADT = Android Developer Tools), or the Android SDK Tools, that does not include Eclipse. In the steps below we will use the Android SDK Tools download.

Install Cordova

Follow these steps to install Cordova:
  1. Install Node.js. Cordova runs on the Node.js platform, which needs to be installed as the first step. Download installer from: http://nodejs.org
  2. Go ahead an run the downloaded installation file. It is recommended to use the default settings. Node.js needs to be added to the PATH environment variable, which is done by default.
  3. To test the installation, open a command window (make sure you open a new command window to get the updated path settings made by the Node.js installation), and type:
    node --version
    If the version number is displayed, Node.js is installed and working!
  4. Install Git. Git is a version control system, which is used by Cordova behind-the-scenes. Download and install from: http://git-scm.com. Default settings are recommended.
  5. Install Cordova. Cordova is installed using the Node Package Manager (npm). Type the following in the command window to install:
    npm install -g cordova
  6. Test the Cordova install by typing:
    cordova --version
    If you see the version number, you have successfully installed Apache Cordova!

Install Java

The Android SDK needs the Java Development Kit (JDK) to be installed (minimum version 1.6). Note that the Java Runtime Environment (JRE) is not sufficient, you will need the JDK. To check if you have the JDK installed already, type this on the command line:
javac -version
If you do not have the JDK installed, proceed as follows:
  1. Download the Java SE JDK (SE = Standard Edition) from Oracle:www.oracle.com/technetwork/java/javase/downloads/. Click the Java SE Download to see the list fo download. Get the "Windows x86" download if you have 32-bit Windows, and "Windows x64" if you have 64-bit Windows. If you do not know which version you have, find out using the Control Panel by selecting "System and Security" and then "System", where you will find the "System type" saying if your Windows version is 32-bit or 64-bit.
  2. Go along and run the downloaded installer file. Using the default selections should be fine, but take a note of the directory in which you install the JDK. You will need to add this to the PATH in a later step below.
  3. Next, update your path to include the JDK. Open the Control Panel, click System and Security, click System, click Change settings, which will open the System Properties window. Select the Advanced tab, then click theEnvironment Variables button.
  4. In the list User variables select PATH and click the Edit button. (If there is no PATH entry in the list, click the New button to create one.)
  5. At the end of the field Variable value, add a semicolon followed by the path to the bin directory of the JDK install. Here is an example (note that this must be the actual path used for the install on your machine):
    ;C:\Program Files\Java\jdk1.8.0_11\bin
    An easy way to do this is to prepare the path to add in a text editor, then paste it at the end of the input field. When done click the OK button.
  6. Next add the JAVA_HOME variable if it is not present (and if it is in the list, you may need to update its value using the Edit button). Click the New button. In the field Variable name type:
    JAVA_HOME
    In the field Variable value enter the path to the directory where the JDK is installed, without the semicolon and the /bin subdirectory, for example:
    C:\Program Files\Java\jdk1.8.0_11
    Click the OK button.
  7. Click the OK button again to close the Environment Variables window.
  8. Now you are ready to test the install. Close any open command windows, and open a new command window and type:
    javac -version
    If you see a version number you are done with the JDK install!

Install Ant

Apache Ant is a build system for Java, which is used by Cordova and the Android SDK. To install Ant, follow these steps:
  1. Download Ant from here: ant.apache.org/bindownload.cgi. Get the zip download available at the page. Click the zip-file link for the most recent release, e.g. apache-ant-1.9.4-bin.zip, and save the file to your machine.
  2. Unpack the zip file to the directory on your machine where you want Ant to be installed. You can pick any directory for the install. In this guide we use this as an example:
    C:\Users\miki\ant
    Note that the files in the ant package should go directly into this directory. Make a note of the directory as you will need to add it to the PATH.
  3. To add Ant to the PATH, open the Control Panel, click System and Security, click System, click Change settings, click the Advanced tab, then click the Environment Variables button.
  4. In the list User variables select PATH and click the Edit button.
  5. At the end of the field Variable value, add a semicolon followed by the path to the bin directory of the Ant install. Here is an example:
    ;C:\Users\miki\ant\bin
    Click the OK button.
  6. Next add the ANT_HOME variable. Click the New button. In the field Variable name type:
    ANT_HOME
    In the field Variable value enter the path to the directory where Ant is installed, without the semicolon and the /bin subdirectory, for example:
    C:\Users\miki\ant
    Click the OK button.
  7. Click the OK button again to close the Environment Variables window.
  8. Now test the install. Close any open command windows, and open a new command window and type:
    ant -version
    If you see a version number you have installed Ant successfully!

Install the Android SDK Tools

The SDK Tools for Android are used by Cordova to build Android apps. Follow these steps to install the SDK Tools:
  1. Go to the page developer.android.com/sdk scroll down the page and click "VIEW ALL DOWNLOADS AND SIZES". Under "SDK Tools Only", click the windows installer exe file and download it (this file is named e.g.installer_r23.0.2-windows.exe).
  2. When downloaded, run the installer. You should do fine to use the default settings used by the installer, but make a note of the directory in which the SDK is installed, as you will have to add this to the PATH in the next step.
  3. To add the SDK Tools to the PATH, open the Control Panel, click System and Security, click System, clickChange settings, click the Advanced tab, then click the Environment Variables button.
  4. In the list User variables select PATH and click the Edit button.
  5. At the end of the field Variable value, add a semicolon followed by the path to the tools and platform-toolsdirectores of the Android SDK install. Here is an example of what to add (note that there are two paths in one line, separated by a semicolon):
    ;C:\Users\miki\AppData\Local\Android\android-sdk\tools;C:\Users\miki\AppData\Local\Android\android-sdk\platform-tools
    You can prepare the path in a text editor, copy it and paste at the end of the input field. Click the OK button when done.
  6. Click the OK button again to close the Environment Variables window.
  7. Now test the install. Close any open command windows, open a new command window and type:
    adb version
    This should display the version of the Android Debug Bridge.
  8. As the final step, you need to get the specific Android SDK version used by Cordova. This is done by running the Android SDK Manager by typing the command:
    android
    This launches a window where you can select to install specific Android SDKs.
  9. First time you launch the Android SDK Manager there will be preset selections. It is recommended to leave these untouched. Also select the entry "Android 4.4.2 (API 19)". This is the version used by the current Cordova 3.5 version. Note that the Android SDK required by Cordova will change in the future, as new versions of Cordova and Android are released. When this happens, open the Android SDK Manager again, and install the required API version(s).

If You Get Stuck

If you get stuck, consult the documentation at the respective web sites for Cordova, Java, Ant, and Android. The Cordova documentation specific for Android is found here:cordova.apache.org/docs/en/3.6.0/guide_platforms_android_index.md.html. You are also welcome to ask for help at theEvothings Forum.
One thing to do is to inspect all the environment variables. You can do this from a command window (note that you have to open a new command window after updating environment variables for updated values to be available). This displays the system PATH:
echo %PATH%
Here is how to inspect the values of JAVA_HOME and ANT_HOME:
echo %JAVA_HOME%
echo %ANT_HOME%

Get random password / Keys

<?php

// Get random password
function get_random_password($chars_min=8, $chars_max=12, $use_upper_case=true, $include_numbers=true, $include_special_chars=true)
    {
        $length = rand($chars_min, $chars_max);
        $selection = 'aeuoyibcdfghjklmnpqrstvwxz';
        if($include_numbers) {
            $selection .= "1234567890";
        }
        if($include_special_chars) {
            $selection .= "!@\"#$%&[]{}?|";
        }

        $password = "";

        for($i=0; $i<$length; $i++) {
            $current_letter = $use_upper_case ? (rand(0,1) ? strtoupper($selection[(rand() % strlen($selection))]) : $selection[(rand() % strlen($selection))]) : $selection[(rand() % strlen($selection))];          
            $password .=  $current_letter;
        }              
      return $password;
    }

?>
AND CALL THIS :-
<?php
$random_key = get_random_password($chars_min=6, $chars_max=8, $use_upper_case=true, $include_numbers=true, $include_special_chars=false);

echo $random_key;
?>

Cake PhP

PHP mail using SMTP


In Codigniter is use this PHP Code to send mail using SMTP

Simple Mail Transfer Protocols :)


        $mail = array();
        $mail["protocol"] = "smtp";
        $mail["smtp_host"] = "ssl://p3plcpnl019.prod.phx3.secureserver.net";
        $mail["smtp_port"] = 465;
        $mail["smtp_user"] = "Your Email Address";
        $mail["smtp_pass"] = "Your Address";
      
         $this->load->library("email", $mail);
         $this->email->set_newline("\r\n");
        
         //set email information and content
         $this->email->from("support@gerosport.com", "GeroSport");
         $this->email->to($to);
        
         $this->email->subject($subject);
   
         $this->email->message($msg);
        
         if($this->email->send())
         {
            $response = 1;
         } else {
            $response = 0;
         }



Also i get help from :-
http://asif18.com/7/php/send-mails-using-smtp-in-php-by-gmail-server-or-own-domain-server/

Building a RESTful Web API with PHP and Apify

Apify is a small and powerful open source library that delivers new levels of developer productivity by simplifying the creation of RESTful architectures. You can see it in action here. Web services are a great way to extend your web application, however, adding a web API to an existing web application can be a tedious and time-consuming task. Apify takes certain common patterns found in most web services and abstracts them so that you can quickly write web APIs without having to write too much code.
Apify exposes similar APIs as the Zend Framework, so if you are familiar with the Zend Framework, then you already know how to use Apify. Take a look at the UsersController class.

Building a RESTful Web API

In Apify, Controllers handle incoming HTTP requests, interact with the model to get data, and direct domain data to the response object for display. The full request object is injected via the action method and is primarily used to query for request parameters, whether they come from a GET or POST request, or from the URL.
Creating a RESTful Web API with Apify is easy. Each action results in a response, which holds the headers and document to be sent to the user’s browser. You are responsible for generating the response object inside the action method.
class UsersController extends Controller
{
public function indexAction($request)
{
// 200 OK
return new Response();
}
}
The response object describes the status code and any headers that are sent. The default response is always 200 OK, however, it is possible to overwrite the default status code and add additional headers:
class UsersController extends Controller
{
public function indexAction($request)
{
$response = new Response();

// 401 Unauthorized
$response->setCode(Response::UNAUTHORIZED);

// Cache-Control header
$response->setCacheHeader(3600);

// ETag header
$response->setEtagHeader(md5($request->getUrlPath()));

// X-RateLimit header
$limit = 300;
$remaining = 280;
$response->setRateLimitHeader($limit, $remaining);

// Raw header
$response->addHeader('Edge-control: no-store');

return $response;
}
}
Content Negotiation
Apify supports sending responses in HTML, XML, RSS and JSON. In addition, it supports JSONP, which is JSON wrapped in a custom JavaScript function call. There are 3 ways to specify the format you want:
  • Appending a format extension to the end of the URL path (.html, .json, .rss or .xml)
  • Specifying the response format in the query string. This means a format=xml or format=json parameter for XML or JSON, respectively, which will override the Accept header if there is one.
  • Sending a standard Accept header in your request (text/html, application/xml or application/json).
The acceptContentTypes method indicates that the request only accepts certain content types:
class UsersController extends Controller
{
public function indexAction($request)
{
// only accept JSON and XML
$request->acceptContentTypes(array('json', 'xml'));

return new Response();
}
}
Apify will render the error message according to the format of the request.
class UsersController extends Controller
{
public function indexAction($request)
{
$request->acceptContentTypes(array('json', 'xml'));

$response = new Response();
if (! $request->hasParam('api_key')) {
throw new Exception('Missing parameter: api_key', Response::FORBIDDEN);
}
$response->api_key = $request->getParam('api_key');

return $response;
}
}
Request
GET /users.json
Response
Status: 403 Forbidden
Content-Type: application/json
{
"code": 403,
"error": {
"message": "Missing parameter: api_key",
"type": "Exception"
}
}
Resourceful Routes
Apify supports REST style URL mappings where you can map different HTTP methods, such as GET, POST, PUT and DELETE, to different actions in a controller. This basic REST design principle establishes a one-to-one mapping between create, read, update, and delete (CRUD) operations and HTTP methods:
HTTP MethodURL PathActionUsed for
GET/usersindexdisplay a list of all users
GET/users/:idshowdisplay a specific user
POST/userscreatecreate a new user
PUT/users/:idupdateupdate a specific user
DELETE/users/:iddestroydelete a specific user

If you wish to enable RESTful mappings, add the following line to the index.php file:
try {
$request = new Request();
$request->enableUrlRewriting();
$request->enableRestfulMapping();
$request->dispatch();
} catch (Exception $e) {
$request->catchException($e);
}
The RESTful UsersController for the above mapping will contain 5 actions as follows:
class UsersController extends Controller
{
public function indexAction($request) {}
public function showAction($request) {}
public function createAction($request) {}
public function updateAction($request) {}
public function destroyAction($request) {}
}
By convention, each action should map to a particular CRUD operation in the database.

Building a Web Application

Building a web application can be as simple as adding a few methods to your controller. The only difference is that each method returns a view object.
class PostsController extends Controller
{
/**
* route: /posts/:id
*
* @param $request Request
* @return View|null
*/
public function showAction($request)
{
$id = $request->getParam('id');
$post = $this->getModel('Post')->find($id);
if (! isset($post->id)) {
return $request->redirect('/page-not-found');
}

$view = $this->initView();
$view->post = $post;
$view->user = $request->getSession()->user

return $view;
}

/**
* route: /posts/create
*
* @param $request Request
* @return View|null
*/
public function createAction($request)
{
$view = $this->initView();
if ('POST' !== $request->getMethod()) {
return $view;
}

try {
$post = new Post(array(
'title' => $request->getPost('title'),
'text' => $request->getPost('text')
));
} catch (ValidationException $e) {
$view->error = $e->getMessage();
return $view;
}

$id = $this->getModel('Post')->save($post);
return $request->redirect('/posts/' . $id);
}
}
The validation is performed inside the Post entity class. An exception is thrown if any given value causes the validation to fail. This allows you to easily implement error handling for the code in your controller.
Entity Class
You can add validation to your entity class to ensure that the values sent by the user are correct before saving them to the database:
class Post extends Entity
{
protected $id;
protected $title;
protected $text;

// sanitize and validate title (optional)
public function setTitle($value)
{
$value = htmlspecialchars(trim($value), ENT_QUOTES);
if (empty($value) || strlen($value) < 3) {
throw new ValidationException('Invalid title');
}
$this->title = $title;
}

// sanitize text (optional)
public function setText($value)
{
$this->text = htmlspecialchars(strip_tags($value), ENT_QUOTES);
}
}
Routes
Apify provides a slimmed down version of the Zend Framework router:
$routes[] = new Route('/posts/:id',
array(
'controller' => 'posts',
'action' => 'show'
),
array(
'id' => '\d+'
)
);
$routes[] = new Route('/posts/create',
array(
'controller' => 'posts',
'action' => 'create'
)
);
HTTP Request
GET /posts/1
Incoming requests are dispatched to the controller “Posts” and action “show”.

Featured post

A23 Rummy - Safe Secure Gaming Platform

A23 Rummy is a popular online rummy platform in India. It is owned and operated by Head Digital Works Private Limited. The platform offers...