OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 14 Nov 2005 21:45:42 -0000 Issue 3794

php-general-digest-helplists.php.net
Date: Mon Nov 14 2005 - 15:45:42 CST


php-general Digest 14 Nov 2005 21:45:42 -0000 Issue 3794

Topics (messages 225725 through 225784):

Re: file get contents
        225725 by: Richard Heyes
        225726 by: Richard Davey
        225729 by: Ross

Re: sending/notifying a server process
        225727 by: tony yau

PHP / MySQL Authentication class
        225728 by: Alan Milnes
        225730 by: Jochem Maas

Changes from 5.0.4 => 5.0.5 (_SERVER variabes not defined).
        225731 by: Sean O Sullivan

Help with Reverse Tree Traversal using Recursion ..
        225732 by: Greg Schnippel
        225744 by: Richard Lynch
        225756 by: Greg Schnippel

Virtual includes of PHP into SSI pages.
        225733 by: Neil Hoggarth

Re: fopen on windows
        225734 by: Ford, Mike
        225735 by: Ford, Mike
        225736 by: Jay Blanchard
        225777 by: Richard Lynch
        225778 by: Richard Lynch
        225782 by: Jay Blanchard

Re: php session in ie
        225737 by: Ford, Mike

split or explode quoted strings
        225738 by: Ördögh László
        225739 by: Chris Shiflett
        225740 by: Robin Vickery

Re: php Slow with Mac OS X 10.4
        225741 by: Nicolas Ross

Re: dependable combo boxes with mysql database (Solved)
        225742 by: Bhoomi Vora

PHP Install problem
        225743 by: russbucket
        225747 by: Curt Zirzow
        225760 by: russbucket
        225764 by: Ben
        225767 by: Richard Lynch

Re: Good user comment system?
        225745 by: Richard Lynch
        225758 by: Dan Baker
        225766 by: Greg Schnippel

Re: Output_Buffer problem
        225746 by: Richard Lynch

Create a numeric hash from a text string?
        225748 by: Brian Dunning
        225750 by: Curt Zirzow
        225751 by: Dan Baker
        225762 by: Brian Dunning
        225770 by: Richard Lynch

Re: mod_rewrite and include paths
        225749 by: Richard Lynch

Re: Printing to a buffer
        225752 by: Richard Lynch
        225755 by: Richard Lynch
        225757 by: Richard Lynch

Re: Zend + Eclipse + Standized Framework
        225753 by: GamblerZG

Walking through a bunch of MySQL Records
        225754 by: Phillip S. Baker
        225763 by: Jim Moseby
        225768 by: tg-php.gryffyndevelopment.com
        225769 by: Richard Lynch
        225784 by: Miles Thompson

Re: php/linux user groups in the east bay area..
        225759 by: Richard Lynch

Re: Recommendations for the Zend PHP Certification
        225761 by: Richard Lynch
        225774 by: Gustavo Narea

Re: emailing MySQL list not working
        225765 by: Richard Lynch

Re: url query problem
        225771 by: Richard Lynch

Re: Question about session
        225772 by: Richard Lynch

Re: What is the purpose of sessions extension?
        225773 by: Richard Lynch
        225781 by: Carlo Razzeto

Re: Filtering and Escaping (Was: Select and $_POST)
        225775 by: Richard Lynch

Easiest way to user DomDocument->getElementById()?
        225776 by: Erik Franzén
        225779 by: Erik Franzén
        225783 by: Erik Franzén

Re: DOMDocument needs a way to format XML code
        225780 by: Richard Lynch

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Ross wrote:
> Hello,
>
> I have been usng the file_get_contents function to insert a (repeating)
> part of my code
>
>
> $lines = file_get_contents('../shared/acessibility_box.htm');
>
> echo "$lines";
>
>
> In this file I have the a self submitting link
>
> <a href="<? $_SERVER['PHP_SELF']; ?>?text_size=small" class="size1">A</a>
>
>
> The problem I think is this code is inserted after the page headers have
> been set. And so the line just generates an error.
> When I roll over the link I get (or something similar)
>
>
> http://localhost/nhs/<? $_SERVER['PHP_SELF']; ?>?text_size=small
>
> I have tried most of the other similar functions (include, require) with no
> success.

Use require('../shared/acessibility_box.htm'); and change the link to this:

http://localhost/nhs/<?=$_SERVER['PHP_SELF']?>?text_size=small

Note the equals sign after the <?.

--
Richard Heyes

attached mail follows:


Hi Ross,

Monday, November 14, 2005, 9:44:45 AM, you wrote:

> $lines = file_get_contents('../shared/acessibility_box.htm');

> In this file I have the a self submitting link
> <a href="<? $_SERVER['PHP_SELF']; ?>?text_size=small" class="size1">A</a>

> The problem I think is this code is inserted after the page headers have
> been set. And so the line just generates an error.

file_get_contents does exactly that - it gets the contents of the file
*without* parsing it, i.e. any raw PHP code that exists within it,
will be treated as what it is when 'got' = plain text.

Cheers,

Rich
--
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

attached mail follows:


Ok...got it now.

Thanks for the tip max. It was that there was no parsing with the
file_get_contents function. Had another minor error but helped that I knew
include() was the way to go.

R.
""Ross"" <rossaztechost.com> wrote in message
news:A1.80.07637.C4C58734pb1.pair.com...
> Hello,
>
> I have been usng the file_get_contents function to insert a (repeating)
> part of my code
>
>
> $lines = file_get_contents('../shared/acessibility_box.htm');
>
> echo "$lines";
>
>
> In this file I have the a self submitting link
>
> <a href="<? $_SERVER['PHP_SELF']; ?>?text_size=small" class="size1">A</a>
>
>
> The problem I think is this code is inserted after the page headers have
> been set. And so the line just generates an error.
> When I roll over the link I get (or something similar)
>
>
> http://localhost/nhs/<? $_SERVER['PHP_SELF']; ?>?text_size=small
>
> I have tried most of the other similar functions (include, require) with
> no success.
>
>
> Any help would be great...
>
>
> Ross

attached mail follows:


Thanks Richard,

the server app was in another box from the database and we thought there may
be security issues behind the router etc.
we have now put the server app in the same box as the database and will use
php UDP to notify the app.

thanks for your help

Tony

"Richard Lynch" <ceol-i-e.com> wrote in message
news:55876.67.108.68.36.1131731363.squirrelwww.l-i-e.com...
> On Fri, November 11, 2005 4:57 am, tony yau wrote:
> > I have a server process that sends fax,print, etc (both in C# and in
> > Java).
> > Currently it polls says the fax table in the database for any fax
> > jobs.
> >
> > How can I get my PHP script to call or notify these services directly
> > so not
> > having to wait for the next poll.
> > I can't open a socket to the server vai the PHP so what mechanism do I
> > use?
>
> Why can't you open a socket to the server?
> http://php.net/fsockopen
>
> If you really can't do that, then just make it poll more often, I
> guess, so the wait time is insignificant.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Can anyone point me to a good User Authentication class written in PHP
(Version 5 preferably) that uses MySQL as the backend. If the output is
valid XHTML then even better. There are lots of hits on Google but I
need some help sorting the wheat from the chaff.

It's for a hobbyist site so I'm looking for something using cookies that
will keep people logged in between visits and provide some
personalisation. Obviously it needs to be reasonably secure but it's
not a banking system or anything.

Thanks!

Alan

attached mail follows:


Alan Milnes wrote:
> Can anyone point me to a good User Authentication class written in PHP
> (Version 5 preferably) that uses MySQL as the backend. If the output is
> valid XHTML then even better. There are lots of hits on Google but I
> need some help sorting the wheat from the chaff.

it might help you to think about it in terms of what 'Auth' is supposed to do...
and whether an 'Auth' module should be responsible for _any_ output what so ever?

i.e. imho if its outputting anything at all then its chaff.

>
> It's for a hobbyist site so I'm looking for something using cookies that
> will keep people logged in between visits and provide some
> personalisation. Obviously it needs to be reasonably secure but it's
> not a banking system or anything.

have a hunt here: pear.php.net - there is probably something there that fits the bill

>
> Thanks!
>
> Alan
>

attached mail follows:


Hello,

Was upgrading PHP-5.0.3 => 5.0.5
Apache version : httpd-2.0.46-54.ent
Distro : RHEL3 U2

configure switches :
./configure --with-zlib --without-gd --without-gdbm
--with-oracle=/opt/oracle/app/oracle/product/9.2.0/ --enable-sigchild
--enable-force-cgi-redirect --enable-memory-limit --enable-ftp
--enable-xml --with-apxs2=/usr/sbin/apxs --prefix=/usr
--exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin
--sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include
--libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var
--mandir=/usr/share/man --infodir=/usr/share/info
--with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d

I came accross a problem where in 5.0.3 I had a series of PHP Variables
defined ( _SERVER & _ENV )
By and large, these were the same as the Environment variables.
e.g.

HOSTNAME => myhostname
SHELL => /bin/bash
TERM => xterm

_SERVER["HOSTNAME"] => myhostname
_SERVER["SHELL"] => /bin/bash
_SERVER["TERM"] => xterm

(just to give a brief example).

However, these were not defined in PHP-5.0.5 - I then tried PHP-5.0.4 to
see if affected this too, which it didn't.

So there is some change in PHP between 5.0.4 & 5.0.5, I'd be grateful
for any suggestions/ideas in regards to this matter.

Regards,

Sean O Sullivan

attached mail follows:


I have a large data tree that I wanted to display in an outline
format. I used a textbook tree recursion function to go through the
data and display it as nested unordered lists:

function outputTree($id) {

       if (checkChildObjectExists($id)) {
               print "<ul>";
               $child = getChildArray($id);
               foreach ($child as $key => $value) {
                       print "<li><a href=\"/object/$key/\">$value</a></li>";
                       outputTree($key);
               }
               print "</ul>";
       }
}

This works as expected:

> Level 1 (Top)
> Level 2
> Level 3 (Bottom)

However, I also want to display a reverse tree to allow users to trace
their way back up the tree after landing on a lower branch. I tried to
be clever and reverse the function above as:

function outputReverseTree($id) {

       if (checkParentExists($id)) {
               print "<ul>";
               $parent = getParentArray($id);
               foreach ($parent as $key => $value) {
                       print "<li><a href=\"/object/$key/\">$value</a>\n";
                       outputReverseTree($key);
               }
               print "</ul>";
       }
}

Which works, but there is something wrong with my logic as the tree
comes back reversed:

> Level 3 (Bottom)
> Level 2
> Level 1 (Top)

Any suggestions on how to do this?

Thanks,

- Greg

attached mail follows:


On Mon, November 14, 2005 7:46 am, Greg Schnippel wrote:
> I have a large data tree that I wanted to display in an outline
> format. I used a textbook tree recursion function to go through the
> data and display it as nested unordered lists:
>
> function outputTree($id) {
>
> if (checkChildObjectExists($id)) {
> print "<ul>";
> $child = getChildArray($id);
> foreach ($child as $key => $value) {
> print "<li><a
> href=\"/object/$key/\">$value</a></li>";
> outputTree($key);
> }
> print "</ul>";
> }
> }
>
> This works as expected:
>
>> Level 1 (Top)
> > Level 2
> > Level 3 (Bottom)
>
> However, I also want to display a reverse tree to allow users to trace
> their way back up the tree after landing on a lower branch. I tried to
> be clever and reverse the function above as:
>
> function outputReverseTree($id) {
>
> if (checkParentExists($id)) {
> print "<ul>";
> $parent = getParentArray($id);
> foreach ($parent as $key => $value) {

Just swap the order of these two lines:
> print "<li><a href=\"/object/$key/\">$value</a>\n";
> outputReverseTree($key);

So that you walk up to the ROOT of the tree *before* you start
printing stuff out.

> }
> print "</ul>";
> }
> }
>
> Which works, but there is something wrong with my logic as the tree
> comes back reversed:
>
>> Level 3 (Bottom)
> > Level 2
> > Level 1 (Top)
>
> Any suggestions on how to do this?

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Richard -

Thanks for the helpful suggestion but that won't resolve my problem
the way I currently have it written because I'm creating a new, nested
<ul> each time I loop through:

print "<ul>";
foreach ($parent as $key => $value) {
...
}
print "</ul>";

So when I tried this, the output was still inverted because it began
printing at the innermost branch of the nested list.

I'm trying to figure out a way now to save the output into an array
instead of outputting and then traversing the array in a separate
function to output it. Might run into the same problem again but I'm
hopeful that once the data is an array, I can make use of a php
function to reverse or sort the array.

Another reader also recommended this article on php and recursion:

http://www.zend.com/zend/art/recursion.php

I'll post if I get any closer,

- Greg

On 11/14/05, Richard Lynch <ceol-i-e.com> wrote:
> On Mon, November 14, 2005 7:46 am, Greg Schnippel wrote:
> > I have a large data tree that I wanted to display in an outline
> > format. I used a textbook tree recursion function to go through the
> > data and display it as nested unordered lists:
> >
> > function outputTree($id) {
> >
> > if (checkChildObjectExists($id)) {
> > print "<ul>";
> > $child = getChildArray($id);
> > foreach ($child as $key => $value) {
> > print "<li><a
> > href=\"/object/$key/\">$value</a></li>";
> > outputTree($key);
> > }
> > print "</ul>";
> > }
> > }
> >
> > This works as expected:
> >
> >> Level 1 (Top)
> > > Level 2
> > > Level 3 (Bottom)
> >
> > However, I also want to display a reverse tree to allow users to trace
> > their way back up the tree after landing on a lower branch. I tried to
> > be clever and reverse the function above as:
> >
> > function outputReverseTree($id) {
> >
> > if (checkParentExists($id)) {
> > print "<ul>";
> > $parent = getParentArray($id);
> > foreach ($parent as $key => $value) {
>
> Just swap the order of these two lines:
> > print "<li><a href=\"/object/$key/\">$value</a>\n";
> > outputReverseTree($key);
>
> So that you walk up to the ROOT of the tree *before* you start
> printing stuff out.
>
> > }
> > print "</ul>";
> > }
> > }
> >
> > Which works, but there is something wrong with my logic as the tree
> > comes back reversed:
> >
> >> Level 3 (Bottom)
> > > Level 2
> > > Level 1 (Top)
> >
> > Any suggestions on how to do this?
>
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
>
>

attached mail follows:


Hi Folks,

I'm attempting to diagnose an apparent problem with my Apache/PHP
server setup. The platform is SPARC Solaris 9. I'm running Apache httpd
2.0.55 and PHP 4.4.1, built from NetBSD pkgsrc.

I have a user who has .shtml (server side include) pages which include
PHP fragments using directives like <!--#include virtual="/name.php" -->
(and yes, I know this is silly, and that obvious thing to do is to use
PHP for the top level pages rather than SSI; unfortunatly I'm the
sysadmin providing the service, rather than the person maintaining the
content).

I wanted to check to see if anyone knows of any known problems or
gotchas in this area?

I'm told that this mechanism was working okay until recently, but it
broke at some point in the last few months. I've done a number of
upgrades to both the apache2 and PHP packages over the time period in
question, in response to security advisories; unfortunately the user
can't pinpoint exactly when things started to fail.

I've recreated a very simple test case:

test.shtml:

   <html>
   <head>
   <title>Test Page</title>
   </head>
   <body>
   <p>Begin Test</p>
   <!--#include virtual="/foo1.php" -->
   <p>End Test</p>
   </body>
   </html>

foo1.php:

   <p>Hello From PHP</p>

Fetching "test.shtml" produces the output:

   Begin Test

   End Test

(no sign of the included fragment in the output).

Editing the test harness to teplacing the include of foo1.php with an
include of a plain HTML or SHTML file produces the expected output
(included content appears in the output between the begin and end
markers).

Furthermore, if I edit the test harness to include an HTML file and
*then* the PHP fragment, I get a reproduceable segmentation fault in
PHP:

Program received signal SIGSEGV, Segmentation fault.
0xfecb541c in zend_hash_index_update_or_next_insert (ht=0xfed3c1c4, h=0,
pData=0xffbfdec8, nDataSize=12,
     pDest=0x0, flag=1) at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_hash.c:390
390 p = ht->arBuckets[nIndex];
(gdb) where
#0 0xfecb541c in zend_hash_index_update_or_next_insert (ht=0xfed3c1c4,
h=0, pData=0xffbfdec8,
     nDataSize=12, pDest=0x0, flag=1)
     at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_hash.c:390
#1 0xfecb8cc0 in zend_list_insert (ptr=0x299250, type=2)
     at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_list.c:45
#2 0xfecb8eb8 in zend_register_resource (rsrc_result=0x0, rsrc_pointer=0x299250, rsrc_type=2)
     at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_list.c:98
#3 0xfec693d8 in _php_stream_alloc (ops=0xfed31528, abstract=0x1eb770, persistent_id=0x0,
     mode=0xfece83f0 "rb") at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:281
#4 0xfec6e0b0 in _php_stream_fopen_from_fd (fd=22, mode=0xfece83f0 "rb", persistent_id=0x0)
     at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2072
#5 0xfec6de5c in _php_stream_fopen (filename=0x297cb8 "/usr/pkg/share/httpd/htdocs/foo1.php",
     mode=0xfece83f0 "rb", opened_path=0xffbfeb90, options=165)
     at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2004
#6 0xfec6d5cc in _php_stream_fopen_with_path (filename=0x297cb8 "/usr/pkg/share/httpd/htdocs/foo1.php",
     mode=0xfece83f0 "rb", path=0xfece7fc8 ".:/usr/pkg/lib/php", opened_path=0xffbfeb90, options=165)
     at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:1784
#7 0xfec6efd4 in php_plain_files_stream_opener (wrapper=0xfed31598,
     path=0x297cb8 "/usr/pkg/share/httpd/htdocs/foo1.php", mode=0xfece83f0 "rb", options=165,
     opened_path=0xffbfeb90, context=0x0)
     at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2489
#8 0xfec6fb18 in _php_stream_open_wrapper_ex (path=0x297cb8 "/usr/pkg/share/httpd/htdocs/foo1.php",
     mode=0xfece83f0 "rb", options=173, opened_path=0xffbfeb90, context=0x0)
     at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2696
#9 0xfec6ff34 in _php_stream_open_wrapper_as_file_handle (
     path=0x297cb8 "/usr/pkg/share/httpd/htdocs/foo1.php", mode=0xfece83f0 "rb", options=141, fh=0xffbfeb88)
     at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2823
#10 0xfec53900 in php_open_wrapper_for_zend (filename=0x297cb8 "/usr/pkg/share/httpd/htdocs/foo1.php",
     fh=0xffbfeb88) at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/main.c:764
#11 0xfec82730 in open_file_for_scanning (file_handle=0xffbfeb88) at Zend/zend_language_scanner.c:3022
#12 0xfec82a34 in compile_file (file_handle=0xffbfeb88, type=2) at Zend/zend_language_scanner.c:3114
#13 0xfecae520 in zend_execute_scripts (type=2, retval=0x0, file_count=1)
     at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend.c:934
#14 0xfecd2b74 in php_handler (r=0x297150)
     at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/sapi/apache2handler/sapi_apache2.c:574
#15 0x000e3c28 in ap_run_handler (r=0x297150) at config.c:152
#16 0x000e4848 in ap_invoke_handler (r=0x297150) at config.c:364
#17 0x00114840 in ap_run_sub_req (r=0x297150) at request.c:1855
#18 0x000382a4 in handle_include (ctx=0x283660, bb=0xffbfef78, r=0x289118, f=0x28a9c0, head_ptr=0x2876e8,
     inserted_head=0xffbfeee8) at mod_include.c:782
#19 0x0003fa58 in send_parsed_content (f=0x28a9c0, bb=0x28abb0) at mod_include.c:3309
#20 0x0004093c in includes_filter (f=0x28a9c0, b=0x28abb0) at mod_include.c:3591
#21 0x000fe614 in ap_pass_brigade (next=0x28a9c0, bb=0x28abb0) at util_filter.c:512
#22 0x0010cde0 in default_handler (r=0x289118) at core.c:3640
#23 0x000e3c28 in ap_run_handler (r=0x289118) at config.c:152
#24 0x000e4848 in ap_invoke_handler (r=0x289118) at config.c:364
#25 0x00094aac in ap_process_request (r=0x289118) at http_request.c:249
#26 0x0008bac0 in ap_process_http_connection (c=0x2831d8) at http_core.c:251
#27 0x000f9820 in ap_run_process_connection (c=0x2831d8) at connection.c:43
#28 0x000f9e04 in ap_process_connection (c=0x2831d8, csd=0x283100) at connection.c:176
#29 0x000e1574 in child_main (child_num_arg=0) at prefork.c:610
#30 0x000e16c0 in make_child (s=0x1b80b0, slot=0) at prefork.c:650
#31 0x000e1878 in startup_children (number_to_start=5) at prefork.c:722
#32 0x000e1f8c in ap_mpm_run (_pconf=0x16cda8, plog=0x1b2ec0, s=0x1b80b0) at prefork.c:941
#33 0x000eced8 in main (argc=2, argv=0xffbff77c) at main.c:618

Regards,
--
Neil Hoggarth Departmental Computing Manager
<neil.hoggarthphysiol.ox.ac.uk> Laboratory of Physiology
http://www.physiol.ox.ac.uk/~njh/ University of Oxford, UK

attached mail follows:


On 11 November 2005 20:52, Jay Blanchard wrote:

> $theFile = fopen("docs/InstallationInstructionMaster.txt", "r") ||
> die;

You need "or" not || here. The operator priorities are such that the above means

  $theFile = (fopen("docs/InstallationInstructionMaster.txt", "r") || die);

which assigns TRUE to $the File when the fopen() succeeds, rather than the file handle. You can't have error reporting turned up very high, or this:
 
> while(!feof($theFile)){
> $theLine = fgets($theFile, 4096);
> echo $theLine . "<br>\n";
> }

would be throwing all sorts of warnings about the invalid file handle. I'm guessing that feof(TRUE) returns NULL as well as throwing the warning, so this should be an infinite loop echoing just linebreaks. Oh, wait....! ;)

On the other hand, the version using "or" works out to be:

   ($theFile = fopen("docs/InstallationInstructionMaster.txt", "r")) or die;

which assigns the result of fopen() to $theFile, and then executes die if it's false -- which is much more satisfactory. ;)

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.fordleedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

attached mail follows:


On 11 November 2005 21:21, Nathan Tobik wrote:

> I've always used:
>
> fopen("C:\\dir\\dir\\file.txt");
>
> on windows, I'm not sure how PHP interprets the slashes internally
> though...

On Windows, "/" in filenames is internally translated by PHP to "\" -- which means you can write code that works on both Windows and *n*x using "/". *Really* portable code uses the DIRECTORY_SEPARATOR constant, however.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.fordleedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

attached mail follows:


[snip]
You need "or" not || here. The operator priorities are such that the above
means
...
which assigns the result of fopen() to $theFile, and then executes die if
it's false -- which is much more satisfactory. ;)
[/snip]

Originally I did not have any '||' or 'or' in the conditional check, with
the same results.

attached mail follows:


On Fri, November 11, 2005 2:51 pm, Jay Blanchard wrote:
> $theFile = fopen("docs/InstallationInstructionMaster.txt", "r") ||
> die;

Don't use || when you mean 'or' :-)

Nor sure it really matters here, but better to follow the crowd and
use 'or' here.

> while(!feof($theFile)){
> $theLine = fgets($theFile, 4096);

4096 is longer than any line in the file?

> echo $theLine . "<br>\n";
> }
> fclose($theFile);
>
> The above code appears to work, but all that is output is lines of
> line
> breaks....no data. The file is a tab delimited test file;

View Source?

> Am I missing something other than an ice cold beer?

Are you 100% certain you don't have an empty file in
docs/InstallationInstructionMaster.txt sitting right next to your
script, while the REAL file you want is somewhere else?

Been there. Done that. Smacked the forehead.

Use the full path to the file to be SURE you are reading the file you
think you are reading.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Fri, November 11, 2005 3:23 pm, Jay Blanchard wrote:
> // Left off the "b" because it ain't binary :)

I think you will find this is the crucial difference if you go back to
your original and take it out.

Your file is text.

It's not binary.

On Windowz, that matters, for some odd reason.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


[snip]
On Fri, November 11, 2005 2:51 pm, Jay Blanchard wrote:
> $theFile = fopen("docs/InstallationInstructionMaster.txt", "r") ||
> die;

Don't use || when you mean 'or' :-)

Nor sure it really matters here, but better to follow the crowd and
use 'or' here.
[/snip]

Okie dokie. Found there to be no change in behavior at this point. Perhaps I
need to set the error checking higher, say E_ALL.

[snip]
> while(!feof($theFile)){
> $theLine = fgets($theFile, 4096);

4096 is longer than any line in the file?
[/snip]

Yes, it accounts for every line in the file.

[snip]
> echo $theLine . "<br>\n";
> }
> fclose($theFile);
>
> The above code appears to work, but all that is output is lines of
> line
> breaks....no data. The file is a tab delimited test file;

View Source?
[/snip]

Looks like;

<br>
<br>
<br>
<br>
<br>
....

[snip]
Are you 100% certain you don't have an empty file in
docs/InstallationInstructionMaster.txt sitting right next to your
script, while the REAL file you want is somewhere else?

Been there. Done that. Smacked the forehead.

Use the full path to the file to be SURE you are reading the file you
think you are reading.
[/snip]

Did that too. Still no joy.

Several other methods have been provided and I will use one of those.
However, when I get to the point that fopen would be my only choice I will
likely encounter these same problems. C'est la vie!

attached mail follows:


On 11 November 2005 18:47, sunaram patir wrote:

> array(1) { ["PHPSESSID"]=> string(32)
> "337a44c0d6c9ed3cf4ba4e97d707589e" } is returned by firefox on calling
> var_dump($_COOKIE). NULL in ie.

If the very same piece of PHP produces different results in different browsers, this *MUST* be due to differences between the browsers. It could be due to settings in the browsers, or it might simply be a bug in one or the other -- but it can NOT NOT NOT be down to PHP. (Well, except inasmuch as you might be able to make reasonable adjustments in your PHP to allow for the difference. ;)

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.fordleedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

attached mail follows:


Hello,

I would like to split or explode strings in a way that
quoted strings inside the strings should remain.
e.g.:

"first second \"third third\" fourth \"fifth fifth fifth\""

after the split I need:

"first"
"second"
"third third"
"fourth"
"fifth fifth fifth"

Is there a simple way to achieve this in PHP? (e.g. like Perl
Text::ParseWords quotedwords function)

Thanks In Advance,

--Laszlo Ordogh
ordoghlgmail.com

attached mail follows:


Ördögh László wrote:
> I would like to split or explode strings in a way that
> quoted strings inside the strings should remain.
> e.g.:
>
> "first second \"third third\" fourth \"fifth fifth fifth\""
>
> after the split I need:
>
> "first"
> "second"
> "third third"
> "fourth"
> "fifth fifth fifth"

I love explode(), too, but this is a job for sscanf():

http://php.net/sscanf

Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

attached mail follows:


On 11/14/05, Ördögh László <ordoghlgmail.com> wrote:
> Hello,
>
> I would like to split or explode strings in a way that
> quoted strings inside the strings should remain.
> e.g.:
>
> "first second \"third third\" fourth \"fifth fifth fifth\""
>
> after the split I need:
>
> "first"
> "second"
> "third third"
> "fourth"
> "fifth fifth fifth"

How about something like this?

<?php

$singleQuoted = "(?:'(?:[^'\\\\]|\\\\.)*')";
$doubleQuoted = '(?:"(?:[^"\\\\]|\\\\.)*")';

$re = "/$singleQuoted|$doubleQuoted|\S+/s";

preg_match_all($re, $text, $quotedWords);

print_r($quotedWords);

?>

attached mail follows:


I've finally narrow-it down and found a solution.

After much, much googeling, trying and error on my test machine and my
xserve running mac os x 10.4, I've found out that apache2 was shipped with
mac os X 10.4 server (server only).

I decided to compile my own php (as allways) againts this apache, and it
works, and it's fast !

This apache is in /opt/apache2, and is only configured with the default from
the apache distribution. The version that comes with os x 10.4 also suffers
from a bug in apr preventing it from delivering more than 64k of content.
But that's not important. I examined the compile option in
/opt/apache2/build/config.nice, and saw something verry importent :

--with-mpm=worker

Php compiled againts this apache works ok. But if I compile my own apache2,
with --with-mpm=worker, apache won't start saying php needs to be
recompiling.

Php's manual about apache2 clearly states not to use worker mpm. Ok, I took
the libphp4.so from the php compiled againts the stock apache2 from /opt,
and copied it into my own apache2 compiled with my usual configure options,
and all is well and fast.

After comparing phpinfo's output from my ususal php and the one's compiled
againts /opt/apache2's apache, I only see 2 difference.

Virtual Directory Support and Thread safety is enabled on the good apache
from /opt/apache2...

Now, after examining the output from configure command, and greping for
safety and all in my source tree, I found that --enable-experimental-zts is
enabling this. So, I tried agin my own php configure option, with my own
apache (without specifing mpm=worker), but with --enable-experimental-zts,
and voilŕ ! All is great.

Now to my question :

Why is that enabling threat safety in php afects the performance of apache2
accessing the filesystem ?

Nicolas

attached mail follows:


I have got it done.
Below is the code:
-------------------------
<form name="from_service" method="post">
<FONT style="FONT-SIZE:12pt" color="#00008B"
face="Courier New"><B>Service</B></FONT>
</DIV>

<select name="D1" size="1"
style="position:absolute;left:230px;top:68px;z-index:7"
onChange="form_service.submit();">
<?php
display_db_combo("service_master","service_name",$conn);

        $ser=$_POST['D1'];
        if ($ser == ""){
        
        print("<option selected>Select Service</option>");
        }
        else {
        
                print("<option selected>$ser</option>");
        }
?>
</select>

<DIV style="position:absolute; left:65px; top:106px;
width:83px; height:22px; z-index:4" align="left"
valign="top">
<FONT style="FONT-SIZE:12pt" color="#00008B"
face="Courier New"><B>Product</B></FONT>
</DIV>
<select name="D2" size="1"
style="position:absolute;left:230px;top:108px;z-index:8"
onChange="form_service.submit();">
<?php
display_db_combo1("service_master","service_id","service_name","product_master","product_name",$conn);

        $ser=$_POST['D1'];
        $prd=$_POST['D2'];

        $a='Select Product';
        
        if ($prd == ""){
        
        print("<option selected>$a</option>");
        }
        else {
                print("<option selected>$prd</option>");
        }

?>
</select>

<DIV style="position:absolute; left:65px; top:152px;
width:103px; height:44px; z-index:5" align="left"
valign="top">
<FONT style="FONT-SIZE:12pt" color="#00008B"
face="Courier New"><B>Nature of Problem</B></FONT>
</DIV>
<select name="D3"
style="position:absolute;left:230px;top:170px;z-index:9"
size="1" onChange="form_service.submit()";>
<?php
display_db_combo2("product_master","product_id","product_name","problem_products","problem",$conn);

        $prb=$_POST['D3'];
        $prd=$_POST['D2'];
        

        if ($prb == "" || $prd == "Select Product") {
                        print("<option selected>Select Problem</option>");
                }

        else {
                        print("<option selected>$prb</option>");
        }

?>
</select>
</form>
---------------------------------------------
regards,

Bhoomi

--- "Pranav Negandhi (concept-I)"
<pranavconcept-i.co.in> wrote:

> This might be slightly OT on this list, but here
> goes nothing.
>
> 1. Submit the form when the user shifts focus from
> D1 using Javascript's
> onBlur event
> 2. On the server side, use PHP to retrieve the
> values for D2 and
> generate the page again
> 3. Repeat 1 & 2 when the value of D2 changes.
>
> HTH
> Pranav
> www.concept-i.co.in
>
>
> Bhoomi Vora wrote:
> > Hello All,
> >
> > I have a php page which contains three combo
> boxes.
> > The first one will have the value
> >
> > from the mysql database table on page load itself.
> >
> > Then depending upon the value selected in the
> first
> > combobox the second combo box
> >
> > should be populated with the respective values
> from
> > another mysql database table, and
> >
> > once again depending upon the value selected in
> second
> > combobox the third combobox
> >
> > should be populated with the respective values
> from
> > one more different database table.
> >
> > I have read through mailing list and also searched
> in
> > google and found that it can be
> >
> > done with javascript onblur function but nothing
> is
> > working. Here is the code:
> .....d similarly
> > D3 should be populated on event like 'onblur' to
> D2.
> >
> > Pl. give me the exact code or proper guideline how
> > should I accomplish this on the same page.
> >
> > Appreciate your replies.
> >
> > Thanks and regards.
> >
> > BJV
> >
> >
> >
> > __________________________________
> > Yahoo! FareChase: Search multiple travel sites in
> one click.
> > http://farechase.yahoo.com
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

                
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

attached mail follows:


Trying to get apache2, php5 and mysql running. get the following error when
opening phpMyAdmin. Can someone explain what it means. There is an include
path in php.ini.

--
Russ

attached mail follows:


On Mon, Nov 14, 2005 at 10:06:17AM -0800, russbucket wrote:
> Trying to get apache2, php5 and mysql running. get the following error when
> opening phpMyAdmin. Can someone explain what it means. There is an include
> path in php.ini.

I think you forgot to include the error message.

curt.
--

attached mail follows:


On Monday 14 November 2005 10:47, Curt Zirzow wrote:
> On Mon, Nov 14, 2005 at 10:06:17AM -0800, russbucket wrote:
> > Trying to get apache2, php5 and mysql running. get the following error
> > when opening phpMyAdmin. Can someone explain what it means. There is an
> > include path in php.ini.
>
> I think you forgot to include the error message.
>
> curt.
> --
Your right, hand got ahead of my brain, Heres the messages when using
http/localhost/phpMyAdmin/

phpMyAdmin - Error
 phpMyAdmin was unable to read your configuration file!
This might happen if PHP finds a parse error in it or PHP cannot find the
file.
Please call the configuration file directly using the link below and read the
PHP error message(s) that you receive. In most cases a quote or a semicolon
is missing somewhere.
If you receive a blank page, everything is fine.

 config.inc.php

Clicking on the config.inc.php gives following error.
Warning: Unknown: failed to open stream: Permission denied in Unknown on line
0
 
 Warning: Unknown: Failed opening '/srv/www/htdocs/phpMyAdmin/config.inc.php'
for inclusion (include_path='.:') in Unknown on line 0

I've checked and rechecked the configurations files, they look correct.

Thanks for responding even with my goof.

--
Russ

attached mail follows:


russbucket said the following on 11/14/2005 11:15 AM:

> Clicking on the config.inc.php gives following error.
> Warning: Unknown: failed to open stream: Permission denied in Unknown on line
> 0
>
> Warning: Unknown: Failed opening '/srv/www/htdocs/phpMyAdmin/config.inc.php'
> for inclusion (include_path='.:') in Unknown on line 0
>
> I've checked and rechecked the configurations files, they look correct.

Sounds like your web server's user does not have permission to read the
file.

chmod 444 /srv/www/htdocs/phpMyAdmin/config.inc.php

will set your permissions (assuming your on *nix) to r--r--r-- which
will give your web server's user (and ever other user account on the
machine - which may not be what you want) permission to read the file.

- Ben

attached mail follows:


On Mon, November 14, 2005 1:15 pm, russbucket wrote:
> On Monday 14 November 2005 10:47, Curt Zirzow wrote:
>> On Mon, Nov 14, 2005 at 10:06:17AM -0800, russbucket wrote:
>> > Trying to get apache2, php5 and mysql running. get the following
>> error
>> > when opening phpMyAdmin. Can someone explain what it means. There
>> is an
>> > include path in php.ini.
>>
>> I think you forgot to include the error message.
>>
>> curt.
>> --
> Your right, hand got ahead of my brain, Heres the messages when using
> http/localhost/phpMyAdmin/
>
> phpMyAdmin - Error
> phpMyAdmin was unable to read your configuration file!
> This might happen if PHP finds a parse error in it or PHP cannot find
> the
> file.
> Please call the configuration file directly using the link below and
> read the
> PHP error message(s) that you receive. In most cases a quote or a
> semicolon
> is missing somewhere.
> If you receive a blank page, everything is fine.
>
> config.inc.php
>
> Clicking on the config.inc.php gives following error.
> Warning: Unknown: failed to open stream: Permission denied in Unknown
> on line
> 0
>
> Warning: Unknown: Failed opening
> '/srv/www/htdocs/phpMyAdmin/config.inc.php'
> for inclusion (include_path='.:') in Unknown on line 0
>
> I've checked and rechecked the configurations files, they look
> correct.

The file contents are fine (maybe) but PHP can't even *READ* the file
because it's set up as un-readable by the PHP user.

You need to find out the permissions on the file (config.inc.php)

In a shell prompt on the server you can do:
ls -als config.inc.php
The output will have something not unlike:
 7 -rw-rw-r-- 1 russbucket nwi_group ... config.inc.php

But I'll bet a dollar *YOUR* file doesn't have the last 'r' letter
there, and just has '-' instead:
-rw-rw----

You need to change that:
chmod 554 config.inc.php

WARNING:
On a shared server, this is exposing your database password to
everybody else on that shared server. You may not have any other
option, however.

To mitigate this risk, you may want to do several things, after you
get phpMyAdmin working.

1. Move the file out of your web tree, so *ONLY* users on the shared
server could possibly read it, not the whole friggin' world.

2. Move it to a directory that denies listings by other users, so they
can't stumble across it. (This may make it unreadable by PHP, though,
depending on things I've never fully understood, so then don't do
that...)

More involved methods of keeping the password accessible to PHP and
not everybody else with a login can be found here:
http://phpsec.org

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Sun, November 13, 2005 7:59 pm, Guy Brom wrote:
> Anyone familiar with a good user-comment system for PHP, preferably
> one that
> works with adodb and has thread-like design (where users can answer
> each
> other).

It's not threaded, but the User Contributed notes system on
http://php.net should be worth looking at. :-)

After that, I suspect almost any forum/bulletin/board code could be
grafted on as a user-comment system...

FUD was recommended here recently as a good choice for
security-concious admins.

YMMV

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


How about good ol' phpbb?
http://www.phpbb.com/

DanB

"Guy Brom" <guybromgmail.com> wrote in message
news:6C.15.07637.0CFE7734pb1.pair.com...
> Hi all,
>
> Anyone familiar with a good user-comment system for PHP, preferably one
> that works with adodb and has thread-like design (where users can answer
> each other).
>
> Thanks!
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


If you're looking for a light-weight, threaded discussion script, I
can recommend this class from xhawk.net

http://www.xhawk.net/projects/discussion/

I like it because I can quickly integrate this into blogs or galleries
by just instantiating a new board instance for each object id or
article.

It does need some work fending off comment-spam, as the demo version
illustrates. However, it is very small and well-documented so you can
easily integrate an approval-based or captcha anti-spam defense.

- Greg

On 11/13/05, Guy Brom <guybromgmail.com> wrote:
> Hi all,
>
> Anyone familiar with a good user-comment system for PHP, preferably one that
> works with adodb and has thread-like design (where users can answer each
> other).
>
> Thanks!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


On Sun, November 13, 2005 4:39 pm, Todd Cary wrote:
> My client has switched to a shared server, so direct access to the
> php.ini is not availble. Our calendar program expects to have
> output_buffering set to On ("1").
>
> Currently, I get the expected error of
>
> Warning: Cannot modify header information - headers already sent by
> (output started at
> /home/content/s/f/y/sfycadmin/html/php/calendar/private/ltw_config.php:375)
> in
> /home/content/s/f/y/sfycadmin/html/php/calendar/private/ltwdisplaymonth.php
> on line 283
>
> At the top of ltwdisplaymonth.php, I tried ini_set(output_buffering,
> "1"), but that does not appear to have an effect.
>
> Have I missed something?

I don't see why it wouldn't have worked, but perhaps try:

<?php ob_start();?>

at the tip-top of the page instead.

Your other option is to structure your code better so that the headers
are dealt with before any HTML output, which, honestly, is usually the
natural way things fall out if your code is well-structured...

"Warning: Cannot modify header information - headers already sent by
(output started at "

is, for me, a Red Flag, that the code is a mess and not well-structured.

YMMV

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Does anyone know if there's a handy way to create a numeric hash from
a text string? I'm trying to generate an integer as a sort of quick &
dirty checksum for text strings. Needs to be a decimal integer, not
hex or otherwise. Any clever ideas appreciated. :)

attached mail follows:


On Mon, Nov 14, 2005 at 10:41:53AM -0800, Brian Dunning wrote:
> Does anyone know if there's a handy way to create a numeric hash from
> a text string? I'm trying to generate an integer as a sort of quick &
> dirty checksum for text strings. Needs to be a decimal integer, not
> hex or otherwise. Any clever ideas appreciated. :)

This should work for a dirty checksum:
  http://php.net/crc32

Curt.
--

attached mail follows:


Quick-n-easy:
int crc32 ( string str ) -- make sure to read the manual about the
unsigned/signed issue.

DanB

"Brian Dunning" <brianbriandunning.com> wrote in message
news:BAE2710C-2A3D-4957-A554-77BCE5E4F664briandunning.com...
> Does anyone know if there's a handy way to create a numeric hash from a
> text string? I'm trying to generate an integer as a sort of quick & dirty
> checksum for text strings. Needs to be a decimal integer, not hex or
> otherwise. Any clever ideas appreciated. :)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Perfect - thanks guys! :)

attached mail follows:


On Mon, November 14, 2005 12:41 pm, Brian Dunning wrote:
> Does anyone know if there's a handy way to create a numeric hash from
> a text string? I'm trying to generate an integer as a sort of quick &
> dirty checksum for text strings. Needs to be a decimal integer, not
> hex or otherwise. Any clever ideas appreciated. :)

Why an integer?...

For that matter, down in the guts, it's all just an integer,
technically...

Do you need a 32-bit integer for some reason?

Something involving md5, substr, and http://php.net/pack should sort
of work.

You're probably better off re-thinking your "needs to be an integer"
requirement, though, honestly, unless there is some really really
compelling driving external force at work.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Sun, November 13, 2005 4:05 pm, Marcus Bointon wrote:
> This seems like a simple problem...

Maybe there should be a simple solution... :-)

> I have a rewrite like this:
>
> RewriteRule ^x/([0-9]+) x.php?x=$1 [PT,L]
>
> This maps a url like http://www.example.com/x/123 to http://
> www.example.com/x.php?x=123
>
> x.php contains a line to include some class like:
>
> require_once 'x.class.php';
>
> My include path contains '.' (plus paths to pear, etc), and the class
> file is in the top level directory.

If it's in the top level directory, then maybe that directory should
be hard-coded into the include_path, as well as '.'

include_path
".:/whatever/httpd.conf/has/for/DocumentRoot:/full/path/to/PEAR"

> So how can I get PHP to look in /? I can set include_path with a
> php_value in .htaccess, but I can only set it absolutely (losing
> existing values), not add to it (AFAIK?). I don't want to add an
> absolute path to my global include_path as there may be multiple
> independent deployments of the same scripts on the server, and I
> don't want them including each others files. Adding .. to the path
> would work but is a security risk. Any other ideas?

This all rules out the above, but one possibility is this:

In just the script that gives you trouble do this:

include_path("/full/path/to/DocumentRoot:" . include_path());
This may not be the right syntax/function to set include_path, but it
is a dynamic way to set the include path, from within PHP.

Of course, for the multiple deployments, you'll need to make the path
based on the deployment somehow.

Now, on to the simple solution I intimated at the beginning...

If mod_rewrite is giving you the headaches it gives me, just get rid
of it. :-)

INSTEAD, do this.

Create a PHP script, and name it 'x'

In .htaccess, force 'x' to be PHP as far as Apache is concerned:
<Files x>
  ForceType application/x-httpd-php
</Files>

You can now access your "x=123" from $_SERVER['PATHINFO'] (or is it
'PATH_INFO'?

No more endless tweaking of Regex rules in httpd.conf and logging the
mod_rewrite and dinking with ^/[0-9]+ junk and re-starting Apache
every time you want to try a change.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Sun, November 13, 2005 8:20 am, Marcus Bointon wrote:
>
> On 13 Nov 2005, at 00:17, Jasper Bryant-Greene wrote:
>
>>> seem to do that. I just tried "application/text" since I use
>>> "application/pdf" for other applications.
>>
>> Whatever it's giving the user the ability to do, it's probably
>> because the browser doesn't recognise the (invalid) MIME-Type.
>
> Quite - it's right up there with 'application/force-download'. If you
> want to suggest (the final choice is not yours to make) that a
> browser might download something instead of displaying it, set an
> appropriate content-disposition header instead of setting the wrong
> type.

Errrr.

It may not be my final choice whether they download or not, but if a
browser doesn't treat:
application/octet-stream
as a download, and only as a download, then that browser is pretty
broken.

Letting the user configure their browser for that MIME type to be
opened by an application is just plain wrong for a browser, by
specification.

If you find a browser that lets you configure application/octet-stream
to be opened with a specific application, then file a bug report with
whomever wrote that browser.

All the other johnny-come-lately hacks from Redmond to 'force'
downloads are highly suspect and non-portable, and should be avoided
if you want to keep your hair.

You can't rely on "Content-disposition ... filename" either, so you
either make the URL end in the filename you want as the default, or
you can count on some browsers using some other filename.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Sun, November 13, 2005 1:53 pm, Marcus Bointon wrote:
> On 13 Nov 2005, at 19:27, Jasper Bryant-Greene wrote:
>
>>> Many thanks! I did not know that MIME-Type. Change duly made!
>>
>> You're not suggesting that you actually set the MIME-Type to
>> application/force-download, are you?
>
> I think he is. I've called the MIME-type police and they'll be round
> later.
>
> Todd, I think you should read this: http://support.microsoft.com/kb/
> q260519/
>
> There's a PHP example just before the user notes here: http://
> www.php.net/header
>
> Marcus
> --
> Marcus Bointon
> Synchromedia Limited: Putting you in the picture
> marcussynchromedia.co.uk | http://www.synchromedia.co.uk
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Sun, November 13, 2005 4:55 pm, Todd Cary wrote:
> Because this was just a test of what will be many "print" lines. The
> original application used a file to hold the data and upon request by
> the user, it was emailed. But with my client's shared server, files
> cannot be opened...a pain.
>
> If you have a better solution, I am open to other ideas.

Switch hosts?
:-^

PS
I'll say it again:
Content-disposition will give you grief from older browsers.
Content-type: application/octet-stream will "just work"

To get the filename default prompt, tack the filename onto the end of
your URL.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Dan Rossi wrote:
> Personally, i am trying to avoid all these frameworks until
> everyones ideas are collabroated into one as i think they only work for
> some or for the developers purposes only.

What features do you need from a framework?

attached mail follows:


Greetings all,

I have a question.
I want to display a group of records pulled form a MySQL db in the following
fashion.

1 6
2 7
3 8
4 9
5 10

Now I can easily figure out how to display the records as

1 2
3 4
5 6
7 8
9 10

But since I am in an HTML table and the need to display the <TR> and </TR> I
am not sure how to make th logic so that I can get the first listing. Can
anyone help me out?? Need more information??

Thanks

Phillip

attached mail follows:


>
> I have a question.
> I want to display a group of records pulled form a MySQL db
> in the following
> fashion.
>
> 1 6
> 2 7
> 3 8
> 4 9
> 5 10
>
> Now I can easily figure out how to display the records as
>
> 1 2
> 3 4
> 5 6
> 7 8
> 9 10
>
> But since I am in an HTML table and the need to display the
> <TR> and </TR> I
> am not sure how to make th logic so that I can get the first
> listing. Can
> anyone help me out?? Need more information??

You could load up an array with your result set:

$records=array();
$rownum=0;
while ($row=mysql_fetch_array($result)){
  $rownum++;
  records[$rownum]=$row['data'];
}

...then use $rownum/2 to determine the second column:

for ($i==1;$i<=$rownum/2;$i++){
  $col1=$i;
  $col2=$i+($rownum/2);
  echo "<tr>$record[$col1]</tr>";
  echo "<tr>$record[$col2]</tr>";
}

There are probably much better ways to do this, but this is a start.

JM

attached mail follows:


Depending on how strict your requirements are for the table layout, you could always do something like this:

<tr>
  <td>
    Item 1<br>
    Item 2<br>
    Item 3<br>
    Item 4<br>
    Item 5
  </td>
  <td>
    Item 6<br>
    Item 7<br>
    Item 8<br>
    Item 9<br>
    Item 10
  </td>
</tr>

Each item isn't in it's own <TD>, but if they don't have to be, then that could be a solution.

Or, as someone else mentioned I believe, you could pre-load the results into another array structured how you want it to be.

Depending on the specifics, there are probably other methods.

-TG

= = = Original message = = =

Greetings all,

I have a question.
I want to display a group of records pulled form a MySQL db in the following
fashion.

1 6
2 7
3 8
4 9
5 10

Now I can easily figure out how to display the records as

1 2
3 4
5 6
7 8
9 10

But since I am in an HTML table and the need to display the <TR> and </TR> I
am not sure how to make th logic so that I can get the first listing. Can
anyone help me out?? Need more information??

Thanks

Phillip

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

attached mail follows:


On Mon, November 14, 2005 1:03 pm, Phillip S. Baker wrote:
> Greetings all,
>
> I have a question.
> I want to display a group of records pulled form a MySQL db in the
> following
> fashion.
>
> 1 6
> 2 7
> 3 8
> 4 9
> 5 10
>
> Now I can easily figure out how to display the records as
>
> 1 2
> 3 4
> 5 6
> 7 8
> 9 10
>
> But since I am in an HTML table and the need to display the <TR> and
> </TR> I
> am not sure how to make th logic so that I can get the first listing.
> Can
> anyone help me out?? Need more information??

$col = 0;
$row = 0;
$count = mysq_numrows($result);
$half_count = floor($count/2); //use ceiling to get "widow" on right
while (list($number) = mysql_fetch_row($result)){
  $table[$row][$col] = $number;
  $row++;
  if ($row == $half_count) $col++;
}
echo "<table>\n";
foreach($table as $row){
  echo "\t<tr>\n";
  foreach($row as $number){
    echo "\t\t<td>$number</td>\n";
  }
}
echo "</table>\n";

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


First of all - remember results display in a web browser, and if you want
to print these you will get results that are not like a normal printed page.

Second - here's an approach. Dump all records into an array, you'll have
the record count, then selectively fetch elements according to how you
want them displayed. Here's a rough approximation.

i = 1
col_lgth = 5
until i = 1+col_lgth+i
         tr td
                 arr[i]
         /td td
                 arr[ i + col_lgth ]
         /td /tr
         i ++
and keep on looping. You'll have to work out something for odd-numbered
result sets, which will not give you a balanced column.

Others may have more sophisticated displays, a CSS guru could probably do
something tricky.

I do not think you can access the $result value returned by any of the
queries with an index.

HTH - Miles

At 03:03 PM 11/14/2005, Phillip S. Baker wrote:
>Greetings all,
>
>I have a question.
>I want to display a group of records pulled form a MySQL db in the following
>fashion.
>
>1 6
>2 7
>3 8
>4 9
>5 10
>
>Now I can easily figure out how to display the records as
>
>1 2
>3 4
>5 6
>7 8
>9 10
>
>But since I am in an HTML table and the need to display the <TR> and </TR> I
>am not sure how to make th logic so that I can get the first listing. Can
>anyone help me out?? Need more information??
>
>Thanks
>
>Phillip
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


On Sat, November 12, 2005 2:33 pm, bruce wrote:
> anybody know of any php/linux/apache user groups in the east bay
> (dublin/pleasanton/san ramon/etc...) area?
>
> need to join one to find other like minded php/linux guys who are into
> developing..

You have to do some weeding, but this is pretty extensive:
http://phpusergroups.org

If you find a group that's not in there, get them to add themselves.

If you don't find a group, just start one!

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Sat, November 12, 2005 10:29 am, Gustavo Narea wrote:
> - AFAIK, there are 3 versions of the Standard SQL (1993, 1999 and
> 2003), but, Which one am I going to need for this test?

I think it would be best to focus on SQL 92 because:

A) It's unlikely that a significant number of Zend Cert questions
would be THAT picuyane to depend on SQL99 (?) or SQL03 (??)

B) Most db platforms haven't even caught up to SQL92 yet, not fully.
They're all "close" but none are "done".
So you may miss a question or two because of the difference between
reality and the Cert test question, but you won't miss a whole bunch
of them.

> - Should I learn to use another HTTP server?

HTTP server?

It might be good to play with PHP on a Windows box, just to see what
it's like... Not with IIS, though, as that's just TOO painful :-)

There are enough differences there to stretch your mind a bit, and to
get a better picture of how it all fits together, without driving you
crazy.

Another SQL server would probably be even more useful.

PostgreSQL is probably the easiest (and certainly the cheapest) to try
from a MySQL background. And PostgresQL is picky enough that all the
bad habits you picked up in MySQL will get corrected pretty
quick-like. :-)

PS MySQL 5 has settings that allow it to be more standard, and that's
a Good Thing (tm) imho.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Hi, Richard.

Richard Lynch wrote:
> On Sat, November 12, 2005 10:29 am, Gustavo Narea wrote:
>
>> - AFAIK, there are 3 versions of the Standard SQL (1993, 1999 and
>>2003), but, Which one am I going to need for this test?
>
>
> I think it would be best to focus on SQL 92 because:
>
> A) It's unlikely that a significant number of Zend Cert questions
> would be THAT picuyane to depend on SQL99 (?) or SQL03 (??)
>
> B) Most db platforms haven't even caught up to SQL92 yet, not fully.
> They're all "close" but none are "done".
> So you may miss a question or two because of the difference between
> reality and the Cert test question, but you won't miss a whole bunch
> of them.

Yes, I am going to take that into account.

By the way, I was wrong: There are more than 3 versions of this
standard; according wikipedia there are five.

>> - Should I learn to use another HTTP server?
>
>
> HTTP server?
>
> It might be good to play with PHP on a Windows box, just to see what
> it's like... Not with IIS, though, as that's just TOO painful :-)

Good ;-), I spent a couple of years using PHP on Window$ (with Apache)
before switching to GNU/Linux a few months ago.

> Another SQL server would probably be even more useful.
>
> PostgreSQL is probably the easiest (and certainly the cheapest) to try
> from a MySQL background. And PostgresQL is picky enough that all the
> bad habits you picked up in MySQL will get corrected pretty
> quick-like. :-)

That's a good reason for me to learn PostgreSQL!

Thanks you so much, Richard.

Regards.
--
Gustavo Narea.
PHP Documentation - Spanish Translation Team.
Valencia, Venezuela.

attached mail follows:


On Fri, November 11, 2005 9:33 pm, Bruce Gilbert wrote:
> $headers = "From: $sender";
> $headers .= "Reply-To: $reply_to";
> $headers .= "Return-Path: $return_path";

> $headers .= "X-Sender: $x_sender";
> $headers .= "X-Mailer: PHP4\n"; //mailer

These two may trip some spam filters.

> $headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal

Setting this at all probably trips a few spam filters.

> $headers .= "Mime-Version:1.0\n Content-Type: text/plain;
> charset=\"iso-8859-1\nContent-Transfer-Encoding: 8bit\n";
>
> mail( $recipient, $subject, stripslashes($message), $headers );

Check the return error code!!!
http://php.net/mail

> sleep(1);

Just how many emails are you trying to send with mail()?

http://php.net/mail was never designed for heavy-volume lists...

Look into http://phpclasses.org for something that WAS designed to
handle the volume you need.

> }
>
> // run second query to automatically dump unsubscribed email
> addresses.

> $query2 = "
> DELETE FROM
> mailinglist
> WHERE
> subscribe='0'
> AND
> confirmed='0' ";
>
> //run the query
> mysql_query($query2, $link) or die (mysql_error());

Dude, if I unsubscribed, get me off the list *BEFORE* you send out
another email, not after.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Fri, November 11, 2005 9:12 pm, Imroz wrote:
> Hi PHP Gurus
> Am new to the php world, I need help to do something. PlZzzzzz help
>
> I have this link HYPERLINK
> "http://www.taximauritius.mu/link1.php"http://www.taximauritius.mu/link1
> ..php.
>
> What I want to do :
>
> When clicking on the link above, that would bring me to a page
> HYPERLINK
> "http://www.taximauritius.mu/reservation.php?client=apartment1"http://ww
> w.taximauritius.mu/reservation.php?client=apartment1, and in this URL,
> as can be seen, there is a variable called apartment1.
>
> I want to get the name of this variable + other form fields in my
> email
> message when the form is sent. Actually I do get the other form fields
> in my email message. I just don’t get the variable (client=apartment1)
>
> Am attaching the codes, It would really be grateful if you could plzzz
> help me.

Read the PHP FAQ on http://php.net/faq about processing all POST values.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Fri, November 11, 2005 7:09 pm, Bagus Nugroho wrote:
> I have session code which written WindowsXP and It wotk properly as
> expected, but when I'm used in Windows 2K, it got error as;
> Notice: Undefined index: loginMessage in
> C:\CentralData\forms\mainForm.php on line 65
> I'am used Apache 2.0 and PHP 5.0.4.
> Is php.ini setting on W2K different with XP

The difference is you have:
E_ALL
on the Win 2K box, and:
E_ALL ~ E_NOTICE
on the XP box.

The bug is in your code in BOTH cases, but the message is being
suppressed by php.ini on the XP box.

Fix your code is the best answer.

Changing E_ALL to just E_ALL ~ E_NOTICE is a distant second.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Fri, November 11, 2005 6:59 pm, Jasper Bryant-Greene wrote:
> GamblerZG wrote:
>> What is the purpose of sessions extension?
>>
>> The reason I ask is because learning to deal with all its functions,
>> ini
>> options and quirks took me _much_ more time than writing pure-php
>> replacement. (That is, without using session_set_save_handler().)
>
> I realise that yours might be a special case, but for most situations
> I
> have only had to do session_start() and then simply used $_SESSION as
> if
> it were any other array with the simple difference that it persists
> across requests. When done with the session, use session_destroy() if
> you feel the need.
>
> I'm not sure how that could be harder than writing a pure-PHP
> replacement for the session extension...

The FIRST time one uses PHP session_start() et al, it tends to be a
lot of wading through and taking the wrong path and...

Once you figure out that you need:
<?php
  session_start();
?>
at the top of every page, and to just read/write session data with:
$_SESSION
it gets real easy.

But it ain't easy the first time.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


In my office we found it to be quite quick and easy to write a library
which uses PHP session extensions to store all session data into a
database (we work in a load balanced environment). We found this to be
the best method of dealing with this because we did not need to deal
with generating unique session id's or identifying when a session has
expired thus reducing code complexity and the DB load.

Carlo Razzeto
Programmer
Mortgage Information Services
Phone: (216) 514-1025 ex. 1212
-----Original Message-----
From: Richard Lynch [mailto:ceol-i-e.com]
Sent: Monday, November 14, 2005 3:18 PM
To: Jasper Bryant-Greene
Cc: GamblerZG; php-generallists.php.net
Subject: Re: [PHP] What is the purpose of sessions extension?

On Fri, November 11, 2005 6:59 pm, Jasper Bryant-Greene wrote:
> GamblerZG wrote:
>> What is the purpose of sessions extension?
>>
>> The reason I ask is because learning to deal with all its functions,
>> ini
>> options and quirks took me _much_ more time than writing pure-php
>> replacement. (That is, without using session_set_save_handler().)
>
> I realise that yours might be a special case, but for most situations
> I
> have only had to do session_start() and then simply used $_SESSION as
> if
> it were any other array with the simple difference that it persists
> across requests. When done with the session, use session_destroy() if
> you feel the need.
>
> I'm not sure how that could be harder than writing a pure-PHP
> replacement for the session extension...

The FIRST time one uses PHP session_start() et al, it tends to be a
lot of wading through and taking the wrong path and...

Once you figure out that you need:
<?php
  session_start();
?>
at the top of every page, and to just read/write session data with:
$_SESSION
it gets real easy.

But it ain't easy the first time.

--
Like Music?
http://l-i-e.com/artists.htm

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

Disclaimer: This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message. Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited.

attached mail follows:


On Fri, November 11, 2005 5:18 pm, Chris Shiflett wrote:
> Richard Lynch wrote:
>> Suppose PHP had a superglobal $_CLEAN which was an empty array.
>
> This seems like a decent idea, for two reasons:
>
> 1. Developers don't have to remember to initialize their array, which
> offers some protection. PHP can do this for them.
>
> 2. Variable scope issues are not a concern. Currently, using this
> technique within functions and classes is clumsy at best.
>
> However, most security issues like XSS and SQL injection aren't really
> input filtering problems. Often, input filtering can effectively
> eliminate these vulnerabilities (and there's no excuse to not be
> filtering input), but escaping addresses the root cause of the
> problem.

It's certainly not a magic bullet.

But I think it would help a lot of newbies get set on the right path
from the get-go, of thinking about security from "Hello World" instead
of trying to graft Security onto their 30,000 line forum after it gets
nailed by bad guys.

The residual effects are, hopefully, bigger than the direct benefit.

If a good way to escape OUTPUT was also incorporated, that would be
even better.

But just getting folks THINKING about this kind of stuff from Day One
of their PHP scripting would make a big difference.

Perhaps one should use:
$_ICLEAN
$_OCLEAN
for Input and Output.

$kosher = '/[^A-Za-z0-9\\',\\.-]/';
$_ICLEAN['first_name'] = preg_replace($kosher, '', $_GET['first_name'];
/* more code */
$_OCLEAN['first_name'] = htmlentities($_ICLEAN['first_name']);
echo "<p>$_OCLEAN[first_name] is way smarter than me.</p>\n";

If you had anything other than $_OCLEAN in an echo and friends, then
you would know you were screwing up.

I really think it's important for the PHP community to push towards
safer practices at the most basic levels.
Examples in the manual, textbooks, etc.

If everybody knew $_ICLEAN and $_OCLEAN meant data cleaned from input
or data cleaned for output, then one could simply use them in examples
instead of $_GET or $data.

I'm not sure we can (or even should) go as far as Perl's tainted mode,
but I think setting the right example and having an infrastructure to
"do it right" would be a Good Thing.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


According to the php docs, the method DomDocument->getElementById() will
not work unless the document is validated using a DTD (not schema):

"According to the DOM standard this requires a DTD which defines the
attribute ID to be of type ID. You need to validate your document with
DOMDocument->validate() or DOMDocument->validateOnParse before using
this function."

I cannot use a schema in ordet to "activate" DomDocument->getElementById()?

/Erik

attached mail follows:


I have run into this behavior on several sites:

$dom->validate('books.dtd');

But according to the docs, the method it is defined

class DOMDocument {

bool validate ( void )

}

Is the dtd (file?) parameter deprecated?

/Erik

attached mail follows:


> I have run into this behavior on several sites:
>
> $dom->validate('books.dtd');
>
> But according to the docs, the method it is defined
>
> class DOMDocument {
>
> bool validate ( void )
>
> }
>
> Is the dtd (file?) parameter deprecated?
>
> /Erik
>

Just tested, $dom->validate('books.dtd') generates the warning
"DOMDocument::validate() expects exactly 0 parameters, 1 given in ..."

/Erik

attached mail follows:


On Fri, November 11, 2005 2:27 pm, Daevid Vincent wrote:
> I have a feature request (and I'm a bit disappointed that this isn't
> already
> in the DOMDocument, when there are nearly useless methods like
> "normalize()")... Ruby has this built in. xmllint has the --format
> parameter. But yet PHP's DOMDocument has no way of cleaning up the
> code.
>
> Could someone please make a method in PHP v5.x to format the XML.
> After
> adding/deleting nodes, the XML gets fairly messy. Ideally it would
> have an
> offset character position to start the indent (default of 0 or left
> margin),
> and a parameter for how many spaces to use for each indentation
> (default of
> say 4 or 5 (same as a tab)).
>
> You could just make this optional parameters to saveXML(), but I think
> it's
> more flexible to have a DOMDocument->format(offset,spaces);

It might be easy to run your XML through XMLTidy somehow...

--
Like Music?
http://l-i-e.com/artists.htm