Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function getContent($url, $cookiePath)
- {
- //used Export Cookies extension to get NC cookie
- $ch = curl_init ();
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt ( $ch, CURLOPT_URL, $url );
- curl_setopt ( $ch, CURLOPT_HEADER, 0 );
- curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
- curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, 0 );
- curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiePath);
- curl_setopt($ch, CURLOPT_VERBOSE, true);
- $file_contents = curl_exec ( $ch );
- if (curl_errno ( $ch )) {
- echo curl_error ( $ch );
- curl_close ( $ch );
- exit ();
- }
- curl_close ( $ch );
- return $file_contents;
- }
- $content = getContent("https://www.newbiecontest.org/epreuves/prog/prog6.php", 'C:/Temp/cookies.txt');
- $equation = substr($content, 54);
- $equation = substr($equation, 0, -4);
- echo $equation . "<br />";
- $array = preg_split("/x/", $equation);
- $array[1] = substr($array[1], 2);
- if(empty($array[0]))
- {
- echo "a is empty <br />";
- $intA = 1;
- }
- else
- {
- $intA = $array[0][0];
- }
- $intA = (int) $intA;
- echo "a : " . $intA . "<br />";
- if (strlen($array[1])>3)
- {
- //got to add b = 10 case
- $intB = substr($array[1], -1);
- }
- else
- {
- $intB = 1;
- }
- $intB = (int) $intB;
- if (!strcmp($array[1][1], '-'))
- {
- $intB = -$intB;
- }
- echo "b : " . $intB . "<br />";
- if(empty($array[2]))
- {
- $intC = 0;
- }
- else
- {
- $intC = substr($array[2], -1);
- if (!strcmp($array[2][1], '-'))
- {
- $intC = -$intC;
- }
- }
- echo "c : " . $intC . "<br />";
- $delta = $intB * $intB * - 4 * $intA * $intC;
- echo "delta : " . $delta . "<br />";
- $x1 = (-$intB - sqrt($delta))/(2*$intA);
- $x1 = round($x1, 2);
- echo "x1 : " . $x1 . "<br />";
- $x2 = (-$intB + sqrt($delta))/(2*$intA);
- $x2 = round($x2, 2);
- echo "x2 : " . $x2 . "<br />";
- if ($x1 < $x2)
- {
- echo "Highest is : " . $x2 . "<br />";
- $solution = $x2;
- }
- else
- {
- echo "Highest is : " . $x1 . "<br />";
- $solution = $x1;
- }
- $subm = "https://www.newbiecontest.org/epreuves/prog/verifpr6.php?solution=" . $solution;
- header("Location: $subm");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement