Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once "conn.php";
- /*
- public function CRUD($type,$request){
- switch($type){
- case "tag":
- if ($request == "insert"){
- }
- elseif ($request == "delete"){
- }
- elseif ($request == "read"){
- }
- elseif ($request == "update"){
- }
- else{
- echo "Nierozpoznane żądanie";
- }
- break;
- case "counter":
- if ($request == "insert"){
- }
- elseif ($request == "delete"){
- }
- elseif ($request == "read"){
- }
- elseif ($request == "update"){
- }
- else{
- echo "Nierozpoznane żądanie";
- }
- break;
- case "action":
- if ($request == "insert"){
- }
- elseif ($request == "delete"){
- }
- elseif ($request == "read"){
- }
- elseif ($request == "update"){
- }
- else{
- echo "Nierozpoznane żądanie";
- }
- break;
- case "quest":
- if ($request == "insert"){
- }
- elseif ($request == "delete"){
- }
- elseif ($request == "read"){
- }
- elseif ($request == "update"){
- }
- else{
- echo "Nierozpoznane żądanie";
- }
- break;
- case "npc":
- if ($request == "insert"){
- }
- elseif ($request == "delete"){
- }
- elseif ($request == "read"){
- }
- elseif ($request == "update"){
- }
- else{
- echo "Nierozpoznane żądanie";
- }
- break;
- case "mainUser":
- if ($request == "insert"){
- }
- elseif ($request == "delete"){
- }
- elseif ($request == "read"){
- }
- elseif ($request == "update"){
- }
- else{
- echo "Nierozpoznane żądanie";
- }
- break;
- }
- }
- */
- class Login {
- protected $username;
- protected $password;
- public function __construct() {
- $this->username = "blank";
- $this->password = "blank";
- }
- public function checkCredentials($email, $input_password) {
- try {
- $conn = new Connection();
- $db = $conn->openConnection();
- $stm = $db->prepare("SELECT username, password, email FROM users WHERE email=:email");
- $stm->bindParam('email', $email, PDO::PARAM_STR);
- $stm->execute();
- if ($stm->rowCount() > 0) {
- $result = $stm->fetch(PDO::FETCH_OBJ);
- if (password_verify($input_password, $result->password)) {
- return "1";
- }
- else {
- return "0";
- }
- }
- else {
- return "0";
- }
- }
- catch(PDOException $e) {
- exit($e->getMessage());
- }
- }
- }
- class CheckIfTagExists {
- public $tag_name;
- public function __construct() {
- $this->tag_name = "blank";
- }
- public function uniqueTest($tag_name) {
- try {
- $conn = new Connection();
- $db = $conn->openConnection();
- $stm = $db->prepare("SELECT id from questy.tags WHERE name=:tag_name");
- $stm->bindParam('tag_name', $tag_name, PDO::PARA_STR);
- $stm->execute();
- if ($stm->rowCount() > 0) {
- return "1";
- }
- else {
- return "0";
- }
- }
- catch(PDOException $e) {
- exit($e->getMessage());
- }
- }
- }
- class CheckIfCounterExists {
- public $counter_name;
- public function __construct() {
- $this->counter_name = "blank";
- }
- public function uniqueTest($counter_name) {
- try {
- $conn = new Connection();
- $db = $conn->openConnection();
- $stm = $db->prepare("SELECT id from questy.counters WHERE name=:counter_name");
- $stm->bindParam('counter_name', $counter_name, PDO::PARA_STR);
- $stm->execute();
- if ($stm->rowCount() > 0) {
- return "1";
- }
- else {
- return "0";
- }
- }
- catch(PDOException $e) {
- exit($e->getMessage());
- }
- }
- }
- class CheckIfQuestExists {
- public $quest_name;
- public function __construct() {
- $this->quest_name = "blank";
- }
- public function uniqueTest($quest_name) {
- try {
- $conn = new Connection();
- $db = $conn->openConnection();
- $stm = $db->prepare("SELECT id from questy.quests WHERE name=:quest_name");
- $stm->bindParam('quest_name', $quest_name, PDO::PARA_STR);
- $stm->execute();
- if ($stm->rowCount() > 0) {
- return "1";
- }
- else {
- return "0";
- }
- }
- catch(PDOException $e) {
- exit($e->getMessage());
- }
- }
- }
- class CheckIfNPCExists {
- public $npc_name;
- public function __construct() {
- $this->npc_name = "blank";
- }
- public function uniqueTest($npc_name) {
- try {
- $conn = new Connection();
- $db = $conn->openConnection();
- $stm = $db->prepare("SELECT id from questy.npcs WHERE name=:npc_name");
- $stm->bindParam('npc_name', $npc_name, PDO::PARA_STR);
- $stm->execute();
- if ($stm->rowCount() > 0) {
- return "1";
- }
- else {
- return "0";
- }
- }
- catch(PDOException $e) {
- exit($e->getMessage());
- }
- }
- }
- class CheckIfActionExists {
- public $action_name;
- public function __construct() {
- $this->action_name = "blank";
- }
- public function uniqueTest($action_name) {
- try {
- $conn = new Connection();
- $db = $conn->openConnection();
- $stm = $db->prepare("SELECT id from questy.npcs WHERE name=:action_name");
- $stm->bindParam('action_name', $action_name, PDO::PARA_STR);
- $stm->execute();
- if ($stm->rowCount() > 0) {
- return "1";
- }
- else {
- return "0";
- }
- }
- catch(PDOException $e) {
- exit($e->getMessage());
- }
- }
- }
- class CheckIfDialogueExists {
- public $dialogue_name;
- public $npc_id;
- public function __construct() {
- $this->dialogue_name = "blank";
- $this->npc_id = "blank";
- }
- public function uniqueTest($dialogue_name,$npc_id) {
- try {
- $conn = new Connection();
- $db = $conn->openConnection();
- $stm = $db->prepare("SELECT id, npc_id from questy.dialogues WHERE name=:dialogue_name AND npc_id:npc_id");
- $stm->bindParam('dialogue_name', $dialogue_name, PDO::PARA_STR);
- $stm->bindParam('npc_id', $npc_id, PDO::PARA_STR);
- $stm->execute();
- if ($stm->rowCount() > 0) {
- return "1";
- }
- else {
- return "0";
- }
- }
- catch(PDOException $e) {
- exit($e->getMessage());
- }
- }
- }
- class CheckIfOptionsExists {
- public $option_name;
- public $npc_id;
- public function __construct() {
- $this->option_name = "blank";
- $this->npc_id = "blank";
- }
- public function uniqueTest($option_name,$npc_id) {
- try {
- $conn = new Connection();
- $db = $conn->openConnection();
- $stm = $db->prepare("SELECT id, npc_id from questy.options WHERE name=:option_name AND npc_id:npc_id");
- $stm->bindParam('option_name', $option_name, PDO::PARA_STR);
- $stm->bindParam('npc_id', $npc_id, PDO::PARA_STR);
- $stm->execute();
- if ($stm->rowCount() > 0) {
- return "1";
- }
- else {
- return "0";
- }
- }
- catch(PDOException $e) {
- exit($e->getMessage());
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement