<?php
require_once(__DIR__.'/../includes/sysinit.php'); //-->needed here for AJAX calls
function checkAccessLevel($basepath)
{
	//to get here our foundation path is SABLE_WORKING_PATH.'media/';
	$filePath = SABLE_WORKING_PATH.'media/'.$basepath;
	if ($_SESSION['user']['access_level'] <= SABLE_ACCESS_MANAGER)
	{
		$filePath .= $_SESSION['user']['user_code'].'/';
		{
			/**
			For windows, you can't create sub-directories in 1 command, so create each individually:
			mkdir("/tmp");
			mkdir("/tmp/e0b093u209");
			mkdir("/tmp/e0b093u209/thirddir");
			
			failed to create directory http://topspeed.dozer.co.za/media/images/gallery/2/
			
			**/
		}
		if (!file_exists($filePath)) 
		{
			$ok = mkdir($filePath, 0755, true);
			if (!$ok) die('failed to create directory '.$filePath);
		}
	}
	return $filePath;
}
// define who may/may not access this page:
if (SableSystem::loggedIn())
{
	if (!SableSystem::loggedIn()) SableGeneralFunctions::divertFromPage();
} else SableGeneralFunctions::divertFromPage();