php-general Digest 15 May 2005 06:53:47 -0000 Issue 3455

Topics (messages 215236 through 215252):

Re: DOMDocument and html doctype
        215236 by: Jared Williams
        215237 by: Johannes Findeisen
        215239 by: Brian V Bonini
        215240 by: Brian V Bonini

Re: Repost: mod_rewirte loses POST data
        215238 by: Bart Seresia

Re: using require
        215241 by: Leif Gregory
        215242 by: James Williams
        215243 by: James Williams
        215246 by: Richard Lynch

Re: Finding current PHP sessions
        215244 by: Bogdan Stancescu

Re: CASE tool
        215245 by: Manuel Lemos

Re: why are session only working with cookies?
        215247 by: Richard Lynch

Re: Shopping Cart, security concerns
        215248 by: Richard Lynch

Re: Same sessions / different domains
        215249 by: Richard Lynch

Auslaender bevorzugt
        215250 by: thies.digicol.de

Re: [thelist] SEO
        215251 by: Richard Lynch

Re: changing php ini location
        215252 by: disguised.jedi.gmail.com

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 ---
> 
> On Sat, 2005-05-14 at 07:57, Jared Williams wrote:
> >  > Hi,
> > > I've used loadHTML() to read a HTML file to DOM. This file starts 
> > > with a string like <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 
> > > Transitional//EN">
> > > 
> > > Do someone know how I can access this string? By reading 
> the doctype 
> > > back from DOMDocument I only found the name (HTML) but nothing 
> > > more...
> > > 
> > 
> >     Use $document->doctype, its DOMDocumentType object..
> >  
> 
> That's part of DOM XML isn't it? I think he's referring to 
> the newer DOM extension since 'loadHTML() is cited...???
> 

I was referring to the new PHP5 DOM extension.

Jared

--- End Message ---
--- Begin Message ---
On Saturday 14 May 2005 16:25, Brian V Bonini wrote:
> <?php
>
> $html = <<<EOS
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html><body>Test<br></body></html>
> EOS; Â
>
> $pattern = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
> Transitional//EN">';
>
> $doc = new DOMDocument();
> $doc->loadHTML($html);
> preg_match($pattern, $doc->saveHTML(), $matches);
> echo '&lt;' . $matches[0] . '&gt;';
>
> ?>

Well, that ist a very crazy idea...

If Claudio knows the doctype allready, he not needs to access this doc type 
string. A preg_match is the wrong function at this place or will you write a 
switch/case block that knows every doctype definition?

This only is usefull to see if the string exists or not.

Regards
-- 
Johannes Findeisen

--- End Message ---
--- Begin Message ---
On Sat, 2005-05-14 at 16:08, Johannes Findeisen wrote:
> On Saturday 14 May 2005 16:25, Brian V Bonini wrote:
> > <?php
> >
> > $html = <<<EOS
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> > <html><body>Test<br></body></html>
> > EOS;  
> >
> > $pattern = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
> > Transitional//EN">';
> >
> > $doc = new DOMDocument();
> > $doc->loadHTML($html);
> > preg_match($pattern, $doc->saveHTML(), $matches);
> > echo '&lt;' . $matches[0] . '&gt;';
> >
> > ?>
> 
> Well, that ist a very crazy idea...
> 
> If Claudio knows the doctype allready, he not needs to access this doc type 
> string. A preg_match is the wrong function at this place or will you write a 
> switch/case block that knows every doctype definition?
> 
> This only is usefull to see if the string exists or not.

I'm sorry, I missed your solution, what was it again?

He said "Do someone know how I can access this string?" There it is,
"THAT" string is now in $matches[0]; Do what you want with it from
there. Otherwise set pattern to a regex and search for similar strings
if the search pattern is not EXACTLY that.

--- End Message ---
--- Begin Message ---
On Sat, 2005-05-14 at 13:03, Jared Williams wrote:
> > 
> > On Sat, 2005-05-14 at 07:57, Jared Williams wrote:
> > >  > Hi,
> > > > I've used loadHTML() to read a HTML file to DOM. This file starts 
> > > > with a string like <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 
> > > > Transitional//EN">
> > > > 
> > > > Do someone know how I can access this string? By reading 
> > the doctype 
> > > > back from DOMDocument I only found the name (HTML) but nothing 
> > > > more...
> > > > 
> > > 
> > >   Use $document->doctype, its DOMDocumentType object..
> > >  
> > 
> > That's part of DOM XML isn't it? I think he's referring to 
> > the newer DOM extension since 'loadHTML() is cited...???
> > 
> 
> I was referring to the new PHP5 DOM extension.

OOppps, there it is, tabel 3 on the first page of the DOM section in the
manual... I swear it wasn't there earlier.. ;-)

--- End Message ---
--- Begin Message ---
Evert from collan thouht it wy have to do with the rewrite rules or the 
script and asked to post both of them

this are the rewrite rules i use:

     RewriteEngine On
     RewriteRule ^/(.*[^/])/Admin/(.*)$ https://my.domain.com/$1/Admin/$2 
[R,L,NS]
     RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d [OR]
     RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f
     RewriteRule ^(.*)$ - [L,NS]
     RewriteCond %{QUERY_STRING} !^$
     RewriteRule ^/(.*)/(.*)/$ 
/index.php?shopid=$1&page=$2&%{QUERY_STRING} [L,NS]
     RewriteRule ^/(.*)/(.*)/$          /index.php?shopid=$1&page=$2 
[L,NS]
     RewriteCond %{QUERY_STRING} !^$
     RewriteRule ^/(.*)/$               /index.php?shopid=$1&%{QUERY_STRING} 
[L,NS]
     RewriteRule ^/(.*)/$               /index.php?shopid=$1 
[L,NS]

He also suggested it might be the fault of the php scripting: this is what i 
do:

  if (isset($_GET["page"]))
    switch (strtolower($_GET["page"]))
    {
// snip //
      break;
     case "basket":
      echo "<pre>\n";
      var_dump(get_defined_vars ());
      echo "</pre>\n";
      include("includes/basket.inc.php");

in IE i get this output for post and get:

array(18) {
  ["HTTP_POST_VARS"]=>
  array(0) {
  }
  ["_POST"]=>
  array(0) {
  }
  ["HTTP_GET_VARS"]=>
  array(2) {
    ["shopid"]=>
    string(3) "wsn"
    ["page"]=>
    string(6) "Basket"
  }
  ["_GET"]=>
  array(2) {
    ["shopid"]=>
    string(3) "wsn"
    ["page"]=>
    string(6) "Basket"
  }
// snip //

Am i doing something wrong?

"Bart Seresia" <[EMAIL PROTECTED]> schreef in bericht 
news:[EMAIL PROTECTED]
> Hi,
>
> I'm currently developing a webapplication that uses mod_rewrite.
>
> At some point i have to post data but i't seems to get lost, checking the 
> web and some archives i've found that normaly mod_rewrite should preserver 
> this data, but apparently it doesn't. Could anyone help me?
>
> Im using:
> Apache/2.0.52 (Unix) mod_ssl/2.0.52 OpenSSL/0.9.7b PHP/4.3.11 Server at 
> host.mydomain.com Port 80 

--- End Message ---
--- Begin Message ---
Hello Cima,

Friday, October 14, 2005, 12:33:57 PM, you wrote:
C> any info will be highly appreciated!!

The easiest way to handle this is to set a session variable once
they're authenticated and on all your pages you have something like
this:

session_start();

if (!$_SESSION['isAuthenticated'] == "Yeppers")
   include('auth.php');

IIRC you have to use include() vs. require() because a require()
would force auth.php regardless of the outcome of the if statement.
I'm pretty sure I remember reading this somewhere, but I could be
wrong.

By using the session variable you only force an auth for people who
already haven't authenticated.

If you're not familiar with sessions, the key thing to remember is you
need to do a session_start(); somewhere in the page prior to reading
or writing session variables.

Cheers,
Leif Gregory 

-- 
TB Lists Moderator (and fellow registered end-user)
PCWize Editor  /  ICQ 216395  /  PGP Key ID 0x7CD4926F
Web Site <http://www.PCWize.com>

--- End Message ---
--- Begin Message ---
On 10/14/05, Cima <[EMAIL PROTECTED]> wrote:
> hi all,
> 
> i have my web site working something like this: in every php script i have 
> require(auth.php). this auth.php has my connection to my postgresql server 
> and database along with some other stuff i need for the user to be 
> authenticated to my web site. when i log on, this auth.php connects to the 
> dbserver and checks if my username and password are stored and then i go to a 
> home page. my connection is stored in $dbh.
> what happens when i start moving through all these web pages (php scripts), 
> each requires auth.php, with respect to the connection? is a new connection 
> established for every web page i go into that uses my $dbh for querying 
> purposes or is it the same connection i originally made when i first logged 
> into the web site?
> 
> any info will be highly appreciated!!
> 
> thanx.
> 


-- 
jamwil.com

--- End Message ---
--- Begin Message ---
On 5/14/05, James Williams <[EMAIL PROTECTED]> wrote:
> On 10/14/05, Cima <[EMAIL PROTECTED]> wrote:
> > hi all,
> >
> > i have my web site working something like this: in every php script i have 
> > require(auth.php). this auth.php has my connection to my postgresql server 
> > and database along with some other stuff i need for the user to be 
> > authenticated to my web site. when i log on, this auth.php connects to the 
> > dbserver and checks if my username and password are stored and then i go to 
> > a home page. my connection is stored in $dbh.
> > what happens when i start moving through all these web pages (php scripts), 
> > each requires auth.php, with respect to the connection? is a new connection 
> > established for every web page i go into that uses my $dbh for querying 
> > purposes or is it the same connection i originally made when i first logged 
> > into the web site?
> >
> > any info will be highly appreciated!!
> >
> > thanx.
> >

A new connection will be established to the database for every time
you run auth.php
-- 
jamwil.com

--- End Message ---
--- Begin Message ---
On Fri, October 14, 2005 11:33 am, Cima said:
> i have my web site working something like this: in every php script i have
> require(auth.php). this auth.php has my connection to my postgresql server
> and database along with some other stuff i need for the user to be
> authenticated to my web site. when i log on, this auth.php connects to the
> dbserver and checks if my username and password are stored and then i go
> to a home page. my connection is stored in $dbh.
> what happens when i start moving through all these web pages (php
> scripts), each requires auth.php, with respect to the connection? is a new
> connection established for every web page i go into that uses my $dbh for
> querying purposes or is it the same connection i originally made when i
> first logged into the web site?

You'll get a new connection on each page.

Which is good, because database connections CANNOT be shared across page
hits.

If you use _pconnect, you can get a "refurbished" connection from the
database instead of a truly new one.  But there are "gotchas" with that,
and I wouldn't recommend you jump into that without a lot more
research/experience.

I would suggest, however, that you put the database connection in a
totally separate file from the auth.php, and require them separately.

You may find more uses for your database some day, maybe even for pages
that do NOT require authentication, and you'll more easily do that if you
can just do:
<?php require 'db_connect.php';?>

For the pages that need authentication, you'd do:
<?php
  require 'db_connect.php';
  require 'auth.php';
?>

You could also look into http://php.net/require_once, but I tend to find
that people who start off with that end up being sloppy coders and end up
having a whole rats' nest of includes with no real Plan behind them, which
cause problems in the long run.  Just my opinion, and I'm bound to take
flak for it.

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

--- End Message ---
--- Begin Message --- Marek Kilimajer wrote:
Bogdan Stancescu wrote:

Ok, I went with the solution you recommended, by the way of a "thank you" to the list, here's the resulting function:

/**
* This function returns the IDs of the current PHP sessions.
* At this time, it only works with
* [EMAIL PROTECTED] http://www.php.net/manual/en/ref.session.php#AEN129461}
* PHP session.save_handler='files'
*
* @author Bogdan Stancescu
* @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
*
* @return mixed false on error or the indexed array of the session IDs;
* please note that the session IDs are 16-bit values represented as


16-bit. That's not very secure ;) Should be 256-bit

*   32-character long hexadecimal strings; letters are in lower caps.
*/

True, that should've read "16 byte", documentation error -- thanks for pointing it out!


Cheers,
Bogdan

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

on 05/14/2005 10:49 AM Krid said the following:
can anybody here tell me if there is a (open souce) CASE tool which supports PHP code generation? I could not find anything like this yet.
What's the best way designing PHP applikations? I guess anybody knows a whitepaper or tutorial URI ?!

You may want to take a look at Metastorage. This is a CASE tool that generates code for data access object classes based on an high level definition in a XML format (CPML) of a model of your application persistent objects.


You just define your classes in CPML, with variables, validation rules, relationships and functions to manipulate the objects of such classes and Metastorage generates classes that perform Object Relational Mapping (ORM) to store persistent objects in a relational database using SQL.

http://www.meta-language.net/metastorage.html

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

--- End Message ---
--- Begin Message ---
On Sat, May 14, 2005 7:49 am, Brian V Bonini said:
> On Fri, 2005-05-13 at 23:31, Jason Wong wrote:
>> On Saturday 14 May 2005 09:42, Brian V Bonini wrote:
>>
>> > Yeah, I know session support is there and I DO NOT have it set to use
>> > ONLY cookies. But if I disable cookies in the browser stuff relying on
>> > sessions stops working. I'm using 5.0.3
>>
>> > session.use_trans_sid
>> > 0
>> > 0
>>
>> Set that to 1. Sessions *are* cookies, they're cookies that have been
>> set
>> to expire when the browsing session finishes (ie when the browser is
>> closed).
>
> I thought the idea was; cookies if available otherwise the session data
> gets serialized and propagated in the URL? The later of which appears to
> not work, for me, if applicable....

Sessions are *NOT* cookies.  PHP sessions use *A* Cookie to maintain state
-- specifically to indentify a singe user/browser on repeat HTTP
connections.

The session *data* is not going to be transmitted in the URL -- Only the
Cookie name/value pair will go in the URL.

Using Cookies, or using URL, the session DATA will be stored on the server
in /tmp files -- Unless you change php.ini to store them somewhere else,
in which case, again, the Cookie and URL only holds the ID and all the
data goes wherever you store it:  database, shared memory, or an army of
elves for all PHP cares.

If trans_sid is "not working" for you, let's narrow this down:

If you do this:
<?php
  session_start();
  echo "<a href=\"yourdomainnamehere.com\">click me</a><br />\n";
?>

Do you see something like "?PHPSESSID=a847hjfu3734hgfjgurur" tacked on to
the end of the URL?

If not, trans_sid is NOT enabled.

Did you restart Apache?

Did you turn *OFF* Cookies?  If PHP *can* use Cookies, I think it's gonna
use Cookies, and not bother with the trans_sid stuff, though maybe it
always puts it there.  I never really dived into that.  To be certain,
though, turn off Cookies in php.ini and/or in your browser.

Re-start Apache for your php.ini changes to kick in.

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

--- End Message ---
--- Begin Message ---
On Sat, May 14, 2005 6:30 am, mayo said:
> I have to say it's a pretty simple project. The don't want to keep any
> information in a db. (!!??!!) Info will be sent to a merchant services
> account and to the distributor which will process the form.
>
> Info will be kept in hidden fields <input type="hidden" ...> and in
> session variables then sent off.

Don't put anything you *NEED* to be correct/accurate in type="hidden"

The web surfer can *CHANGE* that in about 5 seconds and send whatever they
want.

All your prices, all you shipping costs, all the weights, etc had better
be in your PHP source code, as arrays, I guess...

You'd really be better off just using a database with an existing cart.

The amount of code you'll have to write to do this correctly is insane.

> They have three products (it may rise to 5) and everything will be
> hardcoded  as there are no size or color variations. I told them that
> it's not advisable to have everything hardcoded but the client insists
> there is no reason to pull anything from a database. The on-site
> graphics/web designer person will make the changes. He is competent to
> do that and did a good job with the basic design.

But you CANNOT put your prices in type="hidden" fields!!!

That's EXACTLY how you get a shopping cart where the user changes the price!

> This is not my very first foray into PHP but first time doing something
> more complicated than
>
> 1. if person has this permission then show A else show B
>
> or
>
> 2. if person is on page 1 then show page 1 as bold else show page 1 as
> normal

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

--- End Message ---
--- Begin Message ---
On Sat, May 14, 2005 4:45 am, mbneto said:
> They are in the same machine. My major concern is with security and
> the hability to make sure if a user logs in, or adds something to a
> "shopping cart" in one domain it will be available to the other
> domain.
>
> Can I set call setCookie twice with the same variable name but
> different domain ?  I could set the sessionid and call session_start
> with the propagated id when/if a user crosses from one domain to
> another.

No, you can't call setcookie with a domain name AT ALL.

If you could, what would stop you from setting Cookies for *my* site?  Or
msn.com?  Or Sothebys.com?  Then you could just take all their customers'
money, and not need to worry about your own shopping cart.

If you want to transfer Cookies from two domains you control, it's up to
you to do that with your own hack.

It would make a lot more sense to just put all the shopping on one domain,
or have different carts for two domains.

It's more than a little odd to have the same cart on two sites from a user
perspective...  Something that's likely to confuse customers, and make
them think your site is insecure if you can't even keep your shopping cart
confined to one site.

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

--- End Message ---
--- Begin Message ---
Lese selbst:
http://www.npd.de/npd_info/deutschland/2005/d0305-14.html

Jetzt weiss man auch, wie es dazu kommt, dass Drogen, Waffen & Handy's in die 
Haende der Knacki's gelangen!

--- End Message ---
--- Begin Message ---
On Sat, May 14, 2005 12:25 am, [EMAIL PROTECTED] said:
>> For example:
>>
>> mysite/sweaters/
>>
>> (I think) is better than:
>>
>> mysite/index.php?section=1&content=23&style=5.
>
> It's more usable I guess. What handles that though? I'm finding it
> hard to organise the back end of that in my head.
>
> I don't think there's any way around that ending up looking for an
> index file in the sweaters directory. So then you're ending up with
> lots of index files. Maybe they could redirect to the one program that

That's where you are wrong. :-)

'sweaters' isn't a directory.

It's not even a file.

It's a URL.

The file that *handles* that URL is index.php

You do NOT have a one-to-one mapping from URL to file, nor even from what
looks like a directory to a URL.

Consider these pages:
http://uncommonground.com/artist_profile/Ellen+Rosner
http://uncommonground.com/artist_profile/gray
http://uncommonground.com/artist_profile/TRAIN
http://uncommonground.com/artist_profile/David+Gray

You don't think I build 2000 of those things, do you?

artist_profile is the PHP script.

It tears apart $_SERVER['PATH_INFO'] and figures out which artist you
want, or gives you a list to choose from if more than one matches.

Another most excellent example of this kind of thing can be found all over:
http://cdbaby.com/

Every URL you surf to there is really a PHP script.  I dunno which ones
he's got in actual directories, and which ones are actually PHP scripts,
but I don't care.  I can remember the URL, which is all I, as the user,
cares about.

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

--- End Message ---
--- Begin Message ---
On 5/14/05, emre <[EMAIL PROTECTED]> wrote:
> i am not using apache 2.0
/*
Why aren't you?  Apache 2.0 is your best bet.  It really is the best
one available!
*/
> as i mentioned before i am using apache 1.3 which means that i dont have the
> oppurtunity to use phpnidir config parameter. since apache 1.3 doesnt
> support that.
> 
>  i cannot compile php neither,  since i m using a php precompiled windows
> edition.
/*
It sure sounds like you are out of luck.  Your only option is to get
Apache 2.0 and use that directive.  Can I ask why in the world you are
doing this?  Are you aware you can change almost any option in php.ini
in your script with the ini_set function?

http://www.php.net/ini_set
*/

-- 
[EMAIL PROTECTED]

PHP rocks!
"Knowledge is Power.  Power Corrupts.  Go to school, become evil"

Disclaimer: Any disclaimer attached to this message may be ignored. 
However, I must say that the ENTIRE contents of this message are
subject to other's criticism, corrections, and speculations.

This message is Certified Virus Free

--- End Message ---

Reply via email to