<commit_before><?php
$conn = mysqli_connect(SERVERNAME, USERNAME, PASSWORD, DBNAME);
if ($conn->connect_error) {
	die("Connection failed: " . $conn->connect_error);
}
mysqli_set_charset($conn,"utf8");
$userID = $_SESSION['KID'];
$sql = "SELECT * FROM Korisnici WHERE KID='$userID'";
$result = mysqli_query($conn, $sql);
$userrow = mysqli_fetch_assoc($result);
$name = $userrow['Ime'];
$lastname = $userrow['Prezime'];
$userpic = $userrow['SlikaKorisnika'];
$username = $userrow['KorisnickoIme'];
$passhash = $userrow['<PASSWORD>'];

$imgerror = "";
$infoerror = "";
$passerror = "";
$hideupdatebutton = "";


if(isset($_FILES['image'])){
    $file_size = $_FILES['image']['size'];
    $file_tmp = $_FILES['image']['tmp_name'];
    $file_ext = strtolower(end(explode('.',$_FILES['image']['name'])));
    $extensions= array("jpeg","jpg","png","gif");
    $file_name = "userimg_" . sprintf('%08d', $userID) . "." . $file_ext;

	switch ($_FILES['image']['error']) {
		case 4:
		    $imgerror .= "<span class='textfail'>Prvo odaberite sliku</span><br>";
		    break;
		case (1 || 2):
		        $imgerror .= "<span class='textfail'>Maksimalna veličina slike je 2 MB</span><br>";
		        break;
		case (3 || 6 || 7 || 8):
		    $imgerror .= "<span class='textfail'>Serverska greška prilikom preuzimanja slike, pokušajte kasnije</span><br>";
		    break;
		case (0):
		    $finfo = finfo_open( FILEINFO_MIME_TYPE );
			$mtype = finfo_file( $finfo, $file_tmp );
			finfo_close( $finfo );
			if( $mtype == ( "image/jpeg" ) || 
			    $mtype == ( "image/bmp" ) ||
			    $mtype == ( "image/png" ) || 
			    $mtype == ( "image/gif" )) {
			}
			else {
			    $imgerror .= "<span class='textfail'>Slika može da bude isključivo u formatu JPG, JPEG, PNG ili GIF</span><br>";
			}
			break;
		default: 
			$imgerror .= "<span class='textfail'>Nemamo pojma šta se desilo, tim visoko utreniranih majmuna poslat je da izvidi situaciju</span><br>";
	}
    if($imgerror === "") {
    	move_uploaded_file($file_tmp,"img/" . $file_name);<commit_msg>Profile image no-file error fix<commit_after><?php
$conn = mysqli_connect(SERVERNAME, USERNAME, PASSWORD, DBNAME);
if ($conn->connect_error) {
	die("Connection failed: " . $conn->connect_error);
}
mysqli_set_charset($conn,"utf8");
$userID = $_SESSION['KID'];
$sql = "SELECT * FROM Korisnici WHERE KID='$userID'";
$result = mysqli_query($conn, $sql);
$userrow = mysqli_fetch_assoc($result);
$name = $userrow['Ime'];
$lastname = $userrow['Prezime'];
$userpic = $userrow['SlikaKorisnika'];
$username = $userrow['KorisnickoIme'];
$passhash = $userrow['<PASSWORD>'];

$imgerror = "";
$infoerror = "";
$passerror = "";
$hideupdatebutton = "";


if(isset($_FILES['image'])){
    $file_size = $_FILES['image']['size'];
    $file_tmp = $_FILES['image']['tmp_name'];
    $fext = (explode('.',$_FILES['image']['name']));
  	$file_ext = strtolower(end($fext));
    $extensions= array("jpeg","jpg","png","gif");
    $file_name = "userimg_" . sprintf('%08d', $userID) . "." . $file_ext;

	switch ($_FILES['image']['error']) {
		case 4:
		    $imgerror .= "<span class='textfail'>Prvo odaberite sliku</span><br>";
		    break;
		case (1 || 2):
		        $imgerror .= "<span class='textfail'>Maksimalna veličina slike je 2 MB</span><br>";
		        break;
		case (3 || 6 || 7 || 8):
		    $imgerror .= "<span class='textfail'>Serverska greška prilikom preuzimanja slike, pokušajte kasnije</span><br>";
		    break;
		case (0):
		    $finfo = finfo_open( FILEINFO_MIME_TYPE );
			$mtype = finfo_file( $finfo, $file_tmp );
			finfo_close( $finfo );
			if( $mtype == ( "image/jpeg" ) || 
			    $mtype == ( "image/bmp" ) ||
			    $mtype == ( "image/png" ) || 
			    $mtype == ( "image/gif" )) {
			}
			else {
			    $imgerror .= "<span class='textfail'>Slika može da bude isključivo u formatu JPG, JPEG, PNG ili GIF</span><br>";
			}
			break;
		default: 
			$imgerror .= "<span class='textfail'>Nemamo pojma šta se desilo, tim visoko utreniranih majmuna poslat je da izvidi situaciju</span><br>";
	}
    if($imgerror === "") {
    	move_uploaded_file($file_tmp,"img/" . $file_name);
{'fraction_non_alphanumeric': 0.207763671875, 'fraction_numerical': 0.005859375, 'mean_word_length': 4.172979797979798, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 39, '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': '2681561', 'n_tokens_mistral': 1676, 'n_tokens_neox': 1537, 'n_words': 297}