Ejemplo n.º 1
0
 public function install_modules()
 {
     $this->config->addPackage('unknown', ASSETSPATH);
     $class_name = $this->config->get('unknown', 'package', 'main.class_name');
     $name_lowercase = strtolower($class_name);
     $modules = ['foolframe' => ['context' => '\\Foolz\\FoolFrame\\Model\\Context', 'namespace' => 'foolz/foolframe'], $name_lowercase => ['context' => $this->config->get('unknown', 'package', 'main.class_context'), 'namespace' => 'foolz/' . $name_lowercase]];
     $dc = new DoctrineConnection($this->getContext(), $this->config);
     $sm = SchemaManager::forge($dc->getConnection(), $dc->getPrefix());
     Schema::load($this->getContext(), $sm);
     $schema_class = '\\Foolz\\' . $class_name . '\\Model\\Schema';
     $schema_class::load($this->getContext(), $sm);
     $sm->commit();
     $this->config->set('foolz/foolframe', 'config', 'modules.installed', $modules);
     $this->config->set('foolz/foolframe', 'config', 'install.installed', true);
     $this->config->save('foolz/foolframe', 'config');
 }
Ejemplo n.º 2
0
 public function install($slug)
 {
     $plugin = $this->loader->get($slug);
     $plugin->install();
     $this->dc->getConnection()->insert($this->dc->p('plugins'), ['slug' => $slug, 'enabled' => 1]);
     $this->clearCache();
     // run the schema update
     $sm = \Foolz\FoolFrame\Model\SchemaManager::forge($this->dc->getConnection(), $this->dc->getPrefix() . 'plugin_');
     foreach ($this->getInstalled() as $enabled) {
         try {
             $plug = $this->loader->get($enabled['slug']);
             if (!$plug->isBootstrapped()) {
                 $plug->bootstrap();
             }
             \Foolz\Plugin\Hook::forge('Foolz\\FoolFrame\\Model\\Plugin::install#' . $plug->getConfig('name'))->setParam('context', $this->getContext())->setParam('schema', $sm->getCodedSchema())->execute();
         } catch (\OutOfBoundsException $e) {
         }
     }
     $sm->commit();
     $this->clearCache();
 }
Ejemplo n.º 3
0
 public static function load(\Foolz\Foolframe\Model\Context $context, SchemaManager $sm)
 {
     /** @var DoctrineConnection $dc */
     $dc = $context->getService('doctrine');
     $charset = 'utf8mb4';
     $collate = 'utf8mb4_unicode_ci';
     $schema = $sm->getCodedSchema();
     $banned_md5 = $schema->createTable($dc->p('banned_md5'));
     $banned_md5->addColumn('md5', 'string', ['length' => 24]);
     $banned_md5->setPrimaryKey(['md5']);
     $banned_posters = $schema->createTable($dc->p('banned_posters'));
     if ($dc->getConnection()->getDriver()->getName() == 'pdo_mysql') {
         $banned_posters->addOption('charset', $charset);
         $banned_posters->addOption('collate', $collate);
     }
     $banned_posters->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
     $banned_posters->addColumn('ip', 'decimal', ['unsigned' => true, 'precision' => 39, 'scale' => 0]);
     $banned_posters->addColumn('reason', 'text', ['length' => 65532]);
     $banned_posters->addColumn('start', 'integer', ['unsigned' => true, 'default' => 0]);
     $banned_posters->addColumn('length', 'integer', ['unsigned' => true, 'default' => 0]);
     $banned_posters->addColumn('board_id', 'integer', ['unsigned' => true, 'default' => 0]);
     $banned_posters->addColumn('creator_id', 'integer', ['unsigned' => true, 'default' => 0]);
     $banned_posters->addColumn('appeal', 'text', ['length' => 65532]);
     $banned_posters->addColumn('appeal_status', 'integer', ['unsigned' => true, 'default' => 0]);
     $banned_posters->setPrimaryKey(['id']);
     $banned_posters->addIndex(['ip'], 'ip_index');
     $banned_posters->addIndex(['creator_id'], 'creator_id_index');
     $banned_posters->addIndex(['appeal_status'], 'appeal_status_index');
     $boards = $schema->createTable($dc->p('boards'));
     if ($dc->getConnection()->getDriver()->getName() == 'pdo_mysql') {
         $boards->addOption('charset', $charset);
         $boards->addOption('collate', $collate);
     }
     $boards->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
     $boards->addColumn('shortname', 'string', ['length' => 32]);
     $boards->addColumn('name', 'string', ['length' => 256]);
     $boards->addColumn('archive', 'smallint', ['unsigned' => true, 'default' => 0]);
     $boards->addColumn('sphinx', 'smallint', ['unsigned' => true, 'default' => 0]);
     $boards->addColumn('hidden', 'smallint', ['unsigned' => true, 'default' => 0]);
     $boards->addColumn('hide_thumbnails', 'smallint', ['unsigned' => true, 'default' => 0]);
     $boards->addColumn('directory', 'text', ['length' => 65532, 'notnull' => false]);
     $boards->addColumn('max_indexed_id', 'integer', ['unsigned' => true, 'default' => 0]);
     $boards->addColumn('max_ancient_id', 'integer', ['unsigned' => true, 'default' => 0]);
     $boards->setPrimaryKey(['id']);
     $boards->addUniqueIndex(['shortname'], 'shortname_index');
     $boards_preferences = $schema->createTable($dc->p('boards_preferences'));
     if ($dc->getConnection()->getDriver()->getName() == 'pdo_mysql') {
         $boards_preferences->addOption('charset', $charset);
         $boards_preferences->addOption('collate', $collate);
     }
     $boards_preferences->addColumn('board_preference_id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
     $boards_preferences->addColumn('board_id', 'integer', ['unsigned' => true]);
     $boards_preferences->addColumn('name', 'string', ['length' => 64]);
     $boards_preferences->addColumn('value', 'text', ['notnull' => false, 'length' => 65532]);
     $boards_preferences->setPrimaryKey(['board_preference_id']);
     $boards_preferences->addIndex(['board_id', 'name'], 'board_id_name_index');
     $reports = $schema->createTable($dc->p('reports'));
     if ($dc->getConnection()->getDriver()->getName() == 'pdo_mysql') {
         $reports->addOption('charset', $charset);
         $reports->addOption('collate', $collate);
     }
     $reports->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
     $reports->addColumn('board_id', 'integer', ['unsigned' => true]);
     $reports->addColumn('doc_id', 'integer', ['unsigned' => true, 'notnull' => false, 'default' => null]);
     $reports->addColumn('media_id', 'integer', ['unsigned' => true, 'notnull' => false, 'default' => null]);
     $reports->addColumn('reason', 'text', ['length' => 65532]);
     $reports->addColumn('ip_reporter', 'decimal', ['unsigned' => true, 'precision' => 39, 'scale' => 0]);
     $reports->addColumn('created', 'integer', ['unsigned' => true]);
     $reports->setPrimaryKey(['id']);
     $reports->addIndex(['board_id', 'doc_id'], 'board_id_doc_id_index');
     $reports->addIndex(['board_id', 'media_id'], 'board_id_media_id_index');
 }
Ejemplo n.º 4
0
 public function action_database_setup()
 {
     if ($this->getPost()) {
         $validator = new Validator();
         $validator->add('hostname', _i('Database Hostname'), [new Trim(), new Assert\NotBlank()])->add('prefix', _i('Table Prefix'), [new Trim()])->add('username', _i('Username'), [new Trim(), new Assert\NotBlank()])->add('database', _i('Database name'), [new Trim(), new Assert\NotBlank()]);
         $validator->validate($this->getPost());
         if (!$validator->getViolations()->count()) {
             $input = $validator->getFinalValues();
             $input['password'] = $this->getPost('password');
             $input['type'] = $this->getPost('type');
             if ($this->install->check_database($input)) {
                 $this->install->setup_database($input);
                 $dc = new DoctrineConnection($this->getContext(), $this->config);
                 $sm = SchemaManager::forge($dc->getConnection(), $dc->getPrefix());
                 Schema::load($this->getContext(), $sm);
                 $sm->commit();
                 $this->install->create_salts();
                 return new RedirectResponse($this->uri->create('install/create_admin'));
             } else {
                 $this->notices->set('warning', _i('Connection to specified database failed. Please check your connection details again.'));
             }
         } else {
             $this->notices->set('warning', $validator->getViolations()->getText());
         }
     }
     $this->process('database_setup');
     $this->param_manager->setParam('method_title', _i('Database Setup'));
     $this->builder->createPartial('body', 'install/database_setup');
     return new Response($this->builder->build());
 }