#!/usr/bin/php
<?php

/**
 * jobnet.client
 *
 * dette script er for at logge ind i jobnet.dk's database og automatisk bekræfte
 * at du fortsat er aktivt jobsøgende.
 * Ændr $password og $username i det næste og kør scriptet:
 *
 * php jobnet.client
 *
 * Og du vil atutomatisk bekræfte at du søger job.
 */

// jobnet login og username
$username = 'username'; // som regel din email
$password = 'password'; // dit password


$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "./cookieFileName");
curl_setopt($ch, CURLOPT_URL,"https://job.jobnet.dk/CV/Login/Login.aspx");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 1);

$post_fields = "ctl00\$ctl00\$JobnetBaseMiddelContent\$LoginContentPlaceHolder\$txtUsername=$username&";
$post_fields.= "ctl00\$ctl00\$JobnetBaseMiddelContent\$LoginContentPlaceHolder\$txtPassword=$password&";
$post_fields.= "ctl00\$ctl00\$JobnetBaseMiddelContent\$LoginContentPlaceHolder\$btnLogon=Log ind&";
$post_fields.= "__VIEWSTATE=$ret[__VIEWSTATE]";
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);

$html = curl_exec ($ch); // execute the curl command
echo $html;

curl_close ($ch);
unset($ch);

// ny curl session
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "./cookieFileName");
curl_setopt($ch, CURLOPT_URL, "https://job.jobnet.dk/CV/TASS/ConfirmEnrolment/ConfirmEnrolmentReceipt.aspx");

curl_setopt($ch, CURLOPT_POST, 1);

$post_fields = "ctl00\$ctl00\$ctl00\$JobnetBaseMiddelContent\$UncachedPageMiddelContent\$JobSeekerMiddelContentPlaceHolder\$UserActionBox1\$_btnAction=Bekræft aktiv jobsøgning";
$post_fields.= "__VIEWSTATE=$ret[__VIEWSTATE]";

$html = curl_exec ($ch);
curl_close ($ch);

echo $html;

