/**
  * Create an {@link ErrorPage} for status code 503
  * 
  * @see UnderConstruction_Extension::onBeforeInit()
  * @see DataObjectDecorator::requireDefaultRecords()
  * @return Void
  */
 function requireDefaultRecords()
 {
     // Ensure that an assets path exists before we do any error page creation
     if (!file_exists(ASSETS_PATH)) {
         mkdir(ASSETS_PATH);
     }
     $pageUnderConstructionErrorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = '503'");
     $pageUnderConstructionErrorPageExists = $pageUnderConstructionErrorPage && $pageUnderConstructionErrorPage->exists() ? true : false;
     $pageUnderConstructionErrorPagePath = ErrorPage::get_filepath_for_errorcode(503);
     if (!($pageUnderConstructionErrorPageExists && file_exists($pageUnderConstructionErrorPagePath))) {
         if (!$pageUnderConstructionErrorPageExists) {
             $pageUnderConstructionErrorPage = new ErrorPage();
             $pageUnderConstructionErrorPage->ErrorCode = 503;
             $pageUnderConstructionErrorPage->Title = _t('UnderConstruction.TITLE', 'Under Construction');
             $pageUnderConstructionErrorPage->Content = _t('UnderConstruction.CONTENT', '<p>Sorry, this site is currently under construction.</p>');
             $pageUnderConstructionErrorPage->Status = 'New page';
             $pageUnderConstructionErrorPage->write();
             $pageUnderConstructionErrorPage->publish('Stage', 'Live');
         }
         // Ensure a static error page is created from latest error page content
         $response = Director::test(Director::makeRelative($pageUnderConstructionErrorPage->Link()));
         if ($fh = fopen($pageUnderConstructionErrorPagePath, 'w')) {
             $written = fwrite($fh, $response->getBody());
             fclose($fh);
         }
         if ($written) {
             DB::alteration_message('503 error page created', 'created');
         } else {
             DB::alteration_message(sprintf('503 error page could not be created at %s. Please check permissions', $pageUnderConstructionErrorPagePath), 'error');
         }
     }
 }
Example #2
0
 static function die_fancy($except)
 {
     // Log the error?
     if ($except instanceof InternalException) {
         Log::error($except->getMessage());
     }
     // Utility: error pages
     $view = new ErrorPage($except);
     $view->write();
     exit;
 }
Example #3
0
	/**
	 * Ensures that there is always a 404 page
	 * by checking if there's an instance of
	 * ErrorPage with a 404 error code. If there
	 * is not, one is created when the DB is built.
	 */
	function requireDefaultRecords() {
		parent::requireDefaultRecords();

		if(!DataObject::get_one('ErrorPage', "ErrorCode = '404'")) {
			$errorpage = new ErrorPage();
			$errorpage->ErrorCode = 404;
			$errorpage->Title = _t('ErrorPage.DEFAULTERRORPAGETITLE', 'Page not found');
			$errorpage->URLSegment = 'page-not-found';
			$errorpage->Content = _t('ErrorPage.DEFAULTERRORPAGECONTENT', '<p>Sorry, it seems you were trying to access a page that doesn\'t exist.</p><p>Please check the spelling of the URL you were trying to access and try again.</p>');
			$errorpage->Status = 'New page';
			$errorpage->write();
			
			Database::alteration_message('404 page created', 'created');
		}
	}
 public function testLinkShortcodeHandler()
 {
     $testFile = $this->objFromFixture('File', 'asdf');
     $parser = new ShortcodeParser();
     $parser->register('file_link', array('File', 'handle_shortcode'));
     $fileShortcode = sprintf('[file_link,id=%d]', $testFile->ID);
     $fileEnclosed = sprintf('[file_link,id=%d]Example Content[/file_link]', $testFile->ID);
     $fileShortcodeExpected = $testFile->Link();
     $fileEnclosedExpected = sprintf('<a href="%s" class="file" data-type="txt" data-size="977 KB">Example Content</a>', $testFile->Link());
     $this->assertEquals($fileShortcodeExpected, $parser->parse($fileShortcode), 'Test that simple linking works.');
     $this->assertEquals($fileEnclosedExpected, $parser->parse($fileEnclosed), 'Test enclosed content is linked.');
     $testFile->delete();
     $fileShortcode = '[file_link,id="-1"]';
     $fileEnclosed = '[file_link,id="-1"]Example Content[/file_link]';
     $this->assertEquals('', $parser->parse('[file_link]'), 'Test that invalid ID attributes are not parsed.');
     $this->assertEquals('', $parser->parse('[file_link,id="text"]'));
     $this->assertEquals('', $parser->parse('[file_link]Example Content[/file_link]'));
     if (class_exists('ErrorPage')) {
         $errorPage = ErrorPage::get()->filter('ErrorCode', 404)->First();
         $this->assertEquals($errorPage->Link(), $parser->parse($fileShortcode), 'Test link to 404 page if no suitable matches.');
         $this->assertEquals(sprintf('<a href="%s">Example Content</a>', $errorPage->Link()), $parser->parse($fileEnclosed));
     } else {
         $this->assertEquals('', $parser->parse($fileShortcode), 'Short code is removed if file record is not present.');
         $this->assertEquals('', $parser->parse($fileEnclosed));
     }
 }
 public function onBeforeHTTPError($statusCode, $request)
 {
     $response = ErrorPage::response_for($statusCode);
     if ($response) {
         throw new SS_HTTPResponse_Exception($response, $statusCode);
     }
 }
 public function output()
 {
     // TODO: Refactor into a content-type option
     if (\Director::is_ajax()) {
         return $this->friendlyErrorMessage;
     } else {
         // TODO: Refactor this into CMS
         if (class_exists('ErrorPage')) {
             $errorFilePath = \ErrorPage::get_filepath_for_errorcode($this->statusCode, class_exists('Translatable') ? \Translatable::get_current_locale() : null);
             if (file_exists($errorFilePath)) {
                 $content = file_get_contents($errorFilePath);
                 if (!headers_sent()) {
                     header('Content-Type: text/html');
                 }
                 // $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
                 return str_replace('$BaseURL', \Director::absoluteBaseURL(), $content);
             }
         }
         $renderer = \Debug::create_debug_view();
         $output = $renderer->renderHeader();
         $output .= $renderer->renderInfo("Website Error", $this->friendlyErrorMessage, $this->friendlyErrorDetail);
         if (\Email::config()->admin_email) {
             $mailto = \Email::obfuscate(\Email::config()->admin_email);
             $output .= $renderer->renderParagraph('Contact an administrator: ' . $mailto . '');
         }
         $output .= $renderer->renderFooter();
         return $output;
     }
 }
Example #7
0
function __autoload($classe)
{
    $classe = $classe . '.php';
    if (file_exists('Controller' . DS . $classe)) {
        require_once 'Controller' . DS . $classe;
    } else {
        if (file_exists('Model' . DS . $classe)) {
            require_once 'Model' . DS . $classe;
        } else {
            if (file_exists('Model' . DS . 'Entity' . DS . $classe)) {
                require_once 'Model' . DS . 'Entity' . DS . $classe;
            } else {
                if (file_exists('Model' . DS . 'Interface' . DS . $classe)) {
                    require_once 'Model' . DS . 'Interface' . DS . $classe;
                } else {
                    if (file_exists('Library' . DS . $classe)) {
                        require_once 'Library' . DS . $classe;
                    } else {
                        if (file_exists('Exceptions' . DS . $classe)) {
                            require_once 'Exceptions' . DS . $classe;
                        } else {
                            ///se a pagina nao for encontrada ela renderiza errorPage
                            ErrorPage::page404NotFound($classe);
                        }
                    }
                }
            }
        }
    }
}
 public static function create_default_error_page($code = 404, $values = [], $type = 'ErrorPage')
 {
     if (class_exists('ErrorPage')) {
         return;
     }
     $pagePath = \ErrorPage::get_filepath_for_errorcode($code);
     if (!DataList::create('ErrorPage')->filter('ErrorCode', $code)->exists() || !file_exists($pagePath)) {
         $page = Object::create($type);
         foreach ($values as $f => $v) {
             $page->{$f} = $v;
         }
         $page->ErrorCode = $code;
         $page->write();
         $page->publish('Stage', 'Live');
         $response = static::test(static::makeRelative($page->Link()));
         $written = null;
         if ($fh = fopen($pagePath, 'w')) {
             $written = fwrite($fh, $response->getBody());
             fclose($fh);
         }
         if ($written) {
             DB::alteration_message($page->Title . ' Page created', 'created');
         } else {
             DB::alteration_message(sprintf($page->Title . ' Page could not be created at %s. Please check permissions', $pagePath), 'error');
         }
     }
 }
Example #9
0
 public function getByLink($url)
 {
     if (!($page = Page::get_by_link($url))) {
         $page = ErrorPage::get()->filter('ErrorCode', 404)->first();
     }
     $data = array('timepstamp' => time(), 'page' => $page->forAPI());
     return $data;
 }
Example #10
0
 /**
  * Ensures that there is always a 404 page.
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!DataObject::get_one("ErrorPage", "ErrorCode = '404'")) {
         $errorpage = new ErrorPage();
         $errorpage->ErrorCode = 404;
         $errorpage->Title = _t('ErrorPage.DEFAULTERRORPAGETITLE', 'Page not found');
         $errorpage->URLSegment = "page-not-found";
         $errorpage->ShowInMenus = false;
         $errorpage->Content = _t('ErrorPage.DEFAULTERRORPAGECONTENT', '<p>Sorry, it seems you were trying to access a page that doesn\'t exist.</p><p>Please check the spelling of the URL you were trying to access and try again.</p>');
         $errorpage->Status = "New page";
         $errorpage->write();
         // Don't publish, as the manifest may not be built yet
         // $errorpage->publish("Stage", "Live");
         Database::alteration_message("404 page created", "created");
     }
 }
 /**
  * @return mixed
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Main', $templateDropdownField = DropdownField::create('RenderingTemplate', _t('MaintenanceMode.RENDERINGTEMPLATE', 'Template to render with'), self::get_top_level_templates()), 'Content');
     $templateDropdownField->setEmptyString(_t('MaintenanceMode.DEFAULTTEMPLATE', '(Use default template)'));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Example #12
0
 static function require_admin()
 {
     $user = Authentication::require_user();
     if (!$user->is_admin) {
         ErrorPage::die_fancy(new NotAuthorizedException());
     }
     return $user;
 }
Example #13
0
 function tearDown()
 {
     parent::tearDown();
     ErrorPage::set_static_filepath($this->orig['ErrorPage_staticfilepath']);
     Director::set_environment_type($this->orig['Director_environmenttype']);
     Filesystem::removeFolder($this->tmpAssetsPath . '/ErrorPageTest');
     Filesystem::removeFolder($this->tmpAssetsPath);
 }
Example #14
0
 public function tearDown()
 {
     parent::tearDown();
     ErrorPage::config()->static_filepath = $this->orig['ErrorPage_staticfilepath'];
     Filesystem::removeFolder($this->tmpAssetsPath . '/ErrorPageTest');
     Filesystem::removeFolder($this->tmpAssetsPath);
     Config::inst()->update('Director', 'environment_type', $this->origEnvType);
 }
 function testErrorPageLocations()
 {
     $subsite1 = $this->objFromFixture('Subsite', 'domaintest1');
     Subsite::changeSubsite($subsite1->ID);
     $path = ErrorPage::get_filepath_for_errorcode(500);
     $static_path = Config::inst()->get('ErrorPage', 'static_filepath');
     $expected_path = $static_path . '/error-500-' . $subsite1->domain() . '.html';
     $this->assertEquals($expected_path, $path);
 }
Example #16
0
 public function httpError($code, $message = null)
 {
     if (!Permission::check("ADMIN")) {
         $response = ErrorPage::response_for($code);
     }
     if (empty($response)) {
         $response = $message;
     }
     throw new SS_HTTPResponse_Exception($response);
 }
 /**
  * Process IPN request from ClickBank. Only process POST request
  * 
  * @param	object	$_POST
  * @return	int		HTTP code 
  */
 public function ipn(SS_HTTPRequest $request)
 {
     if ($request->isPost()) {
         if (ClickBankManager::validate_ipn_request($request->postVars())) {
             ClickBankManager::process_ipn_request($request->postVars());
             return Director::get_status_code();
         }
     }
     return ErrorPage::response_for(404);
 }
 /**
  *	Retrieve the correct error page for the current multisite instance.
  *	@param integer
  *	@param SS_HTTPRequest
  *	@throws SS_HTTPResponse_Exception
  */
 public function onBeforeHTTPError($code, $request)
 {
     $errorPage = ErrorPage::get()->filter(array('ErrorCode' => $code, 'SiteID' => Multisites::inst()->getCurrentSiteId()))->first();
     if ($errorPage) {
         Requirements::clear();
         Requirements::clear_combined_files();
         $response = ModelAsController::controller_for($errorPage)->handleRequest($request, DataModel::inst());
         throw new SS_HTTPResponse_Exception($response, $code);
     }
 }
 public function requireDefaultRecords()
 {
     if (Config::inst()->get('UniversalErrorPage', 'ConvertOnDevBuild')) {
         $ErrorPages = ErrorPage::get()->filter('ClassName', 'ErrorPage');
         foreach ($ErrorPages as $ErrorPage) {
             $ErrorPage->ClassName = 'UniversalErrorPage';
             $ErrorPage->write();
             $ErrorPage->doPublish();
             DB::alteration_message("#{$ErrorPage->ID} {$ErrorPage->Title} changed to UniversalErrorPage.", "changed");
         }
     }
 }
 public function alternateFilepathForErrorcode($code, $locale)
 {
     $path = ErrorPage::get_static_filepath();
     $parts = array();
     if ($site = Multisites::inst()->getActiveSite()) {
         $parts[] = $site->Host;
     }
     $parts[] = $code;
     if ($locale && $this->owner->hasExtension('Translatable') && $locale != Translatable::default_locale()) {
         $parts[] = $locale;
     }
     return sprintf("%s/error-%s.html", $path, implode('-', $parts));
 }
 function onBeforeInit()
 {
     if (Config::inst()->get('IpAccess', 'enabled')) {
         $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), Config::inst()->get('IpAccess', 'allowed_ips'));
         if (!$ipAccess->hasAccess()) {
             if (class_exists('ErrorPage', true)) {
                 $response = ErrorPage::response_for(403);
             }
             $response = $response ? $response : 'The requested page could not be found.';
             return $this->owner->httpError(403, $response);
         }
     }
 }
Example #22
0
 public function __construct()
 {
     $this->db = new DB();
     $this->errors = new Errors();
     $this->urlParse();
     try {
         if (file_exists(ROOT_DIR . '/core/controllers/' . $this->controller . '/' . $this->action . '.php')) {
             include_once ROOT_DIR . '/core/controllers/' . $this->controller . '/' . $this->action . '.php';
         } else {
             throw new Exception('Страница не существует');
         }
         $controller = new Controller();
         if (!method_exists($controller, 'index')) {
             throw new Exception('Действие не существует');
         }
         $controller->errors = $this->errors->getErrors();
         $controller->warnings = $this->errors->getWarnings();
         $controller->params = $this->params;
         $controller->index();
     } catch (Exception $e) {
         $this->errors->addError($e->getMessage());
         header('HTTP/1.0 404 Not Found');
         try {
             if (file_exists(ROOT_DIR . '/core/controllers/error404/index.php')) {
                 include_once ROOT_DIR . '/core/controllers/error404/index.php';
             } else {
                 throw new Exception('Не найден шаблон вывода ошибок');
             }
             $controller = new ErrorPage();
             $controller->errors = $this->errors->getErrors();
             $controller->warnings = $this->errors->getWarnings();
             $controller->index();
         } catch (Exception $e) {
             $this->errors->addWarning($e->getMessage());
             $this->errors->showErrorPage();
             die;
         }
     }
 }
Example #23
0
 /**
  * Ensures that there is always a 404 page by checking if there's an
  * instance of ErrorPage with a 404 and 500 error code. If there is not,
  * one is created when the DB is built.
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if ($this->class == 'ErrorPage' && SiteTree::config()->create_default_pages) {
         // Ensure that an assets path exists before we do any error page creation
         if (!file_exists(ASSETS_PATH)) {
             mkdir(ASSETS_PATH);
         }
         $defaultPages = $this->getDefaultRecords();
         foreach ($defaultPages as $defaultData) {
             $code = $defaultData['ErrorCode'];
             $page = DataObject::get_one('ErrorPage', sprintf("\"ErrorPage\".\"ErrorCode\" = '%s'", $code));
             $pageExists = $page && $page->exists();
             $pagePath = self::get_filepath_for_errorcode($code);
             if (!($pageExists && file_exists($pagePath))) {
                 if (!$pageExists) {
                     $page = new ErrorPage($defaultData);
                     $page->write();
                     $page->publish('Stage', 'Live');
                 }
                 // Ensure a static error page is created from latest error page content
                 $response = Director::test(Director::makeRelative($page->Link()));
                 $written = null;
                 if ($fh = fopen($pagePath, 'w')) {
                     $written = fwrite($fh, $response->getBody());
                     fclose($fh);
                 }
                 if ($written) {
                     DB::alteration_message(sprintf('%s error page created', $code), 'created');
                 } else {
                     DB::alteration_message(sprintf('%s error page could not be created at %s. Please check permissions', $code, $pagePath), 'error');
                 }
             }
         }
     }
 }
 /**
  * Tries to find the lightbox based on the id given.
  *
  * @param $request
  * @return HTMLText
  * @throws SS_HTTPResponse_Exception
  */
 public function renderBox($request)
 {
     $url = $request->param('URLSegment');
     $id = (int) preg_replace('/lightbox\\-/', '', $url);
     $lightbox = DataObject::get_by_id('Lightbox', $id);
     if ($lightbox) {
         $callback = $request->getVar('callback');
         $content = $lightbox->renderWith(get_class($lightbox));
         if ($callback) {
             $jsonContent = array('content' => $content->getValue());
             return "{$callback}(" . json_encode($jsonContent) . ");";
         } else {
             return $content;
         }
     }
     $this->httpError(404, ErrorPage::response_for(404));
 }
 public function init()
 {
     parent::init();
     if (Config::inst()->get('IpAccess', 'enabled')) {
         $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), Config::inst()->get('IpAccess', 'allowed_ips'));
         if (!$ipAccess->hasAccess()) {
             $reponse = '';
             if (class_exists('ErrorPage', true)) {
                 $response = ErrorPage::response_for(404);
             }
             return $this->owner->httpError(404, $response ? $response : 'The requested page could not be found.');
         }
     }
     // this prevents loading frontend css and javscript files
     Requirements::clear();
     Requirements::css('adminlogin/css/style.css');
 }
 /**
  * Displays a list of all members on the site that belong to the selected
  * groups.
  *
  * @return string
  */
 public function handleList($request)
 {
     if (!$this->parent->AllowProfileViewing) {
         return ErrorPage::response_for(404);
     }
     $sort = $request->getVar('sort');
     if ($sort && singleton('Member')->hasDatabaseField($sort)) {
         $sort = sprintf('"%s"', Convert::raw2sql($sort));
     } else {
         $sort = '"ID"';
     }
     $groups = $this->parent->Groups();
     $fields = $this->parent->Fields('"MemberListVisible" = 1');
     // List all members that are in at least one of the groups on the
     // parent page.
     if (count($groups)) {
         $groups = implode(',', array_keys($groups->map()));
         $filter = "\"Group_Members\".\"GroupID\" IN ({$groups})";
         $join = 'LEFT JOIN "Group_Members" ' . 'ON "Member"."ID" = "Group_Members"."MemberID"';
     } else {
         $filter = $join = null;
     }
     $members = DataObject::get('Member', $filter, $sort, $join, array('start' => $this->getPaginationStart(), 'limit' => 25));
     if ($members && $fields) {
         foreach ($members as $member) {
             $data = new DataObjectSet();
             $public = $member->getPublicFields();
             foreach ($fields as $field) {
                 if ($field->PublicVisibility == 'MemberChoice' && !in_array($field->MemberField, $public)) {
                     $value = null;
                 } else {
                     $value = $member->{$field->MemberField};
                 }
                 $data->push(new ArrayData(array('MemberID' => $member->ID, 'Name' => $field->MemberField, 'Title' => $field->Title, 'Value' => $value, 'Sortable' => $member->hasDatabaseField($field->MemberField))));
             }
             $member->setField('Fields', $data);
         }
     }
     $this->data()->Title = _t('MemberProfiles.MEMBERLIST', 'Member List');
     $this->data()->Parent = $this->parent;
     $controller = $this->customise(array('Members' => $members));
     return $controller->renderWith(array('MemberProfileViewer_list', 'MemberProfileViewer', 'Page'));
 }
 public function init()
 {
     parent::init();
     if (Config::inst()->get('IpAccess', 'enabled')) {
         $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), Config::inst()->get('IpAccess', 'allowed_ips'));
         if (!$ipAccess->hasAccess()) {
             $reponse = '';
             if (class_exists('ErrorPage', true)) {
                 $response = ErrorPage::response_for(404);
             }
             return $this->owner->httpError(404, $response ? $response : 'The requested page could not be found.');
         }
     }
     if (Config::inst()->get('AdminLogin', 'UseTheme') !== true) {
         // this prevents loading frontend css and javscript files
         Object::useCustomClass('Page_Controller', 'AdminLoginPage_Controller');
         Requirements::css('adminlogin/css/style.css');
     }
     Object::useCustomClass('MemberLoginForm', 'AdminLoginForm');
 }
 public static function handle($arguments, $content, ShortcodeParser $parser, $tag, array $extra = array())
 {
     if (!empty($arguments['id'])) {
         $document = DMSDocument::get()->byID($arguments['id']);
         if ($document && !$document->isHidden()) {
             if ($content) {
                 return sprintf('<a href="%s">%s</a>', $document->Link(), $parser->parse($content));
             } else {
                 if (isset($extra['element'])) {
                     $extra['element']->setAttribute('data-ext', $document->getExtension());
                     $extra['element']->setAttribute('data-size', $document->getFileSizeFormatted());
                 }
                 return $document->Link();
             }
         }
     }
     $error = ErrorPage::get()->filter('ErrorCode', '404')->First();
     if ($error) {
         return $error->Link();
     }
     return '';
 }
 /**
  *	Display an error page on invalid request.
  *
  *	@parameter <{ERROR_CODE}> integer
  *	@parameter <{ERROR_MESSAGE}> string
  */
 public function httpError($code, $message = null)
 {
     // Determine the error page for the given status code.
     $errorPages = ClassInfo::exists('SiteTree') ? ErrorPage::get()->filter('ErrorCode', $code) : null;
     // Allow extension customisation.
     $this->extend('updateErrorPages', $errorPages);
     // Retrieve the error page response.
     if ($errorPages && ($errorPage = $errorPages->first())) {
         Requirements::clear();
         Requirements::clear_combined_files();
         $response = ModelAsController::controller_for($errorPage)->handleRequest(new SS_HTTPRequest('GET', ''), DataModel::inst());
         throw new SS_HTTPResponse_Exception($response, $code);
     } else {
         if ($errorPages && file_exists($cachedPage = ErrorPage::get_filepath_for_errorcode($code, class_exists('Translatable') ? Translatable::get_current_locale() : null))) {
             $response = new SS_HTTPResponse();
             $response->setStatusCode($code);
             $response->setBody(file_get_contents($cachedPage));
             throw new SS_HTTPResponse_Exception($response, $code);
         } else {
             return parent::httpError($code, $message);
         }
     }
 }
 public function setUp()
 {
     parent::setUp();
     Config::inst()->update('CloudAssets', 'disabled', false);
     Config::inst()->update('CloudAssets', 'uploads_disabled', false);
     Config::inst()->update('Director', 'alternate_protocol', 'http');
     if (!file_exists(ASSETS_PATH)) {
         mkdir(ASSETS_PATH);
     }
     /* Create a test folders for each of the fixture references */
     $folderIDs = $this->allFixtureIDs('Folder');
     foreach ($folderIDs as $folderID) {
         $folder = DataObject::get_by_id('Folder', $folderID);
         if (!file_exists(BASE_PATH . "/{$folder->Filename}")) {
             mkdir(BASE_PATH . "/{$folder->Filename}");
         }
     }
     /* Create a test files for each of the fixture references */
     $fileIDs = $this->allFixtureIDs('File');
     foreach ($fileIDs as $fileID) {
         if ($fileID == 'png') {
             continue;
         }
         $file = DataObject::get_by_id('File', $fileID);
         $fh = fopen(BASE_PATH . "/{$file->Filename}", "w");
         fwrite($fh, str_repeat('x', 1000));
         fclose($fh);
     }
     // Conditional fixture creation in case the 'cms' module is installed
     if (class_exists('ErrorPage')) {
         $page = new ErrorPage(array('Title' => 'Page not Found', 'ErrorCode' => 404));
         $page->write();
         $page->publish('Stage', 'Live');
     }
     $src = dirname(__FILE__) . '/test-png32.png';
     $dest = ASSETS_PATH . '/FileTest-folder1/test-png32.png';
     $f = copy($src, $dest);
     if (!$f) {
         die('unable to copy $src to $dest');
     }
     CloudAssets::inst()->clearBucketCache();
 }