Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

62 lines (50 sloc) 2.392 kB
<?php
/**
* A quick-and-dirty proxy to make FetLife.com pages accessible to everyone.
*/
// Library.
require_once(dirname(__FILE__) . '/lib/FetLife.php');
// Grab the BugMeNot.com account credential listing for FetLife.com.
$ch = curl_init('http://www.bugmenot.com/view/fetlife.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($ch);
curl_close($ch);
// Create HTML DOM from the BugMeNot.com account page.
$bugmenot = new DOMDocument();
$bugmenot->loadHTML($html);
$divs = $bugmenot->getElementsByTagName('div');
$accts = array();
$i = 0;
foreach ($divs as $div) {
if ('account' === $div->getAttribute('class')) {
$accts[$i]['nickname'] = $div->getElementsByTagName('td')->item(0)->nodeValue;
$accts[$i]['password'] = $div->getElementsByTagName('td')->item(1)->nodeValue;
$accts[$i]['hit_rate'] = $div->getElementsByTagName('td')->item(3)->nodeValue;
$i++;
}
}
// BugMeNot.com already sorts accounts based on reported success rate. Just use those.
// Augment list of accounts with any additional credentials in `fetlife-accounts.php`.
include_once('fetlife-accounts.php');
if (!empty($my_FetLife_accounts)) {
$accts = array_merge($my_FetLife_accounts, $accts);
}
// Find a working login and use it.
for ($i = 0; $i < count($accts); $i++) {
$FL = new FetLifeUser($accts[$i]['nickname'], $accts[$i]['password']);
if ($FL->logIn()) {
break; // exit loop, we've got a functional login to FetLife!
}
}
$conn = new FetLifeConnection($FL);
if (isset($_GET['page'])) {
$response = $conn->doHttpGet(urldecode($_GET['page']));
} else {
$response = $conn->doHttpGet('/home');
}
$html_out = preg_replace('/href="\//', 'href="' . $_SERVER['PHP_SELF'] . '?page=/', $response['body']);
$html_out = preg_replace('/href="https:\/\/fetlife.com/', 'href="' . $_SERVER['PHP_SELF'] . '?page=', $html_out);
// Replace CSS with our own.
$html_out = preg_replace('/<link href="https:\/\/flassets.a.ssl.fastly.net\/stylesheets\/(std2\/std|base_packaged).css/', '<link href="' . dirname($_SERVER['PHP_SELF']) . '/vendor/stylesheets/base_packaged.css', $html_out);
$html_out = preg_replace('/<link href="https:\/\/flassets.a.ssl.fastly.net\/stylesheets\/(std2\/scratch|print_packaged).css/', '<link href="' . dirname($_SERVER['PHP_SELF']) . '/vendor/stylesheets/base_packaged.css', $html_out);
print $html_out;
Jump to Line
Something went wrong with that request. Please try again.