9 Oct 2017

Ajax Image Uploading Code -

Ajax Image Uploading Code -

1. http://phppot.com/php/php-ajax-image-upload/
2. https://www.formget.com/ajax-image-upload-php/

Splitting Content into Two Columns, e.g. Word Wrap with PHP or CSS + Javascript

Splitting Content into Two Columns, e.g. Word Wrap with PHP or CSS + Javascript 

1 - http://dancameron.org/code/splitting-content-into-two-columns-e-g-word-wrap-with-php-or-css-javascript/

2 - https://www.cvwdesign.com/blog/multi-column-layout-with-css3-and-some-javascript

13 Sept 2017

Git Commands -

Git Commands -

1. git clone "Repo URL"

2. Check git status >> git status

3. Add your commit in git >> git add .

4. Git Commmit >> git commit -am "Meaningful message/description"

5. Push to add files on the git repo >> git push

6. Create a branch in repo (on local system) >> git branch --create staging
    Create a branch in repo (on git) >> git push origin staging

7. Git Ignore local Database file
        got update-index --assume-unchanged config/database.php

Angular 4 Installation & Project Setup Instructions

Angular 4 Installation & Project Setup Instructions -

https://coursetro.com/posts/code/55/How-to-Install-an-Angular-4-App

4 Sept 2017

Node Project Setup Sample -

Node Project Setup Sample -

http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/

27 May 2017

Linux Ubuntu Commands -

Linux Ubuntu Commands -

1. Grant Permissions on folder & It's files =>  sudo chmod -R 777 /var/www/html[Path]

2. Check Permissions on folder/files =>  

a).   ls -l  
b).  ls  -la /var/www/

3. Command to access terminal from root user => sudo su

4. MySql Access Command =>   mysql -u username -p

5. Database Show Command => Show Databases;

6. Select Database Command => Use Database Name;

7. See Structure of folder & files => tree

8. Command to correct the apache permission to www folder -

a). sudo chown -R www-data:www-data /var/www/

Refer the following link -
            https://www.digitalocean.com/community/questions/setting-permissions-for-wordpress

9. Mysql DB Export Database Command -

Syntax -  mysqldump -u USER_NAME -p DB_NAME > FILE_NAME.sql

e.g.   mysqldump -u motormanager -p motormanager > motormanager_ravi_bkp_july_2018.sql

10. MySql DB import Database Command -

  source  PATH/FILE_NAME.sql





18 May 2017

Install LAMP on Ubuntu

Install LAMP on Ubuntu -
    https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04

Proper LAMP Setup on Ubuntu -

1. Install & enable mbstring module

2. Install phpmyadmin on Ubunttu & add (in file/etc/apache2/apache2.conf )

#Include the phpmyadmin configuration
Include /etc/phpmyadmin/apache.conf

3. Following changes will be needed to work htaccess properly,
/etc/apache2/apache2.conf file. 
First, find
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
And change AllowOverride None to All and save.
Then enable mode rewrite using the command(In this case already enabeled),
$ sudo a2enmod rewrite
Then restart the server,
$ sudo /etc/init.d/apache2 restart
Run the project.

4 Apr 2017

HT Access Description

HT Access Description-
                           http://glennmessersmith.com/pages/wphtaccess.html

19 Mar 2017

Laravel 5.4 setup instructions -


Laravel Commands -
+=================================================+

Tutorial link -

https://tutorials.kode-blog.com/laravel-5-angularjs-tutorial

Laravel Installation Steps

1. Composer Intallation
2. After that install setup by following command

>> Go to the path htdocs by xampp shell
 composer create-project laravel/laravel

+=================================================+
All the PHP artisan command will run on the path under project (In shell access)

Install Module Artisan Migrate -

php artisan migrate:install

Update & Run Migrations of Database -

php artisan migrate

+=================================================+

Authentication Module Enabling Command -

php artisan make:auth

10 Mar 2017

JQuery Form Validation through validation jQuery library

JQuery Form Validation through validation jQuery library -
https://jqueryvalidation.org/files/demo/

7 Mar 2017

Ajax autoload on Page scroll in PHP

Ajax autoload on Page scroll -
                      https://www.sanwebe.com/2013/05/auto-load-records-on-page-scroll

28 Feb 2017

FB Login Implementation Example

FB Login Implementation Example -

          http://www.devils-heaven.com/facebook-javascript-sdk-login/

function fbInit(){
FB.init({appId: "my-app-id", status: true, cookie: false, xfbml: true, version: 'v2.8'});
var response="";
    FB.login(function(response)
{
var token = response.authResponse.token;
    var uid = response.authResponse.userID;
console.log(response.authResponse);
if (response.authResponse)
{
FB.api('/me?email,id,name,age_range,first_name,gender', function(response)
{
var uid=response.id;
if(uid > 1)
{
fb_doLogin(response);
}
console.log(response);
console.log("my Id="+response.id);
console.log("my email="+response.email);
});
}
    },
{
//scope:'email,id,name,age_range,first_name,gender',
scope:'email',
return_scopes: true
});

FB.getLoginStatus(function(response) {
   if(response.status === 'connected') {
FB.api('/me', function(response) {
  console.log('Your name is ' + response.name);
});
 } else if (response.status === 'not_authorized') {
  console.log('You are not_authorized');
 } else {
  console.log('the user isnot logged in to Facebook.');
 }
});
}
function fb_doLogin(response)
{
$.ajax({
type:'POST',
url: '<?php echo SITE_URL; ?>checkfblogin.php',
data:response,
beforeSend:function(xhr){
},
success: function(data){

if(data==1){
window.location.reload(true);
}
}
});
}


Library Must be -

<script>
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.8";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>


Optional :

/*FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
});

function checkLoginState() {
  FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
  });
}*/

6 Feb 2017

Angular JS Tutorials PDF -

Angular JS Tutorials PDF -   https://www.tutorialspoint.com/angularjs/angularjs_tutorial.pdf

31 Jan 2017

Android API Sample Code -

Android API Sample Code -

<?php
//echo "<pre>".print_r($_SERVER); exit;
// get the HTTP method, path and body of the request
$method = $_SERVER['REQUEST_METHOD'];
$request = explode('/', trim($_SERVER['PATH_INFO'],'/'));
$input = json_decode(file_get_contents('php://input'),true);

if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']=="POST")
{

    $varReqStr = $input;
    $keywords = preg_split("/[\[\]]/", $input["name"]);
    $varReqArr= explode(',', $keywords[1]);
}

$link = mysqli_connect('localhost', 'root', '', 'amlkocpu_maindb');
mysqli_set_charset($link,'utf8');

if($link)
{
    $table = preg_replace('/[^a-z0-9_]+/i','',array_shift($request));
    $key = array_shift($request)+0;
    $columns = preg_replace('/[^a-z0-9_]+/i','',array_keys($input));
    $values = array_map(function ($value) use ($link) {
        if ($value===null) return null;
        return mysqli_real_escape_string($link,(string)$value);
    },array_values($input));

$set = '';
for ($i=0;$i<count($columns);$i++) {
  $set.=($i>0?',':'').'`'.$columns[$i].'`=';
  $set.=($values[$i]===null?'NULL':'"'.$values[$i].'"');
}

// create SQL based on HTTP method
switch ($method) {
  case 'GET':
      $sql = "select * from `$table`".($key?" WHERE id=$key":''); break;
  case 'PUT':
      $sql = "update `$table` set $set where id=$key"; break;
  case 'POST':

      //print_r($link);
      foreach($varReqArr as $indVal){
         //$indValPart=array();

         $indValPart = explode('-', $indVal);
         //$columns = preg_replace("'",'',array_keys($input));

         //print_r($indValPart); exit;
         echo $sql2 = "INSERT INTO `tbl_contact` ( `name`, `mobile`) VALUES    
              ('".str_replace("'",'',$indValPart[1])."', '".str_replace("'",'',$indValPart[0])."')";
              //exit;
         $resultSaved= mysqli_query($link, $sql2);
      }
       break;

  case 'DELETE':
    $sql = "delete `$table` where id=$key"; break;
}

 if($resultSaved){
   echo '{"code":"success","msg":"record inserted successfully"}';
 }else if($result = mysqli_query($link, $sql)){
    echo '{"code":"success","msg":"Task completed"}';
}else{
     echo '{"code":"303","msg":"error found"}';
}
exit;
/*
if ($method == 'GET') {
  if (!$key) echo '[';
  for ($i=0;$i<mysqli_num_rows($result);$i++) {
    echo ($i>0?',':'').json_encode(mysqli_fetch_object($result));
  }
  if (!$key) echo ']';
} elseif ($method == 'POST') {
  echo mysqli_insert_id($link);
} else {
  echo mysqli_affected_rows($link);
}*/

// close mysql connection
    mysqli_close($link);
}else{
    echo "error"; exit;
}

25 Jan 2017

Convertkit subscription through API Subscription


Convertkit subscription through API -

function handle_custom_registration_complete_event($member_data,$custom_fields)
{
//print_r($member_data);
$param= array();
$param['api_key'] = 'U7MAIGT9J4LF51bm_kP3Og';
$param['name'] = $user = $member_data['user_name'];
  $param['email'] = $email = $member_data['email'];
$url = 'https://api.convertkit.com/v3/forms/32338/subscribe';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param));
$results = curl_exec($ch);
curl_close($ch);
//print_r(json_decode($results));
if(isset($results->subscription->id) && $results->subscription->id>0){

}else{
}
}