Compare commits
9
Commits
stats-rework
...
2.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2fb0d6d89 | ||
|
|
617a3f50eb | ||
|
|
c666b50dd8 | ||
|
|
34fb57fa81 | ||
|
|
7680378f28 | ||
|
|
7bab6253cf | ||
|
|
f7db85cc13 | ||
|
|
09396f8c98 | ||
|
|
064eeec5a0 |
@@ -20,11 +20,5 @@
|
|||||||
|
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<IfModule xsendfile_module>
|
|
||||||
XSendFile on
|
|
||||||
XSendFilePath "/tmp/xsend"
|
|
||||||
</IfModule>
|
|
||||||
|
|
||||||
|
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
|
||||||
|
|||||||
@@ -12,5 +12,8 @@ mkdir -p "/tmp/${DDNINJA_AUTHOR}/${DDNINJA_BUILDNAME}"
|
|||||||
chown -R www-data:www-data "/tmp/${DDNINJA_AUTHOR}/${DDNINJA_BUILDNAME}"
|
chown -R www-data:www-data "/tmp/${DDNINJA_AUTHOR}/${DDNINJA_BUILDNAME}"
|
||||||
chown -R www-data:www-data /var/log/${DDNINJA_AUTHOR}
|
chown -R www-data:www-data /var/log/${DDNINJA_AUTHOR}
|
||||||
|
|
||||||
|
mkdir -p "/home/${DDNINJA_AUTHOR}/storage/${DDNINJA_BUILDNAME}/media/"
|
||||||
|
chown -R www-data:www-data "/home/${DDNINJA_AUTHOR}/storage/${DDNINJA_BUILDNAME}/media/"
|
||||||
|
|
||||||
asdphp-entrypoint & wait
|
asdphp-entrypoint & wait
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
* File : convertStats.php
|
* File : convertStats.php
|
||||||
*******************************************/
|
*******************************************/
|
||||||
|
|
||||||
|
die();
|
||||||
require_once(dirname(__FILE__)."/../load.php");
|
require_once(dirname(__FILE__)."/../load.php");
|
||||||
|
|
||||||
$iteration = 0;
|
$iteration = 0;
|
||||||
|
|||||||
Executable
+363
@@ -0,0 +1,363 @@
|
|||||||
|
#!/usr/local/bin/php
|
||||||
|
<?php
|
||||||
|
/******************************************
|
||||||
|
* Author : Riccardo Di Dato
|
||||||
|
* Created On : Tue Aug 30 2022
|
||||||
|
* File : convertStats.php
|
||||||
|
*******************************************/
|
||||||
|
|
||||||
|
require_once(dirname(__FILE__)."/../load.php");
|
||||||
|
|
||||||
|
|
||||||
|
function getDailyBannerImpressionsPipeline($startDate, $endDate) {
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'$project' => [
|
||||||
|
'tdate'=> [
|
||||||
|
'$add' => [ '$date' , 60*60*1000 ]
|
||||||
|
],
|
||||||
|
"statType" => '$statType',
|
||||||
|
'user' => '$user',
|
||||||
|
'banner' => '$content.banner',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$match' => [
|
||||||
|
'statType' => StatisticModel::STAT_TYPE_BANNER_IMPRESSION,
|
||||||
|
'tdate' => [
|
||||||
|
'$gte'=>new MongoDB\BSON\UTCDateTime($startDate * 1000),
|
||||||
|
'$lte'=>new MongoDB\BSON\UTCDateTime($endDate * 1000)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$group' => [
|
||||||
|
'_id' => [
|
||||||
|
'date' => [
|
||||||
|
'day' => [ '$dayOfMonth' => '$tdate' ],
|
||||||
|
"month" => [ '$month' => '$tdate' ],
|
||||||
|
"year" => [ '$year'=>'$tdate' ]
|
||||||
|
],
|
||||||
|
'banner' => '$banner',
|
||||||
|
],
|
||||||
|
"visualizzazioni" => [ '$sum' => 1 ]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getDailyBannerClicksPipeline($startDate, $endDate) {
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'$project' => [
|
||||||
|
'tdate'=> [
|
||||||
|
'$add' => [ '$date' , 60*60*1000 ]
|
||||||
|
],
|
||||||
|
"statType" => '$statType',
|
||||||
|
'user' => '$user',
|
||||||
|
'banner' => '$content.banner',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$match' => [
|
||||||
|
'statType' => StatisticModel::STAT_TYPE_BANNER_CLICK,
|
||||||
|
'tdate' => [
|
||||||
|
'$gte'=>new MongoDB\BSON\UTCDateTime($startDate * 1000),
|
||||||
|
'$lte'=>new MongoDB\BSON\UTCDateTime($endDate * 1000)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$group' => [
|
||||||
|
'_id' => [
|
||||||
|
'date' => [
|
||||||
|
'day' => [ '$dayOfMonth' => '$tdate' ],
|
||||||
|
"month" => [ '$month' => '$tdate' ],
|
||||||
|
"year" => [ '$year'=>'$tdate' ]
|
||||||
|
],
|
||||||
|
'banner' => '$banner',
|
||||||
|
],
|
||||||
|
"visualizzazioni" => [ '$sum' => 1 ]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDailyNotiziaImpressionsPipeline($startDate, $endDate) {
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'$project' => [
|
||||||
|
'tdate'=> [
|
||||||
|
'$add' => [ '$date' , 60*60*1000 ]
|
||||||
|
],
|
||||||
|
"statType" => '$statType',
|
||||||
|
'user' => '$user',
|
||||||
|
"content" => '$content'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$match' => [
|
||||||
|
'statType' => StatisticModel::STAT_TYPE_NOTIZIA,
|
||||||
|
'tdate' => [
|
||||||
|
'$gte'=>new MongoDB\BSON\UTCDateTime($startDate * 1000),
|
||||||
|
'$lte'=>new MongoDB\BSON\UTCDateTime($endDate * 1000)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$group' => [
|
||||||
|
'_id' => [
|
||||||
|
'date' => [
|
||||||
|
'day' => [ '$dayOfMonth' => '$tdate' ],
|
||||||
|
"month" => [ '$month' => '$tdate' ],
|
||||||
|
"year" => [ '$year'=>'$tdate' ]
|
||||||
|
],
|
||||||
|
'notizia' => '$content.notizia',
|
||||||
|
],
|
||||||
|
"visualizzazioni" => [ '$sum' => 1 ]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getYearlyNotiziaImpressionsPipeline($startDate, $endDate) {
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'$project' => [
|
||||||
|
'tdate'=> [
|
||||||
|
'$add' => [ '$date' , 60*60*1000 ]
|
||||||
|
],
|
||||||
|
"statType" => '$statType',
|
||||||
|
'user' => '$user',
|
||||||
|
"content" => '$content'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$match' => [
|
||||||
|
'statType' => StatisticModel::STAT_TYPE_NOTIZIA,
|
||||||
|
'tdate' => [
|
||||||
|
'$gte'=>new MongoDB\BSON\UTCDateTime($startDate * 1000),
|
||||||
|
'$lte'=>new MongoDB\BSON\UTCDateTime($endDate * 1000)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$group' => [
|
||||||
|
'_id' => [
|
||||||
|
'notizia' => '$content.notizia',
|
||||||
|
],
|
||||||
|
"visualizzazioni" => [ '$sum' => 1 ]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDailyPageImpressionsPipeline($startDate, $endDate) {
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'$project' => [
|
||||||
|
'tdate'=> [
|
||||||
|
'$add' => [ '$date' , 60*60*1000 ]
|
||||||
|
],
|
||||||
|
"statType" => '$statType',
|
||||||
|
'user' => '$user',
|
||||||
|
'content' => '$content',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$match' => [
|
||||||
|
'statType' => StatisticModel::STAT_TYPE_PAGE,
|
||||||
|
'tdate' => [
|
||||||
|
'$gte'=>new MongoDB\BSON\UTCDateTime($startDate * 1000),
|
||||||
|
'$lte'=>new MongoDB\BSON\UTCDateTime($endDate * 1000)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$group' => [
|
||||||
|
'_id' => [
|
||||||
|
'date' => [
|
||||||
|
'day' => [ '$dayOfMonth' => '$tdate' ],
|
||||||
|
"month" => [ '$month' => '$tdate' ],
|
||||||
|
"year" => [ '$year'=>'$tdate' ]
|
||||||
|
],
|
||||||
|
'user' => '$user.id',
|
||||||
|
'content' => '$content',
|
||||||
|
],
|
||||||
|
"visualizzazioni" => [ '$sum' => 1 ]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$group' => [
|
||||||
|
'_id' => [
|
||||||
|
'date' => '$_id.date',
|
||||||
|
'content' => '$_id.content',
|
||||||
|
],
|
||||||
|
"visualizzazioni" => [ '$sum' => '$visualizzazioni' ],
|
||||||
|
'isNewToday' => [ '$sum' => 1 ],
|
||||||
|
'isAbsoluteNew' => [ '$sum' => 1 ]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMonthlyPageImpressionsPipeline($startDate, $endDate) {
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'$match' => [
|
||||||
|
'statType' => StatisticModel::STAT_TYPE_PAGE,
|
||||||
|
'tdate' => [
|
||||||
|
'$gte'=>new MongoDB\BSON\UTCDateTime($startDate * 1000),
|
||||||
|
'$lte'=>new MongoDB\BSON\UTCDateTime($endDate * 1000)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$group' => [
|
||||||
|
'_id' => [
|
||||||
|
'date' => [
|
||||||
|
"month" => [ '$month' => '$tdate' ],
|
||||||
|
"year" => [ '$year'=>'$tdate' ]
|
||||||
|
],
|
||||||
|
'user' => '$user.id',
|
||||||
|
'content' => '$content',
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'$group' => [
|
||||||
|
'_id' => [
|
||||||
|
'date' => '$_id.date',
|
||||||
|
'content' => '$_id.content',
|
||||||
|
],
|
||||||
|
"isMonthlyNew" => [ '$sum' => 1 ]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$curYear = intval(date("Y"));
|
||||||
|
for ($y = 2016; $y <= intval(date("Y")); $y++) {
|
||||||
|
echo "Working on year : $y", PHP_EOL;
|
||||||
|
|
||||||
|
$from = strtotime($y."-01-01");
|
||||||
|
$to = strtotime($y."-12-31");
|
||||||
|
|
||||||
|
$dao = GlobalVariables::get("dao");
|
||||||
|
if ($dao instanceof GenericDao) {
|
||||||
|
$pipe = getDailyPageImpressionsPipeline( $from, $to );
|
||||||
|
|
||||||
|
echo " - Working on Daily Page Impressions", PHP_EOL;
|
||||||
|
$data = $dao->aggregate(
|
||||||
|
StatisticModel::class,
|
||||||
|
$pipe,
|
||||||
|
['cursor' => true]
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($data as $elem) {
|
||||||
|
AnalyticsHelper::multiPageImpression(
|
||||||
|
$elem->_id->content,
|
||||||
|
$elem->_id->date->day,
|
||||||
|
$elem->_id->date->month,
|
||||||
|
$elem->_id->date->year,
|
||||||
|
$elem->visualizzazioni,
|
||||||
|
$elem->isNewToday,
|
||||||
|
0,
|
||||||
|
$elem->isAbsoluteNew
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$pipe = getMonthlyPageImpressionsPipeline( $from, $to );
|
||||||
|
|
||||||
|
echo " - Working on Monthly Page Impressions", PHP_EOL;
|
||||||
|
$data = $dao->aggregate(
|
||||||
|
StatisticModel::class,
|
||||||
|
$pipe,
|
||||||
|
['cursor' => true]
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($data as $elem) {
|
||||||
|
AnalyticsHelper::multiPageImpression(
|
||||||
|
$elem->_id->content,
|
||||||
|
1,
|
||||||
|
$elem->_id->date->month,
|
||||||
|
$elem->_id->date->year,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
$elem->isMonthlyNew,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($y == $curYear) {
|
||||||
|
$pipe = getDailyNotiziaImpressionsPipeline( $from, $to );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$pipe = getYearlyNotiziaImpressionsPipeline($from, $to);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo " - Working on Notizia Impressions", PHP_EOL;
|
||||||
|
$data = $dao->aggregate(
|
||||||
|
StatisticModel::class,
|
||||||
|
$pipe,
|
||||||
|
['cursor' => true]
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($data as $elem) {
|
||||||
|
$day = $y == 2022 ? $elem->_id->date->day : 1;
|
||||||
|
$month = $y == 2022 ? $elem->_id->date->month : 1;
|
||||||
|
AnalyticsHelper::multiNotiziaImpression(
|
||||||
|
$elem->_id->notizia,
|
||||||
|
$day,
|
||||||
|
$month,
|
||||||
|
$y,
|
||||||
|
$elem->visualizzazioni
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$pipe = getDailyBannerImpressionsPipeline( $from, $to );
|
||||||
|
|
||||||
|
echo " - Working on Banner Impressions", PHP_EOL;
|
||||||
|
$data = $dao->aggregate(
|
||||||
|
StatisticModel::class,
|
||||||
|
$pipe,
|
||||||
|
['cursor' => true]
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($data as $elem) {
|
||||||
|
AnalyticsHelper::multiBannerImpression(
|
||||||
|
$elem->_id->banner,
|
||||||
|
$elem->_id->date->day,
|
||||||
|
$elem->_id->date->month,
|
||||||
|
$elem->_id->date->year,
|
||||||
|
$elem->visualizzazioni
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$pipe = getDailyBannerClicksPipeline( $from, $to );
|
||||||
|
|
||||||
|
echo " - Working on Banner Clicks", PHP_EOL;
|
||||||
|
$data = $dao->aggregate(
|
||||||
|
StatisticModel::class,
|
||||||
|
$pipe,
|
||||||
|
['cursor' => true]
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($data as $elem) {
|
||||||
|
AnalyticsHelper::multiBannerClick(
|
||||||
|
$elem->_id->banner,
|
||||||
|
$elem->_id->date->day,
|
||||||
|
$elem->_id->date->month,
|
||||||
|
$elem->_id->date->year,
|
||||||
|
$elem->visualizzazioni
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -39,22 +39,22 @@ class AnalyticsHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function pageImpression($content, $d, $m, $y, $isNewToday, $isNewMonth, $isNewAbsolute) {
|
public static function multiPageImpression($content, $d, $m, $y, $incViews = 1, $incToday = 0, $incMonth = 0, $incAbsolute = 0) {
|
||||||
$dao = GlobalVariables::get("dao");
|
$dao = GlobalVariables::get("dao");
|
||||||
if ($dao instanceof GenericDao) {
|
if ($dao instanceof GenericDao) {
|
||||||
$upd = [
|
$upd = [
|
||||||
'$inc' => [
|
'$inc' => [
|
||||||
'views' => 1
|
'views' => $incViews
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
if ($isNewAbsolute || $isNewMonth || $isNewToday) {
|
if ($incToday > 0) {
|
||||||
$upd['$inc']['dayNewVisitors'] = 1;
|
$upd['$inc']['dayNewVisitors'] = $incToday;
|
||||||
}
|
}
|
||||||
if ($isNewAbsolute || $isNewMonth) {
|
if ($incMonth > 0) {
|
||||||
$upd['$inc']['monthNewVisitors'] = 1;
|
$upd['$inc']['monthNewVisitors'] = $incMonth;
|
||||||
}
|
}
|
||||||
if ($isNewAbsolute) {
|
if ($incAbsolute > 0) {
|
||||||
$upd['$inc']['absNewVisitors'] = 1;
|
$upd['$inc']['absNewVisitors'] = $incAbsolute;
|
||||||
}
|
}
|
||||||
$dao->rawUpsert(
|
$dao->rawUpsert(
|
||||||
PageViewStatsModel::class,
|
PageViewStatsModel::class,
|
||||||
@@ -64,6 +64,19 @@ class AnalyticsHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function pageImpression($content, $d, $m, $y, $isNewToday, $isNewMonth, $isNewAbsolute) {
|
||||||
|
self::multiPageImpression(
|
||||||
|
$content,
|
||||||
|
$d,
|
||||||
|
$m,
|
||||||
|
$y,
|
||||||
|
1,
|
||||||
|
$isNewAbsolute || $isNewMonth || $isNewToday ? 1 : 0,
|
||||||
|
$isNewAbsolute || $isNewMonth ? 1 : 0,
|
||||||
|
$isNewAbsolute ? 1 : 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* La funzione si occupa del salvataggio vero e proprio della impression della pagina.
|
* 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
|
* UTILIZZARE QUESTA FUNZIONE SOLO NELLA PAGINA DI BACKEND (stats/pageImpression.php). Nelle pagine base utilizzare invece la funzione di log
|
||||||
@@ -99,8 +112,7 @@ class AnalyticsHelper {
|
|||||||
GUIHandler::addOnLoadJsEvent($function);
|
GUIHandler::addOnLoadJsEvent($function);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function multiNotiziaImpression($content, $d, $m, $y, $incViews) {
|
||||||
public static function notiziaImpression($content, $d, $m, $y) {
|
|
||||||
$dao = GlobalVariables::get("dao");
|
$dao = GlobalVariables::get("dao");
|
||||||
if ($dao instanceof GenericDao) {
|
if ($dao instanceof GenericDao) {
|
||||||
$dao->rawUpsert(
|
$dao->rawUpsert(
|
||||||
@@ -108,13 +120,17 @@ class AnalyticsHelper {
|
|||||||
ArticleStatsModel::getFilter($content, $d, $m, $y),
|
ArticleStatsModel::getFilter($content, $d, $m, $y),
|
||||||
[
|
[
|
||||||
'$inc' => [
|
'$inc' => [
|
||||||
'views' => 1
|
'views' => $incViews
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function notiziaImpression($content, $d, $m, $y) {
|
||||||
|
self::multiNotiziaImpression($content, $d, $m, $y, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* La funzione si occupa del salvataggio vero e proprio della impression della notizia.
|
* 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
|
* UTILIZZARE QUESTA FUNZIONE SOLO NELLA PAGINA DI BACKEND (stats/notiziaImpression.php). Nelle pagine base utilizzare invece la funzione di log
|
||||||
@@ -160,7 +176,7 @@ class AnalyticsHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function bannerImpression($bannerId, $d, $m, $y) {
|
public static function multiBannerImpression($bannerId, $d, $m, $y, $views) {
|
||||||
$dao = GlobalVariables::get("dao");
|
$dao = GlobalVariables::get("dao");
|
||||||
if ($dao instanceof GenericDao) {
|
if ($dao instanceof GenericDao) {
|
||||||
$dao->rawUpsert(
|
$dao->rawUpsert(
|
||||||
@@ -168,25 +184,32 @@ class AnalyticsHelper {
|
|||||||
BannerStatsModel::getFilter($bannerId, $d, $m, $y),
|
BannerStatsModel::getFilter($bannerId, $d, $m, $y),
|
||||||
[
|
[
|
||||||
'$inc' => [
|
'$inc' => [
|
||||||
'views' => 1
|
'views' => $views
|
||||||
|
]
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static function bannerImpression($bannerId, $d, $m, $y) {
|
||||||
|
self::multiBannerImpression($bannerId, $d, $m, $y, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function multiBannerClick($bannerId, $d, $m, $y, $clicks) {
|
||||||
|
$dao = GlobalVariables::get("dao");
|
||||||
|
if ($dao instanceof GenericDao) {
|
||||||
|
$dao->rawUpsert(
|
||||||
|
BannerStatsModel::class,
|
||||||
|
BannerStatsModel::getFilter($bannerId, $d, $m, $y),
|
||||||
|
[
|
||||||
|
'$inc' => [
|
||||||
|
'clicks' => $clicks
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static function bannerClick($bannerId, $d, $m, $y) {
|
public static function bannerClick($bannerId, $d, $m, $y) {
|
||||||
$dao = GlobalVariables::get("dao");
|
self::multiBannerClick($bannerId, $d, $m, $y, 1);
|
||||||
if ($dao instanceof GenericDao) {
|
|
||||||
$dao->rawUpsert(
|
|
||||||
BannerStatsModel::class,
|
|
||||||
BannerStatsModel::getFilter($bannerId, $d, $m, $y),
|
|
||||||
[
|
|
||||||
'$inc' => [
|
|
||||||
'clicks' => 1
|
|
||||||
]
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -275,72 +298,6 @@ class AnalyticsHelper {
|
|||||||
return sizeof($ret) == 0 ? 0 : $ret[0]['tot'];
|
return sizeof($ret) == 0 ? 0 : $ret[0]['tot'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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) {
|
|
||||||
// ?TODO: Ragionaci
|
|
||||||
// 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 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){
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -19,9 +19,7 @@ class BannerHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function printBanner($position = BannerModel::POSITION_HEAD){
|
public static function printBanner($position = BannerModel::POSITION_HEAD){
|
||||||
$category = BannerModel::GENERAL_CATEGORY;
|
$cur = self::getPlaceholderId();
|
||||||
|
|
||||||
$cur = self::getPlaceholderId();
|
|
||||||
|
|
||||||
if (!array_key_exists($position, self::$positions)) {
|
if (!array_key_exists($position, self::$positions)) {
|
||||||
self::$positions[$position] = [];
|
self::$positions[$position] = [];
|
||||||
|
|||||||
@@ -258,13 +258,19 @@ class GenericDao{
|
|||||||
] );
|
] );
|
||||||
$cursor = $this->client->executeCommand( $this->dbName, $command );
|
$cursor = $this->client->executeCommand( $this->dbName, $command );
|
||||||
|
|
||||||
$rval = [];
|
if (array_key_exists('cursor', $options) && $options['cursor'] == true) {
|
||||||
foreach ($cursor as $ele){ // inganniamo il cursore, in realtà il risultato è uno
|
return $cursor;
|
||||||
//TODO CHECK
|
}
|
||||||
$rval[] = json_decode( json_encode($ele) ,true );
|
else {
|
||||||
}
|
$rval = [];
|
||||||
|
foreach ($cursor as $ele){ // inganniamo il cursore, in realtà il risultato è uno
|
||||||
|
//TODO CHECK
|
||||||
|
$rval[] = json_decode( json_encode($ele) ,true );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rval;
|
||||||
|
}
|
||||||
|
|
||||||
return $rval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,17 @@ class BannerModel extends HasMediaModel{
|
|||||||
const POSITION_BODY = 2;
|
const POSITION_BODY = 2;
|
||||||
const POSITION_LONG = 3;
|
const POSITION_LONG = 3;
|
||||||
|
|
||||||
|
const POSITION_TOP = 4;
|
||||||
|
const POSITION_BOTTOM = 5;
|
||||||
|
|
||||||
const GENERAL_CATEGORY = 0;
|
const GENERAL_CATEGORY = 0;
|
||||||
|
|
||||||
public static $BANNER_POSITIONS = array(
|
public static $BANNER_POSITIONS = array(
|
||||||
self::POSITION_HEAD=>array("label"=>"Testata"),
|
self::POSITION_HEAD=>array("label"=>"Testata"),
|
||||||
self::POSITION_BODY=>array("label"=>"Corpo"),
|
self::POSITION_BODY=>array("label"=>"Corpo"),
|
||||||
self::POSITION_LONG=>array("label"=>"Corpo Lungo")
|
self::POSITION_LONG=>array("label"=>"Corpo Lungo"),
|
||||||
|
self::POSITION_TOP=>array("label"=>"Inizio pagina"),
|
||||||
|
self::POSITION_BOTTOM=>array("label"=>"Fine pagina")
|
||||||
);
|
);
|
||||||
|
|
||||||
public function __construct($saveableObject = null){
|
public function __construct($saveableObject = null){
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ class GUIHandler {
|
|||||||
private static $onLoadEvents = array();
|
private static $onLoadEvents = array();
|
||||||
|
|
||||||
public static function generateHtmlHeaders(array $data = array(), $admin = false){
|
public static function generateHtmlHeaders(array $data = array(), $admin = false){
|
||||||
if ($admin) {
|
ASDSessionHandler::getSessionId();
|
||||||
ASDSessionHandler::getSessionId();
|
|
||||||
}
|
|
||||||
$conf = GlobalVariables::get("config");
|
$conf = GlobalVariables::get("config");
|
||||||
|
|
||||||
$title = $conf->info->projectName;
|
$title = $conf->info->projectName;
|
||||||
@@ -222,7 +220,10 @@ class GUIHandler {
|
|||||||
<?php BannerHelper::printBanner(BannerModel::POSITION_HEAD);?>
|
<?php BannerHelper::printBanner(BannerModel::POSITION_HEAD);?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="bottomBar" style="height:40px;width:1000px;"></div>
|
<div class="bottomBar" style="width:1000px;"></div>
|
||||||
|
<div class="banner subheadBanner mediaContent">
|
||||||
|
<?php BannerHelper::printBanner(BannerModel::POSITION_TOP);?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -329,6 +330,9 @@ class GUIHandler {
|
|||||||
self::setCookieSeen();
|
self::setCookieSeen();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
<div class="banner footerBanner mediaContent">
|
||||||
|
<?php BannerHelper::printBanner(BannerModel::POSITION_BOTTOM);?>
|
||||||
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<div class="footerCategory">
|
<div class="footerCategory">
|
||||||
<a href="index.php">Home</a>
|
<a href="index.php">Home</a>
|
||||||
|
|||||||
@@ -343,12 +343,6 @@ class GUIHandlerMobile {
|
|||||||
public static function generateFooter(){
|
public static function generateFooter(){
|
||||||
if (!self::hasSeenCookieMessage()){
|
if (!self::hasSeenCookieMessage()){
|
||||||
?>
|
?>
|
||||||
<!-- <div class="cookieAdvice"> -->
|
|
||||||
<!-- <div>Questo sito utilizza cookie tecnici per offrirti una migliore esperienza di navigazione sul sito.</div> -->
|
|
||||||
<!-- <div>Navigando su questo sito accetti l'utilizzo dei cookie.</div><br/> -->
|
|
||||||
<!-- <a class="closeAdvice">Chiudi</a> -->
|
|
||||||
<!-- <br/><br/> -->
|
|
||||||
<!-- </div> -->
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('.closeAdvice').click(function(){
|
$('.closeAdvice').click(function(){
|
||||||
@@ -363,6 +357,9 @@ class GUIHandlerMobile {
|
|||||||
self::setCookieSeen();
|
self::setCookieSeen();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
<div class="banner footerBanner mediaContent">
|
||||||
|
<?php BannerHelper::printBanner(BannerModel::POSITION_BOTTOM);?>
|
||||||
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<div class="footerButton" style="text-align:center;">
|
<div class="footerButton" style="text-align:center;">
|
||||||
<a href="#">
|
<a href="#">
|
||||||
|
|||||||
@@ -91,9 +91,17 @@ try{
|
|||||||
<span class="label">Posizione:</span>
|
<span class="label">Posizione:</span>
|
||||||
<select name="position">
|
<select name="position">
|
||||||
<option disabled selected style="display:none;">Seleziona Posizione</option>
|
<option disabled selected style="display:none;">Seleziona Posizione</option>
|
||||||
<option <?php echo $banner->position==BannerModel::POSITION_HEAD?"selected":"";?> value="<?php echo BannerModel::POSITION_HEAD;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_HEAD]["label"];?></option>
|
<?php
|
||||||
<option <?php echo $banner->position==BannerModel::POSITION_BODY?"selected":"";?> value="<?php echo BannerModel::POSITION_BODY;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_BODY]["label"];?></option>
|
foreach (BannerModel::$BANNER_POSITIONS as $type => $data) {
|
||||||
<option <?php echo $banner->position==BannerModel::POSITION_LONG?"selected":"";?> value="<?php echo BannerModel::POSITION_LONG;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_LONG]["label"];?></option>
|
printf(
|
||||||
|
'<option %s value="%s">%s</option>',
|
||||||
|
$banner->position==$type ? "selected" : "",
|
||||||
|
$type,
|
||||||
|
$data['label']
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ HTMLHelper::generateAdminHead();
|
|||||||
<li>Banner testata:<b>180x60px</b></li>
|
<li>Banner testata:<b>180x60px</b></li>
|
||||||
<li>Banner corpo:<b>160x120px</b></li>
|
<li>Banner corpo:<b>160x120px</b></li>
|
||||||
<li>Banner lungo:<b>160x240px</b></li>
|
<li>Banner lungo:<b>160x240px</b></li>
|
||||||
|
<li>Banner Inizio pagina:<b>1000x120px</b></li>
|
||||||
|
<li>Banner Fine pagina:<b>1000x200px</b></li>
|
||||||
</ul>
|
</ul>
|
||||||
Tale restizione è consigliata anche per i banner di tipo <i>HTML5</i>.
|
Tale restizione è consigliata anche per i banner di tipo <i>HTML5</i>.
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -23,18 +23,6 @@ try{
|
|||||||
$newMedia = null;
|
$newMedia = null;
|
||||||
$mediaTypeSaved = PostHandler::get("mediaType");
|
$mediaTypeSaved = PostHandler::get("mediaType");
|
||||||
|
|
||||||
// if(!is_null($bannerId) && strcmp($bannerId, "")!=0){
|
|
||||||
// $edit = true;
|
|
||||||
// $banner = GlobalVariables::get("dao")->getFirst("BannerModel",array("id"=>$bannerId));
|
|
||||||
// $newMedias = DaoMediaHandler::getMedias($banner);
|
|
||||||
// if(sizeof($newMedias)>0){
|
|
||||||
// $newMedia = reset($newMedias);
|
|
||||||
// }
|
|
||||||
// if($banner->hasProperty("type") && !is_null($banner->type)){
|
|
||||||
// $mediaTypeSaved = $banner->type;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if(array_key_exists("action", $_POST) && strcmp(PostHandler::get("action"), "save")==0){
|
if(array_key_exists("action", $_POST) && strcmp(PostHandler::get("action"), "save")==0){
|
||||||
$mediaType = PostHandler::get("mediaType");
|
$mediaType = PostHandler::get("mediaType");
|
||||||
if (!is_null($mediaType) && strcmp($mediaType, "")!=0){
|
if (!is_null($mediaType) && strcmp($mediaType, "")!=0){
|
||||||
@@ -98,69 +86,7 @@ try{
|
|||||||
else {
|
else {
|
||||||
throw new GUIException("Selezionare il tipo di file multimediale da utilizzare");
|
throw new GUIException("Selezionare il tipo di file multimediale da utilizzare");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if(is_null($bannerId) || strcmp($bannerId, "")==0){
|
|
||||||
// $banner->customer = PostHandler::get("customer");
|
|
||||||
// $banner->type = PostHandler::get("mediaType");
|
|
||||||
// $banner->start = new Mongodate(strtotime(PostHandler::get("dateStart")));
|
|
||||||
// $banner->end = new Mongodate(strtotime(PostHandler::get("dateEnd")));
|
|
||||||
// GlobalVariables::get("dao")->save($banner);
|
|
||||||
// $bannerId = $banner->id;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if(!is_null($bannerId) && strcmp($bannerId, "")!=0){
|
|
||||||
// $edit=true;
|
|
||||||
// // $banner = GlobalVariables::get("dao")->getFirst("BannerModel",array("id"=>$bannerId));
|
|
||||||
// $file = "";
|
|
||||||
|
|
||||||
// $mediaType = PostHandler::get("mediaType");
|
|
||||||
// $banner->type=$mediaType;
|
|
||||||
// if(strcmp($mediaType, "")!=0){
|
|
||||||
// $tmp = array();
|
|
||||||
// $saveable = new stdClass();
|
|
||||||
// $saveable->mediaType = $mediaType;
|
|
||||||
// if(strcmp($mediaType,MediaModel::TYPE_HTML5)==0){
|
|
||||||
// $saveable->code = PostHandler::get("data");
|
|
||||||
// $media = DaoMediaHandler::createNewTextBasedMedia($saveable);
|
|
||||||
// }
|
|
||||||
// else if(strcmp($mediaType,MediaModel::TYPE_IMAGE)==0){
|
|
||||||
// $file = $_FILES['data']['tmp_name'];
|
|
||||||
// $info = pathinfo($_FILES['data']['name']);
|
|
||||||
// // $file = PostHandler::get("data");
|
|
||||||
// $media = DaoMediaHandler::createNewFileBasedMedia($saveable, $file,$info["extension"]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if(!is_null($media)){
|
|
||||||
// GlobalVariables::get("dao")->save($media);
|
|
||||||
// DaoMediaHandler::addMedia($banner, $media);
|
|
||||||
// GlobalVariables::get("dao")->save($banner);
|
|
||||||
// }
|
|
||||||
// else{
|
|
||||||
// throw new Exception("Cannot save a null media in the news with id '".$bannerId."'");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else{
|
|
||||||
// throw new Exception("Invalid mediaType '".$mediaType."' while trying to add the media in editBanner");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// GUIHandler::redirect("admin/listBanner.php");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
// else if(array_key_exists("action", $_POST) && strcmp(PostHandler::get("action"), "delete")==0){
|
|
||||||
// if(!is_null($bannerId) && strcmp($bannerId, "")!=0){
|
|
||||||
// $banner = GlobalVariables::get("dao")->getFirst("BannerModel",array("id"=>$bannerId));
|
|
||||||
// $medias = DaoMediaHandler::getMedias($banner);
|
|
||||||
// // $media = reset($medias);
|
|
||||||
// // $media = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$mediaId));
|
|
||||||
// foreach ($medias as $media){
|
|
||||||
// DaoMediaHandler::deleteMedia($banner, $media);
|
|
||||||
// $banner->type = null;
|
|
||||||
// GlobalVariables::get("dao")->save($banner);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// GUIHandler::redirect("admin/listBanner.php");
|
|
||||||
// }
|
|
||||||
$formFile = '<input type="hidden" name="MAX_FILE_SIZE" value="52428800" />
|
$formFile = '<input type="hidden" name="MAX_FILE_SIZE" value="52428800" />
|
||||||
<span class="label">Seleziona file</span><input type="file" name="data" />';
|
<span class="label">Seleziona file</span><input type="file" name="data" />';
|
||||||
if($edit && !is_null($newMedia)){
|
if($edit && !is_null($newMedia)){
|
||||||
@@ -173,6 +99,7 @@ try{
|
|||||||
}catch(GUIException $ex){
|
}catch(GUIException $ex){
|
||||||
$error = $ex->getMessage();
|
$error = $ex->getMessage();
|
||||||
}catch (Exception $exec){
|
}catch (Exception $exec){
|
||||||
|
var_dump($exec);
|
||||||
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_ERROR, $exec->getMessage());
|
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_ERROR, $exec->getMessage());
|
||||||
$error = "Si è verificato un errore inaspettato durante l'esecuzione della pagina. Se l'errore persiste contattare il supporto tecnico.";
|
$error = "Si è verificato un errore inaspettato durante l'esecuzione della pagina. Se l'errore persiste contattare il supporto tecnico.";
|
||||||
}
|
}
|
||||||
@@ -196,6 +123,8 @@ try{
|
|||||||
<option value="<?php echo BannerModel::POSITION_HEAD;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_HEAD]["label"];?></option>
|
<option value="<?php echo BannerModel::POSITION_HEAD;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_HEAD]["label"];?></option>
|
||||||
<option value="<?php echo BannerModel::POSITION_BODY;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_BODY]["label"];?></option>
|
<option value="<?php echo BannerModel::POSITION_BODY;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_BODY]["label"];?></option>
|
||||||
<option value="<?php echo BannerModel::POSITION_LONG;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_LONG]["label"];?></option>
|
<option value="<?php echo BannerModel::POSITION_LONG;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_LONG]["label"];?></option>
|
||||||
|
<option value="<?php echo BannerModel::POSITION_TOP;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_TOP]["label"];?></option>
|
||||||
|
<option value="<?php echo BannerModel::POSITION_BOTTOM;?>"><?php echo BannerModel::$BANNER_POSITIONS[BannerModel::POSITION_BOTTOM]["label"];?></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -12,17 +12,11 @@ if (array_key_exists("id",$_GET)) {
|
|||||||
if (!is_null($pdfModel)){
|
if (!is_null($pdfModel)){
|
||||||
$localFilePath = GlobalVariables::get("config")->paths->media."/".$id.".".$pdfModel->extension;
|
$localFilePath = GlobalVariables::get("config")->paths->media."/".$id.".".$pdfModel->extension;
|
||||||
if (SFSManager::fileExists($localFilePath)){
|
if (SFSManager::fileExists($localFilePath)){
|
||||||
$exposedFilePath = GlobalVariables::get("config")->paths->xsendfile."/".$id.".".$pdfModel->extension;
|
|
||||||
if (!SFSManager::fileExists($exposedFilePath)){
|
|
||||||
if (!SFSManager::fileExists(GlobalVariables::get("config")->paths->xsendfile) || !is_dir(GlobalVariables::get("config")->paths->xsendfile)){
|
|
||||||
SystemController::mkdir(GlobalVariables::get("config")->paths->xsendfile);
|
|
||||||
}
|
|
||||||
SystemController::shellExec("ln",'-nFs "'.$localFilePath.'" "'.$exposedFilePath.'"');
|
|
||||||
}
|
|
||||||
header('X-Sendfile: '.$exposedFilePath.'');
|
|
||||||
|
|
||||||
header("Content-type: application/octet-stream");
|
header("Content-type: application/octet-stream");
|
||||||
header('Content-Disposition: attachment; filename="' . basename($exposedFilePath) . '"');
|
header('Content-Disposition: attachment; filename="' . $id.".".$pdfModel->extension . '"');
|
||||||
|
|
||||||
|
echo file_get_contents($localFilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,8 +152,9 @@ try {
|
|||||||
</div>
|
</div>
|
||||||
<div class="archivioResults">
|
<div class="archivioResults">
|
||||||
<div style="text-align:center;">
|
<div style="text-align:center;">
|
||||||
<div class="middleBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_HEAD);?></div>
|
<div class="banner subheadBanner mediaContent">
|
||||||
<div class="middleBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_HEAD);?></div>
|
<?php BannerHelper::printBanner(BannerModel::POSITION_TOP);?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php if(!$post){
|
<?php if(!$post){
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -136,8 +136,9 @@ GUIHandlerMobile::generateHtmlHeaders(array("additionalMetadata"=>$additionalHea
|
|||||||
</script>
|
</script>
|
||||||
<div class="newsContainer">
|
<div class="newsContainer">
|
||||||
<div style="text-align:center;">
|
<div style="text-align:center;">
|
||||||
<div class="middleBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_HEAD);?></div>
|
<div class="banner subheadBanner mediaContent">
|
||||||
<div class="middleBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_HEAD);?></div>
|
<?php BannerHelper::printBanner(BannerModel::POSITION_TOP);?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="articoloCategoryName" style="color:white;background-color:<?php echo NotiziaModel::$NOTIZIE_CATEGORY[$articolo->category]["color"] ?>;">
|
<div class="articoloCategoryName" style="color:white;background-color:<?php echo NotiziaModel::$NOTIZIE_CATEGORY[$articolo->category]["color"] ?>;">
|
||||||
<span itemprop="articleSection"><?php echo strtoupper(NotiziaModel::$NOTIZIE_CATEGORY[$articolo->category]["label"]);?></span>
|
<span itemprop="articleSection"><?php echo strtoupper(NotiziaModel::$NOTIZIE_CATEGORY[$articolo->category]["label"]);?></span>
|
||||||
|
|||||||
@@ -65,9 +65,10 @@ try{
|
|||||||
GUIHandlerMobile::generateHeadPublic();
|
GUIHandlerMobile::generateHeadPublic();
|
||||||
GUIHandlerMobile::generateMenu();?>
|
GUIHandlerMobile::generateMenu();?>
|
||||||
<div class="categorySummaryContainer">
|
<div class="categorySummaryContainer">
|
||||||
<div style="text-align:center;">
|
<div style="text-align:center;">
|
||||||
<div class="middleBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_HEAD);?></div>
|
<div class="banner subheadBanner mediaContent">
|
||||||
<div class="middleBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_HEAD);?></div>
|
<?php BannerHelper::printBanner(BannerModel::POSITION_TOP);?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php $i=0;
|
<?php $i=0;
|
||||||
if(sizeof($notizie)>0){
|
if(sizeof($notizie)>0){
|
||||||
|
|||||||
@@ -144,8 +144,9 @@ catch (Exception $ex){
|
|||||||
?>
|
?>
|
||||||
<div class="newsBarMobile">
|
<div class="newsBarMobile">
|
||||||
<div style="text-align:center;">
|
<div style="text-align:center;">
|
||||||
<div class="middleBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_HEAD);?></div>
|
<div class="banner subheadBanner mediaContent">
|
||||||
<div class="middleBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_HEAD);?></div>
|
<?php BannerHelper::printBanner(BannerModel::POSITION_TOP);?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="newsContainer" >
|
<div class="newsContainer" >
|
||||||
<?php $i=0; foreach($ansaNews as $ansa){
|
<?php $i=0; foreach($ansaNews as $ansa){
|
||||||
|
|||||||
@@ -88,8 +88,9 @@ try {
|
|||||||
GUIHandlerMobile::generateMenu();?>
|
GUIHandlerMobile::generateMenu();?>
|
||||||
<div class="searchResultsContainer">
|
<div class="searchResultsContainer">
|
||||||
<div style="text-align:center;">
|
<div style="text-align:center;">
|
||||||
<div class="middleBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_HEAD);?></div>
|
<div class="banner subheadBanner mediaContent">
|
||||||
<div class="middleBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_HEAD);?></div>
|
<?php BannerHelper::printBanner(BannerModel::POSITION_TOP);?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
if ($found){
|
if ($found){
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ body{font-family:lato, arial;}
|
|||||||
.headArticolo .newsImage{width:100vw;text-align:center;overflow:hidden;}
|
.headArticolo .newsImage{width:100vw;text-align:center;overflow:hidden;}
|
||||||
.headArticolo .newsImage img{max-width:100%;}
|
.headArticolo .newsImage img{max-width:100%;}
|
||||||
.articoloTitle{width:90%;padding:10px;margin:auto;}
|
.articoloTitle{width:90%;padding:10px;margin:auto;}
|
||||||
.articoloTitle .title{font-weight:bold;color:black;}
|
.articoloTitle .title{ font-weight:bold; color:black; }
|
||||||
.articoloTitle .subTitle{font-weight:italic;color:#9a9a9a;}
|
.articoloTitle .subTitle{font-weight:italic;color:#9a9a9a;}
|
||||||
.articoloBody{width:90vw;margin:auto;}
|
.articoloBody{width:90vw;margin:auto;}
|
||||||
.articoloBody .articoloTesto{text-align:justify;padding:5px;}
|
.articoloBody .articoloTesto{text-align:justify;padding:5px;}
|
||||||
|
|||||||
@@ -22,11 +22,14 @@ body{font-family:lato, arial;}
|
|||||||
.socialBar > a > div{display:inline-block;width:22px;height:22px;background-repeat:no-repeat;}
|
.socialBar > a > div{display:inline-block;width:22px;height:22px;background-repeat:no-repeat;}
|
||||||
|
|
||||||
.middleBar{position:relative;height:138px;border:solid #d6d6d6 1px;border-top:0px;border-left:0px;border-right:0px;}
|
.middleBar{position:relative;height:138px;border:solid #d6d6d6 1px;border-top:0px;border-left:0px;border-right:0px;}
|
||||||
|
.banner img{ width: 100%; height: 100%; overflow: hidden; }
|
||||||
.leftBanner{position:absolute;top:45px;left:10px;}
|
.leftBanner{position:absolute;top:45px;left:10px;}
|
||||||
.logo{display:inline-block;width:50%;text-align:center;margin:12px 250px;}
|
.logo{display:inline-block;width:50%;text-align:center;margin:12px 250px;}
|
||||||
.rightBanner{position:absolute;top:45px;right:10px;}
|
.rightBanner{position:absolute;top:45px;right:10px;}
|
||||||
.topBanner{width:180px;height:60px;}
|
.topBanner{width:180px;height:60px;}
|
||||||
.topBanner > *{max-widht:100%;max-height:100%;}
|
.topBanner > * { max-width:100%; max-height:100%; }
|
||||||
|
.subheadBanner { width:1000px; height:120px; }
|
||||||
|
.footerBanner { width:1000px; height:200px; }
|
||||||
|
|
||||||
|
|
||||||
.menuContainer{position:relative;}
|
.menuContainer{position:relative;}
|
||||||
@@ -312,23 +315,23 @@ display: inline-block;
|
|||||||
.meteo div span{font-weight:bold;}
|
.meteo div span{font-weight:bold;}
|
||||||
|
|
||||||
.middleRightBanner{width:210px;overflow: hidden;height: 157px;margin: 5px 0;}
|
.middleRightBanner{width:210px;overflow: hidden;height: 157px;margin: 5px 0;}
|
||||||
.middleRightBanner img{width:100%; heigth:100%;}
|
.middleRightBanner img{width:100%; height:100%;}
|
||||||
.middleRightLongBanner img{height:100%;width:100%;}
|
.middleRightLongBanner img{height:100%;width:100%;}
|
||||||
.middleRightLongBanner{height:314px; width:210px;overflow: hidden;margin: 5px 0;}
|
.middleRightLongBanner{height:314px; width:210px;overflow: hidden;margin: 5px 0;}
|
||||||
|
|
||||||
.reader > .lastContainer, .lastContainer{/* max-height:120px */;display:block;padding:5px;border-bottom:dotted #C1B4B4 1px;cursor:pointer;text-decoration:none;color:black;}
|
.reader > .lastContainer, .lastContainer{ display:block;padding:5px;border-bottom:dotted #C1B4B4 1px;cursor:pointer;text-decoration:none;color:black;}
|
||||||
.reader > .lastContainer:last-child, .lastContainer:last-child {border-bottom: none;}
|
.reader > .lastContainer:last-child, .lastContainer:last-child {border-bottom: none;}
|
||||||
.reader > .lastData, .lastData{font-size:12px;}
|
.reader > .lastData, .lastData{font-size:12px;}
|
||||||
.reader > .lastTitle, .lastTitle{font-size:12px;font-weight:bold;}
|
.reader > .lastTitle, .lastTitle{font-size:12px;font-weight:bold;}
|
||||||
.reader > .lastContinua, .lastContinua{text-align:right; font-size:12px;font-weight:bold;padding-bottom:5px;}
|
.reader > .lastContinua, .lastContinua{text-align:right; font-size:12px;font-weight:bold;padding-bottom:5px;}
|
||||||
.reader > .lastContinua a, .lastContinua a{color:#64bff0;}
|
.reader > .lastContinua a, .lastContinua a{color:#64bff0;}
|
||||||
|
|
||||||
.gossipContainer{/* max-height:165px */;/* margin-top:5px */;margin-bottom:5px;border-bottom:dotted #C1B4B4 1px;cursor:pointer;overflow:hidden;text-decoration:none;color:black;}
|
.gossipContainer{margin-bottom:5px;border-bottom:dotted #C1B4B4 1px;cursor:pointer;overflow:hidden;text-decoration:none;color:black;}
|
||||||
.gossipContainer#gossip_2{border-bottom:none;}
|
.gossipContainer#gossip_2{border-bottom:none;}
|
||||||
.gossipTitle{margin-bottom:5px;font-weight:bold;font-size:20px;}
|
.gossipTitle{margin-bottom:5px;font-weight:bold;font-size:20px;}
|
||||||
.gossipSubtitle{margin-bottom:5px;color:#64bff0;font-weight:bold;font-size:15px;}
|
.gossipSubtitle{margin-bottom:5px;color:#64bff0;font-weight:bold;font-size:15px;}
|
||||||
|
|
||||||
.animaliContainer,.viaggiContainer{/* max-height:165px; *//* margin-top:5px */;display:block;margin-bottom:5px;text-decoration:none;color:black;}
|
.animaliContainer,.viaggiContainer{display:block;margin-bottom:5px;text-decoration:none;color:black;}
|
||||||
.animaliContainer > .culturaMainMedia,.viaggiContainer > .culturaMainMedia{text-align:left;}
|
.animaliContainer > .culturaMainMedia,.viaggiContainer > .culturaMainMedia{text-align:left;}
|
||||||
.animaliTitle,.viaggiTitle{cursor:pointer;margin-bottom:5px;font-weight:bold;font-size:17px;}
|
.animaliTitle,.viaggiTitle{cursor:pointer;margin-bottom:5px;font-weight:bold;font-size:17px;}
|
||||||
|
|
||||||
|
|||||||
@@ -49,10 +49,6 @@ services:
|
|||||||
§PROJECT_BUILDNAME§-network:
|
§PROJECT_BUILDNAME§-network:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
nginx-network:
|
|
||||||
external:
|
|
||||||
name:
|
|
||||||
nginx-network
|
|
||||||
db-network:
|
db-network:
|
||||||
§PROJECT_BUILDNAME§-network:
|
§PROJECT_BUILDNAME§-network:
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# Use a PHP runtime as a parent image
|
||||||
|
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§
|
||||||
|
|
||||||
|
# Set the working directory to /app
|
||||||
|
WORKDIR /§PROJECT_BUILDNAME§
|
||||||
|
|
||||||
|
# Install GD (required by mpdf)
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -yq --no-install-recommends libpng-dev zlib1g-dev && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
RUN docker-php-ext-install gd
|
||||||
|
|
||||||
|
# Install Memcached
|
||||||
|
RUN apt-get update && apt-get install -y libmemcached-dev \
|
||||||
|
&& pecl install memcached-3.1.5 \
|
||||||
|
&& docker-php-ext-enable memcached
|
||||||
|
|
||||||
|
# Copy the current directory contents into the container at /app
|
||||||
|
COPY ./app /§PROJECT_BUILDNAME§
|
||||||
|
|
||||||
|
COPY ./version /§PROJECT_BUILDNAME§
|
||||||
|
|
||||||
|
COPY ./config /§PROJECT_BUILDNAME§
|
||||||
|
|
||||||
|
COPY ./install /§PROJECT_BUILDNAME§
|
||||||
|
|
||||||
|
RUN chmod 744 /§PROJECT_BUILDNAME§/install
|
||||||
|
|
||||||
|
RUN /§PROJECT_BUILDNAME§/install
|
||||||
|
|
||||||
|
|
||||||
|
ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"]
|
||||||
|
|
||||||
|
# Make port 80 available to the world outside this container
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# Use a PHP runtime as a parent image
|
||||||
|
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§
|
||||||
|
|
||||||
|
# Set the working directory to /app
|
||||||
|
WORKDIR /§PROJECT_BUILDNAME§
|
||||||
|
|
||||||
|
# Install XDebug
|
||||||
|
RUN pecl install xdebug | tail -n 1 | awk -F"\"" '{print $2}' > /usr/local/etc/php/conf.d/xdebug.ini
|
||||||
|
RUN echo "\n\n[XDebug]\nxdebug.mode=debug\nxdebug.start_with_request=yes\nxdebug.client_host = §DEBUG_REMOTE_IP§\nxdebug.client_port = §DEBUG_REMOTE_PORT§\n" >> /usr/local/etc/php/conf.d/xdebug.ini
|
||||||
|
|
||||||
|
# Install Memcached
|
||||||
|
RUN apt-get update && apt-get install -y libmemcached-dev zlib1g-dev \
|
||||||
|
&& pecl install memcached-3.1.5 \
|
||||||
|
&& docker-php-ext-enable memcached
|
||||||
|
|
||||||
|
# Install SOAP
|
||||||
|
RUN docker-php-ext-install soap
|
||||||
|
|
||||||
|
# Copy the current directory contents into the container at /app
|
||||||
|
COPY ./app /§PROJECT_BUILDNAME§
|
||||||
|
|
||||||
|
COPY ./version /§PROJECT_BUILDNAME§
|
||||||
|
|
||||||
|
COPY ./config /§PROJECT_BUILDNAME§
|
||||||
|
|
||||||
|
COPY ./install /§PROJECT_BUILDNAME§
|
||||||
|
|
||||||
|
RUN chmod 744 /§PROJECT_BUILDNAME§/install
|
||||||
|
|
||||||
|
RUN /§PROJECT_BUILDNAME§/install
|
||||||
|
|
||||||
|
ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"]
|
||||||
|
|
||||||
|
# Make port 80 available to the world outside this container
|
||||||
|
EXPOSE 80
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§-unit
|
||||||
|
|
||||||
|
WORKDIR /§PROJECT_BUILDNAME§
|
||||||
|
COPY ./app /§PROJECT_BUILDNAME§
|
||||||
|
COPY ./test /test§PROJECT_BUILDNAME§
|
||||||
|
COPY ./version /§PROJECT_BUILDNAME§
|
||||||
|
COPY ./config /§PROJECT_BUILDNAME§
|
||||||
|
COPY ./test/install /§PROJECT_BUILDNAME§
|
||||||
|
|
||||||
|
RUN chmod 744 /§PROJECT_BUILDNAME§/install
|
||||||
|
|
||||||
|
RUN /§PROJECT_BUILDNAME§/install
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/phpunit"]
|
||||||
|
CMD ["--help"]
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
DDNINJA_PROJECTNAME=FDN2
|
DDNINJA_PROJECTNAME=FDN2
|
||||||
DDNINJA_BUILDNAME=fdn2
|
DDNINJA_BUILDNAME=fdn2
|
||||||
|
DDNINJA_AUTHOR=ddninja
|
||||||
@@ -37,4 +37,4 @@ db.notizia.ensureIndex({"about.author": "text",sottotitolo: "text",testo: "text"
|
|||||||
|
|
||||||
db.article_stats.ensureIndex({ "notizia": 1, "time": 1, "deleted": 1 }, {name: "quick_upsert"})
|
db.article_stats.ensureIndex({ "notizia": 1, "time": 1, "deleted": 1 }, {name: "quick_upsert"})
|
||||||
db.banner_stats.ensureIndex({ "banner": 1, "time": 1, "deleted": 1 }, {name: "quick_upsert"})
|
db.banner_stats.ensureIndex({ "banner": 1, "time": 1, "deleted": 1 }, {name: "quick_upsert"})
|
||||||
db.pageview_stats.ensureIndex({ "deleted": 1, "time": 1, "page": 1 }, {name: "quick_upsert"})
|
db.pageview_stats.ensureIndex({ "time": 1, "page": 1, "deleted": 1, }, {name: "quick_upsert"})
|
||||||
|
|||||||
+8
-4
@@ -15,9 +15,10 @@ source "$DIR/../config"
|
|||||||
source "$DIR/libs.sh"
|
source "$DIR/libs.sh"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 [-h] [-v] [-t: version] [image type, see below] " 1>&2;
|
echo "Usage: $0 [-h] [-v] [-t: version] -I <webserver|worker> [image type, see below] " 1>&2;
|
||||||
echo "This script builds framework docker images, the following options are available:" 1>&2;
|
echo "This script builds framework docker images, the following options are available:" 1>&2;
|
||||||
echo " -h: This message" 1>&2;
|
echo " -h: This message" 1>&2;
|
||||||
|
echo " -I: Image (webserver or worker)" 1>&2;
|
||||||
echo " Image types (at least one, otherwise the script does nothing)" 1>&2;
|
echo " Image types (at least one, otherwise the script does nothing)" 1>&2;
|
||||||
echo " -a: All, same as ub" 1>&2;
|
echo " -a: All, same as ub" 1>&2;
|
||||||
echo " -u: Unit" 1>&2;
|
echo " -u: Unit" 1>&2;
|
||||||
@@ -33,9 +34,13 @@ UNIT_MODE=0
|
|||||||
DEBUG_MODE=0
|
DEBUG_MODE=0
|
||||||
|
|
||||||
TAG="local"
|
TAG="local"
|
||||||
|
TYPE="webserver"
|
||||||
|
|
||||||
while getopts "t:hvaubd" o; do
|
while getopts "I:t:hvaubd" o; do
|
||||||
case "${o}" in
|
case "${o}" in
|
||||||
|
I)
|
||||||
|
TYPE="${OPTARG}"
|
||||||
|
;;
|
||||||
b)
|
b)
|
||||||
BASE_MODE=1
|
BASE_MODE=1
|
||||||
;;
|
;;
|
||||||
@@ -66,7 +71,6 @@ while getopts "t:hvaubd" o; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cd ".."
|
cd ".."
|
||||||
|
|
||||||
# STANDARD MODE
|
# STANDARD MODE
|
||||||
@@ -78,7 +82,7 @@ if [[ $BASE_MODE -gt 0 ]]; then
|
|||||||
OPTS+="v"
|
OPTS+="v"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$DIR/generateDockerfile.sh -$OPTS -o $DOCKERFILE
|
$DIR/generateDockerfile.sh -I "${TYPE}" -$OPTS -o $DOCKERFILE
|
||||||
|
|
||||||
msg "Building project image $TAG"
|
msg "Building project image $TAG"
|
||||||
docker build -t $PROJECT_REPOSITORY/$PROJECT_GROUP/$PROJECT_BUILDNAME:$TAG -f $DOCKERFILE .
|
docker build -t $PROJECT_REPOSITORY/$PROJECT_GROUP/$PROJECT_BUILDNAME:$TAG -f $DOCKERFILE .
|
||||||
|
|||||||
+54
-6
@@ -24,7 +24,12 @@ usage() {
|
|||||||
echo " -p: Publish (requires a version)" 1>&2;
|
echo " -p: Publish (requires a version)" 1>&2;
|
||||||
echo " -X: Staging Deploy (requires a version)" 1>&2;
|
echo " -X: Staging Deploy (requires a version)" 1>&2;
|
||||||
echo " -x: Production Deploy (requires a version)" 1>&2;
|
echo " -x: Production Deploy (requires a version)" 1>&2;
|
||||||
echo " -t: Software version, this will be used for the docker tag (default: local)" 1>&2;
|
echo " Tagging, docker images (default: local)" 1>&2;
|
||||||
|
echo " -t: Manual tag" 1>&2;
|
||||||
|
echo " -T: Autotag patch/release" 1>&2;
|
||||||
|
echo " -m: Autotag minor" 1>&2;
|
||||||
|
echo " -M: Autotag major" 1>&2;
|
||||||
|
echo " -P: Pre-release" 1>&2;
|
||||||
echo " -v: Verbose" 1>&2;
|
echo " -v: Verbose" 1>&2;
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
@@ -35,10 +40,13 @@ PUBLISH_MODE=0
|
|||||||
DEPLOY_TEST_MODE=0
|
DEPLOY_TEST_MODE=0
|
||||||
DEPLOY_PROD_MODE=0
|
DEPLOY_PROD_MODE=0
|
||||||
SELECTED_MODES=0
|
SELECTED_MODES=0
|
||||||
|
TAG_IMPLICIT=1
|
||||||
|
|
||||||
TAG="local"
|
TAG="local"
|
||||||
|
TAG_OPTS=""
|
||||||
|
AUTOTAG=0
|
||||||
|
|
||||||
while getopts "t:hvudpxX" o; do
|
while getopts "t:TmMPhvudpxX" o; do
|
||||||
case "${o}" in
|
case "${o}" in
|
||||||
u)
|
u)
|
||||||
UNIT_MODE=1
|
UNIT_MODE=1
|
||||||
@@ -63,6 +71,27 @@ while getopts "t:hvudpxX" o; do
|
|||||||
|
|
||||||
t)
|
t)
|
||||||
TAG=${OPTARG}
|
TAG=${OPTARG}
|
||||||
|
TAG_IMPLICIT=0
|
||||||
|
;;
|
||||||
|
T)
|
||||||
|
TAG_OPTS="${TAG_OPTS}r"
|
||||||
|
TAG_IMPLICIT=0
|
||||||
|
AUTOTAG=1
|
||||||
|
;;
|
||||||
|
m)
|
||||||
|
TAG_OPTS="${TAG_OPTS}m"
|
||||||
|
TAG_IMPLICIT=0
|
||||||
|
AUTOTAG=1
|
||||||
|
;;
|
||||||
|
M)
|
||||||
|
TAG_OPTS="${TAG_OPTS}M"
|
||||||
|
TAG_IMPLICIT=0
|
||||||
|
AUTOTAG=1
|
||||||
|
;;
|
||||||
|
P)
|
||||||
|
TAG_OPTS="${TAG_OPTS}p"
|
||||||
|
TAG_IMPLICIT=0
|
||||||
|
AUTOTAG=1
|
||||||
;;
|
;;
|
||||||
v)
|
v)
|
||||||
VERBOSE=1
|
VERBOSE=1
|
||||||
@@ -103,18 +132,31 @@ if [[ $UNIT_MODE -eq 1 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $PUBLISH_MODE -eq 1 ]]; then
|
if [[ $PUBLISH_MODE -eq 1 ]]; then
|
||||||
|
if [[ $AUTOTAG -eq 1 ]]; then
|
||||||
|
TAG=`./next-ver.sh -${TAG_OPTS}`
|
||||||
|
echo "Using tag $TAG"
|
||||||
|
fi
|
||||||
BUILDOPT+="bu"
|
BUILDOPT+="bu"
|
||||||
VERBOPT=""
|
VERBOPT=""
|
||||||
if [[ $VERBOSE -gt 0 ]]; then
|
if [[ $VERBOSE -gt 0 ]]; then
|
||||||
BUILDOPT+="v"
|
BUILDOPT+="v"
|
||||||
VERBOPT="-v"
|
VERBOPT="-v"
|
||||||
fi
|
fi
|
||||||
msg "running ./build.sh -$BUILDOPT -t $TAG"
|
|
||||||
./build.sh -$BUILDOPT -t $TAG
|
|
||||||
|
|
||||||
./run-unit.sh $VERBOPT -t $TAG
|
# WEBSERVER
|
||||||
|
msg "running ./build.sh -I webserver -$BUILDOPT -t $TAG-webserver"
|
||||||
|
./build.sh -I webserver -$BUILDOPT -t "$TAG-webserver"
|
||||||
|
|
||||||
./publish.sh $VERBOPT -t $TAG
|
./run-unit.sh $VERBOPT -t "$TAG-webserver"
|
||||||
|
|
||||||
|
./publish.sh $VERBOPT -t "$TAG-webserver"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if [[ $TAG_IMPLICIT -ne 1 ]]; then
|
||||||
|
git tag $TAG
|
||||||
|
git push --tags
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -141,6 +183,9 @@ if [[ $DEBUG_MODE -eq 1 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $DEPLOY_TEST_MODE -eq 1 ]]; then
|
if [[ $DEPLOY_TEST_MODE -eq 1 ]]; then
|
||||||
|
if [[ $AUTOTAG -eq 1 ]]; then
|
||||||
|
TAG=`./latest-ver.sh -${TAG_OPTS}`
|
||||||
|
fi
|
||||||
OUT_FOLDER="/home/$PROJECT_AUTHOR/$PROJECT_BUILDNAME/test"
|
OUT_FOLDER="/home/$PROJECT_AUTHOR/$PROJECT_BUILDNAME/test"
|
||||||
mkdir -p $OUT_FOLDER
|
mkdir -p $OUT_FOLDER
|
||||||
./generateComposeFolder.sh -s -o "$OUT_FOLDER" -t $TAG
|
./generateComposeFolder.sh -s -o "$OUT_FOLDER" -t $TAG
|
||||||
@@ -150,6 +195,9 @@ if [[ $DEPLOY_TEST_MODE -eq 1 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $DEPLOY_PROD_MODE -eq 1 ]]; then
|
if [[ $DEPLOY_PROD_MODE -eq 1 ]]; then
|
||||||
|
if [[ $AUTOTAG -eq 1 ]]; then
|
||||||
|
TAG=`./latest-ver.sh -${TAG_OPTS}`
|
||||||
|
fi
|
||||||
OUT_FOLDER="/home/$PROJECT_AUTHOR/$PROJECT_BUILDNAME/production"
|
OUT_FOLDER="/home/$PROJECT_AUTHOR/$PROJECT_BUILDNAME/production"
|
||||||
mkdir -p $OUT_FOLDER
|
mkdir -p $OUT_FOLDER
|
||||||
./generateComposeFolder.sh -p -o "$OUT_FOLDER" -t $TAG
|
./generateComposeFolder.sh -p -o "$OUT_FOLDER" -t $TAG
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ usage() {
|
|||||||
echo " -d: Debug" 1>&2;
|
echo " -d: Debug" 1>&2;
|
||||||
echo " -u: Unit" 1>&2;
|
echo " -u: Unit" 1>&2;
|
||||||
echo " -b: Base" 1>&2;
|
echo " -b: Base" 1>&2;
|
||||||
|
echo " -I: Image (webserver or worker)" 1>&2;
|
||||||
echo " -i: Config Input File" 1>&2;
|
echo " -i: Config Input File" 1>&2;
|
||||||
echo " -o: Output file" 1>&2;
|
echo " -o: Output file" 1>&2;
|
||||||
echo " -v: Verbose" 1>&2;
|
echo " -v: Verbose" 1>&2;
|
||||||
@@ -36,8 +37,13 @@ DEBUG_MODE=0
|
|||||||
UNIT_MODE=0
|
UNIT_MODE=0
|
||||||
BASE_MODE=0
|
BASE_MODE=0
|
||||||
|
|
||||||
while getopts "i:o:hvdub" o; do
|
TYPE="webserver"
|
||||||
|
|
||||||
|
while getopts "i:o:I:hvdub" o; do
|
||||||
case "${o}" in
|
case "${o}" in
|
||||||
|
I)
|
||||||
|
TYPE="${OPTARG}"
|
||||||
|
;;
|
||||||
d)
|
d)
|
||||||
DEBUG_MODE=1
|
DEBUG_MODE=1
|
||||||
SELECTED_MODES+=1
|
SELECTED_MODES+=1
|
||||||
@@ -88,12 +94,12 @@ if [[ $OUTFILE == "" ]]; then
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
STARTING_FILE="../cicd/dockerfiles/build.dockerfile"
|
STARTING_FILE="../cicd/dockerfiles/${TYPE}/build.dockerfile"
|
||||||
if [[ $DEBUG_MODE -eq 1 ]]; then
|
if [[ $DEBUG_MODE -eq 1 ]]; then
|
||||||
STARTING_FILE="../cicd/dockerfiles/debug.dockerfile"
|
STARTING_FILE="../cicd/dockerfiles/${TYPE}/debug.dockerfile"
|
||||||
fi
|
fi
|
||||||
if [[ $UNIT_MODE -eq 1 ]]; then
|
if [[ $UNIT_MODE -eq 1 ]]; then
|
||||||
STARTING_FILE="../cicd/dockerfiles/test.dockerfile"
|
STARTING_FILE="../cicd/dockerfiles/${TYPE}/test.dockerfile"
|
||||||
fi
|
fi
|
||||||
msg "Using source file $STARTING_FILE"
|
msg "Using source file $STARTING_FILE"
|
||||||
|
|
||||||
|
|||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
git pull --quiet
|
||||||
|
git tag -l --sort=-version:refname | head -n 1
|
||||||
Executable
+59
@@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [-h] [-m|M] [-p]" 1>&2;
|
||||||
|
echo " -h: This message" 1>&2;
|
||||||
|
echo " -p: Pre release" 1>&2;
|
||||||
|
echo " -m: Increment minor" 1>&2;
|
||||||
|
echo " -M: Increment major" 1>&2;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRE_RELEASE=0
|
||||||
|
ALTERS=0
|
||||||
|
ALTER_NAME="release"
|
||||||
|
|
||||||
|
while getopts "hpmMr" o; do
|
||||||
|
case "${o}" in
|
||||||
|
p)
|
||||||
|
PRE_RELEASE=1
|
||||||
|
;;
|
||||||
|
r)
|
||||||
|
ALTERS=$ALTERS+1
|
||||||
|
ALTER_NAME="release"
|
||||||
|
;;
|
||||||
|
m)
|
||||||
|
ALTERS=$ALTERS+1
|
||||||
|
ALTER_NAME="minor"
|
||||||
|
;;
|
||||||
|
M)
|
||||||
|
ALTERS=$ALTERS+1
|
||||||
|
ALTER_NAME="major"
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0;
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
printerr "Unsupported option ${o}"
|
||||||
|
usage
|
||||||
|
exit 1;
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $ALTERS -gt 1 ]]; then
|
||||||
|
echo "You can specify exactly one option between m and M"
|
||||||
|
usage
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
CURRENT_VERSION=`./latest-ver.sh`
|
||||||
|
|
||||||
|
INCREMENT_NAME=$ALTER_NAME
|
||||||
|
if [[ $PRE_RELEASE -gt 0 ]]; then
|
||||||
|
INCREMENT_NAME="pre$INCREMENT_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
NEW_VERSION=`semver $CURRENT_VERSION --preid rc -i $INCREMENT_NAME`
|
||||||
|
|
||||||
|
echo "$NEW_VERSION"
|
||||||
Reference in New Issue
Block a user