Changeset 93655 in spip-zone
- Timestamp:
- Dec 13, 2015, 2:56:27 PM (5 years ago)
- Location:
- _core_/plugins/statistiques
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
_core_/plugins/statistiques/action/statistiques_archiver.php
r93626 r93655 145 145 146 146 // Tenter de donner du temps au temps 147 @set_time_limit(15 *60); // 15mn148 149 $annee_par_mois = date('Y') -STATISTIQUES_ARCHIVER_PAR_MOIS;150 $annee_par_an = date('Y') -STATISTIQUES_ARCHIVER_PAR_AN;147 @set_time_limit(15 * 60); // 15mn 148 149 $annee_par_mois = date('Y') - STATISTIQUES_ARCHIVER_PAR_MOIS; 150 $annee_par_an = date('Y') - STATISTIQUES_ARCHIVER_PAR_AN; 151 151 152 152 $annee_minimum = statistiques_concatener_annee_minimum(); -
_core_/plugins/statistiques/base/delete_referers.php
r93626 r93655 40 40 spip_log("raz des referers operee redirige vers " . _request('redirect')); 41 41 } 42 43 ?> -
_core_/plugins/statistiques/base/delete_stats.php
r93626 r93655 41 41 spip_log("raz des stats operee redirige vers " . _request('redirect')); 42 42 } 43 44 ?> -
_core_/plugins/statistiques/base/stats.php
r93626 r93655 108 108 return $tables_auxiliaires; 109 109 } 110 111 ?> -
_core_/plugins/statistiques/exec/base_delete_referers.php
r93626 r93655 33 33 } 34 34 } 35 36 ?> -
_core_/plugins/statistiques/exec/base_delete_stats.php
r93626 r93655 33 33 } 34 34 } 35 36 ?> -
_core_/plugins/statistiques/formulaires/configurer_compteur.php
r93626 r93655 45 45 return array('message_ok' => _T('config_info_enregistree')); 46 46 } 47 48 ?> -
_core_/plugins/statistiques/genie/popularites.php
r93626 r93655 42 42 $periode = 1; 43 43 // $a est le coefficient d'amortissement depuis la derniere mesure 44 $a = pow(2, -$duree /($demivie*24*3600));44 $a = pow(2, -$duree / ($demivie * 24 * 3600)); 45 45 // $b est la constante multiplicative permettant d'avoir 46 46 // une visite par jour (periode de reference) = un point de popularite … … 48 48 // or, magie des maths, ca vaut log(2) * duree journee/demi-vie 49 49 // si la demi-vie n'est pas trop proche de la seconde ;) 50 $b = log(2) *$periode/$demivie;50 $b = log(2) * $periode / $demivie; 51 51 52 52 return array($a, $b); … … 73 73 } 74 74 75 $duree = time() -$t;75 $duree = time() - $t; 76 76 list($a, $b) = genie_popularite_constantes($duree); 77 77 … … 114 114 115 115 } 116 117 ?> -
_core_/plugins/statistiques/genie/visites.php
r93626 r93655 72 72 // S'il s'agit d'un article, noter ses visites 73 73 if ($log_type == 'article' 74 AND$id_article = intval($log_id_num)74 and $id_article = intval($log_id_num) 75 75 ) { 76 76 if (!isset($visites_a[$id_article])) { … … 117 117 118 118 $compteur = _CRON_LOT_FICHIERS_VISITE; 119 $date_init = time() -30*60;119 $date_init = time() - 30 * 60; 120 120 foreach ($sessions as $item) { 121 121 if (($d = @filemtime($item)) < $date_init) { … … 139 139 140 140 include_spip('genie/popularites'); 141 list($a, $b) = genie_popularite_constantes(24 *3600);141 list($a, $b) = genie_popularite_constantes(24 * 3600); 142 142 143 143 // Maintenant on dispose de plusieurs tableaux qu'il faut ventiler dans … … 192 192 array( 193 193 'visites' => "visites+$n", 194 'popularite' => "popularite+" . number_format(round($n *$b, 2), 2, '.', ''),194 'popularite' => "popularite+" . number_format(round($n * $b, 2), 2, '.', ''), 195 195 'maj' => 'maj' 196 196 ), … … 201 201 sql_update('spip_articles', 202 202 array( 203 'visites' => "visites+" . ($n +1),204 'popularite' => "popularite+" . number_format(round($n *$b, 2), 2, '.', ''),203 'visites' => "visites+" . ($n + 1), 204 'popularite' => "popularite+" . number_format(round($n * $b, 2), 2, '.', ''), 205 205 'maj' => 'maj' 206 206 ), … … 292 292 include_spip('inc/invalideur'); 293 293 if (!defined('_IP_FLOOD_TTL')) { 294 define('_IP_FLOOD_TTL', 24 *3600);294 define('_IP_FLOOD_TTL', 24 * 3600); 295 295 } // 24H par defaut 296 296 $options = array( 297 'mtime' => $_SERVER['REQUEST_TIME'] -_IP_FLOOD_TTL,297 'mtime' => $_SERVER['REQUEST_TIME'] - _IP_FLOOD_TTL, 298 298 ); 299 299 purger_repertoire($dir, $options); … … 320 320 // pour etre prioritaire lors du cron suivant 321 321 if ($encore) { 322 return (0 -$t);322 return (0 - $t); 323 323 } 324 324 … … 328 328 return 1; 329 329 } 330 331 ?> -
_core_/plugins/statistiques/inc/referenceurs.php
r93626 r93655 25 25 */ 26 26 function stats_load_engines() { 27 $arr_engines = Array();27 $arr_engines = array(); 28 28 lire_fichier(find_in_path('engines-list.txt'), $moteurs); 29 29 foreach (array_filter(preg_split("/([\r\n]|#.*)+/", $moteurs)) as $ligne) { … … 93 93 for ($cnt = 0; $cnt < sizeof($arr_engines) && !$found; $cnt++) { 94 94 if ($found = preg_match(',' . $arr_engines[$cnt][2] . ',', $host) 95 OR$found = preg_match(',' . $arr_engines[$cnt][2] . ',', $path)95 or $found = preg_match(',' . $arr_engines[$cnt][2] . ',', $path) 96 96 ) { 97 97 $kw_referer_host = $arr_engines[$cnt][0]; … … 118 118 ) { 119 119 include_spip('inc/charsets'); 120 if (!isset($ie) OR!$cset = $ie) {120 if (!isset($ie) or !$cset = $ie) { 121 121 $cset = 'utf-8'; 122 122 } … … 131 131 $buffer["host"] = $host; 132 132 $buffer["scheme"] = $scheme; 133 if (!isset($buffer["hostname"]) OR!$buffer["hostname"]) {133 if (!isset($buffer["hostname"]) or !$buffer["hostname"]) { 134 134 $buffer["hostname"] = $host; 135 135 } … … 180 180 return ''; 181 181 } 182 183 184 ?> -
_core_/plugins/statistiques/inc/statistiques.php
r93626 r93655 58 58 } 59 59 60 return $moyenne /count($tab);60 return $moyenne / count($tab); 61 61 } 62 62 … … 80 80 return $classement[$type]; 81 81 } 82 83 84 ?> -
_core_/plugins/statistiques/inc/stats_referers_to_array.php
r93626 r93655 88 88 ); 89 89 if (isset($buff["keywords"]) 90 AND$c = $buff["keywords"]90 and $c = $buff["keywords"] 91 91 ) { 92 92 if (!isset($referers[$refhost]['keywords'][$c])) { … … 103 103 } 104 104 } 105 if (isset($set['path']) ORisset($set['keywords'])) {105 if (isset($set['path']) or isset($set['keywords'])) { 106 106 $referers[$refhost]['referers'][] = $set; 107 107 } else { … … 126 126 return $referers; 127 127 } 128 129 130 ?> -
_core_/plugins/statistiques/inc/stats_visites_to_array.php
r93626 r93655 49 49 50 50 $format = str_replace('%', '', $format); 51 $periode = ($unite == 'jour' ? 24 *3600 : 365*24*3600/12);52 $step = intval(round($periode *1.1, 0));51 $periode = ($unite == 'jour' ? 24 * 3600 : 365 * 24 * 3600 / 12); 52 $step = intval(round($periode * 1.1, 0)); 53 53 $glisse = constant('MOYENNE_GLISSANTE_' . strtoupper($unite)); 54 54 moyenne_glissante(); … … 65 65 $r = sql_fetch($res, $serveur); 66 66 // si la derniere n'est pas la date courante, l'ajouter 67 if (!$r AND$last != date($format, $now)) {67 if (!$r and $last != date($format, $now)) { 68 68 $r = array('d' => date($format, $now), 'v' => 0); 69 69 } … … 73 73 $next = strtotime($last); 74 74 $current = strtotime($r['d']); 75 while (($next += $step) < $current AND$d = date($format, $next)) {75 while (($next += $step) < $current and $d = date($format, $next)) { 76 76 if (!isset($data[$d])) { 77 77 $data[$d] = array('visites' => 0, 'moyenne' => moyenne_glissante(0, $glisse)); … … 88 88 $moyenne = end($data); 89 89 $moyenne = prev($data); 90 $moyenne = ($moyenne ANDisset($moyenne['moyenne'])) ? $moyenne['moyenne'] : 0;90 $moyenne = ($moyenne and isset($moyenne['moyenne'])) ? $moyenne['moyenne'] : 0; 91 91 $data[$last]['moyenne'] = $moyenne; 92 92 93 93 // temps restant 94 $remaining = strtotime(date($format, strtotime(date($format, $now)) +$step))-$now;94 $remaining = strtotime(date($format, strtotime(date($format, $now)) + $step)) - $now; 95 95 96 $prorata = $remaining /$periode;96 $prorata = $remaining / $periode; 97 97 98 98 // projection 99 $data[$last]['prevision'] = $data[$last]['visites'] +intval(round($moyenne*$prorata));99 $data[$last]['prevision'] = $data[$last]['visites'] + intval(round($moyenne * $prorata)); 100 100 101 101 return $data; 102 102 } 103 104 105 ?> -
_core_/plugins/statistiques/public/stats.php
r93626 r93655 58 58 59 59 // Rejet des robots (qui sont pourtant des humains comme les autres) 60 if (_IS_BOT OR (isset($referer) ANDstrpbrk($referer, '<>"\''))) {60 if (_IS_BOT or (isset($referer) and strpbrk($referer, '<>"\''))) { 61 61 return; 62 62 } … … 64 64 // Ne pas tenir compte des tentatives de spam des forums 65 65 if ($_SERVER['REQUEST_METHOD'] !== 'GET' 66 OR (isset($contexte['page']) AND$contexte['page'] == 'forum')66 or (isset($contexte['page']) and $contexte['page'] == 'forum') 67 67 ) { 68 68 return; … … 71 71 // rejet des pages 404 72 72 if (isset($GLOBALS['page']['status']) 73 AND$GLOBALS['page']['status'] == 40473 and $GLOBALS['page']['status'] == 404 74 74 ) { 75 75 return; … … 91 91 url_de_base())); 92 92 if (!(($url_site_spip <> '') 93 ANDstrpos('-' . strtolower($referer), strtolower($url_site_spip))94 ANDstrpos($referer, "recherche=") === false)93 and strpos('-' . strtolower($referer), strtolower($url_site_spip)) 94 and strpos($referer, "recherche=") === false) 95 95 ) { 96 96 $log_referer = $referer; … … 147 147 } 148 148 } 149 150 ?> -
_core_/plugins/statistiques/stats_administrations.php
r93626 r93655 40 40 $trouver_table = charger_fonction('trouver_table', 'base'); 41 41 if ($desc = $trouver_table('spip_visites') 42 AND isset($desc['exist']) AND$desc['exist']42 and isset($desc['exist']) and $desc['exist'] 43 43 ) { 44 44 ecrire_meta($nom_meta_base_version, '1.0.0'); … … 77 77 effacer_meta($nom_meta_base_version); 78 78 } 79 80 ?> -
_core_/plugins/statistiques/stats_autoriser.php
r93626 r93655 67 67 function autoriser_voirstats_dist($faire, $type, $id, $qui, $opt) { 68 68 return (($GLOBALS['meta']["activer_statistiques"] != 'non') 69 AND($qui['statut'] == '0minirezo'));69 and ($qui['statut'] == '0minirezo')); 70 70 } 71 71 … … 116 116 117 117 return (in_array('spip_articles', $objets) 118 ORin_array('spip_rubriques', $objets))119 ANDautoriser('voirstats', $type, $id, $qui, $opt);118 or in_array('spip_rubriques', $objets)) 119 and autoriser('voirstats', $type, $id, $qui, $opt); 120 120 } 121 121 … … 134 134 return autoriser('voirstats', $type, $id, $qui, $opt); 135 135 } 136 137 ?> -
_core_/plugins/statistiques/stats_ieconfig.php
r93626 r93655 30 30 return $table; 31 31 } 32 33 ?> -
_core_/plugins/statistiques/stats_pipelines.php
r93626 r93655 90 90 if ( 91 91 isset($flux['args']['contexte']['objet']) 92 AND$objet = $flux['args']['contexte']['objet']93 ANDisset($flux['args']['contexte']['id_objet'])94 AND$id_objet = $flux['args']['contexte']['id_objet']92 and $objet = $flux['args']['contexte']['objet'] 93 and isset($flux['args']['contexte']['id_objet']) 94 and $id_objet = $flux['args']['contexte']['id_objet'] 95 95 ) { 96 96 if ($l = admin_stats($objet, $id_objet, defined('_VAR_PREVIEW') ? _VAR_PREVIEW : '')) { … … 123 123 function admin_stats($objet, $id_objet, $var_preview = "") { 124 124 if ($GLOBALS['meta']["activer_statistiques"] != "non" 125 AND$objet == 'article'126 AND!$var_preview127 ANDautoriser('voirstats')125 and $objet == 'article' 126 and !$var_preview 127 and autoriser('voirstats') 128 128 ) { 129 129 $row = sql_fetsel("visites, popularite", "spip_articles", "id_article=$id_objet AND statut='publie'"); … … 165 165 // stats : toutes les 5 minutes on peut vider un panier de visites 166 166 if (isset($GLOBALS['meta']["activer_statistiques"]) 167 AND$GLOBALS['meta']["activer_statistiques"] == "oui"167 and $GLOBALS['meta']["activer_statistiques"] == "oui" 168 168 ) { 169 169 $taches_generales['visites'] = 300; … … 200 200 if ($GLOBALS['meta']["activer_statistiques"] == "oui") { 201 201 if ($flux['args']['type'] == 'article' 202 AND$id_article = $flux['args']['id']203 ANDautoriser('voirstats', 'article', $id_article)202 and $id_article = $flux['args']['id'] 203 and autoriser('voirstats', 'article', $id_article) 204 204 ) { 205 205 $visites = sql_getfetsel('visites', 'spip_articles', 'id_article=' . intval($id_article)); … … 214 214 return $flux; 215 215 } 216 217 ?>
Note: See TracChangeset
for help on using the changeset viewer.