Re: [PHP] Re: How to tell if the filepath exist or not before attempting to create a directory??

2004-12-02 Thread Marek Kilimajer
Richard Lynch wrote:
Scott Fletcher wrote:
Never mind that..  I found a different way to use it.  It would be so cool
if there is such a feature as directory_exists() to check for partical
filepath...

http://php.net/file_exists
You'll need to use @ in front, because it generates an error message when
it doesn't find the file you're not sure exists. :-(
What version? On 5.0.2 file_exists('nonexistingfile'); does not generate 
any error message.

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


Re: [PHP] transparant session propagation and headers

2004-12-02 Thread B . Kamer
On Dec 1, 2004, at 22:19, Richard Lynch wrote:
Bas Kamer wrote:
On Dec 1, 2004, at 21:17, Richard Lynch wrote:
If a client doen't accept cookies and transparant session 
propagation
is enabled, links are changed to include the SID. But this is not 
the
case while redirecting clients. This results in session loss unless
you
manually add the session id to the redirect url. Not really
transparant...

I was wondering if this is correct behavior or a bug in php.
Feature.
There's no way PHP can "know" if you are re-directing to something
where
you want the sesssion propogated or not.
thanks for your answer...
shouldn't the following tell php whether session propagation is 
needed.

php.ini
strlen(SID)
redirect url is within the same domain
i mean, anchors do get SID added when within the same domain and
transparant propagation is ON.
H.  I can see your point...
Too many people (who shouldn't be using Redirect in the first place) 
are
doing so with the expectation that a Redirect will nuke the session 
data.

So you'd have a Legacy issue to work with on this one.
Worth a try, though, if you really think it's important.  Note that you
can append the SID by hand to your URL in the Redirect.
It's also really hard to say for sure that that's what most people 
*want*
PHP to do.
nope, if its an feature it a feature, i can live with it... i just 
wanted to know if its on overlooked issue or a conscious decision.

thank you for the insights
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] picture upload

2004-12-02 Thread William Stokes
Hello,
I'm building a web site for a sports team. I wan't them to be able to update
their own site so I need to build a file upload system for their pictures.
Pictures also need to resized to fit their spot in the web page. Any ideas
or quidelines how to do this. I've never done this kind of stuff before.
Thanks IA

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



[PHP] Differences in arrays

2004-12-02 Thread Stuart Felenstein
I have arrays set up in a user form.  One type is from
a multi-select list. (I'm passing these through a
multi page form as session variables)

The multi select list array code is like this:

To $_POST (going on to next page)I have this:

$_SESSION['industry'] = $_POST['L_Industry'];

Then in the final page where the database insert takes
place:

if ( is_array($_SESSION['industry'] ) ) {
foreach ($_SESSION['industry'] as $p ) {
$query = "INSERT INTO Prof_Industries (ProfID, IndID)
VALUES ('$LID', '$p')";  
 
$res4 = run_query($query);

This seems to work just fine as the printout(echo) :

INSERT INTO Prof_Industries (ProfID, IndID) VALUES
('118', '1')

NOW here is the problem:

I have 3 textfield elements all named school[]

To post those:

$_SESSION['schools'] = $_POST['school'];

Then in preparation for insert:

if ( is_array($_SESSION['schools'] ) ) {
foreach($_SESSION['schools'] as $h) {
$query = "INSERT INTO Prof_Schools (ProfID, School)
VALUES ('$LID', '$h')";
$res6 = run_query($query);
echo $query;
}
}
But here is the problem, it seems if the user didn't
input on all 3 textfields the query fails, because the
array is printing out like this:

INSERT INTO Profiles_Schools (ProfID, School) 
VALUES ('118', 'Baruch')

INSERT INTO Profiles_Schools (ProfID, School) 
VALUES ('118', '')

INSERT INTO Profiles_Schools (ProfID, School) VALUES
('118', '')

So you see there is no value for 2 and 3 as the user
didn't input.  But the array moves through the
elements anyway as the ProfID is assigned in the
query.

1-I guess I need a way to make sure in the foreach
that when the first empty element is reached the loop
dies.

2- Why would the second array behave differently then
the first ?

Stuart
Sorry for the long post. Just wanted to makre sure it
was clear in details.

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



Re: [PHP] Differences in arrays

2004-12-02 Thread Mike Smith
How about:


if ( is_array($_SESSION['schools'] ) ) {
foreach($_SESSION['schools'] as $h) {
If($h!=""){ //First added line
$query = "INSERT INTO Prof_Schools (ProfID, School)
VALUES ('$LID', '$h')";
$res6 = run_query($query);
echo $query;
} //End added line
   }
}

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



Re: [PHP] Differences in arrays

2004-12-02 Thread Stuart Felenstein
--- Mike Smith <[EMAIL PROTECTED]> wrote:

> How about:
> 
> 
> if ( is_array($_SESSION['schools'] ) ) {
> foreach($_SESSION['schools'] as $h) {
> If($h!=""){ //First added line
> $query = "INSERT INTO Prof_Schools (ProfID, School)
> VALUES ('$LID', '$h')";
> $res6 = run_query($query);
> echo $query;
> } //End added line
>}
> }
Yes, I did that and it works correctly now. I was
tryin g to better understand why the difference in the
behaviour.  

Stuart

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



Re: [PHP] Differences in arrays

2004-12-02 Thread Mike Smith
> Yes, I did that and it works correctly now. I was
> tryin g to better understand why the difference in the
> behaviour.
> 
> Stuart


The first array is created by selecting individual elements from a
muli-select list
(My multi-select is a little hazy, but I think it's something like...)


One (Selected)
Two
Three (Selected)
Four


...would create a 2 element array. The second array is created by the
rendered objects. I'm guessing you created text fields like:





...That creates an array with 3 values, empty until the user types
something, upon POST (or GET) of the form.

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



[PHP] Too many DELETE statements

2004-12-02 Thread news.php.net
I have 160,000+ members in my site. 40,000 of them have not logged in since
2003 and they should be deleted. A member is not deleted from only one
table. Based on user id, he should be deleted from 5 tables and also his
photo, if any, should be unlink(ed).

I tried to do that 10 by 10 using:

$query = "delete from table1 where userid = " . $ID;
$result = mysql_query($query, $link);

$query = "delete from table2 where userid = " . $ID;
$result = mysql_query($query, $link);

...

But even with only 10 members, the page takes 30-60 seconds to come back to
me. What is the best way to accomplish this? And it is possibe to delete
1000 by 1000 or 100 by 100?

Thanks.

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



[PHP] XML Downstream

2004-12-02 Thread Luc Pascal
Hi php-general-team,

An large XML Downstream over asp should be saved into a xml-file. If I
open the asp website directly (IE6.0). It shows after 15 min a big part
of the xml-stream (like if I would open an xml-file with the browser)
and a failure at the end. I don't know how to save it into Harddisk,
before a failure-window popup, wich says "Not enough virtual memory,
because stylesheet is activated". And I wouldn't know how to continue
from the rest of the stream on. I thought there's an easy way to
develope a documentpipe with php. Can you show me some example, how to
get a datastreama into files?

Thank you very much for help
Pascal Luc

---
Pascal Luc
Client/System Support (Applicationdeveloping)
SSZ

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



Re: [PHP] Parse error: parse error, expecting `']'' in

2004-12-02 Thread Robert Sossomon
Richard Lynch is quoted as saying on 12/1/2004 2:57 PM:
Robert Sossomon wrote:
Parse error: parse error, expecting `']'' in file.php


Unfortunately?? I knew exactly where the code was breaking (the lines I posted) 
since before I added those lines of code the script worked without any problems. 
 But what I don't understand is why sometimes '$_POST[variable]' works and why 
sometimes it will only work when it is '$_POST['variable']' .

Even through my reading and examples I see it both ways, so anyone able to give 
me a direction to go with it?  I am thinking of just changing my coding to put 
it the second way, but...???

Thanks,
Robert
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re[2]: [PHP] Parse error: parse error, expecting `']'' in

2004-12-02 Thread Richard Davey
Hello Robert,

Thursday, December 2, 2004, 1:21:33 PM, you wrote:

RS> Unfortunately?? I knew exactly where the code was breaking (the
RS> lines I posted) since before I added those lines of code the
RS> script worked without any problems. But what I don't understand is
RS> why sometimes '$_POST[variable]' works and why sometimes it will
RS> only work when it is '$_POST['variable']' .

It should always be the second way ($_POST['var']), although the first
way *will* work most of the time it was cause PHP to first check to
see if 'var' is a defined constant, and then a variable. If it is a
constant, it will substitute that value instead which could cause no
end of problems.

When called with: test.php?a=a&b=b the following should print out ab.
Remove the quotes from $_GET[a] and you'll see the difference.



Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I am not young enough to know everything." - Oscar Wilde

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



RE: [PHP] Parse error: parse error, expecting `']'' in

2004-12-02 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 01 December 2004 19:29, Matthew Sims wrote:

> 
> So when using arrays with string keys within strings you need to
> concatenate it. 
> 
> $var = "I live in the city of ". $_POST['cityname'];

No, you do not *need* to -- it is one option, certainly, but there is no
necessity about it.

Within double-quoted strings, it is perfectly acceptable to use unquoted
array keys:

$var = "I live in the city of $_POST[cityname]";

If you prefer to quote your keys, or have more complex expressions within
the brackets, there is also the {} syntax:

$var = "I live in the city of {$_POST['cityname']}";

$field = 'city';
$var = "I live in the $field of {$_POST[$field.'name']}";

Anyway, read up on it.
http://uk.php.net/manual/en/language.types.string.php#language.types.string.
parsing

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP] Differences in arrays

2004-12-02 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 02 December 2004 10:26, Stuart Felenstein wrote:

> I have arrays set up in a user form.  One type is from
> a multi-select list.

[]

> I have 3 textfield elements all named school[]

[]

> 2- Why would the second array behave differently then the first ?

Because you're using different input types.

A multi-select list sends exactly one value (array element) for each value
selected, so you will always get exactly the same number of array elements
as there were items selected (including possibly none).

Each text element sends its value (hence an array element) unconditionally,
because each is treated separately  -- there's no grouping of like-named
boxes for textboxes like there is for radio buttons.  This means you'll
always see 3 school[] elements, even if some are empty.  Note that this
makes it possible for (say) boxes 1 and 2 to be empty, but box 3 contain a
value, or boxes 1 and 3 to contain values but box 3 be empty -- you may need
to adjust your code to allow for this!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] Too many DELETE statements

2004-12-02 Thread David Dickson
news.php.net wrote:
A member is not deleted from only one
table. Based on user id, he should be deleted from 5 tables and also his
photo, if any, should be unlink(ed).
$query = "delete from table1 where userid = " . $ID;
$result = mysql_query($query, $link);
$query = "delete from table2 where userid = " . $ID;
$result = mysql_query($query, $link);
...
But even with only 10 members, the page takes 30-60 seconds to come back to
me. What is the best way to accomplish this? And it is possibe to delete
1000 by 1000 or 100 by 100?
This could be fixed by changing your database schema. You should have 
your main table, lets call it members, where userid is the primary key. 
All your other tables that use userid should reference members.userid as 
a foreign key with ON DELETE CASCADE set. This will make sure that any 
time a userid is deleted from members, the delete will cascade to all 
other tables that contain userid. See your databases documentation 
CREATE TABLE and ALTER TABLE syntax.

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


Re: [PHP] Text Parser

2004-12-02 Thread M. Sokolewicz
Richard Davey wrote:
Hello Pablo,
Thursday, December 2, 2004, 3:12:09 PM, you wrote:
PDM> I´m receiving this: "house , ball , door , roof , floor"
PDM> And I want to obtain this: "'house','ball','door','roof','floor'"
PDM> Maybe, I should use implode or explode, but I just can´t figure out how..
PDM> Help?
$parts = explode(',', $original);
$parts = array_map('trim', $parts);
$new = "'".implode("','", $parts)."'";
You could explode it, loop it, etc etc - but if the data always
follows that format and is trust-worthy, the following is probably
quicker:
$old_data = "house,ball,door,roof,floor";
$data = "'" . str_replace("," , "','" , $old_data) . "'";
At least, I can't see why this won't work :)
If your data has all those extra spaces in, then just amend the
str_replace accordingly.
Best regards,
Richard Davey
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Text Parser

2004-12-02 Thread Gryffyn, Trevor




That should do it.  The only weird bit is adding the single quotes to the 
beginning and end of the final string.


You could also do a str_replace()




And of course you can do regex stuff, but I'm not good at that so I'll leave an 
example to someone else if they care to give one.


Just remember, explode() creates an array out of items based on a set of 
characters you tell it are the divider.  If you had a tab delimited text file, 
you'd want to break on "\t" (for tab).

Implode() does the opposite.  It takes an array and joins the items using the 
string you give it.   This is good for things like what you're doing above, but 
in this case a simple str_replace() works just as good too.


-TG


> -Original Message-
> From: Pablo D Marotta [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 02, 2004 10:12 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Text Parser
> 
> 
> Hi there..
> A newbie issue:
> I´m receiving this: "house , ball , door , roof , floor"
> And I want to obtain this: "'house','ball','door','roof','floor'"
> 
> Maybe, I should use implode or explode, but I just can´t 
> figure out how..
> Help?
> 
> 
> 
> American Express made the following
>  annotations on 12/02/04 08:13:28
> --
> 
> **
> 
> 
>  "This message and any attachments are solely for the 
> intended recipient and may contain confidential or privileged 
> information. If you are not the intended recipient, any 
> disclosure, copying, use, or distribution of the information 
> included in this message and any attachments is prohibited.  
> If you have received this communication in error, please 
> notify us by reply e-mail and immediately and permanently 
> delete this message and any attachments.  Thank you."
> 
> **
> 
> 
> ==
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



Re: [PHP] Text Parser

2004-12-02 Thread ankur_os

Suppose this is your first string $value
house , ball , door , roof , floor

$saparate = explode(",",$value);
$list = implode("','", $arr1);
$final =  ('$arr2');
echo $final;

Thnx...


Quoting Pablo D Marotta <[EMAIL PROTECTED]>:

> Hi there..
> A newbie issue:
> I´m receiving this: "house , ball , door , roof , floor"
> And I want to obtain this: "'house','ball','door','roof','floor'"
> 
> Maybe, I should use implode or explode, but I just can´t figure out how..
> Help?
> 
> 
> 
> American Express made the following
>  annotations on 12/02/04 08:13:28
> --
> **
> 
>  "This message and any attachments are solely for the intended recipient
> and may contain confidential or privileged information. If you are not the
> intended recipient, any disclosure, copying, use, or distribution of the
> information included in this message and any attachments is prohibited.  If
> you have received this communication in error, please notify us by reply
> e-mail and immediately and permanently delete this message and any
> attachments.  Thank you."
> 
> **
> 
> ==
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



RE: [PHP] Re: Browsing while downloading?

2004-12-02 Thread Gryffyn, Trevor
Yeah, this isn't a PHP specific problem, BUT, in the off chance that PHP
could solve the problem (using a different method of sending to the
browser, etc) then it becomes PHP relevant... So everyone give the guy a
break on the relevance issue.   If there were two ways of doing
something and you only know one, wouldn't you want to ask if there was a
second, better way, that didn't cause the problem you were having?


Anyway..  Yeah, this might not be avoidable, although when you click on
a link to download a file you can usually still continue browsing, so
I'm guessing that there IS another way to do this.

Couple of thoughts:

1. Have you tried smaller files just as a test (something that takes
like 30 to 60 seconds to download maybe) just to see if you still have
the problem?

2. Is it feasible to create the file and provide a "click here to
download" or "right-click and select SAVE AS.. to download"?  This might
force the browser to handle it more like a standard download and not
handle it as if it were loading a web page.

3. Speaking of loading as a web page, are you getting a download
progress bar or does the browser just keep spinning with it's normal
"I'm loading a web page" progress bar?   If that was happening, it could
be an issue of setting a good MIME type (what was it, like
"octet/stream" or something that's a generic "this is a binary file"
mime type?).   If your browser thinks its downloading HTML, that could
lock it up.

4. Lastly... I've noticed when my browser is locked up for whatever
reason, that you can usually open another instance of the browser.
Going to your desktop and double-clicking on the Internet Explorer icon
again, etc.  This second copy of IE seems to operate in a different
memory space... As a different program.  So if you crash or lock up the
other instance, as long as you're not grinding your CPU or maxing out
your memory, the second instance of IE or whatever should still work ok.
I've had IE crash, with a "End Program" type propt and have other
instances of IE be fine. But all the IE windows opened from the
original window get nuked by the "End Program" function.


Hope this helps at least a little.   I'm guessing there's a way to make
it download without freezing your IE and I'm guessing it may have
something to do with your headers and/or MIME type.   If that doesn't
work, I'd investigate creating the file and letting the user click a
link to download it, forcing the browser to handle it how it sees fit.

Good luck!

-TG

> -Original Message-
> From: adrian zaharia [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 01, 2004 6:42 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: Browsing while downloading?
> 
> 
> Hi,
> 
> Thanks for reply, yet:
> 
> 1. i know has nothing to do with php but since now i am doing 
> it in php i
> thought would be a good solution to post here
> 
> 2. bad browser? hmm... i tried: IE, Mozilla&Firefox (Win+Linux),
> Opera(Win+Linux), Konqueror maybe there is still one 
> better out there
> :P
> 
> Thanks,
> 
> Adrian

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



RE: [PHP] Free for commercial use?

2004-12-02 Thread Gryffyn, Trevor
Taken from http://www.php.net/license/:

Note: the following questions and answers only apply to version 2.01 and
2.02 of the PHP license. Ignore for version 3.0. 

Q. What does the PHP license mean then, in simple words? 

A. (Note: This answer should in no way be taken to replace the PHP
license, it is intended to give you a general impression of what the
license means.) Essentially, the PHP license gives you the right to use,
distribute and modify PHP as much as you want, for both commercial and
non-commercial use. You just have to make it clear to the user that what
you have distributed contains PHP. 

Q. The Zend license says I may not charge money for stuff I sell along
with Zend. Does that mean I cannot sell PHP scripts or web sites that I
build? 

A. No. Not at all. This clause only concerns software built around the
Zend scripting engine library, not scripts that PHP executes, using that
library. You are free to distribute PHP source code you write freely or
commercially, without any concern about the PHP or Zend licenses. You
may also package PHP as a whole with your commercial applications as
much as you want. You just can't build commercial applications that use
the Zend scripting engine library directly. 



The last two sentences should cover what you're looking for.  Err..
Except that it only applies to PHP license 2.01 and 2.02, not the newest
3.0.  Maybe I didn't find the answer you were looking for. Sorry.


For full details, see the full license text at
http://www.php.net/license/3_0.txt


> -Original Message-
> From: Brian Dunning [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 02, 2004 10:30 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Free for commercial use?
> 
> 
> I thought I wouldn't have any trouble finding this. I'm trying to 
> provide documentation that PHP is free for commercial use, 
> and I can't 
> find anything on php.net. Can anyone help me?
> 
> - Brian
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



[PHP] Free for commercial use?

2004-12-02 Thread Brian Dunning
I thought I wouldn't have any trouble finding this. I'm trying to 
provide documentation that PHP is free for commercial use, and I can't 
find anything on php.net. Can anyone help me?

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


Re: [PHP] Text Parser

2004-12-02 Thread Richard Davey
Hello Pablo,

Thursday, December 2, 2004, 3:12:09 PM, you wrote:

PDM> I´m receiving this: "house , ball , door , roof , floor"
PDM> And I want to obtain this: "'house','ball','door','roof','floor'"

PDM> Maybe, I should use implode or explode, but I just can´t figure out how..
PDM> Help?

You could explode it, loop it, etc etc - but if the data always
follows that format and is trust-worthy, the following is probably
quicker:

$old_data = "house,ball,door,roof,floor";
$data = "'" . str_replace("," , "','" , $old_data) . "'";

At least, I can't see why this won't work :)

If your data has all those extra spaces in, then just amend the
str_replace accordingly.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I am not young enough to know everything." - Oscar Wilde

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



RE: [PHP] Referencing Multi Dimensional Arrays

2004-12-02 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 01 December 2004 17:31, Robinson, Matthew wrote:

> I have a search function:
> 
> $search_result = multi_array_search($net_array,"needle");
> 
> now search_result equals an array of keys to locate the
> needle, this is
> variable in count.
> 
> Sometimes the array of keys is 3 entries other times 5, I
> want a way of
> taking those entries and being able to do something like:
> 
> $net_array[multi-dimensional-key] = value;
> 
> where sometimes it might be in longhand:
> 
> $net_array["net1"]["net2"]["address1"]
> 
> or other times:
> 
> $net_array["net1"]["address1"]
> 
> but you don't know how deep you're going until the search returns you
> the keys. 

Coming to this a bit late, but one possibility might be:

   $result = &$net_array;
   foreach ($search_result as $index):
  $result = &$result[$index];
   endforeach;
   // $result is now a reference to the array element.

Alternatively, wouldn't it be possible for the search function to return
that reference itself?  Or do you particularly want to know what the
sequence of accessor keys is?

Usual caveats apply: this is all off the top of my head, and completely
untested!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP] Free for commercial use?

2004-12-02 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 02 December 2004 15:30, Brian Dunning wrote:

> I thought I wouldn't have any trouble finding this. I'm trying to
> provide documentation that PHP is free for commercial use,
> and I can't
> find anything on php.net. Can anyone help me?

http://www.php.net/license/3_0.txt is about it.  It states the conditions
for use of PHP, and money isn't one of them.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



[PHP] Cleaner way to do this?

2004-12-02 Thread Robert Sossomon
foreach ( $_POST as $key => $value )
{
 while ($key != "submit")
 {
  \$$key = $value;
  $addtocart .= ",'\$$key'";
 }
}
The problem is that it seems to be hanging at the while loop.  Is there a 
cleaner way to write the foreach loop so that it will dump out the "submit" key? 
 I've been trying different combinations, and am sure it is something simple I 
have boffed.

Thanks,
Robert
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Parse error: parse error, expecting `']'' in

2004-12-02 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 02 December 2004 16:49, Matthew Sims wrote:

> > > So when using arrays with string keys within strings you need to
> > > concatenate it. 
> > > 
> > > $var = "I live in the city of ". $_POST['cityname'];
> > 
> > No, you do not *need* to -- it is one option, certainly, but there
> > is no necessity about it. 
> > 
> > Within double-quoted strings, it is perfectly acceptable to use
> > unquoted array keys: 
> > 
> > $var = "I live in the city of $_POST[cityname]";
> 
> True and that is perfectly fine though PHP will check to see
> if cityname
> is a defined word first.

No it will not -- not in a double-quoted string (if by "defined word" you
mean constant).

Outside of a double-quoted string, yes it will.

> 
> As the manuel shows:
> 
> // Works but note that this works differently outside string-quotes
> echo "A banana is $fruits[banana].";

Yes -- *works*, as in always works, because no constant lookup is done when
interpolating within a double-quoted string.

> Consistency can go a long way. :)

Oh, I agree with you there, which is why I personally always use the
"...{$arr['index']} ..." syntax.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP] Referencing Multi Dimensional Arrays

2004-12-02 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 02 December 2004 15:17, Robinson, Matthew wrote:

>  Thanks for the help Mike, If I've got a reference to an
> entry and say,
> wanted to insert another entry, can I use array_push() with the
> reference? 

Please keep discussions on list so that anyone reading this thread can
follow it to its resolution -- plus which, someone else might still chip in
with better ideas than me!

The reference can be used interchangeably with the thing it's a reference to
-- so if it's a reference to an individual element, no you can't use it with
array_push() any more than you could, say,
$arr['index']['array']['element']; but if the reference is to the parent
array, then you could, just as you could with $arr['index']['array'] (if
that all makes sense!).

It might help you to read the manual section on references at
http://www.php.net/manual/en/language.references.php.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] Too many DELETE statements

2004-12-02 Thread Richard Lynch
news.php.net wrote:
> I have 160,000+ members in my site. 40,000 of them have not logged in
> since
> 2003 and they should be deleted. A member is not deleted from only one
> table. Based on user id, he should be deleted from 5 tables and also his
> photo, if any, should be unlink(ed).
>
> I tried to do that 10 by 10 using:

Ah.  Don't do that.

Do this:

$query = "delete from table1 where userid in (select userid from
login_table where last_login <= '2003-12-31')";

ANY time you are using PHP to loop through record after record after
record in the database, and then you are sending a new query for every
record you find, you DOING IT WRONG. :-)

SQL is *VERY* good at describing exactly which records should have
something done to them, and doing it, or finding them, or whatever.

PHP is not so fast at that.

Oh.  If your version of MySQL doesn't do sub-selects, you'll want to do:

$query = "select userid from login_table where last_login <= '2003-12-31'";
$goners = mysql_query($query, $link) or trigger_error(@mysql_error($link)
. " $query", E_USER_ERROR);
$ids = array();
while (list($userid) = @mysql_fetch_row($goners)){
  $ids[] = $userid;
}
$ids_sql = implode(", ", $ids);

$query = "delete from table1 where userid in ($ids_sql)";
mysql_query($query, $link) or trigger_error(@mysql_error($link) . "
$query", E_USER_ERROR);

You can repeat that for each table.

If it turns out that having 40K IDs in the array/string is too much, just
add a LIMIT clause to the first query:

$query = "select userid from login_table where last_login <= '2003-12-31'
limit 100";

You'll have to reload the page 40 times.  Or, better yet, once you're
comfy with the page working for 100 peeps, just wrap a for($i = 0; $i <
40; $i++) around the whole script.

Needless to say, if you *DO* use the sub-select, you'll have to delete the
records from the table that keeps track of last_login *LAST* :-)

You may also want to archive the 40,000 users somewhere, just in case...

Or even put them into a "user_dormant" table or something, so you can pull
them back from the grave quickly if they want to re-activate their
account.

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

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



RE: [PHP] Days remaining? (years, months, days, hours, minutes, seconds..etc)

2004-12-02 Thread Gryffyn, Trevor
I don't know of a built-in function, but you're welcome to use my
daydiff script below.  It actually gives you year, month, day, hour,
minute, second.. Not just days.  But modify it as you desire.

-TG

31536000,"Months"=>2592000,"Days"=>86400,"Hours"=>3600,"M
inutes"=>60);

# How many seconds between two dates/times
$daydiff = mktime($ehour,$eminute,$esecond,$emonth,$eday,$eyear) -
mktime($shour,$sminute,$ssecond,$smonth,$sday,$syear);

if ($daydiff < 0) { $daydiff *= -1; $negative = TRUE; }

# Just to make sure I didn't use $remainder somewhere else in my script
and forgot
if (isset($remainder)) unset($remainder);

# Cycle through timeframes checking to see if number is large enough to
be a full year/month/day/etc
# If so, find out how many and store remainder for further processing
# If not, set to zero and continue processing
foreach ($secondsequiv as $timeframe=>$seconds) {
  if (isset($remainder)) { $checkvalue = $remainder; } else {
$checkvalue = $daydiff; }
  if ($checkvalue >= $seconds) {
$daydiffarr[$timeframe] = floor($checkvalue/$seconds);
$remainder = $daydiff % $seconds;
  } else {
$daydiffarr[$timeframe] = 0;
  }
}

# If $reminder is never used, then we're dealing with less than a
minute's worth of time diff
if (isset($remainder)) {
  $daydiffarr["Seconds"] = $remainder;
} else {
  $daydiffarr["Seconds"] = $daydiff;
}

# Display results
if ($negative) echo "NEGATIVE!!\n";
foreach ($daydiffarr as $timeframe=>$count) {
  echo "$timeframe = $count\n";
}
?>

> -Original Message-
> From: Peter Lauri [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 02, 2004 11:38 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Days remaining?
> 
> 
> Best groupmember,
> 
> I have the date 2004-12-24 in a string, and 2004-11-05 in a 
> other. Is there
> any date function that can assist in calculating the number 
> of days left
> until 2004-12-24 when it is 2004-11-05. (the dates are just testdates)
> 
> --
> - Best Of Times
> /Peter Lauri
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



Re: [PHP] Differences in arrays

2004-12-02 Thread Richard Lynch
> 1-I guess I need a way to make sure in the foreach
> that when the first empty element is reached the loop
> dies.

Just to be sure you understand:

You should really not die when you hit a blank.

You should just SKIP it and process the rest.

A user *might* choose to fill in the first and third text box INPUTs, and
#2 would be blank.  But they'd (rightly) expect you to process #3.

> 2- Why would the second array behave differently then
> the first ?

It's not you.

It's the way HTTP protocol was set up, not really planning for complicated
forms with arrays and such-like.

PHP using arrays (and other languages doing what they do) are mostly
work-arounds of the short-comings of the HTTP protocol.

It would be nice if the HTTP protocol had planned this out a bit better,
and INPUT, SELECT MUTIPLE, CHECKBOX, and RADIO all behaved in a more
rational/similar manner.

OTOH, if you make them too much the same, you'd probably end up having to
do more work for the simple forms.  So it goes.

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

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



Re: [PHP] Cleaner way to do this?

2004-12-02 Thread Richard Lynch
Robert Sossomon wrote:
> foreach ( $_POST as $key => $value )
> {
>   while ($key != "submit")
>   {
>\$$key = $value;
>$addtocart .= ",'\$$key'";
>   }
> }
>
> The problem is that it seems to be hanging at the while loop.  Is there a
> cleaner way to write the foreach loop so that it will dump out the
> "submit" key?
>   I've been trying different combinations, and am sure it is something
> simple I
> have boffed.

Think about what happens with the first key/value pair.

Let's assume it's $_POST['name'] = "Robert";

Here's what you have, with the simple substitution of 'name' for $key and
"Robert" for $value:

while ('name' != 'submit')
{
  $name = 'Robert';
  $addtocart .= ",'\$name'";
}

Now, inside the while loop, when do you expect $key to change from 'name'
to 'submit'?...

Never gonna happen.

You're not changing $key at all in that inside loop.

You've sent PHP into a tail-spin of an infinite loop where it does the
same thing over and over and over ...

$name = 'Robert';
$addtocart .= ",'\$name'";

Actually, it tacks on '$name' to the $addtocart a zillion times, so it's
not exactly the same thing over and over.

Eventually, because the $addtocart string is growing every time through
the loop, PHP will run over its time limit (30 seconds by default in
php.ini) or if you turned that off (Bad Idea) you'll eventually have
$addtocart filling up *ALL* of your RAM and *ALL* of your swap and run
completely out of memory.

It's also quite possible that when all this code is boiled down into
machine language that it's so short and simple that PHP doesn't even get
an interrupt to stop this runaway process, and the 30-second rule will
never kick in.  Course, you'll still run out of RAM eventually, though
that could take hours and you'll notice the performance drop and kill
PHP/httpd long before that happens.  Hell, you'd reboot the machine if
nothing else.

So, what you REALLY want is probably more like:

if ($key != 'submit')

You only want to test each $key *ONE* time to be sure it's not the
'submit' button.

Another option might be to put this *before* the foreach loop:
unset($_POST['submit']);

That just plain gets rid of 'submit' before you start your loop.

It's kinda icky to alter what came in through $_POST directly, though, so
even better might be to do:
$inputs = $_POST;
unset($inputs['submit']);
foreach($inputs as $key => $value)

Also, *before* you do any of this stuff, you *REALLY* should have a
prepared list of what keys you expect to get in $_POST.

If you're going to walk through *all* of $_POST, blindly, and turn every
key/value pair into a variable in your script, you might as well just turn
register_globals back "On" because you've completely defeated that
security measure of turning it "Off" in the first place!  Your security
measure of having register_globals "Off" is pointless if you're going to
circumvent that. :-)

Look at the example code of why register_globals was turned off in the
first place.  If somebody sends POST data to your server with the same
hack in it, and you blindly walk all of $_POST turning every key/value
pair into a variable, you've got the exact same problem.

There's also no real need to write a loop of your own to do this:

http://php.net/extract

pretty much was designed to do exactly what you are doing.  :-)

If you find yourself doing something you think everybody has done a
million times, check to see if there is a function for doing that :)

So, the final code you *SHOULD* use looks a lot more like this:

//Define valid input 'key's from the FORM:
$acceptable_keys = array('name', 'phone', 'email', 'submit');

//Get all the inputs (possibly bogus hacked ones) from POST data:
$inputs = $_POST;

//Find anything in the inputs that *IS* bogus:
$bogus_keys = array_diff(array_keys($inputs), array_keys($acceptable_keys));

if (count($bogus_keys)){
  //RED ALERT!
  //Somebody is trying to hack your site through your FORM
  //*DO* something here.
  //Record their IP.
  //Log the bogus inputs and their values, maybe
  //But logging them could *also* be a security hole.  H...
  //Have a human review those logs routinely.

  //Do whatever you need to do to close off your HTML tags and print
  //a nasty anti-hacker error message.
  exit;
}

//Now that you know all the stuff in $inputs is kosher:
//Get rid of 'submit', I guess, if you want...
unset($inputs['submit']);
//Set all the keys to their value:
extract($inputs);


PS
I don't think this line is strictly kosher:
\$$key = $value;
At least, I've never seen it done that way, and it wasn't in the manual as
kosher last time I checked.  That's been awhile, though.
Not that it matters, since 'extract' is a better answer anyway :-)

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

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



Re: [PHP] picture upload

2004-12-02 Thread Richard Lynch
William Stokes wrote:
> Hello,
> I'm building a web site for a sports team. I wan't them to be able to
> update
> their own site so I need to build a file upload system for their pictures.
> Pictures also need to resized to fit their spot in the web page. Any ideas
> or quidelines how to do this. I've never done this kind of stuff before.
> Thanks IA

For the file upload part, the PHP Manual has a section (before all the
functions) about how to do that.  Read it.  Try it.  Post if you get
stuck. :-)  Don't forget the ENCTYPE part!!!

For scaling the image, there are several options.

One is to force the user to only submit images that fit within a certain
size/parameters.  This is probably good to avoid people uploading HUGE
image files.

You also should add some code in your file upload to be *SURE* it *is* a
valid image, so your server does not become a clearing-house for the
latest cracked version of Doom or whatever is popular this week.  This
function will be especially useful:
http://php.net/getimagesize

Once you have the file uploaded, you could scale it right away, once, and
save the scaled version for use from then on.

Or, you could scale the image each time, on the fly.

The first option is more efficient.  The second is more flexible if you
want to change the image size later, or if you want to have thumbnails in
one page, and full-size in another.  (You can write one script to handle
both)

Your two main choices for scaling an image are:
GD, which has to be installed with PHP (use http://php.net/phpinfo to check)
ImageMagick (aka 'convert') which is a shell command you can install and
use http://php.net/exec to execute.

There are examples of using GD to scale images, and of using ImageMagick
(aka convert) to scale images with exec all over the 'net, so I won't try
and repeat them here.

Oh yeah:  Sooner or later, somebody will upload an image that's too SMALL.
 Don't try to scale it "up" -- That will be butt ugly.  Just display it
centered in the spot where the image belongs.  Test this with a tiny image
for yourself.

Security Note:  The directory where your uploaded images are stored should
*NOT* be in your htdocs web tree.  You can use PHP to make sure the image
is kosher and *move* it after you check to the web tree.  Or you can use
PHP to check/read/display the image, so it's never in your web-tree.

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

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



RE: [PHP] Page that checks if a user exists on a remote system

2004-12-02 Thread Richard Lynch
Gryffyn, Trevor wrote:
> If it's a un*x system and you have permissions to connect to the SMTP
> server, you could use the VRFY command to check to see if their email
> address exists or not maybe:
>
> Example of Verifying a User Name
>
>  Either
>
> S: VRFY Smith
> R: 250 Fred Smith <[EMAIL PROTECTED]>
>
>  Or
>
> S: VRFY Smith
> R: 251 User not local; will forward to <[EMAIL PROTECTED]>
>
>  Or
>
> S: VRFY Jones
> R: 550 String does not match anything.
>
>  Or
>
> S: VRFY Jones
> R: 551 User not local; please try <[EMAIL PROTECTED]>
>
>  Or
>
> S: VRFY Gourzenkyinplatz
> R: 553 User ambiguous.
>
> (examples taken from: http://www.ietf.org/rfc/rfc0821.txt   Page 8)

I believe that, for performance and security reasons, many/most SMTP
servers these days will out and out *LIE* to you about this...

The real answer is:  There is *NO* *WAY* to do this on a general basis,
unless you control the remote machine, or know enough about its setup, to
be certain that it will respond correctly.

>> ServerA and ServerB

Ah.  The original poster probably has control of ServerB.

Life is now simplified immensely.

>> This, of course, is because the script is being run as "www"
>> who has no
>> place to put ssl keys.
>>
>> Could this be solved by having "www" "su" to a user who has
>> remote access
>> privileges?  Something like this:
>>
>> $idResults = `su admin | ssh [EMAIL PROTECTED] id bigbob 2>&1`;

su simply won't let you do that.  su requires a TTY to avoid you doing
something so incredibly dangerous as this.

So, no, that won't work.  And you shouldn't be trying to do that anyway.

>> Anyone else doing or done something like this?

Sure.

I've never done it, but many many many have.

One fairly simple thing is to create the 'www' user on ServerA so that
they *do* have a home directory where they can store SSH keys.  You may
need to su to 'www' once, and do some ssh work -- ssh-key-gen or whatever
it is.

That, however, increases your risk in the event that the www user is
compromised on ServerA.

Probably the best answer is to attack this from the side of ServerB.

You want ServerB to:
  Only allow ServerA to even ask.
  Tell ServerA if user "X" is a valid username.

>From the point of ServerB, making sure that ServerA is the one asking is
fairly simple.  You could check the IP (which can be spoofed, but that's
fairly difficult) or provide some other means of authentication (SSH/SSL)
that ensures that ServerA is really ServerA.

Then, ServerB can just check /etc/passwd usernames.  Or be even simpler to
use a shell command like 'user' (?) or 'groups' to verify that a user is
valid.

In other words, instead of writing some hacky code on ServerA to try to
poke at ServerB to get the answer you want, write some nice clean code on
ServerB to provide the answer, WHEN APPROPRIATE.

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

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



Re: [PHP] Re: How to tell if the filepath exist or not before attempting to create a directory??

2004-12-02 Thread Richard Lynch
Marek Kilimajer wrote:
> Richard Lynch wrote:
>> Scott Fletcher wrote:
>>
>>>Never mind that..  I found a different way to use it.  It would be so
>>> cool
>>>if there is such a feature as directory_exists() to check for partical
>>>filepath...
>>
>>
>> http://php.net/file_exists
>>
>> You'll need to use @ in front, because it generates an error message
>> when
>> it doesn't find the file you're not sure exists. :-(
>
> What version? On 5.0.2 file_exists('nonexistingfile'); does not generate
> any error message.

Ya got me.

In 4.3.9 it doesn't do that any more either.

I'm getting old.

It would be nice to document when it changed if anybody *does* know.

-- 
Like Music?

http://l-i-e.com/artists.htm

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



Re: [PHP] Too many DELETE statements

2004-12-02 Thread Richard Lynch
David Dickson wrote:
> news.php.net wrote:
>> A member is not deleted from only one
>> table. Based on user id, he should be deleted from 5 tables and also his
>> photo, if any, should be unlink(ed).
>>
>> $query = "delete from table1 where userid = " . $ID;
>> $result = mysql_query($query, $link);
>>
>> $query = "delete from table2 where userid = " . $ID;
>> $result = mysql_query($query, $link);
>>
>> ...
>>
>> But even with only 10 members, the page takes 30-60 seconds to come back
>> to
>> me. What is the best way to accomplish this? And it is possibe to delete
>> 1000 by 1000 or 100 by 100?

First, you're sending a total of:
10 users X 5 tables == 50 queries
to the database.

That's a bit much, really.

Plus you are unlink-ing 10 files.  That's probably the real problem.

You'd have to write some timing code to be sure, though, as a slow
database server and a very fast hard drive could be involved.

Here are some things you could do to speed it up, assuming you don't want
the ON DELETE CASCADE option, or if your database doesn't provide that
option.

1. Send only one query for each table:
You should be able to collect all the $ID values in one list like this:

$ids_sql = "2, 4, 5, 42, 17, 68, 1, 9, 10";
$query = "select from table1 where userid in ($ids_sql)";

Of course, you'll need to write that to handle your incoming FORM data
rather than hard-coding the IDs.

The other thing is unlink-ing the image.  That is probably the bigger
time-sink than just a few (dozen) queries.

One way to beat this is to *NOT* unlink the file in your script.

And the ON DELETE CASCADE won't fix this at all.

Instead, write a cron job to walk through the images and throw away
anything not being used.  This will be "slower" and "less efficient" than
doing it in the script, but it can be a background process, not making the
user wait for what is essentially a house-cleaning project.

Actually, you could have a table of "deleted_users" and *INSERT* any ID
after you delete it from the other 5 tables.  Then your cron job would
just delete the images corresponding to the users in that "deleted_users"
table, and, of course, delete their ID from that table.

The point here is to separate out work that *MUST* be done immediately for
the user to have a good experience, and the house-cleaning chores you need
to do that won't affect the user experience at all.  An unused image file
cluttering up the hard drive for a few hours won't (in almost all cases)
have any real effect on the user.  Unlink the file "later" in a cron job,
and get the user's perceived time for the "delete" down to a nice
experience.

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

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



Re: [PHP] Free for commercial use?

2004-12-02 Thread Robby Russell
On Thu, 2004-12-02 at 07:29 -0800, Brian Dunning wrote:
> I thought I wouldn't have any trouble finding this. I'm trying to 
> provide documentation that PHP is free for commercial use, and I can't 
> find anything on php.net. Can anyone help me?
> 
> - Brian
> 

http://www.php.net/license/

http://www.php.net/license/3_0.txt


-- 
/***
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | [EMAIL PROTECTED]
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
*--- Now supporting PHP5 ---
/


signature.asc
Description: This is a digitally signed message part


Re: [PHP] picture upload

2004-12-02 Thread Raditha Dissanayake
William Stokes wrote:
Hello,
I'm building a web site for a sports team. I wan't them to be able to update
their own site so I need to build a file upload system for their pictures.
Pictures also need to resized to fit their spot in the web page. Any ideas
or quidelines how to do this. I've never done this kind of stuff before.
Thanks IA
 

William how to handle file uploads with PHP is described very well in 
the manual. Once you get past that stage just search google for php 
image upload.


--
Raditha Dissanayake.
--
http://www.radinks.com/print/card-designer/ | Card Designer Applet
http://www.radinks.com/upload/  | Drag and Drop Upload 

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


Re: [PHP] Page that checks if a user exists on a remote system

2004-12-02 Thread Jason Wong
On Thursday 02 December 2004 23:32, Gryffyn, Trevor wrote:
> If it's a un*x system and you have permissions to connect to the SMTP
> server, you could use the VRFY command to check to see if their email
> address exists or not maybe:

Just want to point out that this behaviour is dependent on the flavour of the 
SMTP server so YMMV.

-- 
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
--
/*
...and scantily clad females, of course.  Who cares if it's below zero
outside.
 -- Linus Torvalds
*/

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



RE: [PHP] Page that checks if a user exists on a remote system

2004-12-02 Thread Jonathan Duncan
Well, I can honestly say I had not thought of doing it that way.  I will 
keep that as an option.  Thanks.

Jonathan
On Thu, 2 Dec 2004, Gryffyn, Trevor wrote:
If it's a un*x system and you have permissions to connect to the SMTP
server, you could use the VRFY command to check to see if their email
address exists or not maybe:
   Example of Verifying a User Name
Either
   S: VRFY Smith
   R: 250 Fred Smith <[EMAIL PROTECTED]>
Or
   S: VRFY Smith
   R: 251 User not local; will forward to <[EMAIL PROTECTED]>
Or
   S: VRFY Jones
   R: 550 String does not match anything.
Or
   S: VRFY Jones
   R: 551 User not local; please try <[EMAIL PROTECTED]>
Or
   S: VRFY Gourzenkyinplatz
   R: 553 User ambiguous.
(examples taken from: http://www.ietf.org/rfc/rfc0821.txt   Page 8)
Just a thought.
-TG
-Original Message-
From: news.php.net [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 01, 2004 7:57 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Page that checks if a user exists on a remote system
I have two servers: ServerA and ServerB.  One server serves
web pages, the
other serves mail.  I am making a web page on ServerA that
will access
ServerB to find out if a users exists and if not then add
that user to
ServerB with information collected from the web page on ServerA.
I have this in a php file:
$idResults = `ssh [EMAIL PROTECTED] id bigbob 2>&1`;
echo "id: (".$idResults.")\r\n"."\r\n";
if (ereg("no such user", $idResults)) {
echo 'username is available!';
}
When I access the page I get:
Could not create directory '/nonexistent/.ssh'.
Host key verification failed.
This, of course, is because the script is being run as "www"
who has no
place to put ssl keys.
Could this be solved by having "www" "su" to a user who has
remote access
privileges?  Something like this:
$idResults = `su admin | ssh [EMAIL PROTECTED] id bigbob 2>&1`;
echo "id: (".$idResults.")\r\n"."\r\n";
if (ereg("no such user", $idResults)) {
echo 'username is available!';
// function addUserToServerB(vars);
}
Anyone else doing or done something like this?
Thanks,
--
Jonathan Duncan
http://www.nacnud.com

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


[PHP] Re: Browsing while downloading?

2004-12-02 Thread adrian zaharia
Found the problem...

Just FYI, maybe can help in future.

I am "under" a session and didn't forced a session_write_close() before i
outputted the stream. Acording to php docs, the session file stays locked
until the end of the script or a session_write_close() is issued. So, the
other scripts were in fact waiting for the session file to be unlocked.

Anmyway, ... interesting problem :)

Adrian Zaharia

M. Sokolewicz wrote:

> Adrian Zaharia wrote:
> 
>> Hello,
>> 
>> I have this problem and maybe smbdy can give me a hint.
>> 
>> I have a script which has to pack some server files into a tar created on
>> the fly and then output this archive to the browser via headers.
>> 
>> All is grea, the download works BUT, i am speaking of big archives, over
>> 50M and i noticed that while i am downloading i cannot browse anymore. I
>> tried the operation also via a opened window and it is the same. If i try
>> to click on the link or smth the browser does nothing. In the moment the
>> download finishes, the browser follows that clicked link and resumes it's
>> activity.
>> 
>> Any ideeas how can i keep browsing while dowloading?
>> 
>> Thanks
>> 
>> Adrian Zaharia
> get a different browser.
> This is a 100% browser issue where the browser allocated 100% available
> bandwidth for your download, and doesn't take in extra requests.
> 
> Notice, this has *nothing* whatsoever to do with php though :)

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



RE: [PHP] Page that checks if a user exists on a remote system

2004-12-02 Thread Gryffyn, Trevor
If it's a un*x system and you have permissions to connect to the SMTP
server, you could use the VRFY command to check to see if their email
address exists or not maybe:

Example of Verifying a User Name

 Either

S: VRFY Smith
R: 250 Fred Smith <[EMAIL PROTECTED]>

 Or

S: VRFY Smith
R: 251 User not local; will forward to <[EMAIL PROTECTED]>

 Or

S: VRFY Jones
R: 550 String does not match anything.

 Or

S: VRFY Jones
R: 551 User not local; please try <[EMAIL PROTECTED]>

 Or

S: VRFY Gourzenkyinplatz
R: 553 User ambiguous.

(examples taken from: http://www.ietf.org/rfc/rfc0821.txt   Page 8)

Just a thought.

-TG

> -Original Message-
> From: news.php.net [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 01, 2004 7:57 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Page that checks if a user exists on a remote system
> 
> 
> I have two servers: ServerA and ServerB.  One server serves 
> web pages, the 
> other serves mail.  I am making a web page on ServerA that 
> will access 
> ServerB to find out if a users exists and if not then add 
> that user to 
> ServerB with information collected from the web page on ServerA.
> 
> I have this in a php file:
> 
> $idResults = `ssh [EMAIL PROTECTED] id bigbob 2>&1`;
> echo "id: (".$idResults.")\r\n"."\r\n";
> if (ereg("no such user", $idResults)) {
> echo 'username is available!';
> }
> 
> When I access the page I get:
> 
> Could not create directory '/nonexistent/.ssh'.
> Host key verification failed.
> 
> This, of course, is because the script is being run as "www" 
> who has no 
> place to put ssl keys.
> 
> Could this be solved by having "www" "su" to a user who has 
> remote access 
> privileges?  Something like this:
> 
> $idResults = `su admin | ssh [EMAIL PROTECTED] id bigbob 2>&1`;
> echo "id: (".$idResults.")\r\n"."\r\n";
> if (ereg("no such user", $idResults)) {
> echo 'username is available!';
> // function addUserToServerB(vars);
> }
> 
> Anyone else doing or done something like this?
> 
> Thanks,
> --
> Jonathan Duncan
> http://www.nacnud.com 

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



RE: [PHP] Parse error: parse error, expecting `']'' in

2004-12-02 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 02 December 2004 13:22, Robert Sossomon wrote:

> But what I don't understand is why sometimes
> '$_POST[variable]' works and why
> sometimes it will only work when it is '$_POST['variable']' .
> 
> Even through my reading and examples I see it both ways, so anyone
> able to give me a direction to go with it?  I am thinking of just
> changing my coding to put it the second way, but...???

It's valid to put unquoted array subscripts inside a double-quoted string;
it's not valid anywhere else.  Look at the comment at the start of the
second example at
http://uk.php.net/manual/en/language.types.string.php#language.types.string.
parsing.simple for the official position on this.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] XML Downstream

2004-12-02 Thread Richard Lynch
Luc Pascal wrote:

> An large XML Downstream over asp should be saved into a xml-file. If I
> open the asp website directly (IE6.0). It shows after 15 min a big part
> of the xml-stream (like if I would open an xml-file with the browser)
> and a failure at the end. I don't know how to save it into Harddisk,
> before a failure-window popup, wich says "Not enough virtual memory,
> because stylesheet is activated". And I wouldn't know how to continue
> from the rest of the stream on. I thought there's an easy way to
> develope a documentpipe with php. Can you show me some example, how to
> get a datastreama into files?

In either ASP or PHP, you *should* be able to output:

header("Content-type: application/octet-stream");

And the browser *should* be able to download that into a file where you
choose to save it.

The error message you have provided would indicate to me that:

You are surfing to an XML file, and the browser is trying to display it.

Some kind of Style sheet is referenced before/in that XML file, and the
browser is using that Style sheet.  Or perhaps you've set up a default
Style sheet in your browser preferences???  Or, rather, your browser
implements the default settings of how to render a page with an internal
Style sheet.  At any rate, some kind of Style sheet is involved, but only
because you're trying to VIEW the file, instead of downloading it.  And,
the file being so large, you can't VIEW it in the browser, because it's
just too damn big.

Also note that there are more header()s you can send to ask the browser to
use a specific filename in the File Save As dialog.

And note that if you are just trying to download the file, and it's not
some file you are personally providing on your web-server, so you have no
control over how it gets served up, then the real problem is you don't
know how to use your browser :-)  Right-click (click-and-hold on a Mac) on
the link, and you will be given a popup menu which will include a choice
of "Save Link As..." :-)

Oh yeah. I've also had trouble when somebody sent me the URL to the
document via phone or dead-tree paper, and so there was no link to
right-click on, so...  The easiest thing to do there is to make your own
little text file with a link in it to the document, and then open that
file in your browser:
Open Notepad (or Write)
Type: 
So it should look like:

Then "Save As..."
Be sure to choose "Any file (*.*)" FIRST
Then name it something like:  "linkfile.htm"
Then open up "linkfile.htm" (from Explorer with double-click, or using
File->Open->Browse... in your browser.


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

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



[PHP] Days remaining?

2004-12-02 Thread Peter Lauri
Best groupmember,

I have the date 2004-12-24 in a string, and 2004-11-05 in a other. Is there
any date function that can assist in calculating the number of days left
until 2004-12-24 when it is 2004-11-05. (the dates are just testdates)

--
- Best Of Times
/Peter Lauri

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



[PHP] Days remaining?

2004-12-02 Thread Peter Lauri
Best groupmember,

I have the date 2004-12-24 in a string, and 2004-11-05 in a other. Is there
any date function that can assist in calculating the number of days left
until 2004-12-24 when it is 2004-11-05. (the dates are just testdates)

--
- Best Of Times
/Peter Lauri

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



RE: [PHP] Re: Browsing while downloading?

2004-12-02 Thread adrian zaharia
Hi,

Check the main thread, i have found the problem if you're interested...

Adrian Zaharia

Trevor Gryffyn wrote:

> Yeah, this isn't a PHP specific problem, BUT, in the off chance that PHP
> could solve the problem (using a different method of sending to the
> browser, etc) then it becomes PHP relevant... So everyone give the guy a
> break on the relevance issue.   If there were two ways of doing
> something and you only know one, wouldn't you want to ask if there was a
> second, better way, that didn't cause the problem you were having?
> 
> 
> Anyway..  Yeah, this might not be avoidable, although when you click on
> a link to download a file you can usually still continue browsing, so
> I'm guessing that there IS another way to do this.
> 
> Couple of thoughts:
> 
> 1. Have you tried smaller files just as a test (something that takes
> like 30 to 60 seconds to download maybe) just to see if you still have
> the problem?
> 
> 2. Is it feasible to create the file and provide a "click here to
> download" or "right-click and select SAVE AS.. to download"?  This might
> force the browser to handle it more like a standard download and not
> handle it as if it were loading a web page.
> 
> 3. Speaking of loading as a web page, are you getting a download
> progress bar or does the browser just keep spinning with it's normal
> "I'm loading a web page" progress bar?   If that was happening, it could
> be an issue of setting a good MIME type (what was it, like
> "octet/stream" or something that's a generic "this is a binary file"
> mime type?).   If your browser thinks its downloading HTML, that could
> lock it up.
> 
> 4. Lastly... I've noticed when my browser is locked up for whatever
> reason, that you can usually open another instance of the browser.
> Going to your desktop and double-clicking on the Internet Explorer icon
> again, etc.  This second copy of IE seems to operate in a different
> memory space... As a different program.  So if you crash or lock up the
> other instance, as long as you're not grinding your CPU or maxing out
> your memory, the second instance of IE or whatever should still work ok.
> I've had IE crash, with a "End Program" type propt and have other
> instances of IE be fine. But all the IE windows opened from the
> original window get nuked by the "End Program" function.
> 
> 
> Hope this helps at least a little.   I'm guessing there's a way to make
> it download without freezing your IE and I'm guessing it may have
> something to do with your headers and/or MIME type.   If that doesn't
> work, I'd investigate creating the file and letting the user click a
> link to download it, forcing the browser to handle it how it sees fit.
> 
> Good luck!
> 
> -TG
> 
>> -Original Message-
>> From: adrian zaharia [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, December 01, 2004 6:42 PM
>> To: [EMAIL PROTECTED]
>> Subject: [PHP] Re: Browsing while downloading?
>> 
>> 
>> Hi,
>> 
>> Thanks for reply, yet:
>> 
>> 1. i know has nothing to do with php but since now i am doing
>> it in php i
>> thought would be a good solution to post here
>> 
>> 2. bad browser? hmm... i tried: IE, Mozilla&Firefox (Win+Linux),
>> Opera(Win+Linux), Konqueror maybe there is still one
>> better out there
>> :P
>> 
>> Thanks,
>> 
>> Adrian

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



RE: [PHP] Page that checks if a user exists on a remote system

2004-12-02 Thread Gryffyn, Trevor
Yeah, this is definitely a "maybe" solution and depends on a few things
being right.  But if the alteratives are using "su ANYTHING" commands
and if just asking the SMTP server produces accurate results, then it
seemed like it was worth mentioning.

But the few people who have pointed out that this can possibly be
flawed, you are perfectly correct.

-TG



> -Original Message-
> From: Jason Wong [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 02, 2004 11:28 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Page that checks if a user exists on a 
> remote system
> 
> 
> On Thursday 02 December 2004 23:32, Gryffyn, Trevor wrote:
> > If it's a un*x system and you have permissions to connect 
> to the SMTP
> > server, you could use the VRFY command to check to see if 
> their email
> > address exists or not maybe:
> 
> Just want to point out that this behaviour is dependent on 
> the flavour of the 
> SMTP server so YMMV.
> 
> -- 
> 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
> --
> /*
> ...and scantily clad females, of course.  Who cares if it's below zero
> outside.
>  -- Linus Torvalds
> */

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



Re: [PHP] Cleaner way to do this?

2004-12-02 Thread Thomas Munz
> foreach ( $_POST as $key => $value )
> {
>   while ($key != "submit")
>   {
>\$$key = $value;
>$addtocart .= ",'\$$key'";
>   }
> }
>
> The problem is that it seems to be hanging at the while loop.  Is there a
> cleaner way to write the foreach loop so that it will dump out the "submit"
> key? I've been trying different combinations, and am sure it is something
> simple I have boffed.
>
> Thanks,
> Robert
>
> --
> Robert Sossomon, Business and Technology Application Technician
> 4-H Youth Development Department
> 200 Ricks Hall, Campus Box 7606
> N.C. State University
> Raleigh NC 27695-7606
> Phone: 919/515-8474
> Fax:   919/515-7812
> [EMAIL PROTECTED]

 foreach ( $_POST as $key => $value )
 {
   if($key != "submit")
   {
$addtocart .= ",$key";
   }
 }

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



Re: [PHP] print_r() and SimpleXML

2004-12-02 Thread Paul Reinheimer
Thanks a lot, I read the SimpleXML page a lot, but didn't drop into
the ->attributes page itself.


again, thanks
paul.


On Tue, 30 Nov 2004 23:34:14 -0800, Rick Fletcher <[EMAIL PROTECTED]> wrote:
> [snip]
> > when using print_r on a SimpleXML object that has
> > attributes, the attributes are not shown.
> >
> > I would propose that this is not the desired response. When using
> > print_r on an object, it should display all available information
> > (even, as the manual indicates, private and/or protected properties).
> [snip]
> > Now, if people agree with me, that this is infact not the desired
> > response. Is this a 'bug' with SimpleXML or print_r?
> 
> On the SimpleXML->attributes documentation page
> (http://www.php.net/manual/en/function.simplexml-element-attributes.php)
> you'll find this note:
> 
> "SimpleXML has made a rule of adding iterative properties to most
> methods. They cannot be viewed using var_dump() or anything else which
> can examine objects."
> 
> A pain? Maybe. A bug? No.
> 
> There are a couple of user functions in the SimpleXML documentation
> comments that will convert a SimpleXML object to an array.  You can then
> pass that array to print_r for debugging.
> 
> Find the code here: http://www.php.net/manual/en/ref.simplexml.php
> 
> Cheers,
>Rick
> 
> 


-- 
Paul Reinheimer
Zend Certified Engineer

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



RE: [PHP] Parse error: parse error, expecting `']'' in

2004-12-02 Thread Matthew Sims
>> So when using arrays with string keys within strings you need to
>> concatenate it.
>>
>> $var = "I live in the city of ". $_POST['cityname'];
>
> No, you do not *need* to -- it is one option, certainly, but there is no
> necessity about it.
>
> Within double-quoted strings, it is perfectly acceptable to use unquoted
> array keys:
>
> $var = "I live in the city of $_POST[cityname]";

True and that is perfectly fine though PHP will check to see if cityname
is a defined word first. And for all consistencies within your script it
can be helpful if you use $_POST[cityname] as a define worded array and
$_POST['cityname'] as a string keyed array and keep that seperated if ever
someone else were to look through your code.

As the manuel shows:

// Works but note that this works differently outside string-quotes
echo "A banana is $fruits[banana].";

// Works
echo "A banana is " . $fruits['banana'] . ".";

Consistency can go a long way. :)

You are right about the complex syntax.

-- 
--Matthew Sims
--

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



Re: [PHP] Too many DELETE statements

2004-12-02 Thread Lordo
Thanks alot. You really gave me some good ideas.

Lordo


"Richard Lynch" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> news.php.net wrote:
> > I have 160,000+ members in my site. 40,000 of them have not logged in
> > since
> > 2003 and they should be deleted. A member is not deleted from only one
> > table. Based on user id, he should be deleted from 5 tables and also his
> > photo, if any, should be unlink(ed).
> >
> > I tried to do that 10 by 10 using:
>
> Ah.  Don't do that.
>
> Do this:
>
> $query = "delete from table1 where userid in (select userid from
> login_table where last_login <= '2003-12-31')";
>
> ANY time you are using PHP to loop through record after record after
> record in the database, and then you are sending a new query for every
> record you find, you DOING IT WRONG. :-)
>
> SQL is *VERY* good at describing exactly which records should have
> something done to them, and doing it, or finding them, or whatever.
>
> PHP is not so fast at that.
>
> Oh.  If your version of MySQL doesn't do sub-selects, you'll want to
do:
>
> $query = "select userid from login_table where last_login <=
'2003-12-31'";
> $goners = mysql_query($query, $link) or trigger_error(@mysql_error($link)
> . " $query", E_USER_ERROR);
> $ids = array();
> while (list($userid) = @mysql_fetch_row($goners)){
>   $ids[] = $userid;
> }
> $ids_sql = implode(", ", $ids);
>
> $query = "delete from table1 where userid in ($ids_sql)";
> mysql_query($query, $link) or trigger_error(@mysql_error($link) . "
> $query", E_USER_ERROR);
>
> You can repeat that for each table.
>
> If it turns out that having 40K IDs in the array/string is too much, just
> add a LIMIT clause to the first query:
>
> $query = "select userid from login_table where last_login <= '2003-12-31'
> limit 100";
>
> You'll have to reload the page 40 times.  Or, better yet, once you're
> comfy with the page working for 100 peeps, just wrap a for($i = 0; $i <
> 40; $i++) around the whole script.
>
> Needless to say, if you *DO* use the sub-select, you'll have to delete the
> records from the table that keeps track of last_login *LAST* :-)
>
> You may also want to archive the 40,000 users somewhere, just in case...
>
> Or even put them into a "user_dormant" table or something, so you can pull
> them back from the grave quickly if they want to re-activate their
> account.
>
> -- 
> Like Music?
> http://l-i-e.com/artists.htm

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



Re: [PHP] Go Back Problem

2004-12-02 Thread Afan Pasalic
I solve that problem this way (please correct me if it's wrong)
#   form.php

if(isset($_POST['SubmitForm']))
{
   if(!isset($_POST['Name'] or !isset($_POST['Phone'] or 
!isset($_POST['Email'])
   {
   echo "One or more required fields are empty.";
   }
   else
   {
   header('location: results.php');
   exit;
   }
}
?>

Name: 
Phone: 
Email: 



This way you don't need to go back if somethign's wrong and you go on 
result page ONLY if everything's correct.

-afan



Thomas Goyne wrote:
On Thu, 2 Dec 2004 09:58:46 +0800, Cyrus 
<[EMAIL PROTECTED]>  wrote:

Dear All,
I have a problem of back to the previous page in php.
I need to create a form let people to fill in .It can let user to  
preview the form, if information is not correct , user can back to  
previous page and correct it,
I have used the javascript  :  OnClick='history.go(-1)'   and   
OnClick='history.back()'  in php , but it can not workspls help me.

Thanks and Regards,
Cyrus Chan

This is a browser issue.  For some reason, most browsers interpet 
'back'  as 'reload the previous page' rather than 'go back to where 
the user was',  which results in the information filled into forms 
being nuked.

One possible workaround for this is to skip the back stage, thereby  
removing the chance for the data to be lost.  On the preview page, 
just  include the form, so that they can just make the changes there.


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


Re: [PHP] Too many DELETE statements

2004-12-02 Thread David Dickson
Richard Lynch wrote:
Plus you are unlink-ing 10 files.  That's probably the real problem.
You'd have to write some timing code to be sure, though, as a slow
database server and a very fast hard drive could be involved.
Here are some things you could do to speed it up, assuming you don't want
the ON DELETE CASCADE option, or if your database doesn't provide that
option.
You should do this (even if you don't want to) because it is good 
design. If when a member is deleted you want all associated tables to 
also delete this member information then you should set up your foreign 
keys properly.

1. Send only one query for each table:
You should be able to collect all the $ID values in one list like this:
$ids_sql = "2, 4, 5, 42, 17, 68, 1, 9, 10";
$query = "select from table1 where userid in ($ids_sql)";
Of course, you'll need to write that to handle your incoming FORM data
rather than hard-coding the IDs.
The other thing is unlink-ing the image.  That is probably the bigger
time-sink than just a few (dozen) queries.
One way to beat this is to *NOT* unlink the file in your script.
And the ON DELETE CASCADE won't fix this at all.
Instead, write a cron job to walk through the images and throw away
anything not being used.  This will be "slower" and "less efficient" than
doing it in the script, but it can be a background process, not making the
user wait for what is essentially a house-cleaning project.
Something else you could do is to build one big rm statement and run it 
in the background. This would save you building a cron job which 
sometimes isn't possible depending on the hosting arrangement.


$Remove = "rm $ImageLocation1; rm $ImagLocation2; rm $ImageLocation3";
exec("nohop $Remove > /dev/null 2>&1 &");
?>
Where the $ImageLocationx is the full path to the image you want to 
delete. The & at the end of the exec tells the command to run in the 
background, which means your script won't wait for the command to finish 
before continuing. The output redirection ( > /dev/null 2>&1) is also 
necessary to allow the script to continue. See the PHP documentation on 
exec for more details.

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


[PHP] Re: Custom Open Tags

2004-12-02 Thread Sven Schwyn
Hi all
Thanks for your hints. I need this feature for an easy to use 
minimalistic CMS solution, so tweaking the PHP source is not that much 
of an option. But evals do the trick of course. I ruled that out at 
first because I thought it'll cause a lot of clumsy code. Yet there's 
quite an elegant way to do it, I mail it for future reference:

/**
 * Includes a file executing  tags as if they were  tags.
 *
 * @param string $file file to include
 * @param bool $php whether to execute  tags as well
 */
function xinclude($file, $php=TRUE) {
$content = file_get_contents($file);
if (!$php) { $content = preg_replace('/<\?php.*?\?>/', '', 
$content); }
$content = str_replace("<\x3Fmc", "<\x3Fphp", $content);
$content = "print '".str_replace(array("<\x3Fphp", "\x3F>"), 
array("'; ", "; print '"), $content)."';";
eval($content);
}

The only downside: No single quote (') is possible outside  
tags in the file included. This can of course be fixed, but only with a 
ridiculous amount of code. If only there was a way to do heredoc 
strings that DON'T parse variables (like in Perl).

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


Re: [PHP] Cleaner way to do this?

2004-12-02 Thread Marek Kilimajer
Robert Sossomon wrote:
foreach ( $_POST as $key => $value )
{
 while ($key != "submit")
 {
  \$$key = $value;
  $addtocart .= ",'\$$key'";
 }
}
The problem is that it seems to be hanging at the while loop.  Is there 
a cleaner way to write the foreach loop so that it will dump out the 
"submit" key?  I've been trying different combinations, and am sure it 
is something simple I have boffed.
I guess you want:
if ($key != "submit")
And you don't need to give names to submit buttons. Then it will not be 
posted and the condition is not necessary.

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


Re: [PHP] Too many DELETE statements

2004-12-02 Thread Lordo
Thanks. I will check the foreign key with cascading issue. But I have a
question: Will it have any bad effects on behavior? I have tables with
160,000, 400,000, etc. records.

Lordo

"David Dickson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> news.php.net wrote:
> > A member is not deleted from only one
> > table. Based on user id, he should be deleted from 5 tables and also his
> > photo, if any, should be unlink(ed).
> >
> > $query = "delete from table1 where userid = " . $ID;
> > $result = mysql_query($query, $link);
> >
> > $query = "delete from table2 where userid = " . $ID;
> > $result = mysql_query($query, $link);
> >
> > ...
> >
> > But even with only 10 members, the page takes 30-60 seconds to come back
to
> > me. What is the best way to accomplish this? And it is possibe to delete
> > 1000 by 1000 or 100 by 100?
>
> This could be fixed by changing your database schema. You should have
> your main table, lets call it members, where userid is the primary key.
> All your other tables that use userid should reference members.userid as
> a foreign key with ON DELETE CASCADE set. This will make sure that any
> time a userid is deleted from members, the delete will cascade to all
> other tables that contain userid. See your databases documentation
> CREATE TABLE and ALTER TABLE syntax.
>
> -- David Dickson

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



[PHP] Text Parser

2004-12-02 Thread Pablo D Marotta
Hi there..
A newbie issue:
I´m receiving this: "house , ball , door , roof , floor"
And I want to obtain this: "'house','ball','door','roof','floor'"

Maybe, I should use implode or explode, but I just can´t figure out how..
Help?



American Express made the following
 annotations on 12/02/04 08:13:28
--
**

 "This message and any attachments are solely for the intended recipient 
and may contain confidential or privileged information. If you are not the 
intended recipient, any disclosure, copying, use, or distribution of the 
information included in this message and any attachments is prohibited.  If you 
have received this communication in error, please notify us by reply e-mail and 
immediately and permanently delete this message and any attachments.  Thank 
you."

**

==

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



RE: [PHP] Re: How to tell if the filepath exist or not before attempting to create a directory??

2004-12-02 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 02 December 2004 18:51, Richard Lynch wrote:

> Marek Kilimajer wrote:
> > 
> > What version? On 5.0.2 file_exists('nonexistingfile'); does not
> > generate any error message.
> 
> Ya got me.
> 
> In 4.3.9 it doesn't do that any more either.
> 
> I'm getting old.
> 
> It would be nice to document when it changed if anybody *does* know.

The PHP 4 ChangeLog (http://www.php.net/ChangeLog-4.php) has this for
version 4.3.2:

  Fixed bug #21531 (file_exists() and other filestat functions report
  errors when the requested file/directory does not exists). (Sara) 

and this for version 4.3.3:

  Fixed bug #24313 (file_exists() warning on non-existent files when
  open_basedir is used). (Ilia)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP] Date Manipulation

2004-12-02 Thread Gryffyn, Trevor
In addition to Matthew's response...

Strtotime() and mktime() both return a serial date.  That's the
"1101945775" number you got.  To get this back to a mmdd format that
you seem to be trying to do with mktime(), you want to use date() as
Matthew suggested.  Again, I think examples help more than "RTFM":

date("Ymd",strtotime("now"));

mktime() and strtotime() produce the same output which is not a
human-readable date format.  So basically, in your example below, you
told it that you wanted:

The serial date (mktime()) of hour "Ymd" (evaluates as 0 I believe),
minute "1101945775", with seconds, month, day and year all empty.  I
think the leaving them empty is ok since they're optional from right to
left, and the excessive number of minutes probably wouldn't be a big
deal (unless it goes past the maximum date rate, which looks like what
it's doing).  Let's do a quick calc:


Looks like the max number that mktime() can produce is:
2147483647

This is 1/18/2038 22:14:07

If you take your serial date "1101945775" and pipe it into the minutes
section of mktime(), it'll produce that number times 60 (60 seconds in a
minute) and try to get that date.  This produces a number:

66116746500

Significantly bigger than the max serial date for Windows mentioned
above.


Long answer to maybe help you understand how it all works.


Btw: The serial date is the number of seconds since the beginning of the
"Unix Epoch" (# of secs since January 1, 1970 that is... Hey, time's
gotta start somewhere eh?)

Hope this helps clarify mktime(), strtotime() and date().

-TG

> -Original Message-
> From: Christopher Weaver [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 01, 2004 7:13 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Date Manipulation
> 
> 
> This code:
> 
> echo strtotime("now");
> echo mktime("Ymd", strtotime("now"));
> 
> is producing this result:
> 
> 1101945775
> Warning: mktime(): Windows does not support negative values for this 
> function ...
>  -1
> 
> What am I doing wrong?
> 
> Thanks again.

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



Re: [PHP] Re: How to tell if the filepath exist or not before

2004-12-02 Thread John Nichel
M. Sokolewicz wrote:
John Nichel wrote:
Richard Lynch wrote:
Be kinda like isset() issuing a NOTICE for a variable that's not set. 
Well, duh.  That's why I asked. :-)

isset() doesn't issue a notice...at least not in php 4.3.9.  It just 
returns true or false.

it did for a while in PHP 5.1, for about a day, before it was fixed ;)
isset is defined to specifically check these cases, and thus should 
*never* issue notices about unset variables

It was pointed out to me that Richard wasn't saying that isset() issues 
a notice; more along the lines of, 'it wouldn't make any sense if it did 
issue a notice'.  I don't read to well when I'm sleeping.  ;)

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Working with Dates

2004-12-02 Thread Robert Sossomon
I have this code below that needs to display stuff depending on WHEN it is.  I 
am pretty sure it is something simple I have confused (again) but can't place my 
finger on it.  Anyone see the mistake?


$today = date("m-d-y");
$early = date("m-d-y",mktime(0, 0, 0, 1, 14, 2005));
$normal = date("m-d-y",mktime(0, 0, 0, 1, 31, 2005));
if ($today <= $early) //also done with writing in "01-14-05"
{
 print "Pre-Conference$12";
 print "Early Registration (thru 01-14-05)$85";
 print "Registration for Saturday Only (thru 
01-14-05)$65";
}
else if ($today >= "01-15-05" || $today <= "01-31-05")
{
 print "Registration (01-15-05 thru 
01-31-05)$95";
 print "Registration for Saturday Only (01-15-05 thru 
01-31-05)$70";
}
?>

Thanks,
Robert
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Newbie, project..

2004-12-02 Thread Lennart Andersen
Hi All,

I need to find a newbie project to help me learn PHP, I use Linux and have
apache install with php support! Any suggestions?
-- 
 Lennart Andersen 
 St Thomas, Ontario
 lennart at rogers dot com
--
  - Debian - I hack, therefore I am
  

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



Re: [PHP] Newbie, project..

2004-12-02 Thread Robert Sossomon

Write a guestbook for your website.  :)
My first project for PHP was a custom shopping cart for my old company(ies) and 
I had to write it from the ground up.  Ambitious and I am sure my code is full 
of non-speedy stuff, but it works and still functions (for me anyways, they got 
rid of a 2-yr project when they opted to outsource).


--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] $this - >

2004-12-02 Thread R. Van Tassel
Can someone please point me to the php documentation where it explains

 

$this - > 

 

What is the symbol "- >" and is $this something only used in classes?

 

I can't find any information that explains this specifically but see it used
everywhere.

 

Thanks,

~ R. Van Tassel



[PHP] How to Add a Module

2004-12-02 Thread Nick Peters
Hey,

i currently have a apache and php installed perfectly on my box (slackware
10). However, i have the need to use mcrypt. I have mcrypt all compiled and
installed, but how do i add the module to my php install? I have searched a
few places on the net and i can't figure it out. Thanks in advance.

-- 
-Nick Peters

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



Re: [PHP] Too many DELETE statements

2004-12-02 Thread Lordo
Thanks guys. I delete 500 by 500 now and it takes like 20 seconds only. I am
using the manual select where in method. It is great.

Now for the files, OK I will use a cron. But can I change the way I get the
file names? I mean instead of deleting the photo that is related to a
deleted member, can I delete photos that were last accessed a year ago?

Lordo

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



[PHP] Sessions: Basic Information

2004-12-02 Thread Lordo
I have not yet worked with sessions and I don't know why I DO NOT WANT to
understand it!! :)) I am a traditional ASPer and I am addicted to cookies.
But I want to use sessions if they will make life easier for me.

Can someone please direct me to an easy to understand resource with working
samples? Thanks.

Lordo

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



[PHP] Re: $this - >

2004-12-02 Thread Matthew Weier O'Phinney
* R. Van Tassel <[EMAIL PROTECTED]>:
> --=_NextPart_000_0039_01C4D88C.AECDCB00
> Content-Type: text/plain;
>   charset="us-ascii"
> Content-Transfer-Encoding: 7bit
>
> Can someone please point me to the php documentation where it explains
>
> $this - > 
>
> What is the symbol "- >" and is $this something only used in classes?
>
> I can't find any information that explains this specifically but see it used
> everywhere.

It's in http://php.net/oop and/or http://php.net/oop5 (php5). $this is a
special variable used within methods of classes to indicate the current
object instance. The '->' notation is used to access object properties
and methods.

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



[PHP] Strange character conversion when converting XML by XSLT in PHP

2004-12-02 Thread Age Bosma
I'm converting, or at least trying, one XML file to another XML format 
using XSLT parsing it with PHP.

I'm using a lot of characters in the following style "& #34;", "& #42;", 
etc. (without the space, added now the prevent any conversion in this 
e-mail) in the XML file and I would like to keep it that way. PHP is 
converting every string like these to e.g. "&qout;" or "*". What can be 
done to prevent this conversion?

As far as I understand this is default behaviour of the parser and can 
not be prevented. Personally I consider this a bug because what if I 
just want to use "& #34;" (without the space) as a normal string value? 
The parser shouldn't touch it at all.

Can someone enlighten me a bit more on this one? :-)
Cheers,
Age
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Strange character conversion when converting XML by XSLT in PHP

2004-12-02 Thread John Holmes
Age Bosma wrote:
I'm converting, or at least trying, one XML file to another XML format 
using XSLT parsing it with PHP.

I'm using a lot of characters in the following style "& #34;", "& #42;", 
etc. (without the space, added now the prevent any conversion in this 
e-mail) in the XML file and I would like to keep it that way. PHP is 
converting every string like these to e.g. "&qout;" or "*". What can be 
done to prevent this conversion?

As far as I understand this is default behaviour of the parser and can 
not be prevented. Personally I consider this a bug because what if I 
just want to use "& #34;" (without the space) as a normal string value? 
The parser shouldn't touch it at all.

Can someone enlighten me a bit more on this one? :-)
If you want a literal " in your data, then you should have 
", iirc. Maybe you could run the data through a preparser to 
match "&#xx;" patterns and convert the & to & ??

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Too many DELETE statements

2004-12-02 Thread Richard Lynch
David Dickson wrote:
> Richard Lynch wrote:
>> Plus you are unlink-ing 10 files.  That's probably the real problem.
>>
>> You'd have to write some timing code to be sure, though, as a slow
>> database server and a very fast hard drive could be involved.
>>
>> Here are some things you could do to speed it up, assuming you don't
>> want
>> the ON DELETE CASCADE option, or if your database doesn't provide that
>> option.
>
> You should do this (even if you don't want to) because it is good
> design. If when a member is deleted you want all associated tables to
> also delete this member information then you should set up your foreign
> keys properly.

But you may not want this to *ALWAYS* happen in your business logic.

I don't know enough about the application he's writing to say for sure
either way.

You'd think that you wouldn't want related records hanging around when
deleting a user, but sometimes one does.  Just depends on the application.

> Something else you could do is to build one big rm statement and run it
> in the background. This would save you building a cron job which
> sometimes isn't possible depending on the hosting arrangement.
>
> 
> $Remove = "rm $ImageLocation1; rm $ImagLocation2; rm $ImageLocation3";
> exec("nohop $Remove > /dev/null 2>&1 &");

nohop?

Maybe you mean nohup?...

Or maybe I need to go read "man nohop"... :-)

I've found inconsistent results with trying to fork in the shell from PHP
-- Again this may go back to earlier versions, but I don't know that this
will work for sure in all versions.

> Where the $ImageLocationx is the full path to the image you want to
> delete. The & at the end of the exec tells the command to run in the
> background, which means your script won't wait for the command to finish
> before continuing. The output redirection ( > /dev/null 2>&1) is also
> necessary to allow the script to continue. See the PHP documentation on
> exec for more details.

The downside is that it makes this difficult to debug.

Probably better to re-direct the errors *somewhere* so you have a chance
at debugging things when (not if, when) they break.

Though it probably takes care of whatever was messing me up back in the
day when I was trying to get exec() to fork.

I must say, though, I've found over time that setting up a cron job to
take care of this kind of stuff usually works better for me and the user
experience than exec/fork.

Even with the & to fork, exec is not all that fast, I don't think.

A quick insert to a small table so that a cron job can unlink (and delete
from the table) later works better/faster for me.  YMMV.

Just my opinions, of course.

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

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



Re: [PHP] Working with Dates

2004-12-02 Thread Richard Lynch
Robert Sossomon wrote:
> I have this code below that needs to display stuff depending on WHEN it
> is.  I
> am pretty sure it is something simple I have confused (again) but can't
> place my
> finger on it.  Anyone see the mistake?
>
>
>  $today = date("m-d-y");
> $early = date("m-d-y",mktime(0, 0, 0, 1, 14, 2005));
> $normal = date("m-d-y",mktime(0, 0, 0, 1, 31, 2005));
> if ($today <= $early) //also done with writing in "01-14-05"
> {
>   print "Pre-Conference$12 name=\"Pre-Conference\" type=\"radio\" value=\"Y\">";
>   print "Early Registration (thru 01-14-05)$85 name=\"Conference\" type=\"radio\" value=\"Early
> Registration\">";
>   print "Registration for Saturday Only (thru
> 01-14-05)$65 value=\"Early Saturday Only\">";
> }
> else if ($today >= "01-15-05" || $today <= "01-31-05")

Make this be "elseif" (one word) or you'll some day confuse yourself when
you get nested if/else things going.

Also, you don't want || here, really...
You'd want && to say what you are trying to say.
Dates *WAY* in the future are bigger then 01-15-05, and so they never get
compared to 01-31-05 because you used ||.

At this point, you already *KNOW* that the date is larger than 01-14-05,
so the whole check about 01-15-05 is kinda pointless.

elseif ($today <= "01-31-05") {



A couple other notes.

If you're going to print() out more than a couple lines, just get out of
PHP.  It's going to be easier to maintain your HTML if you do.

Also, you might find this a more natural way to do things:

$today = time();

  Early Registration Stuff Here.
  
  Normal Registratoin Stuff Here.
  
  Tell them how great the event was here, and how they should get on the
  mailing list to sign up for next year!
  http://l-i-e.com/artists.htm

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



Re: [PHP] How to Add a Module

2004-12-02 Thread Richard Lynch
Nick Peters wrote:
> i currently have a apache and php installed perfectly on my box (slackware
> 10). However, i have the need to use mcrypt. I have mcrypt all compiled
> and
> installed, but how do i add the module to my php install? I have searched
> a
> few places on the net and i can't figure it out. Thanks in advance.

If you compiled from source, go back to your PHP source directory, and do:

./config.nice --with-mcrypt

This should copy all your old settings, which were stored in 'config.nice'
from the last time, but tack on --with-mcrypt for you this time.

If you installed from an RPM or whatever Slackware uses for package
management, then you have just stumbled across the main downfall of
packages:  Whomever makes the Slackware PHP package thinks you don't need
mcrypt and you are stuck with starting over compiling PHP from source to
get what you want.  Sorry.

PS While you are at it, you may want to breeze through the manual and see
if there's anything else you for sure want to play with in the next few
weeks, and install that too.

Buut, don't go hog-wild trying to add in a bunch of stuff you might
want "some day"  --  You'll drive yourself crazy trying to get it all
installed, and never get to it until you need to upgrade PHP anyway.  "I
been down that road before"

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

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



Re: [PHP] Too many DELETE statements

2004-12-02 Thread Richard Lynch
Lordo wrote:
> Thanks guys. I delete 500 by 500 now and it takes like 20 seconds only. I
> am
> using the manual select where in method. It is great.
>
> Now for the files, OK I will use a cron. But can I change the way I get
> the
> file names? I mean instead of deleting the photo that is related to a
> deleted member, can I delete photos that were last accessed a year ago?

Sure.

Every Linux file has a file times recorded when it was last accessed, and
last had *anything* including permissions etc modified, and when it was
originally created.

But this might be real dangerous.  Somebody might have a photo they want
to keep that you are about to nuke...

Also be sure to read the caveat in the docs about system where fileatime
is NOT getting changed for performance reasons.

http://php.net/fileatime

You'd probably be better off to nuke the photos of the deleted users, and
then see where you really stand with out-dated/unused photos.

Might be a lot less than you think.

Another option is to write a shell script (or PHP) to find really HUGE
photos that goofballs have uploaded, or users who have *wy* too many
photos, and harass them individually.

It's usually the case that one or two users are clogging up 90% of your
resources when you start digging into this stuff. :-)

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

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



Re: [PHP] Strange character conversion when converting XML by XSLT in PHP

2004-12-02 Thread Richard Lynch
Age Bosma wrote:
> I'm converting, or at least trying, one XML file to another XML format
> using XSLT parsing it with PHP.
>
> I'm using a lot of characters in the following style "& #34;", "& #42;",
> etc. (without the space, added now the prevent any conversion in this
> e-mail) in the XML file and I would like to keep it that way. PHP is
> converting every string like these to e.g. "&qout;" or "*". What can be
> done to prevent this conversion?
>
> As far as I understand this is default behaviour of the parser and can
> not be prevented. Personally I consider this a bug because what if I
> just want to use "& #34;" (without the space) as a normal string value?
> The parser shouldn't touch it at all.
>
> Can someone enlighten me a bit more on this one? :-)

I avoid XML as much as possible, as the biggest bugaboo since Y2K, but,
worst-case scenario.

You should be able to do a http://php.net/str_replace in some judicious
place to un-do the places where the XML parser messed up...

Of course, if you've got & quot; in there in some places, and you want
THAT left alone, you're in trouble...

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

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



[PHP] Apache 2 survey

2004-12-02 Thread Bart Baenisch
Hi -

Please help me quantify the risk of Apache 2.x with PHP 5.x.

Thank you for making the time.

If I missed this on php.net or apache.org or somewhere else, 
please point me to the data.  There is other good survey 
info, but not the PHP 5/Apache 2 combo.

Reply to me directly and I'll summarize for the list by 
Monday, 6 December 2005.

If you are using PHP 5.x with Apache 2.x on Linux or Solaris -

what type of HW?  CPU(s?), RAM, Internet bandwidth
what Solaris level or Linux distro?
average % of HW gets used?  particularly CPU & bandwidth

If you tried Apache 2.x and had to switch to Apache 1.x, what 
were the symptoms?

Thank you for your time.

-Bart

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



[PHP] Mining protection / security code confirmation

2004-12-02 Thread Ho!Tech Guy
I have a classified ad section on my site which uses a privacy mail 
function so users don't have to make their email address public. Recently 
though, the site has been mined (I assume) and spam is being sent.

I was thinking that a "security code confirmation" type script would be 
good where the user has to enter the number shown in a graphic. Am I on the 
right track? If so, can anyone recommend a specific script?

Any advice would be gratefully received.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Sessions: Basic Information

2004-12-02 Thread Peter Lauri
Sessions will make you life easier if you are using cookies to control a web
session. http://th.php.net/manual/en/ref.session.php will give you most
information regarding this, together with some examples. Play around with
simple own examples and you will learn to work with sessions relativly fast.

/Peter


"Lordo" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> I have not yet worked with sessions and I don't know why I DO NOT WANT to
> understand it!! :)) I am a traditional ASPer and I am addicted to cookies.
> But I want to use sessions if they will make life easier for me.
>
> Can someone please direct me to an easy to understand resource with
working
> samples? Thanks.
>
> Lordo

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



[PHP] Need Help

2004-12-02 Thread suneel
Hi to all

any one Could tell me any diffrence between   and . 
And which one is better to use and in which situations.

Byee

Re: [PHP] Need Help

2004-12-02 Thread GH
Basically 

They are the same... some servers might not have  That seems to be the
standard



On Fri, 3 Dec 2004 09:32:34 +0530, suneel <[EMAIL PROTECTED]> wrote:
> Hi to all
> 
>any one Could tell me any diffrence between   and . 
> And which one is better to use and in which situations.
> 
> Byee
>

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



[PHP] Re: Need Help

2004-12-02 Thread Peter Lauri
Use  if you are implementing php. I think that you can predefine
what scriptlanguage to use, and therefore  can be used.

/Peter


"Suneel" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
Hi to all

any one Could tell me any diffrence between   and .
And which one is better to use and in which situations.

Byee

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



Re: [PHP] Need Help

2004-12-02 Thread Thomas Goyne
On Fri, 3 Dec 2004 09:32:34 +0530, suneel <[EMAIL PROTECTED]>  
wrote:

Hi to all
any one Could tell me any diffrence between   and . And which one is better to use and in which situations.

Byee
 is the older syntax, and it can cause problems with xml (as the xml  
prolog uses 

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
http://www.smempire.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] $this - >

2004-12-02 Thread Klaus Reimer
R. Van Tassel wrote:
Can someone please point me to the php documentation where it explains
$this - > 
1. It must be "$this->" and not "$this - >".
2. Documentation can be found here:
http://de.php.net/manual/en/language.oop.php

What is the symbol "- >" and is $this something only used in classes?
Yes. Inside a method you can use "$this" to reference the current object 
in which the method was called. The "->" operator is not specific to 
"$this". It is generelly used to call methods or access properties of an 
object.

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


RE: [PHP] Very fresh to php

2004-12-02 Thread Zareef Ahmed
Hi,

  Visit http://www.sitepoint.com/article/phps-creator-rasmus-lerdorf/39


Zareef ahmed 


-Original Message-
From: Reinhart Viane [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 01, 2004 8:09 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: [PHP] Very fresh to php

I think it was Darth Moeder

"PHP, I am your mother, *heavely breathing*"

(for those who don't speak dutch: Vader is 'father' and Moeder is
'mother') 

-Original Message-
From: Santa [mailto:[EMAIL PROTECTED] 
Sent: woensdag 1 december 2004 9:29
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Very fresh to php


В сообщении от Среда 01 Декабрь 2004 07:45 suneel написал(a):
> Hi...guys,
>
> I'm a new bee to php. Could any one tell me that who is 
> the father of php?
>
> take care guys,

and who is mother? 8)

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



Zareef Ahmed :: A PHP Developer in Delhi ( India )
Homepage :: http://www.zasaifi.com


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.802 / Virus Database: 545 - Release Date: 11/26/2004
 

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