Skip to content

[3.0] Fix stat collection registration - #9641

Open
jdarwood007 wants to merge 5 commits into
SimpleMachines:release-3.0from
jdarwood007:3.0/stats
Open

jdarwood007 wants to merge 5 commits into
SimpleMachines:release-3.0from
jdarwood007:3.0/stats

Conversation

@jdarwood007

Copy link
Copy Markdown
Member

I realize as well we should do something about the calls to register stats being in 3 places.

I can't decide how it should proceed. It seems like something we should drop into Maintenance and then reference. Its typically only called from the installer. The acp and upgrader are less likely to call this.

@Sesquipedalian

Sesquipedalian commented Sep 6, 2026

Copy link
Copy Markdown
Member

I realize as well we should do something about the calls to register stats being in 3 places.

I can't decide how it should proceed. It seems like something we should drop into Maintenance and then reference. Its typically only called from the installer. The acp and upgrader are less likely to call this.

How about creating a SMF\Maintenance\Maintenance::registerForStatisticsCollection() method and then just calling it from those other three places?

@jdarwood007

Copy link
Copy Markdown
Member Author

That would work. The other side of the coin was its not really a maintenance task. The registration logic doesn't have a home since the action is fairly straightforward to dump out data, resulting in us not needing any sort of Stats.php or other file. The only benefit to a Stats.php file is to localize all the documentation about what is collected and the action just references the data to call.

@Sesquipedalian

Copy link
Copy Markdown
Member

Sure,a Stats file could work too.

@Sesquipedalian

Copy link
Copy Markdown
Member

Or even just a static method in Actions\Admin\ACP. If it's static, it can be called from wherever. Since the one place that the admin can interact with the stats settings after installation is via the ACP, it makes sense to put it there, too.

@jdarwood007

Copy link
Copy Markdown
Member Author

I went with a dedicated file at the root.

I've expanded the details and also did something we have done server-side (and still do): enabled checking that it's not a local forum, which saves a web fetch call.

I also added a test forum URL on the server side that returns a success response for the requests, mostly as a placeholder should we want to do some testing. No plans for it currently.

Comment thread Sources/Statistics.php Outdated
jdarwood007 and others added 2 commits September 10, 2026 05:18
Comment on lines -1112 to -1124
if (isset($_GET['save'])) {
// If we have saved the proxy_ip_servers, lets ensure that the list has valid entries
if (!empty($_POST['proxy_ip_servers'])) {
$proxy_server_ips = explode(',', $_POST['proxy_ip_servers']);

foreach ($proxy_server_ips as &$ip) {
$ip = trim($ip);
}

$_POST['proxy_ip_servers'] = implode(',', $proxy_server_ips);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this removal intentional? It seems unrelated.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must have got caught up in my changes. Sometimes I work on multiple PRs, and I split those out before I send up.

Comment thread Sources/Statistics.php
Comment on lines +40 to +59
/**
* URL to send the stats collection data to.
* @var string
*/
public static string $collection_url = 'https://www.simplemachines.org/smf/stats/collect_stats.php';

/**
* URL to send the registration to.
* @var string
*/
public static string $register_url = 'https://www.simplemachines.org/smf/stats/register_stats.php?site=';

/**
* This is the referal check, SMF validates that a request for stats comes from this url.
* This is not a perfect check and can be spoofed, however SMF will still initiate a separate connection to
* the collector rather than presenting any data.
*
* @var string
*/
public static string $referer_check = '746cb59a1a0d5cf4bd240e5a67c73085';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should probably be constants. Nothing should be allowed to change them at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants