Meist gelesene Seiten [Topics, 2]
Wieder einmal habe ich auf dem Thema herumgekaut - und dann Google Bard gefragt. Die KI hatte tatsächliche eine überraschend einfache Antwort: Berechne einfach die durchschnittlichen Aufrufe pro Tag. Dann wird auch das Alter mitgerechnet.
Dafür brauche ich nur ein weiteres Feld: Den Zähler. Weil aber schon geraume Zeit in das Feld topic_score reingezählt wird, muss dieses umbenannt werden zu topic_score_counter und das Feld topic_score neu angelegt werden. Das passiert in upgrade.php. Ebendort werden dann auch gleich mal die ganzen Werte für topic_score neu berechnet und schwupp: passt.
Ab dann wird bei jedem Seitenaufruf in view.final.php ausgeführt:
if(!empty($_SERVER['HTTP_USER_AGENT']) and preg_match('~(bot|crawl)~i',
$_SERVER['HTTP_USER_AGENT'])){
//Bot or Crawler: https://stackoverflow.com/questions/17515381/exclude-bots-and-spiders-from-a-view-counter-in-php
} else {
$topic_score_counter = (int) $topic['topic_score_counter'];
$topic_score_counter ++;
//Startzeit:
$posted_first = (int) $topic['posted_first'];
if ($posted_first == 0) {$posted_first =(int) $topic['published_when'];} //0 korrigieren
$age = floor ( ($t - $posted_first) / (3600 * 24) );
$visitsPerDay = $topic_score_counter / $age;
//Das ist meistens unter 1,
dh score ist mal 1000
$topic_score = (int) floor(1000 * $visitsPerDay);
if ($topic['title'] == '' OR $topic_score_counter < 10) {$topic_score = 0;} //neu angelegt
$theq = "UPDATE ".TABLE_PREFIX."mod_".$tablename. " SET topic_score = $topic_score,
topic_score_counter = $topic_score_counter,
posted_first = $posted_first WHERE topic_id = ".TOPIC_ID.";";
$database->query($theq);
}
Das könnte ich sicher noch verfeinern. Aber fürs erste wird es reichen. Kommt mit der nächsten Topics-Version 1.2.4
Für Tipps und Verbesserungsvorschläge bin ich natürlich offen!

DeizerrDunkles für Buntes
Vertal
nexus-responsiveMit Megamenü
fragstanEin Design für große Ansprüche
cloudzMakes a sunny day
dotsflowcolorful and flat
html5up-txt-chioMobile First
lesefaken