Posted By

meancode on 05/05/10


Tagged

php MT movabletype


Versions (?)

PHP Auth in Movable Type


 / Published in: PHP
 

Credit goes to Fran├žois Nonnenmacher.

  1. <?php
  2. $ch = curl_init();
  3. curl_setopt($ch, CURLOPT_URL, "<$mt:AdminCGIPath$><$mt:CommentScript$>?__mode=session_js&blog_id=<mt:BlogID>&jsonp=mtSetUserOrLogin");
  4. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5. curl_setopt($ch, CURLOPT_COOKIE, $_SERVER["HTTP_COOKIE"]);
  6. $json = curl_exec($ch) or die("Cannot connect to MT!");
  7. curl_close($ch);
  8. $json = substr($json, 17, strlen($json)-20);
  9. $session = json_decode($json, true);
  10. if ($session['can_comment'] == 0) {
  11. header("Location: <$mt:AdminCGIPath$><$mt:CommentScript$>?__mode=login&blog_id=<mt:BlogID>&return_url=".rawurlencode($_SERVER["REQUEST_URI"]));
  12. }
  13. ?>

Report this snippet  

You need to login to post a comment.