mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 15:47:00 +02:00
Refactor working with a locked file
This commit is contained in:
@@ -799,15 +799,15 @@ function get_temp_dir() {
|
|||||||
* @return resource or null for error
|
* @return resource or null for error
|
||||||
*/
|
*/
|
||||||
function file_open_lock($filename) {
|
function file_open_lock($filename) {
|
||||||
$fp = @fopen($filename, "r+"); // @ - may not exist
|
$fp = @fopen($filename, "c+"); // @ - may not be writable
|
||||||
if (!$fp) { // c+ is available since PHP 5.2.6
|
if (!$fp) {
|
||||||
$fp = @fopen($filename, "w"); // @ - may not be writable
|
return;
|
||||||
if (!$fp) {
|
}
|
||||||
return;
|
chmod($filename, 0660);
|
||||||
}
|
if (!flock($fp, LOCK_EX)) {
|
||||||
chmod($filename, 0660);
|
fclose($fp);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
flock($fp, LOCK_EX);
|
|
||||||
return $fp;
|
return $fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user