You can translate to another page if the cls_symstore_V6.out file is not occupied by another process.
I tried to implement it this way:

start: { $cmd = 'cls_symstore_V6.out'; if ($fh = fopen($cmd, 'r+')) { echo "Recording removed!" . "<br /> "; echo "<p><font size='3,5' color='black' face='Times New Roman'> <b> После возврата на предыдущую страницу, выполните обновление страницы. </b></font></p>"; echo "<p><a href='http://mypage/opr/admin/store/index.php'>Вернуться назад</a></p>"; fclose($fh);`введите сюда код` } else { echo "Deleting... Please wait.\n"; goto start; } } 

Here is the following check: if the file can be opened, then an informational message is displayed and a link that returns to the desired page.
If the file cannot be opened, then display the message "Deleting ... Please wait." and goto go back to start and the check is repeated again until the condition is correct and I do not get a link to leave the page.
My way, unfortunately, was not crowned with success.

My working version is through do-while:

 $i = 0; do { if ($fh = fopen("cls_symstore_V6.out", "r+")) { echo "Recording removed!" . "<br /> "; echo "<p><font size='3,5' color='black' face='Times New Roman'> <b> После возврата на предыдущую страницу, выполните обновление страницы. </b></font></p>"; echo "<p><a href='http://mypage/opr/admin/store/index.php'>Вернуться назад</a></p>"; fclose($fh); $i = $i + 1; break; } else { echo "Выполняется удаление. Пожалуйста, подождите...\n"; $string_time_out="\\\\".$server_name."\\".$path_dir_2."\\".$my_log.".out"; // echo $string_time_out; $my->time_out_client($string_time_out,32); echo "Recording removed!" . "<br /> "; echo "<p><font size='3,5' color='black' face='Times New Roman'> <b> После возврата на предыдущую страницу, выполните обновление страницы. </b></font></p>"; echo "<p><a href='http://mypage/opr/admin/store/index.php'>Вернуться назад</a></p>"; $i = $i + 1; break; } } while ($i = 1); 

Thank you all, the question is closed.

  • one
    1. goto will wonderfully replace do {} while(); 2. Why do you bother with file locks? The database is not the right solution? - tutankhamun
  • Alternatively, you can create a temporary file at the beginning of the deletion process, and after it is deleted. And check to make the existence of this particular file: file_exists() . There will be only one problem: if the deletion process fails with an error, the temporary file will live forever. - Alexander Gribennikov
  • @tutankhamun 1. But the expression will be executed even if it is incorrect, if I use do-while. Is not it so? <br> 2. Unfortunately, I do not have enough knowledge to use the database. I can not even imagine how this condition is generally associated with the database. - Yulia
  • @Alexander Gribennikov thanks for the advice, but I’d rather not risk it. Deletion occurs on another server, and there anything can already happen. I, of course, will understand and manually delete the file, but someone may not know about it. - Yulia
  • @tutankhamun I need to use break then, right? Hmm ... only the messages will already be displayed ... - Yulia

1 answer 1

My working version:

 $i = 0; do { if ($fh = fopen("cls_symstore_V6.out", "r+")) { echo "Recording removed!" . "<br /> "; echo "<p><font size='3,5' color='black' face='Times New Roman'> <b> После возврата на предыдущую страницу, выполните обновление страницы. </b></font></p>"; echo "<p><a href='http://mypage/opr/admin/store/index.php'>Вернуться назад</a></p>"; fclose($fh); $i = $i + 1; break; } else { echo "Выполняется удаление. Пожалуйста, подождите...\n"; $string_time_out="\\\\".$server_name."\\".$path_dir_2."\\".$my_log.".out"; // echo $string_time_out; $my->time_out_client($string_time_out,32); echo "Recording removed!" . "<br /> "; echo "<p><font size='3,5' color='black' face='Times New Roman'> <b> После возврата на предыдущую страницу, выполните обновление страницы. </b></font></p>"; echo "<p><a href='http://mypage/opr/admin/store/index.php'>Вернуться назад</a></p>"; $i = $i + 1; break; } } while ($i = 1); 

Thank you all for the advice.