<form action="autokudos.php" method="post">
<input type="text" name="title" size="70"> tittel <br>
<input type="text" name="url" size="70"> url<br>
<input type="text" name="desc" size="70"> beskrivelse<br>
<input type="text" name="tags" size="70"> tags<br><br>
<input type="submit" name="sub"> <br>
</form>
<?php
$cookiejar = "cookies.txt";
$submit = $_POST['sub'];
$title = utf8_encode($_POST['title']);
$url = utf8_encode($_POST['url']);
$desc = utf8_encode($_POST['desc']);
$tags = utf8_encode($_POST['tags']);
// kudos.no
$kudosuser = "skogtrollet";
$kudospass = "asdasdr";
function loginKudos($user, $pass) {
global $title, $url, $desc, $tags, $cookiejar;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://kudos.no/user/userAction.php" );
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"task=validateLogin&username={$user}&password={$pass}&rememberMe=off&_=");
$data = curl_exec($ch);
echo "Logging in to kudos.no. <br>\n";
postKudos($title, $url, $desc, $tags);
}
function postKudos($title, $url, $desc, $tags) {
global $cookiejar;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://kudos.no/submit/submitAction.php" );
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"task=submitStory&title={$title}&URL={$url}&description={$desc}&categoryId=4&tags={$tags}&storyId=&channel=teknologi&nocache=1250899735873&_=");
$data = curl_exec($ch);
echo "Data posted. <br>\n";
$fp = fopen("vg.html", "w");
fwrite($fp, $data);
fclose($fp);
}
if($submit) {
loginKudos($kudosuser, $kudospass);
}
?>