Advertisement
Guest User

Untitled

a guest
Nov 26th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.22 KB | None | 0 0
  1. <?php
  2. include_once "conn.php";
  3.  
  4. /*
  5. public function CRUD($type,$request){
  6.     switch($type){
  7.       case "tag":
  8.         if ($request == "insert"){
  9.  
  10.         }
  11.         elseif ($request == "delete"){
  12.  
  13.         }
  14.         elseif ($request == "read"){
  15.  
  16.         }
  17.         elseif ($request == "update"){
  18.  
  19.         }
  20.         else{
  21.           echo "Nierozpoznane żądanie";
  22.         }
  23.         break;
  24.       case "counter":
  25.         if ($request == "insert"){
  26.  
  27.         }
  28.         elseif ($request == "delete"){
  29.  
  30.         }
  31.         elseif ($request == "read"){
  32.  
  33.         }
  34.         elseif ($request == "update"){
  35.  
  36.         }
  37.         else{
  38.           echo "Nierozpoznane żądanie";
  39.         }
  40.         break;
  41.       case "action":
  42.         if ($request == "insert"){
  43.  
  44.         }
  45.         elseif ($request == "delete"){
  46.  
  47.         }
  48.         elseif ($request == "read"){
  49.  
  50.         }
  51.         elseif ($request == "update"){
  52.  
  53.         }
  54.         else{
  55.           echo "Nierozpoznane żądanie";
  56.         }
  57.         break;
  58.       case "quest":
  59.         if ($request == "insert"){
  60.  
  61.         }
  62.         elseif ($request == "delete"){
  63.  
  64.         }
  65.         elseif ($request == "read"){
  66.  
  67.         }
  68.         elseif ($request == "update"){
  69.  
  70.         }
  71.         else{
  72.           echo "Nierozpoznane żądanie";
  73.         }
  74.         break;
  75.       case "npc":
  76.         if ($request == "insert"){
  77.  
  78.         }
  79.         elseif ($request == "delete"){
  80.  
  81.         }
  82.         elseif ($request == "read"){
  83.  
  84.         }
  85.         elseif ($request == "update"){
  86.  
  87.         }
  88.         else{
  89.           echo "Nierozpoznane żądanie";
  90.         }
  91.         break;
  92.       case "mainUser":
  93.         if ($request == "insert"){
  94.  
  95.         }
  96.         elseif ($request == "delete"){
  97.  
  98.         }
  99.         elseif ($request == "read"){
  100.  
  101.         }
  102.         elseif ($request == "update"){
  103.  
  104.         }
  105.         else{
  106.           echo "Nierozpoznane żądanie";
  107.         }
  108.         break;
  109.     }
  110.     }
  111. */
  112. class Login {
  113.     protected $username;
  114.     protected $password;
  115.  
  116.     public function __construct() {
  117.         $this->username = "blank";
  118.         $this->password = "blank";
  119.     }
  120.     public function checkCredentials($email, $input_password) {
  121.         try {
  122.             $conn = new Connection();
  123.             $db = $conn->openConnection();
  124.             $stm = $db->prepare("SELECT username, password, email FROM users WHERE email=:email");
  125.             $stm->bindParam('email', $email, PDO::PARAM_STR);
  126.             $stm->execute();
  127.             if ($stm->rowCount() > 0) {
  128.                 $result = $stm->fetch(PDO::FETCH_OBJ);
  129.                 if (password_verify($input_password, $result->password)) {
  130.                     return "1";
  131.                 }
  132.                 else {
  133.                     return "0";
  134.                 }
  135.             }
  136.             else {
  137.                 return "0";
  138.             }
  139.         }
  140.         catch(PDOException $e) {
  141.             exit($e->getMessage());
  142.         }
  143.     }
  144. }
  145. class CheckIfTagExists {
  146.     public $tag_name;
  147.     public function __construct() {
  148.         $this->tag_name = "blank";
  149.     }
  150.     public function uniqueTest($tag_name) {
  151.         try {
  152.             $conn = new Connection();
  153.             $db = $conn->openConnection();
  154.             $stm = $db->prepare("SELECT id from questy.tags WHERE name=:tag_name");
  155.             $stm->bindParam('tag_name', $tag_name, PDO::PARA_STR);
  156.             $stm->execute();
  157.             if ($stm->rowCount() > 0) {
  158.                 return "1";
  159.             }
  160.             else {
  161.                 return "0";
  162.             }
  163.         }
  164.         catch(PDOException $e) {
  165.             exit($e->getMessage());
  166.         }
  167.     }
  168. }
  169. class CheckIfCounterExists {
  170.     public $counter_name;
  171.     public function __construct() {
  172.         $this->counter_name = "blank";
  173.     }
  174.     public function uniqueTest($counter_name) {
  175.         try {
  176.             $conn = new Connection();
  177.             $db = $conn->openConnection();
  178.             $stm = $db->prepare("SELECT id from questy.counters WHERE name=:counter_name");
  179.             $stm->bindParam('counter_name', $counter_name, PDO::PARA_STR);
  180.             $stm->execute();
  181.             if ($stm->rowCount() > 0) {
  182.                 return "1";
  183.             }
  184.             else {
  185.                 return "0";
  186.             }
  187.         }
  188.         catch(PDOException $e) {
  189.             exit($e->getMessage());
  190.         }
  191.     }
  192. }
  193. class CheckIfQuestExists {
  194.     public $quest_name;
  195.     public function __construct() {
  196.         $this->quest_name = "blank";
  197.     }
  198.     public function uniqueTest($quest_name) {
  199.         try {
  200.             $conn = new Connection();
  201.             $db = $conn->openConnection();
  202.             $stm = $db->prepare("SELECT id from questy.quests WHERE name=:quest_name");
  203.             $stm->bindParam('quest_name', $quest_name, PDO::PARA_STR);
  204.             $stm->execute();
  205.             if ($stm->rowCount() > 0) {
  206.                 return "1";
  207.             }
  208.             else {
  209.                 return "0";
  210.             }
  211.         }
  212.         catch(PDOException $e) {
  213.             exit($e->getMessage());
  214.         }
  215.     }
  216. }
  217. class CheckIfNPCExists {
  218.     public $npc_name;
  219.     public function __construct() {
  220.         $this->npc_name = "blank";
  221.     }
  222.     public function uniqueTest($npc_name) {
  223.         try {
  224.             $conn = new Connection();
  225.             $db = $conn->openConnection();
  226.             $stm = $db->prepare("SELECT id from questy.npcs WHERE name=:npc_name");
  227.             $stm->bindParam('npc_name', $npc_name, PDO::PARA_STR);
  228.             $stm->execute();
  229.             if ($stm->rowCount() > 0) {
  230.                 return "1";
  231.             }
  232.             else {
  233.                 return "0";
  234.             }
  235.         }
  236.         catch(PDOException $e) {
  237.             exit($e->getMessage());
  238.         }
  239.     }
  240. }
  241. class CheckIfActionExists {
  242.     public $action_name;
  243.     public function __construct() {
  244.         $this->action_name = "blank";
  245.     }
  246.     public function uniqueTest($action_name) {
  247.         try {
  248.             $conn = new Connection();
  249.             $db = $conn->openConnection();
  250.             $stm = $db->prepare("SELECT id from questy.npcs WHERE name=:action_name");
  251.             $stm->bindParam('action_name', $action_name, PDO::PARA_STR);
  252.             $stm->execute();
  253.             if ($stm->rowCount() > 0) {
  254.                 return "1";
  255.             }
  256.             else {
  257.                 return "0";
  258.             }
  259.         }
  260.         catch(PDOException $e) {
  261.             exit($e->getMessage());
  262.         }
  263.     }
  264. }
  265. class CheckIfDialogueExists {
  266.     public $dialogue_name;
  267.     public $npc_id;
  268.     public function __construct() {
  269.         $this->dialogue_name = "blank";
  270.         $this->npc_id = "blank";
  271.     }
  272.     public function uniqueTest($dialogue_name,$npc_id) {
  273.         try {
  274.             $conn = new Connection();
  275.             $db = $conn->openConnection();
  276.             $stm = $db->prepare("SELECT id, npc_id from questy.dialogues WHERE name=:dialogue_name AND npc_id:npc_id");
  277.             $stm->bindParam('dialogue_name', $dialogue_name, PDO::PARA_STR);
  278.             $stm->bindParam('npc_id', $npc_id, PDO::PARA_STR);
  279.             $stm->execute();
  280.             if ($stm->rowCount() > 0) {
  281.                 return "1";
  282.             }
  283.             else {
  284.                 return "0";
  285.             }
  286.         }
  287.         catch(PDOException $e) {
  288.             exit($e->getMessage());
  289.         }
  290.     }
  291. }
  292. class CheckIfOptionsExists {
  293.     public $option_name;
  294.     public $npc_id;
  295.     public function __construct() {
  296.         $this->option_name = "blank";
  297.         $this->npc_id = "blank";
  298.     }
  299.     public function uniqueTest($option_name,$npc_id) {
  300.         try {
  301.             $conn = new Connection();
  302.             $db = $conn->openConnection();
  303.             $stm = $db->prepare("SELECT id, npc_id from questy.options WHERE name=:option_name AND npc_id:npc_id");
  304.             $stm->bindParam('option_name', $option_name, PDO::PARA_STR);
  305.             $stm->bindParam('npc_id', $npc_id, PDO::PARA_STR);
  306.             $stm->execute();
  307.             if ($stm->rowCount() > 0) {
  308.                 return "1";
  309.             }
  310.             else {
  311.                 return "0";
  312.             }
  313.         }
  314.         catch(PDOException $e) {
  315.             exit($e->getMessage());
  316.         }
  317.     }
  318. }
  319.  
  320.  
  321.  
  322. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement