• Willkommen im Geoclub - dem größten deutschsprachigen Geocaching-Forum. Registriere dich kostenlos, um alle Inhalte zu sehen und neue Beiträge zu erstellen.

Fundsignatur per PHP - Anmeldeprobleme

Schiwi

Geocacher
Ich hab mich mal an einem PHPskript versucht, ähnlich wie bei
http://www.geoclub.de/viewtopic.php?p=579930#p579930
damit auch andere Geocacher ohne Geolog sich eine eigene Foundsignatur basteln können
Doch irgendwie komm ich nicht weiter, ich habe große Probleme mich bei geocaching.com anzumelden :???:
Hat jemand eine Lösung? Gibt es sowas eigentlich schon?
Verbesserungen sind auch gern gesehen


Code:
<?php
$username = "Geocacher";
$password = "geheim";
$loginurl = "http://www.geocaching.com/login/default.aspx?RESET=Y&redir=http://www.geocaching.com/my/logs.aspx?s=1&lt=2";
$logincontent = file_get_contents("$loginurl");
$startstring = 'id="__VIEWSTATE" value="';
$endstring = '" />';
$startpos = 0;
$pos = strpos($logincontent, $startstring, $startpos) +24;
$viewstate = substr($logincontent, $pos, strpos($logincontent, $endstring, $pos +10 ) - $pos);
 

$curl = curl_init();
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.1)");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($curl, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($curl, CURLOPT_COOKIEJAR, "cookiefile");
curl_setopt($curl, CURLOPT_URL, "$loginurl");
curl_setopt($curl, CURLOPT_POSTFIELDS, "__VIEWSTATE=$viewstate&ctl00\$ContentBody\$myUsername=$username&ctl00\$ContentBody\$myPassword=$password&ctl00\$ContentBody\$cookie=on&ctl00\$ContentBody\$Button1=Login");
$result = curl_exec($curl); // run the whole process
curl_close($curl);

// echo $result;  
// echo $viewstate;

// ----------------  hier wird das Bild generiert ------------------------

$logs = file_get_contents("$result");
// $finds = preg_match_all('/alt="Found it"/i', $logs, $arrResult);
$suche = 'alt="Found it"';
$finds = substr_count($logs, $suche);


//Pfad zu Fonts (TTF)
$fpath = realpath('/usr/share/fonts/truetype/msttcorefonts/verdana.ttf');
$fpath_bold = realpath('/usr/share/fonts/truetype/msttcorefonts/verdana_bold.ttf');

//Pfad zur Hintergrundgrafik
$image = "geocaching/sig.png";

//Neues Bild auf Basis der Hintergrundgrafik erstellen
$im = imagecreatefrompng($image);
$size = getimagesize($image);

//Textfarben definieren
$orange  = ImageColorAllocate ($im, 251, 173, 0);
$yellow = ImageColorAllocate ($im, 255, 239, 39);
// $black = ImageColorAllocate($im, 0, 0, 0); # Hier wird der Variable $black die Farbe schwarz zugewiesen
$white = ImageColorAllocate($im, 255, 255, 255); # Hier wird der Variable $white die Farbe weiß zugewiesen
# Die drei nullen bestehen aus den RGB-Parametern. 255, 0, 0 wäre z.B. rot. ($img muss am Anfang stehen)
$purple = ImageColorAllocate($im, 205, 55, 139); 
$red = ImageColorAllocate($im, 255, 0, 0); # Hier wird die Farbe rot einer Variable zugewiesen
$blau = ImageColorAllocate($im, 0, 0, 255);
$gruen = ImageColorAllocate($im, 27, 189, 0);
$black = ImageColorAllocate($im, 0, 0, 0); 

// links, oben, links, oben
ImageLine($im, 0, 0, $size[0], 0, $black); //oben 
ImageLine($im, 0, $size[1]-1, 0, 0, $black); //links
ImageLine($im, 0, $size[1]-1, $size[0], $size[1]-1, $black); //unten
ImageLine($im, $size[0]-1, 0, $size[0]-1, $size[1]-1, $black); //rechts
// Text der angezeigt werden soll
ImageTTFText ($im, 8, 0, 49, 12, $blau, $fpath_bold, "Geocaching Statistik"); 
ImageTTFText ($im, 8, 0, 49, 24, $blau, $fpath_bold, "von $username");
ImageTTFText ($im, 8, 0, 49, 35, $orange, $fpath_bold, "gefunden: $finds");
// ImageTTFText ($im, 8, 0, 49, 48, $orange, $fpath_bold, "versteckt: $hidden");
ImageTTFText ($im, 7, 0, 120, 57, $gruen, $fpath_bold, "Schiwi.ath.cx");

//Neues Bild ausgeben
header("Content-Type: image/png");
Imagepng($im); 
ImageDestroy ($im);

?>
 
Oben