<?php

	$special_ids = [];

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

	$year = $tmp_year = 2009;
	$month = $tmp_month = 2;
	$ticker_id = 1;

	$second_try = true;

	while ($year < date('Y') || $month <= date('n'))
	{
		$ticker_url = 'http://www.der-postillon.com/' . $year . '/'
			. str_pad($month, 2, '0', STR_PAD_LEFT) . '/newsticker-' . $ticker_id . '.html';

		echo $ticker_url . ': ';

		curl_setopt($ch, CURLOPT_URL, $ticker_url);
		$response = curl_exec($ch);

		if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200)
		{
			echo 'success<br>';

			$ticker_id++;
			$second_try = false;
		}
		else if (!$second_try)
		{
			echo 'trying again<br>';

			$second_try = true;

			$tmp_month = $month;
			$tmp_year = $year;

			if ($month == 12)
			{
				$month = 1;
				$year++;
			}
			else
			{
				$month++;
			}
		}
		else
		{
			echo 'not found<br>';

			$special_ids[] = $ticker_id;
			$ticker_id++;

			$month = $tmp_month;
			$year = $tmp_year;

			$second_try = false;
		}
	}