<commit_before><?php
// Initialization
require_once('tiki-setup.php');
include_once('lib/userprefs/userprefslib.php');

// User preferences screen

if($feature_userPreferences != 'y') {
   $smarty->assign('msg',tra("This feature is disabled"));
   $smarty->display("styles/$style_base/error.tpl");
   die;
}

if(!$user) {
   $smarty->assign('msg',tra("You are not logged in"));
   $smarty->display("styles/$style_base/error.tpl");
   die;
}

$userwatch=$user;
if(isset($_REQUEST["view_user"])) {
  if($_REQUEST["view_user"]<>$user) {
    if($tiki_p_admin == 'y') {
      $userwatch = $_REQUEST["view_user"];
    } else {
      $smarty->assign('msg',tra("You dont have permission to view other users data"));
      $smarty->display("styles/$style_base/error.tpl");
      die;
    }
  } else {
    $userwatch = $user;
  }
}
$smarty->assign('userwatch',$userwatch);

// Upload avatar is processed here
if(isset($_FILES['userfile1'])&&is_uploaded_file($_FILES['userfile1']['tmp_name'])) {
  $type = $_FILES['userfile1']['type'];
  $size = $_FILES['userfile1']['size'];
  $name = $_FILES['userfile1']['name'];
  $fp = fopen($_FILES['userfile1']['tmp_name'],"rb");
  $data = fread($fp,filesize($_FILES['userfile1']['tmp_name']));
  fclose($fp);
  if(function_exists("ImageCreateFromString")&&(!strstr($type,"gif"))) {
    $img = imagecreatefromstring($data);
    $size_x = imagesx($img);
    $size_y = imagesy($img);
    if ($size_x > $size_y)
      $tscale = ((int)$size_x / 45);
    else
      $tscale = ((int)$size_y / 45);
    $tw = ((int)($size_x / $tscale));
    $ty = ((int)($size_y / $tscale));
    if (chkgd2()) {
      $t = imagecreatetruecolor($tw,$ty);
      imagecopyresampled($t, $img, 0,0,0,0, $tw,$ty, $size_x, $size_y);
    } else {
      $t = imagecreate($tw,$ty);
      $tikilib->ImageCopyResampleBicubic( $t, $img, 0,0,0,0, $tw,$ty, $size_x, $size_y);
    }
    // CHECK IF THIS TEMP IS WRITEABLE OR CHANGE THE PATH TO A WRITEABLE DIRECTORY
    $tmpfname = tempnam ($tmpDir, "FOO").'.jpg';     
    imagejpeg($t,$tmpfname);
    // Now read the information<commit_msg>fixed bug of upload of new avatar<commit_after><?php
// Initialization
require_once('tiki-setup.php');
include_once('lib/userprefs/userprefslib.php');
include_once('lib/imagegals/imagegallib.php');

// User preferences screen

if($feature_userPreferences != 'y') {
   $smarty->assign('msg',tra("This feature is disabled"));
   $smarty->display("styles/$style_base/error.tpl");
   die;
}

if(!$user) {
   $smarty->assign('msg',tra("You are not logged in"));
   $smarty->display("styles/$style_base/error.tpl");
   die;
}

$userwatch=$user;
if(isset($_REQUEST["view_user"])) {
  if($_REQUEST["view_user"]<>$user) {
    if($tiki_p_admin == 'y') {
      $userwatch = $_REQUEST["view_user"];
    } else {
      $smarty->assign('msg',tra("You dont have permission to view other users data"));
      $smarty->display("styles/$style_base/error.tpl");
      die;
    }
  } else {
    $userwatch = $user;
  }
}
$smarty->assign('userwatch',$userwatch);

// Upload avatar is processed here
if(isset($_FILES['userfile1'])&&is_uploaded_file($_FILES['userfile1']['tmp_name'])) {
  $type = $_FILES['userfile1']['type'];
  $size = $_FILES['userfile1']['size'];
  $name = $_FILES['userfile1']['name'];
  $fp = fopen($_FILES['userfile1']['tmp_name'],"rb");
  $data = fread($fp,filesize($_FILES['userfile1']['tmp_name']));
  fclose($fp);
  if(function_exists("ImageCreateFromString")&&(!strstr($type,"gif"))) {
    $img = imagecreatefromstring($data);
    $size_x = imagesx($img);
    $size_y = imagesy($img);
    if ($size_x > $size_y)
      $tscale = ((int)$size_x / 45);
    else
      $tscale = ((int)$size_y / 45);
    $tw = ((int)($size_x / $tscale));
    $ty = ((int)($size_y / $tscale));
    if (chkgd2()) {
      $t = imagecreatetruecolor($tw,$ty);
      imagecopyresampled($t, $img, 0,0,0,0, $tw,$ty, $size_x, $size_y);
    } else {
      $t = imagecreate($tw,$ty);
      $imagegallib->ImageCopyResampleBicubic( $t, $img, 0,0,0,0, $tw,$ty, $size_x, $size_y);
    }
    // CHECK IF THIS TEMP IS WRITEABLE OR CHANGE THE PATH TO A WRITEABLE DIRECTORY
    $tmpfname = tempnam ($tmpDir, "FOO").'.jpg';     
    imagejpeg($t,$tmpfname);
    // Now read the information
{'fraction_non_alphanumeric': 0.21356012284431844, 'fraction_numerical': 0.009449562957713206, 'mean_word_length': 4.285892634207241, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '618988', 'n_tokens_mistral': 1590, 'n_tokens_neox': 1556, 'n_words': 264}