Php

- !

Php-web- > Php

:
, (, , email), ( , "file_base.dat".). , email. . " " ( php ) , , "" . , , , html. file_base.dat , ( - @file), - , ( - @fopen). :

<?

// -
$f = @file ("file_base.dat", "r"); // 2
//
// -
$fp = @fopen ("file_base.dat", "w"); // 1
// -
// file_base.dat - $f
//
// -
@fclose ($fp);

?>

, file_base.dat, , $f, $f ( , file_base.dat ) . , file_base.dat . , , "" , file_base.dat , , , , file_base.dat . , , file_base.dat . , Php @flock, .

<?

// -
$f = @file ("file_base.dat", "r"); // 2
//
// -
$fp = @fopen ("file_base.dat", "w"); // 1
// -
@flock ($fp, LOCK_EX)
// -
// file_base.dat - $f
//
//
@flock ($fp, LOCK_UN)
// -
@fclose ($fp);

?>

, , , - . , , , 1 file_base.dat , @flock, 2 , , @file? 2 , file_base.dat 1 @flock . 2 "" file_base.dat , $f . , - , . , file_base.dat email. , file_base.dat .
, : read_file

function read_file($path)
{
if(!is_file($path)) {return false; }
elseif(!filesize($path)) {return array(); }
elseif($array=file($path)) {return $array; }
else { while(!$array=file($path)){sleep(1);} return $array; }
}

: , , , , , "" , "" , , . :

<?
function read_file($path)
{
if(!is_file($path)) {return false; }
elseif(!filesize($path)) {return array(); }
elseif($array=file($path)) {return $array; }
else { while(!$array=file($path)){sleep(1);} return $array; }
}

// ,
// , ,
// , ,
// -
$f = read_file ("file_base.dat", "r"); // 2
//
// -
$fp = @fopen ("file_base.dat", "w"); // 1
// -
@flock ($fp, LOCK_EX)
// -
// file_base.dat - $f
//
//
@flock ($fp, LOCK_UN)
// -
@fclose ($fp);

?>

. 1 file_base.dat, 2 "" , file_base.dat, file_base.dat , . , "". 2 1 "" "" , file_base.dat, , , , , 1 "" @flock ($fp, LOCK_EX), , $fp file_base.dat, , , file_base.dat . , file_base.dat + . , , file_base.dat .

, :
, , , . , - , , , , . , , , . 

, . , lock. basedir, lock basedir. , file_base.dat, , https://_.ru/basedir/file_base.dat, https://_.ru/lock/basedir/ - file_base.dat.tmp, - https://_.ru/lock/basedir/file_base.dat.tmp, file_base.dat, -,   file_base.dat.tmp , file_base.dat.

<?
//
$Lock_dir = "lock";
//
function touchString($file) {
global $Lock_dir;
$tmp = "$Lock_dir/".$file.".tmp";
while(1) {
if (is_file($tmp))
{
while(file_exists($tmp))
{
$file_exist++;
if($file_exist > 10){break;}
clearstatcache();
sleep(1);
}
}
return touch($tmp);
}
}
//
function delString($file) {
global $Lock_dir;
$tmp = "$Lock_dir/".$file.".tmp";
return unlink($tmp);
}
// @file
function FileArray($file) {
if (!is_readable($file)) return FALSE;
touchString($file);
$bufer = file($file);
delString($file);
return $bufer;
}
// @fopen
function OpenFile($file, $mode) {
touchString($file);
return fopen($file, $mode);
}
// @fclose
function CloseFile($fido, $file) {
$sito = fclose($fido);
delString($file);
return $sito;
}

// ,
// -, ,
// ,
// , ,
// , -,
// -, ,
//
$f = FileArray ("basedir/file_base.dat"); // 2
//
// ,
// -, ,
// ,
// , ,
// , -,
// - , ,
//
$fp = OpenFile ("basedir/file_base.dat", "w"); // 1
// -
// basedir/file_base.dat - $f
//
// -, ,
//
CloseFile ($fp, "basedir/file_base.dat");
// , CloseFile : $fp
// basedir/file_base.dat

?>

, file_base.dat , , file_base.dat , . , , , file_base.dat.tmp, file_base.dat.

"", , , - ( ), Lock, "", , - . -, , , "" 10 ($file_exist++; if($file_exist > 10){break;}), 10 . , , . , , , , , 10 . , 0,5 , 1800 . , 900 , 21600 . , MySql .

Lock file_base.dat.tmp, , : https://_.ru/lock/basedir/file_base.dat.tmp, , https://_.ru/basedir/file_base.dat, , , , "" , file_base.dat.tmp () .

:
1. FileArray , @file
2. OpenFile , @fopen
3. CloseFile , @fclose




https://omsk-777.ru/



, , ( , + ). !

: www.wr-script.ru, 2004-2024.

. WR-Script.ru!

WEB-

WR-Счётчик