Hello. There is such a user class, for authorization, registration and checking whether the usver is authorized. I need to remake a class into functions, that is, call them as functions and not class objects. How can this be cut and assembled correctly?
class Account { private $account_data = []; public function __construct() { global $db; if(isset($_COOKIE['account_session'])) { $account_session = unserialize($_COOKIE['account_session']); if(isset($account_session['account_id']) && $account_session['token']) { $stmt = $db->prepare('SELECT * FROM `accounts` WHERE `id` = :id AND `token` = :token'); $stmt->bindParam(':id', $account_session['account_id'], PDO::PARAM_INT); $stmt->bindParam(':token', $account_session['token'], PDO::PARAM_STR); $stmt->execute(); if($stmt->rowCount()) { $this->account_data = $stmt->fetch(); } else { setcookie('account_session', null, 1, '/'); } } else { setcookie('account_session', null, 1, '/'); } } } public function Auth() { return isset($this->account_data['id']); } public function getData($id = 0) { global $db; if($id && $id != @$this->account_data['id']) { $stmt = $db->prepare('SELECT * FROM `accounts` WHERE `id` = :id'); $stmt->bindParam(':id', $id, PDO::PARAM_INT); $stmt->execute(); return $stmt->fetch(); } else { return $this->account_data; } } }