From 76d680b6dd1158ae25f5e420ce22518f8415ac1d Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Mon, 7 Sep 2015 16:46:21 +0200 Subject: [PATCH] Install: Remove useless --- .../Framadate/Services/InstallService.php | 18 --- install/InstallComposer.php | 90 -------------- install/InstallConfiguration.php | 73 ------------ install/InstallSql.php | 24 ---- install/error.html | 33 ------ install/install.css | 11 -- install/install.html | 72 ----------- install/install.mysql.auto.sqlXX | 8 -- install/install.mysql.sql | 112 ------------------ install/install.php | 43 ------- 10 files changed, 484 deletions(-) delete mode 100644 install/InstallComposer.php delete mode 100644 install/InstallConfiguration.php delete mode 100644 install/InstallSql.php delete mode 100644 install/error.html delete mode 100644 install/install.css delete mode 100644 install/install.html delete mode 100644 install/install.mysql.auto.sqlXX delete mode 100644 install/install.mysql.sql delete mode 100644 install/install.php diff --git a/app/classes/Framadate/Services/InstallService.php b/app/classes/Framadate/Services/InstallService.php index 535ed17..0db9f1f 100644 --- a/app/classes/Framadate/Services/InstallService.php +++ b/app/classes/Framadate/Services/InstallService.php @@ -61,9 +61,6 @@ class InstallService { return $this->error('CANT_CONNECT_TO_DATABASE'); } - // Create database schema - $this->createDatabaseSchema($connect); - // Write configuration to conf.php file $this->writeConfiguration($smarty); @@ -98,21 +95,6 @@ class InstallService { file_put_contents(CONF_FILENAME, $content); } - /** - * Execute SQL installation scripts. - * - * @param \PDO $connect - */ - function createDatabaseSchema($connect) { - $dir = opendir(ROOT_DIR . '/install/'); - while ($dir && ($file = readdir($dir)) !== false) { - if ($file !== '.' && $file !== '..' && strpos($file, '.mysql.auto.sql')) { - $statement = file_get_contents(ROOT_DIR . '/install/' . $file); - $connect->exec($statement); - } - } - } - /** * @return array */ diff --git a/install/InstallComposer.php b/install/InstallComposer.php deleted file mode 100644 index a370f95..0000000 --- a/install/InstallComposer.php +++ /dev/null @@ -1,90 +0,0 @@ -getComposer().'/src/bootstrap.php'; - - $this->initEnv(); - - $application = new \Composer\Console\Application(); - $application->setAutoExit(false); - - $input = new \Symfony\Component\Console\Input\ArrayInput(array( - 'command' => 'install', - '-d' => __DIR__.'/..', - '-vvv', - '--optimize-autoloader', - )); - $output = new \Symfony\Component\Console\Output\NullOutput(); - - $application->run($input, $output); - } - - /** - * @return string - */ - private function getComposer() - { - if (null === $this->composer) { - $this->initComposer(); - } - - return $this->composer; - } - - private function initComposer() - { - // Composer exist ? - $locations = array( - __DIR__.'/../composer.phar', - '/usr/bin/composer.phar', - '/usr/local/bin/composer.phar', - ); - - $this->composer = null; - foreach ($locations as $location) { - if (file_exists($location) === true) { - $this->composer = $location; - break; - } - } - - // If composer not found, download it ! - if (null === $this->composer) { - if (!file_put_contents( - __DIR__.'/../composer.phar', - file_get_contents('https://getcomposer.org/composer.phar') - ) - ) { - throw new \Exception('Impossible to download composer'); - } - - $this->composer = __DIR__.'/../composer.phar'; - } - } - - private function initEnv() - { - $composer_home = getenv('COMPOSER_HOME'); - $personal_home = getenv('HOME'); - if (empty($composer_home) === true && empty($personal_home) === true) { - putenv('COMPOSER_HOME='.sys_get_temp_dir()); - } - } - -} diff --git a/install/InstallConfiguration.php b/install/InstallConfiguration.php deleted file mode 100644 index 3595312..0000000 --- a/install/InstallConfiguration.php +++ /dev/null @@ -1,73 +0,0 @@ - 'Application name', - 'email' => 'email address', - 'no-reply-email' => 'no-reply@mydomain.com', - 'db-name' => 'database name', - 'db-user' => 'database user', - 'db-pass' => 'database password', - 'db-host' => 'database server', - 'db-type' => 'database type', - ); - - /** - * @param array $datas - */ - public function __construct(array $datas) - { - $this->datas = $datas; - } - - /** - * @return bool - */ - public function checkValues() - { - foreach (array_keys($this->checks) as $key) { - if (isset($this->datas[$key]) === false) { - return false; - } - } - - return true; - } - - public function copy($template, $destination) - { - $configuration = file_get_contents($template); - if (false === $configuration) { - throw new \Exception('Impossible to read template configuration'); - } - - $configuration = $this->convertConfigurationFile($configuration); - - if (file_put_contents($destination, $configuration) === false) { - throw new \Exception('Impossible to save configuration'); - } - } - - - private function convertConfigurationFile($content) - { - foreach ($this->checks as $replace => $search) { - $content = str_replace( - '\'<'.$search.'>\'', - var_export($this->datas[$replace], true), - $content - ); - } - - return $content; - } -} diff --git a/install/InstallSql.php b/install/InstallSql.php deleted file mode 100644 index 749767b..0000000 --- a/install/InstallSql.php +++ /dev/null @@ -1,24 +0,0 @@ -ErrorMsg() !== '') { - throw new \Exception('Bad database configuration : '.$connect->ErrorMsg()); - } - - $sqls = explode("\n", file_get_contents(__DIR__.'/install.mysql.auto.sql')); - foreach ($sqls as $sql) { - $sql = trim($sql); - if (empty($sql) === true) { - continue; - } - - $query = $connect->Prepare($sql); - $cleaning = $connect->Execute($query); - } - } -} diff --git a/install/error.html b/install/error.html deleted file mode 100644 index c6dc5ba..0000000 --- a/install/error.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - OpenSondage Installation - - - - - - -
-
-

- Framadate -

-

Make your polls

- -
-
-

Framadate Installation

- - -
-
- - diff --git a/install/install.css b/install/install.css deleted file mode 100644 index 18f3dc5..0000000 --- a/install/install.css +++ /dev/null @@ -1,11 +0,0 @@ -header { - padding-bottom: 0; -} - -main { - padding-top: 0; -} - -fieldset { - margin: 1.5em 0; -} \ No newline at end of file diff --git a/install/install.html b/install/install.html deleted file mode 100644 index 1caa3af..0000000 --- a/install/install.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - OpenSondage Installation - - - - - - -
-
-

- Framadate -

-

Make your polls

- -
-
-

Framadate Installation

-
-
- General - -
- - -
-
- - -
-
- - -
-
-
- Database - -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - diff --git a/install/install.mysql.auto.sqlXX b/install/install.mysql.auto.sqlXX deleted file mode 100644 index a42245e..0000000 --- a/install/install.mysql.auto.sqlXX +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE IF NOT EXISTS `comments` (`id_comment` int(11) unsigned NOT NULL AUTO_INCREMENT, `id_sondage` char(16) NOT NULL, `comment` text NOT NULL, `usercomment` text, PRIMARY KEY (`id_comment`), KEY `id_sondage` (`id_sondage`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE IF NOT EXISTS `sondage` (`id_sondage` char(16) NOT NULL, `commentaires` text, `mail_admin` varchar(128) DEFAULT NULL, `nom_admin` varchar(64) DEFAULT NULL, `titre` text, `id_sondage_admin` char(24) DEFAULT NULL, `date_creation` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `date_fin` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `format` varchar(2) DEFAULT NULL, `mailsonde` tinyint(1) DEFAULT '0', `statut` int(11) NOT NULL DEFAULT '1' COMMENT '1 = actif ; 0 = inactif ; ', UNIQUE KEY `id_sondage` (`id_sondage`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE IF NOT EXISTS `sujet_studs` (`id_sondage` char(16) NOT NULL, `sujet` text, KEY `id_sondage` (`id_sondage`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE IF NOT EXISTS `user_studs` (`id_users` int(11) unsigned NOT NULL AUTO_INCREMENT, `nom` varchar(64) NOT NULL, `id_sondage` char(16) NOT NULL, `reponses` text NOT NULL, PRIMARY KEY (`id_users`), KEY `id_sondage` (`id_sondage`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ; - -INSERT INTO `sondage` (`id_sondage`, `commentaires`, `mail_admin`, `nom_admin`, `titre`, `id_sondage_admin`, `date_fin`, `format`) VALUES ('aqg259dth55iuhwm','Repas de Noel du service','Stephanie@retaillard.com','Stephanie', 'Repas de Noel','aqg259dth55iuhwmy9d8jlwk', FROM_UNIXTIME('1627100361'),'D+'); -INSERT INTO `sujet_studs` (`id_sondage`, `sujet`) VALUES ('aqg259dth55iuhwm','1225839600@12h,1225839600@19h,1226012400@12h,1226012400@19h,1226876400@12h,1226876400@19h,1227049200@12h,1227049200@19h,1227826800@12h,1227826800@19h'); -INSERT INTO `user_studs` (`nom`, `id_sondage`, `reponses`, `id_users`) VALUES ('marcel','aqg259dth55iuhwm','0110111101','933'), ('paul','aqg259dth55iuhwm','1011010111','935'), ('sophie','aqg259dth55iuhwm','1110110000','945'), ('barack','aqg259dth55iuhwm','0110000','948'), ('takashi','aqg259dth55iuhwm','0000110100','951'), ('albert','aqg259dth55iuhwm','1010110','975'), ('alfred','aqg259dth55iuhwm','0110010','1135'), ('marcs','aqg259dth55iuhwm','0100001010','1143'), ('laure','aqg259dth55iuhwm','0011000','1347'), ('benda','aqg259dth55iuhwm','1101101100','1667'), ('Albert','aqg259dth55iuhwm','1111110011','1668'); diff --git a/install/install.mysql.sql b/install/install.mysql.sql deleted file mode 100644 index aa0354c..0000000 --- a/install/install.mysql.sql +++ /dev/null @@ -1,112 +0,0 @@ --- -------------------------------------------------------- - --- --- Table structure `poll` --- - -CREATE TABLE IF NOT EXISTS `poll` ( - `id` CHAR(16) NOT NULL, - `admin_id` CHAR(24) NOT NULL, - `title` TEXT NOT NULL, - `description` TEXT, - `admin_name` VARCHAR(64) DEFAULT NULL, - `admin_mail` VARCHAR(128) DEFAULT NULL, - `creation_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `end_date` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', - `format` VARCHAR(1) DEFAULT NULL, - `editable` TINYINT(1) DEFAULT '0', - `receiveNewVotes` TINYINT(1) DEFAULT '0', - `active` TINYINT(1) DEFAULT '1', - PRIMARY KEY (`id`) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - --- -------------------------------------------------------- - --- --- Table structure `slot` --- - -CREATE TABLE IF NOT EXISTS `slot` ( - `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `poll_id` CHAR(16) NOT NULL, - `title` TEXT, - `moments` TEXT, - PRIMARY KEY (`id`), - KEY `poll_id` (`poll_id`) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - --- -------------------------------------------------------- - --- --- Table structure `comment` --- - -CREATE TABLE IF NOT EXISTS `comment` ( - `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `poll_id` CHAR(16) NOT NULL, - `name` TEXT, - `comment` TEXT NOT NULL, - PRIMARY KEY (`id`), - KEY `poll_id` (`poll_id`) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - --- -------------------------------------------------------- - --- --- Table structure `vote` --- - -CREATE TABLE IF NOT EXISTS `vote` ( - `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `poll_id` CHAR(16) NOT NULL, - `name` VARCHAR(64) NOT NULL, - `choices` TEXT NOT NULL, - PRIMARY KEY (`id`), - KEY `poll_id` (`poll_id`) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - - --- --- Data for Name: poll; Type: TABLE DATA; --- - -INSERT INTO `poll` -(`id`, `description`, `admin_mail`, `admin_name`, `title`, `admin_id`, `end_date`, `format`) -VALUES - ('aqg259dth55iuhwm', 'Repas de Noel du service', 'Stephanie@retaillard.com', 'Stephanie', 'Repas de Noel', - 'aqg259dth55iuhwmy9d8jlwk', FROM_UNIXTIME('1627100361'), 'D'); - --- --- Data for Name: slot; Type: TABLE DATA; --- - -INSERT INTO `slot` (`poll_id`, `title`, `moments`) VALUES - ('aqg259dth55iuhwm', '1225839600', '12h,19h'), - ('aqg259dth55iuhwm', '1226012400', '12h,19h'), - ('aqg259dth55iuhwm', '1226876400', '12h,19h'), - ('aqg259dth55iuhwm', '1227826800', '12h,19h'); - --- --- Data for Name: vote; Type: TABLE DATA; --- - -INSERT INTO `vote` (`name`, `poll_id`, `choices`) VALUES - ('marcel', 'aqg259dth55iuhwm', '02202222'), - ('paul', 'aqg259dth55iuhwm', '20220202'), - ('sophie', 'aqg259dth55iuhwm', '22202200'), - ('barack', 'aqg259dth55iuhwm', '02200000'), - ('takashi', 'aqg259dth55iuhwm', '00002202'), - ('albert', 'aqg259dth55iuhwm', '20202200'), - ('alfred', 'aqg259dth55iuhwm', '02200200'), - ('marcs', 'aqg259dth55iuhwm', '02000020'), - ('laure', 'aqg259dth55iuhwm', '00220000'), - ('benda', 'aqg259dth55iuhwm', '22022022'), - ('albert', 'aqg259dth55iuhwm', '22222200'); diff --git a/install/install.php b/install/install.php deleted file mode 100644 index 8cf9f3f..0000000 --- a/install/install.php +++ /dev/null @@ -1,43 +0,0 @@ -check() === false) { - ini_set('max_execution_time', 0); - $composer->install(); - } - - // Save configuration - $configuration = new InstallConfiguration($_POST); - if ($configuration->checkValues() === false) { - throw new \Exception('Bad value for configuration'); - } - - $configuration->copy($configuration_file.'.template', $configuration_file); - - // Inject database - $sql = new InstallSql(); - $sql->inject(); - - header('Location: ../index.php'); - die(); - } catch (Exception $e) { - require_once __DIR__.'/error.html'; - die(); - } -} - -require_once __DIR__.'/install.html';