Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://doi.org/10.5281/zenodo.594223
07 February 2025, 11:54:05 UTC
  • Code
  • Branches (0)
  • Releases (4)
  • Visits
    • Branches
    • Releases
      • 4
      • 4
      • 3
      • 2
      • 1
    • c501fcf
    • /
    • rubenarslan-formr.org-0797b20
    • /
    • setup.php
    Raw File Download
    Permalinks

    To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
    Select below a type of object currently browsed in order to display its associated SWHID and permalink.

    • content
    • directory
    • snapshot
    • release
    origin badgecontent badge Iframe embedding
    swh:1:cnt:736f94be648f4b641e4ac66bae6013bca55f31e2
    origin badgedirectory badge Iframe embedding
    swh:1:dir:a4f1bf3ec890c395b3ff7526e731387c533a85bd
    origin badgesnapshot badge
    swh:1:snp:fc5be6ea36d914a465ae83272994afb6f8ba2d7d
    origin badgerelease badge
    swh:1:rel:bce81870630aa4105bba65651a8ea173973c44c0
    Citations

    This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
    Select below a type of object currently browsed in order to generate citations for them.

    • content
    • directory
    • snapshot
    • release
    Generate software citation in BibTex format (requires biblatex-software package)
    Generating citation ...
    Generate software citation in BibTex format (requires biblatex-software package)
    Generating citation ...
    Generate software citation in BibTex format (requires biblatex-software package)
    Generating citation ...
    Generate software citation in BibTex format (requires biblatex-software package)
    Generating citation ...
    setup.php
    <?php
    
    define('FORMR_VERSION', 'v0.23.2');
    
    define('APPLICATION_ROOT', __DIR__ . '/');
    define('INCLUDE_ROOT', APPLICATION_ROOT);
    
    define('APPLICATION_PATH', APPLICATION_ROOT . 'application/');
    
    define('APPLICATION_CRYPTO_KEY_FILE', APPLICATION_ROOT . 'formr-crypto.key');
    
    // Load composer Autoloader
    require_once APPLICATION_ROOT . 'vendor/autoload.php';
    
    // Initialize settings array and define routes
    $settings = array();
    $settings['content_settings'] = array();
    $settings['routes'] = array(
    	'admin'          => 'AdminController',
    	'admin/run'      => 'AdminRunController',
    	'admin/survey'   => 'AdminSurveyController',
    	'admin/mail'     => 'AdminMailController',
    	'admin/advanced' => 'AdminAdvancedController',
        'admin/account'  => 'AdminAccountController',
        'public'         => 'PublicController',
    	'api'            => 'ApiController',
    	'run'            => 'RunController'
    );
    
    // Include helper functions
    require_once APPLICATION_PATH . 'Functions.php';
    
    // Load application settings
    /* @var $settings array */
    require_once APPLICATION_ROOT . 'config-dist/settings.php';
    require_once APPLICATION_ROOT . 'config/settings.php';
    
    // Define default assets
    if (php_sapi_name() != 'cli') {
    	require_once APPLICATION_ROOT . 'config-dist/assets.php';
    	require_once APPLICATION_ROOT . 'config-dist/css-classes.php';
    }
    
    // Set current formr version (bumped on release)
    $settings['version'] = FORMR_VERSION;
    
    // Load application autoloader
    $autoloader = require_once APPLICATION_PATH . 'Autoloader.php';
    
    // Initialize Config
    Config::initialize($settings);
    
    // Global Setup
    function __formr_setup($settings = array()) {
    	if (defined('WEBROOT')) {
    		return;
    	}
    
    	$protocol = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == '') ? 'http://' : 'https://';
    	$doc_root = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] . '/' : '/';
    	$online = true;
    
    	if (!empty($settings['protocol'])) {
    		$protocol = $settings['protocol'];
    	}
    
    	define('WEBROOT', $protocol . $doc_root);
    	define('SERVER_NAME', isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '');
    	define('ONLINE', $online);
    	define('SSL', $protocol === "https://");
    	define('RUNROOT', WEBROOT);
    	define('DEBUG', $settings['display_errors']);
    	define('FMRSD_CONTEXT', getenv('FMRSD_CONTEXT'));
    
    	// General PHP-side configuration
    	error_reporting(-1);
    	if (DEBUG > 0) {
    		ini_set('display_errors', 1);
    	} else {
    		ini_set('display_errors',  0);
     	}
    	
    	ini_set("log_errors", 1);
    	ini_set("error_log", get_log_file('errors.log'));
    	ini_set('session.gc_maxlifetime', $settings['session_cookie_lifetime']);
    	ini_set('session.cookie_lifetime', $settings['session_cookie_lifetime']);
    
    	// Set cryptography module
    	try {
    		Crypto::setup();
    	} catch (Exception $e) {
    		formr_log_exception($e);
    		formr_error(503, 'Service Unavailable', 'Encryption service unavailable', null, false);
    	}
    
    	// Set default timzone, encoding and shutdown function.
    	date_default_timezone_set($settings['timezone']);
    	mb_internal_encoding('UTF-8');
    	register_shutdown_function('shutdown_formr_org');
    }
    
    // Bootstrap setup
    __formr_setup($settings);
    
    // Check if maintenance is ongoing
    formr_check_maintenance();
    
    

    back to top

    Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
    The source code of Software Heritage itself is available on our development forge.
    The source code files archived by Software Heritage are available under their own copyright and licenses.
    Terms of use: Archive access, API— Contact— JavaScript license information— Web API