Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Thursday, October 15, 2020

Curl Notification send Using Php Firebase

 <?php

/* New Server Php */



$token = 'user tken';


  define( 'API_ACCESS_KEY', 'key' );

$registrationIds = array($token);


$msg = array

(

'messages' => 'Order Id',

'title'         => 'Got a new Order',

'subtitle' =>  'Order Id ',

'tickerText' => 4545,

'vibrate' => '2',

'sound' => 1,

'largeIcon' => 'large_icon',

'smallIcon' => 'small_icon'

);

$fields = array

(

'registration_ids' => $registrationIds,

'data' => $msg

);


$headers = array

(

'Authorization: key=' . API_ACCESS_KEY,

'Content-Type: application/json'

);


$ch = curl_init();

curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );

curl_setopt( $ch,CURLOPT_POST, true );

curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );

curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );

curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );

curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );

$result = curl_exec($ch );

echo $result

curl_close( $ch );


?>



<?php

 /*Old Server php */

define( 'API_ACCESS_KEY', 'xxxxx' );


$singleID = 'user tken' ; 

$registrationIDs = array( 'user tken',     'user tken',     'user tken'

) ;


$fcmMsg = array(

'body' => 'here is a message. message',

'title' => 'This is title #1',

'sound' => "jingle_bell.mp3",

     'content_available' => true, 

     'priority' => 'high', 

);


$fcmFields = array(

'to' => $singleID,

    'sound' => 'jingle_bell.mp3',

    'priority' => 'high',

'notification' => $fcmMsg

);


$headers = array(

'Authorization: key=' . API_ACCESS_KEY,

'Content-Type: application/json'

);

 

$ch = curl_init();

curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );

curl_setopt( $ch,CURLOPT_POST, true );

curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );

curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );

curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );

curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fcmFields ) );

$result = curl_exec($ch );

curl_close( $ch );

echo $result . "\n\n";

?>

Thursday, October 8, 2020

Sunrise and Sunset time using PHP

 <?php

echo date("D M d Y"); 

echo("\nSunset time: "); 

echo(date_sunset(time(), SUNFUNCS_RET_STRING, 

                 30.7046, 76.7179, 266, 5.30)); 

                 

                 echo "<br>";

echo date("D M d Y"); 

echo("\nsunrise time: "); 

echo(date_sunrise(time(), SUNFUNCS_RET_STRING, 

              30.7046, 76.7179, 88, 5.30)); 

?>

Monday, June 29, 2020

using Htaccess file URL remove links php

OLD :: page.php?page_id=taurus
NEW: page/taurus



RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?page/(.*?)/?$ /page.php?page_id=$1 [L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /page\.php\?page_id=([^\&\ ]+)
RewriteRule ^/?page\.php$ /page/%1? [L,R=301]

Thursday, June 25, 2020

Time Difference script using PHP

<?php

$date1 = strtotime("2016-06-01 22:45:00"); 
$date2 = strtotime("2018-09-21 10:44:01"); 
  
$diff = abs($date2 - $date1); 

$years = floor($diff / (365*60*60*24)); 

$months = floor(($diff - $years * 365*60*60*24)
                               / (30*60*60*24)); 

$days = floor(($diff - $years * 365*60*60*24 - 
             $months*30*60*60*24)/ (60*60*24));
  

$hours = floor(($diff - $years * 365*60*60*24 
       - $months*30*60*60*24 - $days*60*60*24)
                                   / (60*60)); 
$minutes = floor(($diff - $years * 365*60*60*24 
         - $months*30*60*60*24 - $days*60*60*24 
                          - $hours*60*60)/ 60); 
  

$seconds = floor(($diff - $years * 365*60*60*24 
         - $months*30*60*60*24 - $days*60*60*24
                - $hours*60*60 - $minutes*60)); 
  
// Print the result
printf("%d years, %d months, %d days, %d hours, "
     . "%d minutes, %d seconds", $years, $months,
             $days, $hours, $minutes, $seconds); 
?>

Thursday, June 18, 2020

Update Images and content uysimh PHP mysqli

<?php
    include ('config.php');
$categoryid = $_REQUEST['Id'];
if(isset($_POST["user_submit"]))
{
    $name = $_REQUEST['name'];
   $email = $_REQUEST['email'];
   $phone = $_REQUEST['phone'];
   $visa_upload = $_REQUEST['visa_upload'];
   $visa_expiry = $_REQUEST['visa_expiry'];
   $license_upload = $_REQUEST['license_upload'];
   $licence_expiry = $_REQUEST['licence_expiry'];
   $passport_upload = $_REQUEST['passport_upload'];
   $passwport_expiry = $_REQUEST['passwport_expiry'];
 
    $rand = rand(0000,9999);
$filename = $_FILES['visa_upload']['name'];
$filetmpname = $_FILES['visa_upload']['tmp_name'];
$folder ='imagesuploadedf/';
move_uploaded_file($filetmpname, $folder.$filename);
  $timestamp = date("Y-m-d");
 


$filename1 =$_FILES['license_upload']['name'];
$filetmpname = $_FILES['license_upload']['tmp_name'];
$folder ='imagesuploadedf/';
move_uploaded_file($filetmpname, $folder.$filename1);


$filename2 = $_FILES['passport_upload']['name'];
$filetmpname = $_FILES['passport_upload']['tmp_name'];
$folder ='imagesuploadedf/';
move_uploaded_file($filetmpname, $folder.$filename2);

 $sql = "UPDATE driver_register SET name='$name',email='$email',phone='$phone',visa_expiry='$visa_expiry',licence_expiry='$licence_expiry',passwport_expiry='$passwport_expiry' WHERE Id = $categoryid";

  if ($conn->query($sql) === TRUE) {
   

 
   if($filename!='')
   {
      move_uploaded_file($filetmpname, $folder.$filename);
            $ww1 = mysqli_query($conn,"update driver_register set visa_upload='$filename' where Id ='$categoryid'");
   }
      if($filename1!='')
   {
      move_uploaded_file($filetmpname, $folder.$filename1);
            $ww2 = mysqli_query($conn,"update driver_register set license_upload='$filename1' where Id ='$categoryid'");
   }
      if($filename2!='')
   {
     move_uploaded_file($filetmpname, $folder.$filename2);
            $ww3 = mysqli_query($conn,"update driver_register set passport_upload='$filename2' where Id ='$categoryid'");
   }
   
   
    echo '<script>alert("Update Successfully.");window.location.assign("all_driver.php");</script>';
  }
  else{
      echo '<script>alert("please Update Again....");window.location.assign("all_driver.php?Id='.$categoryid.'");</script>';
  }
}


$query=mysqli_query($conn,"select * from driver_register where Id = '$categoryid' ") ;                   
  if(mysqli_num_rows($query)>0)
  {
   $res=mysqli_fetch_assoc($query);
   $name = $res['name'];
   $email = $res['email'];
   $phone = $res['phone'];
   $visa_upload = $res['visa_upload'];
   $visa_expiry = $res['visa_expiry'];
   $license_upload = $res['license_upload'];
   $licence_expiry = $res['licence_expiry'];
   $passport_upload = $res['passport_upload'];
   $passwport_expiry = $res['passwport_expiry'];
   
    $image= $res['image'];
  }
?>

Tuesday, January 21, 2020

CSV data attachment using PHP Mysqli

This summary is not available. Please click here to view the post.

Delete table data using ajax file php Mysqli

<span id="new_select2" style="color:green;text-align:center;font-weight:bold;"></span> // Show div

  onchange="fetch_select2(this.value);"  //Click Function

<script type="text/javascript">
function fetch_select2(val)
{
$.ajax({
type: 'post',
url: 'https://sasnagar.co.in/ezboxes//wp-content/themes/Divi/delete_calender_date.php?del_id=<?php $del_date_id= $row_pack["id"]; echo $del_date_id; ?>',
data: {
 get_option1:val
},
success: function (response) {
 document.getElementById("new_select2").innerHTML=response;
}
});
}
$('#new_select2').delay(5000).fadeOut('slow');
</script>

Thursday, January 16, 2020

Price show in decimal using PHP

<?php echo number_format((float)$total_ct_sum, 2, '.', ''); ?>

Single digit add 0 using PHP :
<?php $num_month = sprintf("%02d", $day_01); ?>

Thursday, January 9, 2020

Get database record using month and year PHP MYSQLI

<table id="example" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
            <th colspan="2" class="tble_fb">Calender</th>
            <th colspan="1" class="tble_fb">Order #</th>
            <th colspan="1" class="tble_fb">Order Status</th>
            <th colspan="5" class="tble_fb">Contact Info</th>
            <th colspan="3" class="tble_fb">Item Info</th>
            <th colspan="3" class="tble_fb">Rent Period</th>
            <th colspan="4" class="tble_fb">Delivery Info</th>
            <th colspan="4" class="tble_fb">Pick Up Info</th>
            <th colspan="1" class="tble_fb">Order Notes</th>
        </tr>
<tr>                     
    <td class="heading_cls">Date</td>
    <td class="heading_cls">Day</td>
    <td class="heading_cls">Order #</td>
    <td class="heading_cls">New Order</td>
        <td class="heading_cls">First Name</td>
        <td class="heading_cls">Last Name</td>
        <td class="heading_cls">Email</td>
        <td class="heading_cls">Phone</td>
        <td class="heading_cls">Secondary Phone</td>
        <td class="heading_cls">Package</td>
        <td class="heading_cls">Package Boxes</td>
        <td class="heading_cls">Added Items</td>
        <td class="heading_cls">Rent Period</td>
        <td class="heading_cls">Rent Extra Week(s)</td>
        <td class="heading_cls">Delivery Date</td>
        <td class="heading_cls">Delivery Address</td>
        <td class="heading_cls">Delivery Apt</td>
        <td class="heading_cls">Stair/Elevator</td>
        <td class="heading_cls">Pick Up Date</td>
        <td class="heading_cls">Pick Up Address</td>
        <td class="heading_cls">Pick Up Apt</td>
        <td class="heading_cls">Stair/Elevator</td>
        <td class="heading_cls">Order Notes</td>
        </tr>
</thead> 
    <tbody>
<?php
$servername = "localhost";
$username = "xxxxx";
$password = "xxxx(*()";
$dbname = "xxxx";
date_default_timezone_set('Canada/Eastern');
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

@$month_year=$_REQUEST['month_year'];
if(@$_POST['cal_dat_get']){
$startdate = date("m/d/Y", strtotime($month_year));

}else{
$startdate =  date("m/d/Y");
}
$exp = explode('/', $startdate);
$year = $exp[2];
$month = $exp[0];
$day_01 = '01';

   for($day_01='01';$day_01<='31';$day_01++){
   $tada_01 = $month.'/'.$day_01.'/'.$year;
   if(@$_POST['cal_dat_get']){  
$sql_package = "SELECT * from xxxx WHERE payment_status='succeeded' AND (order_status_type='New Order' OR order_status_type='Delivered') and order_date like '%$tada_01%' order by id desc";
   }else{
   $sql_package = "SELECT * from xxxxx WHERE payment_status='succeeded' AND (order_status_type='New Order' OR order_status_type='Delivered') and order_date like '%$tada_01%' order by id desc";
   }


$result = $conn->query($sql_package);

$val_price = 0;

if ($result->num_rows > 0) {
    while($row_pack = $result->fetch_assoc()) {
?>
<tr>                     
   
 
        <td class="heading_cls"><?php echo $row_pack["first_name"]; ?></td>
        <td class="heading_cls"><?php echo $row_pack["last_name"]; ?></td>
        <td class="heading_cls"><?php echo $row_pack["email_personal"]; ?></td>
        <td class="heading_cls"><?php echo $row_pack["phone_number1"]; ?></td>
        </tr>
 
<?php
    }
} else {
    ?>
<tr>                     
        <td class="heading_cls" style="border-right: none;"></td>
        <td class="heading_cls" style="border-right: none;"></td>
        <td class="heading_cls" style="border-right: none;"></td>
        <td class="heading_cls" style="border-right: none;"></td>
        <td class="heading_cls"></td>
        </tr>
<?php

}
  }
?> </tbody>
</table>

Get Weekly data using PHP MYSQLI

<table id="example" class="table table-striped table-bordered wely_tableset" style="width:100%">
<thead> 
<tr>
            <th style="line-height: 20px;border-right-color: #000;" colspan="2" class="tble_fb">For the week of Tuesday:</th>
            <th style="line-height: 50px;border-right-color: #000;" colspan="2" class="tble_fb"><?php date_default_timezone_set('Canada/Eastern'); $tuesday_date = date("m/d/Y", strtotime("previous tuesday"));
//echo $tuesday_date; echo '***';
$past_tuesday = date("d-M-Y", strtotime( "$tuesday_date -7 day" ) );
echo $past_tuesday; ?></th>
            <th colspan="2" style="border-right-color: #000;" class="tble_fb sdfrds">To Tuesday:
<span class="tblspn">Items Info</span>
</th>
            <th style="" colspan="3" class="tble_fb sdfrds"><?php  $tuesday_date = date("d-M-Y", strtotime("previous tuesday"));
echo $tuesday_date;
 ?>
<span class="tblspn">Payment Info</span>
</th>
        </tr>
<tr>                     
    <td class="heading_cls">Order Id</td>
        <td class="heading_cls">Order Status</td>
        <td class="heading_cls">Refer By</td>
    </tr>
</thead>
<tbody>
<?php
$servername = "localhost";
$username = "xxxx";
$password = "xxxx(*()";
$dbname = "xxxx";
date_default_timezone_set('Canada/Eastern');
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
  $start_date_week = new DateTime('-7');
  $current_date_week = $start_date_week->format('m/d/Y');
  //echo $current_date_week;echo '****';
  $dt = date("m/d/Y");
  $day_date_future = date("m/d/Y", strtotime( "$dt -7 day" ) );
 //echo $day_date;die('hhhhhhhhhhh');

 $tuesday_date = date("m/d/Y", strtotime("previous tuesday"));
//echo $tuesday_date; echo '***';
$past_tuesday = date("m/d/Y", strtotime( "$tuesday_date -7 day" ) );
//echo $past_tuesday;
 
$sql_package = "SELECT * from xxxxx WHERE order_status_type='Completed' AND order_complete_date and ('$past_tuesday' AND '$tuesday_date') order by id";


$result = $conn->query($sql_package);

$val_price = 0;

if ($result->num_rows > 0) {
    while($row_pack = $result->fetch_assoc()) {
?>
<tr>                     
    <td class="heading_cls size_sett"><?php $order_id_pac = $row_pack["order_id"];echo $order_id_pac; ?></td>
        <td class="heading_cls" style="background:#c6e0b3;"><?php echo $row_pack["order_status_type"]; ?></td>
        <td class="heading_cls size_sett"><?php echo '$'.$row_pack["package_total"]; $val_price += $row_pack["package_total"];?></td>
    </tr>
<?php
    }
} else {
   // echo "0 results";
}
?>
 <tr>

<td style="border-left: none !important;border-right: none !important;font-size:0px;">Total</td>
<td style="font-weight:bold;">Total</td>
<td style="font-weight:bold">$<?php echo number_format($val_price); ?></td>
</tr>
</tbody>

</table>