Viewing file: exam_action.php (3.17 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
require 'connection.php';
$technology=$_REQUEST['technology'];
$semester=$_REQUEST['semester'];
$subject=$_REQUEST['subject'];
$exam=$_REQUEST['exam'];
$exam_title=$_REQUEST['exam_title'];
$examtime=$_REQUEST['examtime'];
$g_status=$_REQUEST['g_status'];
$stu_status=$_REQUEST['stu_status'];
$date=date("Y/m/d") ;
$date1="";
$sql="select * from exam where subject='$subject' and type='1'";
$result=$con->query($sql);
$count=$result->num_rows;
if($count>0){
while($row=$result->fetch_assoc()){
$date1=$row['exam_date'];
header('location:schedule_exam.php?status=failed');
}
}
else{
// $sql="update exam set type='0' where subject='$subject' and type='1'";
// $result=$con->query($sql);
$sql="insert into `exam`(batch_id,semester,subject,exam_date,exam_title,examtime,type,g_status,stu_status) values('$technology','$semester','$subject','$exam','$exam_title','$examtime','1','$g_status','$stu_status')";
$result=$con->query($sql);
$count=$con->affected_rows;
if($count>0){
$tsql="insert into `exam_q_details`(test_name,test_type,duration,no_of_ques,main_type) values('$exam_title','1',$examtime','$examtime','srishti campus')";
$tresult=$con_it->query($tsql);
$tcount=$con_it->affected_rows;
$sql1="SELECT *
FROM `user_details`
INNER JOIN enrolldetails ON user_details.user_id=enrolldetails.user_id where enrolldetails.course_id=$semester ";
$result1=$con->query($sql1);
$count1=$result1->num_rows;
while($row1=$result1->fetch_assoc()){
$phone=$row1['phone'];
$sql2="select * from `tb_user` WHERE phone='$phone' and device_token!=''";
$result2=$con_it->query($sql2);
$count2=$result2->num_rows;
$device="";
if($count2>0){
while ($row=$result->fetch_assoc()) {
$device=$row['device_token'];
}
// API access key from Google API's Console
define( 'API_ACCESS_KEY','AAAABLsF19c:APA91bEwIVggcRMYaF4ZHZtpTjaMYSgnvN3Pc5F-R0IRftn1b4_VHsaFpUkzA5ilpZOHiBtStx5edgWc_zQs9bB4lbiW0AErUgfGBq7JOWKQVDBq1VZt2A6z_au1_T_nZOC0kvEUqIP0');
$device="cc1wbmjCR5-80c0uTdK4mx:APA91bG4Xw4PMETnNC_9Bz7FM786mD6nhEToZ9CG7kBb1lp2dSU6J0i2y7gIkseteNeEGSOO_ocbRovtAXVTarUHzP6QO6Y0spyV-XPEyquRsUenutP5jzvmGBlfTzyoWjQsO7ascMth";
$registrationIds = array($device);
$msg= array('Category'=>'Exam','From'=>'srishti campus','Technology'=>$technology,'Subject'=>$subject);
$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));
//curl_setopt( $ch,CURLOPT_POSTFIELDS, json_decode( $fields ) );
$result = curl_exec($ch );
curl_close($ch);
$post = array("payload"=>$msg);
//echo (json_encode($post));
echo $result;
}}
header('location:schedule_exam.php?status=success');
//echo 'success';
}
else{
header('location:schedule_exam.php?status=failed');
//echo 'failed';
}
}
?>
|