php-general Digest 21 Aug 2007 20:20:28 -0000 Issue 4974
Topics (messages 261069 through 261092):
Ïoëeçío äëÿ Áèçíåña
261069 by: php
Re: Pass $_GET to php cli.
261070 by: Per Jessen
Re: Declare variables in advance question
261071 by: Colin Guthrie
261074 by: Stut
261075 by: shiplu
Re: LDAP
261072 by: Colin Guthrie
261078 by: Alain Roger
261085 by: Dan Shirah
261086 by: Daniel Brown
261088 by: Dan Shirah
Re: php 4.4.7 make install with pear causes zend freeing errors
261073 by: M. Sokolewicz
261089 by: John Mendenhall
oracle instantclient 10 problem
261076 by: Rainhard
Server error
261077 by: Humani Power
261079 by: Borokov Smith
keeping fields moving forward
261080 by: Mike Ryan
261081 by: Chris Boget
261083 by: Jim Lucas
261084 by: Mike Ryan
261087 by: Jim Lucas
261092 by: brian
Re: About Session And Cookies
261082 by: Michelle Konzack
php to generate java-script
261090 by: Jas
LDAP ***RESOLVED***
261091 by: Dan Shirah
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
eehdga otjcpm
exqko bbrgkf
--- End Message ---
--- Begin Message ---
N0K wrote:
> But if it run in the browser, i think it have to run in cli, dont you
> think ?
No, certainly not by default. They are very different environments, as
you have already found out.
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
nitrox . wrote:
> I want to declare these variables Game_id and Member_id in advance. Following
> the suggestionfrom one of my books can I do something like this:
>
> $expected = array('Game_id', 'Member_id');foreach($expected AS $key) { if
> ( !empty($_POST[$key])) { ${$key} = $_POST[$key]; } else {
> ${$key} = NULL; }} case "addmember": switch ($_GET['type']) {
> case "membergame": $sql = "INSERT INTO xsm_membergames
> (Game_id, Member_id) VALUES
> ('" . mysql_real_escape_string((int)$_POST["Game_id"])) . "',
> '" . mysql_real_escape_string((int)$_POST["Member_id"])) .
> "')"; break; } break;
> My concern is did I achieve anything with the code I just added to declare
> the variables? Is it actually being passed to this: case "addmember":
> switch ($_GET['type']) { case "membergame": $sql = "INSERT
> INTO xsm_membergames (Game_id,
> Member_id) VALUES ('" .
> mysql_real_escape_string((int)$_POST["Game_id"]) . "', '"
> . mysql_real_escape_string((int)$_POST["Member_id"]) . "')"; break;
> } break;
> I did add this and tested it on my server and I didnt recieve any errors. So
> how can I be sure its doing what I intended?
> _________________________________________________________________
> See what you’re getting into…before you go there
> http://newlivehotmail.com/?ocid=TXT_TAGHM_migration_HM_viral_preview_0507
Your code is not formatted very nicly in your mail which makes it very
hard to read, but it's also invalid. There is a case statement in there
without a switch to control it.... twice.
Col
--- End Message ---
--- Begin Message ---
Colin Guthrie wrote:
nitrox . wrote:
I want to declare these variables Game_id and Member_id in advance. Following
the suggestionfrom one of my books can I do something like this:
$expected = array('Game_id', 'Member_id');foreach($expected AS $key) { if ( !empty($_POST[$key])) { ${$key} = $_POST[$key]; } else { ${$key} = NULL; }} case "addmember": switch ($_GET['type']) { case "membergame": $sql = "INSERT INTO xsm_membergames (Game_id, Member_id) VALUES ('" . mysql_real_escape_string((int)$_POST["Game_id"])) . "', '" . mysql_real_escape_string((int)$_POST["Member_id"])) . "')"; break; } break;
My concern is did I achieve anything with the code I just added to declare the variables? Is it actually being passed to this: case "addmember": switch ($_GET['type']) { case "membergame": $sql = "INSERT INTO xsm_membergames (Game_id, Member_id) VALUES ('" . mysql_real_escape_string((int)$_POST["Game_id"]) . "', '" . mysql_real_escape_string((int)$_POST["Member_id"]) . "')"; break; } break;
I did add this and tested it on my server and I didnt recieve any errors. So how can I be sure its doing what I intended?
_________________________________________________________________
See what you’re getting into…before you go there
http://newlivehotmail.com/?ocid=TXT_TAGHM_migration_HM_viral_preview_0507
Your code is not formatted very nicly in your mail which makes it very
hard to read, but it's also invalid. There is a case statement in there
without a switch to control it.... twice.
That being the case the fact that you didn't get any errors indicates
that you have PHP configured to not show errors, warnings and notices. I
strongly recommend you modify your php.ini and set display_errors to on
and error_reporting to E_ALL. Then restart your web server and try your
script again. You should then see lots of errors.
-Stut
--
http://stut.net/
--- End Message ---
--- Begin Message ---
use
#php -s
command to indend your source file
On 8/21/07, Colin Guthrie <[EMAIL PROTECTED]> wrote:
> nitrox . wrote:
> > I want to declare these variables Game_id and Member_id in advance.
> > Following the suggestionfrom one of my books can I do something like this:
> >
> > $expected = array('Game_id', 'Member_id');foreach($expected AS $key) {
> > if ( !empty($_POST[$key])) { ${$key} = $_POST[$key]; } else {
> > ${$key} = NULL; }} case "addmember": switch ($_GET['type']) {
> > case "membergame": $sql = "INSERT INTO xsm_membergames
> > (Game_id, Member_id)
> > VALUES ('" .
> > mysql_real_escape_string((int)$_POST["Game_id"])) . "',
> > '" . mysql_real_escape_string((int)$_POST["Member_id"])) . "')";
> > break; } break;
> > My concern is did I achieve anything with the code I just added to declare
> > the variables? Is it actually being passed to this: case "addmember":
> > switch ($_GET['type']) { case "membergame": $sql =
> > "INSERT INTO xsm_membergames (Game_id,
> > Member_id) VALUES ('" .
> > mysql_real_escape_string((int)$_POST["Game_id"]) . "',
> > '" . mysql_real_escape_string((int)$_POST["Member_id"]) . "')";
> > break; } break;
> > I did add this and tested it on my server and I didnt recieve any errors.
> > So how can I be sure its doing what I intended?
> > _________________________________________________________________
> > See what you're getting into…before you go there
> > http://newlivehotmail.com/?ocid=TXT_TAGHM_migration_HM_viral_preview_0507
>
>
> Your code is not formatted very nicly in your mail which makes it very
> hard to read, but it's also invalid. There is a case statement in there
> without a switch to control it.... twice.
>
> Col
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
shout at http://shiplu.awardspace.com/
Available for Hire/Contract/Full Time
--- End Message ---
--- Begin Message ---
Alain Roger wrote:
> Hi,
>
> I have a stupid issue with ldap_connect.
>
> i've reinstalled PHP, postgreSQL and restore my data (web files) after
> reinstalling my PC.
> now, when i try : $ds = ldap_connect($ldaphost, $ldapport) or die("Could not
> connect to $ldaphost");
>
> nothing works.
> i wrote before error_reporting(E_ALL); in order to check which error message
> i get, but nothing is return as error.
>
> what could be the problem ?
Silly question but is the PHP you installed exactly the same as the
previous one or did you select a different package? Perhaps PHP is
compiled without ldap support or perhaps you've not installed the
subpackage needed to enable ldap support. For me I have to install
php-ldap subpackage.
I would expect to see a fatal error saying no such function etc. so this
is perhaps not the problem, but worth a look.
Col
--- End Message ---
--- Begin Message ---
I found what was the problem :-(
in PHP.ini the Temp directory was not setup the same.
i do not know what is the link with LDAP module, but since i updated php.ini,
it works correctly.
Alain
On 8/21/07, Colin Guthrie <[EMAIL PROTECTED]> wrote:
>
> Alain Roger wrote:
> > Hi,
> >
> > I have a stupid issue with ldap_connect.
> >
> > i've reinstalled PHP, postgreSQL and restore my data (web files) after
> > reinstalling my PC.
> > now, when i try : $ds = ldap_connect($ldaphost, $ldapport) or die("Could
> not
> > connect to $ldaphost");
> >
> > nothing works.
> > i wrote before error_reporting(E_ALL); in order to check which error
> message
> > i get, but nothing is return as error.
> >
> > what could be the problem ?
>
>
> Silly question but is the PHP you installed exactly the same as the
> previous one or did you select a different package? Perhaps PHP is
> compiled without ldap support or perhaps you've not installed the
> subpackage needed to enable ldap support. For me I have to install
> php-ldap subpackage.
>
> I would expect to see a fatal error saying no such function etc. so this
> is perhaps not the problem, but worth a look.
>
> Col
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.3
Apache 2.2.4
PHP 5.2.3
--- End Message ---
--- Begin Message ---
Okay, hopefully someone can help me out here. I've gone over ldap at
php.net and multiple other sites but can't get it to work. Everytime I run
the query my results are "0 entries returned".
My AD tree is: CN=Users,DC=domain,DC=us. I have the AD Server set so that
anonymous access to retrieve information is enabled.
Below is my code. Any ideas?
<?php
$ldap_host = "AD Server";
$ldap_port = "389";
$base_dn = "DC=domain,DC=us";
$filter = "(CN=users)";
$connect = ldap_connect( $ldap_host, $ldap_port);
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
$bind = ldap_bind($connect);
$read = ldap_search($connect, $base_dn, $filter);
$info = ldap_get_entries($connect, $read);
echo $info["count"]." entries returned<BR><BR>";
for($row = 0; $row<$info["count"]; $row++)
{
for($column = 0; $column<$info[$row]["count"]; $column++)
{
$data = $info[$row][$column];
echo $data.":".$info[$row][$data][0]."<BR>";
}
echo "<BR>";
}
ldap_close($connect);
?>
--- End Message ---
--- Begin Message ---
On 8/21/07, Dan Shirah <[EMAIL PROTECTED]> wrote:
> Okay, hopefully someone can help me out here. I've gone over ldap at
> php.net and multiple other sites but can't get it to work. Everytime I run
> the query my results are "0 entries returned".
>
> My AD tree is: CN=Users,DC=domain,DC=us. I have the AD Server set so that
> anonymous access to retrieve information is enabled.
>
> Below is my code. Any ideas?
>
>
> <?php
> $ldap_host = "AD Server";
> $ldap_port = "389";
> $base_dn = "DC=domain,DC=us";
> $filter = "(CN=users)";
> $connect = ldap_connect( $ldap_host, $ldap_port);
> ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
>
> $bind = ldap_bind($connect);
> $read = ldap_search($connect, $base_dn, $filter);
>
> $info = ldap_get_entries($connect, $read);
> echo $info["count"]." entries returned<BR><BR>";
> for($row = 0; $row<$info["count"]; $row++)
> {
> for($column = 0; $column<$info[$row]["count"]; $column++)
> {
> $data = $info[$row][$column];
> echo $data.":".$info[$row][$data][0]."<BR>";
> }
> echo "<BR>";
> }
> ldap_close($connect);
> ?>
>
This may be kind of a dumb question.... but did you check your
firewall settings?
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
Hey, PHP-General list....
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.
--- End Message ---
--- Begin Message ---
Nothing is being blocked since both servers are inside the DMZ.
On 8/21/07, Daniel Brown <[EMAIL PROTECTED]> wrote:
>
> On 8/21/07, Dan Shirah <[EMAIL PROTECTED]> wrote:
> > Okay, hopefully someone can help me out here. I've gone over ldap at
> > php.net and multiple other sites but can't get it to work. Everytime I
> run
> > the query my results are "0 entries returned".
> >
> > My AD tree is: CN=Users,DC=domain,DC=us. I have the AD Server set so
> that
> > anonymous access to retrieve information is enabled.
> >
> > Below is my code. Any ideas?
> >
> >
> > <?php
> > $ldap_host = "AD Server";
> > $ldap_port = "389";
> > $base_dn = "DC=domain,DC=us";
> > $filter = "(CN=users)";
> > $connect = ldap_connect( $ldap_host, $ldap_port);
> > ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
> >
> > $bind = ldap_bind($connect);
> > $read = ldap_search($connect, $base_dn, $filter);
> >
> > $info = ldap_get_entries($connect, $read);
> > echo $info["count"]." entries returned<BR><BR>";
> > for($row = 0; $row<$info["count"]; $row++)
> > {
> > for($column = 0; $column<$info[$row]["count"]; $column++)
> > {
> > $data = $info[$row][$column];
> > echo $data.":".$info[$row][$data][0]."<BR>";
> > }
> > echo "<BR>";
> > }
> > ldap_close($connect);
> > ?>
> >
>
> This may be kind of a dumb question.... but did you check your
> firewall settings?
>
> --
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107
>
> Hey, PHP-General list....
> 50% off for life on web hosting plans $10/mo. or more at
> http://www.pilotpig.net/.
> Use the coupon code phpgeneralaug07
> Register domains for about $0.01 more than what it costs me at
> http://domains.pilotpig.net/.
>
--- End Message ---
--- Begin Message ---
Chris wrote:
M. Sokolewicz wrote:
Chris wrote:
John Mendenhall wrote:
Is the only valid response to problems with php4 to
upgrade to php5? Or, are there still some people
out there still using php4 and possibly have had
problems with install such as the following?
If php5 is the only answer, I guess we'll just have
to go with what we have and limp along until we can
get everything converted to work on php5.
I sent this to the php-install list.
Try the -internals list.
I don't think the php-internals folks would appreciate such emails.
For problems with the install, first make sure it's not your fault
(sounds stupid, but usually is), and if it's a bug, report it via the
bugtracker. There is no need to bother the PHP developers with such
things.
The compiler complaining about free'ing memory is something they
should pay attention to as far as I'm concerned. *shrug*
Clearly I should've read the thread better, somehow I missed that
entirely -.-
sorry bout that :)
anyway, first thing to do before posting is cutting down on your config
options to the bare minimum to see if it's due to the core engine or
some kind of extension, I'm sure they would appreciate it.
--- End Message ---
--- Begin Message ---
> >The compiler complaining about free'ing memory is something they
> >should pay attention to as far as I'm concerned. *shrug*
> >
> Clearly I should've read the thread better, somehow I missed that
> entirely -.-
> sorry bout that :)
>
> anyway, first thing to do before posting is cutting down on your config
> options to the bare minimum to see if it's due to the core engine or
> some kind of extension, I'm sure they would appreciate it.
I was assisted by Johannes Schl?ter.
He told me the -enable-debug configure
option was causing these error messages
to be displayed.
I removed that option and the error
messages were no longer displayed.
I am working towards getting all of
our customers off of php4 now.
Thanks for your assistance and pointers.
JohnM
--
john mendenhall
[EMAIL PROTECTED]
surf utopia
internet services
--- End Message ---
--- Begin Message ---
Ehlo,
I compiled php-5.2.3 with the
"--with-oci8=instantclient,/opt/instantclient_10_2/" switch and it
completed with no errors.
First it seems to work well, but now, sometimes i get the infamous -
OCIEnvNlsCreate() failed check LD_LIBRARY_PATH - error.
The funny thing is, those variables are all set.
I dont have really a clue why this appears now.
versions in use
apache 2.2.4
php 5.2.3
instantclient 10.2.0.3
These parameters are set before the apache is started
ORACLE_BASE=/opt/instantclient_10_2
ORACLE_HOME=$ORACLE_BASE
NLS_LANG=GERMAN_GERMANY.WE8ISO8859P9
PATH=$PATH:$ORACLE_BASE
LD_LIBRARY_PATH=$ORACLE_BASE
TNS_ADMIN=/etc
ORACLE_SID=SID
Any suggestions would be much appreciated.
TIA
Rainhard
--- End Message ---
--- Begin Message ---
Hi everybody. I have a Fedora Core 7 with php 5, and I want to upload an
image.
The funniest thing is that my script works fine in other computer but not in
this one.
I look for the error in /var/log/httpd/error.log and I found this
[Tue Aug 21 15:52:46 2007] [notice] caught SIGTERM, shutting down
[Tue Aug 21 15:55:32 2007] [notice] suEXEC mechanism enabled (wrapper:
/usr/sbin/suexec)
[Tue Aug 21 15:55:32 2007] [notice] Digest: generating secret for digest
authentication ...
[Tue Aug 21 15:55:32 2007] [notice] Digest: done
[Tue Aug 21 15:55:33 2007] [notice] mod_python: Creating 4 session mutexes
based on 256 max processes and 0 max threads.
[Tue Aug 21 15:55:33 2007] [notice] mod_python: using mutex_directory /tmp
[Tue Aug 21 15:55:34 2007] [notice] Apache/2.2.4 (Unix) DAV/2 PHP/5.2.2
mod_python/3.3.1 Python/2.5 mod_ssl/2.2.4 OpenSSL/0.9.8b mod_perl/2.0.3
Perl/v5.8.8 configured -- resuming normal operations
I know that this is PHP forum, but dont know if it is related.
Thanks for your help
--- End Message ---
--- Begin Message ---
Hi dr Nick,
The $_FILES autoglobal contains an error code if something went wrong.
What is the code set to ?
Regards,
boro
Humani Power schreef:
Hi everybody. I have a Fedora Core 7 with php 5, and I want to upload an
image.
The funniest thing is that my script works fine in other computer but not in
this one.
I look for the error in /var/log/httpd/error.log and I found this
[Tue Aug 21 15:52:46 2007] [notice] caught SIGTERM, shutting down
[Tue Aug 21 15:55:32 2007] [notice] suEXEC mechanism enabled (wrapper:
/usr/sbin/suexec)
[Tue Aug 21 15:55:32 2007] [notice] Digest: generating secret for digest
authentication ...
[Tue Aug 21 15:55:32 2007] [notice] Digest: done
[Tue Aug 21 15:55:33 2007] [notice] mod_python: Creating 4 session mutexes
based on 256 max processes and 0 max threads.
[Tue Aug 21 15:55:33 2007] [notice] mod_python: using mutex_directory /tmp
[Tue Aug 21 15:55:34 2007] [notice] Apache/2.2.4 (Unix) DAV/2 PHP/5.2.2
mod_python/3.3.1 Python/2.5 mod_ssl/2.2.4 OpenSSL/0.9.8b mod_perl/2.0.3
Perl/v5.8.8 configured -- resuming normal operations
I know that this is PHP forum, but dont know if it is related.
Thanks for your help
--- End Message ---
--- Begin Message ---
I am creating a series of forms that collect information this covers 3
screens before I want to write it out to the database. when I go from one
screen to the next I have tried hidden and readonly input boxes but the data
in the hidden and readonly fields from screen one do not make it to the
final page.
Is there a way to get the data from page one without letting the users
modify the information. I guess I could write the data to the database but
how do I find the record number of the data I just wrote so that I can
update the information, will php tell me the record number? I am using php
5.2.1 and mysql 5.x
thanks for your help.
--- End Message ---
--- Begin Message ---
> Is there a way to get the data from page one without
> letting the users modify the information. I guess I
> could write the data to the database
Or you could store the data in the session space...
thnx,
Chris
--- End Message ---
--- Begin Message ---
Mike Ryan wrote:
I am creating a series of forms that collect information this covers 3
screens before I want to write it out to the database. when I go from one
screen to the next I have tried hidden and readonly input boxes but the data
in the hidden and readonly fields from screen one do not make it to the
final page.
Is there a way to get the data from page one without letting the users
modify the information. I guess I could write the data to the database but
how do I find the record number of the data I just wrote so that I can
update the information, will php tell me the record number? I am using php
5.2.1 and mysql 5.x
thanks for your help.
Are working with the data from Form 1 before going to form 2 and so forth?
If you are not, then you could look into a three layered div with tabs and keep
it all on one page.
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
"Jim Lucas" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Mike Ryan wrote:
> > I am creating a series of forms that collect information this covers 3
> > screens before I want to write it out to the database. when I go from
one
> > screen to the next I have tried hidden and readonly input boxes but the
data
> > in the hidden and readonly fields from screen one do not make it to the
> > final page.
> >
> > Is there a way to get the data from page one without letting the users
> > modify the information. I guess I could write the data to the database
but
> > how do I find the record number of the data I just wrote so that I can
> > update the information, will php tell me the record number? I am using
php
> > 5.2.1 and mysql 5.x
> >
> > thanks for your help.
> >
> >
> Are working with the data from Form 1 before going to form 2 and so forth?
>
> If you are not, then you could look into a three layered div with tabs and
keep it all on one page.
>
> --
> Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare
yes I get information from form one transfers to form two ok but then does
not show up on form 3. form 1 and 2 do not then save to the database after
the last page of form 3.
--- End Message ---
--- Begin Message ---
Mike Ryan wrote:
yes I get information from form one transfers to form two ok but then does
not show up on form 3. form 1 and 2 do not then save to the database after
the last page of form 3.
That wasn't my question.
Again, when you submit form 1, do you do any processing of the data that came in from form 1 and
then place that data inside form 2, and then when form 2 is submitted do you process the data in any
way before inserting it into form 3?
I understand what you are doing with form 3, but I am wondering about form 1
and form 2.
Do you process any of the data from form 1 & 2 before submitting all the data
with form 3?
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
Mike Ryan wrote:
I am creating a series of forms that collect information this covers 3
screens before I want to write it out to the database. when I go from one
screen to the next I have tried hidden and readonly input boxes but the data
in the hidden and readonly fields from screen one do not make it to the
final page.
Is there a way to get the data from page one without letting the users
modify the information. I guess I could write the data to the database but
how do I find the record number of the data I just wrote so that I can
update the information, will php tell me the record number? I am using php
5.2.1 and mysql 5.x
I'd write a class to handle the submissions; I pretty much always do
this with forms. Instantiate the object on the first submit, populate
with whatever from form 1, do your validation, store the object in the
session and display form 2. Repeat.
You could give the class methods to handle setting each field and
validation methods for each form. When all is done, call persist() and
you're done.
Just remember to include() your class file before calling session_start().
As an aside, whenever i'm displaying a form i instantiate the class
first. This way, my form markup can have, eg:
<input type="text" name="foo" value="<?= my_class->getFoo() ?>" />
so that on the first pass the empty object returns NULL. When i want to
re-display the form (because there was an error somewhere) the
already-populated vars are written back to the form.
brian
--- End Message ---
--- Begin Message ---
Am 2007-08-17 22:07:47, schrieb Bastien Koert:
>
> If cookies are not available, you can either
>
> hide the id in the hidden form field element
> or
> enable trans_sid to automatically pass the session id in the url
This will be a security risk since Session-Hijacker can grap the URL
Greetings
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant
--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSN LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
signature.pgp
Description: Digital signature
--- End Message ---
--- Begin Message ---
Anyone have a good method of grabbing the current page and reading data
from it?
For example:
<?PHP
// find all form fields for current page
function FindFormFields( $page ) {
if( empty( $page ) ) {
$data = -1;
} else {
if( ( $fh = @fopen( $page, "r" ) ) === FALSE ) {
$data = -1;
} else {
while( !feof( $fh ) ) {
$line = fgets( $fh, 512 );
if( eregi( "<input type=\"", $line ) ) {
$data[] = $line;
}
}
fclose( $fh );
}
}
return $data;
}
echo FindFormFields( "http://php.net" );
?>
The above code would output the following:
Array
(
[0] => <input type="text" name="pattern" value="" size="30"
accesskey="s" />
[1] => <input type="image"
)
Now for the problem I am having and a description of what I am trying to
accomplish:
I want to dynamically generate a form and in doing so I would like to
dynamically generate the following javascript features for said page
- javascript form validation
- javascript form field focus
The problem is if I call the current page that is being generated such as
<?PHP
echo FindFormFields( "http://" . $_SERVER['SERVER_NAME'] .
$_SERVER['REQUEST_URI'] );
?>
Not only does it take a helluva long time to load the page but it also
creates a nested array with duplicate values.
My best guess is that the order in which the page is being generated has
something to do with the lag as well as the nested array with duplicate
values.
Could anyone help me or point me in a better direction for performing
these actions?
Thanks in advance,
Jas
--- End Message ---
--- Begin Message ---
Apparently even though our Domain Administrator said anonymous access is
enabled for the server, it still did not like me trying to query AD
anonymously. I created a username/password with limited priviledges to AD
and now it works like a charm.
Below you will find my finished code:
<?php
$base_dn="CN=users,DC=domain,DC=us";
$ldap_host="AD server";
$ldap_port="389";
$ldap_user="CN=username, CN=Users, DC=domain, DC=us";
$ldap_pass="password";
$filter="(&(objectclass=user)(Description=My Organization)(cn=*))";
$connect = ldap_connect( $ldap_host, $ldap_port)
or exit(">>Could not connect to LDAP server<<");
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
$bind = ldap_bind($connect, $ldap_user, $ldap_pass)
or exit(">>Could not bind to $ldap_host<<");
$read = ldap_search($connect, $base_dn, $filter)
or exit(">>Unable to search ldap server<<");
$info = ldap_get_entries($connect, $read);
echo $info["count"]." entries returned<p>";
$ii=0;
for ($i=0; $ii<$info[$i]["count"]; $ii++){
$data = $info[$i][$ii];
echo $data.": ".$info[$i][$data][0]."<br>";
}
ldap_close($connect);
?>
--- End Message ---