<commit_before><?php session_start(); ?>
<?php
$org=0;
if(isset($_SESSION['org'])) $org=$_SESSION['org'];
if(isset($_SESSION['security'])){
 if (!($_SESSION['security'] & 64)){die("Secruity level too low for this page");}
}else{
 header('Location: Login.php');
 die("Please logon");
}
?>
<!DOCTYPE HTML>
<html>
<meta name="viewport" content="width=device-width">
<meta name="viewport" content="initial-scale=1.0">
<head>
<link rel="stylesheet" type="text/css" href="styleform1.css">
</head>
<body>
<script>function goBack() {window.history.back()}</script>
<?php
$DEBUG=0;
$pageid=27;
$errtext="";
$sqltext="";
$error=0;
$trantype="Create";
$recid=-1;
$id_f="";
$id_err="";
$name_f="";
$name_err="";
$bill_pic_f="";
$bill_pic_err="";
$bill_p2_f="";
$bill_p2_err="";
$bill_other_f="";
$bill_other_err="";
$no_comment_f="";
$no_comment_err="";
function InputChecker($data)
{
 $data = trim($data);
 $data = stripslashes($data);
 $data = htmlspecialchars($data);
 return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "GET")
{
 if($_GET['id'] != "" && $_GET['id'] != null)
 {
  $recid = $_GET['id'];
  if ($recid >= 0)
  {
$con_params = require('./config/database.php'); $con_params = $con_params['gliding']; 
$con=mysqli_connect($con_params['hostname'],$con_params['username'],$con_params['password'],$con_params['dbname']);
   if (mysqli_connect_errno())
   {
    $errtext= "Failed to connect to Database: " . mysqli_connect_error();
   }
   else
   {
    $q = "SELECT * FROM billingoptions WHERE id = " . $recid ;
    $r = mysqli_query($con,$q);
    $row = mysqli_fetch_array($r);
    $id_f = $row['id'];
    $name_f = htmlspecialchars($row['name'],ENT_QUOTES);
    $bill_pic_f = $row['bill_pic'];
    $bill_p2_f = $row['bill_p2'];
    $bill_other_f = $row['bill_other'];
	$no_comment_f = $row['no_comment'];
    $trantype="Update";
    mysqli_close($con);
   }
  }
 }
}
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
 $error=0;
 $id_err = "";
 $name_err = "";
 $bill_pic_err = "";
 $bill_p2_err = "";
 $bill_other_err = "";
 $no_comment_err="";
 $name_f = InputChecker($_POST["name_i"]);
if(in_array("1",$_POST['bill_pic_i']))
 $bill_pic_f = 1;
else
 $bill_pic_f = 0;
 if (!empty($bill_pic_f ) ) {if (!is_numeric($bill_pic_f ) ) {$bill_pic_err = "Charge PIC is not numeric";$error = 1;}}
if(in_array("1",$_POST['bill_p2_i']))
 $bill_p2_f = 1;
else
 $bill_p2_f = 0;
 if (!empty($bill_p2_f ) ) {if (!is_numeric($bill_p2_f ) ) {$bill_p2_err = "Charge P2 is not numeric";$error = 1;}}
if(in_array("1",$_POST['bill_other_i']))
 $bill_other_f = 1;
else
 $bill_other_f = 0;
 if (!empty($bill_other_f ) ) {if (!is_numeric($bill_other_f ) ) {$bill_other_err = "Charge Other is not numeric";$error = 1;}}
if(in_array("1",$_POST['no_comment_i']))
 $no_comment_f = 1;
else
 $no_comment_f = 0;
 if (!empty($no_comment_f ) ) {if (!is_numeric($no_comment_f ) ) {$no_comment_err = "No Comment is not numeric";$error = 1;}} 
 if ($error != 1)
 {
$con_params = require('./config/database.php'); $con_params = $con_params['gliding']; 
$con=mysqli_connect($con_params['hostname'],$con_params['username'],$con_params['password'],$con_params['dbname']);
   if (mysqli_connect_errno())
   {
    $errtext= "Failed to connect to Database: " . mysqli_connect_error();
   }
   else
   {
     $Q = "";
     if (isset($_POST["del"]) ) {if ($_POST["del"] == "Delete"){
       $Q="DELETE FROM billingoptions WHERE id = " . $_POST['updateid'] ;}}
     if (isset($_POST["tran"]) ) {if ($_POST["tran"] == "Update"){
      $Q = "UPDATE billingoptions SET ";
      $Q .= "name=";
      $Q .= "'" . mysqli_real_escape_string($con, $name_f)  . "'";
      $Q .= ",bill_pic=";
      $Q .= "'" . $bill_pic_f . "'";
      $Q .= ",bill_p2=";
      $Q .= "'" . $bill_p2_f . "'";
      $Q .= ",bill_other=";
      $Q .= "'" . $bill_other_f . "'";
      $Q .= ",no_comment=";
      $Q .= "'" . $no_comment_f . "'";	  
$Q .= " WHERE ";$Q .= "id ";$Q .= "= ";
$Q .= $_POST['updateid'];}
     else
     if ($_POST["tran"] == "Create"){
       $Q = "INSERT INTO billingoptions (";$Q .= "name";$Q .= ", bill_pic";$Q .= ", bill_p2";$Q .= ", bill_other";$Q .= ", no_comment";$Q .= " ) VALUES (";
       $Q .= "'" . mysqli_real_escape_string($con, $name_f) . "'";
       $Q.= ",";
       $Q .= "'" . $bill_pic_f . "'";
       $Q.= ",";
       $Q .= "'" . $bill_p2_f . "'";
       $Q.= ",";
       $Q .= "'" . $bill_other_f . "'";
       $Q.= ",";
       $Q .= "'" . $no_comment_f . "'";	   
      $Q.= ")";
    }}<commit_msg>billingoptions.php improve SQL readability with Heredoc<commit_after><?php session_start(); ?>
<?php
$org=0;
if(isset($_SESSION['org'])) $org=$_SESSION['org'];
if(isset($_SESSION['security'])){
 if (!($_SESSION['security'] & 64)){die("Secruity level too low for this page");}
}else{
 header('Location: Login.php');
 die("Please logon");
}
?>
<!DOCTYPE HTML>
<html>
<meta name="viewport" content="width=device-width">
<meta name="viewport" content="initial-scale=1.0">
<head>
<link rel="stylesheet" type="text/css" href="styleform1.css">
</head>
<body>
<script>function goBack() {window.history.back()}</script>
<?php
$DEBUG=0;
$pageid=27;
$errtext="";
$sqltext="";
$error=0;
$trantype="Create";
$recid=-1;
$id_f="";
$id_err="";
$name_f="";
$name_err="";
$bill_pic_f="";
$bill_pic_err="";
$bill_p2_f="";
$bill_p2_err="";
$bill_other_f="";
$bill_other_err="";
$no_comment_f="";
$no_comment_err="";
function InputChecker($data)
{
 $data = trim($data);
 $data = stripslashes($data);
 $data = htmlspecialchars($data);
 return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "GET")
{
 if($_GET['id'] != "" && $_GET['id'] != null)
 {
  $recid = $_GET['id'];
  if ($recid >= 0)
  {
$con_params = require('./config/database.php'); $con_params = $con_params['gliding']; 
$con=mysqli_connect($con_params['hostname'],$con_params['username'],$con_params['password'],$con_params['dbname']);
   if (mysqli_connect_errno())
   {
    $errtext= "Failed to connect to Database: " . mysqli_connect_error();
   }
   else
   {
	$q = <<<SQL
		SELECT * FROM billingoptions WHERE id = {$recid}
SQL;
    $r = mysqli_query($con,$q);
    $row = mysqli_fetch_array($r);
    $id_f = $row['id'];
    $name_f = htmlspecialchars($row['name'],ENT_QUOTES);
    $bill_pic_f = $row['bill_pic'];
    $bill_p2_f = $row['bill_p2'];
    $bill_other_f = $row['bill_other'];
	$no_comment_f = $row['no_comment'];
    $trantype="Update";
    mysqli_close($con);
   }
  }
 }
}
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
 $error=0;
 $id_err = "";
 $name_err = "";
 $bill_pic_err = "";
 $bill_p2_err = "";
 $bill_other_err = "";
 $no_comment_err="";
 $name_f = InputChecker($_POST["name_i"]);
if(in_array("1",$_POST['bill_pic_i']))
 $bill_pic_f = 1;
else
 $bill_pic_f = 0;
 if (!empty($bill_pic_f ) ) {if (!is_numeric($bill_pic_f ) ) {$bill_pic_err = "Charge PIC is not numeric";$error = 1;}}
if(in_array("1",$_POST['bill_p2_i']))
 $bill_p2_f = 1;
else
 $bill_p2_f = 0;
 if (!empty($bill_p2_f ) ) {if (!is_numeric($bill_p2_f ) ) {$bill_p2_err = "Charge P2 is not numeric";$error = 1;}}
if(in_array("1",$_POST['bill_other_i']))
 $bill_other_f = 1;
else
 $bill_other_f = 0;
 if (!empty($bill_other_f ) ) {if (!is_numeric($bill_other_f ) ) {$bill_other_err = "Charge Other is not numeric";$error = 1;}}
if(in_array("1",$_POST['no_comment_i']))
 $no_comment_f = 1;
else
 $no_comment_f = 0;
 if (!empty($no_comment_f ) ) {if (!is_numeric($no_comment_f ) ) {$no_comment_err = "No Comment is not numeric";$error = 1;}} 
 if ($error != 1)
 {
$con_params = require('./config/database.php'); $con_params = $con_params['gliding']; 
$con=mysqli_connect($con_params['hostname'],$con_params['username'],$con_params['password'],$con_params['dbname']);
   if (mysqli_connect_errno())
   {
    $errtext= "Failed to connect to Database: " . mysqli_connect_error();
   }
   else
   {
	 $escaped_name = mysqli_real_escape_string($con, $name_f);
     $Q = "";
	 
     if (isset($_POST["del"]) ) {if ($_POST["del"] == "Delete"){
       $Q =<<<SQL
		DELETE FROM billingoptions WHERE id = {$_POST['updateid']}
SQL;
	   }}
     if (isset($_POST["tran"]) ) {if ($_POST["tran"] == "Update"){
      $Q =<<<SQL
		UPDATE billingoptions 
		SET name = '{$escaped_name}', bill_pic = '{$bill_pic_f}', bill_p2 = '{$bill_p2_f}', bill_other= '{$bill_other_f}', no_comment = '{$no_comment_f}'
		WHERE id = {$_POST['updateid']}
SQL;
	 }
     else
     if ($_POST["tran"] == "Create"){
      $Q =<<<SQL
		INSERT INTO billingoptions (name, bill_pic, bill_p2, bill_other, no_comment)
		VALUES ('{$escaped_name}', '{$bill_pic_f}', '{$bill_p2_f}', '{$bill_other_f}', '{$no_comment_f}')
SQL;
	 }}
{'fraction_non_alphanumeric': 0.23741679317996028, 'fraction_numerical': 0.010743898166530421, 'mean_word_length': 4.7399463806970505, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2050836', 'n_tokens_mistral': 3585, 'n_tokens_neox': 3418, 'n_words': 588}