RE: [PHP] Generate Random Letters?

2001-03-09 Thread Nathaniel Hekman

Random lower-case letter:

$randomletter = chr(rand(ord("a"), ord("z")))

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 09, 2001 8:13 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Generate Random Letters?


I know it is possible to generate a random number using rand() I don`t 
suppose there is anyway to generate a random letter sequence that anyone 
knows of?

Ade

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Strings..

2001-03-09 Thread Nathaniel Hekman

Could parse_str() help?

From http://php.net/manual/en/function.parse-str.php:

void parse_str (string str [, array arr])

Parses str as if it were the query string passed via an URL and sets
variables in the current scope. If the second parameter arr is present,
variables are stored in this variable as an array elements instead. 


-Original Message-
From: Ashwin Kutty [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 09, 2001 9:04 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Strings..



Was wondering if someone could tell me how I could do this..

I need the dynamically generated number (NUM) from a string, where the
string is:-

http://blah.blah.com/blah/blah?blah.com/blah=something:%3Asessionid=NUMdb
name=blah

Now I tried explode and split, with the '' being as the delimiter, but
how do you dump the rest of the string..


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] need help w/ Split()

2001-03-08 Thread Nathaniel Hekman

Your regex is incorrect.  You've written:

/[\,\;\s*]/

That * means "match a *" because it's inside the brackets.  Put it outside,
like this (actually use a + instead):

/[\,\;\s]+/

to match 1 or more of any of those characters.

That may not be exactly what you want, since that will also cause this:

input "0101, 0102,0103" == [0101][0102][0103]

If you want repeated commas to create empty elements, then try something
like this:

/\s*[\,\;\s]\s*/

I haven't tried that, but it looks right at first glance...  Optional white
space, followed by exactly one of ',; ', followed by optional white space.


Nate

-Original Message-
From: Scott Walter [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 08, 2001 10:44 AM
To: [EMAIL PROTECTED]
Subject: [PHP] need help w/ Split()


I am attempting to take a line of text (a list) that has been entered into 
a form and split it into the appropriate parts, placing them into an 
array.  I am splitting the input on commas, semi-colons, and spaces.

Problem 1:  Is with "white space".  If the input has spaces after a comma, 
it splits on the comma, but enters each "space" as a separate element of 
the array.

Problem 2: Is with "white space" also.  If the input has just spaces 
between the appropriate parts, then it will split on the first "space", but 
enter the rest of the "spaces" as separate elements of the array.

Here my code:
$course_list = preg_split("/[\,\;\s*]/", $input_list);
for ($i=0; $icount($course_list); $i++) {
echo("Item $i: $course_list[$i]br\n");
}

Which on input "0101, 0102,  0103" produces [0101][ ][0102][ ][ ][
][0103]

Any help would be appreciated!!


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] parsing html / xml

2001-03-07 Thread Nathaniel Hekman

I'd like to parse a html file in much the same way the xml parser works.  Ie
calling a method for every tag encountered and so on.  The xml parsing
methods don't seem to be forgiving enough for much of the html that's out
there.  For example, many html files have tags like this:

TABLE border=0

but xml_parse() will choke on it because there are no quotes around the "0".
Also html tags are, in practice, case insensitive, so this is found in many
html documents:

BThis is bold/b

but xml_parse() doesn't like it because it expects the opening and closing
tags to be same-case.

Are there other functions or libraries I'm not aware of that help in parsing
html?  Or some options in xml_parse to get by these problems?

Thanks in advance.


Nate

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] parsing html / xml (more)

2001-03-07 Thread Nathaniel Hekman

Here's another case that shows up often in html, but is illegal in xml, that
I would need to parse:  meta tags, p tags, hr tags, and other
"singletons".

HEAD
META HTTP-EQUIV="Content-Type" CONTENT="text/html"
/HEAD

xml_parse would give an error, because the HEAD block is being closed with a
still-open META "block".


Nate

-----Original Message-
From: Nathaniel Hekman [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 07, 2001 9:57 AM
To: '[EMAIL PROTECTED]'
Subject: [PHP] parsing html / xml


I'd like to parse a html file in much the same way the xml parser works.  Ie
calling a method for every tag encountered and so on.  The xml parsing
methods don't seem to be forgiving enough for much of the html that's out
there.  For example, many html files have tags like this:

TABLE border=0

but xml_parse() will choke on it because there are no quotes around the "0".
Also html tags are, in practice, case insensitive, so this is found in many
html documents:

BThis is bold/b

but xml_parse() doesn't like it because it expects the opening and closing
tags to be same-case.

Are there other functions or libraries I'm not aware of that help in parsing
html?  Or some options in xml_parse to get by these problems?

Thanks in advance.


Nate

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] parsing html / xml (more)

2001-03-07 Thread Nathaniel Hekman

Matt McClanahan wrote:
[...]
 You're not going to find an XML parser that allows for most HTML,
 because if such a parser did exist, it would be a broken XML parser. :)
[...]

Fair enough, and that's as I expected.  So that brings me to the second part
of my question:  is there any php library that allows parsing of html?

Perhaps I'll have to write one myself.  All I want really is something that
parses a bunch of text and calls handlers whenever tags are encountered.
Just like xml_parse, except I don't care if tags are out of order, I don't
care about case, and I don't care if there is a close tag for every open.
If anyone knows of a package that does this, please advise.  If anyone else
would be interested in this, let me know and I could post my code when I'm
done (if I have to do this myself).


Nate

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] performing tasks with a user's rights

2001-02-02 Thread Nathaniel Hekman

Is there any way for a php script to perform some task as a particular user?
Here's what I'm trying to do in particular:

I have a Linux box with a handful of users.  These users do not have shell
access, but they do have ftp (for file uploads to their web sites), pop,
imap, etc.  I'd like to provide an easy way for them to change their
passwords (at least, and possibly also edit some files like their aliases
file (virtual mail hosting) and so on).  To do this through a web interface,
I want first of all to authenticate them, then to get their new password,
say, from a form submittal, and run passwd.

Any suggestions?  Do I have to run apache as root?  (Shudder!)  Are there
packages out there that do this already, or that I could use as an example?

TIA.


Nate

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]