Page 1 of 1

Some code that doesn't work, who can help?

Posted: Thu Jun 06, 2002 3:53 am
by Raphael
Why doesn't this code work?
We expect the fault is to be found between line 26 and 45!
This is the PGP code inside the PHP.
We are using Xitami webserver on Linux, PHP 4, PGP Freeware 7.0.3
We are using Flash MX to execute this script

If someone can help us, that would be great!
Cause I'm really stuck!

--------------------------------------------------------------------------------------
1 <?
2
3 /******************************************************
4 ** Provided by
5 ** http://gandalf.xs4all.nl
6 **
7 *******************************************************/
8
9 // Enter your email address here
10 $adminaddress = "rutger@gandalf.xs4all.nl";
11
12 // Enter the address of your website here MUST include http://www.
13 $siteaddress ="http://www.juwelier-oorebeek.nl";
14
15 // Enter your company name or site name here
16 $sitename = "Het JuweliersHuis Ed Oorebeek";
17
18 // Gets the date and time from your server
19 $date = date("m/d/Y H:i:s");
20
21 // Gets the IP Address
22 if ($REMOTE_ADDR == "") $ip = "no ip";
23 else $ip = getHostByAddr($REMOTE_ADDR);
24
25
26 function pgp_encrypt($keyring_location, $public_key_id, $plain_text) {
27
28 $key_id = EscapeShellArg($public_key_id);
29 putenv("PGPPATH=$keyring_location");
30
31 // encrypt the message
32 $pipe = popen("pgpe -r $key_id -af", "r");
33
34 fwrite($pipe, $plain_text);
35 $encrypted_text = '';
36 while($s = fgets($pipe, 1024)) {
37 // read from the pipe
38 $encrypted_text .= $s;
39 }
40 pclose($pipe);
41
42 return $encrypted_text;
43 }
44
45 $Nummer = pgp_encrypt("/webpages/locationharddisk", "to@domain.com", $Nummer);
46
47 //Process the form data!
48 // and send the information collected in the Flash form to Your nominated email address
49 IF ($action != ""):
50 mail("$adminaddress","Occasion klant via internet",
51 "$sitename \n
52 Voornaam: $fname
53 Achternaam: $lname
54 Creditkaart nr.: $Nummer
55 Op naam van: $kaartnaam
56 Verloop datum:
57 Maand: $maand
58 Jaar: $jaar
59 E-mail: $vemail
60 Artikelnr: $cname
61 Telefoonnr: $telno
62 Adres: $fadres
63 Postcode: $fpostcode
64 Woonplaats: $fplaats
65
66 Opmerking van de bezoeker:
67 ------------------------------
68 $comments
69 ------------------------------
70
71 Inlog Informatie :
72 ------------------------------
73 Using: $HTTP_USER_AGENT
74 Hostname: $ip
75 IP address: $REMOTE_ADDR
76 Date/Time: $date","FROM:$adminaddress");
77
78
79 //This sends a confirmation to your visitor
80 mail("$vemail","Dank u voor uw bezoek aan $sitename", "Geachte $fname,\n
81 Bedankt voor uw interesse in $sitename!\n
82 Uw order wordt zo spoedig mogelijk verwerkt.
83 Wij nemen contact met u op.\n
84 Met vriendelijke groeten,
85 $sitename
86 $siteaddress","FROM:$adminaddress");
87
88 //Confirmation is sent back to the Flash form that the process is complete
89 $sendresult = "Uw order is verzonden!";
90 $send_answer = "answer=";
91 $send_answer .= rawurlencode($sendresult);
92 echo "$send_answer";
93
94 ENDIF;
95 ?>
--------------------------------------------------------------------------------------

Posted: Thu Jun 06, 2002 3:56 am
by twigletmac
Are you getting any error messages - what are they? What's it doing/not doing?

Mac

Posted: Thu Jun 06, 2002 6:47 am
by Raphael
Well I want the filled in string $Nummer to be encryted by PGP

But when the form is filled by the user and send to the owner of the site
The filled space for the string $Nummer is empty

Posted: Fri Jun 07, 2002 2:16 am
by twigletmac
Is it only $Nummer that's affected - is everything else sent ok?

Mac

Posted: Fri Jun 07, 2002 4:29 am
by netclectic
are you sure the problem isn't with your input form? is it definitly $Nummer (not $nummer) that is being passed backed?

Posted: Fri Jun 07, 2002 9:08 am
by Raphael
Yes everything else is ok!

And I dont wat to encrypt the rest, so thats fine!

Posted: Fri Jun 07, 2002 9:17 pm
by volka
hmmm...nothing else is encrypted?
may be a little bit print-debug helps

Code: Select all

26 function pgp_encrypt($keyring_location, $public_key_id, $plain_text) &#123; 
27 
28 $key_id = EscapeShellArg($public_key_id); 
29 putenv("PGPPATH=$keyring_location"); 
30   print('<!-- Dbg: PGPPATH set to '.getenv('PGPPATH').' -->';
31 // encrypt the message 
32 $pipe = popen("pgpe -r $key_id -af", "r") or die('Dbg: popen failed'); 
33 print('<!-- Dbg: fwrite ('.$plaintext.') -->';
34 $nWritten = fwrite($pipe, $plain_text); if ($nWritten == -1) die('Dbg: fwrite failed');
35 $encrypted_text = ''; 
36 while($s = fgets($pipe, 1024)) &#123; 
37 // read from the pipe 
38 $encrypted_text .= $s; print('<!-- Dbg: current res.: "'.$encrypted_text.'" -->';

39 &#125; 
40 pclose($pipe); 
41 
42 return $encrypted_text; 
43 &#125;

Posted: Fri Jun 07, 2002 11:24 pm
by jason
Did you 'chmod o+r pubring.pkr' so that the apache server could read the public keys?