function setupMicroID() { global $wgOut, $wgRequest, $wgHooks; $wgHooks['UserToggles'][] = 'MicroIDUserToggle'; $action = $wgRequest->getText('action', 'view'); if ($action == 'view') { $title = $wgRequest->getText('title'); if (!isset($title) || strlen($title) == 0) { # If there's no title, and Cache404 is in use, check using its stuff if (defined('CACHE404_VERSION')) { if ($_SERVER['REDIRECT_STATUS'] == 404) { $url = getRedirectUrl($_SERVER); if (isset($url)) { $title = cacheUrlToTitle($url); } } } else { $title = wfMsg('mainpage'); } } $nt = Title::newFromText($title); // If the page being viewed is a user page... if ($nt && $nt->getNamespace() == NS_USER && strpos($nt->getText(), '/') === false) { // If the user qualifies... wfDebug("MicroID: on User page " . $nt->getText() . "\n"); $user = User::newFromName($nt->getText()); if ($user && $user->getID() != 0 && $user->getEmail() && $user->isEmailConfirmed() && $user->getOption('microid')) { wfDebug("MicroID: on User page " . $nt->getText() . "\n"); $wgOut->addMeta('microid', MakeMicroID($user->getEmail(), $nt->getFullURL())); } } } }
function setupOpenID() { global $wgMessageCache, $wgOut, $wgRequest; $wgMessageCache->addMessages(array('openidlogin' => 'Login with OpenID', 'openidfinish' => 'Finish OpenID login', 'openidserver' => 'OpenID server', 'openidconvert' => 'OpenID converter', 'openidlogininstructions' => 'Enter your OpenID identifier to log in:', 'openiderror' => 'Verification error', 'openiderrortext' => 'An error occured during verification of the OpenID URL.', 'openidconfigerror' => 'OpenID Configuration Error', 'openidconfigerrortext' => 'The OpenID storage configuration for this wiki is invalid. Please consult this site\'s administrator.', 'openidpermission' => 'OpenID permissions error', 'openidpermissiontext' => 'The OpenID you provided is not allowed to login to this server.', 'openidcancel' => 'Verification cancelled', 'openidcanceltext' => 'Verification of the OpenID URL was cancelled.', 'openidfailure' => 'Verification failed', 'openidfailuretext' => 'Verification of the OpenID URL failed.', 'openidsuccess' => 'Verification succeeded', 'openidsuccesstext' => 'Verification of the OpenID URL succeeded.', 'openidusernameprefix' => 'OpenIDUser', 'openidserverlogininstructions' => 'Enter your password below to log in to $3 as user $2 (user page $1).', 'openidtrustinstructions' => 'Check if you want to share data with $1.', 'openidallowtrust' => 'Allow $1 to trust this user account.', 'openidnopolicy' => 'Site has not specified a privacy policy.', 'openidpolicy' => 'Check the <a target="_new" href="$1">privacy policy</a> for more information.', 'openidoptional' => 'Optional', 'openidrequired' => 'Required', 'openidnickname' => 'Nickname', 'openidfullname' => 'Fullname', 'openidemail' => 'Email address', 'openidlanguage' => 'Language', 'openidnotavailable' => 'Your preferred nickname ($1) is already in use by another user.', 'openidnotprovided' => 'Your OpenID server did not provide a nickname (either because it can\'t, or because you told it not to).', 'openidchooseinstructions' => 'All users need a nickname; you can choose one from the options below.', 'openidchoosefull' => 'Your full name ($1)', 'openidchooseurl' => 'A name picked from your OpenID ($1)', 'openidchooseauto' => 'An auto-generated name ($1)', 'openidchoosemanual' => 'A name of your choice: ', 'openidconvertinstructions' => 'This form lets you change your user account to use an OpenID URL.', 'openidconvertsuccess' => 'Successfully converted to OpenID', 'openidconvertsuccesstext' => 'You have successfully converted your OpenID to $1.', 'openidconvertyourstext' => 'That is already your OpenID.', 'openidconvertothertext' => 'That is someone else\'s OpenID.')); SpecialPage::AddPage(new UnlistedSpecialPage('OpenIDLogin')); SpecialPage::AddPage(new UnlistedSpecialPage('OpenIDFinish')); SpecialPage::AddPage(new UnlistedSpecialPage('OpenIDServer')); SpecialPage::AddPage(new UnlistedSpecialPage('OpenIDConvert')); SpecialPage::AddPage(new UnlistedSpecialPage('OpenIDXRDS')); $action = $wgRequest->getText('action', 'view'); if ($action == 'view') { $title = $wgRequest->getText('title'); if (!isset($title) || strlen($title) == 0) { # If there's no title, and Cache404 is in use, check using its stuff if (defined('CACHE404_VERSION')) { if ($_SERVER['REDIRECT_STATUS'] == 404) { $url = getRedirectUrl($_SERVER); if (isset($url)) { $title = cacheUrlToTitle($url); } } } else { $title = wfMsg('mainpage'); } } $nt = Title::newFromText($title); // If the page being viewed is a user page, // generate the openid.server META tag and output // the X-XRDS-Location. See the OpenIDXRDS // special page for the XRDS output / generation // logic. if ($nt && $nt->getNamespace() == NS_USER && strpos($nt->getText(), '/') === false) { $user = User::newFromName($nt->getText()); if ($user && $user->getID() != 0) { $openid = OpenIdGetUserUrl($user); if (isset($openid) && strlen($openid) != 0) { $url = OpenIDToUrl($openid); $disp = htmlspecialchars($openid); $wgOut->setSubtitle("<span class='subpages'>" . "<img src='http://openid.net/login-bg.gif' alt='OpenID' />" . "<a href='{$url}'>{$disp}</a>" . "</span>"); } else { $wgOut->addLink(array('rel' => 'openid.server', 'href' => OpenIDServerUrl())); $rt = Title::makeTitle(NS_SPECIAL, 'OpenIDXRDS/' . $user->getName()); $wgOut->addMeta('http:X-XRDS-Location', $rt->getFullURL()); header('X-XRDS-Location', $rt->getFullURL()); } } } } // Verify the config file settings. FIXME: How to // report error? global $wgOpenIDServerStorePath, $wgOpenIDServerStoreType, $wgOpenIDConsumerStorePath, $wgOpenIDConsumerStoreType; if ($wgOpenIDConsumerStoreType == 'file') { assert($wgOpenIDConsumerStorePath != false); } if ($wgOpenIDServerStoreType == 'file') { assert($wgOpenIDServerStorePath != false); } }
function setupMwRdf() { global $wgParser, $wgMessageCache, $wgRequest, $wgOut, $wgHooks; $wgMessageCache->addMessages(array('rdf' => 'Rdf', 'rdf-inpage' => "Embedded In-page Turtle", 'rdf-dcmes' => "Dublin Core Metadata Element Set", 'rdf-cc' => "Creative Commons", 'rdf-image' => "Embedded images", 'rdf-linksto' => "Links to the page", 'rdf-linksfrom' => "Links from the page", 'rdf-links' => "All links", 'rdf-history' => "Historical versions", 'rdf-interwiki' => "Interwiki links", 'rdf-categories' => "Categories", 'rdf-target' => "Target page", 'rdf-modelnames' => "Model(s)", 'rdf-format' => "Output format", 'rdf-output-xml' => "XML", 'rdf-output-turtle' => "Turtle", 'rdf-output-ntriples' => "NTriples", 'rdf-instructions' => "Select the target page and RDF models you're interested in.")); $wgParser->setHook('rdf', 'renderMwRdf'); SpecialPage::AddPage(new SpecialPage('Rdf', '', true, 'wfSpecialRdf', 'extensions/MwRdf.php')); # Add an RDF metadata link if requested $action = $wgRequest->getText('action', 'view'); # Note: $wgTitle not yet set; have to get it from the request $title = $wgRequest->getText('title'); # If there's no requested title... if (!isset($title) || strlen($title) == 0) { # If there's no title, and Cache404 is in use, check using its stuff if (defined('CACHE404_VERSION')) { if ($_SERVER['REDIRECT_STATUS'] == 404) { $url = getRedirectUrl($_SERVER); if (isset($url)) { $title = cacheUrlToTitle($url); } } } } if (isset($title) && strlen($title) > 0) { $nt = Title::newFromText($title); if (isset($nt) && $nt->getNamespace() != NS_SPECIAL) { if ($action == 'view') { $rdft = Title::makeTitle(NS_SPECIAL, "Rdf"); $target = $nt->getPrefixedDBkey(); $linkdata = array('title' => 'RDF Metadata', 'type' => 'application/rdf+xml', 'href' => $rdft->getLocalURL("target={$target}")); $wgOut->addMetadataLink($linkdata); } else { if ($action == 'purge') { # clear cache on purge MwRdfClearCacheAll($nt); } } } } # We set some hooks for invalidating the cache $wgHooks['ArticleSave'][] = 'MwRdfOnArticleSave'; $wgHooks['ArticleSaveComplete'][] = 'MwRdfOnArticleSaveComplete'; $wgHooks['TitleMoveComplete'][] = 'MwRdfOnTitleMoveComplete'; $wgHooks['ArticleDeleteComplete'][] = 'MwRdfOnArticleDeleteComplete'; }
function getAccessToken($code) { $accessTokenUrl = API_URL . '/oauth/accesstoken'; // Get cURL resource $curl = curl_init(); $data = array(redirect_uri => getRedirectUrl(), code => $code, grant_type => 'authorization_code', response_type => 'code'); curl_setopt($curl, CURLOPT_URL, $accessTokenUrl); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_HEADER, FALSE); curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded", "Authorization: Basic " . base64_encode(APP_ID . ":" . APP_SECRET))); // Send the request & save response to $resp $resp = curl_exec($curl); // Close request to clear up some resources curl_close($curl); $json_res = json_decode($resp, true); setcookie('php_auth_sample_spark_access_token', $json_res['access_token']); setcookie('php_auth_sample_spark_refresh_token', $json_res['refresh_token']); setcookie('php_auth_sample_spark_refresh_token_expires_at', $json_res['expires_at']); header('location:' . getRedirectUrl()); exit; }
$command = 'rm -rf /home/naresh/LifeParser/Data/GMail_DataStore/mail2naresh@gmail.com'; exec($command, $output, $retVal);*/ header('Location: ' . constructPageUrl('index.php')); } break; case 'logout': session_destroy(); header('Location: ' . $APP_URL); exit; case 'openid_auth': $authorizedToken = $openId->getRequestToken(); $_SESSION['REQUEST_TOKEN'] = $authorizedToken; $_SESSION['OPENID_EMAIL'] = $openId->getEMailId(); $_SESSION['OPENID_FIRSTNAME'] = $openId->getFirstName(); $_SESSION['OPENID_LASTNAME'] = $openId->getLastName(); header('Location: ' . getRedirectUrl('access')); break; case 'gadget_login': global $openId; $redirUrl = constructPageUrl() . '?action=' . getActionString('openid_auth'); header('Location: ' . $openId->getUrl($redirUrl)); break; case 'login': default: if (!isset($_SESSION['ACCESS_TOKEN'])) { renderHTML('login'); } else { //renderHTML('User: '******'OPENID_FIRSTNAME'] . ' ' . $_SESSION['OPENID_LASTNAME'] . '<br/> EMail: <b>' . $_SESSION['OPENID_EMAIL'] . '</b> logged-in with access token: <br> <a href="'. getRedirectUrl().'" >Logout </a>' , false); renderHTML('flashDisplay'); } break;
function renderHTML() { ?> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="default.css" rel="stylesheet" type="text/css"> <title>Gamut...Know your life</title> </head> <body> <table align="center" border="0" height="80%" width="60%" bgcolor="#77BBFF"> <tbody> <tr rowspan="2"> <td> <table align="center" border="0" height="100%" width="100%"> <tbody> <tr> <td class="siteTitle"> <dl> <dd>Gamut.....revisit your past.</dd> </dl> </td> </tr> </tbody> </table> </td> </tr> <tr rowspan="2"> <td colspan="2"></td> </tr> <tr> <td> <table width=100% height=100% align="center" border="0"> <tbody> <tr height=100%> <td width=50%>Gmail account is required to use this site.<br> </td> <td width=50%> <a href="<?php getRedirectUrl(); ?> ">Click Here to Continue</a> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </body> </html> <?php }
} //$category = $_GET["category"]; function getRedirectUrl($url) { stream_context_set_default(array('http' => array('method' => 'HEAD'))); $headers = get_headers($url, 1); if ($headers !== false && isset($headers['Location'])) { return $headers['Location']; } return false; } $category = "Chemistry"; $url = 'http://en.wikipedia.org/wiki/Special:RandomInCategory/' . $category; $page = 'Category'; while (strpos($page, 'Category') !== false or strpos($page, 'Portal') !== false) { $temp = getRedirectUrl($url); if ($temp != false) { $page = $temp[1]; $page = trim($page); $page = str_replace("https://en.wikipedia.org/wiki/", "", $page); $page = str_replace("http://en.wikipedia.org/wiki/", "", $page); } else { $page = false; break; } } if ($page != false) { $temp2 = trim($page); $page2 = str_replace("https://en.wikipedia.org/wiki/", "", $temp2); $page2 = str_replace("http://en.wikipedia.org/wiki/", "", $page2); echo $_GET['callback'] . '(' . "{'category' : '{$page2}' }" . ')';
$_SESSION['OPENID_EMAIL'] = $openId->getEMailId(); $_SESSION['OPENID_FIRSTNAME'] = $openId->getFirstName(); $_SESSION['OPENID_LASTNAME'] = $openId->getLastName(); header('Location: ' . getRedirectUrl('access')); break; case 'gadget_login': global $openId; $redirUrl = constructPageUrl() . '?action=' . getActionString('openid_auth'); header('Location: ' . $openId->getUrl($redirUrl)); break; case 'login': default: if (!isset($_SESSION['ACCESS_TOKEN'])) { renderHTML('Click here to sign-in', true); } else { renderHTML('User: '******'OPENID_FIRSTNAME'] . ' ' . $_SESSION['OPENID_LASTNAME'] . '<br/> EMail: <b>' . $_SESSION['OPENID_EMAIL'] . '</b> logged-in with access token: <br> <a href="' . getRedirectUrl() . '" >Logout </a>', false); } break; } $dbFuncsObj->doDisconnect(); function renderHTML($displayMessage, $isLink) { ?> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="default.css" rel="stylesheet" type="text/css"> <title>Life Parser</title> </head>
<?php header('Access-Control-Allow-Methods: GET'); header('Access-Control-Max-Age: 1000'); header('Content-Type: application/json'); header('Access-Control-Allow-Origin: *'); function getRedirectUrl($url) { stream_context_set_default(array('http' => array('method' => 'HEAD'))); $headers = get_headers($url, 1); if ($headers !== false && isset($headers['Location'])) { return $headers['Location']; } return false; } $timetableUrl = $_GET['timetable']; $redirectedUrl = getRedirectUrl($timetableUrl); if (!$redirectedUrl) { $redirectedUrl = $timetableUrl; } echo json_encode(array('redirectedUrl' => $redirectedUrl));