CreaCaptcha

analytics-export.php

CSV export of the analytics event log.

Table of Contents

Constants

CREATIONELL_CAPTCHA_EXPORT_MAX_ROWS  = 50000
The default upper bound on rows in a single CSV export.

Functions

creationell_captcha_csv_cell()  : string
Neutralises a CSV cell against spreadsheet formula injection.
creationell_captcha_export_events()  : void
Streams the filtered event log as a CSV download.

Constants

CREATIONELL_CAPTCHA_EXPORT_MAX_ROWS

The default upper bound on rows in a single CSV export.

public mixed CREATIONELL_CAPTCHA_EXPORT_MAX_ROWS = 50000

Functions

creationell_captcha_csv_cell()

Neutralises a CSV cell against spreadsheet formula injection.

creationell_captcha_csv_cell(string $value) : string

A value beginning with =, +, - or @ can be executed as a formula by Excel or LibreOffice; a leading single quote forces the spreadsheet to treat the value as text. The path, user_agent, referrer, verification_data and request_body columns all carry bytes an anonymous sender chose.

B-M10: TAB and CR belong in the same list. Both are stripped as leading whitespace while the cell is parsed, so \treq(...) and \r=1+1 reach the formula parser as if the control character were not there — the value is then executed exactly like the four printable starters above. OWASP names them alongside; they were the two the original list missed.

NOT covered, deliberately: a value whose formula starter sits behind other text, and a cell that is dangerous only inside a quoted field. The first is not a formula for any spreadsheet, the second is handled by fputcsv()'s quoting. What this function promises is exactly "the first character cannot start a formula".

Parameters
$value : string

Raw cell value.

Return values
string

creationell_captcha_export_events()

Streams the filtered event log as a CSV download.

creationell_captcha_export_events() : void

Hooked to admin-post.php. Requires the manage_options capability and a valid nonce. The filter (search, event type, date range) is read from the request via the shared parser, so the export mirrors the on-screen filter.

Every reason to refuse is checked BEFORE the first byte goes out. Once the Content-Disposition header and the BOM are on the wire the response is committed to being a successful download, and anything that goes wrong afterwards reaches the admin as a file that looks complete (AF-10/DS-9).


        
On this page

Search results