Skip to content

Commit 46c8f25

Browse files
committed
File locking on write by default.
1 parent a24212a commit 46c8f25

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

index.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function trafic_limiter_canPass($ip)
2424
$tfilename='./data/trafic_limiter.php';
2525
if (!is_file($tfilename))
2626
{
27-
file_put_contents($tfilename,"<?php\n\$GLOBALS['trafic_limiter']=array();\n?>");
27+
file_put_contents($tfilename,"<?php\n\$GLOBALS['trafic_limiter']=array();\n?>", LOCK_EX);
2828
chmod($tfilename,0705);
2929
}
3030
require $tfilename;
@@ -140,7 +140,7 @@ function deletePaste($pasteid)
140140
if (!is_dir('data'))
141141
{
142142
mkdir('data',0705);
143-
file_put_contents('data/.htaccess',"Allow from none\nDeny from all\n");
143+
file_put_contents('data/.htaccess',"Allow from none\nDeny from all\n", LOCK_EX);
144144
}
145145

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

269-
file_put_contents($discdir.$filename,json_encode($storage));
269+
file_put_contents($discdir.$filename,json_encode($storage), LOCK_EX);
270270
echo json_encode(array('status'=>0,'id'=>$dataid)); // 0 = no error
271271
exit;
272272
}
@@ -280,7 +280,7 @@ function deletePaste($pasteid)
280280
exit;
281281
}
282282
// New paste
283-
file_put_contents($storagedir.$dataid,json_encode($storage));
283+
file_put_contents($storagedir.$dataid,json_encode($storage), LOCK_EX);
284284

285285
// Generate the "delete" token.
286286
// The token is the hmac of the pasteid signed with the server salt.

lib/serversalt.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function getServerSalt()
2727
{
2828
$saltfile = 'data/salt.php';
2929
if (!is_file($saltfile))
30-
file_put_contents($saltfile,'<?php /* |'.generateRandomSalt().'| */ ?>');
30+
file_put_contents($saltfile,'<?php /* |'.generateRandomSalt().'| */ ?>',LOCK_EX);
3131
$items=explode('|',file_get_contents($saltfile));
3232
return $items[1];
3333

0 commit comments

Comments
 (0)