<?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; } //si nouveau message alors on badge en rouge $mybb->user['pms_unread'] > 0 ? $badgecolornewmesg = "danger blink_me" : $badgecolornewmesg = "warning" ; // le code pour le forum $valck_run = <<<EOT <li> <div class="w-25 p-2"> <a href="{$mybb->settings['bburl']}/search.php?action=getdaily"> <h5><span data-toggle="tooltip" title="{$lang->welcome_todaysposts}" class="align-middle badge badge-primary badge-pill shadow">{$newposts}</span></h5> </a> </div> </li> <li> <div class="w-25 p-2"> <a href="{$mybb->settings['bburl']}/search.php?action=getnew"> <h5><span data-toggle="tooltip" title="{$lang->welcome_newposts}" class="align-middle badge badge-success badge-pill shadow">{$newthreads}</span></h5> </a> </div> </li> <li class="nav-divider"></li> <li> <div class="w-25 p-2"> <a href="{$mybb->settings['bburl']}/private.php"> <h5><span data-toggle="tooltip" title="Message privé non lu!" class="align-middle badge badge-{$badgecolornewmesg} badge-pill shadow">{$mybb->user['pms_unread']}</span></h5> </a> </div> </li> <li> <div class="w-25 p-2"> <a href="{$mybb->settings['bburl']}/private.php"> <h5><span data-toggle="tooltip" title="Tous les messages Privés" class="align-middle badge badge-info badge-pill shadow">{$mybb->user['totalpms']}</span></h5> </a> </div> </li> EOT; return $valck_run; }