latex/ql.php

<?php

$data = array
(
	'formula' => '2x',
	'out' => 'png',
	'fsize' => '13px',
	'fcolor' => '#000000',
	'mode' => '0',
);

$request = curl_init();
curl_setopt_array($request, array
(
	CURLOPT_URL => 'http://www.quicklatex.com/latex3.f',
	CURLOPT_POST => TRUE,
	CURLOPT_POSTFIELDS => http_build_query($data),
	CURLOPT_RETURNTRANSFER => TRUE,
	CURLOPT_HEADER => FALSE,
	CURLOPT_TIMEOUT => 20,
));

echo curl_exec($request);

exit;

function quicklatex_encode($string)
{

	$string = str_replace(
			array(     '%',    '&'),
			array(   '%25',  '%26'),
			$string
	);

	return $string;
}

{
	// Everyting is ok, parse server response
	if (preg_match("/^([-]?\d+)\r\n(\S+)\s([-]?\d+)\s(\d+)\s(\d+)\r?\n?([\s\S]*)/", $server_resp['body'], $regs))
	{
	
		$status       = $regs[1];
		$image_url    = $regs[2];
		$image_align  = $regs[3];
		$image_width  = $regs[4];
		$image_height = $regs[5];
		$error_msg    = $regs[6];
	}
}