my-status/old_src/streaks.php

22 lines
No EOL
498 B
PHP

<?php
require_once("config.php");
function markTodayAsSuccess(string $streakId)
{
global $STREAKS_FILE_SUFFIX;
$date = date("Y-m-d");
$entries = getStreakEntries($streakId);
if (in_array($date, $entries)) {
return;
}
file_put_contents($streakId . $STREAKS_FILE_SUFFIX, "$date\n", FILE_APPEND);
}
function getStreakEntries(string $streakId)
{
global $STREAKS_FILE_SUFFIX;
return explode("\n", trim(file_get_contents($streakId . $STREAKS_FILE_SUFFIX)));
}