* Creates a folder with proper permissions. * * @param string $name Name of the folder without the trailing slash. * @param string $folder Name of the folder to create $name in. Relative to TH_CORE.TH_CONTENT * @return mixed The absolute path to the folder if creation was successful, otherwise false. */ public static function createFolder($name, $folder = false) { $new = self::$absPath . ($folder ? $folder : "") . rtrim($name, "/") . "/"; self::testWritable(self::$absPath . ($folder ? $folder : "")); $res = mkdir($new); if (function_exists('chmod')) { // 0777 because execute commands are needed for some reason to properly iterate over the folder // and to make new folders. don't ask me why... $res2 = chmod($new, octdec(777)); } return $res && $res2 ? $new : false; } /** * Makes files relative to TH_ROOT instead of being the absolute path. Useful to find the public link: TH_PUB_ROOT."/".Uploads::unbase("/var/www/content/uploads/test.jpg"). * * @param string $file * @return string The relative path (from TH_ROOT) to the file. */ public static function unbase($file) { return mb_substr($file, strlen(utf8_decode(TH_ROOT))); } } Uploads::bootstrap();