*
* @var mysqli
*/
- private $_DB;
+ private mysqli $_DB;
/**
* if the user is logged in or not
*
* @var boolean
*/
- protected $isSignedIn = false;
+ protected bool $isSignedIn = false;
/**
* the data from the current user
*
* @var array
*/
- protected $userData = false;
+ protected array $userData = array();
/**
* the user ID from user management or default
*
- * @var integer
+ * @var string|int
*/
- protected $userID = 0;
+ protected string|int $userID = 0;
/**
* the rights string defined the mysql query !
*
* @var array
*/
- protected $_rightsArray = array(
+ protected array $_rightsArray = array(
'user' => array(
'read' => 'r________',
'write' => 'rw_______',
* @param string $param
* @return bool|mixed
*/
- public function param(string $param) {
+ public function param(string $param): mixed {
$ret = false;
$param = trim($param);
* @param string $token
* @return void
*/
- public function authByApiToken(string $token) {
+ public function authByApiToken(string $token): void {
if(!empty($token)) {
$queryStr = "SELECT `id`
FROM `".DB_PREFIX."_user`
* create the sql string for rights sql
*
* @param string $mode
- * @param bool $tableName
+ * @param string $tableName
* @return string
*/
- public function getSQLRightsString($mode = "read", $tableName=false): string {
+ public function getSQLRightsString(string $mode = "read", string $tableName = ''): string {
$str = '';
$prefix = '';
return false;
}
-
$garbage_timeout = SESSION_LIFETIME + 300;
ini_set('session.gc_maxlifetime', $garbage_timeout);
# the % rate how often the session.gc is run
# existing session info
$result = $query->fetch_assoc();
- # valide the token
+ # validate the token
$_check = $this->_createToken($result['salt']);
if (!empty($_check) && $result['token'] === $_check['token']) {
$this->userID = $result['fk_user_id'];
-
$ret = true;
}
+ else {
+ error_log("[ERROR] ".__METHOD__." mismatched token.");
+ if(isset($result['fk_user_id']) && !empty($result['fk_user_id'])) {
+ $this->userID = $result['fk_user_id'];
+ }
+ $this->_destroySession();
+ }
}
}
catch (Exception $e) {
*
* @return void
*/
- protected function _loginActions() {
+ protected function _loginActions(): void {
# clean old sessions on session table
$timeframe = date("Y-m-d H:i:s",time()-SESSION_LIFETIME);
$queryStr = "DELETE FROM `".DB_PREFIX."_userSession`
*
* @return void
*/
- protected function _loadUser() {
+ protected function _loadUser(): void {
if(!empty($this->userID)) {
$queryStr = "SELECT u.`id`, u.`baseGroupId`,u.`protected`,u.`password`,u.`login`,u.`name`,
u.`apiToken`,u.`apiTokenValidDate`,
* HTTP_ACCEPT_ENCODING, HTTP_VIA
* and a salt
*
- * @param bool $salt
- * @return bool|array
+ * @param string $salt
+ * @return array
*/
- protected function _createToken($salt=false) {
- $ret = false;
+ protected function _createToken(string $salt = ''): array {
+ $ret = array();
$defaultStr = "unknown";
*
* @var mysqli
*/
- private $_DB;
+ private mysqli $_DB;
/**
* The user object to query with
*
* @var Doomguy
*/
- private $_User;
+ private Doomguy $_User;
/**
* Currently loaded collection to work with
*
* @var string Number
*/
- private $_collectionId;
+ private string $_collectionId;
/**
* Options for db queries
*
* @var array
*/
- private $_queryOptions;
+ private array $_queryOptions;
/**
* Store the all the values for an entry from lookup table
*
* @var array
*/
- private $_cacheLookupValuesForEntry = array();
+ private array $_cacheLookupValuesForEntry = array();
/**
* Store entryFields for run time
*
* @var array
*/
- private $_cacheEntryFields = array();
+ private array $_cacheEntryFields = array();
/**
* Mancubus constructor.
*
* @param string $collectionId Number
*/
- public function setCollection(string $collectionId) {
+ public function setCollection(string $collectionId): void {
if(!empty($collectionId)) {
$this->_collectionId = $collectionId;
}
*
* @param array $options
*/
- public function setQueryOptions(array $options) {
+ public function setQueryOptions(array $options): void {
if(!isset($options['limit'])) $options['limit'] = 5;
if(!isset($options['offset'])) $options['offset'] = false;
* @param string $search Search string to search for
* @return array
*/
- public function getLatest(string $selections, string $entries, $search=''): array {
+ public function getLatest(string $selections, string $entries, string $search = ''): array {
$ret = array();
$queryStr = "SELECT `c`.`id`, `c`.`name`, `c`.`description`, `c`.`created`,
* @param array $searchData
* @return array
*/
- public function getEntries($searchData=array()): array {
+ public function getEntries(array $searchData = array()): array {
$ret = array();
if(!empty($this->_collectionId)) {
* Retrieve all the data needed to display the entry for given entryId
*
* @param string $entryId Number
- * @return array|mixed
+ * @return array
*/
public function getEntry(string $entryId): array {
$ret = array();
* lookup function for field type upload_multiple
*
* @param string $entryId Number
- * @param string $fieldData
+ * @param array $fieldData
* @return array
*/
- private function _loadFieldValue_upload_multiple(string $entryId, string $fieldData): array {
+ private function _loadFieldValue_upload_multiple(string $entryId, array $fieldData): array {
$ret = array();
if(!empty($entryId) && !empty($fieldData) && !empty($this->_collectionId)) {
*
* @return void
*/
- private function _setDefaults() {
+ private function _setDefaults(): void {
// default query options
$options['limit'] = 5;
$options['offset'] = false;