php-general Digest 25 Apr 2004 17:27:52 -0000 Issue 2726

Topics (messages 184546 through 184574):

SSI and query string variables to PHP
        184546 by: Tim Traver
        184547 by: Tim Traver
        184552 by: Evan Nemerson
        184554 by: Burhan Khalid
        184573 by: Tim Traver

Re: formatting a string
        184548 by: Tom Rogers

OR
        184549 by: Aidan Lister
        184550 by: daniel.electroteque.org
        184551 by: Evan Nemerson
        184553 by: Rainer Müller
        184559 by: -{ Rene Brehmer }-
        184572 by: Red Wingate

Re: Fetching XML for parsing
        184555 by: Burhan Khalid
        184558 by: Patagonia Hosting Development Group

Re: SMTP and GroupWise
        184556 by: Burhan Khalid

PHP /MySQL problem on SMP machines
        184557 by: Lasse Laursen
        184568 by: Curt Zirzow

adult content censoring
        184560 by: Andy B
        184561 by: Richard Davey
        184565 by: Richard A. DeVenezia
        184566 by: Curt Zirzow
        184570 by: Richard Davey
        184571 by: Curt Zirzow

Re: OK SQL experts...
        184562 by: Daniel Clark
        184563 by: Daniel Clark

Shared session ? (frames application)
        184564 by: Richard A. DeVenezia
        184567 by: Marek Kilimajer
        184574 by: Torsten Roehr

Re: Call to external function
        184569 by: Marek Kilimajer

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 --- Hi all,

ok, this may be a dumb question, but I have a page that has server side includes that include a php script like this :

<!--#include virtual="schedule.php" -->

works fine, except the script doesn't appear to receive any of the query string information if that page has a query string on it...

an example would be something like this :

http://www.domain.com/index.shtml?myvariable=1

the php script should get $_REQUEST['myvariable']==1, but instead does not get any of the query information.

The $_SERVER global gets the unescaped query string, but has no value for just the query string...

any way around this without making the whole page a php script ?

Thanks,

Tim
--- End Message ---
--- Begin Message --- Hi all,

ok, this may be a dumb question, but I have a page that has server side includes that include a php script like this :

<!--#include virtual="schedule.php" -->

works fine, except the script doesn't appear to receive any of the query string information if that page has a query string on it...

an example would be something like this :

http://www.domain.com/index.shtml?myvariable=1

the php script should get $_REQUEST['myvariable']==1, but instead does not get any of the query information.

The $_SERVER global gets the unescaped query string, but has no value for just the query string...

any way around this without making the whole page a php script ?

Thanks,

Tim
--- End Message ---
--- Begin Message ---
On Saturday 24 April 2004 10:29 pm, Tim Traver wrote:
> Hi all,
>
> ok, this may be a dumb question, but I have a page that has server side
> includes that include a php script like this :
>
> <!--#include virtual="schedule.php" -->
>
> works fine, except the script doesn't appear to receive any of the query
> string information if that page has a query string on it...
>
> an example would be something like this :
>
> http://www.domain.com/index.shtml?myvariable=1
>
> the php script should get $_REQUEST['myvariable']==1, but instead does not
> get any of the query information.
>
> The $_SERVER global gets the unescaped query string, but has no value for
> just the query string...

um, huh? you mean it has the query string but it isn't parsed into the proper 
superglobals ($_GET, $_REQUEST)? Not really sure what you're looking for here 
so i'm going to just pretend this paragraph isn't here ;)
>
> any way around this without making the whole page a php script ?

php.net/parse_str
>
> Thanks,
>
> Tim

-- 
Evan Nemerson
[EMAIL PROTECTED]
http://coeusgroup.com/en

--
"The greatest mistake is to imagine that the human being is an autonomous 
individual. The secret freedom which you can supposedly enjoy under a 
despotic government is nonsense, because your thoughts are never entirely 
your own. Philosophers, writers, artists, even scientists, not only need 
encouragement and an audience, they need constant stimulation from other 
people. It is almost impossible to think without talking. If Defoe had really 
lived on a desert island, he could not have written Robinson Crusoe, nor 
would he have wanted to. Take away freedom of speech, and the creative 
faculties dry up."

-George Orwell

--- End Message ---
--- Begin Message --- Tim Traver wrote:
Hi all,

ok, this may be a dumb question, but I have a page that has server side includes that include a php script like this :

Please send a new message if you have a new question, and do not reply to a thread and change the subject. It breaks the conversation flow.


Where is that newbie guide?
--- End Message ---
--- Begin Message --- Yes, I mean that php gets the server information for the request, but it doesn't get the QUERY_STRING variable. But it does get the UNESCAPED_QUERY_STRING variable...wierd, huh ?

It might be that apache isn't sending that variable to php from an included file...not sure...

That's why I'm asking everyone.

Tim.


At 01:22 AM 4/25/2004, Evan Nemerson wrote:
On Saturday 24 April 2004 10:29 pm, Tim Traver wrote:
> Hi all,
>
> ok, this may be a dumb question, but I have a page that has server side
> includes that include a php script like this :
>
> <!--#include virtual="schedule.php" -->
>
> works fine, except the script doesn't appear to receive any of the query
> string information if that page has a query string on it...
>
> an example would be something like this :
>
> http://www.domain.com/index.shtml?myvariable=1
>
> the php script should get $_REQUEST['myvariable']==1, but instead does not
> get any of the query information.
>
> The $_SERVER global gets the unescaped query string, but has no value for
> just the query string...

um, huh? you mean it has the query string but it isn't parsed into the proper
superglobals ($_GET, $_REQUEST)? Not really sure what you're looking for here
so i'm going to just pretend this paragraph isn't here ;)
>
> any way around this without making the whole page a php script ?

php.net/parse_str
>
> Thanks,
>
> Tim

--
Evan Nemerson
[EMAIL PROTECTED]
http://coeusgroup.com/en

--
"The greatest mistake is to imagine that the human being is an autonomous
individual. The secret freedom which you can supposedly enjoy under a
despotic government is nonsense, because your thoughts are never entirely
your own. Philosophers, writers, artists, even scientists, not only need
encouragement and an audience, they need constant stimulation from other
people. It is almost impossible to think without talking. If Defoe had really
lived on a desert island, he could not have written Robinson Crusoe, nor
would he have wanted to. Take away freedom of speech, and the creative
faculties dry up."

-George Orwell

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


SimpleNet's Back !
http://www.simplenet.com

--- End Message ---
--- Begin Message ---
Hi,

Sunday, April 25, 2004, 3:15:25 PM, you wrote:

AB> ok sorry but since i never used preg_* before i dont quite get what some of
AB> this stuff means. i looked at the doc page for it but it doesnt make mention
AB> at all of what \d, \w, \s or any of those things mean... i only assume that
AB> \d means digit and \w or \s means blank space??

AB> anyways to go through the whole example above part by part:
AB> $phone = '1234567890';//understand that
AB> $newphone = preg_replace(//ok now what does this stuff
AB> //mean??
AB> '/(\d{3})(\d{3})(\d)/'
AB> im gathering the line above is the search string (what to look for)? if so i
AB> get from it that it is supposed to look for the first block of 3 digits then
AB> the second block of 3 digits and the other 4 numbers by themself in a sense
AB> seperating the string into 3 different parts: 123 456 7890 and then asigning
AB> like "id numbers to the blocks"
AB> '(\1)\2-\3'
AB> and this one above says put block 1 between (). take block 2 and put a -
AB> after it and leave the other 4 numbers alone to come up with: (123)456-7890
AB> $phone);
AB> the original number to do the replace on of course

AB> let me know if i got that set right

Yes that is exactly what it does .. sorry probably should have
explained it... but at least you read up the function :-)

the () tells preg to store the contents and they get numbered 1 2 3 ..
the \1 with a number below 10 tells it to use what it captured at that
point.

\D btw captures everything that is not a digit so you can use
that to cleanup the user input with $input = preg_replace('/\D/','',$input);

-- 
regards,
Tom

--- End Message ---
--- Begin Message ---
if (cond || cond2)

OR

if (cond OR cond2)


What do you use, and why?

--- End Message ---
--- Begin Message ---
> if (cond || cond2)
>
> OR
>
> if (cond OR cond2)
>
>
> What do you use, and why?
>
> --

|| coz its easier to type ?

--- End Message ---
--- Begin Message ---
On Sunday 25 April 2004 12:14 am, Aidan Lister wrote:
> if (cond || cond2)
>
> OR
>
> if (cond OR cond2)
>
>
> What do you use, and why?

Doesn't matter- personal preference.


-- 
Evan Nemerson
[EMAIL PROTECTED]
http://coeusgroup.com/en

--
"There is a certain right by which we may deprive a man of life, but none by 
which we may deprive him of death."

-Nietzsche

--- End Message ---
--- Begin Message --- Aidan Lister schrieb:
if (cond || cond2)

OR

if (cond OR cond2)


What do you use, and why?

It doesn't matter except you combine it because || has a higher priority as OR.


Rainer
--- End Message ---
--- Begin Message ---
According to historical records, on Sun, 25 Apr 2004 17:14:13 +1000 Aidan
Lister wrote about "[PHP] OR":

>if (cond || cond2)
>
>OR
>
>if (cond OR cond2)
>
>
>What do you use, and why?

I always use ||

basically because to me it's easier to read in more complex statements ...
like this:

    if ((($del_own == 1 && $post_userID == $userID) || $del_other == 1) &&
($postID != $first_postID || $del_thread == 1)) {

I always stick to the symbols ... just easier ...

|| && |! &! 
^ being OR, AND, NOR, and NAND (believe NOR is actually called XOR, can't
remember ...)


Rene
-- 
Rene Brehmer
aka Metalbunny

~ If you don't like what I have to say ... don't read it ~

http://metalbunny.net/
References, tools, and other useful stuff...
Check out the new Metalbunny forums at http://forums.metalbunny.net/

--- End Message ---
--- Begin Message --- BEEP wrong :)

http://www.php.net/manual/en/language.operators.php#language.operators.precedence

therefore:

$a AND $b OR $c AND $d

is not equal

$a AND $b || $c AND $d

but is equal to

$a && $b || $c && $d

-- red

Evan Nemerson wrote:
On Sunday 25 April 2004 12:14 am, Aidan Lister wrote:

if (cond || cond2)

OR

if (cond OR cond2)


What do you use, and why?


Doesn't matter- personal preference.



--- End Message ---
--- Begin Message --- Patagonia Hosting Development Group wrote:

That may be the exact problem. I was not figuring that one out. Thi is my
fopen and XML parser code:

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($uFile,"rb"))) {

Are you sure about rb? Shouldn't that just be r?

--- End Message ---
--- Begin Message ---
I used to have the "r" alone but I thought on trying... and nothing...

"Burhan Khalid" <[EMAIL PROTECTED]> escribió en el mensaje
news:[EMAIL PROTECTED]
> Patagonia Hosting Development Group wrote:
>
> > That may be the exact problem. I was not figuring that one out. Thi is
my
> > fopen and XML parser code:
> >
> > $xml_parser = xml_parser_create();
> > xml_set_element_handler($xml_parser, "startElement", "endElement");
> > xml_set_character_data_handler($xml_parser, "characterData");
> > if (!($fp = fopen($uFile,"rb"))) {
>
> Are you sure about rb? Shouldn't that just be r?

--- End Message ---
--- Begin Message --- Todd Cary wrote:

My client is using GroupWise to relay *without* having relay turned on and it needs/uses an authenication that is different from the regular SMTP. Here is a trace of a message that went through:


[ snipped POP before SMTP authentication ]



Does anyone know of a class that can provide this type of authenication?



I don't know of a class, but phpprojekt 4.1 has this functionality built in. You could look at that code and get some ideas.

--- End Message ---
--- Begin Message ---
Hi all,

We just installed PHP 4.3.6 on FreeBSD 5.2.1 on some SMP machines and we are
experiencing some weird problems.

The PHP processes are running as FastCGI under Zeus with these compile
options:

./configure  --with-curl \
--enable-sockets \
--enable-dbx \
--with-jpeg-dir \
--with-jpeg \
--prefix=/webdisk/local/progs/php/compiled/4.3.6 \
--with-imlib \
--with-mysql \
--with-gd \
--enable-fastcgi \
--with-config-file-path=/webdisk/servers/php \
--with-exec-dir=/webdisk/servers/php/exec-dir \
--enable-memory-limit \
--disable-force-cgi-redirect \
--disable-url-fopen-wrapper \
--enable-track-vars \
--enable-xslt \
--with-xslt-sablot \
--enable-inline-optimization \
--disable-debug \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--with-ttf \
--with-freetype-dir=/usr/local/include/freetype2/ \
--with-zlib-dir=/usr/src/lib/libz/ \
--enable-gd-native-ttf \

The database backend is MySQL 4.0.18 and is run on a seperate dedicated
server.

Last night some problems occured - when we queried the databases for simple
queries that _should_ return some rows (and worked minutes before) the
database simply returned 0 rows. A restart og the mysqld and the php
processes solved the problems but they return at random.

I suspect that it is some weird problem with PHP / MySQL / SMP but I have no
clue what can cause the problem. The old servers we used before the upgrade
are all uni processor machines and we haven't experienced any similar
problems on those machines.

The sysctl for FreeBSD is set to: kern.ipc.shm_use_phys=1 (used on the old
setup as well)

Is there any issues with the mysql library under PHP that can cause the
problems on the server - eg. not thread safe?

I do hope that any of you have some pointers so I can get over this weird
problem.

Thanks in advance.

Regards
--
Lasse Laursen · VP, Hosting Technology · NetGroup A/S
St. Kongensgade 40H · DK-1264 Copenhagen K, Denmark
Phone: +45 3370 1526 · Fax: +45 3313 0066

- Don't be fooled by cheap finnish imitations - BSD is the One True Code

--- End Message ---
--- Begin Message ---
* Thus wrote Lasse Laursen ([EMAIL PROTECTED]):
> Hi all,
> 
> We just installed PHP 4.3.6 on FreeBSD 5.2.1 on some SMP machines and we are
> experiencing some weird problems.
> 
>...
> 
> The database backend is MySQL 4.0.18 and is run on a seperate dedicated
> server.

What mysqlclient is php linked to?
  php -i | grep "Client API"

I would make sure you're using a 4.x version.

> 
> Last night some problems occured - when we queried the databases for simple
> queries that _should_ return some rows (and worked minutes before) the
> database simply returned 0 rows. A restart og the mysqld and the php
> processes solved the problems but they return at random.

A couple things to check:
  - the output of mysql_error(), it usually solves 90% of query
  problems.

  - if myismchk was ran on the table(s) mysql can get confused
    about the indexes (until the table(s) are flushed)


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
hi...

i have to make an adult content censoring system so people cant post "bad"
words on any public viewable posts. i know preg_replace and possibaly
preg_match would be a huge help but im wondering how i would put all the bad
words in a file (textfile) 1 word on a line and have it look through the
file for the words? when it finds a match then it will either replace the
word with * but better yet tell the user that content in the post was
rejected because of bad content and take them back to the form with the
stuff they typed in it...

if there is a better way to do this (i hope sounds like a lot of work)....

--- End Message ---
--- Begin Message ---
Hello Andy,

Sunday, April 25, 2004, 3:22:29 PM, you wrote:

AB> i have to make an adult content censoring system so people cant post "bad"
AB> words on any public viewable posts. i know preg_replace and possibaly
AB> preg_match would be a huge help but im wondering how i would put all the bad
AB> words in a file (textfile) 1 word on a line and have it look through the
AB> file for the words? when it finds a match then it will either replace the
AB> word with * but better yet tell the user that content in the post was
AB> rejected because of bad content and take them back to the form with the
AB> stuff they typed in it...

The way I do it on a piece of forum software I wrote on a VERY popular
web site was as follows:

Create an include file which contains all your badwords in an array,
like:

$badword[] = 'well';
$badword[] = 'you';
$badword[] = 'get';
$badword[] = 'the';
$badword[] = 'idea';

Then I have a simple function as follows:

        function APL_Func_BadWord ($text)
        {
                global $badwords;

                //      This will check our given text against the badword list. It 
does it slightly differently
                //      in that instead of firing up the regular expression engine, we 
use a more simple but just as effective technique:
                
                //      Get the length of the text
                $original_length = strlen($text);
                
                //      Now strip out ANY of the "bad words" using the fast 
str_replace and count the result
                $stripped_length = strlen(str_replace($badwords, '', 
strtolower($text)));

                //      In PHP5 we will use the str_ireplace function instead of 
needing strtolower:
                //      $stripped_length = strlen(str_ireplace($badwords, '', $text));
                
                //      If the two lengths are different, the pos contained a badword 
- simple as that!
                if ($original_length <> $stripped_length)
                {
                        return true;
                }
                else
                {
                        return false;
                }
    }

and that's it - I pass any string I need to this whenever someone
posts a message, subject, etc etc and it hasn't failed me yet :)
(unless the bad word isn't in your list of course!)

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

--- End Message ---
--- Begin Message ---
Richard Davey wrote:
> and that's it - I pass any string I need to this whenever someone
> posts a message, subject, etc etc and it hasn't failed me yet :)
> (unless the bad word isn't in your list of course!)


To guard against 'lame' impressions of words to be filtered, you might also
check all combinations of variations of lettering of each undesired word.
You can do this programmatically without have to list them all.
i.e.
l replaced with digit 1 or any l looking characters with byte code > 128
o replace with digit 0 or any o looking characters with byte code > 128
f replaced with any f looking characters with byte code > 128

Read a spample erectile dysfunction or pain medication mail to get the idea.

Definition: spample - Spam samples; a sampling of spam.

-- 
Richard A. DeVenezia

--- End Message ---
--- Begin Message ---
* Thus wrote Richard Davey ([EMAIL PROTECTED]):
> Hello Andy,
> 
> Sunday, April 25, 2004, 3:22:29 PM, you wrote:
> 
> AB> i have to make an adult content censoring system so people cant post "bad"
> AB> words on any public viewable posts. i know preg_replace and possibaly
> AB> preg_match would be a huge help but im wondering how i would put all the bad
> AB> words in a file (textfile) 1 word on a line and have it look through the
> AB> file for the words? when it finds a match then it will either replace the
> AB> word with * but better yet tell the user that content in the post was
> AB> rejected because of bad content and take them back to the form with the
> AB> stuff they typed in it...
> 
> The way I do it on a piece of forum software I wrote on a VERY popular
> web site was as follows:
> 
> Create an include file which contains all your badwords in an array,
> like:
> 
> $badword[] = 'well';
> $badword[] = 'you';
> $badword[] = 'get';
> $badword[] = 'the';
> $badword[] = 'idea';
> 
> Then I have a simple function as follows:
> 
>         function APL_Func_BadWord ($text)
>         {
>                 global $badwords;
> 
>                 //      This will check our given text against the badword list. It 
> does it slightly differently
>                 //      in that instead of firing up the regular expression engine, 
> we use a more simple but just as effective technique:
                 
One advantage with using preg*, is you can have more flexible
matching  instead of having a real large list of bad words:

$badword[] = '/suck(er|ing|ed)?/i';

Also instead of str_replace scanning the whole string  5 time to
replace the 5 items, its only scanned once, replacing up to five
things.

So depending on  how large your  list of words are and how large
the content is you scanning, preg_*  might be a little more
efficient.

And then there is the possiblity that the users might get smart and
start entering things like:
   s-u-c-k

One way to fix that is to replace all Non-word characters in the
subject string with null:
  preg_replace('/\W/', '')


Of course that wont work if they  use L337 or  html tags.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
Hello Curt,

Sunday, April 25, 2004, 4:28:37 PM, you wrote:

CZ> Also instead of str_replace scanning the whole string  5 time to
CZ> replace the 5 items, its only scanned once, replacing up to five
CZ> things.

My method *did* only scan the string once and str_replace is
definitely faster than preg_replace.

But I agree with the preg use for more complex word catching, but even
using that method you could spend ages building up a definitive
"badwords" array. I guess it depends how anal you want to be ;) (heh)

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

--- End Message ---
--- Begin Message ---
* Thus wrote Richard Davey ([EMAIL PROTECTED]):
> Hello Curt,
> 
> Sunday, April 25, 2004, 4:28:37 PM, you wrote:
> 
> CZ> Also instead of str_replace scanning the whole string  5 time to
> CZ> replace the 5 items, its only scanned once, replacing up to five
> CZ> things.
> 
> My method *did* only scan the string once and str_replace is
> definitely faster than preg_replace.

I was implying that internally php loops through each item in the
array you pass and calls str_replace on the items.  Thats why I
added that it depends on the  number of items and length of the
string your searching.

If you can take 50 element array down to 5, the overhead of preg
wont matter as much.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
I think you want to remove the single quotes around the field names.

SELECT * FROM my_table WHERE (field_1 LIKE '%$keyword%' OR 
field_2 LIKE '%$keyword%' OR field_3 LIKE '%$keyword%') AND 
status = 'active';


>>I STFW and RTFM and I still can't figure out why this returns a 1064 
>>parse error:
>>
>>SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR 
>>'field_2' LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND 
>>'status' = 'active';
>>
>>Anyone? TIA!
>>
>>- B1ff Lamer

--- End Message ---
--- Begin Message ---
The parenthesis are OK.   The query might take a long time to run with 3 LIKE 
statements.


>>Backticks, single quotes, or nothing at all makes no difference. I 
>>believe the parsing error is due to my parentheses or AND/OR structure. 
>>Any thoughts on that?
>>
>>
>>
>>On Apr 23, 2004, at 8:32 AM, John W. Holmes wrote:
>>
>>> From: "Brian Dunning" <[EMAIL PROTECTED]>
>>>
>>>> I STFW and RTFM and I still can't figure out why this returns a 1064
>>>> parse error:
>>>>
>>>> SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
>>>> 'field_2' LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND
>>>> 'status' = 'active';



--- End Message ---
--- Begin Message ---
I am wondering if it is possible to let two or more scripts share a common
session id ?
I am guessing not, but would like to be proved wrong.

This is the situation cut down about as small as I could make it.
Five files: index.php, login-form.inc, frames.inc, left.php, main.php

index.php
-----
<?
session_name('cesh');
session_start();
$function = $_POST['function'];
if (!isset($function) || $function='') {
  include "login-form.inc"; die;
}

//test, user always valid
function validuser () { return true; }

if ($function == 'login') {
  if (!validuser($_POST['user'], $_POST['pass'])) {
    include "login-form.inc"; die;
  }
}
$_SESSION['user'] = $user;
$_SESSION['foo'] = 'bar';
include "frames.inc";
?>
-----

login-form.inc
-----
<html><body>
<form method=POST>
user <input type=text name=user><br>
pass <input type=text name=pass><br>
<input type=submit value=Login>
<input type=hidden name=function value=login>
</body></html>
<? die; ?>
-----

frames.inc
-----
<?
// get var used to pass session id to left and main scripts
$sid = SID;
$src = <<<EOF
<frameset cols="350,*" rows="*" frameborder="1">
    <frame src="left.php?$sid" name="left" frameborder="1">
    <frame src="main.php?$sid" name="main" frameborder="1">
    <noframes>
        <body bgcolor="#FFFFFF">
            <p>phpMyAdmin is more friendly with a <b>frames-capable</b>
browser.</p>
        </body>
    </noframes>
</frameset>
EOF;

$src = str_replace("\n", "", split ( "\n", $src ));
?>
<html>
<script type="text/javascript">
<!--
<?
foreach ($src as $line)
{ echo "document.writeln('${line}');\n"; }
?>
//-->
</script>
<noscript>
<?
foreach ($src as $line)
{ echo ${line} . "\n"; }
?>
</noscript>
</html>
-----

left.php
-----
<html><body>
Left<br>
Is it possible to access (read/write/set/unset) the variables of session
<?=$_GET['cesh']?><br> ?
</body></html>
-----

main.php
-----
<html><body>
Main<br>
Is it possible to access (read/write/set/unset) the variables of session
<?=$_GET['cesh']?><br> ?
</body></html>
-----

-- 
Richard A. DeVenezia

--- End Message ---
--- Begin Message --- Richard A. DeVenezia wrote:
I am wondering if it is possible to let two or more scripts share a common
session id ?
I am guessing not, but would like to be proved wrong.

I might get you wrong, but unless you take some precausions all scripts on a single domain share common session id.

--- End Message ---
--- Begin Message ---
This is possible without problem. Just start your session in every script
and forward the session id from your frameset (which is probably the first
page to be called by the user) to each frame:

frames.inc
----------
<?
// start session here
// ...

<frameset cols="350,*" rows="*" frameborder="1">
    <frame src="left.php?<?= SID; ?>" name="left" frameborder="1">
    <frame src="main.php?<?= SID; ?>" name="main" frameborder="1">
</frameset>
?>

Make sure to put the session start code at the top of EVERY page.

Regards, Torsten


"Richard A. Devenezia" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am wondering if it is possible to let two or more scripts share a common
> session id ?
> I am guessing not, but would like to be proved wrong.
>
> This is the situation cut down about as small as I could make it.
> Five files: index.php, login-form.inc, frames.inc, left.php, main.php
>
> index.php
> -----
> <?
> session_name('cesh');
> session_start();
> $function = $_POST['function'];
> if (!isset($function) || $function='') {
>   include "login-form.inc"; die;
> }
>
> file://test, user always valid
> function validuser () { return true; }
>
> if ($function == 'login') {
>   if (!validuser($_POST['user'], $_POST['pass'])) {
>     include "login-form.inc"; die;
>   }
> }
> $_SESSION['user'] = $user;
> $_SESSION['foo'] = 'bar';
> include "frames.inc";
> ?>
> -----
>
> login-form.inc
> -----
> <html><body>
> <form method=POST>
> user <input type=text name=user><br>
> pass <input type=text name=pass><br>
> <input type=submit value=Login>
> <input type=hidden name=function value=login>
> </body></html>
> <? die; ?>
> -----
>
> frames.inc
> -----
> <?
> // get var used to pass session id to left and main scripts
> $sid = SID;
> $src = <<<EOF
> <frameset cols="350,*" rows="*" frameborder="1">
>     <frame src="left.php?$sid" name="left" frameborder="1">
>     <frame src="main.php?$sid" name="main" frameborder="1">
>     <noframes>
>         <body bgcolor="#FFFFFF">
>             <p>phpMyAdmin is more friendly with a <b>frames-capable</b>
> browser.</p>
>         </body>
>     </noframes>
> </frameset>
> EOF;
>
> $src = str_replace("\n", "", split ( "\n", $src ));
> ?>
> <html>
> <script type="text/javascript">
> <!--
> <?
> foreach ($src as $line)
> { echo "document.writeln('${line}');\n"; }
> ?>
> file://-->
> </script>
> <noscript>
> <?
> foreach ($src as $line)
> { echo ${line} . "\n"; }
> ?>
> </noscript>
> </html>
> -----
>
> left.php
> -----
> <html><body>
> Left<br>
> Is it possible to access (read/write/set/unset) the variables of session
> <?=$_GET['cesh']?><br> ?
> </body></html>
> -----
>
> main.php
> -----
> <html><body>
> Main<br>
> Is it possible to access (read/write/set/unset) the variables of session
> <?=$_GET['cesh']?><br> ?
> </body></html>
> -----
>
> --
> Richard A. DeVenezia

--- End Message ---
--- Begin Message --- Jeff McKeon wrote:
No... PHP and JavaScript are executing at different time and at different place. Besides, they are executed by different programs.

Are you trying to measure execution time of a query??

Look at:
http://www.php.net/microtime


No, I'm trying to get a little animation on the left frame to start when a query begins a pull (when the page begins to load) and then stop the animation when the page and data are fully loaded.


I suppose that the action is triggered by a link. Then you can put the 'start' javascript code in onclick event of that link. The 'stop' code would go into onload event of the document body tag.

--- End Message ---

Reply via email to