<commit_before><?php
include('../includes/config.php');
 
$filename = "";
if(isset($_POST) && $logged_in)
{
  //retrieve the $_POST variables
  $filename = rawurldecode($_POST['file']);
  $file_path  = $CONF['upload_dir'] . $filename;
  $thumbnail_path  = $CONF['upload_dir'] . 'thumbnails/150_150_' . $filename;
  $file_db = $db->select('uploads', "url=? LIMIT 1", array($filename));
  $temp_path = sys_get_temp_dir()."\\".$filename;

  if (file_exists($file_path) && $file_db)
  {
    if ($file_db['hash'] != "")
    {
      $crypt = new Cryptography();
      $result = $crypt->Decrypt($CONF['key'], $file_db['hash'], $file_path, $temp_path, $file_db['cipher']);
      $file_path = $temp_path;
    }
    $file_type = $file_db['type'];
    $pattern = "/^(image)\/(.*)$/";
    if(preg_match($pattern, $file_type))
    {
      $resizeObj = new resize($file_path);
      // *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
      $resizeObj->resizeImage(150, 150, 'auto');
      $resizeObj->saveImage($thumbnail_path, 70);
      $data = array(
                "url" => $filename,
                "user_id" => $user->id,
                "date_added" => date("Y-m-d H:i:s",time())
            );
      $row_id = $db->insert($data, 'ricehalla');
      $data = array(
                "table_name" => 'ricehalla',
                "row_id" => $row_id,
                "user_id" => $user->id,
                "points" => 1
            );
      $db->insert($data, 'votes');
      echo "true";
    }
    else
    {
      echo "Please upload an actual image.";
    }
  }
  else
  {
    echo "No File Found";
  }
}
?><commit_msg>Fixed not using correct file name for checking<commit_after><?php
include('../includes/config.php');
 
$filename = "";
if(isset($_POST) && $logged_in)
{
  //retrieve the $_POST variables
  $filename = rawurldecode($_POST['file']);
  $file_db = $db->select('uploads', "url=? LIMIT 1", array($filename));

  if ($file_db)
  {
    $file_real_name = $file_db['filename'];
    $file_path  = $CONF['upload_dir'] . $file_real_name;
    $thumbnail_path  = $CONF['upload_dir'] . 'thumbnails/150_150_' . $file_real_name;
    $temp_path = sys_get_temp_dir()."\\".$file_real_name;
    if (file_exists($file_path))
    {
      if ($file_db['hash'] != "")
      {
        $crypt = new Cryptography();
        $result = $crypt->Decrypt($CONF['key'], $file_db['hash'], $file_path, $temp_path, $file_db['cipher']);
        $file_path = $temp_path;
      }
      $file_type = $file_db['type'];
      $pattern = "/^(image)\/(.*)$/";
      if(preg_match($pattern, $file_type))
      {
        $resizeObj = new resize($file_path);
        // *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
        $resizeObj->resizeImage(150, 150, 'auto');
        $resizeObj->saveImage($thumbnail_path, 70);
        $data = array(
                  "url" => $filename,
                  "user_id" => $user->id,
                  "date_added" => date("Y-m-d H:i:s",time())
              );
        $row_id = $db->insert($data, 'ricehalla');
        $data = array(
                  "table_name" => 'ricehalla',
                  "row_id" => $row_id,
                  "user_id" => $user->id,
                  "points" => 1
              );
        $db->insert($data, 'votes');
        echo "true";
      }
      else
      {
        echo "Please upload an actual image.";
      }
    }
    else
    {
      echo "No File Found";
    }
  }
  else
  {
    echo "No File Found";
  }
}
?>
{'fraction_non_alphanumeric': 0.19366799771819737, 'fraction_numerical': 0.009697661152310326, 'mean_word_length': 2.271455223880597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '3792717', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1202, 'n_words': 221}