[PHP] Re: execute a script on access to a directory

2001-09-07 Thread Doug Granzow

You can make "go" the name of your PHP script, then put this in your Apache
config:


ForceType application/x-httpd-php


Now in your "go" script, you have it do whatever you wanted it to do, then
use an include to load the "getit" script.

Here's an except from my equivalent of your 'go' script:

// $PATH_INFO = the rest of the URI after dmb/
// (in "http://www.minarets.net/dmb/trading/toptraders";)

// remove anything other than letters, numbers, dots, underscores,
// and dashes, and put into an array

// for example "trading/toptraders" will be an array consisting
// of "trading" ($args[1]) and "toptraders" ($args[2]).  The / is
discarded.

ereg("(^[-_.\/a-zA-Z0-9]*$)", $PATH_INFO, $arg);

$args = split( "/", $arg[1]);
$file = "include/" . $args[1] . ".inc";
if (file_exists($file)) {
  include "$file";
} else {
  ?>
  404 not found
   wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
>
> I would like to know how i can force a PHP script to be
> executed everytime a certain directory is accessed, for
> example in http://domain.com/go/getit the presence of the
> /go/ directory would force a PHP script to be executed
> prior to any operation.
>
> Do i need to play with rewriting urls in Apache or is
> there any other cleaner method (that would not require
> rewriting URLs) to achieve this? i'd hate to have to
> rewrite URLs...
>
> thanks.
>
> Enrique-
>
>
> _
> Descargue GRATUITAMENTE MSN Explorer en http://explorer.msn.es/intl.asp
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: network connections

2001-09-07 Thread Doug Granzow

If you're talking over a million messages, I think you need a solution that
is designed specifically for handling mail. I would suggest looking into
qmail (www.qmail.org) to replace sendmail on the server in question.  qmail
is much more efficient than sendmail in handling large amounts of mail, and
it won't drag your server down.

I think it's possible that some of your smtp connections are hanging for
some reason or another, and PHP is not timing them out.  10,000 connections
out of 1 million emails means about 1% of your connections are failing in
some way -- not surprising when talking smtp.

If you're talking smtp directly to remote mail server, how are you handling
retries, failed mail, etc.?  Again, I would suggest qmail since it would
take care of all of that for you, instead of you having to reinvent the
wheel.  I have a script which sends out about 30,000 emails once a month,
through qmail, and it is set up so that qmail automatically routes any
bounces back to another script where I can update my database to reflect
which users' mail is bouncing.

Doug Granzow
[EMAIL PROTECTED]

"J.R. Lillard" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> i've got a command-line php script that i've been using to deliver large
> amounts of e-mail.  originally it relied on mail() to deliver the
> messages but i could easily overload sendmail and bring the box (redhat
> 7.1) to a crawl.  so i am now using the various network functions to
> speak smtp directly from the script.  i seem to be having a problem with
> an excessive number of tcp connections that eventually brings down the
> machine.
>
> i have attempted a semi-multi-threaded approach by spawning off
> additional copies of the script to deliver more mail simultaneously.  so
> i might have 100 copies of the script running at the same time.  and
> this was after dumping a million messages into my mysql-based mail
> queue.  things may run okay for a few hours...maybe even a day...but
> then doing a netstat shows over 10k tcp connections.  and the only way
> i've found to fix the problem is to reboot the machine.
>
> thinking that i was attempting too many connections at the same time, i
> throttled down the number of threads to 25.  this slowed down my mail
> delivery of course.  and it allowed the machine to stay up longer.  but
> i eventually ran into the same problem after maybe two or three weeks.
> just before it died, i was showing over 30k tcp connections.
>
> are they any known issues in the php networking code that would cause
> this to happen?  as far as i know, i should never have more than 25 tcp
> connections open.  but i'm not sure if they are not being closed
> properly or what.
>
> --
> -jr
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: code troble

2001-09-07 Thread Doug Granzow

You don't have a closing } for function obrada().

When the line number of the parse error is the last line of the file, I've
found it is almost *always* due to a missing brace, paren, or quote
somewhere in the file.

Doug Granzow
[EMAIL PROTECTED]

"Nikola Veber" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi
> I'm having trobles with this code. Can you take a look at it?
> Parse error:  parse error in C:/XITAMI/webpages/index.php on line 34 is
the
> error msg.
>
> thanx
>
> 
> 
> Example 2.01
> 
> 
> 
>  if (emty(provera)) {pokazi();}
> else {obrada();}
> ?>
>  function pokazi() {
> global $PHP_SELF;
> ?>
> 
> 
>   
>  }
> ?>
>  function obrada() {
> global $ime;
> global $vrednost;
> if ($ime == "Nikola" && $vrednost == 100){
> echo "Zdravo $ime ";
> echo "Iznos na Vasem racunu je $vrednost dolara";
> }
> ?>
> 
> 
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: mysql_fetch_array

2001-09-07 Thread Doug Granzow


<[EMAIL PROTECTED]> wrote in message
001001c136af$7c649db0$[EMAIL PROTECTED]">news:001001c136af$7c649db0$[EMAIL PROTECTED]...
>Can someone tell me what i'm doing wrong here?
>
>while($myrow<>mysql_fetch_array($result2))
>

I would guess that you actually want that line to read:

while($myrow=mysql_fetch_array($result2))


Doug Granzow
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: mysql timestamp field

2001-09-07 Thread Doug Granzow

The timestamp data type is a special MySQL type that automatically updates
whenever you add or update a row in a table.

If you want timestamp to work when you add a row but not when you update a
row, you need to write your update statements like this:

UPDATE tbl_name SET vartochange="newvalue", t_stamp=t_stamp WHERE ...

The "t_stamp=t_stamp" will cause t_stamp to not change to now().

Doug Granzow
[EMAIL PROTECTED]



"Mesut Tunga" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi all,
>
> I need an update on my table. but I have a timestamp field called
> t_stamp. When I update a field other than t_stamp field, t_stamp field
> also updates to now(). I need it not to update and saves its value.
>
> How should I do this?
>
> Regards
> Mesut Tunga...
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Problems with Sessions?

2001-09-07 Thread Doug Granzow

On the first page of a session, PHP attempts to set a PHPSESSID cookie.  It
won't get that cookie back until you reload the page or load another page,
so it has no way of knowing on the first page whether or not the browser
accepted the cookie.  So, it adds the PHPSESSID string to all of your local
links in order to maintain the session.  When you load another page during
the same session and your browser sends the cookie back, PHP sees that
cookies are working, so it no longer modifies your links.

If you want to disable this behavior, you can add this line to your php.ini
file:

session.use_trans_sid = 0

This will cause sessions to not work on browsers where cookies are disabled.

Doug Granzow
[EMAIL PROTECTED]

"Tim" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> When I first browse to a site on my LAN, I get links with URLs that look
> like this:
>
> chat/?PHPSESSID=f3d149f79f5196bd709fb3c256dbb3d8
>
> after a refresh, the whoe PHPSESSID goes away.
>
> Wondered if there was some setting in php.ini that I've overlooked?
>
> I'm running PHP4 with Apache on an Unstable Debian box.
>
> Any help would be appreciated :-)
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How to pass variables to php functions from url's?

2001-09-07 Thread Doug Granzow

> > > Let's assume we have a server called www.test.com
> > > When a user access http://www.test.com/path/username,
> > > I want a php script to execute, as if the url entered was
> > > http://www.test.com/path.php?value=username.
> > >
> > > I'm running PHP 4.0.6 on Apache 1.3.20.

Step 1:  Rename "path.php" to "path"

Step 2:  Add this to your Apache conf file:


ForceType application/x-httpd-php


This causes "path" to be executed as a PHP script even though it does not
have a .php extension.

Step 3:  Add this to your "path" php script:

// $PATH_INFO = the rest of the URI after dmb/

// remove anything other than letters, numbers, dots, underscores,
// and dashes, and put into an array

// for example "trading/toptraders" will be an array consisting
// of "trading" ($args[1]) and "toptraders" ($args[2]).  The / is
discarded.

ereg("(^[-_.\/a-zA-Z0-9]*$)", $PATH_INFO, $arg);
$args = split( "/", $arg[1]);


Hope this helps.

Doug Granzow
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]