From b550605bc2f7d45d8f05846ef663baba15ad7d50 Mon Sep 17 00:00:00 2001 From: "stephan.kasdorf" Date: Fri, 29 Aug 2025 14:15:16 +0200 Subject: [PATCH 1/9] Handle trailing URL segments in router Added logic to handle single trailing URL segments in the router, ensuring non-numeric segments are added to the `$_REQUEST` array if not already present. Improved URL parsing for consistent request handling. --- core/c/router.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/c/router.php b/core/c/router.php index 41f71c2..795752b 100755 --- a/core/c/router.php +++ b/core/c/router.php @@ -1,5 +1,7 @@ Date: Mon, 29 Sep 2025 13:39:18 +0200 Subject: [PATCH 2/9] Enhance `typeopenany.php` with new attributes and update `router.php` for SEO URL handling and improved URL parsing. --- core/c/auto.php | 0 core/c/nibiru.php | 0 core/c/router.php | 122 ++++++++++++++++++++--------------------- core/c/typeopenany.php | 7 ++- core/c/typeswitch.php | 0 5 files changed, 65 insertions(+), 64 deletions(-) mode change 100644 => 100755 core/c/auto.php mode change 100644 => 100755 core/c/nibiru.php mode change 100644 => 100755 core/c/typeswitch.php diff --git a/core/c/auto.php b/core/c/auto.php old mode 100644 new mode 100755 diff --git a/core/c/nibiru.php b/core/c/nibiru.php old mode 100644 new mode 100755 diff --git a/core/c/router.php b/core/c/router.php index 795752b..3335162 100755 --- a/core/c/router.php +++ b/core/c/router.php @@ -1,7 +1,5 @@ '', self::FORM_ATTRIBUTE_CLASS => '', self::FORM_ATTRIBUTE_ANY => '', - self::FORM_ATTRIBUTE_HREF => '' + self::FORM_ATTRIBUTE_HREF => '', + 'src' => '', + 'alt' => '', + 'style' => '' ); /** @@ -35,6 +38,6 @@ public function loadElement($attributes) */ private function _setElement( ) { - $this->_element = '' . 'VALUE' . "\n"; + $this->_element = '' . 'VALUE' . "\n"; } } diff --git a/core/c/typeswitch.php b/core/c/typeswitch.php old mode 100644 new mode 100755 From 69c09168093984bf04bd0943a45148e9bd9352ca Mon Sep 17 00:00:00 2001 From: "stephan.kasdorf" Date: Fri, 10 Oct 2025 13:46:49 +0200 Subject: [PATCH 3/9] Enhance `typeopenany.php` with new attributes and update `IForm.php` for improved form handling. --- core/c/typeopenany.php | 7 ++++--- core/i/IForm.php | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/core/c/typeopenany.php b/core/c/typeopenany.php index 8274b6c..b0fa6a9 100755 --- a/core/c/typeopenany.php +++ b/core/c/typeopenany.php @@ -16,9 +16,10 @@ class TypeOpenAny extends FormAttributes implements IForm self::FORM_ATTRIBUTE_CLASS => '', self::FORM_ATTRIBUTE_ANY => '', self::FORM_ATTRIBUTE_HREF => '', - 'src' => '', - 'alt' => '', - 'style' => '' + self::FORM_ATTRIBUTE_SRC => '', + self::FORM_ATTRIBUTE_ALT => '', + 'style' => '', + 'data-sitekey' => '' ); /** diff --git a/core/i/IForm.php b/core/i/IForm.php index 29847dc..6be0274 100755 --- a/core/i/IForm.php +++ b/core/i/IForm.php @@ -33,6 +33,7 @@ interface IForm const FORM_ATTRIBUTE_ALT = 'alt'; const FORM_ATTRIBUTE_ID = 'id'; const FORM_ATTRIBUTE_CLASS = 'class'; + const FORM_ATTRIBUTE_MULTIPLE = 'multiple'; const FORM_ATTRIBUTE_FOR = 'for'; const FORM_ATTRIBUTE_FORM = 'form'; const FORM_ATTRIBUTE_PLACEHOLDER = 'placeholder'; @@ -43,6 +44,7 @@ interface IForm const FORM_ATTRIBUTE_ONBLUR = 'onblur'; const FORM_ATTRIBUTE_ONFOCUS = 'onfocus'; const FORM_ATTRIBUTE_ONCLICK = 'onclick'; + const FORM_ATTRIBUTE_DATA = 'data'; const FORM_ATTRIBUTE_SELECTED = 'selected'; const FORM_ATTRIBUTE_CONTEXT = 'context'; const FORM_ATTRIBUTE_CHECKED = 'checked'; @@ -55,6 +57,10 @@ interface IForm const FORM_ATTRIBUTE_TS_DECIMALS = "data-bts-decimals"; const FORM_ATTRIBUTE_TS_STEPS = "data-bts-step"; + const FROM_ATTRIBUTE_STYLE = 'style'; + + const FORM_ATTRIBUTE_DATA_SITEKEY = 'data-sitekey'; + /** * @desc loads the current Form element to the form * @param $attributes From 0791d99310904ec266c4060e6208f2be18ff1968 Mon Sep 17 00:00:00 2001 From: "stephan.kasdorf" Date: Fri, 10 Oct 2025 13:48:50 +0200 Subject: [PATCH 4/9] Enhance `typeopenany.php` with new attributes and update `IForm.php` for improved form handling. --- core/c/typeopenany.php | 18 +++++++++--------- core/i/IForm.php | 2 -- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/core/c/typeopenany.php b/core/c/typeopenany.php index b0fa6a9..8fc0c02 100755 --- a/core/c/typeopenany.php +++ b/core/c/typeopenany.php @@ -11,15 +11,15 @@ class TypeOpenAny extends FormAttributes implements IForm { private $_attributes = array( - self::FORM_VALUE => '', - self::FORM_ATTRIBUTE_ID => '', - self::FORM_ATTRIBUTE_CLASS => '', - self::FORM_ATTRIBUTE_ANY => '', - self::FORM_ATTRIBUTE_HREF => '', - self::FORM_ATTRIBUTE_SRC => '', - self::FORM_ATTRIBUTE_ALT => '', - 'style' => '', - 'data-sitekey' => '' + self::FORM_VALUE => '', + self::FORM_ATTRIBUTE_ID => '', + self::FORM_ATTRIBUTE_CLASS => '', + self::FORM_ATTRIBUTE_ANY => '', + self::FORM_ATTRIBUTE_HREF => '', + self::FORM_ATTRIBUTE_SRC => '', + self::FORM_ATTRIBUTE_ALT => '', + self::FROM_ATTRIBUTE_STYLE => '', + self::FORM_ATTRIBUTE_DATA_SITEKEY => '' ); /** diff --git a/core/i/IForm.php b/core/i/IForm.php index 6be0274..ef5bcfa 100755 --- a/core/i/IForm.php +++ b/core/i/IForm.php @@ -56,9 +56,7 @@ interface IForm const FORM_ATTRIBUTE_HREF = 'href'; const FORM_ATTRIBUTE_TS_DECIMALS = "data-bts-decimals"; const FORM_ATTRIBUTE_TS_STEPS = "data-bts-step"; - const FROM_ATTRIBUTE_STYLE = 'style'; - const FORM_ATTRIBUTE_DATA_SITEKEY = 'data-sitekey'; /** From cd7c0f723adf3b63f134cdad250c980315a56282 Mon Sep 17 00:00:00 2001 From: "stephan.kasdorf" Date: Fri, 10 Oct 2025 13:50:23 +0200 Subject: [PATCH 5/9] Enhance `typeopenany.php` with new attributes for improved functionality. --- core/c/typeopenany.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/c/typeopenany.php b/core/c/typeopenany.php index 8fc0c02..7b5e0fc 100755 --- a/core/c/typeopenany.php +++ b/core/c/typeopenany.php @@ -39,6 +39,6 @@ public function loadElement($attributes) */ private function _setElement( ) { - $this->_element = '' . 'VALUE' . "\n"; + $this->_element = '' . 'VALUE' . "\n"; } } From 0abbb49b80384860f1b2f435b213fdd37934e6a5 Mon Sep 17 00:00:00 2001 From: "stephan.kasdorf" Date: Mon, 13 Oct 2025 12:27:59 +0200 Subject: [PATCH 6/9] Enhance `formattributes.php` with new attributes for improved functionality. --- core/c/formattributes.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/c/formattributes.php b/core/c/formattributes.php index 8a52ade..75b5353 100755 --- a/core/c/formattributes.php +++ b/core/c/formattributes.php @@ -73,6 +73,9 @@ protected function _setAttributes( $attributes ) $this->_element = str_replace(' min="MIN"', '', $this->_element); $this->_element = str_replace(' max="MAX"', '', $this->_element); $this->_element = str_replace(' href="HREF"', '', $this->_element); + $this->_element = str_replace(' src="SRC"', '', $this->_element); + $this->_element = str_replace(' alt="ALT"', '', $this->_element); + $this->_element = str_replace(' style="STYLE"', '', $this->_element); $this->_element = str_replace(' step="STEP"', '', $this->_element); $this->_element = str_replace(' tabindex="TABINDEX"', '', $this->_element); $this->_element = str_replace(' SPEECH', '', $this->_element); @@ -95,6 +98,7 @@ protected function _setAttributes( $attributes ) $this->_element = str_replace(' VALUE', '', $this->_element); $this->_element = str_replace(' PATTERN', '', $this->_element); $this->_element = str_replace('ANY', '', $this->_element); + $this->_element = str_replace('data-sitekey="DATA-SITEKEY"', '', $this->_element); } /** From 8688cdea12bd4038f2257033d3dd509b95f0990a Mon Sep 17 00:00:00 2001 From: "stephan.kasdorf" Date: Mon, 13 Oct 2025 14:10:26 +0200 Subject: [PATCH 7/9] Enhance `typeopenany.php` with new attributes for improved functionality. --- core/c/typeopenany.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/c/typeopenany.php b/core/c/typeopenany.php index 7b5e0fc..03be323 100755 --- a/core/c/typeopenany.php +++ b/core/c/typeopenany.php @@ -19,7 +19,8 @@ class TypeOpenAny extends FormAttributes implements IForm self::FORM_ATTRIBUTE_SRC => '', self::FORM_ATTRIBUTE_ALT => '', self::FROM_ATTRIBUTE_STYLE => '', - self::FORM_ATTRIBUTE_DATA_SITEKEY => '' + self::FORM_ATTRIBUTE_DATA_SITEKEY => '', + self::FORM_ATTRIBUTE_TYPE => '' ); /** @@ -39,6 +40,6 @@ public function loadElement($attributes) */ private function _setElement( ) { - $this->_element = '' . 'VALUE' . "\n"; + $this->_element = '' . 'VALUE' . "\n"; } } From ef6bce4002c352f89299149f4184a14d016443d3 Mon Sep 17 00:00:00 2001 From: "stephan.kasdorf" Date: Mon, 13 Oct 2025 14:14:44 +0200 Subject: [PATCH 8/9] Enhance `formattributes.php` and `typeopenany.php` with `role` attribute for improved functionality. --- core/c/formattributes.php | 1 + core/c/typeopenany.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/c/formattributes.php b/core/c/formattributes.php index 75b5353..0332b30 100755 --- a/core/c/formattributes.php +++ b/core/c/formattributes.php @@ -99,6 +99,7 @@ protected function _setAttributes( $attributes ) $this->_element = str_replace(' PATTERN', '', $this->_element); $this->_element = str_replace('ANY', '', $this->_element); $this->_element = str_replace('data-sitekey="DATA-SITEKEY"', '', $this->_element); + $this->_element = str_replace('role="ROLE"', '', $this->_element); } /** diff --git a/core/c/typeopenany.php b/core/c/typeopenany.php index 03be323..7d38189 100755 --- a/core/c/typeopenany.php +++ b/core/c/typeopenany.php @@ -20,7 +20,8 @@ class TypeOpenAny extends FormAttributes implements IForm self::FORM_ATTRIBUTE_ALT => '', self::FROM_ATTRIBUTE_STYLE => '', self::FORM_ATTRIBUTE_DATA_SITEKEY => '', - self::FORM_ATTRIBUTE_TYPE => '' + self::FORM_ATTRIBUTE_TYPE => '', + self::FORM_ATTRIBUTE_ROLE => '' ); /** @@ -40,6 +41,6 @@ public function loadElement($attributes) */ private function _setElement( ) { - $this->_element = '' . 'VALUE' . "\n"; + $this->_element = '' . 'VALUE' . "\n"; } } From e4462e9402545d44d0cc5f5179388bf1ea066591 Mon Sep 17 00:00:00 2001 From: "stephan.kasdorf" Date: Fri, 28 Nov 2025 09:24:09 +0100 Subject: [PATCH 9/9] Enhance `IDb.php`, `pdo.php`, and `mysql.db.php` with `deleteRowById` method for improved database handling. --- core/a/mysql.db.php | 10 ++++- core/c/pdo.php | 96 +++++++++++++++++++++++++++++++++++---------- core/i/IDb.php | 7 ++++ 3 files changed, 92 insertions(+), 21 deletions(-) mode change 100644 => 100755 core/a/mysql.db.php diff --git a/core/a/mysql.db.php b/core/a/mysql.db.php old mode 100644 new mode 100755 index 91a8f61..1e01a1e --- a/core/a/mysql.db.php +++ b/core/a/mysql.db.php @@ -169,5 +169,13 @@ public function selectRowByFieldWhere( $field = array() ) return Pdo::fetchRowInArrayByWhere(self::$table['table'], $field['field'], $field['value']); } - + /** + * @desc Deletes a row from the database table by id. + * @param int $id The id of the row to delete. + * @return bool Returns true if the deletion is successful, otherwise false. + */ + public function deleteRowById(int $id = 0): bool + { + Pdo::deleteRowById( self::getTable()['table'], $id ); + } } \ No newline at end of file diff --git a/core/c/pdo.php b/core/c/pdo.php index aa1646b..5ce477e 100755 --- a/core/c/pdo.php +++ b/core/c/pdo.php @@ -9,7 +9,7 @@ * @category - [PLEASE SPECIFIY] * @license - BSD License */ -final class pdo extends Mysql implements IPdo +final class Pdo extends Mysql implements IPdo { private static $section = false; @@ -55,11 +55,10 @@ protected static function loadTableNames(): array /** - * @param string $string - * - * @return array|bool - */ - public static function query( $string = self::PLACE_NO_QUERY ): array|bool + * @param string $string + * @return mixed + */ + public static function query( $string = self::PLACE_NO_QUERY ): mixed { if(!strstr($string, IOdbc::PLACE_SQL_UPDATE)) @@ -91,7 +90,7 @@ public static function query( $string = self::PLACE_NO_QUERY ): array|bool /** * @return array */ - private static function convertFetchToAssociative( array $result ): array + private static function convertFetchToAssociative( array $result ): array { $resultset = []; if(array_key_exists(0, $result)) @@ -169,10 +168,10 @@ public static function selectDatasetByFieldAndValue($tablename = self::PLACE_TAB * @return bool */ public static function updateColumnByFieldWhere( $tablename = self::PLACE_TABLE_NAME, - $column_name = IMysql::PLACE_COLUMN_NAME, - $parameter_name = IMysql::PLACE_SEARCH_TERM, - $field_name = IMysql::PLACE_FIELD_NAME, - $where_value = IMysql::PLACE_WHERE_VALUE ): bool + $column_name = IMysql::PLACE_COLUMN_NAME, + $parameter_name = IMysql::PLACE_SEARCH_TERM, + $field_name = IMysql::PLACE_FIELD_NAME, + $where_value = IMysql::PLACE_WHERE_VALUE ): bool { $statement = parent::getInstance( self::getSettingsSection() )->getConn(); $query = "UPDATE " . $tablename . " SET " . $column_name . " = :" . $column_name . " WHERE " . $field_name . " = :". $field_name; @@ -264,12 +263,12 @@ public static function updateRowById(string $tableName, array $columnNames, arra * @param bool $id * @return array */ - public static function fetchRowInArrayById($tablename = self::PLACE_TABLE_NAME, $id = self::NO_ID ) - { + public static function fetchRowInArrayById($tablename = self::PLACE_TABLE_NAME, $id = self::NO_ID ) + { $result = array(); - $statement = parent::getInstance( self::getSettingsSection() )->getConn(); - $describe = $statement->query('DESC ' . $tablename); - $describe->execute(); + $statement = parent::getInstance( self::getSettingsSection() )->getConn(); + $describe = $statement->query('DESC ' . $tablename); + $describe->execute(); $tableInformation = $describe->fetchAll( \PDO::FETCH_ASSOC ); foreach ( $tableInformation as $entry ) { @@ -374,9 +373,9 @@ public static function fetchRowsInArrayByWhere($tablename = IMysql::PLACE_TABLE_ * @return int|string */ public static function getLastInsertedID() - { - return parent::getInstance( self::getSettingsSection() )->getConn()->lastInsertId(); - } + { + return parent::getInstance( self::getSettingsSection() )->getConn()->lastInsertId(); + } /** * @param string $tablename @@ -413,6 +412,63 @@ public static function fetchTableAsArray( $tablename = self::PLACE_TABLE_NAME, $ return $result; } + /** + * @desc Deletes a row from the specified table by its ID. + * @param string $tablename The name of the table from which to delete the row. If empty, uses the default table. + * @param int $id The ID of the row to delete. + * @return bool Returns true if the deletion was successful, false otherwise. + */ + public static function deleteRowById(string $tablename = '', int $id = 0): bool + { + try { + // Validate that id is a valid number + if (!is_numeric($id) || $id <= 0) + { + throw new \InvalidArgumentException("FATAL ERROR in main CORE deleteRowById: Invalid ID value. Must be a positive number."); + } + + // Validate table name + $validTables = self::loadTableNames(); + if (!in_array($tablename, $validTables, true)) + { + throw new \InvalidArgumentException("FATAL ERROR in main CORE deleteRowById: Invalid table name: {$tablename}"); + } + + // Get PDO instance + $pdo = parent::getInstance(self::getSettingsSection())->getConn(); + + // Fetch the primary key field name + $queryPrimaryKey = "SELECT COLUMN_NAME FROM information_schema.COLUMNS + WHERE TABLE_NAME = :tableName + AND COLUMN_KEY = 'PRI' + LIMIT 1"; + $stmtPrimaryKey = $pdo->prepare($queryPrimaryKey); + $stmtPrimaryKey->bindValue(':tableName', $tablename); + $stmtPrimaryKey->execute(); + $primaryKeyResult = $stmtPrimaryKey->fetch(\PDO::FETCH_ASSOC); + + if (!$primaryKeyResult) { + throw new \RuntimeException('FATAL ERROR in main CORE deleteRowById: No primary key found for table ' . $tablename); + } + + $primaryKeyField = $primaryKeyResult['COLUMN_NAME']; + + // Prepare and execute DELETE statement + $query = "DELETE FROM " . $tablename . " WHERE " . $primaryKeyField . " = :id"; + $stmt = $pdo->prepare($query); + $stmt->bindValue(':id', $id, \PDO::PARAM_INT); + + return $stmt->execute(); + } catch (\PDOException $e) { + error_log($e->getMessage()); + return false; + } catch (\Exception $e) { + error_log($e->getMessage()); + return false; + } + } + + /** * @desc will insert the array with fieldnames into the database, if the last parameter is set it should be a string containing the * fieldname that should be encrypted @@ -421,7 +477,7 @@ public static function fetchTableAsArray( $tablename = self::PLACE_TABLE_NAME, $ * @param bool $encrypted * @return bool */ - public static function insertArrayIntoTable( $tablename = IMysql::PLACE_TABLE_NAME, $array_name = IMysql::PLACE_ARRAY_NAME, $encrypted = IMysql::PLACE_DES_ENCRYPT ): bool + public static function insertArrayIntoTable( $tablename = IMysql::PLACE_TABLE_NAME, $array_name = IMysql::PLACE_ARRAY_NAME, $encrypted = IMysql::PLACE_DES_ENCRYPT ): bool { $statement = parent::getInstance( self::getSettingsSection() )->getConn(); diff --git a/core/i/IDb.php b/core/i/IDb.php index 0e8ff35..306bf75 100755 --- a/core/i/IDb.php +++ b/core/i/IDb.php @@ -100,4 +100,11 @@ public function nextInsertIndex(); * @return mixed */ public function loadPasswordByUsername( $user_name = false ); + + /** + * @desc Deletes a row from the database by its ID. + * @param int $id The ID of the row to be deleted. Defaults to 0. + * @return bool Returns true if the deletion was successful, false otherwise. + */ + public function deleteRowById( int $id = 0 ): bool; } \ No newline at end of file