php-general Digest 20 Feb 2006 12:10:00 -0000 Issue 3974

Topics (messages 230721 through 230734):

Re: Looping from A to Z
        230721 by: Philip Hallstrom
        230722 by: Al
        230724 by: tedd
        230728 by: Jim McIntyre

Re: HN CAPTCHA at http://www.phpclasses.org
        230723 by: tedd
        230725 by: Gerry Danen
        230726 by: comex
        230729 by: Gerry Danen

Re: Recursive permissions
        230727 by: Chris
        230731 by: Curt Zirzow

Re: PHP/LDAP Authentication
        230730 by: Delamatrix

PHP generated JavaScript
        230732 by: Tim Burgan
        230733 by: Curt Zirzow

Re: menu Q
        230734 by: William Stokes

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 ---
Good afternoon. I'm having trouble getting PHP to loop from A through Z. Here is what I tried, coming from a C background:

for ($l = "A"; $l <= "Z"; $l++)
   echo $l;

// Returns A, B, C, ..., X, Y, Z, AA, AB, AC, AD, AE, ... YX, YY, YZ. (26 * 26 results!)

Interestingly, if I make it a "less than" operation instead of "less than or equal to", it works correctly (except for the Z):

for ($l = "A"; $l < "Z"; $l++)
   echo $l;

// Returns A, B, C, ..., W, X, Y  (25 results)

Anyone know why PHP would do that?

Nope... but try...

for ( $l = ord("A"); $l <= ord("Z"); $l++ )
        echo $l;

Also maybe check out the range() function.

-philip

--- End Message ---
--- Begin Message ---
Richard K Miller wrote:
Good afternoon. I'm having trouble getting PHP to loop from A through Z. Here is what I tried, coming from a C background:

for ($l = "A"; $l <= "Z"; $l++)
     echo $l;

// Returns A, B, C, ..., X, Y, Z, AA, AB, AC, AD, AE, ... YX, YY, YZ. (26 * 26 results!)

Interestingly, if I make it a "less than" operation instead of "less than or equal to", it works correctly (except for the Z):

for ($l = "A"; $l < "Z"; $l++)
     echo $l;

// Returns A, B, C, ..., W, X, Y  (25 results)

Anyone know why PHP would do that?

Richard

---
Richard K. Miller
www.richardkmiller.com


foreach(range('a', 'z') as $value){

        echo $value;
}

--- End Message ---
--- Begin Message ---
Good afternoon. I'm having trouble getting PHP to loop from A through Z. Here is what I tried, coming from a C background:

for ($l = "A"; $l <= "Z"; $l++)
     echo $l;

// Returns A, B, C, ..., X, Y, Z, AA, AB, AC, AD, AE, ... YX, YY, YZ. (26 * 26 results!)

Interestingly, if I make it a "less than" operation instead of "less than or equal to", it works correctly (except for the Z):

for ($l = "A"; $l < "Z"; $l++)
     echo $l;

// Returns A, B, C, ..., W, X, Y  (25 results)

Anyone know why PHP would do that?

Richard


I don't see the problem.

There are 26 letters. If you say start at A and finish before Z, then you should expect 25 letters returned.

Maybe there is something I'm not understanding.

tedd
--
--------------------------------------------------------------------------------
http://sperling.com/

--- End Message ---
--- Begin Message ---
>>Good afternoon.  I'm having trouble getting PHP to loop from A
>>through Z.  Here is what I tried, coming from a C background:
>>
>>for ($l = "A"; $l <= "Z"; $l++)
>>      echo $l;
>>
>>// Returns A, B, C, ..., X, Y, Z, AA, AB, AC, AD, AE, ... YX, YY, YZ. 
(26 * 26 results!)
>>
>>Interestingly, if I make it a "less than" operation instead of "less
than or equal to", it works correctly (except for the Z):
>>
>>for ($l = "A"; $l < "Z"; $l++)
>>      echo $l;
>>
>>// Returns A, B, C, ..., W, X, Y  (25 results)
>>
>>Anyone know why PHP would do that?
>>
>>Richard
>

>From the PHP docs:

PHP follows Perl's convention when dealing with arithmetic operations on
character variables and not C's. For example, in Perl 'Z'+1 turns into
'AA', while in C 'Z'+1 turns into '[' ( ord('Z') == 90, ord('[') == 91 ).
Note that character variables can be incremented but not decremented.

-Jim

--- End Message ---
--- Begin Message ---
Manuel:

A good CAPTCHA must be fuzzy. If you know other fuzzy CAPTCHA besides
these, it may help to sharing that knowledge.

Try this:

http://xn--ovg.com/no_bot

The point of CAPTCHA is to provide something that a bot can't figure out, but a human can, right?

Well, for a bot to figure out the answer, the bot must be able to get at the source code, right? Take a look at this source code and from it determine the answer. Also, try to view the "content" source code from any page on this site. I think this data is bot-proof, isn't it? Or have I blundered?

Many thanks for any review and/or suggestions.

tedd

--
--------------------------------------------------------------------------------
http://sperling.com/

--- End Message ---
--- Begin Message ---
You got me. Where are you hiding it?

Gerry

On 2/19/06, tedd <[EMAIL PROTECTED]> wrote:
> Manuel:
>
> >A good CAPTCHA must be fuzzy. If you know other fuzzy CAPTCHA besides
> >these, it may help to sharing that knowledge.
>
> Try this:
>
> http://xn--ovg.com/no_bot
>
> The point of CAPTCHA is to provide something that a bot can't figure
> out, but a human can, right?
>
> Well, for a bot to figure out the answer, the bot must be able to get
> at the source code, right? Take a look at this source code and from
> it determine the answer. Also, try to view the "content" source code
> from any page on this site. I think this data is bot-proof, isn't it?
> Or have I blundered?
>
> Many thanks for any review and/or suggestions.

--
Gerry
http://portal.danen.org/

--- End Message ---
--- Begin Message ---
> You got me. Where are you hiding it?

In test.js:
http://www.xn--ovg.com/no_bot/rpc.php?action=one

Unless you hide it in a different place each time, how useful is that?

--- End Message ---
--- Begin Message ---
How would a bot find it though?

On 2/19/06, comex <[EMAIL PROTECTED]> wrote:
> > You got me. Where are you hiding it?
>
> In test.js:
> http://www.xn--ovg.com/no_bot/rpc.php?action=one
>
> Unless you hide it in a different place each time, how useful is that?

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

I am aware of how to change the contents of a directory to a specific chmod using a recursive php routine, but I was looking for a simpler way.

That's the only way.

Doing it through ftp, the ftp program does the recursive stuff - not the ftp server.
--- End Message ---
--- Begin Message ---
On Sat, Feb 18, 2006 at 06:07:16PM -0500, tedd wrote:
> >On 2/18/06, tedd <[EMAIL PROTECTED]> wrote:
> >> Hi gang:
> >>
> >> Question: I know you can set a directory to have certain permissions,
> >> but how do you set the permissions to be recursive? In other words,
> >> for example, if you set the directory to be 755, then everything
> >> placed within that directory will also be 755.
> >
> >http://php.net/manual/en/function.umask.php
> >
> >--
> >Kim Christensen
> 
> 
> Kim:
> 
> Thanks, but are you sure about that?

In a way, yes. It is rather unclear because, well a 755 on a normal
file isn't and shouldn't be needed. 

It also depends on how the file is created, by default most file
creation tools will always try to create a file with 666
permissions and  directory creation with 777.  The umask is an XOR
value that should be applied to the creation. 

Assuming umask is set to 022, when you create a dir
777 XOR 022 == 755; make a file, 666 XOR 022 = 644.

So if your directories dont end up with a 755 setting your umask is
set to something other than 022. 

> 
> What I'm looking for is how to set the permissions for a directory 
> such that all files in it will have the same permissions.

Directoryies require that you have the x (execution aka octet 1) bit set in
order to get a listing of the directory. Thus why you have 755 on
directories. 

Files should only have the x bit set if they actually should be
executed, otherwise they should be 644.

Now with all that. if you set a umask of 133, and dont need to ever
get a directory listing of files, you most likely will be able to
maintain a file structure that everything has the same permissions
but it will only be 644.

> 
> I use GoLive and in their file "FTP access" settings they have a 
> recursive checkbox. If the checkbox is not checked, then whatever 
> permission setting I give to a directory is just to the directory. 
> However, if it the recursive checkbox is checked, then all files 
> placed in the directory will have the directory's permissions. 
> Perhaps this is something limited to GoLive and not an option in 
> setting chmod's via php's built-in functions.
> 
> I am aware of how to change the contents of a directory to a specific 
> chmod using a recursive php routine, but I was looking for a simpler 
> way.

Your question is really not clear what the problem is.  It seems
you are having some issues with permissions, and is probably due to
your ftp access vs your web access but that is a guess at this
point.

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
Thanks for all the help!  I'll check it out.

- Delamatrix


Weber Sites LTD wrote:
Maybe this can help :

Authentication script to authenticate users in Active Directory through
LDAP.
http://www.weberdev.com/get_example-3261.html
Sincerely berber Visit the Weber Sites Today, To see where PHP might take you tomorrow. Search for PHP Code from your browser http://toolbar.weberdev.com Free Uptime Monitor : http://uptime.weberdev.com
SEO Data Monitor http://seo.weberdev.com


-----Original Message-----
From: Golden Butler [mailto:[EMAIL PROTECTED] Sent: Sunday, February 19, 2006 8:40 AM
To: PHP Mailing List
Subject: [PHP] PHP/LDAP Authentication



I'm currently running OpenLDAP with some users populated in the database.  I
would like to use PHP to create a web page where my ldap users can enter
their username and password credentials to log into our intranet.  Can
someone point me to some expample scripts, articles, or sites.  Thanks.

- Delamatrix

--- End Message ---
--- Begin Message ---
Is is possible to make an external Javascript with PHP.

Am I doing this correcT?

<?php

header("Content-Type: text/javascript");

$text = "Hello World";

echo "alert('".$text."');";

?>

--- End Message ---
--- Begin Message ---
On Mon, Feb 20, 2006 at 06:29:12PM +1030, Tim Burgan wrote:
> Is is possible to make an external Javascript with PHP.
> 
> Am I doing this correcT?
> 
> <?php
> 
> header("Content-Type: text/javascript");
> 
> $text = "Hello World";
> 
> echo "alert('".$text."');";
> 
> ?>

This looks perfectly fine.

There are a few things you have to be careful with:
  - php strings can handle line endings, consider if you have:

    $text = "Hello\nWorld";
    echo alert('". $text ."');

    You will end up with a javscript error.

  - A typical javascript file that resides on on a webserver will
    only be requested once from the webserver (pending cache
    settings) so resources for a page load will be minimal. If you
    have a php script output javascript, the browser will request
    the file on each request.

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
YOU are the MAN! Thanks!!!

-W


"Rafael" <[EMAIL PROTECTED]> kirjoitti 
viestissä:[EMAIL PROTECTED]
I use Fx 1.5.0.1 and Opera 9-prev2 and everything seems to be Ok.  The
select it's inside a form, and my guess is that you haven't set any
padding/margin for that form, so try adding something like
   FORM {
     padding: 0;
     margin:  0;
   }

By the way, this questions should not be here, what Kim posted was a
really better place to post it: http://www.css-discuss.org
--having said that, I must confess I thought I was reading a message
   from that list, so maybe you got confused as well?

William Stokes wrote:
> I have a <select> menu on a header bar on my page. The header bar is 20px 
> high. The menu, code and style below, works ok on Opera but not in Ie6 or 
> Firefox. In these browsers the menu 'streches' the bar height so that the 
> bg image starts repeating itself. (looks nasty) It's almost like the menu 
> prints one 'invisble' or empty row beneath the menu so that the header bar 
> becomes about 30 or 35px high. Any ideas?
>
[···]
> $sql="SELECT * FROM x_table ORDER BY sorter ASC";
> $result=mysql_query($sql);
> $num = mysql_num_rows($result);
> $cur = 1;
> print "<form name=\"form\">";
> print "<select name=\"val_team\" size=\"1\" id=\"menu\" 
> onChange=\"javascript:goToURL()\">";
> print "<option selected value=\"\">Valitse joukkue:</option>";
> while ($num >= $cur) {
> $row = mysql_fetch_array($result);
> $jouk_nimi = $row["jouk_nimi"];
> $team_id = $row["jouk_id"];
> print "<option value=\"index.php?team=$team_id\">$jouk_nimi</option>";
> $cur++;
> }
> print "</select>";
> print "</form>";
>
>
> StyleSheet:
>
> #menu{
>  height: 18px;
>  font-family: Arial, Helvetica, sans-serif;
>  font-size: 12px;
>  font-weight: bold;
>  text-align: left;
>  background-color: #CC0000;
>  BORDER-RIGHT: #FFFFFF 1px solid;
>  BORDER-TOP: #FFFFFF 1px solid;
>  BORDER-LEFT: #FFFFFF 1px solid;
>  BORDER-BOTTOM: #FFFFFF 1px solid;
>  COLOR: #FFFFFF;
> }
-- 
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
[EMAIL PROTECTED]
http://www.innox.com.mx 

--- End Message ---

Reply via email to