<commit_before><?php
  if($_SERVER['SERVER_NAME'] == 'builder.osmand.net') {
  	include '../reports/db_conn.php';
  	$dbconn = db_conn();
    $userid = pg_escape_string($dbconn, $_REQUEST["userid"]);
    $result = pg_query($dbconn, "SELECT userid from supporters where userid = '{$userid}';");
    $ok = false;
    if($result) {
      $row = pg_fetch_row($result);
      if($row) {
        $ok = $row[0] == $_REQUEST["userid"];
      }
    }
    if(!$ok) {
      echo json_encode(array( "error" => "User id is not found"));
      die; 
    }
    if(!array_key_exists("purchaseToken", $_POST) || $_POST["purchaseToken"] == '') {
      echo json_encode(array( "error" => "Purchase token is not specified"));
      die; 
    }
    if(!array_key_exists("sku", $_POST) || $_POST["sku"] == '') {
      echo json_encode(array( "error" => "Subscription id is not specified"));
      die; 
    }

    $sku = pg_escape_string($dbconn, $_POST["sku"]);
    $purchaseToken = pg_escape_string($dbconn, $_POST["purchaseToken"]);
    // $email = pg_escape_string($dbconn, $_POST["email"]);
    $time = time() * 1000;
    
    $result = pg_query($dbconn, "INSERT INTO supporters_subscription(userid, sku, purchasetoken, checktime) 
      VALUES('{$userid}','{$sku}','{$purchaseToken}',${time});");
  	if(!$result) {
  		$res = array();        
  		$res['error'] = "Error";
  		echo json_encode($res);
  		die;
  	}
	  echo "{'status':'OK'}";
  } else {
  	$data = $_POST;
      // use key 'http' even if you send the request to https://...
      $options = array(<commit_msg>Update user<commit_after><?php
  if($_SERVER['SERVER_NAME'] == 'builder.osmand.net') {
  	include '../reports/db_conn.php';
  	$dbconn = db_conn();
    $userid = pg_escape_string($dbconn, $_REQUEST["userid"]);
    $result = pg_query($dbconn, "SELECT userid from supporters where userid = '{$userid}';");
    $ok = false;
    if($result) {
      $row = pg_fetch_row($result);
      if($row) {
        $ok = $row[0] == $_REQUEST["userid"];
      }
    }
    if(!$ok) {
      echo json_encode(array( "error" => "User id is not found"));
      die; 
    }
    if(!array_key_exists("purchaseToken", $_POST) || $_POST["purchaseToken"] == '') {
      echo json_encode(array( "error" => "Purchase token is not specified"));
      die; 
    }
    if(!array_key_exists("sku", $_POST) || $_POST["sku"] == '') {
      echo json_encode(array( "error" => "Subscription id is not specified"));
      die; 
    }

    $sku = pg_escape_string($dbconn, $_POST["sku"]);
    $purchaseToken = pg_escape_string($dbconn, $_POST["purchaseToken"]);
    // $email = pg_escape_string($dbconn, $_POST["email"]);
    $time = time() * 1000;
    
    $result = pg_query($dbconn, "INSERT INTO supporters_subscription(userid, sku, purchasetoken, checktime) 
      VALUES('{$userid}','{$sku}','{$purchaseToken}',${time});");
  	if(!$result) {
  		$res = array();        
  		$res['error'] = "Error";
  		echo json_encode($res);
  		die;
  	}
	  echo "{'status':'OK'}"; 
  } else {
  	$data = $_POST;
      // use key 'http' even if you send the request to https://...
      $options = array(
{'fraction_non_alphanumeric': 0.2016051364365971, 'fraction_numerical': 0.0032102728731942215, 'mean_word_length': 3.2051282051282053, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '2958120', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1092, 'n_words': 218}