Skip to content

Commit

Permalink
File locking on write by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebsauvage committed Feb 6, 2014
1 parent a24212a commit 46c8f25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function trafic_limiter_canPass($ip)
$tfilename='./data/trafic_limiter.php';
if (!is_file($tfilename))
{
file_put_contents($tfilename,"<?php\n\$GLOBALS['trafic_limiter']=array();\n?>");
file_put_contents($tfilename,"<?php\n\$GLOBALS['trafic_limiter']=array();\n?>", LOCK_EX);
chmod($tfilename,0705);
}
require $tfilename;
Expand Down Expand Up @@ -140,7 +140,7 @@ function deletePaste($pasteid)
if (!is_dir('data'))
{
mkdir('data',0705);
file_put_contents('data/.htaccess',"Allow from none\nDeny from all\n");
file_put_contents('data/.htaccess',"Allow from none\nDeny from all\n", LOCK_EX);
}

// Make sure last paste from the IP address was more than 10 seconds ago.
Expand Down Expand Up @@ -266,7 +266,7 @@ function deletePaste($pasteid)
exit;
}

file_put_contents($discdir.$filename,json_encode($storage));
file_put_contents($discdir.$filename,json_encode($storage), LOCK_EX);
echo json_encode(array('status'=>0,'id'=>$dataid)); // 0 = no error
exit;
}
Expand All @@ -280,7 +280,7 @@ function deletePaste($pasteid)
exit;
}
// New paste
file_put_contents($storagedir.$dataid,json_encode($storage));
file_put_contents($storagedir.$dataid,json_encode($storage), LOCK_EX);

// Generate the "delete" token.
// The token is the hmac of the pasteid signed with the server salt.
Expand Down
2 changes: 1 addition & 1 deletion lib/serversalt.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function getServerSalt()
{
$saltfile = 'data/salt.php';
if (!is_file($saltfile))
file_put_contents($saltfile,'<?php /* |'.generateRandomSalt().'| */ ?>');
file_put_contents($saltfile,'<?php /* |'.generateRandomSalt().'| */ ?>',LOCK_EX);
$items=explode('|',file_get_contents($saltfile));
return $items[1];

Expand Down

0 comments on commit 46c8f25

Please sign in to comment.