TCLUG Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [TCLUG-DEVEL:228] LDAP/PHP3
I kind of want to do an inline image, but I know that
nothing but Netscape with LDAP URLs can do it. :(
In the code below, I'm just trying to write the image to a
file, but even that doesn't seem to work...
Here's my code:
<HTML>
<HEAD>
<TITLE>Welcome to the LDAP Name Search!</TITLE>
</HEAD>
<BODY>
<?php
if (!$name)
{
echo "Here we go, let's hope that this works!<BR>\n";
echo "<form action=\"$PHP_SELF\" method=\"post\">";
echo "Enter name to search for: <input type=\"text\" name=\"name\"
value=\"$prevname\"><BR>\n";
echo "<input type=\"submit\"></form>\n";
}
else
{
echo "<a href=\"$PHP_SELF?prevname=$name\">Go back</a><BR>\n";
echo "<h3>LDAP query test...</h3><br>\n";
echo "Connecting...<BR>\n";
$ds=ldap_connect("svho1ws6");
echo "connect result is ".$ds."<p>\n";
if ($ds)
{
echo "Binding ...<BR>\n";
$r=@ldap_bind($ds);
echo "Bind result is ".$r."<p>\n";
echo "Searching for cn=$name...<BR>\n";
$sr=@ldap_search($ds,"o=supervalu.com", "cn=*$name*");
echo "Number of entries returned is
".@ldap_count_entries($ds,$sr)."<p>\n";
$info = ldap_first_entry($ds,$sr);
$values = ldap_get_values_len($ds, $info, "jpegphoto");
for ($i=0;$i<$values["count"];$i++)
{
$jpeg=base64_decode($values[$i]);
echo $values[$i]."<br>\n";
$fs= fopen("/opt/apps/gnu/apache/htdocs/image.jpg","w");
fwrite($fs,$jpeg);
fclose($fs);
}
}
}
?>
</BODY>
</HTML>
john1536@tc.umn.edu, on 04/06/2000 05:07:35 PM
To: tclug-devel@mn-linux.org @ PMDF
cc:
Subject: Re: [TCLUG-DEVEL:228] LDAP/PHP3
Mis-cut! I forget the first line of the header :-(
Here is the HTTP conversation:
troy@count#51% telnet www.tc.umn.edu 80
Trying 160.94.218.250...
Connected to www.tc.umn.edu.
Escape character is '^]'.
GET /~john1536/media/images/jeffb.jpg HTTP/1.0
HTTP/1.1 200 OK
Date: Thu, 06 Apr 2000 22:05:16 GMT
Server: Apache/1.3.12 (Unix)
Last-Modified: Fri, 05 Feb 1999 20:08:29 GMT
ETag: "238f9f-f07-36bb4fbd"
Accept-Ranges: bytes
Content-Length: 3847
Connection: close
Content-Type: image/jpeg
JFIF``C(#(#!#-+(0<dA<77...
Sorry,
Troy
Troy Johnson wrote:
>
> Nick,
>
> What does the surrounding code look like? How is the picture being
> presented to the browser? I don't know if I can help, but I think that
> kind info would be useful in tracking down the problem.
>
> This is the kind of header information a browser expects to see with a
> JPEG:
>
> Date: Thu, 06 Apr 2000 21:59:25 GMT
> Server: Apache/1.3.12 (Unix)
> Last-Modified: Fri, 05 Feb 1999 20:08:29 GMT
> ETag: "238f9f-f07-36bb4fbd"
> Accept-Ranges: bytes
> Content-Length: 3847
> Connection: close
> Content-Type: image/jpeg
>
> JFIF``C(#(#!#-...
>
> so it shouldn't be displayed inline, but that might not be the problem
> at all. HTH,
>
> Troy
>
> Nick.T.Reinking@supervalu.com wrote:
> >
> > I've tried doing that with bin64_decode and fwrite,
> > but it seems to have lost something, as the browsers
> > can't read the file.
> >
> > Nick Reinking
> >
> > ------------------------------------------------------------------------
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tclug-devel-unsubscribe@mn-linux.org
> > For additional commands, e-mail: tclug-devel-help@mn-linux.org
>
> --
> <a href="http://umn.edu/~john1536">Troy Johnson</a>
>
> "Those who make peaceful revolution impossible
> will make violent revolution inevitable."
> -- John F. Kennedy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-devel-unsubscribe@mn-linux.org
> For additional commands, e-mail: tclug-devel-help@mn-linux.org
--
<a href="http://umn.edu/~john1536">Troy Johnson</a>
Rifles, muskets, long-bows and hand-grenades are inherently democratic
weapons. A complex weapon makes the strong stronger, while a simple
weapon -- so long as there is no answer to it -- gives claws to the
weak.
-- George Orwell, "You and the Atom Bomb", 1945
---------------------------------------------------------------------
To unsubscribe, e-mail: tclug-devel-unsubscribe@mn-linux.org
For additional commands, e-mail: tclug-devel-help@mn-linux.org