kura2yamato

test

Nov 19th, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require_once("letmein.php");
  3. $db     = new LetMeIn("127.0.0.1", "letmein", "root", "");
  4.  
  5. $data   = file_get_contents("php://input");
  6. $json   = json_decode($data);
  7. $auth   = 'ItsTooLongAcceptingYou';
  8.  
  9. // @List($objnm, $objid) = explode('/', $_GET['url']);
  10. $respon=array();
  11.  
  12. if ($db->query('SELECT authentication FROM auth WHERE authentication=:auth', array(':auth'=>$auth)))
  13. {
  14.     // echo 'welcome world';
  15.     @List($objnm, $objid) = explode('/', $_GET['url']);
  16.  
  17.     if ($_SERVER['REQUEST_METHOD'] == "GET")
  18.     {
  19.         // get post rest api
  20.         if ($objnm == "posts")
  21.         {
  22.             $posts = $db->query('SELECT * FROM post');
  23.             if ($objid = "1")
  24.             {
  25.                 $posts = $db->query('SELECT * FROM post where id=1');
  26.             }
  27.             $respon=$posts;
  28.             //echo json_encode($posts, JSON_PRETTY_PRINT);
  29.         }
  30.         else
  31.         {
  32.             echo json_encode($respon, JSON_PRETTY_PRINT);
  33.             http_response_code(401);die;
  34.         }
  35.  
  36.         // get blog rest api
  37.         if ($objnm == "blogs")
  38.         {
  39.             echo 'wew';
  40.         }
  41.  
  42.     }
  43.     else if ($_SERVER['REQUEST_METHOD'] == "POST")
  44.     {
  45.         if ($_GET['url'] == "posts")
  46.         {
  47.             echo 'post';
  48.         }
  49.         else
  50.         {
  51.             http_response_code(401);
  52.         }
  53.     }
  54.     else if ($_SERVER['REQUEST_METHOD'] == "DELETE")
  55.     {
  56.        
  57.     }
  58.     else
  59.     {
  60.         http_response_code(405);
  61.     }
  62.  
  63. }
  64. else
  65. {
  66.     http_response_code(407);
  67.     echo 'You have no access to connect jonathan restful api';
  68. }
Add Comment
Please, Sign In to add comment