<commit_before><?php 
	/**
	* BoZoN admin page:
	* allows upload / delete / filter files
	* @author: Bronco (<EMAIL>)
	**/

	include ('auto_restrict.php'); # Admin only!
	include('core.php');
	$message='';

	# search/filter
	if (!empty($_GET['filter'])){$mask=$_GET['filter'];}else{$mask='';}
	

	# get file from url
	if (!empty($_GET['url'])&&$_GET['url']!=''){
		if (remote_file_exists($_GET['url'])){
			$filename=UPLOAD_PATH.pathinfo($_GET['url'],PATHINFO_FILENAME);
			$extension=pathinfo($_GET['url'],PATHINFO_EXTENSION);
			if(is_file($filename.'.'.$extension)){
				$filename=$filename.'_'.uniqid();
			}
			$content=file_curl_contents($_GET['url']);
			file_put_contents($filename.'.'.$extension,$content);

			if (!empty($mask)){$mask='?filter='.$mask;}
			header('location:admin.php'.$mask);
		}else{$message.='<div class="error">'.e('Problem accessing remote file.',false).'</div>';}
	}
	# delete file
	if (!empty($_GET['del'])&&$_GET['del']!=''){
		$f=id2file($_GET['del']);
		if(is_file($f)){
			unlink($f); 
			unset($ids[$_GET['del']]);
			store(ID_FILE,$ids);
			kill_thumb_if_exists($f);
		}
		if (!empty($mask)){$mask='?filter='.$mask;}
		header('location:admin.php'.$mask);
	}
	# rename file
	if (!empty($_GET['ren'])&&!empty($_GET['newname'])){
		$oldfile=id2file($_GET['ren']);
		$extension=pathinfo($oldfile,PATHINFO_EXTENSION);
		$_GET['newname']=only_alphanum_and_dot($_GET['newname']);
		$newfile=$_GET['newname'].'.'.$extension;
		if(is_file($oldfile) && $newfile!=basename($oldfile)){				
			# if newname exists, change newname
			if(is_file(UPLOAD_PATH.$newfile)){
				$newfile=$_GET['newname'].'_'.uniqid().'.'.$extension;
			}
			rename($oldfile,UPLOAD_PATH.$newfile); 
			$ids[$_GET['ren']]=$newfile;
			store(ID_FILE,$ids);
			kill_thumb_if_exists($oldfile);
			kill_thumb_if_exists($newfile);
		}
		if (!empty($mask)){$mask='?filter='.$mask;}
		header('location:admin.php'.$mask);
	}

	if ($_FILES){include('auto_dropzone.php');exit();}

?>
<!DOCTYPE html>
<html  xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" charset="UTF-8">
	<head>
	    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta charset="utf-8" />
		<link rel="shortcut icon" type="/image/png" href="img/bozonlogo2.png">
		<link rel="stylesheet" type="text/css" href="style.css">
		<!--[if IE]><script> document.createElement("article");document.createElement("aside");document.createElement("section");document.createElement("footer");</script> <![endif]-->

		<title>BoZoN: <?php e('Drag, drop, share.');?></title>
	</head>

	<body>
	<header><div class="overlay">
		<div class="lang">
			<?php  
				foreach ($lang as $l=>$content){
					echo '<a href="admin.php?lang='.$l.'">'.$l.'</a>';
				}
			?>
		</div>
		<p class="logo"><strong>BoZoN</strong>: <?php e('Drag, drop, share.');?></p>
		<div class="headerforms">
		<form action="#" method="get" class="searchform">
			<label><?php e('Type to filter the list');?></label>
			<input type="text" name="filter" value="<?php echo $mask; ?>" title="<?php e('Search in the uploaded files'); ?>" placeholder="<?php e('Filter'); ?>"/>
			<input type="submit" value="ok"/>
			<input type="hidden" value="<?php echo LANGUAGE;?>" name="lang"/>
			<?php newToken();?>
		</form>
		<br/>
		<form action="#" method="get">
			<label><?php e('Paste a file\'s URL to get it on this server');?></label>
			<input type="text" name="url" placeholder="http://www.url.com/file.jpg" width="50"/>
			<?php newToken();?>
			<input type="submit" value="ok"/>
		</form>
		</div>
		<div style="clear:both"></div>
		</div>
	</header>
	<?php echo $message;?>
	<table><commit_msg>bugfix: missing token on language change<commit_after><?php 
	/**
	* BoZoN admin page:
	* allows upload / delete / filter files
	* @author: Bronco (<EMAIL>)
	**/

	include ('auto_restrict.php'); # Admin only!
	include('core.php');
	$message='';

	# search/filter
	if (!empty($_GET['filter'])){$mask=$_GET['filter'];}else{$mask='';}
	

	# get file from url
	if (!empty($_GET['url'])&&$_GET['url']!=''){
		if (remote_file_exists($_GET['url'])){
			$filename=UPLOAD_PATH.pathinfo($_GET['url'],PATHINFO_FILENAME);
			$extension=pathinfo($_GET['url'],PATHINFO_EXTENSION);
			if(is_file($filename.'.'.$extension)){
				$filename=$filename.'_'.uniqid();
			}
			$content=file_curl_contents($_GET['url']);
			file_put_contents($filename.'.'.$extension,$content);

			if (!empty($mask)){$mask='?filter='.$mask;}
			header('location:admin.php'.$mask);
		}else{$message.='<div class="error">'.e('Problem accessing remote file.',false).'</div>';}
	}
	# delete file
	if (!empty($_GET['del'])&&$_GET['del']!=''){
		$f=id2file($_GET['del']);
		if(is_file($f)){
			unlink($f); 
			unset($ids[$_GET['del']]);
			store(ID_FILE,$ids);
			kill_thumb_if_exists($f);
		}
		if (!empty($mask)){$mask='?filter='.$mask;}
		header('location:admin.php'.$mask);
	}
	# rename file
	if (!empty($_GET['ren'])&&!empty($_GET['newname'])){
		$oldfile=id2file($_GET['ren']);
		$extension=pathinfo($oldfile,PATHINFO_EXTENSION);
		$_GET['newname']=only_alphanum_and_dot($_GET['newname']);
		$newfile=$_GET['newname'].'.'.$extension;
		if(is_file($oldfile) && $newfile!=basename($oldfile)){				
			# if newname exists, change newname
			if(is_file(UPLOAD_PATH.$newfile)){
				$newfile=$_GET['newname'].'_'.uniqid().'.'.$extension;
			}
			rename($oldfile,UPLOAD_PATH.$newfile); 
			$ids[$_GET['ren']]=$newfile;
			store(ID_FILE,$ids);
			kill_thumb_if_exists($oldfile);
			kill_thumb_if_exists($newfile);
		}
		if (!empty($mask)){$mask='?filter='.$mask;}
		header('location:admin.php'.$mask);
	}

	if ($_FILES){include('auto_dropzone.php');exit();}

?>
<!DOCTYPE html>
<html  xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" charset="UTF-8">
	<head>
	    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta charset="utf-8" />
		<link rel="shortcut icon" type="/image/png" href="img/bozonlogo2.png">
		<link rel="stylesheet" type="text/css" href="style.css">
		<!--[if IE]><script> document.createElement("article");document.createElement("aside");document.createElement("section");document.createElement("footer");</script> <![endif]-->

		<title>BoZoN: <?php e('Drag, drop, share.');?></title>
	</head>

	<body>
	<header><div class="overlay">
		<div class="lang">
			<?php  
				
				foreach ($lang as $l=>$content){
					echo '<a href="admin.php?lang='.$l.'&token=';
					newToken(true);
					echo '">'.$l.'</a>';
				}
			?>
		</div>
		<p class="logo"><strong>BoZoN</strong>: <?php e('Drag, drop, share.');?></p>
		<div class="headerforms">
		<form action="#" method="get" class="searchform">
			<label><?php e('Type to filter the list');?></label>
			<input type="text" name="filter" value="<?php echo $mask; ?>" title="<?php e('Search in the uploaded files'); ?>" placeholder="<?php e('Filter'); ?>"/>
			<input type="submit" value="ok"/>
			<input type="hidden" value="<?php echo LANGUAGE;?>" name="lang"/>
			<?php newToken();?>
		</form>
		<br/>
		<form action="#" method="get">
			<label><?php e('Paste a file\'s URL to get it on this server');?></label>
			<input type="text" name="url" placeholder="http://www.url.com/file.jpg" width="50"/>
			<?php newToken();?>
			<input type="submit" value="ok"/>
		</form>
		</div>
		<div style="clear:both"></div>
		</div>
	</header>
	<?php echo $message;?>
	<table>
{'fraction_non_alphanumeric': 0.2538064165307232, 'fraction_numerical': 0.0035345296356715608, 'mean_word_length': 5.309605488850772, 'pattern_counts': {'":': 0, '<': 127, '<?xml version=': 0, '>': 129, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, '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': '37827', 'n_tokens_mistral': 2953, 'n_tokens_neox': 2706, 'n_words': 425}