WebWork Magazin - Webseiten erstellen lassen, Online Medien, html

Webhoster, Webhosting Provider und Domain registrieren

Home | Registrieren | Einloggen | Suchen | Aktuelles | GSL-Webservice | Suleitec Webhosting
Reparatur-Forum | Elektro forum | Ersatzteilshop Haushalt und Elektronik



Im Homepage und Webhosting-Forum --- Https kommunikation mit einen entfernten Server generieren

Scripte und Programme für PHP, MYSQL. Diskussionen zur Programmierung im Web. Fragen zu CMS, Blogsoftware, Shops, Newsletter und vielen weiteren Scripten.

Forum » PHP & MySQL » Https kommunikation mit einen entfernten Server generieren Antworten
im Forum für Webhosting Homepage gefunden:
Https kommunikation mit einen entfernten Server generieren
Austin Powers
Mausakrobat
Threadstarter




Beiträge: 169

OK altes Problem neue Auflage.
Folgendes muß mein script machen:
1. Entfernte Seite aufrufen
2. Logindaten per https übermitteln (geht nur per https)
3. Session Cookie empfangen
4. Unterseite aufrufen und dabei den session Cookie senden
5. Daten der Seite auslesen und Information extrahieren.
(es sind meine Daten, nur das sie halt von jemanden anders geniert werden... aus so einer art online Spiel, ich will nur meine ganz individuelle Homepage daraus machen, und immer die aktuellsten Daten verwenden)
Soweit so gut.. es geht alles bisher, bis auf den https Teil, ich weiß einfach nicht was ich machen muß um eine https Komunikation zwischen zwei Servern aufzubauen..... eine Lücke im Basiswissen. Ich hab mal in snoopy reingeschaut aber curl sagt mir nicht so viel. (Linux ist immer noch ein böhmisches Dorf mit sieben Siegeln für mich ... oder wie ging der Spruch)
Hier wie es soopy macht:
1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
37: 
38: 
39: 
40: 
41: 
42: 
43: 
44: 
45: 
46: 
47: 
48: 
49: 
50: 
51: 
52: 
53: 
54: 
55: 
56: 
57: 
58: 
59: 
60: 
61: 
62: 
63: 
64: 
65: 
66: 
67: 
68: 
69: 
70: 
71: 
72: 
73: 
74: 
75: 
76: 
77: 
78: 
79: 
80: 
81: 
82: 
83: 
84: 
85: 
86: 
87: 
88: 
89: 
90: 
91: 
92: 
93: 
94: 
95: 
96: 
97: 
98: 
99: 
100: 
101: 
102: 
103: 
104: 
105: 
106: 
107: 
108: 
109: 
110: 
111: 
112: 
113: 
114: 
115: 
116: 
117: 
118: 
119: 
120: 
121: 
122: 
123: 
124: 
125: 
126: 
127: 
128: 
129: 
130: 
131: 
132: 
133: 
134: 
135: 
136: 
137: 
138: 
139: 
140: 
141: 
142: 
143: 
144: 
145: 
146: 
147: 
148:
/*======================================================================*\
	Function:	_httpsrequest
	Purpose:	go get the https data from the server using curl
	Input:		$url		the url to fetch
				$URI		the full URI
				$body		body contents to send if any (POST)
	Output:
\*======================================================================*/

	function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
	{
		if($this->passcookies && $this->_redirectaddr)
			$this->setcookies();

		$headers = array();

		$URI_PARTS = parse_url($URI);
		if(empty($url))
			$url = "/";
		// GET ... header not needed for curl
		//$headers[] = $http_method." ".$url." ".$this->_httpversion;
		if(!empty($this->agent))
			$headers[] = "User-Agent: ".$this->agent;
		if(!empty($this->host))
			if(!empty($this->port))
				$headers[] = "Host: ".$this->host.":".$this->port;
			else
				$headers[] = "Host: ".$this->host;
		if(!empty($this->accept))
			$headers[] = "Accept: ".$this->accept;
		if(!empty($this->referer))
			$headers[] = "Referer: ".$this->referer;
		if(!empty($this->cookies))
		{
			if(!is_array($this->cookies))
				$this->cookies = (array)$this->cookies;

			reset($this->cookies);
			if ( count($this->cookies) > 0 ) {
				$cookie_str = 'Cookie: ';
				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
				$cookie_str .= $cookieKey."=".urlencode($cookieVal)."; ";
				}
				$headers[] = substr($cookie_str,0,-2);
			}
		}
		if(!empty($this->rawheaders))
		{
			if(!is_array($this->rawheaders))
				$this->rawheaders = (array)$this->rawheaders;
			while(list($headerKey,$headerVal) = each($this->rawheaders))
				$headers[] = $headerKey.": ".$headerVal;
		}
		if(!empty($content_type)) {
			if ($content_type == "multipart/form-data")
				$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
			else
				$headers[] = "Content-type: $content_type";
		}
		if(!empty($body))
			$headers[] = "Content-length: ".strlen($body);
		if(!empty($this->user) || !empty($this->pass))
			$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);

		for($curr_header = 0; $curr_header < count($headers); $curr_header++) {
			$safer_header = strtr( $headers[$curr_header], "\"", " " );
			$cmdline_params .= " -H \"".$safer_header."\"";
		}

		if(!empty($body))
			$cmdline_params .= " -d \"$body\"";

		if($this->read_timeout > 0)
			$cmdline_params .= " -m ".$this->read_timeout;

		$headerfile = tempnam($temp_dir, "sno");

		$safer_URI = strtr( $URI, "\"", " " ); // strip quotes from the URI to avoid shell access
		exec($this->curl_path." -D \"$headerfile\"".$cmdline_params." \"".$safer_URI."\"",$results,$return);

		if($return)
		{
			$this->error = "Error: cURL could not retrieve the document, error $return.";
			return false;
		}


		$results = implode("\r\n",$results);

		$result_headers = file("$headerfile");

		$this->_redirectaddr = false;
		unset($this->headers);

		for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
		{

			// if a header begins with Location: or URI:, set the redirect
			if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader]))
			{
				// get URL portion of the redirect
				preg_match("/^(Location: |URI:)\s+(.*)/",chop($result_headers[$currentHeader]),$matches);
				// look for :// in the Location header to see if hostname is included
				if(!preg_match("|\:\/\/|",$matches[2]))
				{
					// no host in the path, so prepend
					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
					// eliminate double slash
					if(!preg_match("|^/|",$matches[2]))
							$this->_redirectaddr .= "/".$matches[2];
					else
							$this->_redirectaddr .= $matches[2];
				}
				else
					$this->_redirectaddr = $matches[2];
			}

			if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
				$this->response_code = $result_headers[$currentHeader];

			$this->headers[] = $result_headers[$currentHeader];
		}

		// check if there is a a redirect meta tag

		if(preg_match("']*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
		{
			$this->_redirectaddr = $this->_expandlinks($match[1],$URI);
		}

		// have we hit our frame depth and is there frame src to fetch?
		if(($this->_framedepth < $this->maxframes) && preg_match_all("']+)'i",$results,$match))
		{
			$this->results[] = $results;
			for($x=0; $x_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
		}
		// have we already fetched framed content?
		elseif(is_array($this->results))
			$this->results[] = $results;
		// no framed content
		else
			$this->results = $results;

		unlink("$headerfile");

		return true;
	}

vieles davon brauch ich auch gar nicht...(redirs & frames)
Ich würd das auch gerne machen ohne ein File zu schreiben..so just aus dem ram nur falls möglich... meinen Bastlercode veröffentliche ich hier erstmal nicht... den müste ich erstmal "säubern" (ist eh nur http), wenn einer ne Idee hat einfach melden.
P.S.: für den Login müßte nur ein Form mit drei Feldern übertragen werden.
1. feld username
2. feld passwort
3. feld "log in"="log in"

---
MfG:Austin Power (Saturn Realm)
OMW! Zumindest sobald ich herausgefunden hab wo ich JETZT gerade bin.
<---------->
"Wenn Liebe die Antwort ist, könnst Du bitte die Frage neu formulieren?" ... Lily Tomlin
<---------->
code hier http://www.pastebin.com

Diese Nachricht wurde geändert von: Austin Powers
  Profil   Website   Editieren   Zitieren
Austin Powers
Mausakrobat
Threadstarter




Beiträge: 169

ok hier mal was ich habe ... ist allerding ne große baustelle

http://kitzune.pastebin.com/m4e974542

---
MfG:Austin Power (Saturn Realm)
OMW! Zumindest sobald ich herausgefunden hab wo ich JETZT gerade bin.
<---------->
"Wenn Liebe die Antwort ist, könnst Du bitte die Frage neu formulieren?" ... Lily Tomlin
<---------->
code hier http://www.pastebin.com

  Profil   Website   Editieren   Zitieren
 

Antworten
Forum » PHP & MySQL » Https kommunikation mit einen entfernten Server generieren

Aktuelle Beiträge zur Hilfe im Forum für Homepage - Https kommunikation mit einen entfernten Server generieren im Forum Homepage Hosting AntwortenLetztes Posting
Best online slots
in "PHP & MySQL"
0 23.01.2023 22:40 von Sevetr
Rangliste (Ohne Mysql) (Kompliziertes Ordner System)
in "PHP & MySQL"
3 19.07.2021 06:00 von newtopblog
kleines problem mit phpadmin
in "PHP & MySQL"
5 11.04.2021 22:22 von Zavylon
Counter mit PHP
in "PHP & MySQL"
4 22.03.2021 16:29 von Robeni
Fehlermeldung beim Importieren der Datenbank in phpmyadmin
in "PHP & MySQL"
0 02.08.2019 22:14 von iFuchs
CMS für Online Shop
in "PHP & MySQL"
18 26.05.2019 13:29 von raiserle
Regestrierungproblem
in "PHP & MySQL"
3 28.11.2018 13:20 von norbertofahey
PHP Datum ausgeben?
in "PHP & MySQL"
1 19.10.2018 10:04 von Klaus1973
PHP befehl ausführen
in "PHP & MySQL"
11 16.08.2018 09:08 von Klaus1973
Visual Composer selber programmieren?
in "PHP & MySQL"
0 22.01.2017 23:45 von Redji
php preg_replace_callback für dynamischen Link
in "PHP & MySQL"
0 05.07.2016 11:02 von Rm21
PHP Code verschlüsseln
in "PHP & MySQL"
20 21.02.2016 21:25 von Kilian1
migrierter WP-Blog läuft nicht ...
in "PHP & MySQL"
0 04.02.2016 02:01 von Oxygon



Besucher : 7980469    Heute : 96     Gestern : 314     Online : 26     16.4.2024    8:26      0 Besucher in den letzten 60 Sekunden        
Nach oben