Translate

Friday, 16 November 2018

Laravel 5.2 By Anjana Janani

Laravel 5.2 Basic Steps

1. Install composer from https://getcomposer.org

2. Run command:
    composer create-project --prefer-dist laravel/laravel oposurge "5.2.*"
3. Cut all files/folders from "Public" folder to Root folder of project.
    Ex- [PATH_TO_HTDOCS_FOLDER]\anjana\project\oposurge\public TO             
           [PATH_TO_HTDOCS_FOLDER]\anjana\project\oposurge

4. Change Path which is related to bootstap repo. (Remove extra ../)
    [PATH_TO_HTDOCS_FOLDER]\anjana\project\oposurge\index.php

5. You can see now first page by running your root folder of project.
    Ex- http://localhost/anjana/project/oposurge/

6.  Change environment setting in .env file & .env.example file 
     DB_DATABASE => oposurge
     DB_USERNAME => root
     DB_PASSWORD => 
     APP_ENV => local
     APP_URL => http://localhost/anjana/project/oposurge/

7. For creating tables into your database, you can do with migrate command:
    A. Create migration table wise for your whole project
         Run command (first target root folder of your project in cmd) -
          php artisan make:migration create_post_table
         This will create a file in Database repo / migrations / of your root repo.
 
     B. Open the created file of migration. (It will be in       
          [PATH_TO_HTDOCS_FOLDER]\anjana\project\oposurge\database\migrations\)

     C. You can add your required columns \ indexes \ tables in up() method. down()
           method will  reverse up() operations.
   
     D. You can see all methods for altering / creating table content methods here :
           https://laravel.com/docs/5.2/migrations#creating-tables

     E. After creating migrations for all your table, you can run command:
         php artisan migrate
         Run by target of root folder of your project
         It will create all tables into database.

8. Create Models using following command: (Target root folder of project)
    create "Models" folder inside "app" repo of root folder
composer require krlove/eloquent-model-generator --dev

Register GeneratorServiceProvider:
'providers' => [
    // ...
    Krlove\EloquentModelGenerator\Provider\GeneratorServiceProvider::class,
];
( If you are using Laravel version 5.5 or higher this step can be omitted since this project supports Package Discovery feature)

php artisan krlove:generate:model Users --output-path=Models
Use table-name option to specify another table name:
php artisan krlove:generate:model User --table-name=user
In this case generated model will contain protected $table = 'user' property.

  You can change env file path as per your requirement (Local/Production environment)
   
    [PATH_TO_HTDOCS_FOLDER]\anjana\project\oposurge\vendor\laravel\framework\src\Illuminate\Foundation\Application.php 

Tuesday, 19 April 2016

Way2SMS Gateway



Anjana Janani.


To send SMS free of charge is as easy as sending mail with PHP.
Way2SMS provides API to us for getting success in this task.

Following are the steps to get started with Sending SMS from your website:

Step:1



Sign Up / Login into way2sms.com


Step:2


Get Login ID and password from it. Prepare your PHP / HTML file for getting Mobile number and message to send end users. 



Step:3


 Put in the form's action as "my_sms.php"


Step:4

 Take a new file and save as my_sms.php and write below code:













in sendWay2SMS(), put your Login ID and Password.



Step:5


Make a new file as "way2sms-api.php" and put following code into it:

<?php

function sendWay2SMS($uid, $pwd, $phone, $msg)
{
  $curl = curl_init();
  $timeout = 30;
  $result = array();

  $uid = urlencode($uid);
  $pwd = urlencode($pwd);

  // Go where the server takes you :P
  curl_setopt($curl, CURLOPT_URL, "http://way2sms.com");
  curl_setopt($curl, CURLOPT_HEADER, true);
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
  $a = curl_exec($curl);
  if(preg_match('#Location: (.*)#', $a, $r))
    $way2sms = trim($r[1]);

  // Setup for login
  curl_setopt($curl, CURLOPT_URL, $way2sms."Login1.action");
  curl_setopt($curl, CURLOPT_POST, 1);
  curl_setopt($curl, CURLOPT_POSTFIELDS, "username=".$uid."&password=".$pwd."&button=Login");
  curl_setopt($curl, CURLOPT_COOKIESESSION, 1);
  curl_setopt($curl, CURLOPT_COOKIEFILE, "cookie_way2sms");
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($curl, CURLOPT_MAXREDIRS, 20);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5");
  curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
  curl_setopt($curl, CURLOPT_REFERER, $way2sms);
  $text = curl_exec($curl);

  // Check if any error occured
  if (curl_errno($curl))
    return "access error : ". curl_error($curl);

  // Check for proper login
  $pos = stripos(curl_getinfo($curl, CURLINFO_EFFECTIVE_URL), "ebrdg.action");
  if ($pos === "FALSE" || $pos == 0 || $pos == "")
   return "invalid login";

  // Check the message
  if (trim($msg) == "" || strlen($msg) == 0)
    return "invalid message";

  // Take only the first 140 characters of the message
  $msg = urlencode(substr($msg, 0, 140));
  // Store the numbers from the string to an array
  $pharr = explode(",", $phone);

  // Set the home page from where we can send message
  $refurl = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
  $newurl = str_replace("ebrdg.action?id=", "main.action?section=s&Token=", $refurl);
  curl_setopt($curl, CURLOPT_URL, $newurl);

  // Extract the token from the URL
  $jstoken = substr($newurl, 50, -41);
  //Go to the homepage
  $text = curl_exec($curl);

  // Send SMS to each number
  foreach ($pharr as $p)
  {
    // Check the mobile number
    if (strlen($p) != 10 || !is_numeric($p) || strpos($p, ".") != false)
    {
      $result[] = array('phone' => $p, 'msg' => urldecode($msg), 'result' => "invalid number");
      continue;
    }
    $p = urlencode($p);

    // Setup to send SMS
    curl_setopt($curl, CURLOPT_URL, $way2sms.'smstoss.action');
    curl_setopt($curl, CURLOPT_REFERER, curl_getinfo($curl, CURLINFO_EFFECTIVE_URL));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, "ssaction=ss&Token=".$jstoken."&mobile=".$p."&message=".$msg."&button=Login");
    $contents = curl_exec($curl);

    //Check Message Status
    $pos = strpos($contents, 'Message has been submitted successfully');
    $res = ($pos !== false) ? true : false;
    $result[] = array('phone' => $p, 'msg' => urldecode($msg), 'result' => $res);
  }

  // Logout
  curl_setopt($curl, CURLOPT_URL, $way2sms."LogOut");
  curl_setopt($curl, CURLOPT_REFERER, $refurl);
  $text = curl_exec($curl);

  curl_close($curl);
  return $result;
}

?>


Step:6


Now, It's ready. Run your HTML/ PHP file which you have created first. 





Saturday, 16 March 2013

[3] ......!!!!!!!!!!!!!!



Chahoon bhi toh main kaise kahoon? 



Sari jo baatein dil kehta hai,



leher sapno ke kaise ginu, 



dariya behta hi rehta hai.



Keh rahi hai kya ye suno meri khamoshiya.. ♥


how are all my Frndzzz.......?!!

Friday, 15 March 2013

[2] The Poor-The Great


‎”Sometimes the poorest man leaves his children the richest inheritance.”


Anjana Janani

[1] Quote


There are two types of Pain in this world: Pain that hurts you, and Pain that changes you! 
Protected by Copyscape