36 Commits
Author SHA1 Message Date
r.didato 3f04905d22 #12 Backup + fix config email 2022-10-02 19:45:09 +02:00
r.didato 0ab6391bf3 #12 2022-10-02 19:16:59 +02:00
r.didato a66dfa8530 CICD 2022-10-02 15:58:36 +02:00
r.didato 09cf83c31b Typo 2022-10-01 20:03:35 +02:00
r.didato aac8e9786d CICD minor 2022-10-01 12:47:32 +02:00
r.didato bcfea0cfad #6 - WIP 2022-10-01 12:42:57 +02:00
r.didato 8a097b5956 #6 - Prima stesura worker 2022-09-29 23:13:55 +02:00
r.didato effeae054e Incrementata dimensione banner top a 150px 2022-09-29 21:42:47 +02:00
r.didato daabdbb566 Fixata priorità banner 2022-09-28 20:27:24 +02:00
r.didato 2ed3a2bf3c #1 - Titoli H1 2022-09-28 20:00:33 +02:00
r.didato 3b12ce1786 #11 - Fix banner sorting 2022-09-28 19:48:51 +02:00
r.didato 6c3acfe5e9 Fix git tag detection 2022-09-25 21:29:34 +02:00
r.didato 93bb9b2610 #10 - Completo 2022-09-25 21:21:42 +02:00
r.didato e2fb0d6d89 #3 - Fatto, da testare 2022-09-25 18:46:44 +02:00
r.didato 617a3f50eb #5 Rimosso xsendfile fixato download pdf 2022-09-25 16:36:16 +02:00
r.didato c666b50dd8 Minor 2022-09-25 16:10:18 +02:00
r.didato 34fb57fa81 Automation 2022-09-25 16:09:04 +02:00
r.didato 7680378f28 Scripts 2022-09-25 15:46:54 +02:00
r.didato 7bab6253cf Automation 2022-09-25 15:43:49 +02:00
r.didato f7db85cc13 Scripts 2022-09-25 15:38:34 +02:00
r.didato 09396f8c98 Stats 2022-09-25 13:55:59 +02:00
r.didato 064eeec5a0 #9 Still in testing 2022-09-23 01:33:08 +02:00
r.didato 47470fef2e Fix cache image 2022-09-20 00:53:06 +02:00
r.didato 4010c65dbc Typo 2022-09-19 23:54:57 +02:00
r.didato e2b8470e54 CICD 2022-09-19 23:01:35 +02:00
r.didato 3546e51d9e CICD 2022-09-19 23:00:10 +02:00
r.didato 7744dcabc1 CICD 2022-09-19 22:54:51 +02:00
r.didato 9e6cb3780e Fix build process 2022-09-19 22:52:10 +02:00
r.didato afb1bff624 comments 2022-09-19 22:48:41 +02:00
r.didato 70a0b64c04 cfg 2022-09-19 22:47:29 +02:00
r.didato c772a20bf9 CICD 2022-09-19 22:46:03 +02:00
r.didato 05987f26e9 CICD 2022-09-19 22:44:44 +02:00
r.didato 78f68a82a3 CICD 2022-09-19 22:43:29 +02:00
r.didato 55cb0b75b9 CICD 2022-09-19 22:30:03 +02:00
r.didato 5cf34f1aea compose 2022-09-19 22:26:01 +02:00
r.didato 28c70e03bf compose 2022-09-19 22:25:29 +02:00
78 changed files with 1561 additions and 790 deletions
-6
View File
@@ -20,11 +20,5 @@
</Directory> </Directory>
<IfModule xsendfile_module>
XSendFile on
XSendFilePath "/tmp/xsend"
</IfModule>
</VirtualHost> </VirtualHost>
+3
View File
@@ -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 $?
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
function exit_func {
echo "SIGTERM detected"
exit 1
}
trap exit_func SIGTERM SIGINT
ASD_BINDIR="/home/${DDNINJA_AUTHOR}/private/${DDNINJA_BUILDNAME}/bin"
mkdir -p "/tmp/${DDNINJA_AUTHOR}/${DDNINJA_BUILDNAME}"
mkdir -p "/home/${DDNINJA_AUTHOR}/storage/${DDNINJA_BUILDNAME}/media/"
mkdir -p "/var/log/${DDNINJA_AUTHOR}/${DDNINJA_BUILDNAME}/"
php /home/${DDNINJA_AUTHOR}/private/${DDNINJA_BUILDNAME}/bin/worker.php & wait
exit $?
+1
View File
@@ -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;
+363
View File
@@ -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
);
}
}
}
?>
+83
View File
@@ -0,0 +1,83 @@
<?php
use ASD\ThresholdTimer;
require_once(dirname(__FILE__)."/../load.php");
require_once("/home/ddninja/private/asdphp/lib/core/ThresholdTimer.php");
$timer = new ThresholdTimer(60);
function logInfo(string $msg) {
echo date("Y-m-d H:i")." - ".$msg,PHP_EOL;
}
function execHour() {
return intval(date('i')) == 0;
}
function execDay() {
return execHour() && intval(date('H')) == 3;
}
function getMinuteTasks() {
return [
GenerateAdminActivationMailTask::class,
GenerateUserActivationMailTask::class,
GenerateAdminPasswordRecoveryMailTask::class,
GenerateUserPasswordRecoveryMailTask::class,
MailSendTask::class
];
}
function getHourTasks() {
return [
// NewsletterCheckTask::class,
DeleteOldPasswordResetRequestsTask::class,
UpdateMeteoCacheTask::class,
GenerateCommentiWarningMailTask::class
];
}
function getDailyTasks() {
return [
// SendBackupTask::class
];
}
function execute($taskName) {
try {
if ($taskName::isActive()){
logInfo("Executing task $taskName");
$taskName::execute();
logInfo("Task $taskName executed with success");
}
}
catch (Exception $ex) {
logInfo("Task $taskName failed execution");
var_dump($ex);
}
}
logInfo("Worker STARTED!!");
$count = 1;
while (1) {
logInfo("Executing Minute");
foreach (getMinuteTasks() as $task ) {
execute($task);
}
if (execHour()) {
logInfo("Exec hourly");
foreach (getHourTasks() as $task ) {
execute($task);
}
}
if (execDay()) {
logInfo("Exec Daily");
foreach (getDailyTasks() as $task ) {
execute($task);
}
}
$timer->waitUntilThresholdReached(true);
}
?>
+7
View File
@@ -132,4 +132,11 @@ $config->cbs2->serverPort = $cbs2->serverPort;
$config->database = $database; $config->database = $database;
$config->mailer = new stdClass();
$config->mailer->address = "email-smtp.eu-west-1.amazonaws.com";
$config->mailer->port = "587";
$config->mailer->username = "AKIASMB7IW2MQPUP5CXS";
$config->mailer->password = "BHv+82Nns1kIKg99Hx0sjKlEpR+X4+1EgX+ec64n/mBt";
$config->mailer->smtpAuth = true;
?> ?>
+48 -91
View File
@@ -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;
}
} }
?> ?>
+8 -11
View File
@@ -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] = [];
@@ -63,17 +61,16 @@ class BannerHelper {
private static function getBannerImpressions($bannerIds) { private static function getBannerImpressions($bannerIds) {
$time = strtotime("today CET");
$stats = GlobalVariables::get("dao")->query( $stats = GlobalVariables::get("dao")->query(
BannerStatsModel::class, BannerStatsModel::class,
[ [
'_id' => [ 'banner' => [
'$in' => array_map( '$in' => $bannerIds
function($banner) {
return new \MongoDB\BSON\ObjectID($banner);
},
$bannerIds
)
], ],
'y' => intval(date('Y', $time)),
'm' => intval(date('m', $time)),
'd' => intval(date('d', $time))
] ]
); );
$rval = array_reduce( $rval = array_reduce(
@@ -85,7 +82,7 @@ class BannerHelper {
[] []
); );
foreach ($stats as $stat) { foreach ($stats as $stat) {
$rval[strval($stat->id)] = intval($stat->views); $rval[strval($stat->banner)] = intval($stat->views);
} }
return $rval; return $rval;
} }
+71
View File
@@ -0,0 +1,71 @@
<?php
class SimpleConfigHelper {
private Memcached $memcached;
private GenericDao $dao;
private stdClass $config;
public function __construct() {
$this->memcached = new Memcached();
$this->memcached->addServer('memcached', 11211);
$this->dao = GlobalVariables::get("dao");
$this->reload();
}
public function hasValue(string $name) : bool {
return property_exists($this->config, $name);
}
public function getValue(string $name) {
return $this->config->$name;
}
public function setValue(string $name, $val) {
$model = $this->dao->getFirst(SimpleConfig::class);
$model->details->$name = $val;
$this->dao->save($model);
$this->reload($model);
}
private function reload($model = null) {
if (!is_null($model)) {
$this->memcached->set($this->getCacheKey(), json_encode($model->details, JSON_FORCE_OBJECT));
}
else if ( !$this->isCached() ) {
$model = $this->dao->getFirst(SimpleConfig::class);
if (is_null($model)) {
$model = new SimpleConfig();
$this->dao->save($model);
}
$this->memcached->set($this->getCacheKey(), json_encode($model->details, JSON_FORCE_OBJECT));
}
$rval = $this->memcached->get(
$this->getCacheKey()
);
$this->config = json_decode($rval, false);
}
private function getCacheKey() {
return 'glob.fdn2.simpleConfig';
}
private function isCached(): bool {
return $this->memcached->get( $this->getCacheKey() ) ? true : false;
}
private function flush() {
$this->memcached->set( $this->getCacheKey(), false );
}
}
?>
+12 -6
View File
@@ -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;
} }
+2
View File
@@ -45,6 +45,8 @@ require_once(dirname(__FILE__)."/models/stats/ArticleStatsModel.php");
require_once(dirname(__FILE__)."/models/stats/BannerStatsModel.php"); require_once(dirname(__FILE__)."/models/stats/BannerStatsModel.php");
require_once(dirname(__FILE__)."/models/stats/PageViewStatsModel.php"); require_once(dirname(__FILE__)."/models/stats/PageViewStatsModel.php");
require_once(dirname(__FILE__)."/models/SimpleConfig.php");
$dao = new GenericDao($database->dbName,$database->connectionString); $dao = new GenericDao($database->dbName,$database->connectionString);
GlobalVariables::set("dao", $dao); GlobalVariables::set("dao", $dao);
?> ?>
+6 -1
View File
@@ -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){
+22 -10
View File
@@ -42,21 +42,23 @@ class MailModel extends Model implements FDN_MailInterface{
return parent::__set($attr, $value); return parent::__set($attr, $value);
} }
public function getMailObject(){
$email = new PHPMailer();
$email->CharSet = "UTF-8";
$email->isMail();
$email->From = $this->from; public function getMailObject() {
$email = new PHPMailer();
$email->CharSet = "UTF-8";
$email->isMail();
$email->From = $this->from;
if ($this->hasProperty("fromName")){ if ($this->hasProperty("fromName")){
$email->FromName = $this->fromName; $email->FromName = $this->fromName;
} }
$email->Subject = $this->subject; $email->Subject = $this->subject;
$email->IsHTML(true); $email->IsHTML(true);
$email->Body = $this->body;
$email->Body = $this->body;
if ($this->hasProperty("altBody")){ if ($this->hasProperty("altBody")){
$email->AltBody = $this->altBody; $email->AltBody = $this->altBody;
} }
@@ -64,14 +66,24 @@ class MailModel extends Model implements FDN_MailInterface{
$email->AltBody = strip_tags($this->body); $email->AltBody = strip_tags($this->body);
} }
$email->AddAddress($this->recipient);
$email->AddAddress($this->recipient);
if ($this->hasProperty("attachment")){ if ($this->hasProperty("attachment")){
$email->AddAttachment( $this->attachment , basename($this->attachment) ); $email->AddAttachment( $this->attachment , basename($this->attachment) );
} }
return $email; $cfg = GlobalVariables::get("config");
}
$email->IsSMTP();
$email->Host = $cfg->mailer->address;
$email->Port = $cfg->mailer->port;
$email->Username = $cfg->mailer->username;
$email->Password = $cfg->mailer->password;
$email->SMTPAuth = $cfg->mailer->smtpAuth;
return $email;
}
public static function getCollectionName(){ public static function getCollectionName(){
return "mail"; return "mail";
@@ -48,6 +48,8 @@ class NotiziaModel extends HasMediaModel implements DaoSearchable{
const CATEGORY_MONDO_SPOSI = 19; const CATEGORY_MONDO_SPOSI = 19;
const CATEGORY_VARIE = 99;
public static $NOTIZIE_CATEGORY = array( public static $NOTIZIE_CATEGORY = array(
self::CATEGORY_POLITICA=>array("label"=>"Politica","mainMenu"=>true,"hidden"=>false,"pages"=>array("list"=>"politica.php"),"color"=>"#3e3e3e","isSubmenu"=>null), self::CATEGORY_POLITICA=>array("label"=>"Politica","mainMenu"=>true,"hidden"=>false,"pages"=>array("list"=>"politica.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
self::CATEGORY_CRONACA=>array("label"=>"Cronaca","mainMenu"=>true, "hidden"=>false,"pages"=>array("list"=>"cronaca.php"),"color"=>"red","isSubmenu"=>null), self::CATEGORY_CRONACA=>array("label"=>"Cronaca","mainMenu"=>true, "hidden"=>false,"pages"=>array("list"=>"cronaca.php"),"color"=>"red","isSubmenu"=>null),
@@ -69,6 +71,8 @@ class NotiziaModel extends HasMediaModel implements DaoSearchable{
self::CATEGORY_CONSIGLI_ESPERTI=>array("label"=>"I consigli degli esperti","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"consigliEsperti.php"),"color"=>"#3e3e3e","isSubmenu"=>null), self::CATEGORY_CONSIGLI_ESPERTI=>array("label"=>"I consigli degli esperti","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"consigliEsperti.php"),"color"=>"#3e3e3e","isSubmenu"=>null),
self::CATEGORY_MONDO_SPOSI=>array("label"=>"Mondo Sposi","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"mondoSposi.php"),"color"=>"#dd603a","isSubmenu"=>null), self::CATEGORY_MONDO_SPOSI=>array("label"=>"Mondo Sposi","mainMenu"=>false, "hidden"=>false,"pages"=>array("list"=>"mondoSposi.php"),"color"=>"#dd603a","isSubmenu"=>null),
self::CATEGORY_VARIE=>array("label"=>"Varie","mainMenu"=>false, "hidden"=>true,"pages"=>array("list"=>"varie.php"),"color"=>"#dd603a","isSubmenu"=>null),
); );
public function __construct($saveableObject = null){ public function __construct($saveableObject = null){
@@ -0,0 +1,26 @@
<?php
/*
Author: Riccardo Di Dato
Creation Date: 13/gen/2016
*/
class SimpleConfig extends Model {
const VARIE_LABEL = "varie_home_label";
public function __construct($saveableObject = null) {
parent::__construct($saveableObject);
if (!$this->hasProperty("data") || !is_object($this->details)) {
$this->details = new stdClass();
}
}
public static function getCollectionName(){
return "simpleConfig";
}
}
?>
+8 -4
View File
@@ -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>
+3 -6
View File
@@ -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="#">
+58 -20
View File
@@ -6,22 +6,58 @@
*/ */
class ImageCacheManager { class ImageCacheManager {
private static $memcached = null;
const EXPIRATION_SECONDS = 2592000; // 30 * 24 * 60 * 60 -> 30 gg
private static function getMemcached() {
if (is_null(self::$memcached)) {
self::$memcached = new Memcached();
self::$memcached->addServer('memcached', 11211);
}
return self::$memcached;
}
private static function getImageKey(MediaModel $media, $size) {
return self::getImageKeyById($media->id, $size);
}
private static function getImageKeyById(string $id, $size) {
return $id."-".$size."-image";
}
private static function getMimeKey(MediaModel $media, $size) {
return self::getMimeKeyById($media->id, $size);
}
private static function getMimeKeyById(string $id, $size) {
return $id."-".$size."-mime";
}
public static function cacheImage(MediaModel $media, $size){ public static function cacheImage(MediaModel $media, $size){
self::checkValidModel($media); self::checkValidModel($media);
$cachedPath = self::getImageCachePath($media->id, $size); // $cachedPath = self::getImageCachePath($media->id, $size);
$mimePath = self::getImageMimePath($media->id, $size); // $mimePath = self::getImageMimePath($media->id, $size);
$originalFilePath = self::getOriginalPath($media); $originalFilePath = self::getOriginalPath($media);
if ( SFSManager::fileExists($cachedPath) ){ // if ( SFSManager::fileExists($cachedPath) ){
SFSManager::deleteFile($cachedPath); // SFSManager::deleteFile($cachedPath);
SFSManager::deleteFile($mimePath); // SFSManager::deleteFile($mimePath);
} // }
if (!is_dir(pathinfo($cachedPath,PATHINFO_DIRNAME))){ // if (!is_dir(pathinfo($cachedPath,PATHINFO_DIRNAME))){
SFSManager::createDirectory(pathinfo($cachedPath,PATHINFO_DIRNAME)); // SFSManager::createDirectory(pathinfo($cachedPath,PATHINFO_DIRNAME));
} // }
SFSManager::writeFile(mime_content_type($originalFilePath), $mimePath); // SFSManager::writeFile(mime_content_type($originalFilePath), $mimePath);
SFSManager::writeFile(self::getImageContent($media, $size), $cachedPath); // SFSManager::writeFile(self::getImageContent($media, $size), $cachedPath);
self::getMemcached()->set(
self::getMimeKey($media, $size),
mime_content_type($originalFilePath),
self::EXPIRATION_SECONDS
);
self::getMemcached()->set(
self::getImageKey($media, $size),
self::getImageContent($media, $size),
self::EXPIRATION_SECONDS
);
} }
/** /**
@@ -30,8 +66,9 @@ class ImageCacheManager {
* @param int $size * @param int $size
*/ */
public static function isCached($id, $size){ public static function isCached($id, $size){
$cachedPath = self::getImageCachePath($id, $size); return self::getMemcached()->get(self::getImageKeyById($id, $size)) ? true : false;
return SFSManager::fileExists($cachedPath); // $cachedPath = self::getImageCachePath($id, $size);
// return SFSManager::fileExists($cachedPath);
} }
@@ -43,8 +80,9 @@ class ImageCacheManager {
* @return string * @return string
*/ */
public static function getMimeType($id, $size){ public static function getMimeType($id, $size){
$mimePath = self::getImageMimePath($id, $size); return self::getMemcached()->get(self::getMimeKeyById($id, $size));
return file_get_contents($mimePath); // $mimePath = self::getImageMimePath($id, $size);
// return file_get_contents($mimePath);
} }
/** /**
@@ -54,14 +92,14 @@ class ImageCacheManager {
* @return string * @return string
*/ */
public static function getContent($id, $size){ public static function getContent($id, $size){
$cachedPath = self::getImageCachePath($id, $size); return self::getMemcached()->get(self::getImageKeyById($id, $size));
return file_get_contents($cachedPath); // $cachedPath = self::getImageCachePath($id, $size);
// return file_get_contents($cachedPath);
} }
public static function printCachedMedia($id, $size){ public static function printCachedMedia($id, $size) {
$cachedPath = self::getImageCachePath($id, $size);
header('Content-type: '.self::getMimeType($id, $size)); header('Content-type: '.self::getMimeType($id, $size));
return readfile($cachedPath); echo self::getContent($id, $size);
} }
+5 -3
View File
@@ -28,9 +28,9 @@ class MenuGenerator {
array("label"=>"Utenti registrati","page"=>"listUsers.php","requires"=>AdminModel::ADMIN_TYPE_NORMALADMIN), array("label"=>"Utenti registrati","page"=>"listUsers.php","requires"=>AdminModel::ADMIN_TYPE_NORMALADMIN),
array("label"=>"Newsletter", "subvoices"=>array( array("label"=>"Newsletter", "subvoices"=>array(
array("label"=>"Nuova","page"=>"editNewsletter.php","requires"=>AdminModel::ADMIN_TYPE_NEWSLETTER), // array("label"=>"Nuova","page"=>"editNewsletter.php","requires"=>AdminModel::ADMIN_TYPE_NEWSLETTER),
array("label"=>"Da inviare","page"=>"pendingNewsletters.php","requires"=>AdminModel::ADMIN_TYPE_NEWSLETTER), // array("label"=>"Da inviare","page"=>"pendingNewsletters.php","requires"=>AdminModel::ADMIN_TYPE_NEWSLETTER),
array("label"=>"Inviate","page"=>"sentNewsletters.php","requires"=>AdminModel::ADMIN_TYPE_NEWSLETTER), // array("label"=>"Inviate","page"=>"sentNewsletters.php","requires"=>AdminModel::ADMIN_TYPE_NEWSLETTER),
array("label"=>"Nuova Mail","page"=>"editMail.php","requires"=>AdminModel::ADMIN_TYPE_SUPERADMIN), array("label"=>"Nuova Mail","page"=>"editMail.php","requires"=>AdminModel::ADMIN_TYPE_SUPERADMIN),
array("label"=>"Coda Mail","page"=>"listMail.php","requires"=>AdminModel::ADMIN_TYPE_SUPERADMIN) array("label"=>"Coda Mail","page"=>"listMail.php","requires"=>AdminModel::ADMIN_TYPE_SUPERADMIN)
)), )),
@@ -48,6 +48,8 @@ class MenuGenerator {
array("label"=>"Logs","page"=>"logs.php","requires"=>AdminModel::ADMIN_TYPE_SUPERADMIN) array("label"=>"Logs","page"=>"logs.php","requires"=>AdminModel::ADMIN_TYPE_SUPERADMIN)
)), )),
array("label"=>"Config","page"=>"simpleConfig.php"),
array("label"=>"Guida","page"=>"index.php"), array("label"=>"Guida","page"=>"index.php"),
array("label"=>"Logout","page"=>"logout.php") array("label"=>"Logout","page"=>"logout.php")
+3
View File
@@ -48,5 +48,8 @@ require_once(dirname(__FILE__)."/BannerHelper.php");
require_once(dirname(__FILE__)."/RSSHelper.php"); require_once(dirname(__FILE__)."/RSSHelper.php");
require_once(dirname(__FILE__)."/SimpleConfigHelper.php");
GlobalVariables::set("cfg", new SimpleConfigHelper());
?> ?>
+11 -3
View File
@@ -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>
+2
View File
@@ -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>1000x150px</b></li>
<li>Banner Fine pagina:<b>1000x200px</b></li>
</ul> </ul>
Tale restizione &egrave; consigliata anche per i banner di tipo <i>HTML5</i>. Tale restizione &egrave; consigliata anche per i banner di tipo <i>HTML5</i>.
</p> </p>
+3 -74
View File
@@ -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>
+69
View File
@@ -0,0 +1,69 @@
<?php
/*
Author: Riccardo Di Dato
Creation Date: 25/gen/2016
*/
require_once(dirname(__FILE__)."/../load.php");
GUIHandler::generateHtmlHeaders(array(),true);
if (!AdminLoginManager::isLogged()){
GUIHandler::redirect("admin/login.php");
}
else if (!AdminLoginManager::getLogged()->hasRole(AdminModel::ADMIN_TYPE_NORMALADMIN)){
GUIHandler::redirect("admin/index.php");
}
MenuGenerator::generateMenu();
HTMLHelper::generateAdminHead();
$saved = false;
$action = PostHandler::get("action");
if (!is_null($action) && strcmp("", $action)!=0){
if (strcmp("save", $action)==0){
if (PostHandler::get(SimpleConfig::VARIE_LABEL)) {
GlobalVariables::get("cfg")->setValue(SimpleConfig::VARIE_LABEL, PostHandler::get(SimpleConfig::VARIE_LABEL));
}
$saved = true;
}
}
?>
<div>
<?php
if ($saved){
echo '<div style="color:green;">Dati salvati con successo</div>';
}
?>
<form id="taskForm" method="POST" action="">
<input type="hidden" name="action" value="" />
<div><span class="label">&nbsp;</span><b>Tasks</b></div>
<?php
printf(
'<div><span class="label">Varie (home)</span><input type="text" name="%s" value="%s" /><br/>',
SimpleConfig::VARIE_LABEL,
GlobalVariables::get("cfg")->hasValue(SimpleConfig::VARIE_LABEL) ? GlobalVariables::get("cfg")->getValue(SimpleConfig::VARIE_LABEL) : ""
)
?>
</form>
<div class="formBtns">
<a href="#" id="taskForm_salva" >Salva</a>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(event){
$("#taskForm_salva").click(function(event){
$("form#taskForm input[type=hidden][name=action]").val("save");
$("form#taskForm").submit();
});
$("#taskForm_annulla").click(function(event){
$("form#taskForm input[type=hidden][name=action]").val("cancel");
$("form#taskForm").submit();
});
});
</script>
+9 -2
View File
@@ -134,13 +134,20 @@ GUIHandler::generateHtmlHeaders(array("additionalMetadata"=>$additionalHeaders,"
<div style="width:1000px;margin-left:auto;margin-right:auto;" itemscope itemtype="http://schema.org/Article"> <div style="width:1000px;margin-left:auto;margin-right:auto;" itemscope itemtype="http://schema.org/Article">
<?php <?php
$categoryName = NotiziaModel::$NOTIZIE_CATEGORY[$articolo->category]["label"];
if ($articolo->category == NotiziaModel::CATEGORY_VARIE) {
if ( GlobalVariables::get("cfg")->hasValue(SimpleConfig::VARIE_LABEL) ) {
$categoryName = GlobalVariables::get("cfg")->getValue(SimpleConfig::VARIE_LABEL);
}
}
GUIHandler::generateHeadPublic(); GUIHandler::generateHeadPublic();
GUIHandler::generateMenu(); GUIHandler::generateMenu();
?> ?>
<div class="articoloCategory"> <div class="articoloCategory">
<div class="categoryStyle"> <div class="categoryStyle">
<div class="icon"><img alt="" src="images/categoryIcon.png"></div> <div class="icon"><img alt="" src="images/categoryIcon.png"></div>
<div class="articoloCategoryName" style="background-color:<?php echo NotiziaModel::$NOTIZIE_CATEGORY[$articolo->category]["color"] ?>"><span itemprop="articleSection"><?php echo strtoupper(NotiziaModel::$NOTIZIE_CATEGORY[$articolo->category]["label"]);?></span></div> <div class="articoloCategoryName" style="background-color:<?php echo NotiziaModel::$NOTIZIE_CATEGORY[$articolo->category]["color"] ?>"><span itemprop="articleSection"><?php echo strtoupper($categoryName);?></span></div>
</div> </div>
</div> </div>
<div class="articoloContainer" > <div class="articoloContainer" >
@@ -165,7 +172,7 @@ GUIHandler::generateHtmlHeaders(array("additionalMetadata"=>$additionalHeaders,"
?> ?>
</div> </div>
<div class="articoloTitle"> <div class="articoloTitle">
<div class="title" itemprop="name"><?php echo htmlentities($articolo->titolo);?></div> <h1 class="title" itemprop="name"><?php echo htmlentities($articolo->titolo);?></h1>
<div class="subTitle"> <div class="subTitle">
<span><?php echo $data;?> &mdash;</span> <span><?php echo $data;?> &mdash;</span>
<span itemprop="headline"><?php echo $articolo->sottotitolo;?></span> <span itemprop="headline"><?php echo $articolo->sottotitolo;?></span>
+2 -2
View File
@@ -17,7 +17,7 @@ if (array_key_exists("id",$_GET)) {
$size=intval($_GET['size']); $size=intval($_GET['size']);
} }
if ($size == 3){ if ($size !== MediaImage::SIZE_ORIGINAL){
if (!ImageCacheManager::isCached($_GET["id"], $size)){ if (!ImageCacheManager::isCached($_GET["id"], $size)){
$img = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$_GET['id'])); $img = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$_GET['id']));
if (!is_null($img)){ if (!is_null($img)){
@@ -32,8 +32,8 @@ if (array_key_exists("id",$_GET)) {
else { else {
$img = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$_GET['id'])); $img = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$_GET['id']));
$basepath = GlobalVariables::get("config")->paths->media;
if (!is_null($img) && file_exists($basepath."/".$img->id.".".$img->extension)){ if (!is_null($img) && file_exists($basepath."/".$img->id.".".$img->extension)){
$basepath = GlobalVariables::get("config")->paths->media;
$toMime = $basepath."/".$img->id.".".$img->extension; $toMime = $basepath."/".$img->id.".".$img->extension;
$thumb = new Imagick($basepath."/".$img->id.".".$img->extension); $thumb = new Imagick($basepath."/".$img->id.".".$img->extension);
+3 -9
View File
@@ -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);
} }
} }
+48 -37
View File
@@ -154,15 +154,27 @@ try {
// } // }
$animalNews = GlobalVariables::get("dao")->getFirst("NotiziaModel", $varie = GlobalVariables::get("dao")->query(
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_MONDO_SPOSI,'_id'=>array('$nin'=>$ansaIds), NotiziaModel::class,
"about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))), [
array("sort"=>array("about.lastEdit"=>-1)) "status"=>NotiziaModel::STATUS_ACCEPTED,
); "category"=>NotiziaModel::CATEGORY_VARIE,
if (!is_null($animalNews)){ '_id'=> [ '$nin'=>$ansaIds ],
$animalNews->testo = strip_tags($animalNews->testo); "about.lastEdit" => [ '$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ) ]
$animalNews->sottotitolo = strip_tags($animalNews->sottotitolo); ]
} );
$varie = array_map(
function ($model) {
$model->testo = strip_tags($model->testo);
$model->sottotitolo = strip_tags($model->sottotitolo);
return $model;
},
$varie
);
$varieName = "Varie";
if ( GlobalVariables::get("cfg")->hasValue(SimpleConfig::VARIE_LABEL) ) {
$varieName = GlobalVariables::get("cfg")->getValue(SimpleConfig::VARIE_LABEL);
}
$saluteNews = GlobalVariables::get("dao")->query("NotiziaModel", $saluteNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_SALUTE,'_id'=>array('$nin'=>$ansaIds), array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_SALUTE,'_id'=>array('$nin'=>$ansaIds),
@@ -209,7 +221,7 @@ catch (Exception $ex){
if(!is_null($media)){ if(!is_null($media)){
?> ?>
<div class="ansaImage mediaContent"> <div class="ansaImage mediaContent">
<?php $media->renderMedia();?> <?php $media->renderMedia(['size' => MediaImage::SIZE_BIG]);?>
</div> </div>
<?php <?php
} }
@@ -246,7 +258,7 @@ catch (Exception $ex){
<div id="politica_<?php echo $i;?>" class="newsSummary"><?php <div id="politica_<?php echo $i;?>" class="newsSummary"><?php
$media = DaoMediaHandler::getMainMediaFromModel($politica); $media = DaoMediaHandler::getMainMediaFromModel($politica);
if(!is_null($media)){?> if(!is_null($media)){?>
<div class="newsMainMedia mediaContent"><?php $media->renderMedia();?></div> <div class="newsMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_BIG]);?></div>
<?php }?> <?php }?>
<div class="newsTitle"><?php echo $stringTitolo;?></div> <div class="newsTitle"><?php echo $stringTitolo;?></div>
<div class="newsSubTitle"><?php echo $string;?></div> <div class="newsSubTitle"><?php echo $string;?></div>
@@ -276,7 +288,7 @@ catch (Exception $ex){
<div id="cronaca_<?php echo $i;?>" class="newsSummary"><?php <div id="cronaca_<?php echo $i;?>" class="newsSummary"><?php
$media = DaoMediaHandler::getMainMediaFromModel($cronaca); $media = DaoMediaHandler::getMainMediaFromModel($cronaca);
if(!is_null($media)){?> if(!is_null($media)){?>
<div class="newsMainMedia mediaContent"><?php $media->renderMedia();?></div> <div class="newsMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_BIG]);?></div>
<?php }?> <?php }?>
<div class="newsTitle"><?php echo $stringTitolo;?></div> <div class="newsTitle"><?php echo $stringTitolo;?></div>
<div class="newsSubTitle"><?php echo $string;?></div> <div class="newsSubTitle"><?php echo $string;?></div>
@@ -305,7 +317,7 @@ catch (Exception $ex){
<div id="sport_<?php echo $i;?>" class="sportSummary"><?php <div id="sport_<?php echo $i;?>" class="sportSummary"><?php
$media = DaoMediaHandler::getMainMediaFromModel($sport); $media = DaoMediaHandler::getMainMediaFromModel($sport);
if(!is_null($media)){?> if(!is_null($media)){?>
<div class="newsMainMedia mediaContent"><?php $media->renderMedia();?></div> <div class="newsMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_BIG]);?></div>
<?php }?> <?php }?>
<div class="newsTitle"><?php echo $stringTitolo;?></div> <div class="newsTitle"><?php echo $stringTitolo;?></div>
<div class="newsSubTitle"><?php echo $string;?></div> <div class="newsSubTitle"><?php echo $string;?></div>
@@ -334,7 +346,7 @@ catch (Exception $ex){
<a href="<?php echo $cultura->getAbsoluteUrl();?>" id="cultura_<?php echo $i;?>" class="culturaNews"><?php <a href="<?php echo $cultura->getAbsoluteUrl();?>" id="cultura_<?php echo $i;?>" class="culturaNews"><?php
$media = DaoMediaHandler::getMainMediaFromModel($cultura); $media = DaoMediaHandler::getMainMediaFromModel($cultura);
if(!is_null($media)){?> if(!is_null($media)){?>
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div> <div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
<?php }?> <?php }?>
<div class="culturaTitle"><?php echo $string;?></div> <div class="culturaTitle"><?php echo $string;?></div>
</a> </a>
@@ -358,7 +370,7 @@ catch (Exception $ex){
<a href="<?php echo $ristoranti->getAbsoluteUrl();?>" id="ristoranti_<?php echo $i;?>" class="ristorantiBlock"><?php <a href="<?php echo $ristoranti->getAbsoluteUrl();?>" id="ristoranti_<?php echo $i;?>" class="ristorantiBlock"><?php
$media = DaoMediaHandler::getMainMediaFromModel($ristoranti); $media = DaoMediaHandler::getMainMediaFromModel($ristoranti);
if(!is_null($media)){?> if(!is_null($media)){?>
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div> <div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
<?php }?> <?php }?>
<div class="ristorantiTitle"><?php echo $string;?></div> <div class="ristorantiTitle"><?php echo $string;?></div>
</a> </a>
@@ -381,7 +393,7 @@ catch (Exception $ex){
<a href="<?php echo $salute->getAbsoluteUrl();?>" id="salute_<?php echo $i;?>" class="saluteContainer"> <a href="<?php echo $salute->getAbsoluteUrl();?>" id="salute_<?php echo $i;?>" class="saluteContainer">
<?php $media = DaoMediaHandler::getMainMediaFromModel($salute); <?php $media = DaoMediaHandler::getMainMediaFromModel($salute);
if(!is_null($media)){?> if(!is_null($media)){?>
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div> <div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
<?php }?> <?php }?>
<div class="saluteTitle"><?php echo $stringTitle;?></div> <div class="saluteTitle"><?php echo $stringTitle;?></div>
</a> </a>
@@ -430,7 +442,7 @@ catch (Exception $ex){
<a href="<?php echo $gossip->getAbsoluteUrl();?>" id="gossip_<?php echo $i;?>"class="gossipContainer"> <a href="<?php echo $gossip->getAbsoluteUrl();?>" id="gossip_<?php echo $i;?>"class="gossipContainer">
<?php $media = DaoMediaHandler::getMainMediaFromModel($gossip); <?php $media = DaoMediaHandler::getMainMediaFromModel($gossip);
if(!is_null($media)){?> if(!is_null($media)){?>
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div> <div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
<?php }?> <?php }?>
<div class="gossipTitle"><?php echo $stringTitle;?></div> <div class="gossipTitle"><?php echo $stringTitle;?></div>
</a> </a>
@@ -455,7 +467,7 @@ catch (Exception $ex){
<a href="<?php echo $professioni->getAbsoluteUrl();?>" id="gossip_<?php echo $i;?>"class="gossipContainer"> <a href="<?php echo $professioni->getAbsoluteUrl();?>" id="gossip_<?php echo $i;?>"class="gossipContainer">
<?php $media = DaoMediaHandler::getMainMediaFromModel($professioni); <?php $media = DaoMediaHandler::getMainMediaFromModel($professioni);
if(!is_null($media)){?> if(!is_null($media)){?>
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div> <div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
<?php }?> <?php }?>
<div class="gossipTitle"><?php echo $stringTitle;?></div> <div class="gossipTitle"><?php echo $stringTitle;?></div>
</a> </a>
@@ -467,7 +479,7 @@ catch (Exception $ex){
<?php <?php
if(sizeof($elezioni)>0){ if(sizeof($elezioni)>0){
?> ?>
<div class="lastViaggi"> <div class="rightCategory">
<div class="categoryBar" style="text-align:left;"> <div class="categoryBar" style="text-align:left;">
<div class="categoryTag"><span>SPECIALE ELEZIONI</span></div> <div class="categoryTag"><span>SPECIALE ELEZIONI</span></div>
<div class="categoryLine"></div> <div class="categoryLine"></div>
@@ -479,7 +491,7 @@ catch (Exception $ex){
<a href="<?php echo $elezioni->getAbsoluteUrl();?>" class="animaliContainer"> <a href="<?php echo $elezioni->getAbsoluteUrl();?>" class="animaliContainer">
<?php $media = DaoMediaHandler::getMainMediaFromModel($elezioni); <?php $media = DaoMediaHandler::getMainMediaFromModel($elezioni);
if(!is_null($media)){?> if(!is_null($media)){?>
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div> <div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
<?php }?> <?php }?>
<div class="viaggiTitle"><?php echo $stringTitle;?></div> <div class="viaggiTitle"><?php echo $stringTitle;?></div>
</a> </a>
@@ -489,7 +501,7 @@ catch (Exception $ex){
} }
else{ else{
?> ?>
<div class="lastViaggi"> <div class="rightCategory">
<div class="categoryBar" style="text-align:left;"> <div class="categoryBar" style="text-align:left;">
<div class="categoryTag"><span>VIAGGI</span></div> <div class="categoryTag"><span>VIAGGI</span></div>
<div class="categoryLine"></div> <div class="categoryLine"></div>
@@ -503,7 +515,7 @@ catch (Exception $ex){
<a href="<?php echo $viaggi->getAbsoluteUrl();?>" id="viaggi_<?php echo $i;?>"class="animaliContainer"> <a href="<?php echo $viaggi->getAbsoluteUrl();?>" id="viaggi_<?php echo $i;?>"class="animaliContainer">
<?php $media = DaoMediaHandler::getMainMediaFromModel($viaggi); <?php $media = DaoMediaHandler::getMainMediaFromModel($viaggi);
if(!is_null($media)){?> if(!is_null($media)){?>
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div> <div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
<?php }?> <?php }?>
<div class="viaggiTitle"><?php echo $stringTitle;?></div> <div class="viaggiTitle"><?php echo $stringTitle;?></div>
</a> </a>
@@ -513,23 +525,22 @@ catch (Exception $ex){
<?php <?php
} }
?> ?>
<div class="animali"> <div class="rightCategory">
<div class="categoryBar" style="text-align:left;"> <div class="categoryBar" style="text-align:left;" >
<div class="categoryTag"><span>MONDO SPOSI</span></div> <div class="categoryTag"><span><?php echo strtoupper($varieName); ?></span></div>
<div class="categoryLine"></div> <div class="categoryLine"></div>
</div> </div>
<?php if(!is_null($animalNews)){ <?php
// $stringTitle = (strlen($animalNews->titolo) > 53) ? htmlentities( substr( html_entity_decode( $animalNews->titolo ) ,0,50) ) .'...' : $animalNews->titolo; foreach ($varie as $model) {
$stringTitle = $animalNews->cutTextHtmlSafe("titolo",50); $media = DaoMediaHandler::hasMainMedia($model) ? DaoMediaHandler::getMainMediaFromModel($model) : null;
?> printf(
<a href="<?php echo $animalNews->getAbsoluteUrl();?>" class="animaliContainer"> '<a href="%s" class=""><div class="mediaContent">%s</div><div class="rightColumnTitle" >%s</div></a>',
<?php $media = DaoMediaHandler::getMainMediaFromModel($animalNews); $model->getAbsoluteUrl(),
if(!is_null($media)){?> is_null($media) ? "" : $media->asText(['size' => MediaImage::SIZE_MEDIUM]),
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div> $model->cutTextHtmlSafe("titolo",50)
<?php }?> );
<div class="animaliTitle"><?php echo $stringTitle;?></div> }
</a> ?>
<?php }?>
</div> </div>
<div class="middleRightLongBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_LONG);?></div> <div class="middleRightLongBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_LONG);?></div>
</div> </div>
+1 -1
View File
@@ -66,5 +66,5 @@ function resortGroup(group) {
} }
function compareEle(a, b) { function compareEle(a, b) {
return a.views >= b.views; return a.views - b.views;
} }
+3 -2
View File
@@ -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){
?> ?>
+12 -4
View File
@@ -128,6 +128,13 @@ GUIHandlerMobile::generateHtmlHeaders(array("additionalMetadata"=>$additionalHea
<div style="margin-top:32vw;width:100vw;margin-left:auto;margin-right:auto;" itemscope itemtype="http://schema.org/Article"> <div style="margin-top:32vw;width:100vw;margin-left:auto;margin-right:auto;" itemscope itemtype="http://schema.org/Article">
<?php <?php
$categoryName = NotiziaModel::$NOTIZIE_CATEGORY[$articolo->category]["label"];
if ($articolo->category == NotiziaModel::CATEGORY_VARIE) {
if ( GlobalVariables::get("cfg")->hasValue(SimpleConfig::VARIE_LABEL) ) {
$categoryName = GlobalVariables::get("cfg")->getValue(SimpleConfig::VARIE_LABEL);
}
}
GUIHandlerMobile::generateHeadPublic(); GUIHandlerMobile::generateHeadPublic();
GUIHandlerMobile::generateMenu(); GUIHandlerMobile::generateMenu();
?> ?>
@@ -136,11 +143,12 @@ 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($categoryName);?></span>
</div> </div>
<div class="headArticolo"> <div class="headArticolo">
<div class="newsImage" > <div class="newsImage" >
@@ -190,7 +198,7 @@ GUIHandlerMobile::generateHtmlHeaders(array("additionalMetadata"=>$additionalHea
?> ?>
</div> </div>
<div class="articoloTitle"> <div class="articoloTitle">
<p class="title" itemprop="name"><?php echo htmlentities($articolo->titolo);?></p> <h1 class="title" itemprop="name"><?php echo htmlentities($articolo->titolo);?></h1>
<p class="subTitle"> <p class="subTitle">
<span><?php echo $data;?> &mdash;</span> <span><?php echo $data;?> &mdash;</span>
<span itemprop="headline"><?php echo $articolo->sottotitolo;?></span> <span itemprop="headline"><?php echo $articolo->sottotitolo;?></span>
+4 -3
View File
@@ -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){
+67 -80
View File
@@ -6,9 +6,13 @@ Creation Date: 22/dic/2015
require_once(dirname(__FILE__)."/../load.php"); require_once(dirname(__FILE__)."/../load.php");
try { function stripModelText($model) {
// AnalyticsHelper::logPageImpression(); $model->testo = strip_tags($model->testo);
$model->sottotitolo = strip_tags($model->sottotitolo);
return $model;
}
try {
$config = GlobalVariables::get("config"); $config = GlobalVariables::get("config");
$directLink = $config->pages->remoteLocationPath."index.php"; $directLink = $config->pages->remoteLocationPath."index.php";
@@ -17,122 +21,107 @@ try {
GUIHandlerMobile::generateHtmlHeaders(array("additionalMetadata"=>$additionalHeaders)); GUIHandlerMobile::generateHtmlHeaders(array("additionalMetadata"=>$additionalHeaders));
// echo "OK";
// var_dump(date("n"));
$mesi = array(1=>'Gennaio', 'Febbraio', 'Marzo', 'Aprile', $mesi = array(1=>'Gennaio', 'Febbraio', 'Marzo', 'Aprile',
'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Maggio', 'Giugno', 'Luglio', 'Agosto',
'Settembre', 'Ottobre', 'Novembre','Dicembre'); 'Settembre', 'Ottobre', 'Novembre','Dicembre');
// $day = date("d");
$pageSelected="home"; $pageSelected="home";
// $ansaNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("isAnsa"=>true,"status"=>NotiziaModel::STATUS_ACCEPTED,"about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4));
$ansaNews = GlobalVariables::get("dao")->query("NotiziaModel", $ansaNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("isAnsa"=>true,"status"=>NotiziaModel::STATUS_ACCEPTED,"about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))), array("isAnsa"=>true,"status"=>NotiziaModel::STATUS_ACCEPTED,"about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.lastEdit"=>-1),"limit"=>8)); array("sort"=>array("about.lastEdit"=>-1),"limit"=>8));
$ansaIds = array();
if (sizeof($ansaNews)>0){
$ansaIds = array_map(function($ele){return new MongoDB\BSON\ObjectID($ele->id);}, $ansaNews);
$ansaNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $ansaNews);
}
$ansaIds = array_map(
function($ele){
return new MongoDB\BSON\ObjectID($ele->id);
},
$ansaNews
);
$ansaNews = array_map(
'stripModelText',
$ansaNews
);
// $politicaNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_POLITICA,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4)
// );
$politicaNews = GlobalVariables::get("dao")->query("NotiziaModel", $politicaNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_POLITICA,'_id'=>array('$nin'=>$ansaIds), array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_POLITICA,'_id'=>array('$nin'=>$ansaIds),
"about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))), "about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.lastEdit"=>-1),"limit"=>4) array("sort"=>array("about.lastEdit"=>-1),"limit"=>4)
); );
if (sizeof($politicaNews)>0){ $politicaNews = array_map(
$politicaNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $politicaNews); 'stripModelText',
} $politicaNews
);
// $cronacaNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_CRONACA,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4)
// );
$cronacaNews = GlobalVariables::get("dao")->query("NotiziaModel", $cronacaNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_CRONACA,'_id'=>array('$nin'=>$ansaIds), array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_CRONACA,'_id'=>array('$nin'=>$ansaIds),
"about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))), "about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.lastEdit"=>-1),"limit"=>6) array("sort"=>array("about.lastEdit"=>-1),"limit"=>6)
); );
if (sizeof($cronacaNews)>0){ $cronacaNews = array_map(
$cronacaNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $cronacaNews); 'stripModelText',
} $cronacaNews
);
// $sportNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_SPORT,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4)
// );
$sportNews = GlobalVariables::get("dao")->query("NotiziaModel", $sportNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_SPORT,'_id'=>array('$nin'=>$ansaIds), array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_SPORT,'_id'=>array('$nin'=>$ansaIds),
"about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))), "about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.lastEdit"=>-1),"limit"=>4) array("sort"=>array("about.lastEdit"=>-1),"limit"=>4)
); );
if (sizeof($sportNews)>0){ $sportNews = array_map(
$sportNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $sportNews); 'stripModelText',
} $sportNews
);
// $culturaNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_CULTURA,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4)
// );
$culturaNews = GlobalVariables::get("dao")->query("NotiziaModel", $culturaNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_CULTURA,'_id'=>array('$nin'=>$ansaIds), array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_CULTURA,'_id'=>array('$nin'=>$ansaIds),
"about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))), "about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.lastEdit"=>-1),"limit"=>4) array("sort"=>array("about.lastEdit"=>-1),"limit"=>4)
); );
if (sizeof($culturaNews)>0){ $culturaNews = array_map(
$culturaNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $culturaNews); 'stripModelText',
} $culturaNews
);
// $foodNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_RISTORANTI,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4)
// );
$foodNews = GlobalVariables::get("dao")->query("NotiziaModel", $foodNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_RISTORANTI,'_id'=>array('$nin'=>$ansaIds), array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_RISTORANTI,'_id'=>array('$nin'=>$ansaIds),
"about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))), "about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.lastEdit"=>-1),"limit"=>4) array("sort"=>array("about.lastEdit"=>-1),"limit"=>4)
); );
if (sizeof($foodNews)>0){ $foodNews = array_map(
$foodNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $foodNews); 'stripModelText',
} $foodNews
);
// $professioniNews = GlobalVariables::get("dao")->query("NotiziaModel",
// array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_MESTIERI,'_id'=>array('$nin'=>$ansaIds),
// "about.data"=>array('$lte'=>new MongoDate())),
// array("sort"=>array("about.data"=>-1),"limit"=>4)
// );
$professioniNews = GlobalVariables::get("dao")->query("NotiziaModel", $professioniNews = GlobalVariables::get("dao")->query("NotiziaModel",
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_MESTIERI,'_id'=>array('$nin'=>$ansaIds), array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_MESTIERI,'_id'=>array('$nin'=>$ansaIds),
"about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))), "about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))),
array("sort"=>array("about.lastEdit"=>-1),"limit"=>4) array("sort"=>array("about.lastEdit"=>-1),"limit"=>4)
); );
if (sizeof($professioniNews)>0){ $professioniNews = array_map(
$professioniNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $professioniNews); 'stripModelText',
} $professioniNews
);
$mondoSposiNews = GlobalVariables::get("dao")->query("NotiziaModel", $varie = GlobalVariables::get("dao")->query(
array("status"=>NotiziaModel::STATUS_ACCEPTED,"category"=>NotiziaModel::CATEGORY_MONDO_SPOSI,'_id'=>array('$nin'=>$ansaIds), NotiziaModel::class,
"about.lastEdit"=>array('$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ))), [
array("sort"=>array("about.lastEdit"=>-1),"limit"=>4) "status"=>NotiziaModel::STATUS_ACCEPTED,
); "category"=>NotiziaModel::CATEGORY_VARIE,
if (sizeof($mondoSposiNews)>0){ '_id'=> [ '$nin'=>$ansaIds ],
$mondoSposiNews = array_map(function($ele){$ele->testo = strip_tags($ele->testo);$ele->sottotitolo = strip_tags($ele->sottotitolo); return $ele; }, $mondoSposiNews); "about.lastEdit" => [ '$lte'=>new MongoDB\BSON\UTCDateTime( time() * 1000 ) ]
} ]
);
$varie = array_map(
'stripModelText',
$varie
);
$varieName = "Varie";
if ( GlobalVariables::get("cfg")->hasValue(SimpleConfig::VARIE_LABEL) ) {
$varieName = GlobalVariables::get("cfg")->getValue(SimpleConfig::VARIE_LABEL);
}
} }
catch (Exception $ex){ catch (Exception $ex){
echo $ex->getMessage(); echo $ex->getMessage();
@@ -144,15 +133,15 @@ 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){
$i++; $i++;
$stringTitolo = (strlen($ansa->titolo) > 103) ? htmlentities ( substr( html_entity_decode( $ansa->titolo ),0,100) ) .'...' : $ansa->titolo; $stringTitolo = (strlen($ansa->titolo) > 103) ? htmlentities ( substr( html_entity_decode( $ansa->titolo ),0,100) ) .'...' : $ansa->titolo;
// $stringSottotitolo = (strlen($ansa->sottotitolo) > 73) ? substr($ansa->sottotitolo,0,70).'...' : $ansa->sottotitolo; ?>
// $stringTesto = (strlen($ansa->testo) > 33) ? substr($ansa->testo,0,30).'...' : $ansa->testo;?>
<div class="primaryNews"> <div class="primaryNews">
<a href="articolo.php?id=<?php echo $ansa->id;?>" id="ansa_<?php echo $i;?>" class="ansaNews"><?php <a href="articolo.php?id=<?php echo $ansa->id;?>" id="ansa_<?php echo $i;?>" class="ansaNews"><?php
$media = DaoMediaHandler::getMainMediaFromModel($ansa); $media = DaoMediaHandler::getMainMediaFromModel($ansa);
@@ -357,12 +346,12 @@ catch (Exception $ex){
</div> </div>
<div class="newsContainer"> <div class="newsContainer">
<div class="categoryBar" style="background-color:<?php echo NotiziaModel::$NOTIZIE_CATEGORY[NotiziaModel::CATEGORY_MONDO_SPOSI]["color"] ?>"> <div class="categoryBar" style="background-color: <?php echo NotiziaModel::$NOTIZIE_CATEGORY[NotiziaModel::CATEGORY_VARIE]["color"] ?>">
<span><?php echo NotiziaModel::$NOTIZIE_CATEGORY[NotiziaModel::CATEGORY_MONDO_SPOSI]["label"] ?></span> <span><?php echo strtoupper($varieName); ?></span>
</div> </div>
<?php if(sizeof($mondoSposiNews)>0){ <?php if(sizeof($varie)>0){
$i=0; $i=0;
foreach ($mondoSposiNews as $articolo){ foreach ($varie as $articolo){
$stringTitolo = (strlen($articolo->titolo) > 53) ? htmlentities ( substr( html_entity_decode( $articolo->titolo ) ,0,50) ) .'...' : $articolo->titolo; $stringTitolo = (strlen($articolo->titolo) > 53) ? htmlentities ( substr( html_entity_decode( $articolo->titolo ) ,0,50) ) .'...' : $articolo->titolo;
// $string = (strlen($politica->sottotitolo) > 33) ? substr($politica->sottotitolo,0,30).'...' : $politica->sottotitolo;?> // $string = (strlen($politica->sottotitolo) > 33) ? substr($politica->sottotitolo,0,30).'...' : $politica->sottotitolo;?>
@@ -429,8 +418,6 @@ catch (Exception $ex){
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
$(".newsBarMobile").css({"margin-top":$(".headContainer").outerHeight()});
$("img.poster").hide(); $("img.poster").hide();
$("video.localVideo").attr("style",""); $("video.localVideo").attr("style","");
+3 -2
View File
@@ -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){
+1 -24
View File
@@ -4,29 +4,6 @@ Author: Riccardo Di Dato
Creation Date: 02/mar/2016 Creation Date: 02/mar/2016
*/ */
require_once(dirname(__FILE__)."/../../load.php"); include(dirname(__FILE__)."/../../stats/bannerClick.php");
try {
if (array_key_exists("HTTP_REFERER",$_SERVER)){
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
if (strcmp($host,$_SERVER["SERVER_NAME"])==0){
$banner = PostHandler::get("banner");
$source = PostHandler::get("source");
if (!is_null($banner) && !is_null($source)){
AnalyticsHelper::saveBannerClick($banner, $source);
}
}
else {
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_INFO,"Dropped statistical data coming from referer '".$host."'");
}
}
else {
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_INFO,"Dropped statistical data coming from null referer. Related ip '".$_SERVER['REMOTE_ADDR']."'");
}
}
catch (Exception $ex){
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_INFO,"Error while logging statistical data. Message: '".$ex->getMessage()."'");
}
?> ?>
+1 -25
View File
@@ -4,30 +4,6 @@ Author: Riccardo Di Dato
Creation Date: 02/mar/2016 Creation Date: 02/mar/2016
*/ */
require_once(dirname(__FILE__)."/../../load.php"); include(dirname(__FILE__)."/../../stats/bannerImpression.php");
try {
if (array_key_exists("HTTP_REFERER",$_SERVER)){
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
if (strcmp($host,$_SERVER["SERVER_NAME"])==0){
$ip = PostHandler::get("ip");
$banner = PostHandler::get("banner");
$source = PostHandler::get("source");
if (!is_null($ip) && !is_null($banner) && !is_null($source)){
AnalyticsHelper::saveBannerImpression($ip, $banner, $source);
}
}
else {
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_INFO,"Dropped statistical data coming from referer '".$host."'");
}
}
else {
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_INFO,"Dropped statistical data coming from null referer. Related ip '".$_SERVER['REMOTE_ADDR']."'");
}
}
catch (Exception $ex){
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_INFO,"Error while logging statistical data. Message: '".$ex->getMessage()."'");
}
?> ?>
@@ -0,0 +1,9 @@
<?php
/*
Author: Riccardo Di Dato
Creation Date: 02/mar/2016
*/
include(dirname(__FILE__)."/../../stats/bannerMultiImpression.php");
?>
+1 -26
View File
@@ -3,31 +3,6 @@
Author: Riccardo Di Dato Author: Riccardo Di Dato
Creation Date: 28/gen/2016 Creation Date: 28/gen/2016
*/ */
include(dirname(__FILE__)."/../../stats/notiziaImpression.php");
require_once(dirname(__FILE__)."/../../load.php");
try {
if (array_key_exists("HTTP_REFERER",$_SERVER)){
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
if (strcmp($host,$_SERVER["SERVER_NAME"])==0){
$ip = PostHandler::get("ip");
$notizia = PostHandler::get("notizia");
$source = PostHandler::get("source");
if (!is_null($ip) && !is_null($notizia) && !is_null($source)){
AnalyticsHelper::saveNotiziaImpression($ip, $notizia, $source);
}
}
else {
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_INFO,"Dropped statistical data coming from referer '".$host."'");
}
}
else {
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_INFO,"Dropped statistical data coming from null referer. Related ip '".$_SERVER['REMOTE_ADDR']."'");
}
}
catch (Exception $ex){
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_INFO,"Error while logging statistical data. Message: '".$ex->getMessage()."'");
}
?> ?>
+1 -25
View File
@@ -4,30 +4,6 @@ Author: Riccardo Di Dato
Creation Date: 27/gen/2016 Creation Date: 27/gen/2016
*/ */
require_once(dirname(__FILE__)."/../../load.php"); include(dirname(__FILE__)."/../../stats/pageImpression.php");
try {
if (array_key_exists("HTTP_REFERER",$_SERVER)){
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
if (strcmp($host,$_SERVER["SERVER_NAME"])==0){
$ip = PostHandler::get("ip");
$content = PostHandler::get("content");
$source = PostHandler::get("source");
if (!is_null($ip) && !is_null($content) && !is_null($source)){
AnalyticsHelper::savePageImpression($ip, $content, $source);
}
}
else {
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_INFO,"Dropped statistical data coming from referer '".$host."'");
}
}
else {
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_INFO,"Dropped statistical data coming from null referer. Related ip '".$_SERVER['REMOTE_ADDR']."'");
}
}
catch (Exception $ex){
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_INFO,"Error while logging statistical data. Message: '".$ex->getMessage()."'");
}
?> ?>
+3 -3
View File
@@ -4,7 +4,7 @@ a{text-decoration:none;}
body{font-family:lato, arial;} body{font-family:lato, arial;}
/* TOP HEAD BAR/Menu/Footer (GUIHandler)*/ /* TOP HEAD BAR/Menu/Footer (GUIHandler)*/
.headContainer{position:fixed;background-color:white;width:100vw;top:0;left:0;z-index:10;overflow:hidden;} .headContainer{position:sticky;background-color:white;width:100vw;top:0;left:0;z-index:10;overflow:hidden;}
.upperBar{text-align:center;border:1px solid #949494;border-left:0px;border-right:0px;margin:5px 0;padding:2px;font-size:8pt;color:#949494;} .upperBar{text-align:center;border:1px solid #949494;border-left:0px;border-right:0px;margin:5px 0;padding:2px;font-size:8pt;color:#949494;}
.logo{text-align:center;} .logo{text-align:center;}
.logo img{width:50vw;margin:auto;} .logo img{width:50vw;margin:auto;}
@@ -102,7 +102,7 @@ body{font-family:lato, arial;}
} }
.newsBarMobile{margin-top:32vw;width:100vw;} .newsBarMobile{width:100vw;}
.newsContainer{width:100vw;} .newsContainer{width:100vw;}
.newsContainer .categoryBar{padding:5px 10px;} .newsContainer .categoryBar{padding:5px 10px;}
.newsContainer .categoryBar > span{color:white;font-weight:bold;font-size:14pt;} .newsContainer .categoryBar > span{color:white;font-weight:bold;font-size:14pt;}
@@ -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; margin: 0; font-size: 1.8em; }
.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;}
+12 -6
View File
@@ -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:150px; }
.footerBanner { width:1000px; height:200px; }
.menuContainer{position:relative;} .menuContainer{position:relative;}
@@ -312,26 +315,29 @@ 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, .variousContainer {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;}
.rightCategory .categoryBar{ margin-bottom: 5px;}
.rightColumnTitle{ margin-bottom:5px; font-weight:bold; font-size:17px; color: black; }
/* /*
_ _ _ _ _ _ _ _
/ \ _ __| |_(_) ___ ___ | | ___ / \ _ __| |_(_) ___ ___ | | ___
@@ -364,7 +370,7 @@ display: inline-block;
.articoloMainMedia.mediaContent img{max-height:225px;cursor:pointer;} .articoloMainMedia.mediaContent img{max-height:225px;cursor:pointer;}
.articoloTitle{display:inline-block;width:550px;padding:0px 20px;vertical-align:top;text-align:left;} .articoloTitle{display:inline-block;width:550px;padding:0px 20px;vertical-align:top;text-align:left;}
.articoloTitle > .title{font-size:20px;font-weight:bold;text-transform:uppercase;font-family:"Arial Bold";} .articoloTitle > .title{font-size:20px;font-weight:bold;text-transform:uppercase;font-family:"Arial Bold"; margin: 0;}
.articoloTitle > .subTitle{font-style:italic;font-family:"Arial Bold";} .articoloTitle > .subTitle{font-style:italic;font-family:"Arial Bold";}
.subTitle > span:first-child{color:rgb(150,150,150);text-transform:none;font-weight:bold;} .subTitle > span:first-child{color:rgb(150,150,150);text-transform:none;font-weight:bold;}
+13
View File
@@ -0,0 +1,13 @@
FROM alpine:3.6
RUN apk add --no-cache --upgrade bash mongodb-tools
# copy crontabs for root user
COPY crontab /etc/crontabs/root
# copy backup script
COPY backup /myscripts/backup
RUN chmod 0744 /myscripts/backup
# start crond with log level 8 in foreground, output to stderr
CMD ["crond", "-f", "-d", "8"]
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
DATE=`date +"%Y-%m-%d_%H:%M"`
echo "Generating backup $DATE"
DATABASE_HOST="fdn2.production.database"
DATABASE_NAME="fdn2"
DATABASE_PORT="27017"
WORKDIR="/workdir"
STORAGE="/backups"
mkdir -p $WORKDIR
mongodump --host $DATABASE_HOST -d $DATABASE_NAME --port $DATABASE_PORT --out "$WORKDIR"
tar -cvzf "$STORAGE/dump-$DATE.tar.gz" "$WORKDIR"
for old in `ls -t $STORAGE | tail -n +7`; do
TOREMOVE="$STORAGE/$old"
echo "Removing '$TOREMOVE'";
rm -r $TOREMOVE
done
+1
View File
@@ -0,0 +1 @@
4 0 * * * /myscripts/backup 2>&1
+17
View File
@@ -0,0 +1,17 @@
version: "3"
services:
backup:
image: cronjob
build: ./
networks:
- backup-network
restart: "unless-stopped"
volumes:
- /home/ddninja/fdn2/backups:/backups
networks:
backup-network:
external: true
name:
backup-network
+96
View File
@@ -0,0 +1,96 @@
version: "3"
services:
mongo:
image: mongo:3
restart: "on-failure:5"
networks:
db-network:
backup-network:
aliases:
- §PROJECT_BUILDNAME§.§ENVIRONMENT_TYPE§.database
volumes:
- ./persistence/database/mongodb:/data/db/
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "50m"
webserver:
image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§-webserver
env_file:
- environments/common/webserver.env
- environments/§ENVIRONMENT_TYPE§/webserver.env
depends_on:
- mongo
- memcached
restart: "on-failure:3"
networks:
db-network:
§PROJECT_BUILDNAME§-network:
nginx-network:
aliases:
- §PROJECT_BUILDNAME§.§ENVIRONMENT_TYPE§.webserver
links:
- mongo:database
volumes:
- ./persistence/storage:/home/§PROJECT_AUTHOR§/storage/§PROJECT_BUILDNAME§
- §PROJECT_BUILDNAME§-ws-log:/var/log/§PROJECT_AUTHOR§/
- §PROJECT_BUILDNAME§-job-comms:/jobComunication/
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "150m"
worker:
image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§-worker
env_file:
- environments/common/worker.env
- environments/§ENVIRONMENT_TYPE§/worker.env
depends_on:
- mongo
- memcached
restart: "on-failure:3"
networks:
db-network:
§PROJECT_BUILDNAME§-network:
links:
- mongo:database
volumes:
- ./persistence/storage:/home/§PROJECT_AUTHOR§/storage/§PROJECT_BUILDNAME§
- §PROJECT_BUILDNAME§-wk-log:/var/log/§PROJECT_AUTHOR§/
- §PROJECT_BUILDNAME§-job-comms:/jobComunication/
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "150m"
memcached:
image: memcached:1.6.9-alpine
restart: "on-failure:5"
networks:
§PROJECT_BUILDNAME§-network:
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "10m"
networks:
db-network:
§PROJECT_BUILDNAME§-network:
backup-network:
external: true
name:
backup-network
nginx-network:
external: true
name:
nginx-network
volumes:
§PROJECT_BUILDNAME§-ws-log:
§PROJECT_BUILDNAME§-wk-log:
§PROJECT_BUILDNAME§-db-persist:
§PROJECT_BUILDNAME§-job-comms:
+24 -22
View File
@@ -5,12 +5,13 @@ services:
restart: "no" restart: "no"
networks: networks:
db-network: db-network:
backup-network:
aliases: aliases:
- §PROJECT_BUILDNAME§.§ENVIRONMENT_TYPE§.database - §PROJECT_BUILDNAME§.local.database
volumes: volumes:
- §PROJECT_BUILDNAME§-db-persist:/usr/local/mongodb - §PROJECT_BUILDNAME§-db-persist:/data/db/
webserver: webserver:
image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§-debug image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§-webserver-debug
env_file: env_file:
- environments/common/webserver.env - environments/common/webserver.env
- environments/local/webserver.env - environments/local/webserver.env
@@ -28,20 +29,22 @@ services:
- §DEBUG_HOST_PROJECT_FOLDER§/app/public:/var/www/§PROJECT_BUILDNAME§:ro - §DEBUG_HOST_PROJECT_FOLDER§/app/public:/var/www/§PROJECT_BUILDNAME§:ro
- §DEBUG_HOST_PROJECT_FOLDER§/app/private:/home/§PROJECT_AUTHOR§/private/§PROJECT_BUILDNAME§:ro - §DEBUG_HOST_PROJECT_FOLDER§/app/private:/home/§PROJECT_AUTHOR§/private/§PROJECT_BUILDNAME§:ro
- §PROJECT_BUILDNAME§-job-comms:/jobComunication/ - §PROJECT_BUILDNAME§-job-comms:/jobComunication/
# worker: worker:
# image: 662348923997.dkr.ecr.eu-west-1.amazonaws.com/§PROJECT_GROUP§/edenlandia-worker:§TAG_NAME§ image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§-worker-debug
# env_file: worker.env env_file:
# restart: "no" - environments/common/worker.env
# networks: - environments/local/worker.env
# db-network: restart: "no"
# §PROJECT_BUILDNAME§-network: networks:
# links: db-network:
# - mongo:database §PROJECT_BUILDNAME§-network:
# volumes: links:
# - §PROJECT_BUILDNAME§-storage:/home/asdynamics/storage/edenlandia-worker - mongo:database
# - edenlandia-worker-log:/var/log/asdynamics/ volumes:
# - ~/workspace-azzurro/webapps/edenlandia-worker/app/private:/home/asdynamics/private/§PROJECT_BUILDNAME§:ro - §PROJECT_BUILDNAME§-storage:/home/§PROJECT_AUTHOR§/storage/§PROJECT_BUILDNAME§
# - §PROJECT_BUILDNAME§-job-comms:/jobComunication/ - ./worker-logs:/var/log/§PROJECT_AUTHOR§/
- §DEBUG_HOST_PROJECT_FOLDER§/app/private:/home/§PROJECT_AUTHOR§/private/§PROJECT_BUILDNAME§:ro
- §PROJECT_BUILDNAME§-job-comms:/jobComunication/
memcached: memcached:
image: memcached:1.6.9-alpine image: memcached:1.6.9-alpine
restart: "no" restart: "no"
@@ -49,17 +52,16 @@ 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:
backup-network:
external: true
name:
backup-network
volumes: volumes:
§PROJECT_BUILDNAME§-storage: §PROJECT_BUILDNAME§-storage:
§PROJECT_BUILDNAME§-log: §PROJECT_BUILDNAME§-log:
# edenlandia-worker-log:
§PROJECT_BUILDNAME§-db-persist: §PROJECT_BUILDNAME§-db-persist:
§PROJECT_BUILDNAME§-job-comms: §PROJECT_BUILDNAME§-job-comms:
-73
View File
@@ -1,73 +0,0 @@
version: "3"
services:
mongo:
image: mongo:3
restart: "on-failure:5"
networks:
db-network:
volumes:
- ./persistence/database/mongodb:/usr/local/mongodb
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "50m"
webserver:
image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§
env_file:
- environments/common/webserver.env
- environments/production/webserver.env
depends_on:
- mongo
- memcached
restart: "on-failure:3"
ports:
- "80:80"
networks:
db-network:
§PROJECT_BUILDNAME§-network:
links:
- mongo:database
volumes:
- ./persistence/webserver/storage:/home/§PROJECT_AUTHOR§/storage/§PROJECT_BUILDNAME§
- §PROJECT_BUILDNAME§-ws-log:/var/log/§PROJECT_AUTHOR§/
- §PROJECT_BUILDNAME§-job-comms:/jobComunication/
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "150m"
# worker:
# image: 662348923997.dkr.ecr.eu-west-1.amazonaws.com/§PROJECT_GROUP§/edenlandia-worker:§TAG_NAME§
# env_file: worker.env
# restart: "no"
# networks:
# db-network:
# §PROJECT_BUILDNAME§-network:
# links:
# - mongo:database
# volumes:
# - §PROJECT_BUILDNAME§-storage:/home/asdynamics/storage/edenlandia-worker
# - edenlandia-worker-log:/var/log/asdynamics/
# - ~/workspace-azzurro/webapps/edenlandia-worker/app/private:/home/asdynamics/private/§PROJECT_BUILDNAME§:ro
# - §PROJECT_BUILDNAME§-job-comms:/jobComunication/
memcached:
image: memcached:1.6.9-alpine
restart: "on-failure:3"
networks:
§PROJECT_BUILDNAME§-network:
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "10m"
networks:
db-network:
§PROJECT_BUILDNAME§-network:
volumes:
§PROJECT_BUILDNAME§-ws-log:
§PROJECT_BUILDNAME§-db-persist:
§PROJECT_BUILDNAME§-job-comms:
@@ -0,0 +1,37 @@
# Use a PHP runtime as a parent image
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-webserver
# 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 webserver
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§-webserver
# 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 webserver
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§-webserver-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 webserver
ENTRYPOINT ["/usr/local/bin/phpunit"]
CMD ["--help"]
@@ -1,5 +1,5 @@
# Use a PHP runtime as a parent image # Use a PHP runtime as a parent image
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§ FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-worker
# Set the working directory to /app # Set the working directory to /app
WORKDIR /§PROJECT_BUILDNAME§ WORKDIR /§PROJECT_BUILDNAME§
@@ -27,7 +27,7 @@ COPY ./install /§PROJECT_BUILDNAME§
RUN chmod 744 /§PROJECT_BUILDNAME§/install RUN chmod 744 /§PROJECT_BUILDNAME§/install
RUN /§PROJECT_BUILDNAME§/install RUN /§PROJECT_BUILDNAME§/install worker
ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"] ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"]
@@ -1,5 +1,5 @@
# Use a PHP runtime as a parent image # Use a PHP runtime as a parent image
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§ FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-worker
# Set the working directory to /app # Set the working directory to /app
WORKDIR /§PROJECT_BUILDNAME§ WORKDIR /§PROJECT_BUILDNAME§
@@ -27,7 +27,7 @@ COPY ./install /§PROJECT_BUILDNAME§
RUN chmod 744 /§PROJECT_BUILDNAME§/install RUN chmod 744 /§PROJECT_BUILDNAME§/install
RUN /§PROJECT_BUILDNAME§/install RUN /§PROJECT_BUILDNAME§/install worker
ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"] ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"]
@@ -1,4 +1,4 @@
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§-unit FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-worker-unit
WORKDIR /§PROJECT_BUILDNAME§ WORKDIR /§PROJECT_BUILDNAME§
COPY ./app /§PROJECT_BUILDNAME§ COPY ./app /§PROJECT_BUILDNAME§
@@ -9,7 +9,7 @@ COPY ./test/install /§PROJECT_BUILDNAME§
RUN chmod 744 /§PROJECT_BUILDNAME§/install RUN chmod 744 /§PROJECT_BUILDNAME§/install
RUN /§PROJECT_BUILDNAME§/install RUN /§PROJECT_BUILDNAME§/install worker
ENTRYPOINT ["/usr/local/bin/phpunit"] ENTRYPOINT ["/usr/local/bin/phpunit"]
CMD ["--help"] CMD ["--help"]
+1
View File
@@ -1,2 +1,3 @@
DDNINJA_PROJECTNAME=FDN2 DDNINJA_PROJECTNAME=FDN2
DDNINJA_BUILDNAME=fdn2 DDNINJA_BUILDNAME=fdn2
DDNINJA_AUTHOR=ddninja
+3
View File
@@ -0,0 +1,3 @@
DDNINJA_PROJECTNAME=FDN2
DDNINJA_BUILDNAME=fdn2
DDNINJA_AUTHOR=ddninja
+7
View File
@@ -0,0 +1,7 @@
DDNINJA_ENVIRONMENT_NAME=local
DDNINJA_IS_PRODUCTION=false
DDNINJA_MONGO_DBNAME=fdn2
DDNINJA_MONGO_LOCATION=database
DDNINJA_PUBLIC_URL=http://www.fdn2.loc:8800
+1 -3
View File
@@ -3,7 +3,5 @@ DDNINJA_IS_PRODUCTION=true
DDNINJA_MONGO_DBNAME=fdn2 DDNINJA_MONGO_DBNAME=fdn2
DDNINJA_MONGO_LOCATION=database DDNINJA_MONGO_LOCATION=database
DDNINJA_MONGO_USER=fdn2
DDNINJA_MONGO_PASSWORD=p14n3ll1FDN2
DDNINJA_PUBLIC_URL=http://www.ifattidinapoli.it DDNINJA_PUBLIC_URL=http://preproduction.ifattidinapoli.it
+7
View File
@@ -0,0 +1,7 @@
DDNINJA_ENVIRONMENT_NAME=production
DDNINJA_IS_PRODUCTION=true
DDNINJA_MONGO_DBNAME=fdn2
DDNINJA_MONGO_LOCATION=database
DDNINJA_PUBLIC_URL=http://preproduction.ifattidinapoli.it
+7
View File
@@ -0,0 +1,7 @@
DDNINJA_ENVIRONMENT_NAME=test
DDNINJA_IS_PRODUCTION=false
DDNINJA_MONGO_DBNAME=fdn2_test
DDNINJA_MONGO_LOCATION=database
DDNINJA_PUBLIC_URL=http://test.ifattidinapoli.it
+19
View File
@@ -0,0 +1,19 @@
version: "3"
services:
nginx:
image: nginx:1.16
ports:
- "80:80"
- "443:443"
networks:
- nginx-network
restart: always
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
networks:
nginx-network:
external: true
name:
nginx-network
+32
View File
@@ -0,0 +1,32 @@
worker_processes 1;
events { worker_connections 1024; }
http {
client_max_body_size 5M;
server {
listen 80;
server_name www.ifattidinapoli.it preproduction.ifattidinapoli.it default_server;
location / {
proxy_pass http://fdn2.production.webserver/;
proxy_redirect off;
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name test.ifattidinapoli.it;
location / {
proxy_pass http://fdn2.test.webserver/;
proxy_redirect off;
proxy_set_header Host $host;
}
}
}
-2
View File
@@ -4,7 +4,6 @@ declare -A CONFIG=(
["FRAMEWORK_REPOSITORY"]="299952237278.dkr.ecr.eu-west-1.amazonaws.com" ["FRAMEWORK_REPOSITORY"]="299952237278.dkr.ecr.eu-west-1.amazonaws.com"
["FRAMEWORK_IMAGE"]="ddninja/phpframework" ["FRAMEWORK_IMAGE"]="ddninja/phpframework"
["FRAMEWORK_VERSION"]="2.5.4" ["FRAMEWORK_VERSION"]="2.5.4"
["FRAMEWORK_TYPE"]="webserver"
["FRAMEWORK_AUTHOR"]="ddninja" ["FRAMEWORK_AUTHOR"]="ddninja"
["PROJECT_REPOSITORY"]="299952237278.dkr.ecr.eu-west-1.amazonaws.com" ["PROJECT_REPOSITORY"]="299952237278.dkr.ecr.eu-west-1.amazonaws.com"
@@ -23,7 +22,6 @@ declare -A CONFIG=(
FRAMEWORK_REPOSITORY=${CONFIG['FRAMEWORK_REPOSITORY']} FRAMEWORK_REPOSITORY=${CONFIG['FRAMEWORK_REPOSITORY']}
FRAMEWORK_IMAGE=${CONFIG['FRAMEWORK_IMAGE']} FRAMEWORK_IMAGE=${CONFIG['FRAMEWORK_IMAGE']}
FRAMEWORK_VERSION=${CONFIG['FRAMEWORK_VERSION']} FRAMEWORK_VERSION=${CONFIG['FRAMEWORK_VERSION']}
FRAMEWORK_TYPE=${CONFIG['FRAMEWORK_TYPE']}
FRAMEWORK_AUTHOR=${CONFIG['FRAMEWORK_AUTHOR']} FRAMEWORK_AUTHOR=${CONFIG['FRAMEWORK_AUTHOR']}
PROJECT_REPOSITORY=${CONFIG['PROJECT_REPOSITORY']} PROJECT_REPOSITORY=${CONFIG['PROJECT_REPOSITORY']}
+1 -1
View File
@@ -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"})
+13 -5
View File
@@ -1,5 +1,11 @@
#!/bin/bash #!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
fi
TYPE=$1
my_dir="$(dirname "$0")" my_dir="$(dirname "$0")"
DIR_RETURN=`pwd` DIR_RETURN=`pwd`
@@ -25,11 +31,13 @@ chown -R www-data:www-data /var/log/$PROJECT_AUTHOR
chmod 0744 /home/$PROJECT_AUTHOR/private/$PROJECT_BUILDNAME/bin/* chmod 0744 /home/$PROJECT_AUTHOR/private/$PROJECT_BUILDNAME/bin/*
# Apache # Apache
cat ./os/000-${PROJECT_TYPE}.template.conf | if [[ $TYPE == "webserver" ]]; then
sed -e "s/§PROJECT_BUILDNAME§/${PROJECT_BUILDNAME}/g" \ cat ./os/000-${PROJECT_TYPE}.template.conf |
> /etc/apache2/sites-available/000-default.conf sed -e "s/§PROJECT_BUILDNAME§/${PROJECT_BUILDNAME}/g" \
> /etc/apache2/sites-available/000-default.conf
a2enmod rewrite a2enmod rewrite
fi
# Overwrite opcache default config # Overwrite opcache default config
cat ./os/opcache.template.ini | cat ./os/opcache.template.ini |
@@ -40,7 +48,7 @@ cat ./os/opcache.template.ini |
cat ./os/php.template.ini > /usr/local/etc/php/php.ini cat ./os/php.template.ini > /usr/local/etc/php/php.ini
# Generate Entrypoint # Generate Entrypoint
cp "./os/webserver-entrypoint" "/usr/local/bin/$PROJECT_BUILDNAME-entrypoint" cp "./os/${TYPE}-entrypoint" "/usr/local/bin/$PROJECT_BUILDNAME-entrypoint"
chmod 0744 /usr/local/bin/$PROJECT_BUILDNAME-entrypoint chmod 0744 /usr/local/bin/$PROJECT_BUILDNAME-entrypoint
-18
View File
@@ -1,18 +0,0 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__). "/../load.php");
// try {
// }
// catch (UNHADBException $unex){
// $msg = $application->core->loggingCatalogManager->getCatalog($unex->getMessage(),$unex->getData());
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("ProcessMailQueue.php",$msg),true);
// }
// catch (Exception $ex){
// $msg = $application->core->loggingCatalogManager->getCatalog($ex->getMessage());
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("ProcessMailQueue.php",$msg),true);
// }
?>
-38
View File
@@ -1,38 +0,0 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__). "/../load.php");
$tasks = array("SendBackupTask");
if (sizeof($tasks)>0){
foreach ($tasks as $taskName){
try {
if ($taskName::isActive()){
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_INFO,"Executing task '".$taskName::getLabel()."' ");
$taskName::execute();
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_INFO,"Task '".$taskName::getLabel()."' completed successfully");
}
}catch (CoreException $ex){
$msg = "Error while executing task '".$taskName::getLabel()."' with message '".$ex->getMessage()."'";
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
}
catch (Exception $ex){
$msg = "Unexpected error while executing task '".$taskName::getLabel()."' with message '".$ex->getMessage()."'";
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
}
}
}
// try {
// }catch (UNHADBException $unex){
// $msg = $application->core->loggingCatalogManager->getCatalog($unex->getMessage(),$unex->getData());
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("ProcessMailQueue.php",$msg),true);
// }
// catch (Exception $ex){
// $msg = $application->core->loggingCatalogManager->getCatalog($ex->getMessage());
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("ProcessMailQueue.php",$msg),true);
// }
?>
-40
View File
@@ -1,40 +0,0 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__). "/../load.php");
$tasks = array("NewsletterCheckTask","DeleteOldPasswordResetRequestsTask", "UpdateMeteoCacheTask", "GenerateCommentiWarningMailTask");
if (sizeof($tasks)>0){
foreach ($tasks as $taskName){
try {
if ($taskName::isActive()){
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_INFO,"Executing task '".$taskName::getLabel()."' ");
$taskName::execute();
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_INFO,"Task '".$taskName::getLabel()."' completed successfully");
}
}catch (CoreException $ex){
$msg = "Error while executing task '".$taskName::getLabel()."' with message '".$ex->getMessage()."'";
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
}
catch (Exception $ex){
$msg = "Unexpected error while executing task '".$taskName::getLabel()."' with message '".$ex->getMessage()."'";
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
}
}
}
// try {
// SystemController::executeTask("RefreshApiCache.php");
// }
// catch (UNHADBException $unex){
// $msg = $application->core->loggingCatalogManager->getCatalog($unex->getMessage(),$unex->getData());
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("GenerateReminderMail.php",$msg),true);
// }
// catch (Exception $ex){
// $msg = $application->core->loggingCatalogManager->getCatalog($ex->getMessage());
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("GenerateReminderMail.php",$msg),true);
// }
?>
-37
View File
@@ -1,37 +0,0 @@
#!/usr/bin/php
<?php
/*
Author: Riccardo Di Dato
Creation Date: 12/gen/2016
*/
require_once(dirname(__FILE__). "/../load.php");
$tasks = array(
"GenerateAdminActivationMailTask",
"GenerateUserActivationMailTask",
"GenerateAdminPasswordRecoveryMailTask",
"GenerateUserPasswordRecoveryMailTask",
"MailSendTask",
);
if (sizeof($tasks)>0){
foreach ($tasks as $taskName){
try {
if ($taskName::isActive()){
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_INFO,"Executing task '".$taskName::getLabel()."' ");
$taskName::execute();
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_INFO,"Task '".$taskName::getLabel()."' completed successfully");
}
}catch (CoreException $ex){
$msg = "Error while executing task '".$taskName::getLabel()."' with message '".$ex->getMessage()."'";
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
}
catch (Exception $ex){
$msg = "Unexpected error while executing task '".$taskName::getLabel()."' with message '".$ex->getMessage()."'";
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
}
}
}
?>
-5
View File
@@ -1,5 +0,0 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__). "/../load.php");
?>
-16
View File
@@ -1,16 +0,0 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__). "/../load.php");
// try {
// }catch (UNHADBException $unex){
// $msg = $application->core->loggingCatalogManager->getCatalog($unex->getMessage(),$unex->getData());
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("ProcessMailQueue.php",$msg),true);
// }
// catch (Exception $ex){
// $msg = $application->core->loggingCatalogManager->getCatalog($ex->getMessage());
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("ProcessMailQueue.php",$msg),true);
// }
?>
+10 -6
View File
@@ -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 .
@@ -93,7 +97,7 @@ if [[ $UNIT_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-unit -f $DOCKERFILE . docker build -t $PROJECT_REPOSITORY/$PROJECT_GROUP/$PROJECT_BUILDNAME:$TAG-unit -f $DOCKERFILE .
@@ -108,7 +112,7 @@ if [[ $DEBUG_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-debug -f $DOCKERFILE . docker build -t $PROJECT_REPOSITORY/$PROJECT_GROUP/$PROJECT_BUILDNAME:$TAG-debug -f $DOCKERFILE .
+89 -15
View File
@@ -22,8 +22,14 @@ usage() {
echo " -u: Unit tests locally" 1>&2; echo " -u: Unit tests locally" 1>&2;
echo " -d: Run debug vesion locally" 1>&2; echo " -d: Run debug vesion locally" 1>&2;
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: 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;
} }
@@ -31,12 +37,16 @@ usage() {
UNIT_MODE=0 UNIT_MODE=0
DEBUG_MODE=0 DEBUG_MODE=0
PUBLISH_MODE=0 PUBLISH_MODE=0
DEPLOY_MODE=0 DEPLOY_TEST_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:hvudpx" o; do while getopts "t:TmMPhvudpxX" o; do
case "${o}" in case "${o}" in
u) u)
UNIT_MODE=1 UNIT_MODE=1
@@ -50,13 +60,38 @@ while getopts "t:hvudpx" o; do
PUBLISH_MODE=1 PUBLISH_MODE=1
SELECTED_MODES+=1 SELECTED_MODES+=1
;; ;;
X)
DEPLOY_TEST_MODE=1
SELECTED_MODES+=1
;;
x) x)
DEPLOY_MODE=1 DEPLOY_PROD_MODE=1
SELECTED_MODES+=1 SELECTED_MODES+=1
;; ;;
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
@@ -90,25 +125,48 @@ if [[ $UNIT_MODE -eq 1 ]]; then
BUILDOPT+="v" BUILDOPT+="v"
UNITOPT="-v" UNITOPT="-v"
fi fi
msg "running ./build.sh -$BUILDOPT -t $TAG" msg "running ./build.sh -I webserver -$BUILDOPT -t \"$TAG-webserver\""
./build.sh -$BUILDOPT -t $TAG ./build.sh -I webserver -$BUILDOPT -t "$TAG-webserver"
./run-unit.sh $UNITOPT -t $TAG msg "running ./build.sh -I worker -$BUILDOPT -t \"$TAG-worker\""
./build.sh -I worker -$BUILDOPT -t "$TAG-worker"
./run-unit.sh $UNITOPT -t $TAG-webserver
./run-unit.sh $UNITOPT -t $TAG-worker
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"
# WORKER
msg "running ./build.sh -I worker -$BUILDOPT -t $TAG-worker"
./build.sh -I worker -$BUILDOPT -t "$TAG-worker"
./run-unit.sh $VERBOPT -t "$TAG-worker"
./publish.sh $VERBOPT -t "$TAG-worker"
if [[ $TAG_IMPLICIT -ne 1 ]]; then
git tag $TAG
git push --tags
fi
fi fi
@@ -117,8 +175,10 @@ if [[ $DEBUG_MODE -eq 1 ]]; then
if [[ $VERBOSE -gt 0 ]]; then if [[ $VERBOSE -gt 0 ]]; then
BUILDOPT+="v" BUILDOPT+="v"
fi fi
msg "running ./build.sh -$BUILDOPT -t $TAG" msg "running ./build.sh -I webserver -$BUILDOPT -t $TAG-webserver"
./build.sh -$BUILDOPT -t $TAG ./build.sh -$BUILDOPT -I webserver -t $TAG-webserver
msg "running ./build.sh -I worker -$BUILDOPT -t $TAG-worker"
./build.sh -$BUILDOPT -I worker -t $TAG-worker
OUT_FOLDER="/home/$PROJECT_AUTHOR/$PROJECT_BUILDNAME/local" OUT_FOLDER="/home/$PROJECT_AUTHOR/$PROJECT_BUILDNAME/local"
mkdir -p $OUT_FOLDER mkdir -p $OUT_FOLDER
@@ -134,9 +194,23 @@ if [[ $DEBUG_MODE -eq 1 ]]; then
xdg-open "$DDNINJA_PUBLIC_URL" xdg-open "$DDNINJA_PUBLIC_URL"
fi fi
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"
mkdir -p $OUT_FOLDER
./generateComposeFolder.sh -s -o "$OUT_FOLDER" -t $TAG
if [[ $DEPLOY_MODE -eq 1 ]]; then cd "$OUT_FOLDER"
OUT_FOLDER="/home/$PROJECT_AUTHOR/$PROJECT_BUILDNAME/local" docker compose up -d
fi
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"
mkdir -p $OUT_FOLDER mkdir -p $OUT_FOLDER
./generateComposeFolder.sh -p -o "$OUT_FOLDER" -t $TAG ./generateComposeFolder.sh -p -o "$OUT_FOLDER" -t $TAG
+6 -3
View File
@@ -33,6 +33,7 @@ usage() {
STARTING_FILE="" STARTING_FILE=""
CFGFILE="$DIR/../config" CFGFILE="$DIR/../config"
OUT_DIRECTORY="" OUT_DIRECTORY=""
ENV_TYPE="local"
SELECTED_MODES=0 SELECTED_MODES=0
@@ -47,11 +48,13 @@ while getopts "i:o:t:hvlLsp" o; do
SELECTED_MODES+=1 SELECTED_MODES+=1
;; ;;
s) s)
STARTING_FILE="$DIR/../cicd/docker-compose/test.yml" STARTING_FILE="$DIR/../cicd/docker-compose/deploy.yml"
ENV_TYPE="test"
SELECTED_MODES+=1 SELECTED_MODES+=1
;; ;;
p) p)
STARTING_FILE="$DIR/../cicd/docker-compose/production.yml" STARTING_FILE="$DIR/../cicd/docker-compose/deploy.yml"
ENV_TYPE="production"
SELECTED_MODES+=1 SELECTED_MODES+=1
;; ;;
i) i)
@@ -89,5 +92,5 @@ fi
cp -rT "$DIR/../cicd/environments" "$OUT_DIRECTORY/environments" cp -rT "$DIR/../cicd/environments" "$OUT_DIRECTORY/environments"
buildTemplate -f "$CFGFILE" -t "$STARTING_FILE" -o "$OUT_DIRECTORY/docker-compose.yml" --add TAG_NAME=$TAG buildTemplate -f "$CFGFILE" -t "$STARTING_FILE" -o "$OUT_DIRECTORY/docker-compose.yml" --add TAG_NAME=$TAG --add ENVIRONMENT_TYPE=$ENV_TYPE
+10 -4
View File
@@ -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"
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
git pull --quiet
git tag | tr - \~ | sort -V | tr \~ - | tail -n 1
+59
View File
@@ -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"