php-general Digest 14 Sep 2003 00:36:26 -0000 Issue 2295

Topics (messages 162494 through 162532):

Re: problems and segmentation fault with constants in PHP5
        162494 by: Cristiano Duarte

Whats wrong?
        162495 by: Stevie D Peele
        162496 by: Ryan A
        162497 by: Sid
        162519 by: esctoday.com | Wouter van Vliet

Re: Displaying Blobs by a newbie
        162498 by: Phil King
        162500 by: Curt Zirzow

For Loops and Variables??
        162499 by: John Ryan
        162501 by: Curt Zirzow

Re: PHP on a .NET enviroment machine: Conflicts?
        162502 by: Curt Zirzow

Re: Calling functions from Button actions
        162503 by: Daniel Souza

Re: loading classes and efficiency
        162504 by: Curt Zirzow
        162521 by: Brad Pauly

Re: Mysql Authentication problem
        162505 by: Curt Zirzow

Using Image/GD functions to transform images stored in database
        162506 by: weston.leary.csoft.net
        162509 by: Jason Wong

Repost - Cookie advice
        162507 by: James Johnson

Re: caching program...
        162508 by: Curt Zirzow

square brackets in form names violate HTML specs?
        162510 by: Eugene Lee
        162513 by: Curt Zirzow
        162523 by: Eugene Lee

Re: PEAR DB flipped fetch mode
        162511 by: Curt Zirzow

Re: Header and dfile download bug???
        162512 by: Curt Zirzow

Re: Looking for a real good editor with some specific featrues ...
        162514 by: Curt Zirzow

htmlentities() and the macintosh character set
        162515 by: Michael Winston
        162522 by: Eugene Lee

Mozilla and german 'Umlaute'
        162516 by: Thomas Weber
        162524 by: Dan Anderson

Re: Session stealing, ..
        162517 by: esctoday.com | Wouter van Vliet
        162525 by: Ben C.

socket_write eats data
        162518 by: Thomas Weber

Re: socket_write eats data - solved
        162520 by: Thomas Weber

MySql Query Help: COUNT()
        162526 by: [-^-!-%-
        162530 by: John W. Holmes

Text into a url
        162527 by: Tom Wollaston
        162528 by: John W. Holmes

More Image Transformation Difficulty
        162529 by: weston.leary.csoft.net

Re: Integrating an Applet with PHP
        162531 by: Todd Cary
        162532 by: Raditha Dissanayake

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 ---
I reported this BUG at php.bugs as http://bugs.php.net/?id=25323.
It's there for 13 days now and still no answer... :-(

Cristiano Duarte

"Cristiano Duarte" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
> Is this suppose to work ? Currently it does not.
>
> class Priority {
>         const DEBUG = 0;
>         const INFO = 1;
>         const WARN = 2;
>         const ERROR = 3;
>         const FATAL = 4;
>
>         const MAX_PRIORITY = FATAL;
> }
>
> class ExtendedPriority extends Priority {
>         const REMOTE = Priority::MAX_PRIORITY + 1;
>         const URGENT = Priority::MAX_PRIORITY + 2;
> }
>
> if it's not supposed to work, there is also some parser problem in ZE2
that
> accepts a constant expression based on string concatenation(This code
causes
> segmentation fault):
>
> class test {
>         const TEST = "hi";
>         const TEST1 = self::TEST . "ih";
> }
>
> Cristiano Duarte

--- End Message ---
--- Begin Message ---
Whats wrong with this

<title><?php echo "Thank You, $senderemail"; ?></title>

where

$senderemail = $_POST['from'];

It doesnt It only echos thank you.

Why?

--- End Message ---
--- Begin Message ---
Hey,
Just touched it up a bit but its working:

<title>
<?php
$senderemail = $_POST['from'];
print "Thank You, $senderemail";
?>
</title>

This should come before:
$senderemail = $_POST['from'];

not after this:
print "Thank You, $senderemail";

plus

I'm guessing that either your form is sending $senderemail  or that you are
getting via a $_GET

you have to post $from not $senderemail.

If you change the above to a $_GET this will work
YourFileName.php?from=Ryan

Cheers,
-Ryan




We will slaughter you all! - The Iraqi (Dis)information ministers site
http://MrSahaf.com


----- Original Message ----- 
From: "Stevie D Peele" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, September 13, 2003 2:45 PM
Subject: [PHP] Whats wrong?


> Whats wrong with this
>
> <title><?php echo "Thank You, $senderemail"; ?></title>
>
> where
>
> $senderemail = $_POST['from'];
>
> It doesnt It only echos thank you.
>
> Why?

--- End Message ---
--- Begin Message ---
Try this

<title><?echo "Thank You, ".$_POST['from']; ?></title>

- Sid

On Sat, 13 Sep 2003 08:45:16 -0400, Stevie D Peele wrote:
> Whats wrong with this
>
>
> <title><?php echo "Thank You, $senderemail"; ?></title>
>
>
> where
>
>
> $senderemail = $_POST['from'];
>
>
> It doesnt It only echos thank you.
>
>
> Why?

--- End Message ---
--- Begin Message ---
or even:

<title><?=("Thank you, $_POST[from]")?></title>

:P

 -> -----Oorspronkelijk bericht-----
 -> Van: Sid [mailto:[EMAIL PROTECTED]
 -> Verzonden: zondag 14 september 2003 3:43
 -> Aan: Stevie D Peele; [EMAIL PROTECTED]
 -> Onderwerp: Re: [PHP] Whats wrong?
 -> 
 -> 
 -> Try this
 -> 
 -> <title><?echo "Thank You, ".$_POST['from']; ?></title>
 -> 
 -> - Sid
 -> 
 -> On Sat, 13 Sep 2003 08:45:16 -0400, Stevie D Peele wrote:
 -> > Whats wrong with this
 -> >
 -> >
 -> > <title><?php echo "Thank You, $senderemail"; ?></title>
 -> >
 -> >
 -> > where
 -> >
 -> >
 -> > $senderemail = $_POST['from'];
 -> >
 -> >
 -> > It doesnt It only echos thank you.
 -> >
 -> >
 -> > Why?
 -> 
 -> -- 
 -> PHP General Mailing List (http://www.php.net/)
 -> To unsubscribe, visit: http://www.php.net/unsub.php
 -> 

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

Thanks for your reply.

I imported the blobs into mysql database. They were in jpeg format.

Phil.


"Warren Vail" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> You didn't say how the images were placed in the db but you did indicate
they were jpeg format.
>
> I'd try;
>
> fetching the db column in to a string variable;
>
> then;
>
> $im = imagecreatefromstring($imagestring);
> header ("Content-type: image/jpeg");
> imagejpeg($im);
> imagedestroy($im);
>
> good luck,
>
> Warren Vail
>
> -----Original Message-----
> From: Phil King [mailto:[EMAIL PROTECTED]
> Sent: Friday, September 12, 2003 11:54 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Displaying Blobs by a newbie
>
>
> Hi All,
>
> I have some images in a mysql database. I wish to display all these images
> on a PHP Page.
>
> I have created a query to retrieve all the images from the database but
all
> that is displayed is characters.
> I have the Content-Type as image/jpeg in the header of the page to display
> the images.
>
> Can anyone advise me or point me in the right direction to rectify this.
>
> Thanks very much.
>
> Phil.
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
* Thus wrote Phil King ([EMAIL PROTECTED]):
> Hi All,
> 
> I have some images in a mysql database. I wish to display all these images
> on a PHP Page.
> 
> I have created a query to retrieve all the images from the database but all
> that is displayed is characters.
> I have the Content-Type as image/jpeg in the header of the page to display
> the images.

Basically you need two scripts:

script1:
generate html that has <img> tags that point to script2.

script2:
read one image from the database and send that image with the
appropriate content-type


> 
> Can anyone advise me or point me in the right direction to rectify this.

This has been discussed may times on the list, you can search the
archives to find out more detailed discussions on this.


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

--- End Message ---
--- Begin Message ---
When I use for loops, at the start of each iteration, the variables hold the
values from the last loop.

First, is there an elegant way of clearing variables at the start of each
loop rather than using unset???! It just seems wrong.

Also, all my problems would be solved if variables in a for loop were kept
local, but everything by default is a global. Can I change this in php.ini
or something??

TIA

--- End Message ---
--- Begin Message ---
* Thus wrote John Ryan ([EMAIL PROTECTED]):
> When I use for loops, at the start of each iteration, the variables hold the
> values from the last loop.
> 
> First, is there an elegant way of clearing variables at the start of each
> loop rather than using unset???! It just seems wrong.

I'm unclear as to what elegant implies.

> 
> Also, all my problems would be solved if variables in a for loop were kept
> local, but everything by default is a global. Can I change this in php.ini
> or something??

no, there are only two scopes in php, it is either GLOBAL or local inside
a function/class.


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

--- End Message ---
--- Begin Message ---
* Thus wrote Jay Paulson ([EMAIL PROTECTED]):
> Quick question to the community here.  The company I work for got bought out and now 
> they are wanting to migrate all the web sites that I have created in PHP to their 
> Windows, IIS, .NET enviroment.  I have been trying to talk to the people at 
> corporate about putting PHP on their Windows machines but they are reluctant saying 
> the following:
> 
> "An additional complication we discussed here is the fact that our servers are set 
> up as pure a .NET environment. While we could add PHP to it. It could create 
> conflicts that would effect the entire system. We have had this problem with Cold 
> Fusion in the past."

hmm.. php != cold fusion

> 
> My question is... has anyone put both PHP and .NET in a Windows enviroment at the 
> same time and had any conflicts?  I have done it several times before and have not 
> run into any problems.  I really want to continue to run some of the PHP things that 
> I have on the sites (i.e. message forums, chats etc) but I really need to know if 
> anyone has run into any conflicts.  

I havn't set up .NET so can't provide any input on that.

Funny though how this question always comes up with the term
'Corporate' tied in with it :)

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

--- End Message ---
--- Begin Message ---
<?
   function func1()
   {
   }
   function func2()
   {
   }
   function func3()
   {
   }
   function func4()
   {
   }
   function func5()
   {
   }

   if (isset($_REQUEST['funcs']))
      foreach ($_REQUEST['funcs'] as $key=>$val)
         if (function_exists($key))
            $key();
?>
<hr>
<form method=POST>
<input type=submit name=funcs[func1] value="Execute Function 1"><br>
<input type=submit name=funcs[func2] value="Execute Function 2"><br>
<input type=submit name=funcs[func3] value="Execute Function 3"><br>
<input type=submit name=funcs[func4] value="Execute Function 4"><br>
<input type=submit name=funcs[func5] value="Execute Function 5"><br>
</form>

--- End Message ---
--- Begin Message ---
* Thus wrote [EMAIL PROTECTED] ([EMAIL PROTECTED]):
> > function &create_object() {
> >     [..]
> > }
> >
> > $some_object =& create_object('some_object');
> >

This line should be:
  $some_object = create_object('some_object');

The use of & at calltime is deprecated and should only be used in
the declaration of the functions:
  function &func_name(&$ref_var) { }


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

--- End Message ---
--- Begin Message ---
On Sat, 2003-09-13 at 11:08, Curt Zirzow wrote:
> * Thus wrote [EMAIL PROTECTED] ([EMAIL PROTECTED]):
> > > function &create_object() {
> > >   [..]
> > > }
> > >
> > > $some_object =& create_object('some_object');
> > >
> 
> This line should be:
>   $some_object = create_object('some_object');
> 
> The use of & at calltime is deprecated and should only be used in
> the declaration of the functions:
>   function &func_name(&$ref_var) { }

Wouldn't =& still be legal because you are assigning a reference of what
is returned? Would that make $some_object a reference to a reference? It
doesn't seem to raise an exception.

- Brad

--- End Message ---
--- Begin Message ---
* Thus wrote James Hamilton ([EMAIL PROTECTED]):
> > > [snip]
> > > The user has both localhost and % host privileges in the mysql
> > > permission
> > > schema.
> > > [/snip]
> > >
> > Any other thoughts?
> > [/snip]
> > 
> current testing code:
> 
> $link = mysql_connect("localhost", "user", "pass" )
>     or die("Could not connect : " . mysql_error());
> print "Connected successfully";
> mysql_select_db("name") or die("Could not select database");
> print "connected";

Increase your error_reporting and turn on display_errors, you will
most likely be enlightened as to why you're unable to connect.

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

--- End Message ---
--- Begin Message ---
I'm new to the GD/Image functions with PHP, and I'm trying to use them 
to manipulate jpeg images that I've stored in a MySQL database 
(specifically, creating thumbnails). The thing I can't tell from reading 
the documentation is how to use these image functions to operate on 
image data -- it looks like you get a GD image resource in each case 
by specifying a file name, not by passing image data directly. While I 
can see how that's convenient for the common case, I can't figure out 
how to make this work without writing the image out to a file (and since 
I'm already taking a bit of a performance hit by reading the image out 
a database, that seems like the wrong thing to do). Can anyone elaborate? 

Thanks,
        Weston

--- End Message ---
--- Begin Message ---
On Sunday 14 September 2003 01:12, [EMAIL PROTECTED] wrote:
> I'm new to the GD/Image functions with PHP, and I'm trying to use them
> to manipulate jpeg images that I've stored in a MySQL database
> (specifically, creating thumbnails). The thing I can't tell from reading
> the documentation is how to use these image functions to operate on
> image data -- it looks like you get a GD image resource in each case
> by specifying a file name, not by passing image data directly. While I
> can see how that's convenient for the common case, I can't figure out
> how to make this work without writing the image out to a file (and since
> I'm already taking a bit of a performance hit by reading the image out
> a database, that seems like the wrong thing to do). Can anyone elaborate?

imagecreatefromstring()

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
The wise shepherd never trusts his flock to a smiling wolf.
*/

--- End Message ---
--- Begin Message ---
Reposted, as it appears it didn't go thru.
****
Hi,

I have a "Remember me on this computer" check box, which sets a cookie for
future logins. What's the consensus on when a cookie of this type should
expire? I currently have it set for 30 days.

Thanks,
James

--- End Message ---
--- Begin Message ---
* Thus wrote Andrea Tricco ([EMAIL PROTECTED]):
> Hi,

Hello

> 
> I'm using the function "file_get_contents()" to replicate the content of a
> remote html page on my server.
> 
> But, the function file_get_contents() works even when the name of the file
> is not specified. For example:
> 
> "http://www.php.net"; rather that "http://php.net/index.php";

http://php.net/           - apache serves index.php
http://php.net            - apache redirects to http://php.net/
http://php.net/index.php  - servers index.php

All three of these will show the same content.

> 
> Does a method exist to know the name of the file received form web server?

Nope

> 
> I would like to write a program that automatically downloads the images
> inserted into a html page.

The odds are if you right one, it wont be 100% compatible with all
sites.  What in essance you are doing is writing a web browser, and
there are a lot of things that need to be taken care of to handle
special cases.


> 
> For this reason, I need to determine the paths of the images in order to get
> them from the web server.

For starters probably reading up on HTML and HTTP specifications
might be a good place to start. ( http://w3c.org )

> 
> In other words, my program should work as the "Save as" function (File menu)
> of any Web browser.

There are alternative choices, there are programs out there like
webget and wget that will automatically do what you want to do. You
could use those programs with a system call. 

> 
> 
> 
> Can anybody help me?

I hope I did already :)


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

--- End Message ---
--- Begin Message ---
Something I've noticed in PHP is a proliferation of code like this:

        <input name="stuff[title]" value="" type="text" size="40">

According to the specs, the square brackets in "stuff[title]" are
technically illegal.

        http://www.w3.org/TR/html4/types.html#h-6.2

        ID and NAME tokens must begin with a letter ([A-Za-z]) and may
        be followed by any number of letters, digits ([0-9]), hyphens
        ("-"), underscores ("_"), colons (":"), and periods (".").

Thoughts?  Suggestions for writing flexible PHP code that at least
passes the HTML 4.01 Transitional DTD?

--- End Message ---
--- Begin Message ---
* Thus wrote Eugene Lee ([EMAIL PROTECTED]):
> Something I've noticed in PHP is a proliferation of code like this:
> 
>       <input name="stuff[title]" value="" type="text" size="40">
> 
> According to the specs, the square brackets in "stuff[title]" are
> technically illegal.
> 
>       http://www.w3.org/TR/html4/types.html#h-6.2

Yes, this is correct.  The way to properly do it would be to set
set your name as:

<input name="stuff%5Btitle%5D" value="" type="text" size="40">


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

--- End Message ---
--- Begin Message ---
On Sat, Sep 13, 2003 at 06:15:29PM +0000, Curt Zirzow wrote:
: * Thus wrote Eugene Lee ([EMAIL PROTECTED]):
: > Something I've noticed in PHP is a proliferation of code like this:
: > 
: >     <input name="stuff[title]" value="" type="text" size="40">
[...]
: The way to properly do it would be to set set your name as:
: 
: <input name="stuff%5Btitle%5D" value="" type="text" size="40">

Great idea, thanks Curt!

--- End Message ---
--- Begin Message ---
* Thus wrote Dan Phiffer ([EMAIL PROTECTED]):
> Could somebody explain (or point me to some online docs) the usage of
> DB_FETCHMODE_FLIPPED, defined by PEAR DB? I feel like I've seen it mentioned
> on the PEAR site, but somehow I can't find it now.
> 
> I'm pretty sure it's on a page linked from here:
> http://pear.php.net/manual/en/package.database.php

I'm not sure.  There is a pear mailing list, you might be able to
get a quick answer over there.

> 
> Also, why isn't Google spidering the PEAR docs?

hmm.. a pear.php.net is in google. they may have a robots.txt file
that dissallows spidering for the site.



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

--- End Message ---
--- Begin Message ---
* Thus wrote [EMAIL PROTECTED] ([EMAIL PROTECTED]):
> Hi all,
> I have a download for that collects data from a user (name, e-mail etc) 
> The $bu variable and others are from the previous form too.
> [...]
> 
> So, it works great on my desktop here at work, but I just got a few mails 
> from random users, who complained that they saw an error screen after 
> trying to download pdf's.

Well did they supply any information like what the error was or
what browser they were using?


> Dunno if this is a PDF problem, or if my script is bad?
> 
> So, here is my code... (that site at the very top of my page.)
> The headers after the else statement are simply to avoid page caching, so 
> we can ignore them in this example.....
> So, why does this work for me and many others, but not all?

I'm unable to answer that. Some knowlege of what exactly the error
is might help. The headers shouldn't cause error.

> 
> *********************************************************************
> The information contained in this e-mail message is intended only for 
> the personal and confidential use of the recipient(s) named above.  

am I the intended person? the email wasn't addressed to me, so I
feel like I'm breaking the policy...

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

--- End Message ---
--- Begin Message ---
* Thus wrote Daniel Szasz ([EMAIL PROTECTED]):
> Hello
> 
> I'm working in programming for many years and I'm looking now for an editor
> for php good like the borland editor in Delphi/CBuilder..
> Also I will be glad to b something with the same shortcuts like there ( i'm
> talking about classic shortcuts) since I'm working with that when wordstar
> was the best editor.

hmm.. when did vim not be the best editor.

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

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

I have a request but don't know where to send it. Thus, it ends up here. Alternately, I'm looking for some solutions:

The request: Can the macintosh character set be added as an option for htmlentities() and other commands? That would be so helpful for our mac-based company.

The problem: I'm fairly new to php and have found that the macintosh character set is pretty different from other standard sets, so when someone in our company enters an em-dash (an extended dash, that would be represented as &emdash; in html) into our SQL database, browsers display it as Ñ (&Ntilde;) because that's the correct mapping in other, standard sets. Of course, I could do a replace on that character, but there are another 6 characters that I know of that will cause problems, and probably more beyond that. The quick and good way is to convert with htmlentities(), but the mac charset is lacking.

Any suggestions how to fix this?

Thanks,
Michael

--- End Message ---
--- Begin Message ---
On Sat, Sep 13, 2003 at 11:24:56AM -0700, Michael Winston wrote:
: 
: The request:  Can the macintosh character set be added as an option for 
: htmlentities() and other commands?  That would be so helpful for our 
: mac-based company.
: 
: The problem:  I'm fairly new to php and have found that the macintosh 
: character set is pretty different from other standard sets, so when 
: someone in our company enters an em-dash (an extended dash, that would 
: be represented as &emdash; in html) into our SQL database, browsers 
: display it as Ñ (&Ntilde;) because that's the correct mapping in other, 
: standard sets.  Of course, I could do a replace on that character, but 
: there are another 6 characters that I know of that will cause problems, 
: and probably more beyond that.  The quick and good way is to convert 
: with htmlentities(), but the mac charset is lacking.
: 
: Any suggestions how to fix this?

You could modify the HTML translation table and add Mac specific
characters to the mix.

        <?php

        $trans = get_html_translation_table(HTML_ENTITIES);
        $trans[chr(213)] = '&apostrophe;';
        $trans[chr(165)] = '&bullet;';
        $trans[chr(208)] = '&endash;';
        $trans[chr(209)] = '&emdash;';

        $macstring = 'A string containing some Mac-specific characters';
        $encoded = strtr($macstring, $trans);

        echo $encoded;

        ?>

I wonder if anyone has already done the work for the other entites.
Anyways, if not, you can always build your own from Apple's list:

        http://developer.apple.com/documentation/mac/Text/Text-516.html#MARKER-9-3

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

i have a strange problem with Mozilla. When submitting a form, german
umlaute (ä (ae), ü (ue) and others) become strange 16bit-chars like 'ä'.
I've tested this with PHP as dynamic Apache-module and with an own webserver
written in PHP.
Doctype and other XML-specific things in the page with the form don't make
any changes.

Does anyone know this problem? Does someone have a solution for this?

Thanks,
Thomas 'Neo' Weber
---
[EMAIL PROTECTED]
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
> Does anyone know this problem? Does someone have a solution for this?

You are probably using UTF16 (or is it called UTF8?) encoding which
allows many spiffier things then ASCII.  There are functions to allow
conversion between UTF and ASCII.  I ran into this problem when a
spanish client tried using spanish in a script sold in America.  I
refunded him his money because the solution was much too expensive.

-Dan

--- End Message ---
--- Begin Message ---
Thanks all for your replies .. It's pretty much what I already thought, a
really secure way of handling sessions there is not. Though most of the most
interesting information came from Jason (Yes! I'd love to see your custom
session handler .. if be it only for inspiration to the one I'm planning to
write soon) and Mike .. this issue is one that bothers me also.

I'm not on AOL but my IP also can change at any time. It's not common,
usually I hold the same one untill I dial my cable provider again .. but how
often does this IP change happen and does other ISP's also do things like
that?

Wouter

 -> -----Oorspronkelijk bericht-----
 -> Van: Jennifer Goodie [mailto:[EMAIL PROTECTED]
 -> Verzonden: zaterdag 13 september 2003 0:37
 -> Aan: Wouter van Vliet; PHP General
 -> Onderwerp: RE: [PHP] Session stealing, ..
 ->
 ->
 -> >      93         # When deserialized we are called and need to
 -> check if the
 -> > stored IP address equals the client's
 -> >      94         function __wakeup() {
 -> >      95                 global $Log;
 -> >      96                 if ($_SERVER['REMOTE_ADDR'] !=
 -> > $this->Night['IP']) {
 -> >      97                         $Log->Warning('IP Address
 -> changed during
 -> > sleep and wakeup, will clear userdata');
 -> >      98                         $this->Data = Array();
 -> >      99                 };
 -> >     100         }
 -> >
 -> > Upon sleep it stores the IP and time in the session data, and
 -> > when it smells
 -> > coffee my object wakes up, checks if he's still being used on the
 -> > same host
 -> > and if not the userdata is plainly cleared.
 -> >
 ->
 -> I hope none of your site visitors are on AOL as the IP can
 -> change between
 -> page requests for AOL users.

--- End Message ---
--- Begin Message ---
I would also be interested in seeing the code as well.  If you could also
e-mail it to me, I would be very appreciative.

Ben

-----Original Message-----
From: Jason Sheets [mailto:[EMAIL PROTECTED]
Sent: Friday, September 12, 2003 4:56 PM
To: Wouter van Vliet
Cc: PHP General
Subject: Re: [PHP] Session stealing, ..


I wrote a custom session handler that encrypts the session before it is
stored in /tmp that way even if someone has access to the session files
they are useless.

It stores the randomly generated encryption key on the user's client
base64_encoded, which can be intercepted as well all know but it still
increases the difficulty of reading the /session files now they must
have access AND sniff the encryption key.  Additionally for the more
secure sites I require the user access the site through SSL so the
cookie is not passed in plain text.

If you are interested I'll see if I can send it to you, it uses my Crypt
Class (PHP class simplifying Mcrypt usage).

Jason

Wouter van Vliet wrote:

>Hi All,
>
>There's always been a lot of discussion about how safe sessions are. I'd
>like to store a complete user object (instance of a class) in a session
with
>the best security measures possible. Who doesn't.
>
>Now, to prevent that the session file from the server gets stolen by some
>other user of the virtual host I did this to my object:
>
>     87         # Called upon serialization of the object. It stored the IP
>address and serialization time.
>     88         function __sleep() {
>     89                 $this->Night = Array('Time' => time(), 'IP' =>
>$_SERVER['REMOTE_ADDR']);
>     90                 return Array('Data', 'Night');
>     91         }
>     92
>     93         # When deserialized we are called and need to check if the
>stored IP address equals the client's
>     94         function __wakeup() {
>     95                 global $Log;
>     96                 if ($_SERVER['REMOTE_ADDR'] != $this->Night['IP'])
{
>     97                         $Log->Warning('IP Address changed during
>sleep and wakeup, will clear userdata');
>     98                         $this->Data = Array();
>     99                 };
>    100         }
>
>Upon sleep it stores the IP and time in the session data, and when it
smells
>coffee my object wakes up, checks if he's still being used on the same host
>and if not the userdata is plainly cleared.
>
>This all probably takes care about the problem with session id's in the
>query string, which is known as referrer to the next website our visitor
>visits. What I'm worrying and wondering about now are other users of the
>server my site's at. They can most likely go into the /tmp folder and just
>read my session files. Not Nice. I know it has been discussed for quite
some
>times now .. but never really found anything else than warnings for stuff,
>no real solutions.
>
>So, get your idea's rolling and let the good things flow...
>
>Wouter
>
>
>

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

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

I am deveoping a chatserver in IRC-style in PHP. For communication it uses
socket-multiplexing aka socket_select. So long so good, works perfectly.
The problem is, than when i make several socket_write's to the same client
without waiting about 0.1sec after each write, the written data gets lost
somewhere. socket_write does NOT throw any error, the data seams just
sended, but the clients never receives it.

Small example of the used code:
-----
var $clients // array of 'client'-objects, each object has it's own
socket-descriptor in the object-variable $socket

function write_to_clients ($text) {
  for ($i = 0; $i < count ($this->clients); $i++) {
    socket_write ($this->clients[$i]->socket, $text);
  }
  // usleep (10000); if this is uncommented, all write are received by all
clients
}

for ($i = 0; $i < 10; $i++) {
    $this->write_to_clients ("test ".$i);
}
-----

Okay, this doesn't check the client-sockets for readiness to write, but even
if I check (via socket_select), ALL clients are ready to write and writes
get lost too. It can't be the network-connection, because the tests run with
standalone PHP-clients on the same machine.

Is there any possibility to make fast writes without waiting after each
write? The wait limits the server to max. 10 writes per second, wich isn't
really enaugh for a good chatserver.

Thanks for your help!

Thomas 'Neo' Weber
---
[EMAIL PROTECTED]
[EMAIL PROTECTED]

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

i've checked a hundred things before posting this question, but i forgot the
most important thing, the buffer.
The 'eaten' writes were buffered by the network-kernel and sent as bunch of
data. If too much data for the buffer is sent, the write is broken up and
completed in the next bunch-of-data.
My receive-script hasn't diplayed the raw output, but an unserialized array,
fetched out of the received string.

Maybe this will will help someone in future.

Thomas 'Neo' Weber
---
[EMAIL PROTECTED]
[EMAIL PROTECTED]

----- Original Message ----- 
From: "Thomas Weber" <[EMAIL PROTECTED]>
To: "PHP-List" <[EMAIL PROTECTED]>
Sent: Saturday, September 13, 2003 9:15 PM
Subject: [PHP] socket_write eats data


> Hi,
>
> I am deveoping a chatserver in IRC-style in PHP. For communication it uses
> socket-multiplexing aka socket_select. So long so good, works perfectly.
> The problem is, than when i make several socket_write's to the same client
> without waiting about 0.1sec after each write, the written data gets lost
> somewhere. socket_write does NOT throw any error, the data seams just
> sended, but the clients never receives it.
>
> Small example of the used code:
> -----
> var $clients // array of 'client'-objects, each object has it's own
> socket-descriptor in the object-variable $socket
>
> function write_to_clients ($text) {
>   for ($i = 0; $i < count ($this->clients); $i++) {
>     socket_write ($this->clients[$i]->socket, $text);
>   }
>   // usleep (10000); if this is uncommented, all write are received by all
> clients
> }
>
> for ($i = 0; $i < 10; $i++) {
>     $this->write_to_clients ("test ".$i);
> }
> -----
>
> Okay, this doesn't check the client-sockets for readiness to write, but
even
> if I check (via socket_select), ALL clients are ready to write and writes
> get lost too. It can't be the network-connection, because the tests run
with
> standalone PHP-clients on the same machine.
>
> Is there any possibility to make fast writes without waiting after each
> write? The wait limits the server to max. 10 writes per second, wich isn't
> really enaugh for a good chatserver.
>
> Thanks for your help!
>
> Thomas 'Neo' Weber
> ---
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---

Hello everyone!

I'm trying to get the total number of a certain records from a database,
but the result is always '1'. Please advise!

=MySql Table =
=activitiy =

id  |  employee_id | project_id | date
1   | 45           | 60         | 2003-09-09
2   | 34           | 10         | 2003-09-10
3   | 45           | 45         | 2003-09-10
4   | 23           | 30         | 2003-04-11

Now, I'm trying to get the following info:
 - Total Number of employees in the datbase
 - Total number of projects
 -total number of projects per employee


I currently have

$_sql = "select count(*) as TotalRecords, count(employee_id) as
TotalEmployees, count(project_id) as TotalProjects GROUP BY employee_id,
project_id

$_qry = mysql_query($_sql) or die('...blah...');

$_res = mysql_fetch_object($_qry);

//output

echo $_res->TotalRecords;  //prints nothing
echo $_res->TotalEmployees;   // returns 1
echo $_res->TotalProjects;   //also return 1


//end of code



Any suggestions? Did I miss something?

Please advise.

Thanks in advance.

_john

--- End Message ---
--- Begin Message ---
I'm trying to get the total number of a certain records from a database,
but the result is always '1'. Please advise!

=MySql Table =
=activitiy =

id  |  employee_id | project_id | date
1   | 45           | 60         | 2003-09-09
2   | 34           | 10         | 2003-09-10
3   | 45           | 45         | 2003-09-10
4   | 23           | 30         | 2003-04-11

Now, I'm trying to get the following info:
 - Total Number of employees in the datbase
 - Total number of projects
 -total number of projects per employee


I currently have


$_sql = "select count(*) as TotalRecords, count(employee_id) as
TotalEmployees, count(project_id) as TotalProjects GROUP BY employee_id,
project_id

$_qry = mysql_query($_sql) or die('...blah...');

$_res = mysql_fetch_object($_qry);

//output

echo $_res->TotalRecords;  //prints nothing
echo $_res->TotalEmployees;   // returns 1
echo $_res->TotalProjects;   //also return 1

Your query doesn't even have a "FROM Table" in it. Hopefully that's just a cut and paste error, as you should see your "die" message because of that error.


You're not going to get the results you're after with a single query (unless you have PHP do some of the counting). Look at using a couple different queries to get your count.

One solution may be:

SELECT employee_id, COUNT(*) AS NumProjects FROM activity GROUP BY employee_id;

The number of rows returned will be the number of employees. Each row will list the employee_id and how many times it appeared in the table. If project_id is not repeated for a given employee_id, then this will be your project count. As you loop throught the results, keep a running total of the NumProjects column to get the total projects.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Hi
I am havening a problem retrieving url from a mysql database. I have the
url's stored as text and am using the following code to retrieve them


$query = "SELECT name,url FROM clubs WHERE url>'' ORDER BY name";

 $result = @mysql_query($query) or die ("Query failed");

 if (mysql_num_rows($result) == 0) {

  print "No Club Links Found.";

 } else {

  while ($row = mysql_fetch_assoc($result)) {

  print $row["name"] . "<A HREF= ".$row['url'].">";


This seems to work except the url refers to the previous name on the list
produced with the first name as a blank url.
Can anybody help

Thanks

--- End Message ---
--- Begin Message --- Tom Wollaston wrote:
Hi
I am havening a problem retrieving url from a mysql database. I have the
url's stored as text and am using the following code to retrieve them


$query = "SELECT name,url FROM clubs WHERE url>'' ORDER BY name";


$result = @mysql_query($query) or die ("Query failed");

if (mysql_num_rows($result) == 0) {

print "No Club Links Found.";

} else {

while ($row = mysql_fetch_assoc($result)) {

print $row["name"] . "<A HREF= ".$row['url'].">";


This seems to work except the url refers to the previous name on the list produced with the first name as a blank url. Can anybody help

You have incorrect HTML. You're last line should look like this:


print "<a href=\"{$row['url']}\">{$row['name']}</a>";

You were starting your link after you printed out the value, without ending the link, so it continued to the next item and only ended when the next link started on the next row.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
I'm trying to write a script that pulls an image from a database and transforms
the size if passed a width via the url query string.

Thanks to the helpful hint about the function "imagecreatefromstring", I 
think I'm now able to ready image data I've pulled for a database with 
GD. However, I'm still having trouble resizing... at least, when I'm 
sending the image to my browser, I'm being told that it "cannot be 
displayed, because it contains errors." (And the script does work if
I don't try resizing... see below for example URL).


Here's what I'm doing:

        $row = mysql_fetch_row($dbresult);
        $imgdata = $row[0];

        if(isset($width) && !empty($width) && is_numeric($width))
        /* only do transformation if given a width */
        {
                $gdimg = imagecreatefromstring($imgdata);
                $srcWidth = imagesx($gdimg);
                $srcHeight = imagesy($gdimg);
                $scaleFactor = $width/$srcWidth;
                $targetHeight = $srcHeight * $scaleFactor;

                $resizedimg = imagecreatetruecolor($width,$targetHeight);
                
imagecopyresized($resizedimg,$gdimg,0,0,0,0,$width,$targetHeight,$srcWidth,$srcHeight);
        }

        header("Content-Type: image/jpeg");
        header("Content-Transfer-Encoding: binary\n");
        //send file contents
        if(!empty($resizedimg)) 
                imagejpg($resizedimg);
        else 
        {
                header("Content-length: " . strlen($imgdata) . "\n");
                print($imgdata);
        }


Does anyone see what I'm doing wrong? Again, the script actually works if I
don't try to do the transform. See:

http://www.fsboutah.net/jpg.php?table=homes&key=4&field=Picture1

and

http://www.fsboutah.net/jpg.php?table=homes&key=4&field=Picture1&width=100

for contrasts.


-W

--- End Message ---
--- Begin Message --- Raditha -

I am using NS 7.1 running in Windows 2000. Which version of Netscape are you running?

This certainly is a strange situation.....

http://www.hexidec.com/ekitdemo.php

No HTML shows in the Editor window on startup with NS; it is there with IE.....

Todd

Raditha Dissanayake wrote:

HI,

I tried it on netscape and it works. My jre is 1.4.2. AFAIK this is the only stable jre after 1.3xx series. It's a simple matter to add a line of code to the java applet to do the base64 decoding if you are concerned about compatibility.

On the point raised about activex : The default plug in for ie (extremely crappy) is in fact an activex but that does not mean your applet behaves like an activex.



Todd Cary wrote:

Dan -

I am surprised that an Open Source applet would rely on ActiveX. It appears that there is something I am not doing correctly in setting the DATA param for Netscape.

Please overlook my ignorance about browsers and applets as I try to get a better understanding, but is BASE64 encoding/decoding a feature of IE and not , possibly, of Netscape?

Todd

Dan Anderson wrote:

why does it work in IE and not in Netscape 7.1?


I'm pretty sure ActiveX controls don't run on anything besides MS
Windows Lockinware (TM).  There are a number of other things that
netscape does not fully support (try loading a page with an iframe tag
in Netscape).  You probably ran into another such problem.

-Dan





--





--

--- End Message ---
--- Begin Message --- Mozilla 1.4 Red Hat 9.0 KDE 3.2 JRE 1.4.2


Todd Cary wrote:


Raditha -

I am using NS 7.1 running in Windows 2000. Which version of Netscape are you running?

This certainly is a strange situation.....

http://www.hexidec.com/ekitdemo.php

No HTML shows in the Editor window on startup with NS; it is there with IE.....

Todd

Raditha Dissanayake wrote:

HI,

I tried it on netscape and it works. My jre is 1.4.2. AFAIK this is the only stable jre after 1.3xx series. It's a simple matter to add a line of code to the java applet to do the base64 decoding if you are concerned about compatibility.

On the point raised about activex : The default plug in for ie (extremely crappy) is in fact an activex but that does not mean your applet behaves like an activex.



Todd Cary wrote:

Dan -

I am surprised that an Open Source applet would rely on ActiveX. It appears that there is something I am not doing correctly in setting the DATA param for Netscape.

Please overlook my ignorance about browsers and applets as I try to get a better understanding, but is BASE64 encoding/decoding a feature of IE and not , possibly, of Netscape?

Todd

Dan Anderson wrote:

why does it work in IE and not in Netscape 7.1?



I'm pretty sure ActiveX controls don't run on anything besides MS Windows Lockinware (TM). There are a number of other things that netscape does not fully support (try loading a page with an iframe tag in Netscape). You probably ran into another such problem.

-Dan





--








--
http://www.radinks.com/upload
Drag and Drop File Uploader.

--- End Message ---

Reply via email to