<commit_before><?php
  session_start();
  require('config.php');
  require_once('helpers/string.php');
  require_once('classes/database.php');
  
  $db = new Database();
  
  
  $r = array();
  $r['status'] = 0;
  $r['msg'] = '';
  
  if(isset($_GET['u']) && isset($_GET['p']))
  {
    $username = sanitize($_GET['u'], false, true);
    $password = sanitize($_GET['p']);
    $sql = 'select * from users where email = "' .$username . '" limit 1';
    $result = $db->query($sql);
    $row = $result->fetch_assoc();
  }
  
  if(isset($_GET['users']) && isset($_SESSION['apiuser']))
  {
    $sql = 'select id, name, facebook_id, role_id, created  from users';
    $users = array();
    $result = $db->query($sql);
    while ($row = $result->fetch_assoc()) {
      array_push($users, $row);
    }
    $r['status'] = 1;
    $r['msg'] = 'ok';
    $r['result'] = $users;
  } else {    
    if(isset($row['password']))
    {
      if(password_verify($password, $row['password']))
      { 
        $_SESSION['apiuser'] = 1;
        $r['status'] = 1;
        $r['msg'] = 'ok';
      } else {
        $r['status'] = -1;
        $r['msg'] = 'Invalid credentials';
      }
    } else {
      $r['status'] = -1;
      $r['msg'] = 'Error';
    }
  }
  header('Content-Type: application/json');
  echo json_encode($r);<commit_msg>Working around the server weirdness<commit_after><?php
  session_start();
  require('config.php');
  require_once('helpers/string.php');
  require_once('classes/database.php');
  
  $db = new Database();
  
  
  $r = array();
  $r['status'] = 0;
  $r['msg'] = '';
  
  if(isset($_GET['u']) && isset($_GET['p']))
  {
    $username = sanitize($_GET['u'], false, true);
    $password = sanitize($_GET['p']);
    $sql = 'select * from users where email = "' .$username . '" limit 1';
    $result = $db->query($sql);
    $row = $result->fetch_assoc();
  }
  
  if(isset($_GET['users']) && isset($_SESSION['apiuser']))
  {
    $sql = 'select id, name, facebook_id, role_id, created  from users';
    $users = array();
    $result = $db->query($sql);
    while ($row = $result->fetch_assoc()) {
      // json encode on the server won't accept direct mysql result array object.
      array_push($users, array(
        'id' => $row['id'],
        'name' => $row['name'],
        'facebook_id' => $row['facebook_id'],
        'role_id' => $row['role_id'],
        'created' => $row['created']
      ));
    }
    $r['status'] = 1;
    $r['msg'] = 'ok';
    $r['result'] = $users;
  } else {    
    if(isset($row['password']))
    {
      if(password_verify($password, $row['password']))
      { 
        $_SESSION['apiuser'] = 1;
        $r['status'] = 1;
        $r['msg'] = 'ok';
      } else {
        $r['status'] = -1;
        $r['msg'] = 'Invalid credentials';
      }
    } else {
      $r['status'] = -1;
      $r['msg'] = 'Error';
    }
  }
  header('Content-Type: application/json');
  echo json_encode($r);
{'fraction_non_alphanumeric': 0.23074289626840122, 'fraction_numerical': 0.004792879150975694, 'mean_word_length': 2.694058154235145, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, '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': '4760596', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1035, 'n_words': 195}