php-general Digest 24 Jun 2009 08:52:45 -0000 Issue 6192

Topics (messages 294486 through 294506):

Re: supplied argument errors
        294486 by: PJ
        294489 by: Lex Braun
        294491 by: kranthi
        294497 by: Shawn McKenzie

Re: delete & insert ?
        294487 by: Bastien Koert

Re: modifying within foreach
        294488 by: Eddie Drapkin
        294490 by: Martin Scotta

Re: I've some doubts if I should go with 5.2 or go already with 5.3 (for a 
course)
        294492 by: Manuel Aude
        294493 by: Michael A. Peters
        294494 by: Michael A. Peters
        294506 by: Robert Cummings

Re: Using large multi dimenstional arrays in js
        294495 by: Simon

PHP module "portability" on OSX 10.4
        294496 by: Matt Neimeyer

Re: resubmit form after validation error
        294498 by: Shawn McKenzie

Re: XSS Preventing.
        294499 by: Martin Zvarík

Re: Deleting a file after download/upload
        294500 by: Shawn McKenzie

anyone using session_mysql successfully
        294501 by: Randy Paries
        294502 by: Michael A. Peters

Progressbar
        294503 by: Teun Lassche
        294504 by: Tom Sparks
        294505 by: Nitsan Bin-Nun

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Lex Braun wrote:
>
>
> On Tue, Jun 23, 2009 at 4:10 PM, PJ <af.gour...@videotron.ca
> <mailto:af.gour...@videotron.ca>> wrote:
>
>     I think there is something I do not understand in the manual about
>     mysql_fetch_assoc(), mysql_affected_rows()
>     The code works, but I get these annoying messages.
>     snippet:
>
> <snip>
> What are the warnings?
1 .supplied argument is not a valid MySQL result resource
2. supplied argument is not a valid MySQL-link resource

snippet:
$result = mysql_query($sql, $db); // this is following an UPDATE
          $row = mysql_fetch_assoc($result); // warning... 1.
          if (mysql_affected_rows($result) !== -1) //warning...2.
        print_r($result); // returns 1

another:
 $sql = "DELETE FROM book_categories WHERE bookID = $bid";
            $result = mysql_query($sql, $db);     // warning...1.
              $row = mysql_fetch_assoc($result); // warning...1.
                if (mysql_num_rows($result) !== 0) {
the last:
  $result = mysql_query($sql,$db); // following an INSERT
    if (mysql_affected_rows($result) == -1) {  // warning....2.



-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


--- End Message ---
--- Begin Message ---
On Tue, Jun 23, 2009 at 4:10 PM, PJ <af.gour...@videotron.ca> wrote:

> I think there is something I do not understand in the manual about
> mysql_fetch_assoc(), mysql_affected_rows()
> The code works, but I get these annoying messages.
> snippet:
>
<snip>
What are the warnings?

--- End Message ---
--- Begin Message ---
the code works?

the above warnings suggest that ter is a mysql syntax error.

moreover the documentation of mysql_affected_rows suggests that u should
supply a valid recource identifier but not a mysql result resource.
i.e., the above should be mysql_affected_rows($db)

--- End Message ---
--- Begin Message ---
kranthi wrote:
> the code works?
> 
> the above warnings suggest that ter is a mysql syntax error.
> 
> moreover the documentation of mysql_affected_rows suggests that u should
> supply a valid recource identifier but not a mysql result resource.
> i.e., the above should be mysql_affected_rows($db)
> 

Yes, so:

1.  It was an UPDATE and not a SELECT, how would it return any f'ing
rows?!?! $rows is either TRUE or FALSE, because it returns whether the
UPDATE was successful or not.

2. Please read the f'ing manual about what kranthi said!

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
On Tue, Jun 23, 2009 at 4:20 PM, PJ<af.gour...@videotron.ca> wrote:
> I just had a bright idea ???
> Am doing editing file for book entries; it occurs to me (now that I am
> practically finished) that it might be much simpler to delete entries
> and just insert rather than going through the rigamarole of checking if
> the new entries exist and if and if and if... just delete & insert -
> less code, less headaches... or is this a cute fantasy & I should get
> myself locked up?
> Guys, don't go overboard on this... I know I'm leaving myself wide open :-P
>
> --
> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> -------------------------------------------------------------
> Phil Jourdan --- p...@ptahhotep.com
>   http://www.ptahhotep.com
>   http://www.chiccantine.com/andypantry.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Try using the REPLACE statement if you are using mysql... it will
allow automatic update without the UPDATE syntax and inserts if the
key id is not there

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
It's just foreach($foo as $key => &$item) { }

You can't assign the key by reference >.>

On Tue, Jun 23, 2009 at 3:04 PM, Ashley
Sheridan<a...@ashleysheridan.co.uk> wrote:
> On Tue, 2009-06-23 at 12:56 -0600, kirk.john...@zootweb.com wrote:
>> Andres Gonzalez <and...@packetstorm.com> wrote on 06/23/2009 12:26:38 PM:
>>
>> > I want to modify $results within the foreach. In other words,
>> > during a given pass of this iteration, I want to delete some
>> > of the items based on particular conditions. Then on the next
>> > pass thru the foreach, I want $results to be the newer, modified
>> > array.
>> >
>> > This does not seem to work. It appears that the foreach statement
>> > is implemented such that $results is read into memory at the start
>> > so that any modifications I make to it during a given pass, are ignored
>> > on the next pass. Is this true?
>>
>> foreach works on a copy of an array, so the behavior you saw is expected.
>> See the online manual.
>>
>> You could use a while loop, or, instead of unset-ing elements of $results,
>> store the elements you want to keep into a new array.
>>
>> Kirk
>
> What about passing it by reference?
>
> foreach($results as &$key => &$item)
> {
>    // modify items here
> }
>
> Thanks
> Ash
> www.ashleysheridan.co.uk
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
AddBrainHandler x-httpd-php5 .php

On Tue, Jun 23, 2009 at 4:25 PM, Robert Cummings <rob...@interjinn.com>wrote:

> Ashley Sheridan wrote:
>
>> On Tue, 2009-06-23 at 15:07 -0400, Eddie Drapkin wrote:
>>
>>> It's just foreach($foo as $key => &$item) { }
>>>
>>> You can't assign the key by reference >.>
>>>
>>> On Tue, Jun 23, 2009 at 3:04 PM, Ashley
>>> Sheridan<a...@ashleysheridan.co.uk> wrote:
>>>
>>>> On Tue, 2009-06-23 at 12:56 -0600, kirk.john...@zootweb.com wrote:
>>>>
>>>>> Andres Gonzalez <and...@packetstorm.com> wrote on 06/23/2009 12:26:38
>>>>> PM:
>>>>>
>>>>>  I want to modify $results within the foreach. In other words,
>>>>>> during a given pass of this iteration, I want to delete some
>>>>>> of the items based on particular conditions. Then on the next
>>>>>> pass thru the foreach, I want $results to be the newer, modified
>>>>>> array.
>>>>>>
>>>>>> This does not seem to work. It appears that the foreach statement
>>>>>> is implemented such that $results is read into memory at the start
>>>>>> so that any modifications I make to it during a given pass, are
>>>>>> ignored
>>>>>> on the next pass. Is this true?
>>>>>>
>>>>> foreach works on a copy of an array, so the behavior you saw is
>>>>> expected.
>>>>> See the online manual.
>>>>>
>>>>> You could use a while loop, or, instead of unset-ing elements of
>>>>> $results,
>>>>> store the elements you want to keep into a new array.
>>>>>
>>>>> Kirk
>>>>>
>>>> What about passing it by reference?
>>>>
>>>> foreach($results as &$key => &$item)
>>>> {
>>>>   // modify items here
>>>> }
>>>>
>>>> Thanks
>>>> Ash
>>>> www.ashleysheridan.co.uk
>>>>
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>>>
>> Yeah, hehe, I was trying to remember off the top of my head, and
>> obviously forgot! :p
>>
>> *slaps self*
>>
>
> Your brain is in PHP4 mode...
>
> *slaps Ashley*
>
> >:)
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Martin Scotta

--- End Message ---
--- Begin Message ---
Let's put it this way: MVC frameworks with namespaces are going to change a
lot. The architecture can be made much cleaner and class names won't have to
be so long (Zend_Db_Adapter_Db2_Exception), for instance.

The design part of coding is __VERY__ important, and this changes are
specially for that. See PHAR extension, which will be enabled now, which
allows for easier distribution of software. And closures, which simply have
so many uses in design and save you from clustering your code with too many
function names.

Sure, it doesn't change the language, and it doesn't really break apps that
were written in PHP 5.2, but if you're going to design an application,
thinking about this options is very useful.

Too bad we don't get Traits yet =( Horizontal re-use is very nice.


> Robert Cummings wrote:
>
> > Per Jessen wrote:
> >> Manuel Aude wrote:
> >>
> >>> I'm giving a PHP course next semester (3 hours all saturdays for 22
> >>> weeks) and I just realized that PHP 5.3 is coming very soon (2 days
> >>> now!). So, my plans of teaching PHP 5.2 are starting to change, and
> >>> I think it's a good idea to teach them 5.3 already.
> >>
> >> Does it _really_ matter which one? I can't imagine there are that
> >> many revolutionary changes in a dot-release.
> >
> > Given the naming of PHP versions of PHP-x.y.z, I would agree that not
> > much changes between versions at the .z level. But at the .y level
> > there are usually significant changes.
> >
> > Coming to a PHP 5.3 near you are the following notable features:
> >
> > - namespaces
> > - closures
> > - late static binding
> > - garbage collector to handle cyclic references
> > - PHAR
> > - goto
>
> I hadn't actually seen/studied the list, but apart from the goto, I
> don't consider any of those revolutionary :-)
>
>
> /Per
>

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
Michael A. Peters wrote:
Manuel Aude wrote:
I'm giving a PHP course next semester (3 hours all saturdays for 22 weeks) and I just realized that PHP 5.3 is coming very soon (2 days now!). So, my plans of teaching PHP 5.2 are starting to change, and I think it's a good
idea to teach them 5.3 already.

While the majority of the students use Windows, I'm aware that a vast amount
will be using Ubuntu/Debian (and some use Gentoo, Fedora and Arch)
distributions of Linux, so I'm hoping there won't be too many problems on
installation. I don't want to waste the entire first class fixing
installation problems, because that kills the student's motivation.

The course starts on August, but I'm preparing it during the last two weeks of July. You think that installation packages will be bulletproof by then? Or should I just teach 5.2 and wait for another semester before starting on 5.3? I mean, most hosts will remain with PHP 5.2 for the rest of the year,
so I'm a bit confused on what I should do.

I'm just a university student that wants to spread PHP, for I've been using
it for many years now =)

Thanks for the advices,
Mamsaac


Many hosts are still on php 5.1.x (IE RHEL based hosts).
I would be worried that many popular classes and apps might be quirky under 5.3.

I've not played with it at all, and probably won't for some time, but I've been bitten by that more than once.

Nice thing about 5.2.x as far as linux goes anyway, installing it is cake from the package repositories. Using package repositories for php installs is suggested as security fixes can be updated with ease.

As someone running a newer version of php (5.2.9) than what my distro ships with, here are some of the issues:

A) I needed to create packages so that I could RPM install various stuff, like Squirelmail, etc. - and get the security updates for them from my OS vendor (CentOS or EPEL repods). So to do that, I used the Fedora src.rpm.

B) When building php rpm's on my system, the %check portion of the spec file (runs make test I believe) fails sometimes if there is an existing php install. To solve that, you have to build it in mock.

C) Mock needs a lot of disk space and will download a lot of packages, if you don't local mirror the update repositories, it can be really time consuming. Furthermore, occasionally the build list for mock is broken making it un-usable for package building.

I have to use 5.2.x because I need a pecl extension that does not work with 5.1.x - and building rpm myself lets me add suhosin patch (to the fedora spec file) but unless your Linux students want to do absolutely everything php by source and not have anything installed from the package managers that rely on php, I would highly suggest that they use whatever version of php their distro of choice has in its stable repositories.

-=-

Since you are teaching students, one pet peeve of mine that I see in web app after web app after web app - they have an admin interface that writes a php file which the app then parses as php. Often they even instruct the person installing the web app to have 777 permissions of directories and/or files within the web root.

There's a better way. Either store the configuration settings in a database (obviously can't store database connection setting in the database ...) or store them in an xml file, not php.

You can write and read the xml file with any number of existing php functions. And the config file should not be in the web root, nothing the web server can write to should be in the document root.

Applications (like Gallery and I think joomla and wordpress) often want write permission to the document root so they can have a web interface to install/update their modules - but it creates a security risk. It's better to install the modules you want from a distro vendor repository so you can keep them up to date that way, and hence, it's better to use a packaged php install so that the dependencies are met.

Sorry for rambling, but the trend of web server having write permissions to files the web server then executes (and often in the web root) is a trend that needs to stop. So flunk the students that do it ;)

And how do you propose people get around open_basedir restrictions which is common in many Plesk environments?

There is nothing wrong with having the above mentioned write access if it is properly protected.

Nothing wrong other than any vulnerability in apache (or a module apache loads or cgi/server script code) that allows a malicious user to write data as the apache user can now do so inside the web root where they can then request it causing php/perl/python/whatever to execute the code they just wrote.

Every single web host I have ever used that has a shell account given me a directory that is not inside the web root.

IE my login home dir might be /srv/www.mydomain.com/

The documentroot would likely be /srv/www.mydomain.com/www

Thus I could create directories inside my home directory apache can write to that are outside the web root and thus are far more secure.

Any web host that did not allow me to set up a secure environment for my apps is a web host I would never use again, as there are PLENTY of web hosts that DO allow the user to properly set up a web app.


Cheers,
Rob.


--- End Message ---
--- Begin Message ---
Bob McConnell wrote:


I have recently been told that we are switching from compiling Apache,
PHP and PostgreSQL ourselves to only using the official RedHat RPMs on
our production servers[*].

*snip*


[*] No, I don't like this at all. I see it as the antithesis of both the
Open Source and Free Software philosophies. It means we give up control
of some of the options we were selecting at compile time and have to
settle for somebody else's idea of the perfect server. I fully expect it
will come back to bite us at some point.


It's probably a paid support issue.
If they are going with RHEL instead of a free distribution, they probably are doing so for the support RHEL offers.

As soon as you modify the applications, Red Hat understandably refuses to support the modified applications, thus neutering the point of using RHEL.
--- End Message ---
--- Begin Message ---


Michael A. Peters wrote:
Robert Cummings wrote:
Michael A. Peters wrote:
Manuel Aude wrote:
I'm giving a PHP course next semester (3 hours all saturdays for 22 weeks) and I just realized that PHP 5.3 is coming very soon (2 days now!). So, my plans of teaching PHP 5.2 are starting to change, and I think it's a good
idea to teach them 5.3 already.

While the majority of the students use Windows, I'm aware that a vast amount
will be using Ubuntu/Debian (and some use Gentoo, Fedora and Arch)
distributions of Linux, so I'm hoping there won't be too many problems on
installation. I don't want to waste the entire first class fixing
installation problems, because that kills the student's motivation.

The course starts on August, but I'm preparing it during the last two weeks of July. You think that installation packages will be bulletproof by then? Or should I just teach 5.2 and wait for another semester before starting on 5.3? I mean, most hosts will remain with PHP 5.2 for the rest of the year,
so I'm a bit confused on what I should do.

I'm just a university student that wants to spread PHP, for I've been using
it for many years now =)

Thanks for the advices,
Mamsaac

Many hosts are still on php 5.1.x (IE RHEL based hosts).
I would be worried that many popular classes and apps might be quirky under 5.3.

I've not played with it at all, and probably won't for some time, but I've been bitten by that more than once.

Nice thing about 5.2.x as far as linux goes anyway, installing it is cake from the package repositories. Using package repositories for php installs is suggested as security fixes can be updated with ease.

As someone running a newer version of php (5.2.9) than what my distro ships with, here are some of the issues:

A) I needed to create packages so that I could RPM install various stuff, like Squirelmail, etc. - and get the security updates for them from my OS vendor (CentOS or EPEL repods). So to do that, I used the Fedora src.rpm.

B) When building php rpm's on my system, the %check portion of the spec file (runs make test I believe) fails sometimes if there is an existing php install. To solve that, you have to build it in mock.

C) Mock needs a lot of disk space and will download a lot of packages, if you don't local mirror the update repositories, it can be really time consuming. Furthermore, occasionally the build list for mock is broken making it un-usable for package building.

I have to use 5.2.x because I need a pecl extension that does not work with 5.1.x - and building rpm myself lets me add suhosin patch (to the fedora spec file) but unless your Linux students want to do absolutely everything php by source and not have anything installed from the package managers that rely on php, I would highly suggest that they use whatever version of php their distro of choice has in its stable repositories.

-=-

Since you are teaching students, one pet peeve of mine that I see in web app after web app after web app - they have an admin interface that writes a php file which the app then parses as php. Often they even instruct the person installing the web app to have 777 permissions of directories and/or files within the web root.

There's a better way. Either store the configuration settings in a database (obviously can't store database connection setting in the database ...) or store them in an xml file, not php.

You can write and read the xml file with any number of existing php functions. And the config file should not be in the web root, nothing the web server can write to should be in the document root.

Applications (like Gallery and I think joomla and wordpress) often want write permission to the document root so they can have a web interface to install/update their modules - but it creates a security risk. It's better to install the modules you want from a distro vendor repository so you can keep them up to date that way, and hence, it's better to use a packaged php install so that the dependencies are met.

Sorry for rambling, but the trend of web server having write permissions to files the web server then executes (and often in the web root) is a trend that needs to stop. So flunk the students that do it ;)
And how do you propose people get around open_basedir restrictions which is common in many Plesk environments?

There is nothing wrong with having the above mentioned write access if it is properly protected.

Nothing wrong other than any vulnerability in apache (or a module apache loads or cgi/server script code) that allows a malicious user to write data as the apache user can now do so inside the web root where they can then request it causing php/perl/python/whatever to execute the code they just wrote.

This is fear mongering. I could make the same argument that making use of a webserver opens you up to any vulnerability in the webserver that may provide access to the entire filesystem. The intended purpose of the webserver is not to allow such access when configured properly, and so it is an exceptional circumstance when such security is compromised. It is common practice to use .htaccess to lock off sensitive areas of a website such as where any writeable documents live. if you set permissions appropriately on the filesystem then the web process should only be able to read those areas where you don't want it to write. Writeable and executable permissions may pose a special problem, but one can merely enable the rights when updating the modules and revoke them afterwards.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---
--- Begin Message ---
you could pack the array into a string and decode that later, using
json prolly...

Or, you could output the data to XML and load the xml file in an
iframe, then browse through the iframe's DOM structure to get the
values you need.


On Wed, Jun 17, 2009 at 6:32 PM, Sancar Saran<sancar.sa...@evodot.com> wrote:
> Hello all,
>
> My new project needs to use large multi dimenstional php arrays in javascript.
>
> I'm not sure how to do it.
>
> Is there any lead or any one give a clue.
>
> Regards
>
> Sancar
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
I know this is a bit OS specific but it's for PHP so I'm hoping
someone here has run into it before and can answer.

I've compiled php_gd.so for use on an XServe running OSX 10.4. It
works fine there. When I copy it to another XServe it fails because of
missing dependencies (don't remember the exact error but that was the
jist of it).

I used otool -L php_gd.so and got the following...

php_gd.so:
        /usr/local/lib/libpng12.0.dylib (compatibility version 33.0.0,
current version 33.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current
version 1.2.3)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0,
current version 88.1.11)

libz.1.dylib and libSystem.B.dylib exist on a "raw" machine so I
assume it's just the libpng.

So... Can I just ALSO copy the libpng file, drop it in the right place
and have it work? It seems like it should work... but at the same
time, something in my head is telling me it shouldn't work...

Barring that does anyone have steps "written down" that I can follow
to compile php_gd.so with libpng compiled in somehow so it is only one
file?

Thanks in advance!

Matt

--- End Message ---
--- Begin Message ---
PJ wrote:
> Shawn McKenzie wrote:
>> PJ wrote:
>>   
>>> Caner Bulut wrote:
>>>     
>>>> Hi PJ,
>>>>
>>>> You can use the structure following
>>>>
>>>> $bid = htmlentities($_GET['id']);
>>>>
>>>>       
>>> the code below
>>>     
>>>> if(empty($bid) {
>>>> $bid=0;
>>>> }
>>>>       
>>> produces an empty screen with no error messages...
>>> I have been having some trouble understanding "empty()" -- it doesn't
>>> seem to want to work for me in any situation
>>>     
>> YOU, always need to have error_reporting on and display errors on, and
>> also be logging errors so that you can see parse errors in the log.
>> Always check the log after a "empty screen".  I've seen many posts from
>> you where you get a blank, empty, white screen.  This is most always a
>> parse error!.  Get an editor that will show you bad syntax like the
>> above.  It is a freaking parse error because you don't have matched
>> parentheses!
>>
>>   
> Shawn, I always have error_reporting on and display errors on.
> Ok, I didn't see the error above; but in my defense (no defense really),
> I should have thought about it) i just copied the code I was given.
> Dumb, dumb, dumb. Thanks for pointing it out.
> And yes, I do have a lot of problems with curly braces & parentheses.
> I eventually do find them... but...
> I have been thinking about what editor would show me bad syntax...
> I've been using HOMESITE+ for no other reason than that it allows me to
> switch between files quickly ... I do have Netbeans, but it screwed me
> once when I accidentally closed it and I lost the whole file and had to
> redo it all, so I'm a bit wary...
> And I'm not too keen on getting into some IDE... tried them and found
> them cumbersome to set up & learn.
> Any suggestions?
> 

If you are on Winbloze, I thing the free notepad++ has syntax
highlighting for PHP.

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Philip Thompson napsal(a):
On Jun 23, 2009, at 9:29 AM, Martin Zvarík wrote:

Don't htmlentiies() before DB save.  In general:
- mysql_real_escape_string() before DB insertion
- htmlentities() before dispaly


I, on the other hand, would do htmlentities() BEFORE insertion.


Pros:
---
The text is processed once and doesn't have to be htmlentitied() everytime you read the database - what a stupid waste of performance anyway.


Cons:
---
Instead "&" you'll see "&amp;" ... is that a problem? Not for me and I believe 80% of others who use DB to store & view on web.

I had a problem with storing &amp; into the database instead of just &. When I wanted to search for something and "&amp;" was in the value, typing "&" would not find the result. I fixed that by not using htmlentities() before inputing data into the database. IMO, using htmlentities() or htmlspecialchars() before inserting into db is inherently wrong. Making calls to those functions should have negligible impact on the application - there are other ways to improve the performance of your application.

My too scents,
~Philip


Martin


You could do htmlentities() at the search string...

--- End Message ---
--- Begin Message ---
Parham Doustdar wrote:
> Hi there,
> I am writing a PHP FTP client for my project. I want to put a "download" 
> option and an "upload"" option, but I don't know how. My problem is this:
> How can I make the server the PHP script is on delete the file after 
> uploading it to the SFTP, or after the user has finished downloading it from 
> the server the PHP script is on?
> Let me put the question this way.
> My server connects to an FTP. Then, it downloads a file from the FTP, and 
> then sends me the link to that temperary file on the server. Now, when I 
> download it from my server, my script should delete the file. How can I make 
> it wait until the download of the file is finished?
> Same goes for uploading.
> Thanks!
> 

Well if you write a download script, then you can delete it at the end
and it won't be deleted until after the download completes:

//Do your ftp from remote to local'/path/to/file.ext'
exec('ftp_get.sh remotefile.ext /path/to/file.ext);
//or
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_gett($conn_id, '/path/to/file.ext', $server_file, FTP_BINARY)
ftp_close($conn_id);

<?php
//send proper headers for download
readfile('/path/to/file.ext');

unlink('/path/to/file.ext');
?>

For upload, depending upon how you're doing it, a call to unlink()
shouldn't execute until your FTP is done and exited:

<?php
//User uploads file to '/path/to/file.ext'

exec('ftp_put.sh /path/to/file.ext);
//or
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_put($conn_id, $server_file, '/path/to/file.ext', FTP_BINARY)
ftp_close($conn_id);

unlink('/path/to/file.ext');
?>

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Hello,
i am trying to get session_mysql

http://websupport.sk/~stanojr/projects/session_mysql/

It configured, compiled and installed ok (no errors anyways)

but i am getting an error
session_start() [<a
href='function.session-start'>function.session-start</a>]: Cannot find
save handler mysql in

I was hoping someone in the group was using this and has seen the error

Thanks
Randy

--- End Message ---
--- Begin Message ---
Randy Paries wrote:
Hello,
i am trying to get session_mysql

http://websupport.sk/~stanojr/projects/session_mysql/

It configured, compiled and installed ok (no errors anyways)

but i am getting an error
session_start() [<a
href='function.session-start'>function.session-start</a>]: Cannot find
save handler mysql in

I was hoping someone in the group was using this and has seen the error

Thanks
Randy


Not sure about your problem but you shouldn't need to use a compiled module to use MySQL (or any other database) for sessions.

There are several tutorials on the web, not of which involve compiling squat.
--- End Message ---
--- Begin Message ---
I'm making an upload script with PHP, is there a way I can show a
progressbar while uploading?

-- 
Teun Lassche
Bill Cosby <http://www.brainyquote.com/quotes/authors/b/bill_cosby.html>  -
"A word to the wise ain't necessary - it's the stupid ones that need the
advice."

--- End Message ---
--- Begin Message ---
have you looked at http://postlet.com/ ?

tom_a_sparks

Please avoid sending me Word or PowerPoint attachments.
but instead use OpenDocument File Formats or 
use OpenOffice
http://en.wikipedia.org/wiki/OpenDocument
http://en.wikipedia.org/wiki/OpenOffice.org
http://www.gnu.org/philosophy/no-word-attachments.html


--- On Wed, 24/6/09, Teun Lassche <teun.lass...@gmail.com> wrote:

> From: Teun Lassche <teun.lass...@gmail.com>
> Subject: [PHP] Progressbar
> To: php-gene...@lists.php.net
> Received: Wednesday, 24 June, 2009, 3:55 PM
> I'm making an upload script with PHP,
> is there a way I can show a
> progressbar while uploading?
> 
> -- 
> Teun Lassche
> Bill Cosby <http://www.brainyquote.com/quotes/authors/b/bill_cosby.html> 
> -
> "A word to the wise ain't necessary - it's the stupid ones
> that need the
> advice."
> 


      Access Yahoo!7 Mail on your mobile. Anytime. Anywhere.
Show me how: http://au.mobile.yahoo.com/mail

--- End Message ---
--- Begin Message ---
You can use either perl uploading with ajax or flash uploader.

For the perl - google 'uber uploader'
For the flash - google 'flash uploader site:de' and get into the first it
should pop up something with fancy I think..

Good luck mate!

On Wed, Jun 24, 2009 at 8:20 AM, Tom Sparks <tom_a_spa...@yahoo.com.au>wrote:

>
> have you looked at http://postlet.com/ ?
>
> tom_a_sparks
>
> Please avoid sending me Word or PowerPoint attachments.
> but instead use OpenDocument File Formats or
> use OpenOffice
> http://en.wikipedia.org/wiki/OpenDocument
> http://en.wikipedia.org/wiki/OpenOffice.org
> http://www.gnu.org/philosophy/no-word-attachments.html
>
>
> --- On Wed, 24/6/09, Teun Lassche <teun.lass...@gmail.com> wrote:
>
> > From: Teun Lassche <teun.lass...@gmail.com>
> > Subject: [PHP] Progressbar
> > To: php-gene...@lists.php.net
> > Received: Wednesday, 24 June, 2009, 3:55 PM
> > I'm making an upload script with PHP,
> > is there a way I can show a
> > progressbar while uploading?
> >
> > --
> > Teun Lassche
> > Bill Cosby <http://www.brainyquote.com/quotes/authors/b/bill_cosby.html
> >
> > -
> > "A word to the wise ain't necessary - it's the stupid ones
> > that need the
> > advice."
> >
>
>
>       Access Yahoo!7 Mail on your mobile. Anytime. Anywhere.
> Show me how: http://au.mobile.yahoo.com/mail
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---

Reply via email to