public static function dirsize($dir, $createifmissing = false) {
		$dirsize = 0;
		if (!file_exists($dir)) {
			if ($createifmissing === true) {
				mkdir($dir);
				return 0;
			}
			throw new \Exception('Directory does not exist!', 400);
		}

		$dir_info = scandir($dir);

		if ($dir{(mb_strlen($dir) - 1)} !== '/') {
			$dir .= '/';
		}

		clearstatcache();
		foreach ($dir_info as $i => $member) {
			if ($member === '.' || $member === '..') {
				continue;
			}
			$abs_member = $dir.$member;
			if (is_file($abs_member)) {
				$dirsize += filesize($abs_member);
			} elseif (is_dir($abs_member)) {
				$dirsize += static::dirsize($abs_member.'/');
			}
		}
		return $dirsize;
	}