1 - Obtenir l'adresse de l'article en cours dans PluXml
$url_article=$plxShow->plxMotor->urlRewrite('index.php?article'.$plxShow->plxMotor->plxRecord_arts->f('numero').'/'.$plxShow->plxMotor->plxRecord_arts->f('url'))
$url_article=$plxShow->plxMotor->urlRewrite('index.php?article'.$plxShow->plxMotor->plxRecord_arts->f('numero').'/'.$plxShow->plxMotor->plxRecord_arts->f('url'))
$plxMotor=plxMotor::getInstance();
$plugin=$plxMotor->plxPlugins->aPlugins['nom_du_plugin'];
$plugin->methode();
<?php include(PLX_ROOT.$plxMotor->aConf['racine_themes'].$plxMotor->style.'/php/monfichier.php') ?>
<?php $plxShow->staticInclude('002') ?>
echo '<td>'.plxUtils::strCut($plxAdmin->plxRecord_coms->f('author'),30).' / '.$plxAdmin->plxRecord_coms->f('ip').' </td>';
<ul>
<?php ob_start();
$plxShow->catList('',"
<li><a id=\"toggler-#cat_id\" href=\"#cat_url\" onclick=\"toggleDiv('cat-#cat_id','toggler-#cat_id','+ #cat_name','- #cat_name');return false;\" title=\"#cat_name\">+ #cat_name</a> (#art_nb)
<ul id=\"cat-#cat_id\" class=\"hide\">
[#cat_id]
</ul>
</li>");
$list = ob_get_clean();
preg_match_all('!\[([a-zA-Z0-9-_])*\]!',$list,$match);
$art = array();
foreach ($match[1] as $key => $value) {
ob_start();
$plxShow->lastArtList('<li><a href="#art_url">#art_title</a> (#art_nbcoms)</li>', 5, $value,'');
$art[$key] = ob_get_clean();
}
foreach ($match[0] as $key => $value) {
$list = str_replace(array(''',$value),array('\'',$art[$key]),$list);
}
echo $list;
?>
</ul>
<?php $plxShow = plxShow::getInstance();
if ($plxShow->mode() == 'static') :
$group='Documentation';
if (!empty($plxShow->plxMotor->aStats)) {
foreach($plxShow->plxMotor->aStats as $k => $v) {
if ($v['group'] == $group) {
echo '<a href="?static'.intval($k).'/'.$v['url'].'" class="icone_'.strtolower($v['name']).'">'.$v['name'].'</a>';
}
}
}
endif;?>
<?php
/*
Script compteur de visites et compteur de visiteurs en ligne pour PluXml V4 ou V5.
Inspiré de cet article : http://www.asp-php.net/scripts/asp-php/compteurs.php
Installation :
-------------
- Créer un dossier plugins/compteur/
- y ajouter deux fichiers txt vides nommés : cpt.txt et online.txt ainsi que le présent fichier cpt.php
- Modifier le début du fichier header.php de votre thème, juste après le premier "<?php if(!defined('PLX_ROOT')) exit;" en ajoutant :
session_start();
include_once(PLX_ROOT.'plugins/compteur/cpt.php');
- Enfin, modifier le fichier footer.php (par exemple) pour l'affichage du résultat, en ajoutant :
<p><?php
echo $cpt." visiteurs | ";
echo $online." visiteur".$nbtemp;
echo " en ligne";
?></p>
Ce qui affichera par exemple : 324 visiteurs | 2 visiteurs en ligne
Pour info, la variable $nbtemp contient un 's' lorsqu'il y a plus d'un visiteur en ligne ;o)
Ludovic AMATHIEU
http://ludo.qbf.free.fr/
*/
### Compteur de visites ###
if(!isset($_SESSION['visite'])) {$_SESSION['visite'] = "";}
$fichier=PLX_ROOT."plugins/compteur/cpt.txt";
// si c'est le premier hit de la session
if($_SESSION['visite'] == "") {
// marque la session
$_SESSION['visite'] = "ok";
// Incrémente le compteur
$inF = fopen($fichier,"a");
fputs($inF,".");
fclose($inF);
}
// Lecture de la taille du fichier
$cpt = filesize($fichier);
### Compteur de visiteurs en ligne ###
$Fnm = PLX_ROOT."plugins/compteur/online.txt";
// IP du visiteur
$IP=$_SERVER["REMOTE_ADDR"];
// Date/heure courante en minutes
$date0 = time()/60;
// Durée de vie max
$vie = 5;
// Si le fichier existe, on le lit
if (file_exists($Fnm)) {
$inF = fopen($Fnm,"r");
while (!feof($inF)) {
// on lit chaque IP|minutes
$ligne=fgets($inF, 4096);
$temp = explode("|",$ligne);
// différente de l'IP courante ?
if($temp[0]!=$IP) {
// non périmée ?
if($date0-intVal($temp[1])<=$vie) {
$online++;
$result .= $ligne . "n";
}
}
}
fclose($inF);
}
// On ajoute le hit
$result .= $IP . "|" . $date0 . "n";
$online++;
// Et on sauve
$inF = fopen($Fnm,"w");
fputs($inF,$result);
fclose($inF);
if ($online <= 1){$nbtemp = "";} else {$nbtemp = "s";}
?>