forked from elementary/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…d document their usage. (elementary#1463) * Migrate lang to _lang * Migrate some data to _data * Move l10n * Move sitewide.php * Move most of backend * Update references * Move payment to api endpoint * Move payment pointers * Finish moving backend * Require the preload * Fix template references * Don't .json config * Stop echoing errors * Update contributing guide * Update README.md * Fix backend reference * Fix elementary#1433 * Tidy translation sets * Don't translate into english * Fix sentry reference * fix some store related paths * fix legacy template regex * fix a couple of paths
- Loading branch information
1 parent
c999432
commit 178b8d2
Showing
2,088 changed files
with
305 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
//// Settings | ||
$database = __DIR__.'/../_data/average_payments.db'; | ||
require_once __DIR__.'/log-echo.php'; | ||
|
||
if ( empty($amount) ) { | ||
exit; | ||
} | ||
|
||
//// Error Handling | ||
function LastError($db) { | ||
global $sentry; | ||
$Error = 'Error Code "'.$db->lastErrorCode().'" : '.$db->lastErrorCode(); | ||
if (getenv('PHPENV') !== 'production') { | ||
echo $Error; | ||
} else { | ||
error_log($Error); | ||
$sentry->captureMessage($msg); | ||
} | ||
exit; | ||
} | ||
|
||
//// Open database | ||
if ( !is_writable(dirname($database)) ) { | ||
log_echo('ERROR: database is not writable.'); | ||
exit(1); | ||
} | ||
try { | ||
$db = new SQLite3($database, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE); | ||
} catch (Exception $e) { | ||
log_echo('ERROR: unable to create database'); | ||
exit(2); | ||
} | ||
|
||
if ( $db->lastErrorCode() ) LastError($db); | ||
$db->busyTimeout(300); | ||
if ( $db->lastErrorCode() ) LastError($db); | ||
|
||
//// Initialize database | ||
$query = 'CREATE TABLE IF NOT EXISTS `AveragePayments` (`OS` TEXT PRIMARY KEY, `Total` INTEGER, `Count` INTEGER, `Average` INTEGER);'; | ||
$db->exec($query); // Result-less | ||
|
||
if ( $db->lastErrorCode() ) LastError($db); | ||
|
||
$Systems = array('total', 'android', 'ios', 'windows', 'macos', 'linux', 'other'); | ||
$query = 'DELETE FROM `AveragePayments` WHERE `OS` NOT IN (\''.implode('\', \'', $Systems).'\')'; | ||
$db->exec($query); // Result-less | ||
|
||
foreach ( $Systems as $System ) { | ||
$query = 'INSERT OR IGNORE INTO `AveragePayments` VALUES (\''.$System.'\', 0, 0, 0);'; | ||
$db->exec($query); // Result-less | ||
} | ||
|
||
//// Update | ||
$amount = intval(htmlentities($amount, ENT_QUOTES)); | ||
$os = strtolower(htmlentities($os, ENT_QUOTES)); | ||
$query = 'UPDATE `AveragePayments` SET `Total` = `Total` + \''.$amount.'\', `Count` = `Count` + 1, `Average` = ((`Total` + \''.$amount.'\') / (`Count` + 1)) WHERE `OS`=\''.$os.'\' OR `OS`=\'total\';'; | ||
$result = $db->exec($query); // Result-less | ||
|
||
if ( $db->lastErrorCode() ) LastError($db); | ||
echo 'OK'.PHP_EOL; |
Oops, something went wrong.