Skip to content

Commit fccb995

Browse files
author
Christopher Brown
committed
config commenting
1 parent ad864a2 commit fccb995

File tree

3 files changed

+89
-18
lines changed

3 files changed

+89
-18
lines changed

includes/config.inc.php

Lines changed: 86 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,95 @@
44
$config = array(
55

66
'page' => array(
7-
'date_format' => 'M j, Y G:i A',
8-
'time_offset' => 0,
9-
'footer' =>
7+
/**
8+
* The format that dates constructed via PHP are displayed in. See
9+
* http://php.net/manual/en/function.date.php for more information.
10+
*/
11+
'php_date_format' => 'M j, Y G:i A',
12+
13+
/**
14+
* The offset in seconds of the default time zone used for displaying dates.
15+
*/
16+
'php_time_offset' => 0,
17+
18+
/**
19+
* The format that dates constructed via JavaScript are displayed in. See
20+
* https://github.com/phstc/jquery-dateFormat for more information.
21+
*
22+
* This is used when possible to ensure that dates match the visitor's local
23+
* time zone. It should be equivalent to the PHP date format.
24+
*/
25+
'js_date_format' => 'MMM d, yyyy h:mm a',
26+
27+
/**
28+
* Footer HTML.
29+
*/
30+
'footer' =>
1031
'Please direct feedback to <a href="http://www.pathofexile.com/forum/view-thread/69448" target="_blank">this thread</a>. '.
1132
'Want a new feature? <a href="https://github.com/ccbrown/gggtracker" target="_blank">Add it yourself!</a>',
1233
),
1334

14-
'mysql' => array(
15-
'host' => '',
16-
'username' => '',
17-
'password' => '',
18-
'db_name' => '',
19-
'pconnect' => false,
35+
/**
36+
* MySQL information.
37+
*/
38+
'mysql' => array(
39+
'host' => '',
40+
'username' => '',
41+
'password' => '',
42+
'db_name' => '',
43+
'pconnect' => false,
2044
),
2145

46+
/**
47+
* To poll forum posts and Twitter updates, two cron jobs should be set up to invoke
48+
* scan_posts.cron.php and update_tweets.cron.php. These are publically accessible
49+
* files, so to prevent abuse, you must create a random secret here. Then, when
50+
* invoking the scripts, pass that secret as a GET parameter.
51+
*
52+
* Make this long and random.
53+
*/
2254
'cron' => array(
23-
'secret' => '',
55+
'secret' => '',
2456
),
2557

2658
'poe' => array(
27-
'forum_timezone' => '',
28-
'forum_sessid' => '',
29-
'news_forum_id' => 54,
30-
'forum_posters' => array(
59+
/**
60+
* The timezone of the forum account used (e.g. 'GMT' or 'PST').
61+
*/
62+
'forum_timezone' => '',
63+
64+
/**
65+
* The value of the PHPSESSID cookie for a valid login session.
66+
*/
67+
'forum_sessid' => '',
68+
69+
/**
70+
* The id of the news forum.
71+
*/
72+
'news_forum_id' => 54,
73+
74+
/**
75+
* An array of forum posters to track.
76+
*/
77+
'forum_posters' => array(
3178
'Chris', 'Jonathan', 'Erik', 'Mark_GGG', 'Samantha', 'Rory', 'Rhys', 'Qarl',
3279
'Andrew_GGG', 'Damien_GGG', 'Russell', 'Joel_GGG', 'Ari', 'Thomas',
3380
'BrianWeissman', 'Edwin_GGG', 'Support', 'Dylan', 'MaxS', 'Ammon_GGG',
3481
'Jess_GGG', 'Robbie_GGG', 'GGG_Neon', 'Jason_GGG', 'Henry_GGG',
3582
'Michael_GGG', 'Bex_GGG', 'Cagan_GGG', 'Daniel_GGG', 'Kieren_GGG',
3683
'Yeran_GGG', 'Gary_GGG',
3784
),
38-
'twitter_name' => 'pathofexile',
85+
86+
/**
87+
* The Twitter user to track.
88+
*/
89+
'twitter_name' => 'pathofexile',
3990
),
4091

92+
/**
93+
* Twitter-supplied credentials. Create an app at https://apps.twitter.com and obtain
94+
* these through the "Keys and Access Tokens" tab for your app.
95+
*/
4196
'twitter' => array(
4297
'consumer_key' => '',
4398
'consumer_secret' => '',
@@ -46,7 +101,23 @@
46101
),
47102
);
48103

104+
/**
105+
* Any of the above can be overridden in a local configuration file. Simply create a file named
106+
* local_config.php that looks like this:
107+
*
108+
* <?php
109+
* return array(
110+
* '[thing you want to override]' => [the value you want to use],
111+
* ...
112+
* );
113+
* ?>
114+
*
115+
*/
49116
$local = @include('local_config.inc.php');
50117

118+
if (isset($local['date_format']) || isset($local['time_offset'])) {
119+
die('out-dated configuration. review the changes to config.inc.php');
120+
}
121+
51122
return $local ? array_replace_recursive($config, $local) : $config;
52123
?>

includes/footer.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<script>
55
$(function() {
66
$('.js-time').each(function() {
7-
$(this).text($.format.date(new Date($(this).data('time') * 1000), 'MMM d, yyyy h:mm a'));
7+
$(this).text($.format.date(new Date($(this).data('time') * 1000), '<?= $_['page']['js_date_format'] ?>'));
88
});
99
});
1010
</script>

includes/functions.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function create_date($timestamp, $format = NULL) {
6969
if ($timestamp === NULL) {
7070
$date = 'N/A';
7171
} else {
72-
$date = gmdate($format === NULL ? $_['page']['date_format'] : $format, $timestamp + $_['page']['time_offset']);
72+
$date = gmdate($format === NULL ? $_['page']['php_date_format'] : $format, $timestamp + $_['page']['php_time_offset']);
7373
}
7474

7575
return $date;
@@ -81,7 +81,7 @@ function create_gmdate($timestamp, $format = NULL) {
8181
if ($timestamp === NULL) {
8282
$date = 'N/A';
8383
} else {
84-
$date = gmdate($format === NULL ? $_['page']['date_format'] : $format, $timestamp);
84+
$date = gmdate($format === NULL ? $_['page']['php_date_format'] : $format, $timestamp);
8585
}
8686

8787
return $date;

0 commit comments

Comments
 (0)