<commit_before><?php
class mainFMController {
	public function manage($f3) {
		$isLogin = $f3->get ( 'isLogin' );
		if (! $isLogin) {
			$f3->reroute ( 'login' );
			return;
		}
		echo \Template::instance ()->render ( 'main.html' );
	}
	
	// routeing api
	public function action($f3) {
		$isLogin = $f3->get ( 'isLogin' );
		if (! $isLogin) {
			$f3->reroute ( '../login' );
			return;
		}
		$db = $f3->get ( 'DB' );
		
		// just create an object
		new \DB\SQL\Session ( $db );
		
		$path = $f3->get ( 'SESSION.path' );
		if ($path == null) {
			$path = getcwd ();
			$f3->set ( 'SESSION.path', $path );
		}
		
		switch ($f3->get ( 'PARAMS.action', '' )) {
			case 'get_dir_list' :
				$this->get_dir_list ( $path );
				break;
			case 'cd_to' :
				$this->cd_to ( $f3, $path );
				break;
			case 'delete_dir' :
				$this->delete_dir ( $f3, $path );
				break;
			case 'del' :
				$this->del ( $f3, $path );
				break;
			case 'resetpath' :
				$this->resetpath ( $f3 );
				break;
			case 'upload_file' :
				$this->upload_file ( $f3, $path );
				break;
			case 'new_dir' :
				$this->new_directory ( $f3, $path );
				break;
			case 'unzip':
				$this->unzip($f3, $path);
				break;
			case 'zip':
					$this->zip($f3, $path);
					break;
			case 'download_a_file':
				$this->download_a_file($f3,$path);
				break;
			default :
				echo '404';
				break;
		}
	}
	
	public function upload_file($f3, $path) {
		$web = \Web::instance ();
		if (mb_substr ( $path, (mb_strlen ( $path ) - 1), mb_strlen ( $path ) ) != "/") {
			$up_path = $path . "/";
		} else {
			$up_path = $path;
		}
		$f3->set ( 'UPLOADS', $up_path ); // don't forget to set an Upload directory, and make it writable!
		
		$overwrite = true; // set to true, to overwrite an existing file; Default: false
		$slug = true; // rename file to filesystem-friendly version
		
		$a = $web->receive ( function ($file, $formFieldName) {
			// var_dump($file);
			// maybe you want to check the file size
			if ($file ['size'] > (9 * 1024 * 1024)) // if bigger than 2 MB
				return false; // this file is not valid, return false will skip moving it
				              
			// everything went fine, hurray!
			return true; // allows the file to be moved from php tmp dir to your defined upload dir
		}, $overwrite, $slug );
		
		$result ['ok'] = true;<commit_msg>Update mainFMController.php<commit_after><?php
class mainFMController {
	public function manage($f3) {
		$isLogin = $f3->get ( 'isLogin' );
		if (! $isLogin) {
			$f3->reroute ( 'login' );
			return;
		}
		echo \Template::instance ()->render ( 'main.html' );
	}
	
	// routeing api
	public function action($f3) {
		$isLogin = $f3->get ( 'isLogin' );
		if (! $isLogin) {
			$f3->reroute ( '../login' );
			return;
		}
		$db = $f3->get ( 'DB' );
		
		// just create an object
		new \DB\SQL\Session ( $db );
		
		$path = $f3->get ( 'SESSION.path' );
		if ($path == null) {
			$path = getcwd ();
			$f3->set ( 'SESSION.path', $path );
		}
		
		switch ($f3->get ( 'PARAMS.action', '' )) {
			case 'get_dir_list' :
				$this->get_dir_list ( $path );
				break;
			case 'cd_to' :
				$this->cd_to ( $f3, $path );
				break;
			case 'delete_dir' :
				$this->delete_dir ( $f3, $path );
				break;
			case 'del' :
				$this->del ( $f3, $path );
				break;
			case 'resetpath' :
				$this->resetpath ( $f3 );
				break;
			case 'upload_file' :
				$this->upload_file ( $f3, $path );
				break;
			case 'new_dir' :
				$this->new_directory ( $f3, $path );
				break;
			case 'unzip':
				$this->unzip($f3, $path);
				break;
			case 'zip':
					$this->zip($f3, $path);
					break;
			case 'download_a_file':
				$this->download_a_file($f3,$path);
				break;
			default :
				echo '404';
				break;
		}
	}
	
	public function upload_file($f3, $path) {
		$web = \Web::instance ();
		if (mb_substr ( $path, (mb_strlen ( $path ) - 1), mb_strlen ( $path ) ) != "/") {
			$up_path = $path . "/";
		} else {
			$up_path = $path;
		}
		$f3->set ( 'UPLOADS', $up_path ); // don't forget to set an Upload directory, and make it writable!
		
		$overwrite = true; // set to true, to overwrite an existing file; Default: false
		$slug = false; // rename file to filesystem-friendly version
		
		$a = $web->receive ( function ($file, $formFieldName) {
			// var_dump($file);
			// maybe you want to check the file size
			if ($file ['size'] > (9 * 1024 * 1024)) // if bigger than 2 MB
				return false; // this file is not valid, return false will skip moving it
				              
			// everything went fine, hurray!
			return true; // allows the file to be moved from php tmp dir to your defined upload dir
		}, $overwrite, $slug );
		
		$result ['ok'] = true;
{'fraction_non_alphanumeric': 0.18152524167561762, 'fraction_numerical': 0.015037593984962405, 'mean_word_length': 2.5192743764172336, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4994207', 'n_tokens_mistral': 2074, 'n_tokens_neox': 1708, 'n_words': 458}