Raised This Month: $ Target: $400
 0% 

How to check if file is opened or its closed?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
erickvan
Junior Member
Join Date: Dec 2020
Old 12-22-2020 , 05:23   How to check if file is opened or its closed?
Reply With Quote #1

I have auto demo recorder plugin. This plugin have PHP script to move demo to web dir and put into zip.

PHP Code:
<?php
//error_reporting(E_ALL);
//set_time_limit(0);
$path "MIX1/cstrike";
$path2 "/var/www/html/public/";
$to_dirs = array('/demos/');
$from_dirs = array('/demos/');

$filesizes = array();
//первый проход запоминаем размеры
foreach($from_dirs as $from_dir)
    {
    
$demos_dir opendir($path.$from_dir);
    while (
false!==($file=readdir($demos_dir)))
        {
        if (
$file!='.'&&$file!='..'&&strpos($file,'.dem')!==false)
            {
            
$fsize=filesize($path.$from_dir.$file);
            if (
$fsize<50000000)
                {
                
$filesizes[$file]=$fsize;
                }
            else{
    
//            echo "<br/>bad file:",$file, ",  size = ", $fsize;
                
}
            }
        }
    
closedir($demos_dir);
    }
//echo date("h:i:s");
sleep(3);
clearstatcache ();
//второй проход пермещаем 
$i=0;
foreach(
$from_dirs as $from_dir)
    {
    
$to_dir=$from_dirs[$i];
    
$demos_dir opendir($path.$from_dir);
    while (
false!==($file=readdir($demos_dir)))
        {
        if (
$file!='.'&&$file!='..'&&strpos($file,'.dem')!==false)
            {
            
$fsize=0;
            
$fsize=filesize($path.$from_dir.$file);
            if (
$fsize<50000000)
                {
                if (
$fsize==$filesizes[$file])
                    {
                    
//echo "<br>ѕеремещаем файл ",$file," размер не изменилс¤; было ",$filesizes[$file]," стало, ".$fsize,";";
                    
move_demo($file$from_dir$to_dir);
                    }
                else
                    {
                    
//echo "<br>","размер изменилс¤ у файла ", $file;
                    
}
                }
            else
                {
                
//echo "<br/>bad file:",$file, ",  size = ", $fsize;
                
}
            }
        }
    
$i++;
    
closedir($demos_dir);
    }

function 
move_demo($filename$from_dir$to_dir)
{
//echo $filename,"from ",$from_dir," to ",$to_dir,"<br>";
global $path$path2;
if (
file_exists($path2.$to_dir.$filename.".zip"))
    
unlink($path2.$to_dir.$filename.".zip");
echo 
"$path$from_dir$filename\n";
echo 
"$path2$to_dir$filename\n\n";
$data file_get_contents($path.$from_dir.$filename);
$gzdata gzencode($data9);
unset(
$data);
$fp fopen($path2.$to_dir.$filename.".zip""xb+");
//$fp = fopen($path.$to_dir.$filename.".zip")
fwrite($fp$gzdata);
unset(
$gzdata);
fclose($fp);
unlink($path.$from_dir.$filename);
}
?>
Does any know how to check if file is opened by HLTV? why i need this? Becouse its allways moving files, that file need to be checked if are closed becouse maybe demo is still recording? Thanks
erickvan is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-22-2020 , 07:23   Re: How to check if file is opened or its closed?
Reply With Quote #2

This section is about AMXX scripting, not PHP. You're better off posting in the off-topic section.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode