Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Test touch() function : basic functionality --CREDITS-- Dave Kelsey <d_kelsey@uk...

Decoded Output download

--TEST--
Test touch() function : basic functionality
--CREDITS--
Dave Kelsey <[email protected]>
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) != 'WIN') {
    die('skip.. only for Windows');
}
?>
--FILE--
<?php
echo "*** Testing touch() : basic functionality ***
";

$filename = __DIR__."/touch.dat";

echo "
--- testing touch creates a file ---
";
@unlink($filename);
if (file_exists($filename)) {
   die("touch_basic failed");
}
var_dump( touch($filename) );
if (file_exists($filename) == false) {
   die("touch_basic failed");
}

echo "
 --- testing touch doesn't alter file contents ---
";
$testln = "Here is a test line";
$h = fopen($filename, "wb");
fwrite($h, $testln);
fclose($h);
touch($filename);
$h = fopen($filename, "rb");
echo fgets($h);
fclose($h);

echo "

 --- testing touch alters the correct file metadata ---
";
$init_meta = stat($filename);
clearstatcache();
sleep(1);
touch($filename);
$next_meta = stat($filename);
$type = array("dev", "ino", "mode", "nlink", "uid", "gid",
              "rdev", "size", "atime", "mtime", "ctime",
              "blksize", "blocks");

for ($i = 0; $i < count($type); $i++) {
   if ($init_meta[$i] != $next_meta[$i]) {
      echo "stat data differs at $type[$i]
";
   }
}


// Initialise all required variables
$time = 10000;
$atime = 20470;

// Calling touch() with all possible arguments
echo "
 --- testing touch using all parameters ---
";
var_dump( touch($filename, $time, $atime) );
clearstatcache();
$init_meta = stat($filename);
echo "ctime=".$init_meta['ctime']."
";
echo "mtime=".$init_meta['mtime']."
";
echo "atime=".$init_meta['atime']."
";

unlink($filename);

echo "Done";
?>
--EXPECTF--
*** Testing touch() : basic functionality ***

--- testing touch creates a file ---
bool(true)

 --- testing touch doesn't alter file contents ---
Here is a test line

 --- testing touch alters the correct file metadata ---
stat data differs at atime
stat data differs at mtime

 --- testing touch using all parameters ---
bool(true)
ctime=%d
mtime=10000
atime=20470
Done

Did this file decode correctly?

Original Code

--TEST--
Test touch() function : basic functionality
--CREDITS--
Dave Kelsey <[email protected]>
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) != 'WIN') {
    die('skip.. only for Windows');
}
?>
--FILE--
<?php
echo "*** Testing touch() : basic functionality ***\n";

$filename = __DIR__."/touch.dat";

echo "\n--- testing touch creates a file ---\n";
@unlink($filename);
if (file_exists($filename)) {
   die("touch_basic failed");
}
var_dump( touch($filename) );
if (file_exists($filename) == false) {
   die("touch_basic failed");
}

echo "\n --- testing touch doesn't alter file contents ---\n";
$testln = "Here is a test line";
$h = fopen($filename, "wb");
fwrite($h, $testln);
fclose($h);
touch($filename);
$h = fopen($filename, "rb");
echo fgets($h);
fclose($h);

echo "\n\n --- testing touch alters the correct file metadata ---\n";
$init_meta = stat($filename);
clearstatcache();
sleep(1);
touch($filename);
$next_meta = stat($filename);
$type = array("dev", "ino", "mode", "nlink", "uid", "gid",
              "rdev", "size", "atime", "mtime", "ctime",
              "blksize", "blocks");

for ($i = 0; $i < count($type); $i++) {
   if ($init_meta[$i] != $next_meta[$i]) {
      echo "stat data differs at $type[$i]\n";
   }
}


// Initialise all required variables
$time = 10000;
$atime = 20470;

// Calling touch() with all possible arguments
echo "\n --- testing touch using all parameters ---\n";
var_dump( touch($filename, $time, $atime) );
clearstatcache();
$init_meta = stat($filename);
echo "ctime=".$init_meta['ctime']."\n";
echo "mtime=".$init_meta['mtime']."\n";
echo "atime=".$init_meta['atime']."\n";

unlink($filename);

echo "Done";
?>
--EXPECTF--
*** Testing touch() : basic functionality ***

--- testing touch creates a file ---
bool(true)

 --- testing touch doesn't alter file contents ---
Here is a test line

 --- testing touch alters the correct file metadata ---
stat data differs at atime
stat data differs at mtime

 --- testing touch using all parameters ---
bool(true)
ctime=%d
mtime=10000
atime=20470
Done

Function Calls

None

Variables

None

Stats

MD5 41fb60399fbe92c535c857fe9b849655
Eval Count 0
Decode Time 79 ms