Skip to content

Commit b17bbf2

Browse files
committed
Added support for naming INI files .ini.php so that they can be secured without the need for .htaccess files. This should be the new best practice as we aim to make Xataface more friendly to non-apache environments.
1 parent 540f1c0 commit b17bbf2

25 files changed

+53
-6
lines changed

Dataface/Application.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,20 @@ function Dataface_Application($conf = null){
550550
}
551551
$this->_baseUrl = $_SERVER['PHP_SELF'];
552552
if ( !is_array($conf) ) $conf = array();
553-
if ( is_readable(DATAFACE_SITE_PATH.'/conf.ini') ){
554-
$conf = array_merge(parse_ini_file(DATAFACE_SITE_PATH.'/conf.ini', true), $conf);
553+
$configPath = DATAFACE_SITE_PATH.'/conf.ini.php';
554+
if (!is_readable($configPath)) {
555+
$configPath = DATAFACE_SITE_PATH.'/conf.ini';
556+
}
557+
if ( is_readable($configPath) ){
558+
$conf = array_merge(parse_ini_file($configPath, true), $conf);
555559
if ( @$conf['__include__'] ){
556560
$includes = array_map('trim',explode(',', $conf['__include__']));
557561
foreach ($includes as $i){
562+
558563
if ( is_readable($i) ){
559564
$conf = array_merge($conf, parse_ini_file($i, true));
565+
} else if ( is_readable($i.'.php') ){
566+
$conf = array_merge($conf, parse_ini_file($i.'.php', true));
560567
}
561568
}
562569
}

Dataface/ConfigTool.php

+21-4
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,18 @@ function &loadConfigFromINI($type=null, $tablename='__global__'){
161161

162162
if ( $tablename !== '__global__' ){
163163
$paths[] = DATAFACE_PATH.'/lang/'.basename($app->_conf['lang']).'.ini';
164-
$lpaths[] = DATAFACE_SITE_PATH.'/lang/'.basename($app->_conf['lang']).'.ini';
165-
if ( !class_exists('Dataface_Table') ) import('Dataface/Table.php');
166-
$lpaths[] = Dataface_Table::getBasePath($tablename).'/tables/'.basename($tablename).'/lang/'.basename($app->_conf['lang']).'.ini';
167-
164+
$paths[] = DATAFACE_PATH.'/lang/'.basename($app->_conf['lang']).'.ini.php';
165+
$lpaths[] = DATAFACE_SITE_PATH.'/lang/'.basename($app->_conf['lang']).'.ini';
166+
$lpaths[] = DATAFACE_SITE_PATH.'/lang/'.basename($app->_conf['lang']).'.ini.php';
167+
if ( !class_exists('Dataface_Table') ) import('Dataface/Table.php');
168+
$lpaths[] = Dataface_Table::getBasePath($tablename).'/tables/'.basename($tablename).'/lang/'.basename($app->_conf['lang']).'.ini';
169+
$lpaths[] = Dataface_Table::getBasePath($tablename).'/tables/'.basename($tablename).'/lang/'.basename($app->_conf['lang']).'.ini.php';
170+
168171
} else {
169172
$paths[] = DATAFACE_PATH.'/lang/'.basename($app->_conf['lang']).'.ini';
173+
$paths[] = DATAFACE_PATH.'/lang/'.basename($app->_conf['lang']).'.ini.php';
170174
$lpaths[] = DATAFACE_SITE_PATH.'/lang/'.basename($app->_conf['lang']).'.ini';
175+
$lpaths[] = DATAFACE_SITE_PATH.'/lang/'.basename($app->_conf['lang']).'.ini.php';
171176
}
172177

173178
} else if ( $tablename !== '__global__' ){
@@ -176,13 +181,18 @@ function &loadConfigFromINI($type=null, $tablename='__global__'){
176181
// the valuelist each time... and there may be opportunities to
177182
// share between tables
178183
if ( $type != 'valuelists' ) $paths[] = DATAFACE_PATH.'/'.basename($type).'.ini';
184+
if ( $type != 'valuelists' ) $paths[] = DATAFACE_PATH.'/'.basename($type).'.ini.php';
179185
if ( $type != 'valuelists' ) $lpaths[] = DATAFACE_SITE_PATH.'/'.basename($type).'.ini';
186+
if ( $type != 'valuelists' ) $lpaths[] = DATAFACE_SITE_PATH.'/'.basename($type).'.ini.php';
180187
$lpaths[] = Dataface_Table::getBasePath($tablename).'/tables/'.basename($tablename).'/'.basename($type).'.ini';
188+
$lpaths[] = Dataface_Table::getBasePath($tablename).'/tables/'.basename($tablename).'/'.basename($type).'.ini.php';
181189

182190
} else {
183191

184192
$paths[] = DATAFACE_PATH.'/'.basename($type).'.ini';
193+
$paths[] = DATAFACE_PATH.'/'.basename($type).'.ini.php';
185194
$lpaths[] = DATAFACE_SITE_PATH.'/'.basename($type).'.ini';
195+
$lpaths[] = DATAFACE_SITE_PATH.'/'.basename($type).'.ini.php';
186196
}
187197

188198
// Add the ability to override settings in a module.
@@ -194,10 +204,14 @@ function &loadConfigFromINI($type=null, $tablename='__global__'){
194204
$modname = implode('_', $modpath);
195205
if ( $type == 'lang' ){
196206
$paths[] = DATAFACE_SITE_PATH.'/modules/'.basename($modname).'/lang/'.basename($app->_conf['lang']).'.ini';
207+
$paths[] = DATAFACE_SITE_PATH.'/modules/'.basename($modname).'/lang/'.basename($app->_conf['lang']).'.ini.php';
197208
$paths[] = DATAFACE_PATH.'/modules/'.basename($modname).'/lang/'.basename($app->_conf['lang']).'.ini';
209+
$paths[] = DATAFACE_PATH.'/modules/'.basename($modname).'/lang/'.basename($app->_conf['lang']).'.ini.php';
198210
} else {
199211
$paths[] = DATAFACE_SITE_PATH.'/modules/'.basename($modname).'/'.basename($type).'.ini';
212+
$paths[] = DATAFACE_SITE_PATH.'/modules/'.basename($modname).'/'.basename($type).'.ini.php';
200213
$paths[] = DATAFACE_PATH.'/modules/'.basename($modname).'/'.basename($type).'.ini';
214+
$paths[] = DATAFACE_PATH.'/modules/'.basename($modname).'/'.basename($type).'.ini.php';
201215
}
202216
}
203217
}
@@ -325,10 +339,13 @@ function &loadConfigFromINI($type=null, $tablename='__global__'){
325339
$upaths = array();
326340
if ( $type == 'lang' ){
327341
$upaths[] = 'lang/'.$app->_conf['lang'].'.ini';
342+
$upaths[] = 'lang/'.$app->_conf['lang'].'.ini.php';
328343
$upaths[] = 'tables/'.$tablename.'/lang/'.$app->_conf['lang'].'.ini';
344+
$upaths[] = 'tables/'.$tablename.'/lang/'.$app->_conf['lang'].'.ini.php';
329345
} else {
330346
$upaths[] = $type.'.ini';
331347
$upaths[] = 'tables/'.$tablename.'/'.$type.'.ini';
348+
$upaths[] = 'tables/'.$tablename.'/'.$type.'.ini.php';
332349
}
333350
foreach ( $upaths as $p ){
334351
if ( isset($user_config->{$p}) ){

actions.ini actions.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
;;------------------------------------------------------------------------------
23
;; Table tabs
34
;; -----------

lang/ca.ini lang/ca.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
440 = "322"
23
templates.Dataface_Fineprint.COPYRIGHT = "(c) $year Tots els drets reservats"
34
actions.related_records_list.label = "{$query['-relationship']}"

lang/de.ini lang/de.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
440 = "439"
23
templates.Dataface_Fineprint.COPYRIGHT = "(c) $year Alle Rechte vorbehalten"
34
actions.related_records_list.label = "{$query['-relationship']}"

lang/el.ini lang/el.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
actions.edit.label = "Τροποποίηση"
23
actions.summary_edit.label = "Τροποποίηση"
34
templates.Dataface_RecordHistory.LABEL_CHANGES = "Αλλαγές"

lang/en.ini lang/en.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
440 = "440"
23
templates.Dataface_Fineprint.COPYRIGHT = "(c) $year All rights reserved"
34
actions.related_records_list.label = "{$query['-relationship']}"

lang/es.ini lang/es.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
440 = "436"
23
templates.Dataface_Fineprint.COPYRIGHT = "&copy; $year - Todos los derechos reservados"
34
actions.edit.label = "Editar"

lang/fr.ini lang/fr.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
440 = "408"
23
templates.Dataface_Fineprint.COPYRIGHT = "(c) $year Tous droits réservés"
34
actions.related_records_list.label = "{$query['-relationship']}"

lang/it.ini lang/it.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
440 = "440"
23
templates.Dataface_Fineprint.COPYRIGHT = "(c) $year Tutti i diritti riservati"
34
actions.related_records_list.label = "{$query['-relationship']}"

lang/jp.ini lang/jp.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
440 = "149"
23
templates.Dataface_Fineprint.COPYRIGHT = "(c) $year すべての権利を保有"
34
actions.related_records_list.label = "{$query['-関係']}"

lang/nl.ini lang/nl.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
440 = "323"
23
templates.Dataface_Fineprint.COPYRIGHT = "(c) $year Alle rechten voorbehouden"
34
actions.related_records_list.label = "{$query['-relationship']}"

lang/pl.ini lang/pl.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
440 = "424"
23
templates.Dataface_Fineprint.COPYRIGHT = "(c) $year Wszelkie prawa zastrzeżone."
34
actions.related_records_list.label = "{$query['-relationship']}"

lang/pt.ini lang/pt.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
440 = "16"
23
templates.Dataface_Fineprint.COPYRIGHT = "(c) $year Todos os direitos reservados"
34
actions.related_records_list.label = "{$query['-relationship]}"

lang/zh.ini lang/zh.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
440 = "306"
23
templates.Dataface_Fineprint.COPYRIGHT = "(三){$year}保留所有權利"
34
actions.related_records_list.label = "{$query['-relationship']}"

lang/zt.ini lang/zt.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
440 = "306"
23
templates.Dataface_Fineprint.COPYRIGHT = "(c) $year保留所有權利"
34
actions.related_records_list.label = "{$query['-relationship']}"

metadata.ini metadata.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
[translation_state]
23
Type="int(11)"
34
multilingual=1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
;<?php exit;
12
view schema = "Permission to view the schema for a table, field, or relationship"

modules/g2/actions.ini modules/g2/actions.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
[logout > logout]
23
url="{$site_href}?-action=logout"
34
condition="df_is_logged_in()"

modules/g2/lang/en.ini modules/g2/lang/en.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
actions.new.label = "New {$tableObj->getSingularLabel()}"
23
actions.new.description = "Insert a new {$tableObj->getSingularLabel()} into {$tableObj->getLabel()}"
34
actions.import.label = "Import {$tableObj->getLabel()}"

modules/g2/lang/fr.ini modules/g2/lang/fr.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
actions.new.label = "Créer un(e) {$tableObj->getSingularLabel()}"
23
actions.new.description = "Insérer un(e) {$tableObj->getSingularLabel()} dans les {$tableObj->getLabel()}"
34
actions.import.label = "Importer des {$tableObj->getLabel()}"

modules/g2/lang/it.ini modules/g2/lang/it.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
actions.new.label = "Nuovo {$tableObj->getSingularLabel()}"
23
actions.new.description = "Inserire un nuovo {$tableObj->getSingularLabel()} in {$tableObj->getLabel()}"
34
actions.import.label = "Importa {$tableObj->getLabel()}"

modules/g2/lang/pl.ini modules/g2/lang/pl.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
actions.new.label = "Nowy rekord"
23
actions.new.description = "Wstawienie nowego rekordu do {$tableObj->getLabel()}"
34
actions.import.label = "Importuj rekordy"

permissions.ini permissions.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
;;First we will list the permissions and their associated labels.
23

34
;; view : Allowed to view an element

site_skeleton/conf.ini site_skeleton/conf.ini.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
;<?php exit;
12
; File: conf.ini
23
; Description:
34
; ------------

0 commit comments

Comments
 (0)