Merge remote-tracking branch 'origin/v1.0.1' into v1.0.1
This commit is contained in:
12
README.md
12
README.md
@@ -20,17 +20,23 @@ MMVC in the **nibiru framework** stands for Modular Model-View-Controller. Modul
|
|||||||
|
|
||||||
Usage: ./nibiru [-m <module_name>] [-c <controller_name>] [-h]
|
Usage: ./nibiru [-m <module_name>] [-c <controller_name>] [-h]
|
||||||
|
|
||||||
-m {name}: create a new module with the given name.
|
-m {name}: create a new module with the given name. Add -g switch if a Graylog Server present.
|
||||||
-c {name}: create a new controller with the given name.
|
-c {name}: create a new controller with the given name.
|
||||||
-p {name} -m {name}: create a new plugin with the given name in the given name for the module.
|
-p {name} -m {name}: create a new plugin with the given name in the given name for the module.
|
||||||
add -g switch if a Graylog Server present.
|
add -g switch if a Graylog Server present.
|
||||||
-cache-clear: will clear the cache of the applications template_c folder.
|
-cache-clear: will clear the cache of the applications template_c folder.
|
||||||
-s: check framework folders and permissions, and set them if they are not present.
|
-s: check framework folders and permissions, and set them if they are not present.
|
||||||
-mi {local|staging|production}: run migration files from application/settings/config/database/.
|
-mi {local|staging|production}: run migration files from application/settings/config/database/.
|
||||||
-mi-reset {local|staging|production}: will reset the migrations table, use only if you know what you are doing.
|
-mi-reset {local|staging|production}: will reset the migrations table, use only if you know what
|
||||||
-mi-reset-file {filename} {local|staging|production}: will reset the migration entry for a filename e.g. mytable.sql, use only if you know what you are doing.
|
you are doing.
|
||||||
|
-mi-reset-file {filename} {local|staging|production}: will reset the migration entry for a filename
|
||||||
|
e.g. mytable.sql, use only if you know what
|
||||||
|
you are doing.
|
||||||
-ws {URL} -wp {PORT}: connect to a WebSocket at the given URL and port.
|
-ws {URL} -wp {PORT}: connect to a WebSocket at the given URL and port.
|
||||||
-h: display this help message.
|
-h: display this help message.
|
||||||
|
-new-cms-page {name} (only available with the CMS module): will create a new page with connection
|
||||||
|
to an existing template.
|
||||||
|
-delete-cms-page {name} (only available with the CMS module): will delete a CMS page with the given name.
|
||||||
-version or -v: display the version of the nibiru binary, and the current framework version.
|
-version or -v: display the version of the nibiru binary, and the current framework version.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -75,11 +75,12 @@ abstract class Db implements IDb
|
|||||||
* @desc will update the a row with the $rowset parameter by the given id
|
* @desc will update the a row with the $rowset parameter by the given id
|
||||||
* @param array $rowData
|
* @param array $rowData
|
||||||
* @param int $id
|
* @param int $id
|
||||||
|
* @param string $encrypted
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function updateRowById(array $rowData, int $id): bool
|
public function updateRowById(array $rowData, int $id, string $encrypted = ""): bool
|
||||||
{
|
{
|
||||||
return Pdo::updateRowById( self::getTable()['table'], self::getTable()['fields'], $rowData, $id );
|
return Pdo::updateRowById( self::getTable()['table'], self::getTable()['fields'], $rowData, $id, $encrypted );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -188,17 +188,19 @@ final class pdo extends Mysql implements IPdo
|
|||||||
* @param string $tableName The name of the table to update.
|
* @param string $tableName The name of the table to update.
|
||||||
* @param array $data An associative array where keys are column names and values are the new values for those columns.
|
* @param array $data An associative array where keys are column names and values are the new values for those columns.
|
||||||
* @param int $id The value of the primary key for the row to update.
|
* @param int $id The value of the primary key for the row to update.
|
||||||
|
* @param string $encrypted The field that has encrypted data for handling correct field encryption
|
||||||
*
|
*
|
||||||
* @return bool Returns true on success or false on failure.
|
* @return bool Returns true on success or false on failure.
|
||||||
*/
|
*/
|
||||||
public static function updateRowById(string $tableName, array $columnNames, array $data, int $id): bool
|
public static function updateRowById(string $tableName, array $columnNames, array $data, int $id, string $encrypted = IMysql::PLACE_DES_ENCRYPT): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Inside a method of the mysql.db.php class or its subclass
|
// Inside a method of the mysql.db.php class or its subclass
|
||||||
$validTables = self::loadTableNames();
|
$validTables = self::loadTableNames();
|
||||||
|
|
||||||
// Validate the table name
|
// Validate the table name
|
||||||
if (!in_array($tableName, $validTables, true)) {
|
if (!in_array($tableName, $validTables, true))
|
||||||
|
{
|
||||||
throw new \InvalidArgumentException("FATAL ERROR in main CORE updateRowById: Invalid table name: {$tableName}");
|
throw new \InvalidArgumentException("FATAL ERROR in main CORE updateRowById: Invalid table name: {$tableName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,8 +217,8 @@ final class pdo extends Mysql implements IPdo
|
|||||||
|
|
||||||
// Fetch the primary key field name
|
// Fetch the primary key field name
|
||||||
$queryPrimaryKey = "SELECT COLUMN_NAME FROM information_schema.COLUMNS
|
$queryPrimaryKey = "SELECT COLUMN_NAME FROM information_schema.COLUMNS
|
||||||
WHERE TABLE_NAME = :tableName
|
WHERE TABLE_NAME = :tableName
|
||||||
AND COLUMN_KEY = 'PRI' LIMIT 1;";
|
AND COLUMN_KEY = 'PRI' LIMIT 1;";
|
||||||
$stmtPrimaryKey = $pdo->prepare($queryPrimaryKey);
|
$stmtPrimaryKey = $pdo->prepare($queryPrimaryKey);
|
||||||
$stmtPrimaryKey->bindValue(':tableName', $tableName);
|
$stmtPrimaryKey->bindValue(':tableName', $tableName);
|
||||||
$stmtPrimaryKey->execute();
|
$stmtPrimaryKey->execute();
|
||||||
@@ -230,7 +232,13 @@ final class pdo extends Mysql implements IPdo
|
|||||||
$query = "UPDATE " . $tableName . " SET ";
|
$query = "UPDATE " . $tableName . " SET ";
|
||||||
$updateParts = [];
|
$updateParts = [];
|
||||||
foreach ($data as $column => $value) {
|
foreach ($data as $column => $value) {
|
||||||
$updateParts[] = $column . " = :" . $column;
|
if ($column === $encrypted)
|
||||||
|
{
|
||||||
|
// Encrypt the value using DES_ENCRYPT function
|
||||||
|
$updateParts[] = "$column = DES_ENCRYPT(:$column, :key)";
|
||||||
|
} else {
|
||||||
|
$updateParts[] = "$column = :$column";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$query .= implode(', ', $updateParts);
|
$query .= implode(', ', $updateParts);
|
||||||
$query .= " WHERE " . $primaryKeyField . " = :primaryKeyValue";
|
$query .= " WHERE " . $primaryKeyField . " = :primaryKeyValue";
|
||||||
@@ -238,6 +246,11 @@ final class pdo extends Mysql implements IPdo
|
|||||||
foreach ($data as $column => $value) {
|
foreach ($data as $column => $value) {
|
||||||
$stmt->bindValue(':' . $column, $value);
|
$stmt->bindValue(':' . $column, $value);
|
||||||
}
|
}
|
||||||
|
if ($encrypted != "")
|
||||||
|
{
|
||||||
|
$key = Config::getInstance()->getConfig()[View::NIBIRU_SECURITY]["password_hash"];
|
||||||
|
$stmt->bindValue(':key', $key);
|
||||||
|
}
|
||||||
$stmt->bindValue(':primaryKeyValue', $id);
|
$stmt->bindValue(':primaryKeyValue', $id);
|
||||||
return $stmt->execute();
|
return $stmt->execute();
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ class TypeCheckbox extends FormAttributes implements IForm
|
|||||||
self::FORM_VALUE => '',
|
self::FORM_VALUE => '',
|
||||||
self::FORM_ATTRIBUTE_ID => '',
|
self::FORM_ATTRIBUTE_ID => '',
|
||||||
self::FORM_ATTRIBUTE_CLASS => '',
|
self::FORM_ATTRIBUTE_CLASS => '',
|
||||||
self::FORM_ATTRIBUTE_CHECKED => ''
|
self::FORM_ATTRIBUTE_CHECKED => '',
|
||||||
|
self::FORM_ATTRIBUTE_DISABLED => ''
|
||||||
);
|
);
|
||||||
|
|
||||||
public function loadElement( $attributes )
|
public function loadElement( $attributes )
|
||||||
@@ -33,7 +34,7 @@ class TypeCheckbox extends FormAttributes implements IForm
|
|||||||
*/
|
*/
|
||||||
private function _setElement( )
|
private function _setElement( )
|
||||||
{
|
{
|
||||||
$this->_element = '<input type="checkbox" name="NAME" value="VALUE" ID CLASS CHECKED>' . ' VALUE' . "\n";
|
$this->_element = '<input type="checkbox" name="NAME" value="VALUE" ID CLASS CHECKED DISABLED>' . ' VALUE' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,10 @@ interface IDb
|
|||||||
* @desc will update the a row with the $rowset parameter by the given id
|
* @desc will update the a row with the $rowset parameter by the given id
|
||||||
* @param array $rowData
|
* @param array $rowData
|
||||||
* @param int $id
|
* @param int $id
|
||||||
|
* @param string $encrypted
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function updateRowById( array $rowData, int $id );
|
public function updateRowById( array $rowData, int $id, string $encrypted = "" );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc updates a row by a given field and field where search value
|
* @desc updates a row by a given field and field where search value
|
||||||
|
|||||||
Reference in New Issue
Block a user