Hej alle sammen jeg får en fejl når jeg koder i PHP
Fuldfejl :
Fatal error: Using $this when not in object context in C:\SERVER\htdocs\ZinXan Social Network\core\classes\Users\Users.php on line 23
Kode :
- <?php
- class Users {
- public $MySqli;
-
- public static function rand_string($length) {
- $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- $size = strlen( $chars );
- for( $i = 0; $i < $length; $i++ ) {
- $str .= $chars[ rand( 0, $size - 1 ) ];
- }
- return $str;
- }
-
- public static function crypttext($sptext, $text) {
- $crypt = md5($text .$sptext);
- $crypt = sha1($text . $sptext . $crypt);
- $math = 5*45+2/3-21*3*33223;
- $crypt = md5('DFJthjtj7427373732737' . $text . $sptext . $math);
- $crypt = sha1(md5($crypt));
- }
-
- public static function Create_user(mysqli $MySqli, $username, $password, $name, $last, $email, $Birthday, $gender, $auser, $apass) {
- $salt = $this->rand_string(3);
- $salt = $this->crypttext("SaltCeryeer3334213", $salt);
-
- $password = md5('DFHt9W9k3JfnMnekrne99883838384383272372723734737372727374343727237378' . $password . 'DF1NF2N134G42NRnRWLFDQRIOSSQ2521432');
- $password = md5($password);
- $spuser = md5(sha1('FJgfehujt4Fj48ivJjggNFrerkfmFFwernnf93020101010101010' .$password . 'DJfh3' . $username . 'FJtfu5875r7dU483828fjJFhrtuy5474JFjr448JFjrjS'));
- $password = md5(sha1($spuser . $password . $username));
- $password = $this->crypttext("FMFMmu5u8urJFGj5j4ejdcJGjgfF4877F", $password);
- if($stmt=$MySqli->prepare('INSERT INTO `users`(`username`, `password`, `salt`, `name`, `last`, `email`, `age`, `gender`, `auser`, `apass`) VALUES (?,?,?,?,?,?,?,?,?)')) {
- $stmt->bind_param('ssssssssss', $username, $password, $salt, $name, $last, $email, $Birthday, $gender, $auser, $apass);
- $stmt->execute();
- $stmt->close();
- } else {
-
- }
- }
- public static function generate_age($birthdate) {
- //explode the date to get month, day and year
- $birthdate = explode("/", $birthdate);
- //get age from date or birthdate
- $age = (date("md", date("U", mktime(0, 0, 0, $birthdate[0], $birthdate[1], $birthdate[2]))) > date("md") ? ((date("Y") - $birthdate[2]) - 1): (date("Y") - $birthdate[2]));
- echo $age;
- }
-
- public static function Check_User(mysqli $mysqli,$username, $password) {
- $password = md5(sha1($username . $password . '4858484gjgjFntn4rn4gnRH4hbr4bVFEHHR' . '01010101011011110100101100110111' . $username));
- $spcuser = md5(sha1($username) . '58it7fdhHDH0001010101010110');
- $password = md5(sha1($spcuser . $password . $spcuser . 'FHrttrh4rrnrnjrnhrfdnrGHRHJ#E¤JRJD'));
- $password = md5(sha1($password . '01001010010101101001011010101010101010101010101010110101010101010'));
- if ($stmt = $mysqli->prepare("SELECT COUNT(*) FROM `users` WHERE username=? AND password=?")) {
- $stmt->bind_param("ss", $username, $password);
- $stmt->execute();
- $stmt->bind_result($count);
- $stmt->fetch();
- $stmt->close();
- }
- return ($count > 0 ? true : false);
- }
-
- public static function Check_Username(mysqli $MySqli,$username) {
- if ($stmt = $MySqli->prepare("SELECT COUNT(*) FROM `users` WHERE username=?")) {
- $stmt->bind_param("s", $username);
- $stmt->execute();
- $stmt->bind_result($count);
- $stmt->fetch();
- $stmt->close();
- }
- return ($count > 0 ? true : false);
- }
-
- public static function Check_Email(mysqli $mysqli,$email) {
- if ($stmt = $mysqli->prepare("SELECT COUNT(*) FROM `users` WHERE email=?")) {
- $stmt->bind_param("s", $email);
- $stmt->execute();
- $stmt->bind_result($count);
- $stmt->fetch();
- $stmt->close();
- }
-
- return ($count > 0 ? true : false);
- }
- }
- ?>