Portrety Uliczne Nieznajomych - zobacz wyjątkową galerię portretów z warszawskich ulic
ZALOGUJ SIĘ
login:
hasło:
przypomnij hasło
załóż konto użytkownika
(i zobacz kilka porad gratis)
   
WYSZUKIWARKA I DZIAŁY
całe porady  tytuły
zaznacz działy do przeszukania
(brak wyboru = wszystkie działy)
PHP
MySQL >
PostgreSQL
SQLite
Perl
Java
XML
XSLT
XPath
WML
SVG
RegExp
Wyszukiwarki
Ochrona
VBScript
Google Plus
XHTML/CSS
JavaScript
Grafika
Flash
Photoshop
Windows
Linux
Bash
Apache
Procmail
E-biznes
Explorer
Opera
Firefox
Inne porady
   
KURSY, DOKUMENTACJE
Własne:
XHTML/CSS
JavaScript
ActionScript
WML, RSS, SSI
Pozostałe:
PHP
MySQL
Java API
więcej...
   
użytkowników online: 65
W CZYM MOGĘ POMÓC?


   
OPINIE UŻYTKOWNIKÓW
Nie jestem webmasterem, ale i na mnie zrobiła wrażenie szybkość reakcji Darka na mój problem. Jego kompetencja i przede wszystkim zupełnie niemodna w dzisiejszych skomercjalizowanych czasach - zwykła ludzka życzliwość dla innego człowieka. Tacy ludzie to dziś gatunek niemal wymarły...

Leszek
Wojskowy Instytut Medyczny

   
GALERIA FOTOGRAFII
   
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net

[Spis] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [X] [W] [Z]

touch

(PHP 3, PHP 4, PHP 5)

touch -- Ustawia czas modyfikacji pliku

Opis

bool touch ( string nazwa_pliku [, int czas [, int dczas]] )

Próbuje ustawić czas dostępu i modyfikacji pliku o nazwie nazwa_pliku na wartość podaną przez czas. Jeśli parametr czas nie został podany, używa czasu bieżącego. To jest odpowiednik działania utime (czasami odwołujemy się do utime). Jeśli trzeci parametr dczas jest dostępny, czas dostępu do podanego pliku jest ustawiany na wartość dczas. Zauważ, że czas dostępu jest zawsze modyfikowany, niezależnie od ilości parametrów.

Jeśli plik nie istnieje, to zostanie utworzony. Zwraca TRUE w przypadku sukcesu, FALSE w przypadku porażki.

Przykład 1. touch() przykład

<?php
if (touch($FileName)) {
   echo
"$FileName czas modyfikacji został zmieniony na bieżący czas";
} else {
   echo
"Przykro mi ale Nie Mogę zmienić czasu modyfikacji pliku $FileName";
}
?>




User Contributed Notes

spam at webmastersguide dot com
01-Sep-2005 02:09

If you're going to go around deleting (unlinking) files
that you don't own just in order to change the modification
time on the file, you darn well better chown() the file
back to it's original ownership after you are done and
chmod() it back to it's correct permissions.  Otherwise
you will almost certainly break things.  Additionally the
code listed for touch()ing a file you don't own should
set the file creation time back to it's original time if
what is wanted is to just change the modification time.
Also, the code listed will break things if there is an i/o
error such as disk full or too many files in the directory.
Here's how the code SHOULD be written:

Create the new file FIRST, rather than last, with a different
name such as $file.tmp.
Read the ownership, permissions, and creation time of the old file.
Set permissions and creation time of the new file the same as the old.
Rename the new file to the name of the old.
chown() the new file to the user that owned the file it's replacing.

Please be careful adding to the documentation if you've
never taken programming 101.


rf_public at yahoo dot co dot uk
25-Jul-2005 09:19

Note: the script to touch a file you don't own will change it's owner so ensure permissions are correct or you could lose access to it


guy at forster design dot com
12-May-2005 12:42

Here's a little workaround that allows the PHP user to touch a file it doesn't own:

<?php

   $target_file
= "/path/to/file/filename.txt"; //system filepath to your file
  
$file_content = implode("",file($target_file));
   @
unlink($target_file);
   if(
$savetofile = fopen($target_file, "w")) {
      
fputs($savetofile, $file_content);
      
fclose($savetofile);
   }
  
$new_date = strtotime("23 April 2005"); // set the required date timestamp here
  
touch($target_file,$new_date);
 
?>

Of course, PHP needs to have write access to the folder containing the file you want to touch, but that should be easy to arrange.


feathern at yahoo dot com
14-Aug-2002 12:31

Neat little script that will give you a list of all modified files in a certain folder after a certain date:

$filelist = Array();
$filelist = list_dir("d:\\my_folder");
for($i=0;$i<count($filelist);$i++){
   $test = Array();
   $test = explode("/",date("m/d/Y",filemtime($filelist[$i])));
//example of files that are later then
//06/17/2002
   if(($test[2] > 2001) && ($test[1] > 16) && ($test[0] > 5)){
       echo $filelist[$i]."\r\n";
   }
   clearstatcache();
}
function list_dir($dn){
   if($dn[strlen($dn)-1] != '\\') $dn.='\\';
   static $ra = array();
   $handle = opendir($dn);
   while($fn = readdir($handle)){
       if($fn == '.' || $fn == '..') continue;
       if(is_dir($dn.$fn)) list_dir($dn.$fn.'\\');
       else $ra[] = $dn.$fn;
   }
   closedir($handle);
   return $ra;
}


emilebosch at hotmail dot com
07-Oct-2001 12:41

To spare you ppl couple of hours of valuable time, you can only TOUCH a file that you own! Usually PHP is *nobody*
Warm regards,
Emile Bosch


master at dreamphp dot com
15-May-2001 08:23

$filename = "test.dat";
if (!file_exists($filename)) {
  touch($filename); // Create blank file
  chmod($filename,0666);
}


 

 
  © 1996-2012 & Reporter.plmiejscao serwisieabonamentwarunki korzystaniaRSSkontakt