<commit_before><?php
require_once ("FileUpload.class.php");
require_once ("ImageResize.class.php");

// setup response
$data = array('response' => null, 'status' => null);

// UPLOAD FILE
$folder = '/uploads/';
$w = $h = 0;
$tw = $th = 0;

$options = isset($_POST['options']) ? $_POST['options'] : null;
if (count($options) > 0) {
	$folder = isset($options['upload_dir']) ? $options['upload_dir'] : $folder;
	$w = isset($options['w']) ? $options['w'] : $w;
	$h = isset($options['h']) ? $options['h'] : $h;
	$tw = isset($options['tw']) ? $options['tw'] : $tw;
	$th = isset($options['th']) ? $options['th'] : $th;
}

if (isset($_FILES)) {
	foreach ($_FILES as $file) {
		$upd = new FileUpload();
		$result = $upd->Put($file, realpath(dirname(__FILE__) . '/../../../') . $folder );
		if ($result) {
			$data['response'] = array('filename' => basename($upd->GetFile(0)), 'url' => $folder . basename($upd->GetFile(0)), 'filepath' => $upd->GetFile(0));
			
			// create thumbnail
			if ($tw > 0) {
				$ir = new ImageResize($data['response']['filepath']);
				$thumb = $ir->CreateThumb($tw, $th);
				$data['response']['thumbnail'] = array('filename' => basename($thumb), 'url' => $folder . basename($thumb), 'filepath' => $thumb);
			}
			
			// resize original file
			if ($w > 0) {
				$large = $ir->Resize($w, $h);<commit_msg>set load path to doc root<commit_after><?php
require_once ("FileUpload.class.php");
require_once ("ImageResize.class.php");

// define constants
defined('APP_PATH') or define('APP_PATH', $_SERVER['DOCUMENT_ROOT'] . '/');

// setup response
$data = array('response' => null, 'status' => null);

// UPLOAD FILE
$folder = '/uploads/';
$w = $h = 0;
$tw = $th = 0;

$options = isset($_POST['options']) ? $_POST['options'] : null;
if (count($options) > 0) {
	$folder = isset($options['upload_dir']) ? $options['upload_dir'] : $folder;
	$w = isset($options['w']) ? $options['w'] : $w;
	$h = isset($options['h']) ? $options['h'] : $h;
	$tw = isset($options['tw']) ? $options['tw'] : $tw;
	$th = isset($options['th']) ? $options['th'] : $th;
}

if (isset($_FILES)) {
	foreach ($_FILES as $file) {
		$upd = new FileUpload();
		$result = $upd->Put($file, realpath(APP_PATH . $folder) );
		if ($result) {
			$data['response'] = array('filename' => basename($upd->GetFile(0)), 'url' => $folder . basename($upd->GetFile(0)), 'filepath' => $upd->GetFile(0));
			
			// create thumbnail
			if ($tw > 0) {
				$ir = new ImageResize($data['response']['filepath']);
				$thumb = $ir->CreateThumb($tw, $th);
				$data['response']['thumbnail'] = array('filename' => basename($thumb), 'url' => $folder . basename($thumb), 'filepath' => $thumb);
			}
			
			// resize original file
			if ($w > 0) {
				$large = $ir->Resize($w, $h);
{'fraction_non_alphanumeric': 0.2575923893157702, 'fraction_numerical': 0.005854372484449323, 'mean_word_length': 4.3713163064833, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '7354880', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1004, 'n_words': 210}