Dat } na de data moet daar juist niet, ik ga daar verder met de script, waarvoor ik die data nodig heb, dus also de $brute leeg is, word het script niet geactiveerd.
Oke, ik heb het geprobeerd zonder de andere code, en het werkte, toen de get en brute var geechoed, ze waren allebei goed.
dus nu zit ik met de vraag, waar zit mijn error?
Hier is de code;
en de error die ik krijg is:
Parse error: syntax error, unexpected $end in /home/candan21/public_html/test/index.php on line 1
<?php
if(!isset($_GET['brute'])) {
Echo "You need to fill in a name.";
} else {
$brute = $_GET['brute'];
$brute = strip_tags($brute);
$brute = preg_replace('#\'#', '', $brute);
$brute = preg_replace('#\"#', '', $brute);
if(strlen($brute) > 13)
{
Echo "A name can only be 13 characters or less.";
}
else
{
$data = file_get_contents("http://".$brute.".mybrute.com/cellule");
//lvl
$regex = "/Level(1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-9]|[0-9])/";
preg_match_all($regex, $data, $mydata);
$lvl = $mydata[0][0];
//name
$regex1 = "/<h1>(.*)<\/h1>/";
preg_match_all($regex1, $data, $mydata1);
$name = strip_tags($mydata1[0][0]);
// hp
$regex2 = "/<div class=\"life\">(.*)<\/div><\/div>/";
preg_match_all($regex2, $data, $mydata2);
$hp = strip_tags($mydata2[0][0]);
$hp = preg_replace('#health points#', '', $hp);
$hp = preg_replace('#:#', '', $hp);
$hp = preg_replace('#Strength#', '', $hp);
$hp = preg_replace('# #', '', $hp);
$hp = preg_replace('#Agility#', '', $hp);
$hp = preg_replace('#Speed#', '', $hp);
//Victories
$regex3 = "/<div class=\"value\" onmouseover=\"mt\.js\.Tip\.show\(this,'Number of victories in the Arena.',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\">(.*)<\/div>/";
preg_match_all($regex3, $data, $mydata3);
$victories = strip_tags($mydata3[0][0]);
//Pupils
$regex4 = "/<div class=\"value\" onmouseover=\"mt\.js\.Tip\.show\(this,'Number of Brutes who have been recruited. Click here to see your pupils.',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><a href=\"\/dojo\">1<\/a><\/div>/";
preg_match_all($regex4, $data, $mydata4);
$pupils = strip_tags($mydata4[0][0]);
//Strenght
$regex5 = "/<div class=\"caracBar\" onmouseover=\"mt\.js\.Tip\.show\(this,'Strength:(1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-9]|[0-9])',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><div class=\"legend\">Strength:<\/div><div class=\"bar\">/";
preg_match_all($regex5, $data, $mydata5);
$strength = $mydata5[0][0];
$strength = preg_replace('#<div class=\"caracBar\" onmouseover=\"mt\.js\.Tip\.show\(this,\'#', '', $strength);
$strength = preg_replace('#\',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><div class=\"legend\">Strength:<\/div><div class=\"bar\">#', '', $strength);
//Agility
$regex6 = "/<div class=\"caracBar\" onmouseover=\"mt\.js\.Tip\.show\(this,'Agility:(1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-9]|[0-9])',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><div class=\"legend\">Agility:<\/div><div class=\"bar\">/";
preg_match_all($regex6, $data, $mydata6);
$agil = $mydata6[0][0];
$agil = preg_replace('#<div class=\"caracBar\" onmouseover=\"mt\.js\.Tip\.show\(this,\'#', '', $agil);
$agil = preg_replace('#\',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><div class=\"legend\">Agility:<\/div><div class=\"bar\">#', '', $agil);
//Speed
$regex7 = "/<div class=\"caracBar\" onmouseover=\"mt\.js\.Tip\.show\(this,'Speed:(1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-9]|[0-9])',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><div class=\"legend\">Speed:<\/div><div class=\"bar\">/";
preg_match_all($regex7, $data, $mydata7);
$speed = $mydata7[0][0];
$speed = preg_replace('#<div class=\"caracBar\" onmouseover=\"mt\.js\.Tip\.show\(this,\'#', '', $speed);
$speed = preg_replace('#\',null\)\" onmouseout=\"mt\.js\.Tip\.hide\(\)\"><div class=\"legend\">Speed:<\/div><div class=\"bar\">#', '', $speed);
if($pupils == 1){
$puptxt = $pupils." Pupil";
} else if($pupils == 0){
$puptxt = "No Pupils";
} else {
$puptxt = $pupils." Pupils";
}
$my_img = imagecreatefrompng("background.PNG");
$text_colour = imagecolorallocate($my_img, 139, 119, 101);
imagestring($my_img, 4, 25, 20, $name, $text_colour);
imagestring($my_img, 4, 25, 35, $lvl, $text_colour);
imagestring($my_img, 4, 25, 50, $puptxt, $text_colour);
imagestring($my_img, 4, 25, 65, $strength, $text_colour);
imagestring($my_img, 4, 25, 80, $agil, $text_colour);
imagestring($my_img, 4, 25, 95, $speed, $text_colour);
imagestring($my_img, 4, 25, 110, $victories." Victories", $text_colour);
imagestring($my_img, 4, 25, 127, "http://".$brute.".mybrute.com/cellule", $text_colour);
imagesetthickness($my_img, 5);
header("Content-type: image/png");
imagepng($my_img);
imagecolordeallocate($text_color);
imagedestroy($my_img);
}
}
?>