initializing git repo
This commit is contained in:
commit
3df8fc53b8
86 changed files with 5649 additions and 0 deletions
65
includes/lock.php
Executable file
65
includes/lock.php
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
function LockIsActive($Table,$Id)
|
||||
{
|
||||
$Ret=1;
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalLockAutoReleaseTime;
|
||||
|
||||
$LockQuery="SELECT `LockId`, `LockTime` FROM `$Table` WHERE `Id` = $Id";
|
||||
$LockQuery=mysqli_query($GlobalMysqlHandler, $LockQuery);
|
||||
|
||||
if ($LockQuery)
|
||||
{
|
||||
if (mysqli_num_rows($LockQuery))
|
||||
{
|
||||
$Lock = mysqli_fetch_array($LockQuery);
|
||||
if (!$Lock['LockId']
|
||||
|| ($Lock['LockId']==UserGetId())
|
||||
|| ($Lock['LockTime']<(time()-$GlobalLockAutoReleaseTime))
|
||||
)
|
||||
{ $Ret=0; }
|
||||
}
|
||||
else
|
||||
{ $Ret=0; }
|
||||
}
|
||||
else
|
||||
{ ErrorLog("[lock.php] Can not fetch lock fields in table \"$Table\" at id $Id"); }
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
function LockActivate($Table,$Id)
|
||||
{
|
||||
$Ret=0;
|
||||
global $GlobalMysqlHandler;
|
||||
|
||||
if (!LockIsActive($Table,$Id))
|
||||
{
|
||||
$LockQuery="UPDATE `$Table` SET `LockId` = '".UserGetId()."', `LockTime` = '".time()."' WHERE `Id` =$Id";
|
||||
if (mysqli_query($GlobalMysqlHandler, $LockQuery))
|
||||
{ $Ret=1; }
|
||||
else
|
||||
{ ErrorLog("[lock.php] Can not update lock fields in table \"$Table\" at id $Id"); }
|
||||
}
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
function LockRelease($Table,$Id)
|
||||
{
|
||||
$Ret=0;
|
||||
global $GlobalMysqlHandler;
|
||||
|
||||
if (!LockIsActive($Table,$Id))
|
||||
{
|
||||
$LockQuery="UPDATE `$Table` SET `LockId` = '0', `LockTime` = '0' WHERE `Id` =$Id";
|
||||
if (mysqli_query($GlobalMysqlHandler, $LockQuery))
|
||||
{ $Ret=1; }
|
||||
else
|
||||
{ ErrorLog("[lock.php] Can not update lock fields in table \"$Table\" at id $Id"); }
|
||||
}
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue