Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3.2.0 develop #41

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions hungng/HungNG_Custom_Based_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ public function getTableName()
*/
public function bindDBPrefix($table)
{
if (strpos($table, $this->db->dbprefix)) {
return $table;
if (!empty($this->db->dbprefix)) {
if (strpos($table, $this->db->dbprefix)) {
return $table;
}
}

return $this->db->dbprefix($table);
Expand Down
2 changes: 1 addition & 1 deletion thirdParty/REST/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public function to_json($data = null)
if (empty($callback) === true) {
return json_encode($data, JSON_UNESCAPED_UNICODE);
} // We only honour a jsonp callback which are valid javascript identifiers
elseif (preg_match('/^[a-z_\$][a-z0-9\$_]*(\.[a-z_\$][a-z0-9\$_]*)*$/i', $callback)) {
if (preg_match('/^[a-z_\$][a-z0-9\$_]*(\.[a-z_\$][a-z0-9\$_]*)*$/i', $callback)) {
// Return the data as encoded json with a callback
return $callback . '(' . json_encode($data, JSON_UNESCAPED_UNICODE) . ');';
}
Expand Down
11 changes: 4 additions & 7 deletions thirdParty/REST/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function getBodyParams()

$contentType = $this->getContentType();

if (strcasecmp($contentType, 'application/json') == 0) {
if (strcasecmp($contentType, 'application/json') === 0) {
// JSON content type
$this->_bodyParams = json_decode($this->getRawBody(), true);
} elseif ($this->getMethod() === 'POST') {
Expand Down Expand Up @@ -131,7 +131,7 @@ public function input()
*/
public function getAuthCredentialsWithBasic()
{
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
if (isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {

return [$_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']];
}
Expand Down Expand Up @@ -166,12 +166,9 @@ public function getAuthCredentialsWithBearer()
{
$b64token = null;

if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
if (isset($_SERVER['HTTP_AUTHORIZATION']) && strpos(bear_str_to_lower($_SERVER['HTTP_AUTHORIZATION']), 'bearer ') === 0) {

if (strpos(bear_str_to_lower($_SERVER['HTTP_AUTHORIZATION']), 'bearer ') === 0) {

$b64token = substr($_SERVER['HTTP_AUTHORIZATION'], 7);
}
$b64token = substr($_SERVER['HTTP_AUTHORIZATION'], 7);
}

return $b64token;
Expand Down
24 changes: 12 additions & 12 deletions thirdParty/REST/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function __construct()
/**
* Set Response Format into CI_Output
*
* @param string Response format
* @param string $format Response format
*/
public function setFormat($format)
{
Expand All @@ -105,7 +105,7 @@ public function setFormat($format)
*
* @todo Format data before send
*
* @param mixed Response data
* @param mixed $data Response data
*
* @return object self
*/
Expand Down Expand Up @@ -189,10 +189,10 @@ public function send()
}

/**
* Common format funciton by format types. {FORMAT}Format()
* Common format function by format types. {FORMAT}Format()
*
* @param array Pre-handle array data
* @param string Format
* @param array $data Pre-handle array data
* @param string $format Format
*
* @return string Formatted data by specified formatter
*/
Expand All @@ -207,16 +207,16 @@ public function format($data, $format)
$data = $this->{$formatFunc}($data);
} elseif (is_array($data)) {
// Use JSON while the Formatter not found and the data is array
$data = $this->formatJson($data);
$data = self::formatJson($data);
}

return $data;
}

/**
* Common format funciton by format types. {FORMAT}Format()
* Common format function by format types. {FORMAT}Format()
*
* @param array Pre-handle array data
* @param array $data Pre-handle array data
*
* @return string Formatted data
*/
Expand All @@ -228,10 +228,10 @@ public static function formatJson($data)
/**
* JSON output shortcut
*
* @param array|mixed Callback data body, false will remove body key
* @param int Callback status code
* @param array|mixed $data Callback data body, false will remove body key
* @param int $statusCode Callback status code
*
* @return string Response body data
* @return string|void Response body data
* @throws \Exception
*/
public function json($data, $statusCode = null)
Expand All @@ -241,7 +241,7 @@ public function json($data, $statusCode = null)
$this->setStatusCode($statusCode);
}

$this->setFormat(Response::FORMAT_JSON);
$this->setFormat(self::FORMAT_JSON);

if (!is_null($data)) {
$this->setData($data);
Expand Down