[PHP] Re: How to write a PHP coding to list out all files and directories as links to them?

2011-04-14 Thread David Robley
Mikhail S wrote:

> How to write a PHP coding to list out all files and directories as links
> to them?
> 
> This is somewhat similar to some index pages. When new file or folder is
> added to the directory, HTML page should display the newly created
> file/folder together with previous ones after it is being refreshed.
> (prefer in alphabatical order)
> 
> How to achieve this sort of functionality in PHP? Please provide sample
> coding as well. (and any references)
> 
> Thanks.
> 
> --
> Mike
> http://jp.shopsloop.com/

Start with http://php.net/manual/en/function.opendir.php for a basic method.

Alternatively you can use the SPL DirectoryIterator class
http://php.net/manual/en/class.directoryiterator.php

http://php.net is your first resource for php



Cheers
-- 
David Robley

Hm..what's this red button fo:=/07http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to write a PHP coding to list out all files and directories as links to them?

2011-04-14 Thread Mikhail S
How to write a PHP coding to list out all files and directories as links to
them?

This is somewhat similar to some index pages. When new file or folder is
added to the directory, HTML page should display the newly created
file/folder together with previous ones after it is being refreshed. (prefer
in alphabatical order)

How to achieve this sort of functionality in PHP? Please provide sample
coding as well. (and any references)

Thanks.

--
Mike
http://jp.shopsloop.com/


Re: [PHP] $_POST vars

2011-04-14 Thread Jim Giner
Guys - the problem has been solved.

Give it a rest.

(sent only to the list)

(remainder deleted for the benefit of all :) ) 



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



Re: [PHP] $_POST vars

2011-04-14 Thread Stuart Dallas
On Thursday, 14 April 2011 at 23:08, Nathan Nobbe wrote:
On Thu, Apr 14, 2011 at 2:53 AM, Stuart Dallas  wrote:
> > On Thursday, 14 April 2011 at 07:11, Nathan Nobbe wrote:
> >  On Wed, Apr 13, 2011 at 3:30 PM, Stuart Dallas  wrote:
> > > > On Wednesday, 13 April 2011 at 19:47, Nathan Nobbe wrote:
> > > > I never make any assumptions about the source of any data when I'm 
> > > > developing software, whether in PHP or not. Returning to a previous 
> > > > point, usage of global variables as the source of data anywhere other 
> > > > than the initial script a request hits is tantamount to negligence. But 
> > > > that's just my opinion.
> > > Who said you should make assumptions. One thing you know is that $_POST 
> > > was populated by the contents of HTTP POST, or most of it anyways, lol.
> > 
> > Again, I don't see how that "knowledge" is useful?
> 
> you know what doesn't belong there.

It's coming from the client, over which you have no control whatsoever. It 
doesn't matter what you think you know about what it should contain, you 
actually don't know anything about what it does contain and you should write 
your code accordingly. You can't afford to assume anything about data coming 
into your application from sources you don't control.

> > > Here's an example, suppose you have an object, any object in php should 
> > > let you dynamically create a public member variable on it on the fly 
> > > unless there's an explicit override in __get().
> > > 
> > > $oXml = new 
> > > SimpleXmlElement('real-data');
> > > 
> > > now someone decides to use it to store something clever, because they 
> > > can, and it's so much easier than creating an appropriate location
> > > 
> > > $oXml->myCleverValue = 'something unrelated';
> > > 
> > > whoops the client web service stopped processing our request successfully 
> > > because the clever new node inadvertently broke the validation against 
> > > the xsd.
> > > 
> > > or I'm running through some code and see it in a for loop
> > > 
> > > foreach($oXml as $node => $value)
> > > 
> > > but I don't see any clever value in the docs from the vendor..
> > > 
> > > Separation of concerns for data. The same reason you have a typical 
> > > directory structure on an operating system and the same reason you don't 
> > > have 10 projects all in the same vcs repository. but nothing is written 
> > > in stone..
> > 
> > Whoa, whoa, whoa! At what point did I say I think it's ok to put arbitrary 
> > data into $_POST?
> 
> when you suggested to OP to put the result of a query into $_POST. 

Terminology confusion. To me, the "result of a query" is the data, not the 
resource. Personally I think it was pretty clear that's what I meant based on 
what the OP was planning to do, but I can see how that might not have been 
crystal clear.

> >  As I said in a previous email, I was responding to the OP's question which 
> > was essentially "is it possible to fake a form post" and the answer is yes
> 
> 
> the question was more like, how do i abstract the input for a template such 
> that it can be supplied data via $_POST in one case and the result of a 
> select in another.

That's not what he asked, but it is one possible answer to his question.

> > I have at no point advocated using $_POST for data that you simply want to 
> > be globally available.
> you've recommended populating $_POST with data that has nothing to do with 
> HTTP POST, it is by nature globally available.

I have suggested that there is nothing wrong with modifying data in the $_POST 
global variable to essentially fake that it had come from a form post. I never 
suggested that it should be used as a generic global store.

I think we've started going around in circles and this is no longer benefiting 
anyone. I think we're essentially saying the same thing, but where you're 
relying on rules around how $_POST should be used I'm advocating vigilant 
defensive programming techniques, and it seems we're going to have to agree to 
disagree.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/





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



Re: [PHP] $_POST vars

2011-04-14 Thread Nathan Nobbe
On Thu, Apr 14, 2011 at 2:53 AM, Stuart Dallas  wrote:

> On Thursday, 14 April 2011 at 07:11, Nathan Nobbe wrote:
> On Wed, Apr 13, 2011 at 3:30 PM, Stuart Dallas  wrote:
> > > On Wednesday, 13 April 2011 at 19:47, Nathan Nobbe wrote:
> > > I never make any assumptions about the source of any data when I'm
> developing software, whether in PHP or not. Returning to a previous point,
> usage of global variables as the source of data anywhere other than the
> initial script a request hits is tantamount to negligence. But that's just
> my opinion.
> > Who said you should make assumptions. One thing you know is that $_POST
> was populated by the contents of HTTP POST, or most of it anyways, lol.
>
> Again, I don't see how that "knowledge" is useful?
>

you know what doesn't belong there.


>  > Here's an example, suppose you have an object, any object in php should
> let you dynamically create a public member variable on it on the fly unless
> there's an explicit override in __get().
> >
> > $oXml = new
> SimpleXmlElement('real-data');
> >
> > now someone decides to use it to store something clever, because they
> can, and it's so much easier than creating an appropriate location
> >
> > $oXml->myCleverValue = 'something unrelated';
> >
> > whoops the client web service stopped processing our request successfully
> because the clever new node inadvertently broke the validation against the
> xsd.
> >
> > or I'm running through some code and see it in a for loop
> >
> > foreach($oXml as $node => $value)
> >
> > but I don't see any clever value in the docs from the vendor..
> >
> > Separation of concerns for data. The same reason you have a typical
> directory structure on an operating system and the same reason you don't
> have 10 projects all in the same vcs repository. but nothing is written in
> stone..
>
> Whoa, whoa, whoa! At what point did I say I think it's ok to put arbitrary
> data into $_POST?


when you suggested to OP to put the result of a query into $_POST.


> As I said in a previous email, I was responding to the OP's question which
> was essentially "is it possible to fake a form post" and the answer is yes


the question was more like, how do i abstract the input for a template such
that it can be supplied data via $_POST in one case and the result of a
select in another.


> I have at no point advocated using $_POST for data that you simply want to
> be globally available.
>

you've recommended populating $_POST with data that has nothing to do with
HTTP POST, it is by nature globally available.

-nathan


[PHP] gmp_gcdext() results are different for 32 bit & 64 bit machines

2011-04-14 Thread Waiki Wright

Hi,
I ran a few different numbers using gmp_gcdext on both 32 & 64 bit 
machines and most of the results are the same except the following example:




On a 32 bit machine, the results are:
string(3) "195"
string(14) "-4760039754357"
string(10) "6965866288"
Done

On a 64 bit machine, the results are:
string(3) "195"
string(15) "-20983781660442"
string(11) "30707772373"
Done

Does anyone know why I have different results for "s" and "t" on 32 bit 
and 64 bit machines?


Thanks!
Waiki Wright


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



Re: [PHP] A Starter has prob in blog script

2011-04-14 Thread Silvio Siefke
Hello,


i have it running now. For complete the thread, write here the code with
it run.

query($sql);
foreach ($result as $var)  {
echo $var['content'];
}
$DB = null;
}
catch (PDOException $e) {
echo "Fehler: " . $e->getMessage();
exit ();
}
?>

Regards
Silvio

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



Re: [PHP] $_POST vars

2011-04-14 Thread Stuart Dallas
On Thursday, 14 April 2011 at 07:11, Nathan Nobbe wrote:
On Wed, Apr 13, 2011 at 3:30 PM, Stuart Dallas  wrote:
> > On Wednesday, 13 April 2011 at 19:47, Nathan Nobbe wrote:
> > I never make any assumptions about the source of any data when I'm 
> > developing software, whether in PHP or not. Returning to a previous point, 
> > usage of global variables as the source of data anywhere other than the 
> > initial script a request hits is tantamount to negligence. But that's just 
> > my opinion.
> Who said you should make assumptions. One thing you know is that $_POST was 
> populated by the contents of HTTP POST, or most of it anyways, lol.

Again, I don't see how that "knowledge" is useful?

> Here's an example, suppose you have an object, any object in php should let 
> you dynamically create a public member variable on it on the fly unless 
> there's an explicit override in __get(). 
> 
> $oXml = new 
> SimpleXmlElement('real-data');
> 
> now someone decides to use it to store something clever, because they can, 
> and it's so much easier than creating an appropriate location 
> 
> $oXml->myCleverValue = 'something unrelated';
> 
> whoops the client web service stopped processing our request successfully 
> because the clever new node inadvertently broke the validation against the 
> xsd. 
> 
> or I'm running through some code and see it in a for loop
> 
> foreach($oXml as $node => $value)
> 
> but I don't see any clever value in the docs from the vendor.. 
> 
> Separation of concerns for data. The same reason you have a typical directory 
> structure on an operating system and the same reason you don't have 10 
> projects all in the same vcs repository. but nothing is written in stone.. 

Whoa, whoa, whoa! At what point did I say I think it's ok to put arbitrary data 
into $_POST? As I said in a previous email, I was responding to the OP's 
question which was essentially "is it possible to fake a form post" and the 
answer is yes. I have at no point advocated using $_POST for data that you 
simply want to be globally available.

> > But here's a question that just occurred to me... what are you doing 
> > differently based on the assumption that those arrays are populated by PHP?
> 
> the first place you look for data in the $_POST array is the client layer. it 
> doesn't matter if they were populated by php or apache, the important part is 
> what the container is supposed to store, what it represents. A common issue 
> that was recently brought up on the list is the typical abuse the $_SESSION 
> array gets in PHP applications. $_POST is no different, though in my 
> experience it's not abused as frequently, most people seem to just get it, 
> but then, nothing's written in stone. 
> 
> > Seems to me that data in those arrays should be treated more carefully than 
> > any other data, so why you feel you need to know where they came from is 
> > beyond me. Can you elaborate?
> 
> 
> It's not where the data came from, it's what the data represents. I worked on 
> an application several years ago where values were gratuitously placed in all 
> of the superglobal arrays. The application had some crude database layer that 
> was stuffing the mysql_insert_id into $_POST. So you might see some code like 
> 
> // do some real work, and by the way insert a record into the db
> 
> // then later on
> $ourNewWhateverID = $_POST['NEW_ID'];
> 
> well the first assumption is that that value had to come from the browser 
> (only client in this application) so you start looking through html forms and 
> javascript code (running grep through the template directories etc)... maybe 
> it's set dynamically by some javascript code and passed over in an ajax 
> request... or it was passed along by the previous page.., or no, maybe 
> someone who used to code here didn't realize they could put it in the 
> $GLOBALS array where other programmers expect to find user space values ... 
> or better yet, they might not use the global context for this sort of thing 
> at all... but no, you had to go ahead and 
> 
> $_POST['NEW_ID'] = mysql_insert_id();
> 
> I'm not sure where your meter on best practices falls, but in my book even if 
> the key was 'LAST_INSERT_ID' i'd chalk it up to brain dead. Let's take a 
> dynamically generated value from the database and put it in a structure 
> understood to be populated by data from the request; brilliant! 

My point is and has always been that there is nothing inherently wrong with 
setting or modifying values in $_POST. I agree that it is bad practice to use 
$_POST for arbitrary stuff, but I see nothing wrong in setting or modifying 
values to enable another part of your code to process that data as if it had 
been POSTed, which is what the OP was wanting to do.

> The only real value I see to setting values in the $_REQUEST et al arrays is 
> unit testing.

IOW, faking a request which, again, was what the OP wanted to do!

A couple of final points of personal opinion...

* Any code that

[PHP] upload big files

2011-04-14 Thread Ricardo Martinez
Hi List!

Need can upload big files ( around 300MB ) the system must be easy of use (
cann't use ftp ).

Was thinking in make it, using a form with post, and update the cfg files
for can upload big files.
But don't know how it going to work. I think that can give a lot of errors
or be unestable.

Just asking if anyone had a project like this one ;)

Greetings!

-- 
Ricardo
___
IT Architect
website: http://www.pulsarinara.com