Avviato nuovo sistema statistiche
This commit is contained in:
@@ -9,17 +9,22 @@
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f
|
||||
RewriteRule "^(.*)$" "$1.php" [NC,L,QSA]
|
||||
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
|
||||
RewriteRule ^ - [L]
|
||||
|
||||
RewriteRule "^(api/.*)$" "api/index.php" [NC,L,QSA]
|
||||
|
||||
RewriteRule "sitemap.xml" "sitemap.php" [L,QSA]
|
||||
RewriteRule "^(.*)articolo_(.*)$" "$1articolo.php?id=$2" [QSA]
|
||||
RewriteRule "^art_(.*).html$" "articolo.php?short=$1" [QSA]
|
||||
RewriteRule "^mobile/art_(.*).html$" "mobile/articolo.php?short=$1" [QSA]
|
||||
RewriteRule "^(.*)categorySummary_(.*)$" "$1categorySummary.php?category=$2" [QSA]
|
||||
RewriteRule "^(.*)dynImg/(.*)/(.*)$" "$1getImage.php?id=$3&size=$2" [QSA]
|
||||
RewriteRule "giornale/all/.*" "oldArticleRedirect.php" [L,QSA]
|
||||
RewriteRule "Giornale/all/.*" "oldArticleRedirect.php" [L,QSA]
|
||||
|
||||
</Directory>
|
||||
|
||||
<IfModule xsendfile_module>
|
||||
XSendFile on
|
||||
XSendFilePath "/tmp/xsend"
|
||||
</IfModule>
|
||||
|
||||
|
||||
</VirtualHost>
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
require_once(dirname(__FILE__)."/../load.php");
|
||||
|
||||
|
||||
|
||||
function getModels() {
|
||||
static $iteration = 0;
|
||||
$size = 1000;
|
||||
@@ -32,7 +30,7 @@ exit;
|
||||
$models = getModels();
|
||||
while (sizeof($models)>0) {
|
||||
foreach ($models as $model) {
|
||||
|
||||
|
||||
}
|
||||
$models = getModels();
|
||||
}
|
||||
|
||||
+112
-140
@@ -8,6 +8,26 @@ class AnalyticsHelper {
|
||||
private static $COOKIE_NAME = "FDN_STAT_NUM";
|
||||
private static $COOKIE_TIME = "+1 year";
|
||||
|
||||
|
||||
public static function pageImpression($content, $d, $m, $y, $isUnique) {
|
||||
$dao = GlobalVariables::get("dao");
|
||||
if ($dao instanceof GenericDao) {
|
||||
$upd = [
|
||||
'$inc' => [
|
||||
'views' => 1
|
||||
]
|
||||
];
|
||||
if ($isUnique) {
|
||||
$upd['$inc']['unique'] = 1;
|
||||
}
|
||||
$dao->rawUpsert(
|
||||
PageViewStatsModel::class,
|
||||
PageViewStatsModel::getFilter($content, $d, $m, $y),
|
||||
$upd
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* La funzione si occupa del salvataggio vero e proprio della impression della pagina.
|
||||
* UTILIZZARE QUESTA FUNZIONE SOLO NELLA PAGINA DI BACKEND (stats/pageImpression.php). Nelle pagine base utilizzare invece la funzione di log
|
||||
@@ -15,37 +35,21 @@ class AnalyticsHelper {
|
||||
* @param string $content
|
||||
* @param string $source
|
||||
*/
|
||||
public static function savePageImpression($ip, $content, $source){
|
||||
$tmp = new stdClass();
|
||||
|
||||
$tmp->user = null;
|
||||
if (isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
$id = $_COOKIE[self::$COOKIE_NAME];
|
||||
|
||||
$tmp->user = new stdClass();
|
||||
$tmp->user->id = $id;
|
||||
$tmp->user->isNew = false;
|
||||
if (GlobalVariables::get("dao")->count("StatisticModel",array("user.id"=>$id))==0){
|
||||
$tmp->user->isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
$tmp->content = $content;
|
||||
$tmp->source = $source;
|
||||
$tmp->ip = $ip;
|
||||
$tmp->statType = StatisticModel::STAT_TYPE_PAGE;
|
||||
$stat = new StatisticModel($tmp);
|
||||
GlobalVariables::get("dao")->save($stat);
|
||||
public static function savePageImpression($ip, $content, $source) {
|
||||
self::pageImpression(
|
||||
$content,
|
||||
intval(date('d')),
|
||||
intval(date('m')),
|
||||
intval(date('Y')),
|
||||
!isset($_COOKIE[self::$COOKIE_NAME])
|
||||
);
|
||||
self::prepareStatCookie();
|
||||
}
|
||||
|
||||
/**
|
||||
* La funzione si occupa di aggiungere una visualizzazione alla pagina corrente
|
||||
*/
|
||||
public static function logPageImpression(){
|
||||
if (!isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
self::prepareStatCookie();
|
||||
}
|
||||
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
$content = $_SERVER['PHP_SELF'];
|
||||
$source = null;
|
||||
@@ -63,6 +67,21 @@ class AnalyticsHelper {
|
||||
}
|
||||
|
||||
|
||||
public static function notiziaImpression($content, $d, $m, $y) {
|
||||
$dao = GlobalVariables::get("dao");
|
||||
if ($dao instanceof GenericDao) {
|
||||
$dao->rawUpsert(
|
||||
ArticleStatsModel::class,
|
||||
ArticleStatsModel::getFilter($content, $d, $m, $y),
|
||||
[
|
||||
'$inc' => [
|
||||
'views' => 1
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* La funzione si occupa del salvataggio vero e proprio della impression della notizia.
|
||||
* UTILIZZARE QUESTA FUNZIONE SOLO NELLA PAGINA DI BACKEND (stats/notiziaImpression.php). Nelle pagine base utilizzare invece la funzione di log
|
||||
@@ -70,34 +89,13 @@ class AnalyticsHelper {
|
||||
* @param string $content
|
||||
* @param string $source
|
||||
*/
|
||||
public static function saveNotiziaImpression($ip, $notiziaId, $source){
|
||||
$tmp = new stdClass();
|
||||
|
||||
$tmp->user = null;
|
||||
if (isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
$id = $_COOKIE[self::$COOKIE_NAME];
|
||||
|
||||
$tmp->user = new stdClass();
|
||||
$tmp->user->id = $id;
|
||||
$tmp->user->isNew = false;
|
||||
if (GlobalVariables::get("dao")->count("StatisticModel",array("user.id"=>$id))==0){
|
||||
$tmp->user->isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
$tmp->content = new stdClass();
|
||||
$notizia = GlobalVariables::get("dao")->getFirst("NotiziaModel",array("id"=>$notiziaId));
|
||||
if (!is_null($notizia)){
|
||||
$tmp->content->notizia = $notiziaId;
|
||||
$tmp->content->category = $notizia->category;
|
||||
|
||||
$tmp->source = $source;
|
||||
$tmp->ip = $ip;
|
||||
$tmp->statType = StatisticModel::STAT_TYPE_NOTIZIA;
|
||||
$stat = new StatisticModel($tmp);
|
||||
GlobalVariables::get("dao")->save($stat);
|
||||
}
|
||||
|
||||
public static function saveNotiziaImpression($ip, $notiziaId, $source) {
|
||||
self::notiziaImpression(
|
||||
$notiziaId,
|
||||
intval(date('d')),
|
||||
intval(date('m')),
|
||||
intval(date('Y'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,21 +123,44 @@ class AnalyticsHelper {
|
||||
* @param string $id
|
||||
*/
|
||||
public static function countNotiziaImpressions($id, $start = null, $end = null){
|
||||
$searchArray = array("statType"=>StatisticModel::STAT_TYPE_NOTIZIA,"content.notizia"=>$id);
|
||||
if (!is_null($start)){
|
||||
// $searchArray["date"]['$gte'] = new MongoDate($start);
|
||||
$searchArray["date"]['$gte'] = new MongoDB\BSON\UTCDateTime( $start * 1000 );
|
||||
|
||||
}
|
||||
if (!is_null($end)){
|
||||
// $searchArray["date"]['$lte'] = new MongoDate($end);
|
||||
$searchArray["date"]['$lte'] = new MongoDB\BSON\UTCDateTime( $end * 1000 );
|
||||
}
|
||||
return GlobalVariables::get("dao")->count("StatisticModel",$searchArray);
|
||||
$ret = GlobalVariables::get("dao")->aggregate(
|
||||
ArticleStatsModel::class,
|
||||
PipelineHelper::getNotiziaImpressions($id, $start, $end)
|
||||
);
|
||||
|
||||
return sizeof($ret) == 0 ? 0 : $ret[0]['tot'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function bannerImpression($bannerId, $d, $m, $y) {
|
||||
$dao = GlobalVariables::get("dao");
|
||||
if ($dao instanceof GenericDao) {
|
||||
$dao->rawUpsert(
|
||||
BannerStatsModel::class,
|
||||
BannerStatsModel::getFilter($bannerId, $d, $m, $y),
|
||||
[
|
||||
'$inc' => [
|
||||
'views' => 1
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
public static function bannerClick($bannerId, $d, $m, $y) {
|
||||
$dao = GlobalVariables::get("dao");
|
||||
if ($dao instanceof GenericDao) {
|
||||
$dao->rawUpsert(
|
||||
BannerStatsModel::class,
|
||||
BannerStatsModel::getFilter($bannerId, $d, $m, $y),
|
||||
[
|
||||
'$inc' => [
|
||||
'clicks' => 1
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* La funzione si occupa del salvataggio vero e proprio della impression del banner.
|
||||
* UTILIZZARE QUESTA FUNZIONE SOLO NELLA PAGINA DI BACKEND (stats/bannerImpression.php). Nelle pagine base utilizzare invece la funzione di log
|
||||
@@ -148,33 +169,12 @@ class AnalyticsHelper {
|
||||
* @param string $source
|
||||
*/
|
||||
public static function saveBannerImpression($ip, $bannerId, $source){
|
||||
$tmp = new stdClass();
|
||||
|
||||
$tmp->user = null;
|
||||
if (isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
$id = $_COOKIE[self::$COOKIE_NAME];
|
||||
|
||||
$tmp->user = new stdClass();
|
||||
$tmp->user->id = $id;
|
||||
$tmp->user->isNew = false;
|
||||
if (GlobalVariables::get("dao")->count("StatisticModel",array("user.id"=>$id))==0){
|
||||
$tmp->user->isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
$tmp->content = new stdClass();
|
||||
$banner = GlobalVariables::get("dao")->getFirst("BannerModel",array("id"=>$bannerId));
|
||||
if (!is_null($banner)){
|
||||
$tmp->content->banner = $bannerId;
|
||||
$tmp->content->position = $banner->position;
|
||||
|
||||
$tmp->source = $source;
|
||||
$tmp->ip = $ip;
|
||||
$tmp->statType = StatisticModel::STAT_TYPE_BANNER_IMPRESSION;
|
||||
$stat = new StatisticModel($tmp);
|
||||
GlobalVariables::get("dao")->save($stat);
|
||||
}
|
||||
|
||||
self::bannerImpression(
|
||||
$bannerId,
|
||||
intval(date('d')),
|
||||
intval(date('m')),
|
||||
intval(date('Y'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,20 +201,16 @@ class AnalyticsHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Restitusce il numero di impressions per una notizia
|
||||
* Restitusce il numero di impressions per un banner
|
||||
* @param string $id
|
||||
*/
|
||||
public static function countBannerImpressions($id, $start = null, $end = null){
|
||||
$searchArray = array("statType"=>StatisticModel::STAT_TYPE_BANNER_IMPRESSION,"content.banner"=>$id);
|
||||
if (!is_null($start)){
|
||||
// $searchArray["date"]['$gte'] = new MongoDate($start);
|
||||
$searchArray["date"]['$gte'] = new MongoDB\BSON\UTCDateTime($start * 1000);
|
||||
}
|
||||
if (!is_null($end)){
|
||||
// $searchArray["date"]['$lte'] = new MongoDate($end);
|
||||
$searchArray["date"]['$lte'] = new MongoDB\BSON\UTCDateTime($end * 1000);
|
||||
}
|
||||
return GlobalVariables::get("dao")->count("StatisticModel",$searchArray);
|
||||
$ret = GlobalVariables::get("dao")->aggregate(
|
||||
BannerStatsModel::class,
|
||||
PipelineHelper::getBannerImpressions($id, $start, $end)
|
||||
);
|
||||
|
||||
return sizeof($ret) == 0 ? 0 : $ret[0]['tot'];
|
||||
}
|
||||
|
||||
|
||||
@@ -226,32 +222,12 @@ class AnalyticsHelper {
|
||||
* @param string $source
|
||||
*/
|
||||
public static function saveBannerClick($bannerId, $source){
|
||||
$tmp = new stdClass();
|
||||
|
||||
$tmp->user = null;
|
||||
if (isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
$id = $_COOKIE[self::$COOKIE_NAME];
|
||||
|
||||
$tmp->user = new stdClass();
|
||||
$tmp->user->id = $id;
|
||||
$tmp->user->isNew = false;
|
||||
if (GlobalVariables::get("dao")->count("StatisticModel",array("user.id"=>$id))==0){
|
||||
$tmp->user->isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
$tmp->content = new stdClass();
|
||||
$banner = GlobalVariables::get("dao")->getFirst("BannerModel",array("id"=>$bannerId));
|
||||
if (!is_null($banner)){
|
||||
$tmp->content->banner = $bannerId;
|
||||
$tmp->content->position = $banner->position;
|
||||
|
||||
$tmp->source = $source;
|
||||
$tmp->ip = $_SERVER['REMOTE_ADDR'];
|
||||
$tmp->statType = StatisticModel::STAT_TYPE_BANNER_CLICK;
|
||||
$stat = new StatisticModel($tmp);
|
||||
GlobalVariables::get("dao")->save($stat);
|
||||
}
|
||||
self::bannerClick(
|
||||
$bannerId,
|
||||
intval(date('d')),
|
||||
intval(date('m')),
|
||||
intval(date('Y'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,16 +246,12 @@ class AnalyticsHelper {
|
||||
* @param string $id
|
||||
*/
|
||||
public static function countBannerClicks($id, $start = null, $end = null){
|
||||
$searchArray = array("statType"=>StatisticModel::STAT_TYPE_BANNER_CLICK,"content.banner"=>$id);
|
||||
if (!is_null($start)){
|
||||
// $searchArray["date"]['$gte'] = new MongoDate($start);
|
||||
$searchArray["date"]['$gte'] = new MongoDB\BSON\UTCDateTime($start * 1000);
|
||||
}
|
||||
if (!is_null($end)){
|
||||
// $searchArray["date"]['$lte'] = new MongoDate($end);
|
||||
$searchArray["date"]['$lte'] = new MongoDB\BSON\UTCDateTime($end * 1000);
|
||||
}
|
||||
return GlobalVariables::get("dao")->count("StatisticModel",$searchArray);
|
||||
$ret = GlobalVariables::get("dao")->aggregate(
|
||||
BannerStatsModel::class,
|
||||
PipelineHelper::getBannerClicks($id, $start, $end)
|
||||
);
|
||||
|
||||
return sizeof($ret) == 0 ? 0 : $ret[0]['tot'];
|
||||
}
|
||||
|
||||
|
||||
@@ -314,7 +286,7 @@ class AnalyticsHelper {
|
||||
}
|
||||
|
||||
// $baseSearchArray = array("position"=>$position,"end"=>array('$gte'=>new MongoDate(strtotime("tomorrow"))),"categories"=>$category);
|
||||
$baseSearchArray = array("position"=>$position,"end"=>array('$gte'=>new MongoDB\BSON\UTCDateTime( strtotime("tomorrow") * 1000 ) ),"categories"=>$category);
|
||||
$baseSearchArray = array("position"=>$position,"end"=>array('$gte'=>new MongoDB\BSON\UTCDateTime( strtotime("tomorrow CET") * 1000 ) ),"categories"=>$category);
|
||||
// Prendi il primo dei "mai mostrati oggi" tra quelli non presenti nella pagina
|
||||
$todayPlusShown = array_merge($idList,$shown);
|
||||
if (sizeof($todayPlusShown)>0){
|
||||
|
||||
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 27/gen/2016
|
||||
*/
|
||||
|
||||
class AnalyticsHelper {
|
||||
private static $COOKIE_NAME = "FDN_STAT_NUM";
|
||||
private static $COOKIE_TIME = "+1 year";
|
||||
|
||||
/**
|
||||
* La funzione si occupa del salvataggio vero e proprio della impression della pagina.
|
||||
* UTILIZZARE QUESTA FUNZIONE SOLO NELLA PAGINA DI BACKEND (stats/pageImpression.php). Nelle pagine base utilizzare invece la funzione di log
|
||||
* @param string $ip
|
||||
* @param string $content
|
||||
* @param string $source
|
||||
*/
|
||||
public static function savePageImpression($ip, $content, $source) {
|
||||
$tmp = new stdClass();
|
||||
|
||||
$tmp->user = null;
|
||||
if (isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
$id = $_COOKIE[self::$COOKIE_NAME];
|
||||
|
||||
$tmp->user = new stdClass();
|
||||
$tmp->user->id = $id;
|
||||
$tmp->user->isNew = false;
|
||||
if (GlobalVariables::get("dao")->count("StatisticModel",array("user.id"=>$id))==0){
|
||||
$tmp->user->isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
$tmp->content = $content;
|
||||
$tmp->source = $source;
|
||||
$tmp->ip = $ip;
|
||||
$tmp->statType = StatisticModel::STAT_TYPE_PAGE;
|
||||
$stat = new StatisticModel($tmp);
|
||||
GlobalVariables::get("dao")->save($stat);
|
||||
}
|
||||
|
||||
/**
|
||||
* La funzione si occupa di aggiungere una visualizzazione alla pagina corrente
|
||||
*/
|
||||
public static function logPageImpression(){
|
||||
if (!isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
self::prepareStatCookie();
|
||||
}
|
||||
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
$content = $_SERVER['PHP_SELF'];
|
||||
$source = null;
|
||||
if (array_key_exists("HTTP_REFERER",$_SERVER)){
|
||||
$source = $_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
|
||||
$function = '$.ajax({url: "stats/pageImpression.php", method: "POST", data: { "ip": "'.$ip.'", "content": "'.$content.'", "source": "'.$source.'" }, dataType: "html" });';
|
||||
GUIHandler::addOnLoadJsEvent($function);
|
||||
}
|
||||
|
||||
|
||||
private static function prepareStatCookie(){
|
||||
setcookie(self::$COOKIE_NAME, uniqid("",true), strtotime(self::$COOKIE_TIME) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* La funzione si occupa del salvataggio vero e proprio della impression della notizia.
|
||||
* UTILIZZARE QUESTA FUNZIONE SOLO NELLA PAGINA DI BACKEND (stats/notiziaImpression.php). Nelle pagine base utilizzare invece la funzione di log
|
||||
* @param string $ip
|
||||
* @param string $content
|
||||
* @param string $source
|
||||
*/
|
||||
public static function saveNotiziaImpression($ip, $notiziaId, $source){
|
||||
$tmp = new stdClass();
|
||||
|
||||
$tmp->user = null;
|
||||
if (isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
$id = $_COOKIE[self::$COOKIE_NAME];
|
||||
|
||||
$tmp->user = new stdClass();
|
||||
$tmp->user->id = $id;
|
||||
$tmp->user->isNew = false;
|
||||
if (GlobalVariables::get("dao")->count("StatisticModel",array("user.id"=>$id))==0){
|
||||
$tmp->user->isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
$tmp->content = new stdClass();
|
||||
$notizia = GlobalVariables::get("dao")->getFirst("NotiziaModel",array("id"=>$notiziaId));
|
||||
if (!is_null($notizia)){
|
||||
$tmp->content->notizia = $notiziaId;
|
||||
$tmp->content->category = $notizia->category;
|
||||
|
||||
$tmp->source = $source;
|
||||
$tmp->ip = $ip;
|
||||
$tmp->statType = StatisticModel::STAT_TYPE_NOTIZIA;
|
||||
$stat = new StatisticModel($tmp);
|
||||
GlobalVariables::get("dao")->save($stat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* La funzione si occupa di aggiungere una visualizzazione alla notizia correlata a $id
|
||||
* @param string $id
|
||||
*/
|
||||
public static function logNotiziaImpression($id){
|
||||
if (!isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
self::prepareStatCookie();
|
||||
}
|
||||
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
$notizia = $id;
|
||||
$source = null;
|
||||
if (array_key_exists("HTTP_REFERER",$_SERVER)){
|
||||
$source = $_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
|
||||
$function = '$.ajax({url: "stats/notiziaImpression.php", method: "POST", data: { "ip": "'.$ip.'", "notizia": "'.$id.'", "source": "'.$source.'" }, dataType: "html" });';
|
||||
GUIHandler::addOnLoadJsEvent($function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restitusce il numero di impressions per una notizia
|
||||
* @param string $id
|
||||
*/
|
||||
public static function countNotiziaImpressions($id, $start = null, $end = null){
|
||||
$searchArray = array("statType"=>StatisticModel::STAT_TYPE_NOTIZIA,"content.notizia"=>$id);
|
||||
if (!is_null($start)){
|
||||
// $searchArray["date"]['$gte'] = new MongoDate($start);
|
||||
$searchArray["date"]['$gte'] = new MongoDB\BSON\UTCDateTime( $start * 1000 );
|
||||
|
||||
}
|
||||
if (!is_null($end)){
|
||||
// $searchArray["date"]['$lte'] = new MongoDate($end);
|
||||
$searchArray["date"]['$lte'] = new MongoDB\BSON\UTCDateTime( $end * 1000 );
|
||||
}
|
||||
return GlobalVariables::get("dao")->count("StatisticModel",$searchArray);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* La funzione si occupa del salvataggio vero e proprio della impression del banner.
|
||||
* UTILIZZARE QUESTA FUNZIONE SOLO NELLA PAGINA DI BACKEND (stats/bannerImpression.php). Nelle pagine base utilizzare invece la funzione di log
|
||||
* @param string $ip
|
||||
* @param string $content
|
||||
* @param string $source
|
||||
*/
|
||||
public static function saveBannerImpression($ip, $bannerId, $source){
|
||||
$tmp = new stdClass();
|
||||
|
||||
$tmp->user = null;
|
||||
if (isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
$id = $_COOKIE[self::$COOKIE_NAME];
|
||||
|
||||
$tmp->user = new stdClass();
|
||||
$tmp->user->id = $id;
|
||||
$tmp->user->isNew = false;
|
||||
if (GlobalVariables::get("dao")->count("StatisticModel",array("user.id"=>$id))==0){
|
||||
$tmp->user->isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
$tmp->content = new stdClass();
|
||||
$banner = GlobalVariables::get("dao")->getFirst("BannerModel",array("id"=>$bannerId));
|
||||
if (!is_null($banner)){
|
||||
$tmp->content->banner = $bannerId;
|
||||
$tmp->content->position = $banner->position;
|
||||
|
||||
$tmp->source = $source;
|
||||
$tmp->ip = $ip;
|
||||
$tmp->statType = StatisticModel::STAT_TYPE_BANNER_IMPRESSION;
|
||||
$stat = new StatisticModel($tmp);
|
||||
GlobalVariables::get("dao")->save($stat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* La funzione si occupa di aggiungere una visualizzazione all banner $id
|
||||
* @param string $id
|
||||
*/
|
||||
public static function logBannerImpression($id){
|
||||
if (!isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
self::prepareStatCookie();
|
||||
}
|
||||
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
$source = null;
|
||||
if (array_key_exists("HTTP_REFERER",$_SERVER)){
|
||||
$source = $_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
|
||||
$function = '$.ajax({url: "stats/bannerImpression.php", method: "POST", data: { "ip": "'.$ip.'", "banner": "'.$id.'", "source": "'.$source.'" }, dataType: "html" });';
|
||||
echo '<script type="text/javascript">'.$function.'</script>';
|
||||
|
||||
// OLD VERSION
|
||||
// $function = '$.ajax({url: "stats/bannerImpression.php", method: "POST", data: { "ip": "'.$ip.'", "banner": "'.$id.'", "source": "'.$source.'" }, dataType: "html" });';
|
||||
// GUIHandler::addOnLoadJsEvent($function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restitusce il numero di impressions per una notizia
|
||||
* @param string $id
|
||||
*/
|
||||
public static function countBannerImpressions($id, $start = null, $end = null){
|
||||
$searchArray = array("statType"=>StatisticModel::STAT_TYPE_BANNER_IMPRESSION,"content.banner"=>$id);
|
||||
if (!is_null($start)){
|
||||
// $searchArray["date"]['$gte'] = new MongoDate($start);
|
||||
$searchArray["date"]['$gte'] = new MongoDB\BSON\UTCDateTime($start * 1000);
|
||||
}
|
||||
if (!is_null($end)){
|
||||
// $searchArray["date"]['$lte'] = new MongoDate($end);
|
||||
$searchArray["date"]['$lte'] = new MongoDB\BSON\UTCDateTime($end * 1000);
|
||||
}
|
||||
return GlobalVariables::get("dao")->count("StatisticModel",$searchArray);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* La funzione si occupa del salvataggio vero e proprio della impression dell banner.
|
||||
* UTILIZZARE QUESTA FUNZIONE SOLO NELLA PAGINA DI BACKEND (stats/bannerImpression.php). Nelle pagine base utilizzare invece la funzione di log
|
||||
* @param string $ip
|
||||
* @param string $content
|
||||
* @param string $source
|
||||
*/
|
||||
public static function saveBannerClick($bannerId, $source){
|
||||
$tmp = new stdClass();
|
||||
|
||||
$tmp->user = null;
|
||||
if (isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
$id = $_COOKIE[self::$COOKIE_NAME];
|
||||
|
||||
$tmp->user = new stdClass();
|
||||
$tmp->user->id = $id;
|
||||
$tmp->user->isNew = false;
|
||||
if (GlobalVariables::get("dao")->count("StatisticModel",array("user.id"=>$id))==0){
|
||||
$tmp->user->isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
$tmp->content = new stdClass();
|
||||
$banner = GlobalVariables::get("dao")->getFirst("BannerModel",array("id"=>$bannerId));
|
||||
if (!is_null($banner)){
|
||||
$tmp->content->banner = $bannerId;
|
||||
$tmp->content->position = $banner->position;
|
||||
|
||||
$tmp->source = $source;
|
||||
$tmp->ip = $_SERVER['REMOTE_ADDR'];
|
||||
$tmp->statType = StatisticModel::STAT_TYPE_BANNER_CLICK;
|
||||
$stat = new StatisticModel($tmp);
|
||||
GlobalVariables::get("dao")->save($stat);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* La funzione si occupa di aggiungere una visualizzazione all banner $id
|
||||
* @param string $id
|
||||
*/
|
||||
public static function getBannerClickLink($banner){
|
||||
if (!isset($_COOKIE[self::$COOKIE_NAME])){
|
||||
self::prepareStatCookie();
|
||||
}
|
||||
return "bannerClick('".$banner->id."','".$banner->link."');";
|
||||
}
|
||||
|
||||
/**
|
||||
* Restitusce il numero di impressions per una notizia
|
||||
* @param string $id
|
||||
*/
|
||||
public static function countBannerClicks($id, $start = null, $end = null){
|
||||
$searchArray = array("statType"=>StatisticModel::STAT_TYPE_BANNER_CLICK,"content.banner"=>$id);
|
||||
if (!is_null($start)){
|
||||
// $searchArray["date"]['$gte'] = new MongoDate($start);
|
||||
$searchArray["date"]['$gte'] = new MongoDB\BSON\UTCDateTime($start * 1000);
|
||||
}
|
||||
if (!is_null($end)){
|
||||
// $searchArray["date"]['$lte'] = new MongoDate($end);
|
||||
$searchArray["date"]['$lte'] = new MongoDB\BSON\UTCDateTime($end * 1000);
|
||||
}
|
||||
return GlobalVariables::get("dao")->count("StatisticModel",$searchArray);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restituisce il banner da mostrare tenendo in considerazione quelli già visualizzati e le visualizzazioni totali
|
||||
* @param int $position
|
||||
* @param string $replaced id del banner rimpiazzato
|
||||
*/
|
||||
public static function getBannerToShow($position, $replaced = null, $category = BannerModel::GENERAL_CATEGORY){
|
||||
// Rimuovi il replaced dalla lista
|
||||
$shown = array();
|
||||
$rval = null;
|
||||
if (ASDSessionHandler::sessionValueExists("bannerActive")){
|
||||
$shown = ASDSessionHandler::getSessionValue("bannerActive");
|
||||
|
||||
if (!is_null($replaced) && in_array($replaced, $shown)){
|
||||
$key = array_search($replaced, $shown);
|
||||
unset($shown[$key]);
|
||||
ASDSessionHandler::setSessionValue("bannerActive",$shown);
|
||||
}
|
||||
}
|
||||
|
||||
// idlist contiene gli id dei banner in ordine di visualizzazione crescente (esclusi quelli non visualizzati)
|
||||
$pipeline = PipelineHelper::getTodaysBannerVisualizationPipeline($position);
|
||||
$stats = GlobalVariables::get("dao")->aggregate("StatisticModel",$pipeline);
|
||||
// var_dump($stats);
|
||||
$idList = array();
|
||||
if (sizeof($stats)>0){
|
||||
foreach ($stats as $stat){
|
||||
$idList[] = $stat["_id"]["banner"];
|
||||
}
|
||||
}
|
||||
|
||||
// $baseSearchArray = array("position"=>$position,"end"=>array('$gte'=>new MongoDate(strtotime("tomorrow"))),"categories"=>$category);
|
||||
$baseSearchArray = array("position"=>$position,"end"=>array('$gte'=>new MongoDB\BSON\UTCDateTime( strtotime("tomorrow") * 1000 ) ),"categories"=>$category);
|
||||
// Prendi il primo dei "mai mostrati oggi" tra quelli non presenti nella pagina
|
||||
$todayPlusShown = array_merge($idList,$shown);
|
||||
if (sizeof($todayPlusShown)>0){
|
||||
$tmp = array_map(function ($id) {return new MongoDB\BSON\ObjectID($id);}, $todayPlusShown);
|
||||
$tmp = array('_id'=>array('$nin'=>$tmp));
|
||||
$rval = GlobalVariables::get("dao")->getFirst("BannerModel", array_merge($baseSearchArray, $tmp) );
|
||||
}
|
||||
else {
|
||||
$rval = GlobalVariables::get("dao")->getFirst("BannerModel", $baseSearchArray);
|
||||
}
|
||||
|
||||
if (is_null($rval)){
|
||||
$todayLessShown = array_values(array_diff($idList, $shown));
|
||||
if (sizeof($todayLessShown)>0){
|
||||
$i = 0;
|
||||
while (is_null($rval) && $i<sizeof($todayLessShown)){
|
||||
$condition = array_merge($baseSearchArray, array("id"=>$todayLessShown[$i]) );
|
||||
$rval = GlobalVariables::get("dao")->getFirst("BannerModel", $condition );
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!is_null($rval)){
|
||||
$shown[] = $rval->id;
|
||||
ASDSessionHandler::setSessionValue("bannerActive",$shown);
|
||||
}
|
||||
return $rval;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -5,6 +5,67 @@ Creation Date: 05/feb/2016
|
||||
*/
|
||||
|
||||
class PipelineHelper {
|
||||
|
||||
private static function sumFieldFilterDate($filter, $field, $from = null, $to = null) {
|
||||
if (!is_null($from) || !is_null($to)) {
|
||||
$filter['time'] = [];
|
||||
if (!is_null($from)) {
|
||||
$filter['time'] = [
|
||||
'$gte' => new MongoDB\BSON\UTCDateTime($from * 1000)
|
||||
];
|
||||
}
|
||||
if (!is_null($to)) {
|
||||
$filter['time'] = [
|
||||
'$lte' => new MongoDB\BSON\UTCDateTime($to * 1000)
|
||||
];
|
||||
}
|
||||
}
|
||||
$rval = [
|
||||
[
|
||||
'$match' => $filter
|
||||
],
|
||||
[
|
||||
'$group' => [
|
||||
'_id' => null,
|
||||
'tot' => ['$sum' => '$'.$field]
|
||||
]
|
||||
]
|
||||
];
|
||||
return $rval;
|
||||
}
|
||||
|
||||
public static function getNotiziaImpressions($id, $from = null, $to = null){
|
||||
return self::sumFieldFilterDate(
|
||||
[
|
||||
'notizia' => $id
|
||||
],
|
||||
'views',
|
||||
$from,
|
||||
$to
|
||||
);
|
||||
}
|
||||
|
||||
public static function getBannerImpressions($id, $from = null, $to = null){
|
||||
return self::sumFieldFilterDate(
|
||||
[
|
||||
'banner' => $id
|
||||
],
|
||||
'views',
|
||||
$from,
|
||||
$to
|
||||
);
|
||||
}
|
||||
|
||||
public static function getBannerClicks($id, $from = null, $to = null){
|
||||
return self::sumFieldFilterDate(
|
||||
[
|
||||
'banner' => $id
|
||||
],
|
||||
'clicks',
|
||||
$from,
|
||||
$to
|
||||
);
|
||||
}
|
||||
|
||||
public static function getDailyVisualizationPipeline($startDate){
|
||||
$rval = array(
|
||||
@@ -217,7 +278,7 @@ class PipelineHelper {
|
||||
'statType'=>StatisticModel::STAT_TYPE_BANNER_IMPRESSION,
|
||||
'content.position'=>$position,
|
||||
// 'date'=>array( '$gte'=>new MongoDate(strtotime("today")) )
|
||||
'date'=>array( '$gte'=>new MongoDB\BSON\UTCDateTime(strtotime("today") * 1000) )
|
||||
'date'=>array( '$gte'=>new MongoDB\BSON\UTCDateTime(strtotime("today CET") * 1000) )
|
||||
)
|
||||
),
|
||||
array(
|
||||
|
||||
@@ -462,6 +462,32 @@ class GenericDao{
|
||||
|
||||
return $cursor->count(true);
|
||||
}
|
||||
|
||||
|
||||
public function rawUpsert($modelClass, $query, $update) {
|
||||
if (!is_null($modelClass)){
|
||||
if (!is_subclass_of($modelClass, "DaoSaveable", true)){
|
||||
throw new CoreException("Invalid return class passed to GenericDao::query ($modelClass)");
|
||||
}
|
||||
}
|
||||
if (!array_key_exists('deleted', $query)) {
|
||||
$query['deleted'] = false;
|
||||
}
|
||||
|
||||
$collectionName = $modelClass::getCollectionName();
|
||||
|
||||
$command = new \MongoDB\Driver\Command([
|
||||
'findAndModify' => $collectionName,
|
||||
'query' => $query,
|
||||
'update' => $update,
|
||||
'upsert' => true,
|
||||
'new' => false
|
||||
]);
|
||||
|
||||
$this->client->executeCommand( $this->dbName, $command );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -41,6 +41,9 @@ require_once(dirname(__FILE__)."/models/CBSQueueModel.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/models/PasswordRecoveryRequestModel.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/models/stats/ArticleStatsModel.php");
|
||||
require_once(dirname(__FILE__)."/models/stats/BannerStatsModel.php");
|
||||
require_once(dirname(__FILE__)."/models/stats/PageViewStatsModel.php");
|
||||
|
||||
$dao = new GenericDao($database->dbName,$database->connectionString);
|
||||
GlobalVariables::set("dao", $dao);
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 30/ago/2022
|
||||
*/
|
||||
|
||||
|
||||
class ArticleStatsModel extends Model {
|
||||
|
||||
public function __construct($saveableObject = null){
|
||||
parent::__construct($saveableObject);
|
||||
}
|
||||
|
||||
public static function getCollectionName(){
|
||||
return "article_stats";
|
||||
}
|
||||
|
||||
public static function new($articleId, $day, $month, $year){
|
||||
return new static(
|
||||
(object)[
|
||||
'notizia' => $articleId,
|
||||
'y' => intval($year),
|
||||
'm' => intval($month),
|
||||
'd' => intval($day),
|
||||
'views' => 0
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public static function getFilter($articleId, $day, $month, $year) {
|
||||
$time = strtotime("$year-$month-$day CET");
|
||||
return [
|
||||
'notizia' => $articleId,
|
||||
'time' => new MongoDB\BSON\UTCDateTime( $time * 1000 ),
|
||||
'y' => intval($year),
|
||||
'm' => intval($month),
|
||||
'd' => intval($day)
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 30/ago/2022
|
||||
*/
|
||||
|
||||
|
||||
class BannerStatsModel extends Model {
|
||||
|
||||
public function __construct($saveableObject = null){
|
||||
parent::__construct($saveableObject);
|
||||
}
|
||||
|
||||
public static function getCollectionName(){
|
||||
return "banner_stats";
|
||||
}
|
||||
|
||||
public static function new($bannerId, $day, $month, $year) {
|
||||
$time = strtotime("$year-$month-$day CET");
|
||||
return new static(
|
||||
(object)[
|
||||
'banner' => $bannerId,
|
||||
'time' => new MongoDB\BSON\UTCDateTime( $time * 1000 ),
|
||||
'y' => intval($year),
|
||||
'm' => intval($month),
|
||||
'd' => intval($day),
|
||||
'views' => 0,
|
||||
'clicks' => 0
|
||||
]
|
||||
);
|
||||
}
|
||||
public static function getFilter($bannerId, $day, $month, $year) {
|
||||
$time = strtotime("$year-$month-$day CET");
|
||||
return [
|
||||
'banner' => $bannerId,
|
||||
'time' => new MongoDB\BSON\UTCDateTime( $time * 1000 ),
|
||||
'y' => intval($year),
|
||||
'm' => intval($month),
|
||||
'd' => intval($day)
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 30/ago/2022
|
||||
*/
|
||||
|
||||
|
||||
class PageViewStatsModel extends Model {
|
||||
|
||||
public function __construct($saveableObject = null){
|
||||
parent::__construct($saveableObject);
|
||||
}
|
||||
|
||||
public static function getCollectionName(){
|
||||
return "pageview_stats";
|
||||
}
|
||||
|
||||
public static function getFilter($page, $day, $month, $year) {
|
||||
$time = strtotime("$year-$month-$day CET");
|
||||
return [
|
||||
'page' => $page,
|
||||
'time' => new MongoDB\BSON\UTCDateTime( $time * 1000 ),
|
||||
'y' => intval($year),
|
||||
'm' => intval($month),
|
||||
'd' => intval($day)
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -393,7 +393,7 @@ class GUIHandler {
|
||||
// $lastsNews = array_merge($lastsNews,$add);
|
||||
// }
|
||||
|
||||
$stats = GlobalVariables::get("dao")->aggregate("StatisticModel",PipelineHelper::getMostViewedOfLastDays(strtotime("-7 days"),5));
|
||||
$stats = GlobalVariables::get("dao")->aggregate("StatisticModel",PipelineHelper::getMostViewedOfLastDays(strtotime("-7 days CET"),5));
|
||||
$idArray = array_map(function ($ele){ return new MongoDB\BSON\ObjectID($ele["_id"]["notizia"]);}, $stats);
|
||||
|
||||
// $lastsNews = GlobalVariables::get("dao")->query("NotiziaModel",
|
||||
|
||||
@@ -72,13 +72,13 @@ try{
|
||||
<div class="bannerStat">
|
||||
<div>
|
||||
<div class="statName">Oggi</div>
|
||||
<div>Visualizzazioni: <?php echo AnalyticsHelper::countBannerImpressions($banner->id,strtotime("today"));?></div>
|
||||
<div class="toHide">Click: <?php echo AnalyticsHelper::countBannerClicks($banner->id,strtotime("today"));?></div>
|
||||
<div>Visualizzazioni: <?php echo AnalyticsHelper::countBannerImpressions($banner->id,strtotime("today CET"));?></div>
|
||||
<div class="toHide">Click: <?php echo AnalyticsHelper::countBannerClicks($banner->id,strtotime("today CET"));?></div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="statName">Ultima settimana</div>
|
||||
<div>Visualizzazioni: <?php echo AnalyticsHelper::countBannerImpressions($banner->id,strtotime("-7 days"));?></div>
|
||||
<div class="toHide">Click: <?php echo AnalyticsHelper::countBannerClicks($banner->id,strtotime("-7 days"));?></div>
|
||||
<div>Visualizzazioni: <?php echo AnalyticsHelper::countBannerImpressions($banner->id,strtotime("-7 days CET"));?></div>
|
||||
<div class="toHide">Click: <?php echo AnalyticsHelper::countBannerClicks($banner->id,strtotime("-7 days CET"));?></div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="statName">Totali</div>
|
||||
|
||||
@@ -144,11 +144,11 @@ try{
|
||||
<div class="notiziaStat">
|
||||
<div>
|
||||
<div class="statName">Oggi</div>
|
||||
<div><?php echo AnalyticsHelper::countNotiziaImpressions($notizia->id,strtotime("today"));?></div>
|
||||
<div><?php echo AnalyticsHelper::countNotiziaImpressions($notizia->id,strtotime("today CET"));?></div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="statName">Ultima settimana</div>
|
||||
<div><?php echo AnalyticsHelper::countNotiziaImpressions($notizia->id,strtotime("-7 days"));?></div>
|
||||
<div><?php echo AnalyticsHelper::countNotiziaImpressions($notizia->id,strtotime("-7 days CET"));?></div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="statName">Totali</div>
|
||||
|
||||
@@ -15,7 +15,6 @@ if (!AdminLoginManager::isLogged()){
|
||||
MenuGenerator::generateMenu();
|
||||
|
||||
HTMLHelper::generateAdminHead();
|
||||
|
||||
?>
|
||||
<div>
|
||||
Benvenuto!
|
||||
|
||||
@@ -10,7 +10,7 @@ try {
|
||||
if (array_key_exists("HTTP_REFERER",$_SERVER)){
|
||||
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
|
||||
|
||||
if (strcmp($host,$_SERVER["HTTP_HOST"])==0){
|
||||
if (strcmp($host,$_SERVER["SERVER_NAME"])==0){
|
||||
$banner = PostHandler::get("banner");
|
||||
$source = PostHandler::get("source");
|
||||
if (!is_null($banner) && !is_null($source)){
|
||||
|
||||
@@ -10,7 +10,7 @@ try {
|
||||
if (array_key_exists("HTTP_REFERER",$_SERVER)){
|
||||
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
|
||||
|
||||
if (strcmp($host,$_SERVER["HTTP_HOST"])==0){
|
||||
if (strcmp($host,$_SERVER["SERVER_NAME"])==0){
|
||||
$ip = PostHandler::get("ip");
|
||||
$banner = PostHandler::get("banner");
|
||||
$source = PostHandler::get("source");
|
||||
|
||||
@@ -10,7 +10,7 @@ try {
|
||||
if (array_key_exists("HTTP_REFERER",$_SERVER)){
|
||||
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
|
||||
|
||||
if (strcmp($host,$_SERVER["HTTP_HOST"])==0){
|
||||
if (strcmp($host,$_SERVER["SERVER_NAME"])==0){
|
||||
$ip = PostHandler::get("ip");
|
||||
$notizia = PostHandler::get("notizia");
|
||||
$source = PostHandler::get("source");
|
||||
|
||||
@@ -10,7 +10,7 @@ try {
|
||||
if (array_key_exists("HTTP_REFERER",$_SERVER)){
|
||||
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
|
||||
|
||||
if (strcmp($host,$_SERVER["HTTP_HOST"])==0){
|
||||
if (strcmp($host,$_SERVER["SERVER_NAME"])==0){
|
||||
$ip = PostHandler::get("ip");
|
||||
$content = PostHandler::get("content");
|
||||
$source = PostHandler::get("source");
|
||||
|
||||
@@ -10,7 +10,7 @@ try {
|
||||
if (array_key_exists("HTTP_REFERER",$_SERVER)){
|
||||
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
|
||||
|
||||
if (strcmp($host,$_SERVER["HTTP_HOST"])==0){
|
||||
if (strcmp($host,$_SERVER["SERVER_NAME"])==0){
|
||||
$banner = PostHandler::get("banner");
|
||||
$source = PostHandler::get("source");
|
||||
if (!is_null($banner) && !is_null($source)){
|
||||
|
||||
@@ -10,7 +10,7 @@ try {
|
||||
if (array_key_exists("HTTP_REFERER",$_SERVER)){
|
||||
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
|
||||
|
||||
if (strcmp($host,$_SERVER["HTTP_HOST"])==0){
|
||||
if (strcmp($host,$_SERVER["SERVER_NAME"])==0){
|
||||
$ip = PostHandler::get("ip");
|
||||
$banner = PostHandler::get("banner");
|
||||
$source = PostHandler::get("source");
|
||||
|
||||
@@ -10,7 +10,7 @@ try {
|
||||
if (array_key_exists("HTTP_REFERER",$_SERVER)){
|
||||
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
|
||||
|
||||
if (strcmp($host,$_SERVER["HTTP_HOST"])==0){
|
||||
if (strcmp($host,$_SERVER["SERVER_NAME"])==0){
|
||||
$ip = PostHandler::get("ip");
|
||||
$notizia = PostHandler::get("notizia");
|
||||
$source = PostHandler::get("source");
|
||||
|
||||
@@ -10,7 +10,7 @@ try {
|
||||
if (array_key_exists("HTTP_REFERER",$_SERVER)){
|
||||
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
|
||||
|
||||
if (strcmp($host,$_SERVER["HTTP_HOST"])==0){
|
||||
if (strcmp($host,$_SERVER["SERVER_NAME"])==0){
|
||||
$ip = PostHandler::get("ip");
|
||||
$content = PostHandler::get("content");
|
||||
$source = PostHandler::get("source");
|
||||
|
||||
Reference in New Issue
Block a user