File system commands
Markeren
5 berichten - Alles samenvouwen
/groups/adfetch?hl=nl&adid=isOC8REAAACxLeDXaVcwxXcnEYSQZEBenT3luubDeskUok6AUQ17nQ
De groep waarnaar je een bericht verzendt, is een Usenet-groep. Berichten die je in deze groep verzendt, zijn zichtbaar voor iedereen op het Internet
Je antwoord is niet verzonden.
Uw bericht is geplaatst
 
Van:
Aan:
Cc:
Reactie op:
Cc toevoegen | Reactie toevoegen | Onderwerp bewerken
Onderwerp:
Validatie:
Typ ter verificatie de tekens uit de onderstaande afbeelding of de getallen die je hoort wanneer je klikt op het pictogram voor toegankelijkheid. Luister en typ de nummers die je hoort
 
1.  Trevor Barker  
Profiel weergeven   Naar het vertalen Vertaald (origineel weergeven)
 Meer opties 24 sep 2004, 23:53
Nieuwsgroepen: alt.comp.lang.php
Van: "Trevor Barker" <trevor.bark...@ntlworld.com>
Datum: Fri, 24 Sep 2004 21:53:54 GMT
Lokaal: vr 24 sep 2004 23:53
Onderwerp: File system commands
Hi,

I've been trying to work out how to issue file system commands from a PHP
script to Redhat Linux. I want to be able to delete files and directories,
and copy files. I thought that using 'exec', 'system', or 'passthru' would
be the answer but although they don't produce errors (thereby indicating
that they work), the don't actually carry out the command. Can anyone
suggest how I should do it please?

Thanks
Trev


    Auteur beantwoorden    Doorsturen  
Je moet je aanmelden voordat je berichten kunt plaatsen.
Als je een bericht wilt verzenden, moet je eerst deelnemen aan deze discussiegroep.
Werk je bijnaam bij op de pagina met abonnementsinstellingen voordat je een bericht plaatst.
Je hebt geen toestemming om berichten te plaatsen.
2.  Janwillem Borleffs  
Profiel weergeven   Naar het vertalen Vertaald (origineel weergeven)
 Meer opties 25 sep 2004, 01:24
Nieuwsgroepen: alt.comp.lang.php
Van: "Janwillem Borleffs" <j...@jwscripts.com>
Datum: Sat, 25 Sep 2004 01:24:21 +0200
Lokaal: za 25 sep 2004 01:24
Onderwerp: Re: File system commands

Trevor Barker wrote:
> I've been trying to work out how to issue file system commands from a
> PHP script to Redhat Linux. I want to be able to delete files and
> directories, and copy files. I thought that using 'exec', 'system',
> or 'passthru' would be the answer but although they don't produce
> errors (thereby indicating that they work), the don't actually carry
> out the command. Can anyone suggest how I should do it please?

You can only execute file system commands when the files and directories are
either chmod 777 or writeable by Apache.

I'm sure that when you run the following code it will print 1, indicating
that an error occurred (replace somefile with a file that actually present
on your filesystem):

<?
    exec ("cp somefile anotherfile", $output, $result);
    print $result;
?>

Furthermore, it's more efficient to use native PHP functions instead of
passing system commands through the exec/passthru/etc functions.

Per example:

To delete a file, use unlink(); to remove a dir use rmdir(); to copy a file
use copy(). See the manual for more info about these functions.

What you should do is the following:

1. Create a sandbox directory which you chmod to 777
2. Use the suggested functions in this sandbox directory only
3. Start reading the manual (http://nl.php.net/manual/en/ref.filesystem.php)

HTH;
JW


    Auteur beantwoorden    Doorsturen  
Je moet je aanmelden voordat je berichten kunt plaatsen.
Als je een bericht wilt verzenden, moet je eerst deelnemen aan deze discussiegroep.
Werk je bijnaam bij op de pagina met abonnementsinstellingen voordat je een bericht plaatst.
Je hebt geen toestemming om berichten te plaatsen.
3.  Andy Hassall  
Profiel weergeven   Naar het vertalen Vertaald (origineel weergeven)
 Meer opties 25 sep 2004, 01:40
Nieuwsgroepen: alt.comp.lang.php
Van: Andy Hassall <a...@andyh.co.uk>
Datum: Sat, 25 Sep 2004 00:40:04 +0100
Lokaal: za 25 sep 2004 01:40
Onderwerp: Re: File system commands
On Fri, 24 Sep 2004 21:53:54 GMT, "Trevor Barker" <trevor.bark...@ntlworld.com>
wrote:

>I've been trying to work out how to issue file system commands from a PHP
>script to Redhat Linux. I want to be able to delete files and directories,
>and copy files. I thought that using 'exec', 'system', or 'passthru' would
>be the answer but although they don't produce errors (thereby indicating
>that they work), the don't actually carry out the command. Can anyone
>suggest how I should do it please?

 PHP has various PHP-native filesystem functions which are arguably better
choices than spawning shells and opening potential command injection,
performance and portability issues.

 See the Filesystem Functions chapter of the PHP manual for details.

--
Andy Hassall / <a...@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool


    Auteur beantwoorden    Doorsturen  
Je moet je aanmelden voordat je berichten kunt plaatsen.
Als je een bericht wilt verzenden, moet je eerst deelnemen aan deze discussiegroep.
Werk je bijnaam bij op de pagina met abonnementsinstellingen voordat je een bericht plaatst.
Je hebt geen toestemming om berichten te plaatsen.
4.  Steven Stern  
Profiel weergeven   Naar het vertalen Vertaald (origineel weergeven)
 Meer opties 26 sep 2004, 14:41
Nieuwsgroepen: alt.comp.lang.php
Van: Steven Stern <sdsternNOSPAMH...@NOSPAMHEREmindspring.com>
Datum: Sun, 26 Sep 2004 12:41:56 GMT
Lokaal: zo 26 sep 2004 14:41
Onderwerp: Re: File system commands
On Fri, 24 Sep 2004 21:53:54 GMT (more or less), "Trevor Barker"

<trevor.bark...@ntlworld.com> wrote:
>Hi,

>I've been trying to work out how to issue file system commands from a PHP
>script to Redhat Linux. I want to be able to delete files and directories,
>and copy files. I thought that using 'exec', 'system', or 'passthru' would
>be the answer but although they don't produce errors (thereby indicating
>that they work), the don't actually carry out the command. Can anyone
>suggest how I should do it please?

>Thanks
>Trev

Here's a simple script that searches a given directory and deletes files more
than 2 days old.  Look up file functions on php.net.

#! /bin/php
<?php

// calculate two days ago

$now = time();
$old = $now - (60*60*24*2);
echo "<hr>\n\nDelete old report files ",date("Y-m-d H:i:s"),"<br>\n";
echo "Using ", date("Y-m-d H:i:s",$old),"<br>\n";

// make a list of files in tmp

$dir = '/www/htdocs/admin/tmp/';
if ($handle = opendir($dir)) {
   while (false !== ($file = readdir($handle))) {
       if ($file == ".") continue;
       if ($file == "..") continue;
       $fname = $dir.$file;
       if (filemtime($fname) < $old):
          echo "deleting ",$fname,": ",date("Y-m-d
H:i:s",filemtime($fname)),"<br>\n";
        unlink($fname);   ;
          endif;
  }

}

   closedir($handle);
?>

    Auteur beantwoorden    Doorsturen  
Je moet je aanmelden voordat je berichten kunt plaatsen.
Als je een bericht wilt verzenden, moet je eerst deelnemen aan deze discussiegroep.
Werk je bijnaam bij op de pagina met abonnementsinstellingen voordat je een bericht plaatst.
Je hebt geen toestemming om berichten te plaatsen.
5.  Trevor Barker  
Profiel weergeven   Naar het vertalen Vertaald (origineel weergeven)
 Meer opties 26 sep 2004, 23:00
Nieuwsgroepen: alt.comp.lang.php
Van: "Trevor Barker" <trevor.bark...@ntlworld.com>
Datum: Sun, 26 Sep 2004 21:00:04 GMT
Lokaal: zo 26 sep 2004 23:00
Onderwerp: Re: File system commands
Thanks guys, I think ownership is the key to the problem i've been having
but I will look at the internal funnctions too, I didnt realise they were
there.

"Steven Stern" <sdsternNOSPAMH...@NOSPAMHEREmindspring.com> wrote in message

news:o3edl01gj0gpgac2b6b3e6fsu2c6nt518a@4ax.com...


    Auteur beantwoorden    Doorsturen  
Je moet je aanmelden voordat je berichten kunt plaatsen.
Als je een bericht wilt verzenden, moet je eerst deelnemen aan deze discussiegroep.
Werk je bijnaam bij op de pagina met abonnementsinstellingen voordat je een bericht plaatst.
Je hebt geen toestemming om berichten te plaatsen.

Discussiegroep maken - Google Discussiegroepen - Google Startpagina - Servicevoorwaarden - Privacybeleid
©2009 Google