Select Git revision
valck.php 3.71 KiB
<?php
// Make sure we can't access this file directly from the browser.
if(!defined('IN_MYBB'))
{
die('This file cannot be accessed directly.');
}
// my first hook
$plugins->add_hook("global_start", "valck_run");
function valck_info()
{
/* Versioning of files - dev */
$versionAPP = exec('cd /home/ck/Mygit/MyBB/ckval/ && git rev-parse --short HEAD', $returnval );
$versionAPP_long = exec('cd /home/ck/Mygit/MyBB/ckval/ && git rev-parse HEAD', $returnval );
// descrition of plugin
$ckdescription = <<<EOT
Var for badge about treads count to index <br />
<span style="display: inline-block; margin: 2px 0; padding: 4px; background-color:mediumseagreen; font-size: 9px; color: #fff">
Version du git <a href="https://github.nailis.fr/ckbox/ckval/commit/{$versionAPP_long}" target="_blank" >{$versionAPP_long}</a>
</span>
EOT;
return array(
'name' => "valck",
'description' => $ckdescription,
'website' => "https://www.ckforum.com",
'author' => "ck",
'authorsite' => "http://github.nailis.fr/ckbox/ckval/-/blob/master/upload/inc/plugins/valck.php",
'version' => "1.1 - ".$versionAPP,
'compatibility' => "18*"
);
}
// function execute by index
function valck_run()
{
global $mybb, $lang, $db, $valck_run;
// requete pour les nouveaux messages like getdaily
// Get number of new posts, threads
// via https://community.mybb.com/thread-140350-post-1182934.html#pid1182934
// requete pour le badge message aujourdui
if($mybb->get_input('days', MyBB::INPUT_INT) < 1)
{
$days = 1;
}
else
{
$days = $mybb->get_input('days', MyBB::INPUT_INT);
}
$datecut = TIME_NOW-(86400*$days);
$sql = "SELECT count(*) FROM `".TABLE_PREFIX."threads` where lastpost >= ".$datecut." ORDER BY `tid` DESC";
$query = $db->query("SELECT count(*) as count FROM `" . TABLE_PREFIX . "threads` where lastpost >= ".$datecut." ORDER BY `tid` DESC");
$newposts = $db->fetch_field($query, "count");
$db->free_result($query);
// fin requete message aujourdui
if ($newposts > 0) {
// Get new treads - nouveau sujet like search getnew
// If there aren't any new posts, there is no point in wasting two more queries
$query = $db->simple_select("threads", "COUNT(tid) AS newthreads", "visible=1 AND dateline>'".$mybb->user['lastvisit']."' $unviewwhere");
$newthreads = $db->fetch_field($query, "newthreads");
} else {
$newthreads = 0;