[PHP-DEV] INI File Entries: Retrieving Multiple/Unregistered

2002-12-25 Thread Marshall A. Greenblatt
Hi guys,

I'm currently writing a PHP module compiled against 4.2.3 sources that needs
to load multiple name/value pairs dynamically at run-time.  Ideally, I would
like to use entries in the PHP INI file, but the names of those entries will
not necessarily be known at compile-time.  One of two models would be ideal
for my purposes;  either multiple entries with the same name, or one entry
that contains the names of other entries to be loaded.  For instance:

mymodule.load = mymodule_foo /path/to/foo_extension.so.4.8
mymodule.load = mymodule_bar /path/to/bar_extension.so.1.5

or

mymodule.load = mymodule_foo, mymodule_bar
mymodule_foo = /path/to/foo_extension.so.4.8
mymodule_bar = /path/to/bar_extension.so.1.5

However, it seems that the only (non-hackish) way for a module to retrieve
INI file entries is by registering the name with the ZEND_INI_* family of
functions, and then retrieving the value via either a callback function or
the INI_* functions.  If I use the first method (multiple entries with the
same name) only the last entry with that name in the INI file is passed to
the callback function.  If I use the second method (specifying the entry
names using another, known, entry) then I can't access the sub-entries
because they weren't compiled in and therefore aren't recognized by the INI
file parser (as far as I can tell).

Does anyone have any suggestions on how I could implement this type of
configuration mechanism using existing PHP INI file functionality?  I'd
rather not put everything on one line, as that would become rather messy as
the number of entries increases.  I'd also like to avoid loading a separate
configuration file just for my module, if at all possible.

Thanks,
  Marshall


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] session only for who needs it

2002-12-25 Thread Rick Widmer
At 03:59 AM 12/26/02 +0100, Mattia wrote:

First, this list is for the development _of_ PHP, not development _with_ 
PHP, so further discussion of this and similar subjects should appear on 
the php-general list.

I have a site in wich user can register, but everyone can navigate as
Guest, even if he/she is nt registered.
The problem is that I need session for registered user, but I don't
need them for unregistered ones!
So I tried to check if they already have an opened session (they are
registered), but to check it I have to do a session_start(), and this
will OPEN a session if it's not opened! So I'll have an opened session
for every guest I have in the site. This is difficult for me because I
would like session to last very long, and many empty session waste a
lot of space!


Try something like:

if( isset( $REQUEST[ 'PHPSESSID' ] )) { #  User is registered/logged in
   session_start();
   }

This is based on looking for the cookie or get value for PHPSESSID, the 
default session name.  If it is set, then either a cookie with the session 
ID is set, or the session is being passed in the URL.

Rick


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] session only for who needs it

2002-12-25 Thread Mattia
I have a site in wich user can register, but everyone can navigate as
Guest, even if he/she is nt registered.
The problem is that I need session for registered user, but I don't
need them for unregistered ones!
So I tried to check if they already have an opened session (they are
registered), but to check it I have to do a session_start(), and this
will OPEN a session if it's not opened! So I'll have an opened session
for every guest I have in the site. This is difficult for me because I
would like session to last very long, and many empty session waste a
lot of space!

so session_start() must be like

void session_start()
{
  if( [cookie_on_client] == [sess_file_on_server] )
  {
look_up_the_file [...]
  }
  else
  {
// create new session
create sess_file_on_server
give corresponding cookie to client
  } ...
}

but I would need a function like

bool session_check()
{
 if( [cookie_on_client] == [sess_file_on_server] )
  {
return true;
  }
  else
  {
return false;
  }
}

Is it possible to do it with the PHP session API, without hacking the
code, go and read the session files,...?
any hint is appreciated.

bye
Mattia Cazzola



-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: Fwd: Re: [PHP-DEV] ext_skel

2002-12-25 Thread Leon Mergen
Hello,

"David Gillies" <[EMAIL PROTECTED]> schreef in bericht
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> OK, how about a much-expanded version for 4.3.1, say?
> I'm a big fan of self-documenting code (use the
> source, Luke). Perhaps a default function with all the
> bells and whistles (checking for references, grabbing
> a resource, etc, all documented up the wazoo).

Being a complete newbie at extending PHP (I started yesterday as we speak) ,
I must say that that first function helped me a lot. It gave me a general
idea how the things worked, and also how argument passing works.

And, like you stated, I think it would be a great idea to demonstrate all
major functions that people use...

Just my $0.02 worth

Regards,

Leon Mergen
http://www.antrophia.com/



-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] " too few arguments to function `call_user_function_ex'"

2002-12-25 Thread Leon Mergen

"Derick Rethans" <[EMAIL PROTECTED]> schreef in bericht
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Tought this was the best newsgroup to post to, since I'm developing an
> > in-house only additional PHP module.
> >
> > Anyway, I want to call a user function from a function in my module...
so I
> > should use call_user_function_ex . Well, I tried the example on the
website,
>
> The website is outdated, just find an example in the normal extensions
> that we have. There are tons of examples there.

Okay, many thanks for the fast response!

So I am not crazy... :-x

Grtz,

Leon



-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] " too few arguments to function `call_user_function_ex'"

2002-12-25 Thread Derick Rethans
On Wed, 25 Dec 2002, Leon Mergen wrote:

> Tought this was the best newsgroup to post to, since I'm developing an
> in-house only additional PHP module.
> 
> Anyway, I want to call a user function from a function in my module... so I
> should use call_user_function_ex . Well, I tried the example on the website,

The website is outdated, just find an example in the normal extensions 
that we have. There are tons of examples there.

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] " too few arguments to function `call_user_function_ex'"

2002-12-25 Thread Leon Mergen
Hello,

Tought this was the best newsgroup to post to, since I'm developing an
in-house only additional PHP module.

Anyway, I want to call a user function from a function in my module... so I
should use call_user_function_ex . Well, I tried the example on the website,
and it gives me the error:

antrophia.c: In function `zif_antrophia_msgincrease':
antrophia.c:147: too few arguments to function `call_user_function_ex'


I have pasted the source of that function below... anyone has any idea what
I am doing wrong? (and again, I am sorry if this is the wrong group)

Thanks in advance.

Regards,

Leon Mergen



--- source


PHP_FUNCTION(antrophia_msgincrease)
{
 zval *rtrn;
 zval **function_name;

 if((ZEND_NUM_ARGS() != 1) || (zend_get_parameters_ex(1, &function_name) !=
SUCCESS))
 {
 WRONG_PARAM_COUNT;
 }

 if((*function_name)->type != IS_STRING)
 {
 zend_error(E_ERROR, "Function requires string argument");
 }

 // Introduce compiler globals (CG) to this function
 TSRMLS_FETCH();

 if(call_user_function_ex(CG(function_table), NULL, *function_name, &rtrn,
0, NULL, 0) != SUCCESS)
 {
 zend_error(E_ERROR, "Function call failed");
 }

 zend_printf("We have %i as type", rtrn->type);

 *return_value = *rtrn;
 zval_copy_ctor(return_value);
 zval_ptr_dtor(&rtrn);
}



-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] DomXML and ZE2?

2002-12-25 Thread Erik Franzén
I am testing the new Zend Engine (win32-binary) and trying to add domXML
support via the extension php_domxml.dll

I get the errorcode:

unknown(): Unable to load dynamic library
'C:\php\php4-ze2\extensions\php_domxml.dll' - Can't find the given module

The extension path is correct.

When I look at the compile log for ZE2, the domXML is compiled.

Now I wonder if ZE2 can use the domxml extention?




-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] [PATCH] CLI and CGI defaults

2002-12-25 Thread Philip Olson
> Andrei already decided, that --enable-cli should not change it's
> behavior for 4.3, allthough I think it's intuitive for --enable-cli to
> disable CGI if --enable-cgi was not given, I don't have a problem with
> it, as long as the NEWS entry is correct and Philip documents it
> correctly :)

I also feel an explicit --enable-cli should do that but 
regardless the current method has been documented.  The 
distinction can be seen in this unxmled excerpt:

 If a module SAPI is chosen during configure, such as apxs, 
 or the --disable-cgi option is used, the CLI is copied to
 {PREFIX}/bin/php during make install otherwise the CGI 
 is placed there. 

Because CLI is a SAPI so I guess only module (web servers) 
count.  Anyway please have a look at:

http://cvs.php.net/diff.php/phpdoc/en/features/commandline.xml?r1=1.12&r2=1.13

And make sure this is written correctly.  If so, information
from it will also live in install.commandline.  Btw, it sure
is weird writing examples when cgi and cli have the same 
name and get installed at the location.  I didn't change 
those much.  I also didn't add the history of what these 
files were called in 4.2.x as I'm not fully sure how it all 
worked back then *hint* *hint*.

Regards,
Philip Olson


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Bug # 21177 - main/main.c_r1.515 - Second call to sapi_activate?

2002-12-25 Thread Sara Golemon
Ref: http://bugs.php.net/21177

r1.515 seems to have added a second call to sapi_activate.  In the case of
this particular bug this is causing the following behavior:

1) Call sapi_active: initialize sapi globals

2) sapi/cgi sets SG(headers_sent) = 1 for options like -q & -f

3) New Code in patch r1.515 calls sapi_active again, reinitializing the
sapi globals ( in this case SG(headers_sent) = 0 )


Can someone explain this second call to sapi_active?

"gschlossnagle" perhaps?

-Pollita



-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php