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 19 May 2003 03:52:54 -0000 Issue 2065

php-general-digest-helplists.php.net
Date: Sun May 18 2003 - 22:52:54 CDT


php-general Digest 19 May 2003 03:52:54 -0000 Issue 2065

Topics (messages 148080 through 148136):

Re: Edit a file
        148080 by: Miles Thompson
        148084 by: David Otton
        148087 by: shaun
        148097 by: Miles Thompson
        148102 by: David Otton

Re: Cookies on Phoenix
        148081 by: David Otton
        148082 by: John W. Holmes
        148085 by: Niels Uhlendorf
        148086 by: Niels Uhlendorf
        148090 by: John W. Holmes
        148092 by: Niels Uhlendorf

Re: dynamic html <head> info
        148083 by: John W. Holmes

passing args to c program
        148088 by: Brian V Bonini
        148093 by: David Otton
        148130 by: Maxim Maletsky

creating a alphanumeric password
        148089 by: Denis L. Menezes
        148098 by: Jason Wong
        148124 by: Evan Nemerson

Re: Calling a static method with call_user_method?
        148091 by: David Otton

Re: registration/login function....
        148094 by: Frappy John
        148096 by: Bruce Douglas

Session problem
        148095 by: Donahue Ben
        148108 by: John W. Holmes
        148133 by: Maxim Maletsky

A simple date question
        148099 by: Denis L. Menezes
        148106 by: John W. Holmes
        148129 by: Maxim Maletsky

a little logic...
        148100 by: Ryan A
        148104 by: Jason Wong
        148105 by: John W. Holmes
        148107 by: Ryan A
        148110 by: Bruce Douglas
        148131 by: Maxim Maletsky

Re: install packages
        148101 by: Jason Wong

Re: Assoiative Array and Accessing Them
        148103 by: Jason Wong

embedding PHP within HTML documents
        148109 by: Steve
        148128 by: Maxim Maletsky

display order by field value?
        148111 by: - \[ Paul Ferrie \] -
        148112 by: Anton
        148113 by: - \[ Paul Ferrie \] -
        148114 by: John W. Holmes
        148115 by: Jason Wong
        148116 by: Anton
        148117 by: - \[ Paul Ferrie \] -

Validate a form entry against an existing entry.
        148118 by: SP Computing
        148119 by: Seraphim
        148120 by: John W. Holmes
        148132 by: Bruce Douglas

Execute commands at root?
        148121 by: David Busby

No problem, just performance question (a little ot)
        148122 by: Ryan A
        148123 by: David Otton
        148134 by: Maxim Maletsky

timer javascript and php
        148125 by: Riza Fahmi
        148127 by: Leif K-Brooks

Re: hwo stable is apache2 + php ?
        148126 by: Rasmus Lerdorf

What's a binary safe function?
        148135 by: Douglas Douglas

Re: Get PHP generated Javascript to work
        148136 by: Justin French

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:


Well, help yourself. Look at the file ands tring function in the manual.

The deal is open the file, read and write out lines until you come to what
you want to change
Change it and write it out.
Read and write out the rest.

Been a while since I've done it, but that's the essence.

Miles

At 03:33 PM 5/18/2003 +0100, shaun wrote:
>Hi,
>
>How can i open a file and change the contents of everything in the file that
>lands between the <script> </script> tags?
>
>Thanks for your help
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


On Sun, 18 May 2003 15:33:05 +0100, you wrote:

>How can i open a file and change the contents of everything in the file that
>lands between the <script> </script> tags?

I'm sure this is the second time you've asked this question, and you already
got one answer with example code. What exactly are you trying to accomplish?

Open a file: fopen()

http://www.php.net/manual/en/function.fopen.php

Read the contents of a file: file(), fread(), fgets(), etc.

http://www.php.net/manual/en/ref.filesystem.php

To modify a string once it's in memory: string and regex functions

http://www.php.net/manual/en/ref.strings.php
http://www.php.net/manual/en/ref.pcre.php
http://www.php.net/manual/en/ref.regex.php

Without a more specific question, you're unlikely to get more specific help.

attached mail follows:


Thanks for your reply, but this question is different!

what i am trying to do is create a script that replaces a certain part of a
page e.g. everything between the <script> </script> tags.

The problem i found with the fopen() function is that writing to a file
automatically wipes the original content from the file...

"David Otton" <phpmailjawbone.freeserve.co.uk> wrote in message
news:lf7fcv0vg7vvgoanbpr0udt2bnpfs7iq2j4ax.com...
> On Sun, 18 May 2003 15:33:05 +0100, you wrote:
>
> >How can i open a file and change the contents of everything in the file
that
> >lands between the <script> </script> tags?
>
> I'm sure this is the second time you've asked this question, and you
already
> got one answer with example code. What exactly are you trying to
accomplish?
>
> Open a file: fopen()
>
> http://www.php.net/manual/en/function.fopen.php
>
> Read the contents of a file: file(), fread(), fgets(), etc.
>
> http://www.php.net/manual/en/ref.filesystem.php
>
> To modify a string once it's in memory: string and regex functions
>
> http://www.php.net/manual/en/ref.strings.php
> http://www.php.net/manual/en/ref.pcre.php
> http://www.php.net/manual/en/ref.regex.php
>
> Without a more specific question, you're unlikely to get more specific
help.
>

attached mail follows:


Yes, you'll see that in the docs.

It ain't a text editor - so read in and write out until you get to the part
you want to tchange, write that and then write out the rest of it.

You'll also notice there are various parameters for fopen()

Alternately - boilerplate beginning and end, with your script section as a
fragment. Make changes to the script section, them wrap all 3 in a fourth
file and include() them. There's more than one way to do this stuff.

Regards - Miles Thompson

At 04:18 PM 5/18/2003 +0100, shaun wrote:
>Thanks for your reply, but this question is different!
>
>what i am trying to do is create a script that replaces a certain part of a
>page e.g. everything between the <script> </script> tags.
>
>The problem i found with the fopen() function is that writing to a file
>automatically wipes the original content from the file...
>
>"David Otton" <phpmailjawbone.freeserve.co.uk> wrote in message
>news:lf7fcv0vg7vvgoanbpr0udt2bnpfs7iq2j4ax.com...
> > On Sun, 18 May 2003 15:33:05 +0100, you wrote:
> >
> > >How can i open a file and change the contents of everything in the file
>that
> > >lands between the <script> </script> tags?
> >
> > I'm sure this is the second time you've asked this question, and you
>already
> > got one answer with example code. What exactly are you trying to
>accomplish?
> >
> > Open a file: fopen()
> >
> > http://www.php.net/manual/en/function.fopen.php
> >
> > Read the contents of a file: file(), fread(), fgets(), etc.
> >
> > http://www.php.net/manual/en/ref.filesystem.php
> >
> > To modify a string once it's in memory: string and regex functions
> >
> > http://www.php.net/manual/en/ref.strings.php
> > http://www.php.net/manual/en/ref.pcre.php
> > http://www.php.net/manual/en/ref.regex.php
> >
> > Without a more specific question, you're unlikely to get more specific
>help.
> >
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


On Sun, 18 May 2003 16:18:00 +0100, you wrote:

>Thanks for your reply, but this question is different!
>
>what i am trying to do is create a script that replaces a certain part of a
>page e.g. everything between the <script> </script> tags.
>
>The problem i found with the fopen() function is that writing to a file
>automatically wipes the original content from the file...

Ok, then you need to do a sequence of things:

1. Read the contents of the old file into memory
2. Replace everything between <script> and </script>
3. Write out the changed text to the new file (may be the same file)

In an older language there might be more steps, but PHP has a few neat
functions that simplify things (the code below uses file_get_contents(),
available in PHP 4.3 and above. Replace with file() if you prefer)

However, this is a more difficult task it first appears. Some problems you
ought to consider:

What is the <script> tag has attribues? eg
        <script lang="Javascript">
What if the file is insanely large?
What if the file has more than one <script/> block?
What if the read or write fails?
What about <SCRIPT> and <ScRiPt>?

The following function is a quick hack rather than a solution, but it should
get you started:

/* this function replaces any <script></script> block in $oldFilename
   with $newText, and writes the result to $newFilename.
   Matching is greedy */

function replaceScriptBlock ($oldFilename, $newFilename, $newText) {
        /* read the contents of $oldFilename into memory */
        $text = file_get_contents ($oldFilename);

        /* replace everything between <script> and </script> with $newText */
        $text = ereg_replace("<script>.*</script>", $newText, $text);

        /* write out the changed text to $newFilename */
        //file_put_contents ($newFilename, $text);
        $f = fopen($newFilename, 'w');
        fwrite($f, $text, strlen($text));
        fclose($f);
}

attached mail follows:


On Sun, 18 May 2003 15:20:38 +0200, you wrote:

>I tried to work with Cookies for a _little_ forum thingie. The problem I
>have is that it doesn't read it out correctly. It is saved and I can
>work with it first. But as I close the browser and open the site again
>it doesn't see the cookie.
>
>I had the same problem with Mozilla and Opera. IE was the only browser
>where it worked =|.

That sounds like correct behaviour - cookies can be set to expire when the
browser session ends.

Did you set an explicit expiry time on the cookie? Got a code snippet? Do
you have "Throw away new cookies on exit" set in Opera? "Limit maximum
lifetime of cookies to current session" in Mozilla?

attached mail follows:


> I tried to work with Cookies for a _little_ forum thingie. The problem
I
> have is that it doesn't read it out correctly. It is saved and I can
> work with it first. But as I close the browser and open the site again
> it doesn't see the cookie.
>
> I had the same problem with Mozilla and Opera. IE was the only browser
> where it worked =|.

Show some code. Are you setting an expire time for the cookie? Are your
settings in Mozilla deleting the cookie regardless of the expiration
time (a setting under preferences can allow you to do that).

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

attached mail follows:


John W. Holmes wrote:
>>I tried to work with Cookies for a _little_ forum thingie. The problem
>
> I
>
>>have is that it doesn't read it out correctly. It is saved and I can
>>work with it first. But as I close the browser and open the site again
>>it doesn't see the cookie.
>>
>>I had the same problem with Mozilla and Opera. IE was the only browser
>>where it worked =|.
>
>
> Show some code. Are you setting an expire time for the cookie? Are your
> settings in Mozilla deleting the cookie regardless of the expiration
> time (a setting under preferences can allow you to do that).
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>
Thx For quick reply.

Here's an extract of the code. An expire time was set and the cookie
still exists as I watch through the list of cookies set in Mozilla.

<?php
[...]
$str = serialize($cook);
setcookie($CName,$str, time()+(1000000000*100000000));
[...]
?>

<?php
[...]
$cook = unserialize(stripslashes($_COOKIE[$CName]));
[...]
?>

$cook is definded as an array.

> Do you have "Throw away new cookies on exit" set in Opera? "Limit
> maximum lifetime of cookies to current session" in Mozilla?

Call me supernoob .. but... where do I find this option in Mozilla?

Thx For Help
Niels

attached mail follows:


[addition] ok. the cookie just exists until the end of the session. sorry.

attached mail follows:


> Here's an extract of the code. An expire time was set and the cookie
> still exists as I watch through the list of cookies set in Mozilla.
>
> <?php
> [...]
> $str = serialize($cook);
> setcookie($CName,$str, time()+(1000000000*100000000));

Ummm... maybe you should be a little realistic in your expiry time? Do
you really need a cookie persisting for 3.1 billion years??

> > Do you have "Throw away new cookies on exit" set in Opera? "Limit
> > maximum lifetime of cookies to current session" in Mozilla?
>
> Call me supernoob .. but... where do I find this option in Mozilla?

Edit -> Preferences -> Privacy and Security -> Cookies -> Limit maximum
lifetime of cookie to: -> current session

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

attached mail follows:


John W. Holmes wrote:
>>Here's an extract of the code. An expire time was set and the cookie
>>still exists as I watch through the list of cookies set in Mozilla.
>>
>><?php
>>[...]
>>$str = serialize($cook);
>>setcookie($CName,$str, time()+(1000000000*100000000));
>
>
> Ummm... maybe you should be a little realistic in your expiry time? Do
> you really need a cookie persisting for 3.1 billion years??
>
>
>> > Do you have "Throw away new cookies on exit" set in Opera? "Limit
>> > maximum lifetime of cookies to current session" in Mozilla?
>>
>>Call me supernoob .. but... where do I find this option in Mozilla?
>
>
> Edit -> Preferences -> Privacy and Security -> Cookies -> Limit maximum
> lifetime of cookie to: -> current session
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>
thx a lot. it works by setting smaller times.

attached mail follows:


> Somewhat general variable usage question I guess. Thanks to anyone
that
> has
> a few minutes to enlighten me.
>
> Say 'head.php' contains the html <head>title, meta, etc...</head>
block of
> text, and 'content.php' has html content, and your index page looks
like:
>
> <html>
> <head>
> <? require ("/usr/local/www/dubya.org/htdocs/common/head.php"); ?>
> </head>
> <body>
> <? require ("/usr/local/www/dubya.org/htdocs/common/content.php"); ?>
> </body>
> </html>
>
> Can you populate variables in 'head.php' from vars in 'content.php,'
even
> though the head was included first? (and thus already processed?)
>
> eg. having <title><?php print $pagetitle; ?></title> in the head.php,
and
> <?
> $pagetitle = "my page title"; ?> at the top of the 'content.php' file.

No, you can't. It's like saying:

echo $a;
$a = 'foo';

and expecting to get 'foo' as output.

You may want to use functions or classes that don't actually output your
code, but return them to a variable.

$content = get_content();
$pagetitle = $somevar_from_get_content; //global var or something
$header = get_header(); //using $pagetitle somewhere

echo "<html>$header<body>$content</body></html>";

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

attached mail follows:


which functions should i be looking at for passing values to a c++
program and displaying or getting the output back?

attached mail follows:


On 18 May 2003 11:23:50 -0400, you wrote:

>which functions should i be looking at for passing values to a c++
>program and displaying or getting the output back?

system(), exec(), passthru(), etc. all execute a command line in one way or
another.

http://www.php.net/manual/en/function.system.php

Be careful when passing data from a browser to a command line - it can open
up some nasty security holes. Read

http://www.php.net/manual/en/function.escapeshellcmd.php

attached mail follows:


On 18 May 2003 11:23:50 -0400
Brian V Bonini <b-boninicox.net> wrote:

> which functions should i be looking at for passing values to a c++
> program and displaying or getting the output back?

This depends on what exactly you have meant. If you were passing the
variables through shell, you might as well rely on the post below
(system(), exec(), passthru(), etc) this will execute something as the
user your PHP runs under and will get back the result. Alternatively,
you might want to wrap up a PHP extension for your C program to interact
with it directly. This is harder, but if you know some C you can easily
manage it. Take a look at swig as well.

--
Maxim Maletsky
maximphp.net

attached mail follows:


Hello Friends.

Anybody could please give me some scripts to generate a alphanumeric(smallcase + uppercase) passwords?

Any link to encrypt and decrypt the password would be very good too.

Thanks very much
denis

attached mail follows:


On Sunday 18 May 2003 23:21, Denis L. Menezes wrote:

> Anybody could please give me some scripts to generate a
> alphanumeric(smallcase + uppercase) passwords?
>
> Any link to encrypt and decrypt the password would be very good too.

Please say you googled for "php password generator" and didn't find any.

--
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
------------------------------------------
/*
2180, U.S. History question:
        What 20th Century U.S. President was almost impeached and what
        office did he later hold?
*/

attached mail follows:


They're all over the internet. www.google.com. anyways here's one I wrote
which is pretty useful. Handles variable lengths, alpha-numeric, and
pronouncable. I really just wrote it for me, so it's not too clean, but here
it is anyways.

#!/usr/local/bin/php -q
<?php

function genpropwd($length)
{
        $vowels = array("a","e","i","o","u");
        $cons =
array("b","c","d","g","h","j","k","l","m","n","p","r","s","t","u","v","w","tr","cr","br","fr","th","dr","ch","ph","wr","st","sp","sw","pr","sl","cl");

        $num_vowels = count($vowels);
        $num_cons = count($cons);

        $password = '';
        for ( $i=0 ; $i<$length ; $i++ )
                $password .= $cons[mt_rand(0, $num_cons-1)].$vowels[mt_rand(0,
$num_vowels-1)];

        return substr($password,0,$length);
}

function genpwd($length)
{
        $pwd = '';
        $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
        for ( $x=0 ; $x<$length ; $x++ )
        {
                $tmp = substr($chars,mt_rand(0,strlen($chars)-1),1);
                if ( mt_rand(0,1) == 1 )
                        $tmp = strtoupper($tmp);
                $pwd .= $tmp;
        }
        return $pwd;
}

function writeHelp()
{
        echo "USAGE: ".$_SERVER['argv'][0]." [OPTIONS]\n".
                        "OPTIONS:\n".
                        " -l:INTL,--length:INT\tGenerate passwords of length INTL.\n".
                        " \t\t\tThe default value is twelve (12) characters.\n".
                        " -c:INTC,--count:INT\tGenerate INTC passwords.\n".
                        " \t\t\tThe default value is one (1) password.\n".
                        " -p,--pronounceable\tGenerate a pronouncable password.\n".
                        " -h,--help\t\tGenerate this help screen.\n";
        exit();
}

$myArgs = $_SERVER['argv'];
unset($myArgs[0]);

$length = 12;
$p = $number = FALSE;
foreach ( $myArgs as $arg )
{
        if ( ($arg == '-h') | ($arg == '--help') )
                writeHelp();
        elseif ( ( substr($arg,0,3) == '-c:' ) )
                $count = substr($arg,3);
        elseif ( ( substr($arg,0,8) == '--count:' ) )
                $count = substr($arg,8);
        elseif ( substr($arg,0,9) == '--length:' )
                $length = substr($arg,9);
        elseif ( substr($arg,0,3) == '-l:' )
                $length = substr($arg,3);
        elseif ( ($arg == '-p' ) | ($arg == '--pronounceable'))
                $p = TRUE;
        elseif ( ($arg == '-n' ) | ($arg == '--number-lines'))
                $number = TRUE;
}

$x=$y=0;

if ( !isset($count) )
        $count = 1;

switch($p)
{
        case TRUE:
                for ( $x=0 ; $x<$count ; $x++ )
                {
                        if ( $number == TRUE )
                                echo str_pad(++$y,4,' ',STR_PAD_LEFT).') ';
                        echo genpropwd($length)."\n";
                }
                break;
        case FALSE:
                for ( $x=0 ; $x<$count ; $x++ )
                {
                        if ( $number == TRUE )
                                echo str_pad(++$y,4,' ',STR_PAD_LEFT).') ';
                        echo genpwd($length)."\n";
                }
                break;
}

?>

attached mail follows:


On Sun, 18 May 2003 15:08:36 +0200, you wrote:

>Is it possible to call a static method from a object with call_user_func?
>Cause call_user_method needs an instance of an object as parameter, you
>can't pass a name of a class in a string.

You sound like a Java programmer :)

My first reaction was that this isn't possible, but I messed about for ten
minutes and came up with this:

<?
        /* Class A has method B */
        class A {
                function B ($s = "None") {
                        echo ("<p>input : $s</p>");
                }
        }

        /* C is an instance of A */
        $C = new A ();

        /* invoke A::B */
        A::B ("call 1");

        /* invoke C->B */
        $C->B ("call 2");

        /* invoke A::B via call_user_func() */
        call_user_func (array("A", "B"), "call 3");

        /* invoke C->B via call_user_func() */
        call_user_func (array($C, "B"), "call 4");

        /* invoke A::B via call_user_func_array() */
        call_user_func_array (array("A", "B"), array("call 5"));

        /* invoke C->B via call_user_func_array() */
        call_user_func_array (array($C, "B"), array("call 6"));
?>

Which seems to cover every possible variation. I think it's pretty nasty
unless you have a very good reason, but it's your code :)

Let me know if it works for you.

attached mail follows:


Bruce--

> I'm in need of a seriously good Login/Registration
> application.

Any of the open source content mangagement systems will
have this capability.

> This will form the basis of the user
> authenticatino portion of the site I'm developing.
. . .
> The language could be either PHP/Perl.

I would choose your overall platform first, then look for a
registration/authentication system using that platform.

> Thanks for your input. However, what we're looking for is
> for more than 100-200 lines of code...

Please see: http://pespmc1.vub.ac.be/OCCAMRAZ.html

> We're looking for
> something that's pretty robust... and incorporates a
> number of different security features.

The only requirements you've given us are
"registration/authentication". Authentication implies
authenticity, which implies security. Do you have
additional security reqirements? If so, what are they?

--Frappy

If you have specific

On Sunday 18 May 2003 02:31 am, Bruce Douglas wrote:
> Paul....
>
> Thanks for your input. However, what we're looking for is
> for more than 100-200 lines of code...We're looking for
> something that's pretty robust... and incorporates a
> number of different security features. Pretty sure that
> Yahoo/Amazon don't have 200 lines of code for their
> registration/login function!!!!!
>
> Be that as it may, we'd also be interested in something
> "Open Source" if it met our needs.. Our concern with
> writing it ourselves is that we let insecure items
> propagate through the code.... And yes.. we've been
> writing code for years.. so we're familiar with
> thoroughly testing the code... But this is why some basic
> functionality should be available so developers don't
> have to recreate the wheel from scratch.......
>
> Our $0.02 worth....
>
> Regards,
>
> Bruce
> bedouglasearthlink.net
>
>
> -----Original Message-----
> From: Paul Chvostek [mailto:paul+phpit.ca]
> Sent: Saturday, May 17, 2003 9:49 PM
> To: Bruce Douglas
> Cc: php-generallists.php.net
> Subject: Re: registration/login function....
>
> On Sat, May 17, 2003 at 05:24:50PM -0700, Bruce Douglas
wrote:
> > I'm in need of a seriously good Login/Registration
> > application.
>
> Lots of 'em out there, for both PHP and Perl. Rather
> than searching sourceforge and *scripts for "user
> authentication" scripts, you might get further ahead by
> finding a software package that authenticates the way you
> like, then use that source code as inspiration when you
> write your own.
>
> I use PHP for this sort of stuff.
>
> One method is to mimic .htaccess-style authentication as
> described on the Zend page you've no doubt already looked
> at. Another way is to use session variables. It's
> pretty straightforward -- the user supplies a username
> and password in a form, which is submitted to a script
> which checks them against the database, and sets a
> session variable that indicates to "secure" scripts that
> this user is kosher. In my case, I set elements in an
> array with session details for the user -- their
> username, customer ID, language preference, display
> theme, etc. Once the array is set, the login script
> forwards the user to a "secure" page, which checks for
> the existence of the session variables. If they're not
> set, the "secure" page forwards the user back to the
> login page. The code that does this is in a file
> require()d by each "secure" script on the site.
>
> All in all, the login intelligence I'm using here
> comprises less than 50 lines of PHP code. It was written
> a few years ago, so I could probably tighten it up even
> more if I felt the urge to rewrite.
>
> The moral here is that if you're developing software,
> develop the software. If you look for example code for
> every little thing you need to write, you'll never get
> anything finished. If instead of searching script
> archives for what you needed, you had just sat down and
> written it yourself, you'd likely be hours ahead. The
> search for a wheel that matches your precise
> specifications may very well take longer than simply
> reinventing it.
>
> > The core of this code should really be written so that
> > users don't have to recreate it as needed...!!!! I'm
> > looking for something "Open Source".
>
> I'm not sure what you mean by "recreate it as needed".
> And of course, any example code you find will likely be
> open source. Closed source things tend not to be
> distributed, because they're, well, closed source.

attached mail follows:


Hey...

Thanks for the responses....

Here are some of the requirements that I imagine a good
Login/Registration/User Authentication app should have:
        1) User/Passwd Form
        2) Session Based
        3) Database driven
        4) Modular design
        5) Key pages reside outside/beyond the user's ability to mofify
        6) All input vars are thoroughly checked/tested to ensure they are of the
correct
                type/length/etc...
        7) Regex checking is performed
        8) Thorough checking/testing of all SQL queries as well as all input to any
                SQL queries
        9) Open to public testing/checking
        10) Uses session vars to limit page access
        11) Handles users/groups of various access rights
        12) Admin Control Panel/Function
        13) Handles/Checks the following conditions:
                IP Address Checking/Deny
                Denies User Name usage from multiple IPs within a given amount of time
        14) Minimal usage of global vars

These are just a few and a first pass.... feel free to add your own. What
I'm getting at, is that this code is normally written, kindof works, and is
implemented.... We're looking for something a little better...

Thanks

Bruce
bedouglasearthlink.net

-----Original Message-----
From: Frappy John [mailto:frappyjohngulfbridge.net]
Sent: Sunday, May 18, 2003 9:41 AM
To: Bruce Douglas; php-generallists.php.net
Subject: Re: [PHP] RE: registration/login function....

Bruce--

> I'm in need of a seriously good Login/Registration
> application.

Any of the open source content mangagement systems will
have this capability.

> This will form the basis of the user
> authenticatino portion of the site I'm developing.
. . .
> The language could be either PHP/Perl.

I would choose your overall platform first, then look for a
registration/authentication system using that platform.

> Thanks for your input. However, what we're looking for is
> for more than 100-200 lines of code...

Please see: http://pespmc1.vub.ac.be/OCCAMRAZ.html

> We're looking for
> something that's pretty robust... and incorporates a
> number of different security features.

The only requirements you've given us are
"registration/authentication". Authentication implies
authenticity, which implies security. Do you have
additional security reqirements? If so, what are they?

--Frappy

If you have specific

On Sunday 18 May 2003 02:31 am, Bruce Douglas wrote:
> Paul....
>
> Thanks for your input. However, what we're looking for is
> for more than 100-200 lines of code...We're looking for
> something that's pretty robust... and incorporates a
> number of different security features. Pretty sure that
> Yahoo/Amazon don't have 200 lines of code for their
> registration/login function!!!!!
>
> Be that as it may, we'd also be interested in something
> "Open Source" if it met our needs.. Our concern with
> writing it ourselves is that we let insecure items
> propagate through the code.... And yes.. we've been
> writing code for years.. so we're familiar with
> thoroughly testing the code... But this is why some basic
> functionality should be available so developers don't
> have to recreate the wheel from scratch.......
>
> Our $0.02 worth....
>
> Regards,
>
> Bruce
> bedouglasearthlink.net
>
>
> -----Original Message-----
> From: Paul Chvostek [mailto:paul+phpit.ca]
> Sent: Saturday, May 17, 2003 9:49 PM
> To: Bruce Douglas
> Cc: php-generallists.php.net
> Subject: Re: registration/login function....
>
> On Sat, May 17, 2003 at 05:24:50PM -0700, Bruce Douglas
wrote:
> > I'm in need of a seriously good Login/Registration
> > application.
>
> Lots of 'em out there, for both PHP and Perl. Rather
> than searching sourceforge and *scripts for "user
> authentication" scripts, you might get further ahead by
> finding a software package that authenticates the way you
> like, then use that source code as inspiration when you
> write your own.
>
> I use PHP for this sort of stuff.
>
> One method is to mimic .htaccess-style authentication as
> described on the Zend page you've no doubt already looked
> at. Another way is to use session variables. It's
> pretty straightforward -- the user supplies a username
> and password in a form, which is submitted to a script
> which checks them against the database, and sets a
> session variable that indicates to "secure" scripts that
> this user is kosher. In my case, I set elements in an
> array with session details for the user -- their
> username, customer ID, language preference, display
> theme, etc. Once the array is set, the login script
> forwards the user to a "secure" page, which checks for
> the existence of the session variables. If they're not
> set, the "secure" page forwards the user back to the
> login page. The code that does this is in a file
> require()d by each "secure" script on the site.
>
> All in all, the login intelligence I'm using here
> comprises less than 50 lines of PHP code. It was written
> a few years ago, so I could probably tighten it up even
> more if I felt the urge to rewrite.
>
> The moral here is that if you're developing software,
> develop the software. If you look for example code for
> every little thing you need to write, you'll never get
> anything finished. If instead of searching script
> archives for what you needed, you had just sat down and
> written it yourself, you'd likely be hours ahead. The
> search for a wheel that matches your precise
> specifications may very well take longer than simply
> reinventing it.
>
> > The core of this code should really be written so that
> > users don't have to recreate it as needed...!!!! I'm
> > looking for something "Open Source".
>
> I'm not sure what you mean by "recreate it as needed".
> And of course, any example code you find will likely be
> open source. Closed source things tend not to be
> distributed, because they're, well, closed source.

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

attached mail follows:


i have two php scripts the first one says:
test.php
<?php
session_start();

if(!isset($_SESSION['testsession']))
  $_SESSION['testsession']=0;

//empty session array
$testsession=array();

$testsession['testthis']='hello';

echo(isset($testsession['testthis'])); //this prints
true

header("Location: test2.php");
?>

test2.php
<?php
session_start();

echo(isset($testsession['testthis'])); //this prints
false

session_unregister('testsession');
?>

What I can figure out is in the test.php script the
echo statement prints out true, in the test2.php
script the echo statement prints out false. Why does
it print out false?????

Thanks, Ben

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

attached mail follows:


> i have two php scripts the first one says:
> test.php
> <?php
> session_start();
>
> if(!isset($_SESSION['testsession']))
> $_SESSION['testsession']=0;
>
> //empty session array
> $testsession=array();
>
> $testsession['testthis']='hello';
>
> echo(isset($testsession['testthis'])); //this prints
> true

It is true because you just defined the variable directly before this.
It has no relation to the session at all, though.
 
> header("Location: test2.php");
> ?>
>
> test2.php
> <?php
> session_start();
>
> echo(isset($testsession['testthis'])); //this prints
> false

It should, there is no $testsession var in this script. You need to use
the $_SESSION array.

> session_unregister('testsession');

Don't do this, either. Use unset($_SESSION['testsession']);

Either use the $_SESSION array for everything, or use the session_*
functions (with register_globals on). Just because you have
$_SESSION['var'] = 1; it does not mean session_is_registered('var') will
return true. You can't mix the two.

So you want to set a session var:

$_SESSION['testsession'] = array();
$_SESSION['testsession']['testthis'] = 'hello';

And then to check later if it's set, use

If(isset($_SESSION['testsession']['testthis']))

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

attached mail follows:


On Sun, 18 May 2003 09:50:59 -0700 (PDT)
Donahue Ben <fun23_usyahoo.com> wrote:

> i have two php scripts the first one says:
> test.php
> <?php
> session_start();
>
> if(!isset($_SESSION['testsession']))
> $_SESSION['testsession']=0;
>
> //empty session array
> $testsession=array();
>
> $testsession['testthis']='hello';
>
> echo(isset($testsession['testthis'])); //this prints
> true
>
> header("Location: test2.php");
> ?>
>
> test2.php
> <?php
> session_start();
>
> echo(isset($testsession['testthis'])); //this prints
> false
>
> session_unregister('testsession');
> ?>
>
> What I can figure out is in the test.php script the
> echo statement prints out true, in the test2.php
> script the echo statement prints out false. Why does
> it print out false?????

A good idea is to always refer to any session data as
$_SESSION['whatever']. This way, your session arrays will always be intuitive
and passed over all the time as long as you've got session_start() on
top of your pages.

--
Maxim Maletsky
maximphp.net

attached mail follows:


Hello friends.

All I want to do is input our local time into the mysql database with time taken from a Unix server which is 15 hrs behind our time. We are keeping Japan time of GMT + 8 hrs.

I looked at many codes in PHp and Mysql and a bit confused.

Please help.

DM

attached mail follows:


> All I want to do is input our local time into the mysql database with
time
> taken from a Unix server which is 15 hrs behind our time. We are
keeping
> Japan time of GMT + 8 hrs.
>
> I looked at many codes in PHp and Mysql and a bit confused.

What format are you storing the time in? If it's a Unix timestamp in an
INT column, then use mktime() to add 15 hours to the time before you
insert it.

If you're storing it as a MySQL datetime format, then you can use
something like this while inserting or extracting..

INSERT INTO table (datetime_column) VALUES (NOW() + INTERVAL 15 HOUR)

Or

SELECT datetime_column + INTERVAL 15 HOUR, other, columns FROM table ...

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

attached mail follows:


On Mon, 19 May 2003 01:39:33 +0800
"Developer" <menezesdsingnet.com.sg> wrote:

> Hello friends.
>
> All I want to do is input our local time into the mysql database with time taken from a Unix server which is 15 hrs behind our time. We are keeping Japan time of GMT + 8 hrs.

Store all your timestamps as the GMT values directly - then, while
retrieving, get them with your current GMT difference. This is the
cleanest way to accomplish your task. I worked in Japan and this was
exactly how I've done some of such thingies.

--
Maxim Maletsky
maximphp.net

attached mail follows:


Hi,
Having a little logic problem here...This is my (original)code:
----------------------------------------------------------------------------
---
$q = "SELECT cno FROM main_co where user='".$user."' and pass='".$pass."'";
$r = mysql_result(mysql_query($q),0) or die("Error: " . mysql_error());

     $_SESSION['cno'] = $r;
----------------------------------------------------------------------------
---

what logic should I use to get/add $company and $site?
(This is what i want to make of it)
eg:
----------------------------------------------------------------------------
---
$q = "SELECT cno,company,site FROM main_co where user='".$user."' and
pass='".$pass."'";
$r = mysql_result(mysql_query($q),0) or die("Error: " . mysql_error());

     $_SESSION['cno'] =$r //???
     $_SESSION['company'] = $r // ???
     $_SESSION['site'] = $r; // ???
----------------------------------------------------------------------------
---

After reading up in the manual I think $r becomes an array/ or I should make
it an array or somehow use an array...right? I HATE arrays so dont really
know how to use them or even if I need one here...the only arrays I use are
the ones that return a resultset after querying the database.

Kindly reply,
-Ryan

attached mail follows:


On Monday 19 May 2003 01:43, Ryan A wrote:
> Hi,
> Having a little logic problem here...This is my (original)code:
> ---------------------------------------------------------------------------
>- ---
> $q = "SELECT cno FROM main_co where user='".$user."' and pass='".$pass."'";
> $r = mysql_result(mysql_query($q),0) or die("Error: " . mysql_error());
>
> $_SESSION['cno'] = $r;
> ---------------------------------------------------------------------------
>- ---
>
> what logic should I use to get/add $company and $site?
> (This is what i want to make of it)
> eg:
> ---------------------------------------------------------------------------
>- ---
> $q = "SELECT cno,company,site FROM main_co where user='".$user."' and
> pass='".$pass."'";
> $r = mysql_result(mysql_query($q),0) or die("Error: " . mysql_error());
>
> $_SESSION['cno'] =$r //???
> $_SESSION['company'] = $r // ???
> $_SESSION['site'] = $r; // ???
> ---------------------------------------------------------------------------
>- ---
>
> After reading up in the manual I think $r becomes an array/ or I should
> make it an array or somehow use an array...right? I HATE arrays so dont
> really know how to use them or even if I need one here...the only arrays I
> use are the ones that return a resultset after querying the database.

You're using the wrong function. You should be using one of these:
mysql_fetch_array(), mysql_fetch_assoc(), mysql_fetch_object(),
mysql_fetch_row().

In this particular you probably want to use mysql_fetch_assoc(), look it up in
the manual and follow the example.

--
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
------------------------------------------
/*
Can you MAIL a BEAN CAKE?
*/

attached mail follows:


> Having a little logic problem here...This is my (original)code:
>
------------------------------------------------------------------------
--
> $q = "SELECT cno FROM main_co where user='".$user."' and
> pass='".$pass."'";
> $r = mysql_result(mysql_query($q),0) or die("Error: " .
mysql_error());
>
> $_SESSION['cno'] = $r;
>
------------------------------------------------------------------------
--
> what logic should I use to get/add $company and $site?
> (This is what i want to make of it)
> eg:
>
------------------------------------------------------------------------
--
> $q = "SELECT cno,company,site FROM main_co where user='".$user."' and
> pass='".$pass."'";
> $r = mysql_result(mysql_query($q),0) or die("Error: " .
mysql_error());
>
> $_SESSION['cno'] =$r //???
> $_SESSION['company'] = $r // ???
> $_SESSION['site'] = $r; // ???
>
------------------------------------------------------------------------
--

Learn to use the mysql_fetch_* functions. The fetch a whole row instead
of one column from the result set.

$q = "SELECT cno,company,site FROM main_co where user='".$user."' And
pass='".$pass."'";

$rs = mysql_query($q) or die(...);

if($r = mysql_fetch_assoc($rs))
{
        $_SESSION['cno'] = $r['cno'];
        $_SESSION['company'] = $r['company'];
        $_SESSION['site'] = $r['site'];
}

Or you could use array_merge() instead of those last 3 lines.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

attached mail follows:


Hey,
Thanks John, the genius PHP problem solver as always :-)
Will give it a try and hopefully it should work, if not will write back.
Cheers,
-Ryan

> > Having a little logic problem here...This is my (original)code:
> >
> ------------------------------------------------------------------------
> --
> > $q = "SELECT cno FROM main_co where user='".$user."' and
> > pass='".$pass."'";
> > $r = mysql_result(mysql_query($q),0) or die("Error: " .
> mysql_error());
> >
> > $_SESSION['cno'] = $r;
> >
> ------------------------------------------------------------------------
> --
> > what logic should I use to get/add $company and $site?
> > (This is what i want to make of it)
> > eg:
> >
> ------------------------------------------------------------------------
> --
> > $q = "SELECT cno,company,site FROM main_co where user='".$user."' and
> > pass='".$pass."'";
> > $r = mysql_result(mysql_query($q),0) or die("Error: " .
> mysql_error());
> >
> > $_SESSION['cno'] =$r //???
> > $_SESSION['company'] = $r // ???
> > $_SESSION['site'] = $r; // ???
> >
> ------------------------------------------------------------------------
> --
>
> Learn to use the mysql_fetch_* functions. The fetch a whole row instead
> of one column from the result set.
>
> $q = "SELECT cno,company,site FROM main_co where user='".$user."' And
> pass='".$pass."'";
>
> $rs = mysql_query($q) or die(...);
>
> if($r = mysql_fetch_assoc($rs))
> {
> $_SESSION['cno'] = $r['cno'];
> $_SESSION['company'] = $r['company'];
> $_SESSION['site'] = $r['site'];
> }
>
> Or you could use array_merge() instead of those last 3 lines.
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>

attached mail follows:


The following sampl of code should help with what you're trying to do
regarding the mysql arrays....

To add anything.. you will have to alter the table schema..and then modify
the associated select/insert/update queries...

<?php
        //Auction - Items page
    $menuvar = 2;

        require('../mysql/dbconfig.inc');
        require('../mysql/database.php');
        require('../includes/items.inc.php');

        //initialize the database
        $result = db_connect($HOST, $USER, $PASSWORD);
        $result = db_select($DBNAME, $result);
?>

<?php
        $query = "select * from foo";
        $result = db_query($query);
        $object = db_fetch_array($result);
        $ii=count($object);

        for ($i=1;$i<$ii+1;$i++)
        {
                $auction = $object[$i]["auctionid"];
                $descr = $object[$i]["description"];
        }

        etc......
?>

Now... you need to remember that the retuned array starts with an ndx of 1.
The object returned from the db_fetch_array is simply an array of the
returned rows from the query...

I created a couple of simple functions that i use to encpasulate the mysql
functions...
//connects to the mysql database engine
//
function db_connect($dbhost,$dbuser,$dbpasswd) {
        global $conn;
        $conn = mysql_connect($dbhost,$dbuser,$dbpasswd)
                        or die("Could not connect: " . mysql_error());
        return $conn;
}

//select the specific database
//
function db_select($dbname, $conn) {
        $result = mysql_select_db($dbname, $conn)
                        or die(mysql_error());
        return $result;
}

//query the specific database
//
function db_query($query) {
        $result = mysql_query($query)
                                or die("Query error is: ".mysql_error());
        return $result;
}

//return the number of rows for a db_query
//this is used directly after a db_query call
//
function db_numrows($result) {
        $numrows = 0;
        $numrows = mysql_num_rows($result);
                // or die("Could not determine any rows: " . mysql_error());
        return $numrows;
}

function db_free_result($qhandle) {
        return mysql_free_result($qhandle);
}

function db_result($qhandle,$row,$field) {
        return mysql_result($qhandle,$row,$field);
}

function db_numfields($lhandle) {
        return mysql_numfields($lhandle);
}

function db_fieldname($lhandle,$fnumber) {
           return mysql_fieldname($lhandle,$fnumber);
}

function db_affected_rows($qhandle) {
        return mysql_affected_rows();
}

function db_fetch_single_array($qhandle) {
        $res = 0;
        $res = mysql_fetch_array($qhandle);
        if ($res){
                return $res;
        }else{
                return false;
        }
}

function db_fetch_array($qhandle) {
        $num_fields = mysql_num_fields($qhandle);
        $j=0;
        $x=1;
        while($row=mysql_fetch_array($qhandle))
        {
          for($j=0;$j<$num_fields;$j++){
           $name = mysql_field_name($qhandle, $j);
           $object[$x][$name]=$row[$name];
          }
          $x++;
        }
        return $object;
}

Have fun....

bruce

-----Original Message-----
From: Jason Wong [mailto:php-generalgremlins.biz]
Sent: Sunday, May 18, 2003 11:04 AM
To: php-generallists.php.net
Subject: Re: [PHP] a little logic...

On Monday 19 May 2003 01:43, Ryan A wrote:
> Hi,
> Having a little logic problem here...This is my (original)code:
> --------------------------------------------------------------------------
-
>- ---
> $q = "SELECT cno FROM main_co where user='".$user."' and
pass='".$pass."'";
> $r = mysql_result(mysql_query($q),0) or die("Error: " . mysql_error());
>
> $_SESSION['cno'] = $r;
> --------------------------------------------------------------------------
-
>- ---
>
> what logic should I use to get/add $company and $site?
> (This is what i want to make of it)
> eg:
> --------------------------------------------------------------------------
-
>- ---
> $q = "SELECT cno,company,site FROM main_co where user='".$user."' and
> pass='".$pass."'";
> $r = mysql_result(mysql_query($q),0) or die("Error: " . mysql_error());
>
> $_SESSION['cno'] =$r //???
> $_SESSION['company'] = $r // ???
> $_SESSION['site'] = $r; // ???
> --------------------------------------------------------------------------
-
>- ---
>
> After reading up in the manual I think $r becomes an array/ or I should
> make it an array or somehow use an array...right? I HATE arrays so dont
> really know how to use them or even if I need one here...the only arrays I
> use are the ones that return a resultset after querying the database.

You're using the wrong function. You should be using one of these:
mysql_fetch_array(), mysql_fetch_assoc(), mysql_fetch_object(),
mysql_fetch_row().

In this particular you probably want to use mysql_fetch_assoc(), look it up
in
the manual and follow the example.

--
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
------------------------------------------
/*
Can you MAIL a BEAN CAKE?
*/

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

attached mail follows:


On Sun, 18 May 2003 19:43:19 +0200
"Ryan A" <ryanjumac.com> wrote:

> Hi,
> Having a little logic problem here...This is my (original)code:
> ----------------------------------------------------------------------------
> ---
> $q = "SELECT cno FROM main_co where user='".$user."' and pass='".$pass."'";
> $r = mysql_result(mysql_query($q),0) or die("Error: " . mysql_error());
>
> $_SESSION['cno'] = $r;
> ----------------------------------------------------------------------------
> ---
>
> what logic should I use to get/add $company and $site?
> (This is what i want to make of it)
> eg:
> ----------------------------------------------------------------------------
> ---
> $q = "SELECT cno,company,site FROM main_co where user='".$user."' and
> pass='".$pass."'";
> $r = mysql_result(mysql_query($q),0) or die("Error: " . mysql_error());
>
> $_SESSION['cno'] =$r //???
> $_SESSION['company'] = $r // ???
> $_SESSION['site'] = $r; // ???
> ----------------------------------------------------------------------------
> ---
>
> After reading up in the manual I think $r becomes an array/ or I should make
> it an array or somehow use an array...right? I HATE arrays so dont really
> know how to use them or even if I need one here...the only arrays I use are
> the ones that return a resultset after querying the database.

Short answer:

Read deeper the manual - you still leak some understanding about the way
arrays work.

Long answer:

If you were to hold all the data in sessions, you should have assign the
whole resultset to your session and act through it.

$_SESSION['db_result'] = $r;

Alternatively, if only a few values were needed, refer directly to its
elements.

$_SESSION['db_result']['site'] = $r['site'];

moreover, as jason mentioned, you have some probs with the way you use
you DB connection. Try stealing some code from elsewhere.

--
Maxim Maletsky
maximphp.net

attached mail follows:


On Sunday 18 May 2003 14:54, Justin French wrote:

> I have an existing LAN server with php 4.1.2, MySQL 3.23 and Apache 1.3.2
> on FreeBSD. I want to upgrade PHP to 4.3.1, with gd support, trans-sid,
> and a few other goodies, so that my server is as close to my hosts as
> possible.

[snip]

> I've attempted to do a basic compile as per the manual's step-by-step, but
> I've got errors on "make".
>
>
> Right now, I'm thinking a pre-compiled package might be the go -- can
> anyone recommend a package which solves a fair bit of the above problems
> for me?

There's something called ApacheToolbox (or something like that) which is a
script that compiles Apache, Mysql and PHP for you. Select the modules and
other bits and pieces that you need from a menu and it'll download everything
you need then compile and install the whole lot for you. It can also make an
RPM for you.

BUT I'm not sure whether it'll work on FreeBSD ;-)

--
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
------------------------------------------
/*
Exceptions prove the rule, and wreck the budget.
                -- Miller
*/

attached mail follows:


On Sunday 18 May 2003 09:32, KEN - 2mediaZone wrote:
> Hi, I'm trying to do one job here.
> Please take look at a simple foreach loop below first.
>
> foreach($result_p as $key => $value)
>
> {
>
> $result[] = $result_p[$key];
>
> }

[snip]

Could you give the output of print_r($result_p)? It's easier to visualise the
problem given some real life data.

Of course, if $result_p contains 1000's of values just list the first 5-10
values.

--
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
------------------------------------------
/*
"Buy land. They've stopped making it."
-- Mark Twain
*/

attached mail follows:


Please read my previous postings. Any help here is appreciated.

attached mail follows:


On Sun, 18 May 2003 13:16:24 -0500
"Steve" <stevenhostway.com> wrote:

> Please read my previous postings. Any help here is appreciated.

Like which ones? Some of us are lazier to browse your posts than you are pasting
them in.

--
Maxim Maletsky
maximphp.net

attached mail follows:


Hi guys :)

Tonight i would likt to know hot to set the display order of data from mysql
with the field with the highest value being the first, i hope u follow.
here's what i have

    $query = "SELECT wall_scr, username, hscr_d FROM forumUsers WHERE
wall_scr>0 ORDER BY wall_scr ASC";

wall_scr= number whatever
h_scrd = date set
username= well...
I would have thought that the query would return the highest value in the
wall_scr field, but it dosnt.

anyone

Cheers

P.S
It's a highscore table

attached mail follows:


Hello ,

Try

$query = "SELECT wall_scr, username, hscr_d FROM forumUsers WHERE wall_scr>0 ORDER BY wall_scr DESC";

--
Best regards,
 Anton mailto:antonartprom.ru

attached mail follows:


Give me some credit.

Already tried that.

"Anton" <antonartprom.ru> wrote in message
news:6648785720.20030518233917artprom.ru...
> Hello ,
>
> Try
>
> $query = "SELECT wall_scr, username, hscr_d FROM forumUsers WHERE
wall_scr>0 ORDER BY wall_scr DESC";
>
>
>
> --
> Best regards,
> Anton mailto:antonartprom.ru
>

attached mail follows:


> > Try
> >
> > $query = "SELECT wall_scr, username, hscr_d FROM forumUsers WHERE
> > wall_scr>0 ORDER BY wall_scr DESC";
>
> Give me some credit.
>
> Already tried that.

Give us some credit; why didn't that work? If you only want a single row
returned, use LIMIT.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

attached mail follows:


On Monday 19 May 2003 03:48, - \[ Paul Ferrie \] - wrote:
> Give me some credit.
>
> Already tried that.

You should've said so.

If you want to order a set of results with the highest value first then ORDER
BY DESC *should* work.

So, can you show why it doesn't work?

- what is your dataset
- what is your code
- what results are you expecting
- what results did you actually get

--
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
------------------------------------------
/*
Loni Anderson's hair should be LEGALIZED!!
*/

attached mail follows:


PF> Give me some credit.

PF> Already tried that.

Try again :-)

What type has wall_scr? INT?

--
Best regards,
 Anton mailto:antonartprom.ru

attached mail follows:


Soz guys simple newbie mistake

the field was not set to INT

Cheers

"- -" <infoinnovativedesigns.org.uk> wrote in message
news:20030518192446.96693.qmailpb1.pair.com...
> Hi guys :)
>
> Tonight i would likt to know hot to set the display order of data from
mysql
> with the field with the highest value being the first, i hope u follow.
> here's what i have
>
> $query = "SELECT wall_scr, username, hscr_d FROM forumUsers WHERE
> wall_scr>0 ORDER BY wall_scr ASC";
>
> wall_scr= number whatever
> h_scrd = date set
> username= well...
> I would have thought that the query would return the highest value in the
> wall_scr field, but it dosnt.
>
> anyone
>
> Cheers
>
> P.S
> It's a highscore table
>
>
>

attached mail follows:


hi all,

i have a test form with 1 form field and the data from the form field is
inserted into a mysql db.

how do i make sure that no 2 same values can go into the database? I want
to validate it using PHP and not JavaScript or anything like that.

TIA

--

--
SP Computing
http://www.spcomputing.com
Assisting Windows® Users!

attached mail follows:


Sp Computing wrote:
> i have a test form with 1 form field and the data from the form field
> is inserted into a mysql db.
>
> how do i make sure that no 2 same values can go into the database? I
> want to validate it using PHP and not JavaScript or anything like
> that.

You can place an 'unique' requirement on the table-field.
this way MySQL won't let you insert a non-unique value into that field.

-Peter

attached mail follows:


> i have a test form with 1 form field and the data from the form field
is
> inserted into a mysql db.
>
> how do i make sure that no 2 same values can go into the database? I
want
> to validate it using PHP and not JavaScript or anything like that.

One way is to let your database handle it by declaring the column to be
UNIQUE. Then you simply cannot put a duplicate entry in.

You could also manage this with PHP by first doing a select to see if
the data exists. If it does not, then insert it, otherwise reject it.
You can run into trouble with this in high traffic situations where two
people may submit the same data at the same time unless you put locking
around both SQL statements.

Hope that helps.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

attached mail follows:


you could define the table schema as "UNIQUE" on the column that you don't
want duplicates for....

-----Original Message-----
From: SP Computing [mailto:webmasterspcomputing.com]
Sent: Sunday, May 18, 2003 1:06 PM
To: php-generallists.php.net
Subject: [PHP] Validate a form entry against an existing entry.

hi all,

i have a test form with 1 form field and the data from the form field is
inserted into a mysql db.

how do i make sure that no 2 same values can go into the database? I want
to validate it using PHP and not JavaScript or anything like that.

TIA

--

--
SP Computing
http://www.spcomputing.com
Assisting Windows® Users!

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

attached mail follows:


List,
    How can I get my PHP scripts running under Apache (as nobody:nobody) to
be able to run a command for iptables? iptables needs root access, but PHP
can't do it. Must I work a clever sudo trick? Can someone provide an
example, I have zero experience with sudo. Other options?

/B

attached mail follows:


Hi,
I have a table with around 30 fields, but most of the fields have only the
values 1 or 0.
I want to add the fields counter,month,day to the end of it so that i can
know how many times a particular record is being viewed...

I will have around 5000 records there on a pretty busy site and when someone
clicks the link to see that particular recored (for our example a record
with $cno=777)
I would 1) run a "update" for the $counter,$day based on $month and then
2)run a select to get all the data from the DB

my question is: if i get 5000 hits a day each fetching on an average of 10
records...will this put a big strain PHP/MySql?
I am on a shared server (cant afford a dedicated one).
Do you think i can safely implempt this (as i have not done so as yet) or
will the performance degrade so badly that the sacrifice for statistics too
high?

Your views are appreciated.
Cheers,
-Ryan

attached mail follows:


On Sun, 18 May 2003 22:41:57 +0200, you wrote:

>my question is: if i get 5000 hits a day each fetching on an average of 10
>records...will this put a big strain PHP/MySql?
>I am on a shared server (cant afford a dedicated one).
>Do you think i can safely implempt this (as i have not done so as yet) or
>will the performance degrade so badly that the sacrifice for statistics too
>high?

a) Questions about MySQL performance will get a better response on the MySQL
list

b) It depends on your hardware and your database size and structure. You
haven't given us the information we need to answer. Suck it and see

http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=mysql+profiling

5000 requests in a sixteen hour period equates to less than one every eleven
seconds, which doesn't seem onerous to me. YMMV.

Have you considered appending your statistics to a logfile (a flat file or a
separate database table), rotated daily/weekly, and parsing the logfiles
only when you want to review statistics? That's the way these things are
usually done.

attached mail follows:


On Sun, 18 May 2003 22:41:57 +0200
"Ryan A" <ryanjumac.com> wrote:

> Hi,
> I have a table with around 30 fields, but most of the fields have only the
> values 1 or 0.

You better have ENUM or SET datatype there. Hope this was already
thought by you.

> I want to add the fields counter,month,day to the end of it so that i can
> know how many times a particular record is being viewed...

two fields are more than enough - reference ID and a TIMESTAMP. let me
expand on this further below.

> I will have around 5000 records there on a pretty busy site and when someone
> clicks the link to see that particular recored (for our example a record
> with $cno=777)

As David pointed out - 5000 hits daily is pretty few. BUT, you might
want to study your log files to know the maximum amount of hits per
second that appeared to your site at any time of its existence. This
means, if 1000 hits were done in one only hour while other 4000 in 23 hours,
you should be understanding your traffic as 24.000 (24 * 1000) hits
daily max. It makes a big difference.

> I would 1) run a "update" for the $counter,$day based on $month and then
> 2)run a select to get all the data from the DB

Get two tables. One for logging in the ID of your product/data viewed
and the timestamp when it occured. Second one should be what you already
have but well indexed for a faster fetch (SELECT).

> my question is: if i get 5000 hits a day each fetching on an average of 10
> records...will this put a big strain PHP/MySql?

Keep in mind that, mySQL cannot afford too many record in it. I had
trouble with my tables (deadly crash and dataloss) once they were over a
million hits. This is something you would get within just half of the
year. And, your data would be huge there.

Do you really really really want to store the times of every hit? Think
about it - how often will you need to know that? Split them daily - like
hits of today update only one record andtomorrow there will be another
one. This will reduce your hits by 5000 times apprx while creating
another SELECT to know where to update. Simply incrementing the hit
count for a dataset would be much smarter.

> I am on a shared server (cant afford a dedicated one).

Another reason to follow my advice.

> Do you think i can safely implempt this (as i have not done so as yet) or
> will the performance degrade so badly that the sacrifice for statistics too
> high?

Performace will definitely decrease, you you might want to increment
only at the page's end with an at-mark () before the calls to DB. This
way, should anything fail your page would still load.

Consider also the most ideal logic - logging your hits in a simple flat
file and then build your stats once in a while. Writing to the file is
much faster than writing to the DB. And, since we are talking about
mySQL here the thread safety and data intergation is pretty much similar.

my regards to your interestind question

--
Maxim Maletsky
maximphp.net

attached mail follows:


Hi all....!

  i want to make timer with javascript, and some variables taken from
  database use php. but the problems are if user refresh (reload/F5)
  the browser, the time back to start. how the solution of this
  problem? maybe uses cookies? thanks before

---Riza Fahmi---

attached mail follows:


Ask on a javascript list/newsgroup. This has nothing to do with PHP.

Riza Fahmi wrote:

>Hi all....!
>
> i want to make timer with javascript, and some variables taken from
> database use php. but the problems are if user refresh (reload/F5)
> the browser, the time back to start. how the solution of this
> problem? maybe uses cookies? thanks before
>
>---Riza Fahmi---
>
>
>
>
>
>

--
The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.

attached mail follows:


On Sat, 17 May 2003, Robert Mena wrote:
> This seems like a real limitation that my turn into to
> trouble in a near future.
>
> Since the "recommended" apache is 2.0.x, bugfix and
> new features are expected to be available for such
> branch.

Apache1 is going to be maintained indefinitely. There are way too many
people using it without the option of switching to Apache2 for it to go
away. Many modules available for Apache1 are simply not available for
Apache2 yet and the module API has changed quite a bit.

> That will force us to stick with apache 1.3.x
> possibily narrowing the options of mod_something or
> usability.

At the moment, switching to Apache2 narrows your options much more.

> I know this is not motivating (specially with the 5.0
> devel) but it is surely necessary.

Why? Apache1 works just fine. When/if Apache2 gets to the same level of
stability and features as Apache1 we will look at it harder. It is simply
not there at this point.

-Rasmus

attached mail follows:


Hello everybody.

I don't have so clear the phrase "binary safe"
function.

Is a binary safe function one that will correctly
recognize all data, rather than only ASCII text?

Can anyone explain me what a binary safe function is
or where can I find this concept explained.

Thanks.

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

attached mail follows:


If you suspect it's JS related, then view>source in your browser, and check
the code is what you expected. If it is, copy the related code bits into an
email, and send it/post it to a JS newsgroup or list.

Easy.

Justin

on 17/05/03 4:39 AM, InfoBest-IT (infobest-it.biz) wrote:

> I have a drop dow list with the following options:
>
> "<option name=\"title$i\" value=\"$id\" onChange=\"return
> reloadLoc();\">$element</option>\n";
>
> It is getting built in a while loop. I also have a file called loc.html
> that holds the java script function. So I read in that function with the
> following method:
>
> function SetScripts($filename)
> {
>
>
>
> $handle = fopen($filename, "r");
>
>
> $contents = fread($handle, filesize($filename));
>
>
> $this->scripts = $contents;
>
>
> fclose($handle);
>
>
> }
>
> $this->scripts then gets passed to a display() function. The HTML looks
> good in the source code of the page but does not execute. Here is my JS:
>
>
> <script language="JavaScript1.4" type="text/javascript">
> function reloadLoc()
> {
> window.location.href = "http://cajunmikes.com/adminform.php?table=$id";
> window.location.reload();
> }
> </script>
>
> Any insights why it won't work?
>
> /T
>