Return to Snippet

Revision: 26665
at May 5, 2010 22:46 by meancode


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

Initial URL


Initial Description
Credit goes to François Nonnenmacher.

Initial Title
PHP Auth in Movable Type

Initial Tags
php

Initial Language
PHP