ajgkqsldxvkqsldkqs azelfkqsmkqsmlkdqsmld azmlekdqmskdmlqskd nkldsfkqsmldkqsmdmlskd decrypt($_GET['id']); $day = $mcrypt->decrypt($_GET['day']); $from = $mcrypt->decrypt($_GET['from']); $to = $mcrypt->decrypt($_GET['to']); $opening_hrs = " "; /* Fetch the information */ $con = db_connect(); $sql = session($con,$session); $total = 0; if(db_rows($con,$sql)>0){ /* fetch userid and create session token */ $query = mysqli_query($con,$sql); while($row=mysqli_fetch_array($query)){ $userid = $row['userid']; } /* check if user has passed curfew */ if((!valInt($day))||($day<1)||($day>7)){ $message = "Please check opening day."; }else if(empty($from)){ $message = "Please select the opening time."; }else if(empty($to)){ $message = "Please select the closing time."; }else if((strtotime($from)>strtotime($to))||(strtotime($from)==strtotime($to))){ $message = "Please opening time can't be equal or more than closing time."; }else{ /* Record opening hours */ if(opening_hrs_recorded($con,$userid,$day)){ $sql = update_opening_hrs($con,$userid,$day,$from,$to); if(mysqli_query($con,$sql)){ $opening_hrs = company_opening_hours($con,$userid); $success = 1; $message = "Opening hours is successfully updated."; }else{ $message = "Server error. Please try again later."; } }else{ $sql = record_opening_hrs($con,$userid,$day,$from,$to); if(mysqli_query($con,$sql)){ $opening_hrs = company_opening_hours($con,$userid); $success = 1; $message = "Opening hours is successfully recorded."; }else{ $message = "Server error. Please try again later."; } } } }else{ $message = "You don't have right to use this system"; } $response['success'] = $success; $response['message'] = $mcrypt->encrypt($message); $response['opening_hrs'] = $mcrypt->encrypt($opening_hrs); echo json_encode($response); db_close($con); }