diff --git a/buildLibs b/buildLibs index 591624a..b012e75 100644 --- a/buildLibs +++ b/buildLibs @@ -117,7 +117,7 @@ function deploy(){ chmod -R a+x "$APPLICATION_BINARY_PATH" chmod -R a+x "$APPLICATION_CRON_PATH" - chmod -R a+x "$APPLICATION_TASK_PATH" +# chmod -R a+x "$APPLICATION_TASK_PATH" } diff --git a/buildLibs~ b/buildLibs~ new file mode 100644 index 0000000..591624a --- /dev/null +++ b/buildLibs~ @@ -0,0 +1,273 @@ +#!/bin/bash + +## Funzioni utilizzate da build + +#Stampa i comandi possibili +function help() { + printf "\n" + printf "build [-h] -[ptl] -[DCcfs] [config_file]\n" + printf "\n" + printf "Specificare il config_file solo se non si desidera utilizzare quello di default.\n" + printf "E' obbligatorio specificare l'environment. In caso di environment multipli sarà utilizzato solo quello a priorità maggiore.\n" + printf "L'opzione default di database è -f (fix).\n" + printf "\n" + printf "Possibili valori di option\n" + printf "\t -h questa schermata\n" + printf "\n" + printf "Lista environment (per deployare la configurazione) in ordine di priorità\n" + printf "\t -p Produzione\n" + printf "\t -t Test\n" + printf "\t -l Locale\n" + printf "\n" + printf "Opzioni database\n" + printf "\t -D Droppa tutto il database e lo rebuilda\n" + printf "\t -C Droppa le tabelle di contenuti e le rebuilda\n" + printf "\t -c Droppa le tabelle di configurazione e le rebuilda\n" + printf "\t -f Aggiunge le tabelle mancanti\n" + printf "\t -s Skip db fix\n" +} + +#Stampa il nome del comando in esecuzione +function printcmd () { + printf "*-----------------------------------------*\n" + printf " PROJECT: $PROJECT_NAME\n" + printf " EXECUTING: $1\n" + printf "\n" + printf "*-----------------------------------------*\n" +} + + + +# Imposta come proprietario della cartella l'utente apache +function chown_folder() { + if [[ -z "$1" ]] || [[ "$1" == "/" ]] || [[ "$1" == "./" ]]; then + exit 1 + else + chown -R $APACHE2_USER:$APACHE2_GROUP "$1" + fi +} + +function svncleanup() { + if [[ -z "$1" ]] || [[ "$1" == "/" ]] || [[ "$1" == "./" ]]; then + exit 1 + else + for i in `find "$1" -name .svn`; + do + printf "Deleting .. $i\n" + rm -rf "$i" + done + fi +} + +# Crea le cartelle di sistema +function create_project_fs(){ + # CREATES APPLICATION PRIVATE FOLDER + mkdir -p $APPLICATION_PRIVATE + chown_folder $APPLICATION_PRIVATE + + # CREATES APPLICATION PUBLIC FOLDER + mkdir -p $APPLICATION_PUBLIC + chown_folder $APPLICATION_PUBLIC + + # CREATES APPLICATION STORAGE FOLDER + mkdir -p $APPLICATION_STORAGE + chown_folder $APPLICATION_STORAGE + + # CREATES APPLICATION LOG FOLDER + mkdir -p $APPLICATION_LOG_PATH + chown_folder $APPLICATION_LOG_PATH + + # CREATES XSENDFILE FOLDER + mkdir -p $APPLICATION_XSENDFILE_PATH + chown_folder $APPLICATION_XSENDFILE_PATH + + # CREATES APPLICATION MEDIA FOLDER + mkdir -p $APPLICATION_MEDIA_PATH + chown_folder $APPLICATION_MEDIA_PATH + + # CREATES APPLICATION BACKUP FOLDER + mkdir -p $APPLICATION_BACKUPS_PATH + chown_folder $APPLICATION_BACKUPS_PATH + + # CREATES APPLICATION TEMPORARY FOLDER + mkdir -p $APPLICATION_TMP_PATH + chown_folder $APPLICATION_TMP_PATH +} + + +# Deploya i sorgenti +function deploy(){ + echo "Deleting old build (Private)" + rm -rf "$APPLICATION_PRIVATE/*" + + echo "Deleting old build (Public)" + rm -rf "$APPLICATION_PUBLIC/*" + + + echo "Deploying new build (Private)" + cp -a "./private/"* "$APPLICATION_PRIVATE" + svncleanup "$APPLICATION_PRIVATE" + chown_folder "$APPLICATION_PRIVATE" + + echo "Deploying new build (Public)" + cp -a "./public/"* "$APPLICATION_PUBLIC" + svncleanup "$APPLICATION_PUBLIC" + chown_folder "$APPLICATION_PUBLIC" + + + chmod -R a+x "$APPLICATION_BINARY_PATH" + chmod -R a+x "$APPLICATION_CRON_PATH" + chmod -R a+x "$APPLICATION_TASK_PATH" +} + + + +# Deploya il progetto e mantiene solo la configurazione di produzione +function deploy_production_env(){ + create_project_fs + deploy + if [[ -f "$APPLICATION_CONFIG_PATH/config.local.php" ]];then + rm "$APPLICATION_CONFIG_PATH/config.local.php" + fi + if [[ -f "$APPLICATION_CONFIG_PATH/config.test.php" ]];then + rm "$APPLICATION_CONFIG_PATH/config.test.php" + fi +} + +# Deploya il progetto e mantiene solo la configurazione del server di test +function deploy_test_env(){ + create_project_fs + deploy + if [[ -f "$APPLICATION_CONFIG_PATH/config.local.php" ]];then + rm "$APPLICATION_CONFIG_PATH/config.local.php" + fi + if [[ -f "$APPLICATION_CONFIG_PATH/config.prod.php" ]];then + rm "$APPLICATION_CONFIG_PATH/config.prod.php" + fi +} + +# Deploya il progetto e mantiene solo la configurazione locale +function deploy_local_env(){ + create_project_fs + deploy + if [[ -f "$APPLICATION_CONFIG_PATH/config.prod.php" ]];then + rm "$APPLICATION_CONFIG_PATH/config.prod.php" + fi + if [[ -f "$APPLICATION_CONFIG_PATH/config.test.php" ]];then + rm "$APPLICATION_CONFIG_PATH/config.test.php" + fi +} + +function database_rebuild_content(){ + echo "Function not implemented... faking execution" + for collection_name in "${!MONGO_DB_CONTENT_COLLECTIONS[@]}"; do + echo "Rebuilding collection $collection_name - ${MONGO_DB_CONTENT_COLLECTIONS["$collection_name"]}"; + done + + for table_name in "${!MYSQL_DB_CONTENT_TABLES[@]}"; do + echo "Rebuilding table '$table_name' using query '${MYSQL_DB_CONTENT_TABLES["$table_name"]}'"; + done +} + +function database_rebuild_config(){ + echo "Function not implemented... faking execution" + for collection_name in "${!MONGO_DB_CONFIG_COLLECTIONS[@]}"; do + echo "Rebuilding collection $collection_name - ${MONGO_DB_CONFIG_COLLECTIONS["$collection_name"]}"; + done + + for table_name in "${!MYSQL_DB_CONFIG_TABLES[@]}"; do + echo "Rebuilding table '$table_name' using query '${MYSQL_DB_CONFIG_TABLES["$table_name"]}'"; + done +} + +function database_add_missing(){ + echo "Function not implemented... faking execution" + for collection_name in "${!MONGO_DB_CONFIG_COLLECTIONS[@]}"; do + echo "Checking collection $collection_name - ${MONGO_DB_CONFIG_COLLECTIONS["$collection_name"]}"; + done + + for table_name in "${!MYSQL_DB_CONFIG_TABLES[@]}"; do + echo "Checking table '$table_name' using query '${MYSQL_DB_CONFIG_TABLES["$table_name"]}'"; + done +} + + + +# Droppa e ricrea solo le tabelle dei dati +function regenerate_db(){ + EXDIR=`pwd` + cd "$APPLICATION_BINARY_PATH" + + ./createDatabase + DBCONN=`./getDbConnectionString` + + QUERY="CREATE TABLE campagna (id bigint auto_increment PRIMARY KEY, nome VARCHAR(64), owner bigint not null, creation_date TIMESTAMP default CURRENT_TIMESTAMP, current boolean default false, deleted boolean default false)" + TABNAME="campagna" + EXISTS=`echo "show tables" | $DBCONN | grep "$TABNAME" | wc -l` + if [[ "$EXISTS" -gt 0 ]];then + echo "Dropping table $TABNAME" + echo "DROP TABLE $TABNAME" | $DBCONN + fi + echo "Executing query '$QUERY'" + echo $QUERY | $DBCONN + + QUERY="CREATE TABLE personaggio ( id bigint auto_increment PRIMARY KEY, deleted boolean default false, campagna bigint, active boolean default true, nome varchar(128), giocatore varchar(128), vita_cur smallint, vita_max smallint, forza tinyint unsigned, destrezza tinyint unsigned, costituzione tinyint unsigned, intelligenza tinyint unsigned, saggezza tinyint unsigned, carisma tinyint unsigned, ts_tempra smallint, ts_tempra_note varchar(128), ts_riflessi smallint, ts_riflessi_note varchar(128), ts_volonta smallint, ts_volonta_note varchar(128), ca_base tinyint, ca_contatto tinyint, ca_sprovvista tinyint, iniziativa int not null default 0, ascoltare int, ascoltare_note varchar(128), cercare int, cercare_note varchar(128), diplomazia int, diplomazia_note varchar(128), muov_sil int, muov_sil_note varchar(128), nascondersi int, nascondersi_note varchar(128), osservare int, osservare_note varchar(128), perc_intenz int, perc_intenz_note varchar(128), raggirare int, raggirare_note varchar(128), valutare int, valutare_note varchar(128), conoscenze varchar(256), lingue varchar(256), melee_atk_short varchar(512), melee_atk_complete varchar(512), ranged_atk_short varchar(512), ranged_atk_complete varchar(512), unarmed_atk_short varchar(512), unarmed_atk_complete varchar(512), resist_incant smallint default 0, combat_note varchar(512), details TEXT, INDEX(campagna) )" + TABNAME="personaggio" + EXISTS=`echo "show tables" | $DBCONN | grep "$TABNAME" | wc -l` + if [[ "$EXISTS" -gt 0 ]];then + echo "Dropping table $TABNAME" + echo "DROP TABLE $TABNAME" | $DBCONN + fi + echo "Executing query '$QUERY'" + echo $QUERY | $DBCONN + + + QUERY="CREATE TABLE npc( id bigint auto_increment PRIMARY KEY, deleted boolean default false, nome varchar(128), tipo varchar(128), dadi_vita smallint, vita_max smallint, allineamento varchar(32), grado_sfida smallint, forza tinyint unsigned, destrezza tinyint unsigned, costituzione tinyint unsigned, intelligenza tinyint unsigned, saggezza tinyint unsigned, carisma tinyint unsigned, ts_tempra smallint, ts_tempra_note varchar(128), ts_riflessi smallint, ts_riflessi_note varchar(128), ts_volonta smallint, ts_volonta_note varchar(128), ca_base tinyint, ca_contatto tinyint, ca_sprovvista tinyint, iniziativa int not null default 0, ascoltare int, ascoltare_note varchar(128), cercare int, cercare_note varchar(128), muov_sil int, muov_sil_note varchar(128), nascondersi int, nascondersi_note varchar(128), osservare int, osservare_note varchar(128), perc_intenz int, perc_intenz_note varchar(128), raggirare int, raggirare_note varchar(128), valutare int, valutare_note varchar(128), conoscenze varchar(256), lingue varchar(256), melee_atk_short varchar(512), melee_atk_complete varchar(512), ranged_atk_short varchar(512), ranged_atk_complete varchar(512), unarmed_atk_short varchar(512), unarmed_atk_complete varchar(512), resist_incant smallint default 0, combat_note varchar(512), details TEXT )" + TABNAME="npc" + EXISTS=`echo "show tables" | $DBCONN | grep "$TABNAME" | wc -l` + if [[ "$EXISTS" -gt 0 ]];then + echo "Dropping table $TABNAME" + echo "DROP TABLE $TABNAME" | $DBCONN + fi + echo "Executing query '$QUERY'" + echo $QUERY | $DBCONN + + cd "$EXDIR" +} + +# Droppa e ricrea le tabelle base (tipo admin e config) +function regenerate_db_hard(){ + EXDIR=`pwd` + cd "$APPLICATION_BINARY_PATH" + + ./createDatabase + DBCONN=`./getDbConnectionString` + + + QUERY="CREATE TABLE general_configuration (config_key varchar(128) primary key, config_value varchar(128), INDEX(config_key))" + TABNAME="general_configuration" + EXISTS=`echo "show tables" | $DBCONN | grep "$TABNAME" | wc -l` + if [[ "$EXISTS" -gt 0 ]];then + echo "Dropping table $TABNAME" + echo "DROP TABLE $TABNAME" | $DBCONN + fi + echo "Executing query '$QUERY'" + echo $QUERY | $DBCONN + + + QUERY="CREATE TABLE user (id bigint auto_increment PRIMARY KEY, login varchar(64) not null, password varchar(64) not null, last_session_id varchar(64) default null, is_admin boolean not null default false, INDEX(login), INDEX(last_session_id))" + TABNAME="user" + EXISTS=`echo "show tables" | $DBCONN | grep "$TABNAME" | wc -l` + if [[ "$EXISTS" -gt 0 ]];then + echo "Dropping table $TABNAME" + echo "DROP TABLE $TABNAME" | $DBCONN + fi + echo "Executing query '$QUERY'" + echo $QUERY | $DBCONN + + + cd "$EXDIR" +} + + + diff --git a/private/common/config.php b/private/common/config.php index bc20133..be65f7d 100644 --- a/private/common/config.php +++ b/private/common/config.php @@ -24,6 +24,12 @@ else{ // Generic voices $config = new stdClass(); +$config->info = new stdClass(); +$config->info->projectName = "I Fatti di Napoli"; +$config->info->projectDescription = "Il giornale della terza metropoli italiana"; +$config->info->owner = "Antonio Pianelli"; +$config->info->author = "ASDynamics"; + $config->locale = new stdClass(); $config->locale->gui = $project->defaultLocale; $config->locale->system = $project->defaultLocale; diff --git a/private/crontab/core.minute.php b/private/crontab/core.minute.php index b2cdfc4..c7dd3a8 100644 --- a/private/crontab/core.minute.php +++ b/private/crontab/core.minute.php @@ -8,14 +8,15 @@ Creation Date: 12/gen/2016 require_once(dirname(__FILE__). "/../load.php"); try { - $task = "test"; - SystemController::executeTask("$task.php"); + if (TestTask::isActive()){ + TestTask::execute(); + } }catch (CoreException $ex){ - $msg = "Error while executing task '$task' with message '".$ex->getMessage()."'"; + $msg = "Error while executing task '".TestTask::getLabel()."' with message '".$ex->getMessage()."'"; LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg); } catch (Exception $ex){ - $msg = "Unexpected error while executing task '$task' with message '".$ex->getMessage()."'"; + $msg = "Unexpected error while executing task '".TestTask::getLabel()."' with message '".$ex->getMessage()."'"; LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg); } diff --git a/private/lib/dao/DaoSaveableDefaultImplementation.php b/private/lib/dao/DaoSaveableDefaultImplementation.php index 910af05..8b10c44 100644 --- a/private/lib/dao/DaoSaveableDefaultImplementation.php +++ b/private/lib/dao/DaoSaveableDefaultImplementation.php @@ -16,10 +16,19 @@ abstract class DaoSaveableDefaultImplementation implements DaoSaveable { } public function __set($attr,$value){ + if (strcmp($attr,"id")==0){ + $attr = "_id"; + if (!($value instanceof MongoId)){ + $value = new MongoId($value); + } + } $this->saveableObject->$attr = $value; } public function &__get($attr){ + if (strcmp($attr,"id")==0){ + $attr = "_id"; + } $rval = &$this->saveableObject->$attr; return $rval; } @@ -28,6 +37,13 @@ abstract class DaoSaveableDefaultImplementation implements DaoSaveable { unset($this->saveableObject->$attr); } + public function hasProperty($attr){ + if (strcmp($attr,"id")==0){ + $attr = "_id"; + } + return property_exists($this->saveableObject, $attr); + } + /** * (non-PHPdoc) * @see DaoSaveable::getSaveableObj() @@ -69,6 +85,9 @@ abstract class DaoSaveableDefaultImplementation implements DaoSaveable { */ public function updateFromSaveableObj($saveableObject){ $this->saveableObject = $this->toObject($saveableObject); + if (!property_exists($this->saveableObject, "deleted")){ + $this->saveableObject->deleted = false; + } // $this->saveableObject = $saveableObject; } diff --git a/private/lib/dao/GenericDao.php b/private/lib/dao/GenericDao.php index 5d1fa95..1b99fba 100644 --- a/private/lib/dao/GenericDao.php +++ b/private/lib/dao/GenericDao.php @@ -61,12 +61,22 @@ class GenericDao{ $rval = array(); foreach ($cursor as $element){ - var_dump($element); $rval[] = $modelClass::buildFromSaveableObj($element); } return $rval; } + + public function getFirst($modelClass, array $filter = array(), array $options = array()){ + $rval = $this->query($modelClass,$filter,$options); + if (sizeof($rval)>0){ + $rval = reset($rval); + } + else { + $rval = null; + } + return $rval; + } public function save(DaoSaveable $model){ @@ -75,7 +85,7 @@ class GenericDao{ $saveObj = $model->getSaveableObj(); - if ( !is_null($saveObj["_id"]) ){ + if ( array_key_exists("_id", $saveObj) && !is_null($saveObj["_id"]) ){ $collection->update( array("_id"=>$saveObj["_id"] ), $saveObj ); } else { diff --git a/private/lib/dao/lib.inclusion.php b/private/lib/dao/lib.inclusion.php index 58e89e3..908c27b 100644 --- a/private/lib/dao/lib.inclusion.php +++ b/private/lib/dao/lib.inclusion.php @@ -13,7 +13,10 @@ require_once(dirname(__FILE__)."/GenericDao.php"); require_once(dirname(__FILE__)."/Model.php"); +require_once(dirname(__FILE__)."/models/ConfigModel.php"); +require_once(dirname(__FILE__)."/models/TaskModel.php"); require_once(dirname(__FILE__)."/models/NotiziaModel.php"); +require_once(dirname(__FILE__)."/models/AdminModel.php"); $dao = new GenericDao($database->dbName,$database->connectionString); GlobalVariables::set("dao", $dao); diff --git a/private/lib/dao/models/AdminModel.php b/private/lib/dao/models/AdminModel.php new file mode 100644 index 0000000..80ce434 --- /dev/null +++ b/private/lib/dao/models/AdminModel.php @@ -0,0 +1,63 @@ + array("label"=>"Editore") + ); + + public static $ROLE_SUPERADMIN_HANDLED = array( + self::ADMIN_TYPE_BANNER => array("label"=>"Banner"), + self::ADMIN_TYPE_ROLEADMIN => array("label"=>"Amministratore"), + self::ADMIN_TYPE_COMMENTI => array("label"=>"Commenti"), + self::ADMIN_TYPE_STATISTICHE => array("label"=>"Statistiche"), + self::ADMIN_TYPE_NEWSLETTER => array("label"=>"Newsletter"), + self::ADMIN_TYPE_SONDAGGI => array("label"=>"Sondaggi"), + self::ADMIN_TYPE_EDITORE => array("label"=>"Editore"), + self::ADMIN_TYPE_EDITORE_SUPERVISOR => array("label"=>"Supervisione Editori") + ); + + + public function __construct($saveableObject = null){ + parent::__construct($saveableObject); + if (!$this->hasProperty("roles")){ + $this->roles = false; + } + } + + public static function getCollectionName(){ + return "administrators"; + } + + public function hasRole($role){ + return $role & $this->role == $role; + } + + public function addRole($role){ + $this->role = $this->role | $role; + } + + public function removeRole($role){ + $this->role = $this->role & ~$role; + } + + public function setRole($role){ + $this->role = $role; + } + +} + +?> \ No newline at end of file diff --git a/private/lib/dao/models/ConfigModel.php b/private/lib/dao/models/ConfigModel.php new file mode 100644 index 0000000..6cec19d --- /dev/null +++ b/private/lib/dao/models/ConfigModel.php @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/private/lib/dao/models/TaskModel.php b/private/lib/dao/models/TaskModel.php new file mode 100644 index 0000000..df24ff8 --- /dev/null +++ b/private/lib/dao/models/TaskModel.php @@ -0,0 +1,22 @@ +hasProperty("isActive")){ + $this->isActive = false; + } + } + + public static function getCollectionName(){ + return "task"; + } + +} + +?> \ No newline at end of file diff --git a/private/lib/gui/ASDSessionHandler.php b/private/lib/gui/ASDSessionHandler.php new file mode 100644 index 0000000..d714f8e --- /dev/null +++ b/private/lib/gui/ASDSessionHandler.php @@ -0,0 +1,48 @@ + \ No newline at end of file diff --git a/private/lib/gui/GUIHandler.php b/private/lib/gui/GUIHandler.php new file mode 100644 index 0000000..3e92e22 --- /dev/null +++ b/private/lib/gui/GUIHandler.php @@ -0,0 +1,50 @@ +info->projectName; + if (array_key_exists("title", $data)){ + $title = $data["title"]; + } + + $description = $conf->info->projectDescription; + if (array_key_exists("description", $data)){ + $description = $data["description"]; + } + + $author = $conf->info->author; + if (array_key_exists("author", $data)){ + $author = $data["author"]; + } + + header("Content-type: text/html; charset=utf-8"); + + echo "\n"; + echo "\n\n"; + echo "\n"; + echo "$title\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + echo ''."\n"; +// foreach (self::$inclusions as $incl){ +// $incl->render(); +// } + echo ''; + } + + public static function getImagesUrl(){ + return "./images"; + } + +} + +?> \ No newline at end of file diff --git a/private/lib/gui/PostHandler.php b/private/lib/gui/PostHandler.php new file mode 100644 index 0000000..ff89ba0 --- /dev/null +++ b/private/lib/gui/PostHandler.php @@ -0,0 +1,33 @@ +"; +// } + } + return $rval; + } + + public static function getComplete($exclude = array()){ + $rval = array(); + if (sizeof($_POST)>0){ + foreach ($_POST as $key=>$val){ + $rval[$key] = self::get($key,in_array($key,$exclude)); + } + } + return $rval; + } + +} + +?> \ No newline at end of file diff --git a/private/lib/gui/lib.inclusion.php b/private/lib/gui/lib.inclusion.php index 9c75b68..4b4e870 100644 --- a/private/lib/gui/lib.inclusion.php +++ b/private/lib/gui/lib.inclusion.php @@ -5,12 +5,15 @@ Creation Date: 07/gen/2016 */ // Include GUI Handler -// require_once(dirname(__FILE__)."/gui/GUIHandler.php"); // require_once(dirname(__FILE__)."/gui/ThumbnailGenerator.php"); + require_once(dirname(__FILE__)."/CatalogManager.php"); require_once(dirname(__FILE__)."/StaticCatalogManager.php"); -// require_once(dirname(__FILE__)."/LoginManager.php"); +require_once(dirname(__FILE__)."/GUIHandler.php"); +require_once(dirname(__FILE__)."/PostHandler.php"); + +require_once(dirname(__FILE__)."/ASDSessionHandler.php"); // GUIHandler::setCatalogManager(new StaticCatalogManager($catalog[$config->locale->gui])); diff --git a/private/lib/gui/loginManager/AdminLoginManager.php b/private/lib/gui/loginManager/AdminLoginManager.php new file mode 100644 index 0000000..cf22142 --- /dev/null +++ b/private/lib/gui/loginManager/AdminLoginManager.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/private/lib/gui/loginManager/UserLoginManager.php b/private/lib/gui/loginManager/UserLoginManager.php new file mode 100644 index 0000000..3d3d40e --- /dev/null +++ b/private/lib/gui/loginManager/UserLoginManager.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/private/lib/lib.inclusions.php b/private/lib/lib.inclusions.php index 8234d8a..ab379af 100644 --- a/private/lib/lib.inclusions.php +++ b/private/lib/lib.inclusions.php @@ -29,6 +29,8 @@ require_once(dirname(__FILE__)."/system/lib.inclusion.php"); require_once(dirname(__FILE__)."/dao/lib.inclusion.php"); +require_once(dirname(__FILE__)."/task/lib.inclusion.php"); + // require_once(dirname(__FILE__)."/media/lib.inclusion.php"); // asdasdasd diff --git a/private/lib/system/SystemController.php b/private/lib/system/SystemController.php index d3af86f..9e1b46f 100644 --- a/private/lib/system/SystemController.php +++ b/private/lib/system/SystemController.php @@ -37,10 +37,10 @@ class SystemController { return self::shellExec($binpath."/".$cmdName,$cmdParams,$sudo); } - public static function executeTask($cmdName,$cmdParams="",$sudo=false){ - $basePath = GlobalVariables::get("config")->paths->task; - return self::shellExec($basePath."/".$cmdName,$cmdParams,$sudo); - } +// public static function executeTask($cmdName,$cmdParams="",$sudo=false){ +// $basePath = GlobalVariables::get("config")->paths->task; +// return self::shellExec($basePath."/".$cmdName,$cmdParams,$sudo); +// } public static function mountRo($path) { return self::executeCustomCommand("mountro",'"'.$path.'"'); diff --git a/private/lib/task/Task.php b/private/lib/task/Task.php new file mode 100644 index 0000000..6e8fda0 --- /dev/null +++ b/private/lib/task/Task.php @@ -0,0 +1,38 @@ +isActive; + } + + public static function setActive($state){ + $model = static::getModel(); + $model->isActive = $state; + GlobalVariables::get("dao")->save($model); + } + + protected static function getModel(){ + $dao = GlobalVariables::get("dao"); + $model = $dao->getFirst("TaskModel",array("name"=>static::getName())); + if (is_null($model)){ + $saveable = array(); + $saveable["name"] = static::getName(); + $model = new TaskModel($saveable); + } + return $model; + } +} + +?> \ No newline at end of file diff --git a/private/lib/task/TestTask.php b/private/lib/task/TestTask.php new file mode 100644 index 0000000..f51ca37 --- /dev/null +++ b/private/lib/task/TestTask.php @@ -0,0 +1,21 @@ +log(LoggingFacility::$LEVEL_DEBUG,"Execution of task '".self::getLabel()."'"); + } +} + +?> \ No newline at end of file diff --git a/private/lib/task/lib.inclusion.php b/private/lib/task/lib.inclusion.php new file mode 100644 index 0000000..d82d4e7 --- /dev/null +++ b/private/lib/task/lib.inclusion.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/private/task/test.php b/private/task/test.php deleted file mode 100644 index 9cd6998..0000000 --- a/private/task/test.php +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/php -log(LoggingFacility::$LEVEL_DEBUG,"Execution of task 'test' begins"); - echo "OK"; - LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_DEBUG,"Execution of task 'test' completed"); -}catch (CoreException $ex){ - $msg = "Error while executing task '$task' with message '".$ex->getMessage()."'"; - LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg); -} -catch (Exception $ex){ - $msg = "Unexpected error while executing task '$task' with message '".$ex->getMessage()."'"; - LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg); -} - -?> \ No newline at end of file diff --git a/public/admin/index.php b/public/admin/index.php new file mode 100644 index 0000000..be96694 --- /dev/null +++ b/public/admin/index.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/public/admin/login.php b/public/admin/login.php new file mode 100644 index 0000000..965c7bd --- /dev/null +++ b/public/admin/login.php @@ -0,0 +1,60 @@ +getFirst("AdminModel",array("username"=>$username,"password"=>sha1($pass))); + if (!LoginManager::loginUser($username,$pass)){ + $errMsg = "Invalid Data"; + } + else { + GUIHandler::changeLocation($config->pages->index); + } + } +} +echo ''; +GUIHandler::generateLoadingOverlay(); + +?> +
+
+ +
+
+

Login

+
+
+
+
+
+ +
+ +
+
+ +
+
+ Login +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/public/admin/logout.php b/public/admin/logout.php new file mode 100644 index 0000000..4ecede3 --- /dev/null +++ b/public/admin/logout.php @@ -0,0 +1,9 @@ + diff --git a/public/index.php b/public/index.php index 0f9d034..db0b2e5 100644 --- a/public/index.php +++ b/public/index.php @@ -8,6 +8,8 @@ require_once(dirname(__FILE__)."/load.php"); try { // var_dump($dao->query("notizia")); + TestTask::setActive(false); + echo "

"; $models = $dao->query("NotiziaModel"); $model = reset($models); @@ -21,6 +23,13 @@ try { $model->immagini[] = "2.jpg"; $model->about->giorno = "boh"; + if ($model->hasProperty("about")){ + echo "esiste"; + } + else { + echo "non esiste"; + } + var_dump($model); echo "

";