Advertisement
Guest User

jarvis.php

a guest
Feb 17th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.93 KB | None | 0 0
  1. <?php
  2. /** J.A.R.V.I.S Artificial Intelligence | php CODE
  3. *   30 - Januari - 2017
  4. *   Author by muhammad fahriansyah X - RPL 1
  5. */
  6.    
  7.  
  8. class jarvis
  9. {
  10.  
  11. var $host = "localhost";
  12. var $user = "root";
  13. var $db = "jarvis";
  14. var $pass = "123456";
  15.  
  16. var $data_ac = "";
  17. var $data_con = "";
  18. var $data_tar = "";
  19.  
  20.  
  21.     function action()
  22.     {
  23.         $connect = mysqli_connect($this->host,$this->user,$this->pass,$this->db);
  24.         $cmd = $_GET['cmd'];
  25.  
  26.         $sql_action = "select * from action";
  27.         $query_action = mysqli_query($connect,$sql_action);
  28.  
  29.         while ($data_action = mysqli_fetch_array($query_action)) {
  30.             $action = $data_action['action'];
  31.    
  32.             if (preg_match("/$action/", $cmd)) {
  33.                $this->data_ac = $action;
  34.             }      
  35.     }
  36. }
  37.     function conv()
  38.     {
  39.         $connect = mysqli_connect($this->host,$this->user,$this->pass,$this->db);
  40.         $cmd = $_GET['cmd'];
  41.  
  42.         $sql_conversation = "select * from conversation";
  43.         $query_conversation = mysqli_query($connect,$sql_conversation);
  44.  
  45.         while ($data_conversation = mysqli_fetch_array($query_conversation)) {
  46.             $conversation = $data_conversation['conversation'];
  47.  
  48.             if (preg_match("/$conversation/", $cmd)) {
  49.                 $this->data_con = $conversation;
  50.         }
  51.     }
  52. }
  53.     function target()
  54.     {
  55.         $connect = mysqli_connect($this->host,$this->user,$this->pass,$this->db);
  56.         $cmd = $_GET['cmd'];
  57.  
  58.        $sql_target = "select * from target";
  59.        $query_target = mysqli_query($connect,$sql_target);
  60.  
  61.         while ($data_target = mysqli_fetch_array($query_target)) {
  62.             $target = $data_target['target'];
  63.  
  64.             if (preg_match("/$target/", $cmd)) {
  65.                 $this->data_tar = $target;
  66.             }
  67.     }
  68. }
  69.     function command()
  70.     {
  71.         $connect = mysqli_connect($this->host,$this->user,$this->pass,$this->db);
  72.         $cmd = $_GET['cmd'];
  73.  
  74.         $sql_command = "select * from command";
  75.         $query_command = mysqli_query($connect,$sql_command);
  76.  
  77.         while ($data_command = mysqli_fetch_array($query_command)) {
  78.             $command = $data_command['query'];
  79.             $yes = $data_command['yes'];
  80.             $actions = $data_command['action'];
  81.  
  82.             $suggest_a = $this->data_ac." ".$this->data_con." ".$this->data_tar;
  83.             $suggest_b = $this->data_con." ".$this->data_ac." ".$this->data_tar;
  84.             $suggest_c = $this->data_tar." ".$this->data_con." ".$this->data_ac;
  85.  
  86.             $suggest_d = $this->data_con." ".$this->data_tar." ".$this->data_ac;
  87.             $suggest_e = $this->data_tar." ".$this->data_ac." ".$this->data_con;
  88.             $suggest_f = $this->data_ac." ".$this->data_tar." ".$this->data_con;
  89.  
  90.             if ($suggest_a == $command || $suggest_b == $command || $suggest_c == $command || $suggest_d == $command || $suggest_e == $command || $suggest_f == $command || $cmd == $command) {
  91.                 echo $yes;
  92.             }              
  93.                
  94.     }
  95.   }
  96. }
  97.  
  98. $jarvis = new jarvis();
  99. $jarvis->action();
  100. $jarvis->conv();
  101. $jarvis->target();
  102. $jarvis->command();
  103.  
  104. echo "<br>action : ".$jarvis->data_ac."<br>";
  105. echo "conversation : ".$jarvis->data_con."<br>";
  106. echo "target : ".$jarvis->data_tar."<br>";
  107.  
  108. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement