Skip to content

Instantly share code, notes, and snippets.

@meancode
Created May 9, 2011 16:34
Show Gist options
  • Save meancode/962841 to your computer and use it in GitHub Desktop.
Save meancode/962841 to your computer and use it in GitHub Desktop.
Authenticate Template Module
<?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_post'] == 0) {
header("Location: <$mt:AdminCGIPath$><$mt:CommentScript$>?__mode=login&blog_id=<mt:BlogID>&return_url=".rawurlencode($_SERVER["REQUEST_URI"]));
}
?>
<script language="Javascript"><!--
mtSignInOnClick('signin-widget-content');
--></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment