-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathConfig.php
87 lines (78 loc) · 2.49 KB
/
Config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* This file is part of amfPHP
*
* LICENSE
*
* This source file is subject to the license that is bundled
* with this package in the file license.txt.
* @package Amfphp_BackOffice
*/
/**
* config for the backoffice
*
* @package Amfphp_BackOffice
* @author Ariel Sommeria-Klein
*/
class Amfphp_BackOffice_Config {
/**
* path to amfPHP. relative or absolute. If relative, be careful, it's relative to the script, not this file.
* 'http://silexlabs.org/Tests/TestData/';
* some entry points that pertain to the code:
* '../Amfphp/index.php'
* '../Examples/Php/index.php'
* '../Tests/TestData/index.php'
* @var String
*/
public $amfphpEntryPointPath = '../Amfphp/index.php';
/**
* set credentials for back office here.
* expected format: username => password
* See constructor for example code.
*
* @var array
*/
public $backOfficeCredentials;
/**
* set to false for private server. Set to true for public server.
* true by default
* @var boolean
*/
public $requireSignIn = true;
/**
* if true the back office shall fetch information about the latest version of amfphp and read the
* amfphp news on opening. This information is stored and refreshed only once a week.
*
* @var boolean
*/
public $fetchAmfphpUpdates = true;
/**
* constructor
*/
public function __construct() {
$this->backOfficeCredentials = array();
//example code for username + password:
//$this->backOfficeCredentials['login'] = 'password';
//$this->backOfficeCredentials['a'] = 'a';
$extraConfigPath = dirname(__FILE__) . '/extraConfig.php';
if(file_exists($extraConfigPath)){
include $extraConfigPath;
}
}
/**
* determine url to amfphp. If in config it contains 'http', we consider it's absolute. Otherwise it's relative, and we build it.
* @return string
*/
public function resolveAmfphpEntryPointUrl() {
$httpMarkerPos = strpos($this->amfphpEntryPointPath, 'http');
if ($httpMarkerPos === false) {
$scriptUrl = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
//remove everything after last '/'
$scriptUrlPath = substr($scriptUrl, 0, strrpos($scriptUrl, '/'));
return $scriptUrlPath . '/' . $this->amfphpEntryPointPath;
} else {
return $this->amfphpEntryPointPath;
}
}
}
?>