File modules/cms/update/version/DBVersion000007.class.php

Last commit: Sun Oct 1 02:58:08 2023 +0200	Jan Dankert	Refactoring: No it is possible to use 8 byte integers in the database
1 <?php 2 3 namespace cms\update\version; 4 5 use database\DbVersion; 6 use database\Column; 7 use security\Password; 8 9 /** 10 * Security enhancements. 11 * 12 * @author dankert 13 * 14 */ 15 class DBVersion000007 extends DbVersion 16 { 17 public function update() 18 { 19 $table = $this->table('user'); 20 $table->column('otp_secret' )->type(Column::TYPE_VARCHAR)->nullable()->add(); 21 22 $tableName = $table->getSqlName(); 23 $db = $this->getDb(); 24 $stmt = $db->sql('SELECT id FROM '.$tableName); 25 foreach($stmt->getCol() as $userid ) 26 { 27 $secret = Password::randomHexString(64); 28 $stmt = $db->sql('UPDATE '.$tableName.' SET otp_secret={secret} WHERE id={id}'); 29 $stmt->setString('secret',$secret); 30 $stmt->setInt('id',$userid); 31 $stmt->execute(); 32 } 33 34 $table->column('totp' )->type(Column::TYPE_INT )->size( Column::SIZE_INT_BOOL)->defaultValue( 0)->add(); 35 $table->column('hotp_counter')->type(Column::TYPE_INT )->size( Column::SIZE_INT_MED)->defaultValue( 0)->add(); 36 $table->column('hotp' )->type(Column::TYPE_INT )->size( Column::SIZE_INT_BOOL)->defaultValue( 0)->add(); 37 38 } 39 }
Download modules/cms/update/version/DBVersion000007.class.php
History Sun, 1 Oct 2023 02:58:08 +0200 Jan Dankert Refactoring: No it is possible to use 8 byte integers in the database Sun, 7 Mar 2021 00:10:20 +0100 Jan Dankert Refactoring: Hopefully more performance while accessing the database resultsets. Fri, 25 Sep 2020 01:00:58 +0200 Jan Dankert Refactoring: More OO in the database updater :) Sun, 23 Feb 2020 00:30:10 +0100 Jan Dankert Refactoring: Namespacing for module 'database-update', now called 'cms\update'.