diff --git a/.build.config b/.build.config new file mode 100644 index 0000000..624c11f --- /dev/null +++ b/.build.config @@ -0,0 +1,39 @@ +#!/bin/bash +PROJECT_NAME="I Fatti di Napoli 2.0" +APPLICATION_BUILDNAME="fdn2" + +########################### +####### APACHE DATA ####### +########################### +APACHE2_USER="www-data" +APACHE2_GROUP="www-data" +APACHE2_DOCUMENTROOT="/var/www" + + +########################### +##### SYSTEM DETAILS ###### +########################### +SYSTEM_LOG_PATH="/var/log/asdynamics" +SYSTEM_PRIVATE="/home/asdynamics/private" +SYSTEM_STORAGE="/home/asdynamics/storage" + + +################################### +##### APPLICATION ESSENTIALS ###### +################################### +APPLICATION_PUBLIC="$APACHE2_DOCUMENTROOT/$APPLICATION_BUILDNAME" +APPLICATION_PRIVATE="$SYSTEM_PRIVATE/$APPLICATION_BUILDNAME" +APPLICATION_STORAGE="$SYSTEM_STORAGE/$APPLICATION_BUILDNAME" + +APPLICATION_LOG_PATH="$SYSTEM_LOG_PATH/$APPLICATION_BUILDNAME" +APPLICATION_XSENDFILE_PATH="/tmp/xsend/$APPLICATION_BUILDNAME" + + +#################################### +##### OTHER APPLICATION PATHS ###### +#################################### +APPLICATION_MEDIA_PATH="$APPLICATION_STORAGE/media" +APPLICATION_BACKUPS_PATH="$APPLICATION_STORAGE/backups" +APPLICATION_TMP_PATH="$APPLICATION_STORAGE/tmp" +APPLICATION_CONFIG_PATH="$APPLICATION_PRIVATE/common" +APPLICATION_BINARY_PATH="$APPLICATION_PRIVATE/bin" diff --git a/.build_db.config b/.build_db.config new file mode 100644 index 0000000..92fa58a --- /dev/null +++ b/.build_db.config @@ -0,0 +1,59 @@ +#!/bin/bash + +########################### +#### MYSQL DATABASES ###### +########################### +MYSQL_CONNECTION_STRING="" + +declare -A MYSQL_DB_CONTENT_TABLES +declare -A MYSQL_DB_CONFIG_TABLES + +MYSQL_DB_CONTENT_TABLES=() +MYSQL_DB_CONFIG_TABLES=() + +while read line || [ -n "$line" ]; +do + if echo $line | grep -P "([=][>]).*([=][>])" &>/dev/null + then + group=$(echo "$line" | sed -r 's/^\s*(\S+)\s*[=][>]\s*(\S+)\s*[=][>]\s*(.+)$/\1/') + table=$(echo "$line" | sed -r 's/^\s*(\S+)\s*[=][>]\s*(\S+)\s*[=][>]\s*(.+)$/\2/') + query=$(echo "$line" | sed -r 's/^\s*(\S+)\s*[=][>]\s*(\S+)\s*[=][>]\s*(.+)$/\3/') + if [ "$group" = "content" ]; then + MYSQL_DB_CONTENT_TABLES["$table"]="$query" + elif [ "$group" = "config" ]; then + MYSQL_DB_CONFIG_TABLES["$table"]="$query" + fi + fi +done < dbCreation.mysql + + +#MYSQL_DB_CONTENT_TABLES=( ["tizi"]="create table tizi" ["posti"]="create table posti" ) + + +########################### +#### MONGO DATABASES ###### +########################### +MONGO_CONNECTION_STRING="" + +declare -A MONGO_DB_CONTENT_COLLECTIONS +declare -A MONGO_DB_CONFIG_COLLECTIONS + +MONGO_DB_CONTENT_COLLECTIONS=() +MONGO_DB_CONFIG_COLLECTIONS=() + +while read line || [ -n "$line" ]; +do + if echo $line | grep -P "([=][>]).*([=][>])" &>/dev/null + then + group=$(echo "$line" | sed -r 's/^\s*(\S+)\s*[=][>]\s*(\S+)\s*[=][>]\s*(.+)$/\1/') + table=$(echo "$line" | sed -r 's/^\s*(\S+)\s*[=][>]\s*(\S+)\s*[=][>]\s*(.+)$/\2/') + query=$(echo "$line" | sed -r 's/^\s*(\S+)\s*[=][>]\s*(\S+)\s*[=][>]\s*(.+)$/\3/') + if [ "$group" = "content" ]; then + MONGO_DB_CONTENT_COLLECTIONS["$table"]="$query" + elif [ "$group" = "config" ]; then + MONGO_DB_CONFIG_COLLECTIONS["$table"]="$query" + fi + fi +done < dbCreation.mongo + + diff --git a/build b/build new file mode 100755 index 0000000..5dbd7fe --- /dev/null +++ b/build @@ -0,0 +1,145 @@ +#!/bin/bash + +########### +# Lo script utilizza tre possibili environment: Produzione, Test e Locale +# Permette cinque operazioni su database: Drop and rebuild all, Drop and rebuild all content, Drop and rebuild config, Add missing tables e Skip +########### + +source "buildLibs" + +OPTION_HELP=false # -h + +ENVIRONMENT_PRODUCTION=false # -p +ENVIRONMENT_TEST=false # -t +ENVIRONMENT_LOCAL=false # -l + +DATABASE_DROP_ALL=false # -D +DATABASE_DROP_CONTENT=false # -C +DATABASE_DROP_CONFIG=false # -c +DATABASE_FIX=false # -f +DATABASE_SKIP=false # -s + +DEFAULT_CONFIG_FILE=".build.config" + +DEFAULT_DATABASE_FILE=".build_db.config" + +USE_CONFIG_FILE="$DEFAULT_CONFIG_FILE" +USE_DATABASE_FILE="$DEFAULT_DATABASE_FILE" + +while getopts ":hptlDCcfs" optname +do + case "$optname" in + "h") + OPTION_HELP=true + ;; + "p") + ENVIRONMENT_PRODUCTION=true + ;; + "t") + ENVIRONMENT_TEST=true + ;; + "l") + ENVIRONMENT_LOCAL=true + ;; + "D") + DATABASE_DROP_ALL=true + ;; + "C") + DATABASE_DROP_CONTENT=true + ;; + "c") + DATABASE_DROP_CONFIG=true + ;; + "f") + DATABASE_FIX=true + ;; + "s") + DATABASE_SKIP=true + ;; + "?") + echo "Invalid option -$OPTARG" + ;; + ":") + echo "No argument value for option $OPTARG" + ;; + *) + # Should not occur + echo "Unknown error while processing options" + ;; + esac +done + +if [ "$ENVIRONMENT_PRODUCTION" = false ] && [ "$ENVIRONMENT_TEST" = false ] && [ "$ENVIRONMENT_LOCAL" = false ]; then + OPTION_HELP=true +fi + +if [ $OPTION_HELP = true ]; then + help + exit 0 +fi + +shift $(($OPTIND - 1)) + +if [ "$1" != "" ]; then + USE_CONFIG_FILE="$1" +fi + +if [ -f "$USE_CONFIG_FILE" ]; then + source "$USE_CONFIG_FILE" +else + printf "Impossibile Leggere il file di configurazione '$USE_CONFIG_FILE')\n" + exit 1 +fi + +if [ -f "$USE_DATABASE_FILE" ]; then + source "$USE_DATABASE_FILE" +else + printf "Impossibile Leggere il file di configurazione del database '$USE_DATABASE_FILE')\n" + exit 1 +fi + +if [ ! -w "$APACHE2_DOCUMENTROOT" ] || [ ! -w "$SYSTEM_PRIVATE" ] || [ ! -w "$SYSTEM_STORAGE" ] || [ ! -w "$SYSTEM_LOG_PATH" ]; then + printf "Permessi insufficienti per eseguire lo script (sudo?)\n" + if [ ! -w "$APACHE2_DOCUMENTROOT" ]; then + printf "Impossibile scrivere in '$APACHE2_DOCUMENTROOT'\n" + fi + if [ ! -w "$SYSTEM_PRIVATE" ]; then + printf "Impossibile scrivere in '$SYSTEM_PRIVATE'\n" + fi + if [ ! -w "$SYSTEM_STORAGE" ]; then + printf "Impossibile scrivere in '$SYSTEM_STORAGE'\n" + fi + if [ ! -w "$SYSTEM_LOG_PATH" ]; then + printf "Impossibile scrivere in '$SYSTEM_LOG_PATH'\n" + fi + exit 1 +fi + + +printf "Asdynamics Application Build/Deploy Script\n" +if [ -f .logo ]; then + cat .logo +fi + +if [ "$ENVIRONMENT_PRODUCTION" = true ]; then + deploy_production_env +elif [ "$ENVIRONMENT_TEST" = true ]; then + deploy_test_env +elif [ "$ENVIRONMENT_LOCAL" = true ]; then + deploy_local_env +fi + +if [ "$DATABASE_DROP_ALL" = true ]; then + database_rebuild_content + database_rebuild_config +elif [ "$DATABASE_DROP_CONTENT" = true ]; then + database_rebuild_content +elif [ "$DATABASE_DROP_CONFIG" = true ]; then + database_rebuild_config +elif [ "$DATABASE_FIX" = true ]; then + database_add_missing +elif [ "$DATABASE_SKIP" = false ]; then + database_add_missing +fi + + diff --git a/buildLibs b/buildLibs new file mode 100644 index 0000000..138db39 --- /dev/null +++ b/buildLibs @@ -0,0 +1,271 @@ +#!/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" +} + + + +# 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.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 +} + +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/dbCreation.mongo b/dbCreation.mongo new file mode 100644 index 0000000..2467de6 --- /dev/null +++ b/dbCreation.mongo @@ -0,0 +1,3 @@ +content => persone => persone +content => luoghi => luoghi +config => configuration => the_configuration \ No newline at end of file diff --git a/dbCreation.mysql b/dbCreation.mysql new file mode 100644 index 0000000..24cb689 --- /dev/null +++ b/dbCreation.mysql @@ -0,0 +1,3 @@ +content => tizi => create table tizi +content => posti => create table posti +config => configz => create table configz \ No newline at end of file diff --git a/private/bin/cronexec b/private/bin/cronexec new file mode 100644 index 0000000..b4eaafd --- /dev/null +++ b/private/bin/cronexec @@ -0,0 +1,25 @@ +#!/bin/bash + +if [ -z "$1" ]; +then + echo "Missing specifier" + exit 1 +fi + +if [ "$1" == "5minutes" ] || [ "$1" == "minute" ] || [ "$1" == "daily" ] || [ "$1" == "hourly" ] || [ "$1" == "monthly" ] || [ "$1" == "weekly" ]; +then + BASEDIR=`pwd` + cd /eam/crontab/ + logger "CRONEXEC Executing $1 tasks" + + for i in `ls | grep -P "\.$1\."` + do + logger "Executing $i" + RESULT=`./$i` + logger "$RESULT" + done + cd "$BASEDIR" +else + echo "Invalid specifier $1" + exit 1 +fi diff --git a/private/lib/CoreException.php b/private/lib/CoreException.php new file mode 100644 index 0000000..887234b --- /dev/null +++ b/private/lib/CoreException.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/private/lib/dao/GenericDao.php b/private/lib/dao/GenericDao.php new file mode 100644 index 0000000..05c778c --- /dev/null +++ b/private/lib/dao/GenericDao.php @@ -0,0 +1,64 @@ +getTable($name); + + $query = new MongoDB\Driver\Query($filter, $options); + $cursor = $this->mongo->executeQuery($collectionName,$query); + + foreach ($cursor as $ele){ + $rval[] = new Model($ele); + } + return $ele; + } + + public function save(Model $model){ + $bulk = new MongoDB\Driver\BulkWrite(['ordered' => false]); + $writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 1000); + + try { + $result = $manager->executeBulkWrite('db.collection', $bulk, $writeConcern); + } catch (MongoDB\Driver\Exception\BulkWriteException $e) { + + } + } + + public function delete(Model $model){ + + } + + /** + * Costruisce un oggetto mongo da passare al costruttore. + * + * @param string $connectionString + * @return \MongoDB\Driver\Manager + */ + private static function generateMongoObject($connectionString){ + return new MongoClient("mongodb://$connectionString"); +// return new MongoDB\Driver\Manager("mongodb://$connectionString"); + } +} + +?> \ No newline at end of file diff --git a/private/lib/dao/Model.php b/private/lib/dao/Model.php new file mode 100644 index 0000000..c590f44 --- /dev/null +++ b/private/lib/dao/Model.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 new file mode 100644 index 0000000..76b58b2 --- /dev/null +++ b/private/lib/lib.inclusions.php @@ -0,0 +1,66 @@ + \ No newline at end of file diff --git a/private/lib/lib.instances.php b/private/lib/lib.instances.php new file mode 100644 index 0000000..22957ae --- /dev/null +++ b/private/lib/lib.instances.php @@ -0,0 +1,143 @@ +locale->gui); + +GUIHandler::setSystemUrl($config->systemUrl); + +GUIHandler::setCatalogManager(new StaticCatalogManager($catalog[$config->locale->gui])); +$systemCatalogManager = new StaticCatalogManager($catalog[$config->locale->system]); + +require_once(dirname(__FILE__)."/../common/html.include.php"); + +// // _____ ____ ___ +// // | ___/ ___| / _ \ +// // | |_ \___ \| | | | +// // | _| ___) | |_| | +// // |_| |____/ \___/ +// // +// SFSManager::addFilesystem(new LocallyMountedFS( +// FSObject::$DEVICE_TYPE_HARD_DRIVE, +// FSObject::$WRITELAW_NOT_WRITEABLE, +// LocallyMountedFS::$ACCESSMODE_RO, +// "/", +// "Root Filesystem") +// ); +// SFSManager::addFilesystem(new LocallyMountedFS( +// FSObject::$DEVICE_TYPE_HARD_DRIVE, +// FSObject::$WRITELAW_NORMALLY_W, +// LocallyMountedFS::$ACCESSMODE_RW, +// $config->paths->log, +// "Log Filesystem") +// ); +// SFSManager::addFilesystem(new LocallyMountedFS( +// FSObject::$DEVICE_TYPE_HARD_DRIVE, +// FSObject::$WRITELAW_NORMALLY_W, +// LocallyMountedFS::$ACCESSMODE_RW, +// $config->paths->backup, +// "Backups Filesystem") +// ); +// SFSManager::addFilesystem(new LocallyMountedFS( +// FSObject::$DEVICE_TYPE_HARD_DRIVE, +// FSObject::$WRITELAW_NORMALLY_W, +// LocallyMountedFS::$ACCESSMODE_RW, +// $config->paths->media, +// "Media Filesystem") +// ); +// SFSManager::addFilesystem(new LocallyMountedFS( +// FSObject::$DEVICE_TYPE_HARD_DRIVE, +// FSObject::$WRITELAW_NORMALLY_W, +// LocallyMountedFS::$ACCESSMODE_RW, +// $config->paths->tmp, +// "Temporary Filesystem") +// ); +// SFSManager::addFilesystem(new LocallyMountedFS( +// FSObject::$DEVICE_TYPE_HARD_DRIVE, +// FSObject::$WRITELAW_NORMALLY_W, +// LocallyMountedFS::$ACCESSMODE_RW, +// $config->paths->xsendfile, +// "XSendFile Filesystem") +// ); +// SFSManager::addFilesystem(new LocallyMountedFS( +// FSObject::$DEVICE_TYPE_HARD_DRIVE, +// FSObject::$WRITELAW_NORMALLY_W, +// LocallyMountedFS::$ACCESSMODE_RW, +// $config->paths->pubkey, +// "Public Keys Filesystem") +// ); +// SFSManager::addFilesystem(new LocallyMountedFS( +// FSObject::$DEVICE_TYPE_HARD_DRIVE, +// FSObject::$WRITELAW_NORMALLY_W, +// LocallyMountedFS::$ACCESSMODE_RW, +// $config->paths->sshDir, +// "SSH Configuration directory") +// ); + +// // _ +// // | | ___ __ _ __ _ ___ _ __ ___ +// // | | / _ \ / _` |/ _` |/ _ \ '__/ __| +// // | |__| (_) | (_| | (_| | __/ | \__ \ +// // |_____\___/ \__, |\__, |\___|_| |___/ +// // |___/ |___/ +// // +// LoggingFacilityManager::addLogger( +// "system", +// new SyslogLogger("Core",$systemCatalogManager,true) +// ); +// LoggingFacilityManager::getLogger("system")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG); + + +// LoggingFacilityManager::addLogger( +// "dao", +// new FileLogger("DAO",$systemCatalogManager,$config->files->dao_log,true) +// ); +// LoggingFacilityManager::getLogger("dao")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG); + + +// LoggingFacilityManager::addLogger( +// "saam", +// new FileLogger("SAAM",$systemCatalogManager,$config->files->saam_log,true) +// ); +// LoggingFacilityManager::getLogger("saam")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG); + + +// LoggingFacilityManager::addLogger( +// "task", +// new FileLogger("Task",$systemCatalogManager,$config->files->task_log,true) +// ); +// LoggingFacilityManager::getLogger("task")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG); + +// LoggingFacilityManager::addLogger( +// "general", +// new FileLogger("General",$systemCatalogManager,$config->files->general_log,true) +// ); +// LoggingFacilityManager::getLogger("general")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG); + + +// ____ _ ___ +// | _ \ / \ / _ \ +// | | | |/ _ \| | | | +// | |_| / ___ \ |_| | +// |____/_/ \_\___/ +// +new GeneralConfigurationDao($config->dbConnection); +new AdminDao($config->dbConnection); +new ClientDao($config->dbConnection,$config->paths->pubkey); +new BackupDao($config->dbConnection); + +ASDSessionHandler::regenerateContext(); + + +$checkPath = $config->paths->tmp."/backup"; +if (!file_exists($checkPath)){ + mkdir($checkPath,0751,true); +} +else if (!is_dir($checkPath)){ + die("Impossible to run cbs... cannot create directory '$checkPath' (a file with this name exists)"); +} + +?> \ No newline at end of file diff --git a/private/lib/logger/FileLogger.php b/private/lib/logger/FileLogger.php new file mode 100644 index 0000000..c4e3583 --- /dev/null +++ b/private/lib/logger/FileLogger.php @@ -0,0 +1,36 @@ +filePath = $filePath; + parent::__construct($name,$catalogManager,$usedate); + } + + protected function writelog($level,$message,&$data) { +// $translate_level = LOG_DEBUG; +// if($level == LoggingFacility::$LEVEL_ERROR) $translate_level = LOG_ERROR; +// else if($level == LoggingFacility::$LEVEL_WARNING) $translate_level = LOG_WARNING; +// else if ($level == LoggingFacility::$LEVEL_INFO) $translate_level = LOG_INFO; +// syslog($translate_level,$message); +// if (!SFSManager::fileExists($this->filePath)){ +// SFSManager::touchFile($this->filePath); +// } + SFSManager::appendToFile($message."\n",$this->filePath); + } + + protected function getIndicationForLevel($level) { + if($level == LoggingFacility::$LEVEL_ERROR) return " [ERROR] "; + else if($level == LoggingFacility::$LEVEL_WARNING) return " [WARNING] "; + else if ($level == LoggingFacility::$LEVEL_INFO) return " [INFO] "; + else return " [DEBUG] "; + } + +} + +?> \ No newline at end of file diff --git a/private/lib/logger/LoggingFacility.php b/private/lib/logger/LoggingFacility.php new file mode 100644 index 0000000..ec7947d --- /dev/null +++ b/private/lib/logger/LoggingFacility.php @@ -0,0 +1,61 @@ +myname = $name; + $this->useDate = $prependDate; + $this->mylevel = self::$LEVEL_ERROR; + $this->catalogManager = $catalogMan; + } + + + public function setLoggingLevel($level) { + if ($level < self::$LEVEL_ERROR) $this->mylevel = self::$LEVEL_ERROR; + else if ($level > self::$LEVEL_DEBUG) $this->mylevel = self::$LEVEL_DEBUG; + else $this->mylevel = $level; + } + + + public function log($level, $message, $data = null,$usecatalog = false) { + if($level <= $this->mylevel) { + if(!is_array($data)) $data = array($data); + if($usecatalog) $finalMessage = $this->catalogManager->getCatalog($message,$data); + else $finalMessage = $message; + if($this->useDate) { + $formattedDate = strftime($this->catalogManager->getCatalog("core.dateformat"),time()); + $finalMessage = $this->myname . " " . $this->getIndicationForLevel($level) + . " - " . $formattedDate . " > " . $finalMessage; + } + else { + $finalMessage = $this->myname . " " . $this->getIndicationForLevel($level) + . " > " . $finalMessage; + } + + $this->writelog($level,$finalMessage,$data); + } + } + + protected abstract function writelog($level,$message,&$data); + protected abstract function getIndicationForLevel($level); + + public function getName() { + return $this->myname; + } +} + +?> \ No newline at end of file diff --git a/private/lib/logger/LoggingFacilityManager.php b/private/lib/logger/LoggingFacilityManager.php new file mode 100644 index 0000000..c99f707 --- /dev/null +++ b/private/lib/logger/LoggingFacilityManager.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/private/lib/logger/SyslogLogger.php b/private/lib/logger/SyslogLogger.php new file mode 100644 index 0000000..74e7078 --- /dev/null +++ b/private/lib/logger/SyslogLogger.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/private/lib/logger/lib.inclusion.php b/private/lib/logger/lib.inclusion.php new file mode 100644 index 0000000..6a45fba --- /dev/null +++ b/private/lib/logger/lib.inclusion.php @@ -0,0 +1,53 @@ +setLoggingLevel(LoggingFacility::$LEVEL_DEBUG); + + +LoggingFacilityManager::addLogger( + "dao", + new FileLogger("DAO",$systemCatalogManager,$config->files->dao_log,true) +); +LoggingFacilityManager::getLogger("dao")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG); + + +LoggingFacilityManager::addLogger( + "system", + new FileLogger("SAAM",$systemCatalogManager,$config->files->saam_log,true) +); +LoggingFacilityManager::getLogger("saam")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG); + + +LoggingFacilityManager::addLogger( + "task", + new FileLogger("Task",$systemCatalogManager,$config->files->task_log,true) +); +LoggingFacilityManager::getLogger("task")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG); + +LoggingFacilityManager::addLogger( + "general", + new FileLogger("General",$systemCatalogManager,$config->files->general_log,true) +); +LoggingFacilityManager::getLogger("general")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG); + +?> \ No newline at end of file diff --git a/private/lib/system/FSObject.php b/private/lib/system/FSObject.php new file mode 100644 index 0000000..7818c96 --- /dev/null +++ b/private/lib/system/FSObject.php @@ -0,0 +1,161 @@ +mountPoint; + } + + /** + * Scrive su un file del file system in base alle sue caratteristiche + * @param string $path + */ + public abstract function writeFile($content,$filePath); + + /** + * Scrive su un file del file system in append + * @param string $path + */ + public abstract function appendToFile($content,$filePath); + /** + * Legge da un file del file system in base alle sue caratteristiche + * @param string $path + */ + public abstract function readFile($filePath); + + /** + * Copia un file nella posizione inserita in base alle caratteristiche del FS + * @param string $path + */ + public abstract function copyFile($source,$destination,$sudo); + + /** + * Sposta un file nella posizione inserita in base alle caratteristiche del FS + * @param string $path + */ + public abstract function moveFile($source,$destination,$sudo); + + /** + * Crea un file sul file system in base alle sue caratteristiche + * @param string $path + */ + public abstract function touchFile($path,$sudo); + + /** + * Cancella il file al percorso pecificato + * @param string $path + */ + public abstract function deleteFile($path,$sudo); + + + /** + * Crea una cartella sul file system in base alle sue caratteristiche + * @param string $path + */ + public abstract function createDirectory($path,$sudo); + + /** + * Copia una cartella sul file system in base alle sue caratteristiche + * @param string $path + */ + public abstract function copyDirectory($source,$destination,$sudo); + + /** + * Verifica l'esistenza di un file + * @param string $path + */ + public abstract function fileExists($filePath); + + /** + * Verifica l'esistenza di un file + * @param string $path + */ + public abstract function directoryExists($dirPath); + + + /** + * Verifica che il file sia una cartella + * @param string $path + */ + public abstract function isDirectory($path); + + /** + * Verifica che il file sia una cartella + * @param string $path + */ + public abstract function lsDir($path); + +}?> \ No newline at end of file diff --git a/private/lib/system/SFSManager.php b/private/lib/system/SFSManager.php new file mode 100644 index 0000000..0bdaf63 --- /dev/null +++ b/private/lib/system/SFSManager.php @@ -0,0 +1,127 @@ +getMountPoint().'|',$path)){ + if ($memory!=null){ + if (preg_match('|^'.$memory->getMountPoint().'|',$fso->getMountPoint())){ + $memory=$fso; + } + } + else { + $memory=$fso; + } + } + } + return $memory; + } + + public static function readFile($path){ + $fso=self::getFSObjByPath($path); + if($fso!=null){ + return $fso->readFile($path); + } + } + + public static function writeFile($content,$file){ + $fso=self::getFSObjByPath($file); + if($fso!=null){ + return $fso->writeFile($content,$file); + } + } + + public static function appendToFile($content,$file){ + $fso=self::getFSObjByPath($file); + if($fso!=null){ + return $fso->appendToFile($content,$file); + } + } + + public static function copyFile($source,$destination,$sudo=false){ + $fso=self::getFSObjByPath($destination); + if($fso!=null){ + return $fso->copyFile($source,$destination,$sudo); + } + } + + public static function moveFile($source,$destination,$sudo=false){ + $fso=self::getFSObjByPath($destination); + if($fso!=null){ + return $fso->moveFile($source,$destination,$sudo); + } + } + + public static function touchFile($path,$sudo=false){ + $fso=self::getFSObjByPath($path); + if($fso!=null){ + return $fso->touchFile($path,$sudo); + } + } + + public static function deleteFile($path,$sudo=false){ + $fso=self::getFSObjByPath($path); + if($fso!=null){ + return $fso->deleteFile($path,$sudo); + } + } + + public static function createDirectory($path,$sudo=false){ + $fso=self::getFSObjByPath($path); + if($fso!=null){ + return $fso->createDirectory($path,$sudo); + } + } + + public static function copyDirectory($source,$destination,$sudo=false){ + $fso=self::getFSObjByPath($destination); + if($fso!=null){ + return $fso->copyDirectory($source,$destination,$sudo); + } + } + + public static function fileExists($path){ + $fso=self::getFSObjByPath($path); + if($fso!=null){ + return $fso->fileExists($path); + } + } + + public static function lsDir($path){ + $fso=self::getFSObjByPath($path); + if($fso!=null){ + return $fso->lsDir($path); + } + } + +} +?> \ No newline at end of file diff --git a/private/lib/system/SystemController.php b/private/lib/system/SystemController.php new file mode 100644 index 0000000..e528b22 --- /dev/null +++ b/private/lib/system/SystemController.php @@ -0,0 +1,92 @@ +log($level,$message,$data,true); + } + + public static function shellExec($cmdName,$cmdParams="",$sudo=false){ + $myCmd=($sudo?"sudo ":"").$cmdName.($cmdParams!=""?" ".$cmdParams:""); + + self::logMessage(LoggingFacility::$LEVEL_DEBUG,"log.sysctl.tryexecute",$myCmd." 2>&1"); + + $answers=array(); + $execReturn=null; + exec($myCmd." 2>&1",$answers,$execReturn); + $return=new SystemAnswer($execReturn,$answers); + if ($return->status!=0){ + if ( is_array($return->messages) && sizeof($return->messages)>0 ){ + foreach ($return->messages as $answer){ + self::logMessage(LoggingFacility::$LEVEL_DEBUG,$answer); + } + } + self::logMessage(LoggingFacility::$LEVEL_ERROR,"log.sysctl.cantexecute",$myCmd." 2>&1",true); + $catParameters=array($myCmd,$return->messages[sizeof($return->messages)-1],$return); + throw new SystemException("exc.sysctl.cantexecute",$catParameters); + } + + self::logMessage(LoggingFacility::$LEVEL_INFO,"log.sysctl.correctlyexecute",$myCmd." 2>&1",true); + return $return; + } + + public static function executeCustomCommand($cmdName,$cmdParams="",$sudo=false){ + $binpath = Context::getContextValue("sysconfig")->application->custom_bin_path; + return self::shellExec($binpath."/".$cmdName,$cmdParams,$sudo); + } + + public static function executeTask($cmdName,$cmdParams="",$sudo=false){ + $basePath = Context::getContextValue("sysconfig")->application->tasks_path; + return self::shellExec($basePath."/".$cmdName,$cmdParams,$sudo); + } + + public static function mountRo($path) { + return self::executeCustomCommand("mountro",'"'.$path.'"'); + } + + public static function mountRw($path) { + return self::executeCustomCommand("mountrw",'"'.$path.'"'); + } + + public static function cp($source,$dest,$useSudo=false){ + return self::shellExec("cp",'"'.$source.'" "'.$dest.'"',$useSudo); + } + + public static function cpRec($source,$dest,$useSudo=false){ + return self::shellExec("cp",'-r "'.$source.'" "'.$dest.'"',$useSudo); + } + + public static function mv($source,$dest,$useSudo=false){ + return self::shellExec("mv",'"'.$source.'" "'.$dest.'"',$useSudo); + } + + public static function touch($path,$useSudo=false){ + return self::shellExec("touch",'"'.$path.'"',$useSudo); + } + + public static function mkdir($path,$useSudo=false){ + return self::shellExec("mkdir",'"'.$path.'"',$useSudo); + } + + public static function rm($path,$useSudo=false){ + return self::shellExec("rm",'"'.$path.'"',$useSudo); + } + + public static function wget($targetPage,$destFile,$useSudo=false){ + return self::shellExec("wget",'-O "'.$destFile.'" '.$targetPage,$useSudo); + } + +} + +class SystemAnswer { + public $status; + public $messages; + + public function __construct($status,$messages){ + $this->status=$status; + $this->messages=$messages; + } +} +?> \ No newline at end of file diff --git a/private/lib/system/fsobjects/LocallyMountedFS.php b/private/lib/system/fsobjects/LocallyMountedFS.php new file mode 100644 index 0000000..afb5464 --- /dev/null +++ b/private/lib/system/fsobjects/LocallyMountedFS.php @@ -0,0 +1,171 @@ +type=$deviceType; + $this->writeLaw=$writelaw; + $this->accessMode=$accessmode; + $this->mountPoint=$mountPoint; + + $this->name=$name; + } + + private function useSysFunction($funcName){ + $funcArgs = array(); + for ($i = 1; $i < func_num_args(); $i++){ + $funcArgs[] = func_get_arg($i); + } + if ($this->accessMode==self::$ACCESSMODE_RW){ + if ($this->writeLaw==parent::$WRITELAW_NOT_WRITEABLE){ + throw new SFSException('fsobj.not_writeable',$this->name); + } + else if ($this->writeLaw==parent::$WRITELAW_NORMALLY_RO){ + SystemController::mountRw($this->mountPoint); + call_user_func_array(array("SystemController",$funcName),$funcArgs); + SystemController::mountRw($this->mountPoint); + } + else if ($this->writeLaw==parent::$WRITELAW_NORMALLY_W){ + call_user_func_array(array("SystemController",$funcName),$funcArgs); + } + } + else { + throw new SFSException('fsobj.not_writeable',$this->name); + } + } + + private function write($content,$file,$mode='w'){ + $fh = fopen($file, $mode); + if ($fh === false){ + throw new SFSException('fsobj.file_not_writeable',$file); + } + $count = 0; + $done = false; + while (!$done && $count<3){ + if (flock($fh, LOCK_EX)){ + fwrite($fh,$content); +// flock($fh, LOCK_UN); // not necessary + $done = true; + } + else { + sleep(5); + } + $count++; + } + fclose($fh); + if (!$done){ + throw new SFSException("Error writing file '$file'... the file is being used from another resource."); + } + } + + + public function readFile($path){ +// var_dump($path); + $fh = fopen($path, 'r'); + if ($fh === false){ + throw new SFSException('fsobj.file_not_readable',$path); + } + $done = false; + $count = 0; + while (!$done && $count<3){ + if (flock($fh, LOCK_EX)){ + $rows=file($path); + $done = true; + } + else { + sleep(5); + } + $count++; + } + fclose($fh); + if (!$done){ + throw new SFSException("Error reading file '$path'... the file is being used from another resource."); + } + return $rows; + } + + public function appendToFile($content,$file){ + if ($this->accessMode==self::$ACCESSMODE_RO || $this->writeLaw==parent::$WRITELAW_NOT_WRITEABLE){ + throw new SFSException('fsobj.not_writeable',$this->name); + } + else if ($this->writeLaw==parent::$WRITELAW_NORMALLY_W) { + $this->write($content,$file,'a'); + } + else if ($this->writeLaw==parent::$WRITELAW_NORMALLY_RO) { + SystemController::mountRw($this->mountPoint); + $this->write($content,$file,'a'); + SystemController::mountRw($this->mountPoint); + } + } + + public function writeFile($content,$file){ + if ($this->accessMode==self::$ACCESSMODE_RO || $this->writeLaw==parent::$WRITELAW_NOT_WRITEABLE){ + throw new SFSException('fsobj.not_writeable',$this->name); + } + else if ($this->writeLaw==parent::$WRITELAW_NORMALLY_W) { + $this->write($content,$file); + } + else if ($this->writeLaw==parent::$WRITELAW_NORMALLY_RO) { + SystemController::mountRw($this->mountPoint); + $this->write($content,$file); + SystemController::mountRw($this->mountPoint); + } + + } + + public function moveFile($source,$destination,$useSudo=false){ + $this->useSysFunction("mv",$source,$destination,$useSudo); + } + + public function copyFile($source,$destination,$useSudo=false){ + $this->useSysFunction("cp",$source,$destination,$useSudo); + } + + public function touchFile($path,$useSudo=false){ + $this->useSysFunction("touch",$path,$useSudo); + } + + public function deleteFile($path,$useSudo=false){ + $this->useSysFunction("rm",$path,$useSudo); + } + + public function createDirectory($path,$useSudo=false){ + $this->useSysFunction("mkdir",$path,$useSudo); + } + + public function copyDirectory($source,$destination,$useSudo=false){ + $this->useSysFunction("cpRec",$source,$destination,$useSudo); + } + + public function fileExists($path){ + return (file_exists($path)); + } + + public function directoryExists($path){ + return (file_exists($path)); + } + + public function isDirectory($path){ + return ($this->directoryExists($path) && is_dir($path)); + } + + public function lsDir($path){ + $rval = array(); + if ($this->isDirectory($path)){ + if ($dh = opendir($path)) { + while (($file = readdir($dh)) !== false) { + if (strcmp($file,".")!=0 && strcmp($file,"..")!=0){ + $rval[] = $file; + } + } + closedir($dh); + } + } + return $rval; + } +} \ No newline at end of file diff --git a/private/lib/system/lib.inclusion.php b/private/lib/system/lib.inclusion.php new file mode 100644 index 0000000..0c45851 --- /dev/null +++ b/private/lib/system/lib.inclusion.php @@ -0,0 +1,78 @@ +paths->log, + "Log Filesystem") +); +SFSManager::addFilesystem(new LocallyMountedFS( + FSObject::$DEVICE_TYPE_HARD_DRIVE, + FSObject::$WRITELAW_NORMALLY_W, + LocallyMountedFS::$ACCESSMODE_RW, + $config->paths->backup, + "Backups Filesystem") +); +SFSManager::addFilesystem(new LocallyMountedFS( + FSObject::$DEVICE_TYPE_HARD_DRIVE, + FSObject::$WRITELAW_NORMALLY_W, + LocallyMountedFS::$ACCESSMODE_RW, + $config->paths->media, + "Media Filesystem") +); +SFSManager::addFilesystem(new LocallyMountedFS( + FSObject::$DEVICE_TYPE_HARD_DRIVE, + FSObject::$WRITELAW_NORMALLY_W, + LocallyMountedFS::$ACCESSMODE_RW, + $config->paths->tmp, + "Temporary Filesystem") +); +SFSManager::addFilesystem(new LocallyMountedFS( + FSObject::$DEVICE_TYPE_HARD_DRIVE, + FSObject::$WRITELAW_NORMALLY_W, + LocallyMountedFS::$ACCESSMODE_RW, + $config->paths->xsendfile, + "XSendFile Filesystem") +); +SFSManager::addFilesystem(new LocallyMountedFS( + FSObject::$DEVICE_TYPE_HARD_DRIVE, + FSObject::$WRITELAW_NORMALLY_W, + LocallyMountedFS::$ACCESSMODE_RW, + $config->paths->pubkey, + "Public Keys Filesystem") +); +SFSManager::addFilesystem(new LocallyMountedFS( + FSObject::$DEVICE_TYPE_HARD_DRIVE, + FSObject::$WRITELAW_NORMALLY_W, + LocallyMountedFS::$ACCESSMODE_RW, + $config->paths->sshDir, + "SSH Configuration directory") +); + +?> \ No newline at end of file diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..65f5d32 --- /dev/null +++ b/public/index.php @@ -0,0 +1,9 @@ + \ No newline at end of file