Update to mail() function help

php.internals

Patrick Gibson

23 years ago
I'd like modify the PHP mail() function to add the $_SERVER['SERVER_NAME'] into the header if it's available. It would be equivalent to adding a line into the headers argument from the PHP end that would be like: if ($_SERVER['SERVER_NAME']) { $headers .= '\nX-Originated-From: www.mywebsite.com'; } I see exactly in ext/standard/mail.c where I need to add this, but my problem is I'm not sure how to gain access to the $_SERVER super global array from the C API. Can anyone point me in the right direction? I don't see anything in the API docs that explains this, nor can I think of any PHP function that does something like this for a reference (except phpinfo(), but the code is unclear to me). I run a hosting company, and if any of our customers abuses this function, I want to be able to know from which website the mail originated. When there are hundreds of virtual hosts, something like this would make it really helpful at times. Thanks so much, Patrick

Rasmus Lerdorf

23 years ago
To access $_SERVER['SERVER_NAME'] from C you would do: zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name)==FAILURE) But, if variables_order doesn't include "S" it isn't going to be there. You are probably better off getting it directly from the server instead of from the PHP symbol table. You can call php_apache_getenv() directly, or to be more correct and portable to other SAPI's you would call sapi_module.getenv(). -Rasmus On Fri, 23 May 2003, Patrick Gibson wrote:

Patrick Gibson

23 years ago
Thanks so much -- I'll give this a try. Is there some online documentation where I'd be able to find things like this, or is pretty much just up to me to search through the code to see how it's done elsewhere? (By the way, I attended the Vancouver PHP User Group meeting when you gave your presentation, and found it very informative. I have kept the PDF of it for future reference.) Patrick On 5/23/03 13:30, Rasmus Lerdorf wrote:

Jani Taskinen

23 years ago
Maybe a php.ini option would be best for this? Like mail.extra_headers or something alike..? ie. that would add the specified headers to every mail sent with mail(). --Jani On Fri, 23 May 2003, Rasmus Lerdorf wrote:
>To access $_SERVER['SERVER_NAME'] from C you would do: > >zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name)==FAILURE) > >But, if variables_order doesn't include "S" it isn't going to be there. >You are probably better off getting it directly from the server instead of >from the PHP symbol table. You can call php_apache_getenv() directly, or >to be more correct and portable to other SAPI's you would call >sapi_module.getenv(). > >-Rasmus > > >On Fri, 23 May 2003, Patrick Gibson wrote: > >> I'd like modify the PHP mail() function to add the $_SERVER['SERVER_NAME'] >> into the header if it's available. It would be equivalent to adding a line >> into the headers argument from the PHP end that would be like: >> >> if ($_SERVER['SERVER_NAME']) >> { >> $headers .= '\nX-Originated-From: www.mywebsite.com'; >> } >> >> I see exactly in ext/standard/mail.c where I need to add this, but my >> problem is I'm not sure how to gain access to the $_SERVER super global >> array from the C API. >> >> Can anyone point me in the right direction? I don't see anything in the API >> docs that explains this, nor can I think of any PHP function that does >> something like this for a reference (except phpinfo(), but the code is >> unclear to me). >> >> I run a hosting company, and if any of our customers abuses this function, I >> want to be able to know from which website the mail originated. When there >> are hundreds of virtual hosts, something like this would make it really >> helpful at times. >> >> Thanks so much, >> >> Patrick >> >> >> > > >
-- <- For Sale! ->

Rasmus Lerdorf

23 years ago
That would require a different ini setting for each virtual server and thus could be a lot more work than just hacking the code. On Sat, 24 May 2003, Jani Taskinen wrote:

Jani Taskinen

23 years ago
Oh well, just thought about more general solution. :) Someone might want to add some other headers too. --Jani On Fri, 23 May 2003, Rasmus Lerdorf wrote:
>That would require a different ini setting for each virtual server and >thus could be a lot more work than just hacking the code. > >On Sat, 24 May 2003, Jani Taskinen wrote: > >> >> Maybe a php.ini option would be best for this? >> Like mail.extra_headers or something alike..? >> ie. that would add the specified headers to every >> mail sent with mail(). >> >> --Jani >> >> >> On Fri, 23 May 2003, Rasmus Lerdorf wrote: >> >> >To access $_SERVER['SERVER_NAME'] from C you would do: >> > >> >zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name)==FAILURE) >> > >> >But, if variables_order doesn't include "S" it isn't going to be there. >> >You are probably better off getting it directly from the server instead of >> >from the PHP symbol table. You can call php_apache_getenv() directly, or >> >to be more correct and portable to other SAPI's you would call >> >sapi_module.getenv(). >> > >> >-Rasmus >> > >> > >> >On Fri, 23 May 2003, Patrick Gibson wrote: >> > >> >> I'd like modify the PHP mail() function to add the $_SERVER['SERVER_NAME'] >> >> into the header if it's available. It would be equivalent to adding a line >> >> into the headers argument from the PHP end that would be like: >> >> >> >> if ($_SERVER['SERVER_NAME']) >> >> { >> >> $headers .= '\nX-Originated-From: www.mywebsite.com'; >> >> } >> >> >> >> I see exactly in ext/standard/mail.c where I need to add this, but my >> >> problem is I'm not sure how to gain access to the $_SERVER super global >> >> array from the C API. >> >> >> >> Can anyone point me in the right direction? I don't see anything in the API >> >> docs that explains this, nor can I think of any PHP function that does >> >> something like this for a reference (except phpinfo(), but the code is >> >> unclear to me). >> >> >> >> I run a hosting company, and if any of our customers abuses this function, I >> >> want to be able to know from which website the mail originated. When there >> >> are hundreds of virtual hosts, something like this would make it really >> >> helpful at times. >> >> >> >> Thanks so much, >> >> >> >> Patrick >> >> >> >> >> >> >> > >> > >> > >> >> > > >
-- <- For Sale! ->

Rasmus Lerdorf

23 years ago
I am not saying that is a bad idea, just that in this case what he wants to add is not just a static string, but the current server name. If we could do variable expansion at runtime from ini directives then this would fit perfectly. -Rasmus On Sat, 24 May 2003, Jani Taskinen wrote:

Sara Golemon

23 years ago
I recall this conversation comming up a month or two ago, this exact usage in fact... The best solution (albiet an ugly one) was to use zend_eval_str() to "evaluate" an interpolated string: if (zend_eval_str("\"{$_SERVER['SERVER_NAME']}\"", &tmpzval, "server_name" TSRMLS_CC) == SUCCESS) { foo = Z_STRVAL(tmpzval); } else { foo = NULL; } Or something close to that, I havn't had cause to use zend_eval_str so I'm not sure about the exact code needed... "Rasmus Lerdorf" <rasmus@lerdorf.com> wrote in message news:Pine.LNX.4.44.0305231622560.1158-100000@thinkpad.lerdorf.com...
> I am not saying that is a bad idea, just that in this case what he wants > to add is not just a static string, but the current server name. If we > could do variable expansion at runtime from ini directives then this would > fit perfectly. > > -Rasmus > > On Sat, 24 May 2003, Jani Taskinen wrote: > > > > > Oh well, just thought about more general solution. :) > > Someone might want to add some other headers too. > > > > --Jani > > > > > > On Fri, 23 May 2003, Rasmus Lerdorf wrote: > > > > >That would require a different ini setting for each virtual server and > > >thus could be a lot more work than just hacking the code. > > > > > >On Sat, 24 May 2003, Jani Taskinen wrote: > > > > > >> > > >> Maybe a php.ini option would be best for this? > > >> Like mail.extra_headers or something alike..? > > >> ie. that would add the specified headers to every > > >> mail sent with mail(). > > >> > > >> --Jani > > >> > > >> > > >> On Fri, 23 May 2003, Rasmus Lerdorf wrote: > > >> > > >> >To access $_SERVER['SERVER_NAME'] from C you would do: > > >> > > > >> >zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht,
"SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name)==FAILURE)
> > >> > > > >> >But, if variables_order doesn't include "S" it isn't going to be
there.
> > >> >You are probably better off getting it directly from the server
instead of
> > >> >from the PHP symbol table. You can call php_apache_getenv()
directly, or
> > >> >to be more correct and portable to other SAPI's you would call > > >> >sapi_module.getenv(). > > >> > > > >> >-Rasmus > > >> > > > >> > > > >> >On Fri, 23 May 2003, Patrick Gibson wrote: > > >> > > > >> >> I'd like modify the PHP mail() function to add the
$_SERVER['SERVER_NAME']
> > >> >> into the header if it's available. It would be equivalent to
adding a line
> > >> >> into the headers argument from the PHP end that would be like: > > >> >> > > >> >> if ($_SERVER['SERVER_NAME']) > > >> >> { > > >> >> $headers .= '\nX-Originated-From: www.mywebsite.com'; > > >> >> } > > >> >> > > >> >> I see exactly in ext/standard/mail.c where I need to add this, but
my
> > >> >> problem is I'm not sure how to gain access to the $_SERVER super
global
> > >> >> array from the C API. > > >> >> > > >> >> Can anyone point me in the right direction? I don't see anything
in the API
> > >> >> docs that explains this, nor can I think of any PHP function that
does
> > >> >> something like this for a reference (except phpinfo(), but the
code is
> > >> >> unclear to me). > > >> >> > > >> >> I run a hosting company, and if any of our customers abuses this
function, I
> > >> >> want to be able to know from which website the mail originated.
When there
> > >> >> are hundreds of virtual hosts, something like this would make it
really

Sara Golemon

23 years ago
> I recall this conversation comming up a month or two ago, this exact usage > in fact... > > The best solution (albiet an ugly one) was to use zend_eval_str() to > "evaluate" an interpolated string: >
Erm... I should mention that the context was using a value from an ini option containing general headers (of which server name could be one), which is why evaling an interpolated string was used rather than searching the hash and/or examining the environment as Rasmus already described. -Sara

John Coggeshall

23 years ago
On Fri, 2003-05-23 at 19:24, Rasmus Lerdorf wrote:
> I am not saying that is a bad idea, just that in this case what he wants > to add is not just a static string, but the current server name. If we > could do variable expansion at runtime from ini directives then this would > fit perfectly.
Wouldn't variable expansion @ runtime be a security issue? Besides, couldn't ini_set() do that trick anyway? John
-- -~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~- John Coggeshall john at coggeshall dot org http://www.coggeshall.org/ -~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-

Patrick Gibson

23 years ago
Hi Rasmus, I'm having a (likely) small problem here. I just preface this problem with the fact that I do not have a lot of C experience (which is the cause of my problem) -- most of my experiences are in Java, PHP and the like. I have added the following into php_mail() in mail.c: zval *server_name; <snip, snip...> fprintf(sendmail, "To: %s\n", to); fprintf(sendmail, "Subject: %s\n", subject); zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name); if (server_name != NULL) { fprintf(sendmail, "X-Site-Origin: %s\n", server_name); } The problem I'm not sure how to declare server_name because I'm not really clear on what zend_hash_find() is expecting, and then if it will be compatible with the fprintf() statement. I've tried a few different things with the server_name declaration, but so far I haven't had any luck -- server_name always comes out blank. I guess I'm used to online API documentation that outlines all the functions, etc. I haven't been able to find anything yet with the Zend API that provides a complete list what everything does. I also tried using php_apache_getenv() and sapi_module.getenv(), but I am unclear of what I need to #include inside mail.c to get these to work. If I can just get past this hurdle, I think I will start understanding things much better. I'm really eager to learn as much C as possible, as I see it opening many doors for me, but I'm finding things to be very different from what I'm used to. If anyone has any recommendations on books for a good introduction to C, perhaps with some Unix focus, I'd be very happy to hear them. Thanks, Patrick On 5/23/03 13:30, Rasmus Lerdorf wrote:

Unnamed Person

23 years ago
"Patrick Gibson" <php.dev@patrickg.com> a écrit dans le message news: BAF555C5.C868%php.dev@patrickg.com...
> Hi Rasmus, I'm having a (likely) small problem here. I just preface this > problem with the fact that I do not have a lot of C experience (which is
the
> cause of my problem) -- most of my experiences are in Java, PHP and the > like. > > I have added the following into php_mail() in mail.c: > > zval *server_name; > > <snip, snip...> > > fprintf(sendmail, "To: %s\n", to); > fprintf(sendmail, "Subject: %s\n", subject);
Hey, fprintf is not strcat. You're just overwriting sendmail with all these fprints. Use strcat.
> > zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, > "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name); > > if (server_name != NULL) > { > fprintf(sendmail, "X-Site-Origin: %s\n", server_name);
You prolly need a convert_to_string_ex(server_name) before using it in the

Derick Rethans

23 years ago
On Sun, 25 May 2003 nicos@php.net wrote:
> "Patrick Gibson" <php.dev@patrickg.com> a écrit dans le message news: > BAF555C5.C868%php.dev@patrickg.com... > > Hi Rasmus, I'm having a (likely) small problem here. I just preface this > > problem with the fact that I do not have a lot of C experience (which is > the > > cause of my problem) -- most of my experiences are in Java, PHP and the > > like. > > > > I have added the following into php_mail() in mail.c: > > > > zval *server_name; > > > > <snip, snip...> > > > > fprintf(sendmail, "To: %s\n", to); > > fprintf(sendmail, "Subject: %s\n", subject); > > Hey, fprintf is not strcat. You're just overwriting sendmail with all these > fprints. Use strcat.
What the hell are you talking about? sendmail is just a filepointer here. Derick
-- "my other box is your windows PC" ------------------------------------------------------------------------- Derick Rethans http://derickrethans.nl/ International PHP Magazine http://php-mag.net/ -------------------------------------------------------------------------

Unnamed Person

23 years ago
"Patrick Gibson" <php.dev@patrickg.com> a écrit dans le message news: BAF555C5.C868%php.dev@patrickg.com...
> Hi Rasmus, I'm having a (likely) small problem here. I just preface this > problem with the fact that I do not have a lot of C experience (which is
the
> cause of my problem) -- most of my experiences are in Java, PHP and the > like. > > I have added the following into php_mail() in mail.c: > > zval *server_name; > > <snip, snip...> > > fprintf(sendmail, "To: %s\n", to); > fprintf(sendmail, "Subject: %s\n", subject);
Hey, fprintf is not strcat. You're just overwriting sendmail with all these fprints. Use strcat.
> > zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, > "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name); > > if (server_name != NULL) > { > fprintf(sendmail, "X-Site-Origin: %s\n", server_name);
You prolly need a convert_to_string_ex(server_name) before using it in the fprintf statement.
> } > > The problem I'm not sure how to declare server_name because I'm not really > clear on what zend_hash_find() is expecting, and then if it will be > compatible with the fprintf() statement. I've tried a few different things > with the server_name declaration, but so far I haven't had any luck -- > server_name always comes out blank. > > I guess I'm used to online API documentation that outlines all the > functions, etc. I haven't been able to find anything yet with the Zend API > that provides a complete list what everything does. > > I also tried using php_apache_getenv() and sapi_module.getenv(), but I am > unclear of what I need to #include inside mail.c to get these to work. If
I
> can just get past this hurdle, I think I will start understanding things > much better. I'm really eager to learn as much C as possible, as I see it > opening many doors for me, but I'm finding things to be very different
from
> what I'm used to. If anyone has any recommendations on books for a good > introduction to C, perhaps with some Unix focus, I'd be very happy to hear > them. > > Thanks, > > Patrick
Thank you, nicos.
> > > On 5/23/03 13:30, Rasmus Lerdorf wrote: > > > To access $_SERVER['SERVER_NAME'] from C you would do: > > > > zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht,
"SERVER_NAME",
> > sizeof("SERVER_NAME"), (void **) &server_name)==FAILURE) > > > > But, if variables_order doesn't include "S" it isn't going to be there. > > You are probably better off getting it directly from the server instead
of
> > from the PHP symbol table. You can call php_apache_getenv() directly,
or
> > to be more correct and portable to other SAPI's you would call > > sapi_module.getenv(). > > > > -Rasmus > > > > > > On Fri, 23 May 2003, Patrick Gibson wrote: > > > >> I'd like modify the PHP mail() function to add the
$_SERVER['SERVER_NAME']
> >> into the header if it's available. It would be equivalent to adding a
line
> >> into the headers argument from the PHP end that would be like: > >> > >> if ($_SERVER['SERVER_NAME']) > >> { > >> $headers .= '\nX-Originated-From: www.mywebsite.com'; > >> } > >> > >> I see exactly in ext/standard/mail.c where I need to add this, but my > >> problem is I'm not sure how to gain access to the $_SERVER super global > >> array from the C API. > >> > >> Can anyone point me in the right direction? I don't see anything in the
API
> >> docs that explains this, nor can I think of any PHP function that does > >> something like this for a reference (except phpinfo(), but the code is > >> unclear to me). > >> > >> I run a hosting company, and if any of our customers abuses this
function, I
> >> want to be able to know from which website the mail originated. When
there

Unnamed Person

23 years ago
"Patrick Gibson" <php.dev@patrickg.com> a écrit dans le message news: BAF555C5.C868%php.dev@patrickg.com...
> Hi Rasmus, I'm having a (likely) small problem here. I just preface this > problem with the fact that I do not have a lot of C experience (which is
the
> cause of my problem) -- most of my experiences are in Java, PHP and the > like. > > I have added the following into php_mail() in mail.c: > > zval *server_name; > > <snip, snip...> > > fprintf(sendmail, "To: %s\n", to); > fprintf(sendmail, "Subject: %s\n", subject);
Hey, fprintf is not strcat. You're just overwriting sendmail with all these fprints. Use strcat.
> > zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, > "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name); > > if (server_name != NULL) > { > fprintf(sendmail, "X-Site-Origin: %s\n", server_name);
You prolly need a convert_to_string_ex(server_name) before using it in the fprintf statement.
> } > > The problem I'm not sure how to declare server_name because I'm not really > clear on what zend_hash_find() is expecting, and then if it will be > compatible with the fprintf() statement. I've tried a few different things > with the server_name declaration, but so far I haven't had any luck -- > server_name always comes out blank. > > I guess I'm used to online API documentation that outlines all the > functions, etc. I haven't been able to find anything yet with the Zend API > that provides a complete list what everything does. > > I also tried using php_apache_getenv() and sapi_module.getenv(), but I am > unclear of what I need to #include inside mail.c to get these to work. If
I
> can just get past this hurdle, I think I will start understanding things > much better. I'm really eager to learn as much C as possible, as I see it > opening many doors for me, but I'm finding things to be very different
from
> what I'm used to. If anyone has any recommendations on books for a good > introduction to C, perhaps with some Unix focus, I'd be very happy to hear > them. > > Thanks, > > Patrick
Thank you, nicos.
> > > On 5/23/03 13:30, Rasmus Lerdorf wrote: > > > To access $_SERVER['SERVER_NAME'] from C you would do: > > > > zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht,
"SERVER_NAME",
> > sizeof("SERVER_NAME"), (void **) &server_name)==FAILURE) > > > > But, if variables_order doesn't include "S" it isn't going to be there. > > You are probably better off getting it directly from the server instead
of
> > from the PHP symbol table. You can call php_apache_getenv() directly,
or
> > to be more correct and portable to other SAPI's you would call > > sapi_module.getenv(). > > > > -Rasmus > > > > > > On Fri, 23 May 2003, Patrick Gibson wrote: > > > >> I'd like modify the PHP mail() function to add the
$_SERVER['SERVER_NAME']
> >> into the header if it's available. It would be equivalent to adding a
line
> >> into the headers argument from the PHP end that would be like: > >> > >> if ($_SERVER['SERVER_NAME']) > >> { > >> $headers .= '\nX-Originated-From: www.mywebsite.com'; > >> } > >> > >> I see exactly in ext/standard/mail.c where I need to add this, but my > >> problem is I'm not sure how to gain access to the $_SERVER super global > >> array from the C API. > >> > >> Can anyone point me in the right direction? I don't see anything in the
API
> >> docs that explains this, nor can I think of any PHP function that does > >> something like this for a reference (except phpinfo(), but the code is > >> unclear to me). > >> > >> I run a hosting company, and if any of our customers abuses this
function, I
> >> want to be able to know from which website the mail originated. When
there

Unnamed Person

23 years ago
"Patrick Gibson" <php.dev@patrickg.com> a écrit dans le message news: BAF555C5.C868%php.dev@patrickg.com...
> Hi Rasmus, I'm having a (likely) small problem here. I just preface this > problem with the fact that I do not have a lot of C experience (which is
the
> cause of my problem) -- most of my experiences are in Java, PHP and the > like. > > I have added the following into php_mail() in mail.c: > > zval *server_name; > > <snip, snip...> > > fprintf(sendmail, "To: %s\n", to); > fprintf(sendmail, "Subject: %s\n", subject); > > zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, > "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name); > > if (server_name != NULL) > { > fprintf(sendmail, "X-Site-Origin: %s\n", server_name); > } > > The problem I'm not sure how to declare server_name because I'm not really > clear on what zend_hash_find() is expecting, and then if it will be > compatible with the fprintf() statement. I've tried a few different things > with the server_name declaration, but so far I haven't had any luck -- > server_name always comes out blank.
Just to let you know the proto of zend_hash_find: ZEND_API int zend_hash_find(HashTable *ht, char *arKey, uint nKeyLength, void **pData);
> > I guess I'm used to online API documentation that outlines all the > functions, etc. I haven't been able to find anything yet with the Zend API > that provides a complete list what everything does. > > I also tried using php_apache_getenv() and sapi_module.getenv(), but I am > unclear of what I need to #include inside mail.c to get these to work. If
I
> can just get past this hurdle, I think I will start understanding things > much better. I'm really eager to learn as much C as possible, as I see it > opening many doors for me, but I'm finding things to be very different
from
> what I'm used to. If anyone has any recommendations on books for a good > introduction to C, perhaps with some Unix focus, I'd be very happy to hear > them. > > Thanks, > > Patrick > > > On 5/23/03 13:30, Rasmus Lerdorf wrote: > > > To access $_SERVER['SERVER_NAME'] from C you would do: > > > > zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht,
"SERVER_NAME",

Unnamed Person

23 years ago
"Patrick Gibson" <php.dev@patrickg.com> a écrit dans le message news: BAF555C5.C868%php.dev@patrickg.com...
> Hi Rasmus, I'm having a (likely) small problem here. I just preface this > problem with the fact that I do not have a lot of C experience (which is
the
> cause of my problem) -- most of my experiences are in Java, PHP and the > like. > > I have added the following into php_mail() in mail.c: > > zval *server_name; > > <snip, snip...> > > fprintf(sendmail, "To: %s\n", to); > fprintf(sendmail, "Subject: %s\n", subject); > > zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, > "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name); > > if (server_name != NULL) > { > fprintf(sendmail, "X-Site-Origin: %s\n", server_name); > } > > The problem I'm not sure how to declare server_name because I'm not really > clear on what zend_hash_find() is expecting, and then if it will be > compatible with the fprintf() statement. I've tried a few different things > with the server_name declaration, but so far I haven't had any luck -- > server_name always comes out blank.
Just to let you know the proto of zend_hash_find: ZEND_API int zend_hash_find(HashTable *ht, char *arKey, uint nKeyLength, void **pData);
> > I guess I'm used to online API documentation that outlines all the > functions, etc. I haven't been able to find anything yet with the Zend API > that provides a complete list what everything does. > > I also tried using php_apache_getenv() and sapi_module.getenv(), but I am > unclear of what I need to #include inside mail.c to get these to work. If
I
> can just get past this hurdle, I think I will start understanding things > much better. I'm really eager to learn as much C as possible, as I see it > opening many doors for me, but I'm finding things to be very different
from
> what I'm used to. If anyone has any recommendations on books for a good > introduction to C, perhaps with some Unix focus, I'd be very happy to hear > them. > > Thanks, > > Patrick > > > On 5/23/03 13:30, Rasmus Lerdorf wrote: > > > To access $_SERVER['SERVER_NAME'] from C you would do: > > > > zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht,
"SERVER_NAME",
> > sizeof("SERVER_NAME"), (void **) &server_name)==FAILURE) > > > > But, if variables_order doesn't include "S" it isn't going to be there. > > You are probably better off getting it directly from the server instead
of
> > from the PHP symbol table. You can call php_apache_getenv() directly,
or
> > to be more correct and portable to other SAPI's you would call > > sapi_module.getenv(). > > > > -Rasmus > > > > > > On Fri, 23 May 2003, Patrick Gibson wrote: > > > >> I'd like modify the PHP mail() function to add the
$_SERVER['SERVER_NAME']
> >> into the header if it's available. It would be equivalent to adding a
line
> >> into the headers argument from the PHP end that would be like: > >> > >> if ($_SERVER['SERVER_NAME']) > >> { > >> $headers .= '\nX-Originated-From: www.mywebsite.com'; > >> } > >> > >> I see exactly in ext/standard/mail.c where I need to add this, but my > >> problem is I'm not sure how to gain access to the $_SERVER super global > >> array from the C API. > >> > >> Can anyone point me in the right direction? I don't see anything in the
API
> >> docs that explains this, nor can I think of any PHP function that does > >> something like this for a reference (except phpinfo(), but the code is > >> unclear to me). > >> > >> I run a hosting company, and if any of our customers abuses this
function, I
> >> want to be able to know from which website the mail originated. When
there

Unnamed Person

23 years ago
"Patrick Gibson" <php.dev@patrickg.com> a écrit dans le message news: BAF555C5.C868%php.dev@patrickg.com...
> Hi Rasmus, I'm having a (likely) small problem here. I just preface this > problem with the fact that I do not have a lot of C experience (which is
the

Unnamed Person

23 years ago
Sorry for these mails but it looks because of news.php.net's lag and timeout, outlook sent my mail many times. I'm sorry about this. Regards. M.CHAILLAN Nicolas nicos@php.net www.WorldAKT.com Hébergement de sites internets.