public function __construct(Setup $setup)
 {
     $this->setup = $setup;
     $this->storageMode = 'flat-file';
     $metadata_file = $this->setup->dir . '/.metadata';
     $update_metadata = false;
     // Read exist metadata file if one exists
     if (file_exists($metadata_file)) {
         $json_metadata = json_decode(file_get_contents($metadata_file), true);
         $this->setup->metadata = array_merge($this->setup->metadata, $json_metadata);
     }
     // Check if comment thread directory exists
     if ($setup->mode !== 'api') {
         if (file_exists(dirname($metadata_file)) and is_writable(dirname($metadata_file))) {
             // Check whether the page and metadata URLs differ
             if ($this->setup->metadata['title'] !== $setup->pageTitle) {
                 $this->setup->metadata['title'] = $setup->pageTitle;
                 $update_metadata = true;
             }
             // Check whether the page and metadata titles differ
             if ($this->setup->metadata['url'] !== $setup->pageURL) {
                 $this->setup->metadata['url'] = $setup->pageURL;
                 $update_metadata = true;
             }
             // Update metadata if the data has changed
             if ($update_metadata === true) {
                 if ($this->save_metadata($this->setup->metadata, $metadata_file) === false) {
                     exit($setup->escapeOutput('<b>HashOver</b>: Failed to create metadata file.', 'single'));
                 }
             }
         }
     }
 }
 public function __construct(Setup $setup)
 {
     $this->setup = $setup;
     $this->storageMode = $setup->databaseType;
     try {
         if ($setup->databaseType === 'sqlite') {
             $this->database = new PDO('sqlite:' . $setup->rootDirectory . '/pages/' . $setup->databaseName . '.sqlite');
         } else {
             $sql_connection = 'host=' . $setup->databaseHost . ';' . 'dbname=' . $setup->databaseName . ';' . 'charset=' . $setup->databaseCharset;
             $this->database = new PDO($setup->databaseType . ':' . $sql_connection, $setup->databaseUser, $setup->databasePassword);
         }
     } catch (PDOException $error) {
         exit($setup->escapeOutput($error->getMessage(), 'single'));
     }
     // Create comment tread table
     $create = 'CREATE TABLE IF NOT EXISTS \'' . $setup->threadDirectory . '\' ' . '(id TEXT PRIMARY KEY,' . ' name TEXT,' . ' password TEXT,' . ' login_id TEXT,' . ' email TEXT,' . ' encryption TEXT,' . ' website TEXT,' . ' date TEXT,' . ' likes TEXT,' . ' dislikes TEXT,' . ' notifications TEXT,' . ' ipaddr TEXT,' . ' status TEXT,' . ' body TEXT)';
     $this->database->exec($create);
 }