Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.49 KB | None | 0 0
  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.  
  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.             echo json_encode($posts, JSON_PRETTY_PRINT);
  28.         }
  29.         else
  30.         {
  31.             http_response_code(401);
  32.         }
  33.  
  34.         // get blog rest api
  35.         if ($objnm == "blogs")
  36.         {
  37.             echo 'wew';
  38.         }
  39.  
  40.     }
  41.     else if ($_SERVER['REQUEST_METHOD'] == "POST")
  42.     {
  43.         if ($_GET['url'] == "posts")
  44.         {
  45.             echo 'post';
  46.         }
  47.         else
  48.         {
  49.             http_response_code(401);
  50.         }
  51.     }
  52.     else if ($_SERVER['REQUEST_METHOD'] == "DELETE")
  53.     {
  54.        
  55.     }
  56.     else
  57.     {
  58.         http_response_code(405);
  59.     }
  60.  
  61. }
  62. else
  63. {
  64.     http_response_code(405);
  65.     echo 'You have no access to connect jonathan restful api';
  66. }
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement