<?php
ob_start();
set_time_limit(0);
session_start();
$submitURL = htmlspecialchars(addslashes($_GET['url']));
header('Content-Type: text/html; charset=utf-8');
echo '<base href="http://svejo.net" />';
$login = 'http://svejo.net/user/login/';
$getKey = file_get_contents($login);
$getKey1 = eregi('<input name="authenticity_token" type="hidden" value="(.*)" />', $getKey, $getKey2);
$getKey3 = explode('" /></div>', $getKey2[0]);
$getKey4 = explode('<input name="authenticity_token" type="hidden" value="', $getKey3[0]);
$realKey = $getKey4[1];
$username = 'user';
$password = 'pass';
$data = array('user[email_or_username]'=>''.$username.'', 'user[password]'=>''.$password.'', 'user[remember_me]'=>'checked', 'authenticity_token'=>''.$realKey.'', 'commit'=>'Влез', 'user[url_referer]'=>'http://svejo.net/popular/all/new');
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, $login);
$result = curl_exec($ch);
$submited = 'http://svejo.net/submit/';
$sgetKey = file_get_contents($submited);
$sgetKey1 = eregi('<input name="authenticity_token" type="hidden" value="(.*)" />', $sgetKey, $sgetKey2);
$sgetKey3 = explode('" /></div>', $getKey2[0]);
$sgetKey4 = explode('<input name="authenticity_token" type="hidden" value="', $sgetKey3[0]);
$srealKey = $sgetKey4[1];
$data2 = array('story[url]'=>''.$submitURL.'', 'authenticity_token'=>''.$srealKey.'', 'commit'=>'Продължи');
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch2, CURLOPT_POST, 1);
curl_setopt($ch2, CURLOPT_POSTFIELDS, $data2);
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch2, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch2, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch2, CURLOPT_COOKIEJAR, "cookiefile");
curl_setopt($ch2, CURLOPT_COOKIE, session_name() . '=' . session_id());
curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch2, CURLOPT_URL, $submited);
echo $result2 = curl_exec($ch2);
?>