function unlock($user) { // Expire existing locks: $file = $GLOBALS['pie']['run_path'] . '/lock'; if (!is_dir($file)) { return false; } if (!is_writable($file)) { return false; } if ($GLOBALS['pie']['edit_timeout']) { pieExpireDirectory($file, $GLOBALS['pie']['edit_timeout']); } // Remove lock file, if owner matches: $file = "{$file}/" . pieEncodeName($this->name); if (file_exists($file)) { list($current) = file($file); if (trim($current) != $user) { return false; } return unlink($file); } return false; }
if ($_REQUEST['stamp'] < 1) { $_REQUEST['stamp'] = 0; } $page = new Page(); $page->name = $_REQUEST['page']; $preview = pieTempName("_preview"); // Check validity. if (!$page->isValidName($page->name)) { pieError("PageNameInvalid"); } if (!$page->lock($GLOBALS['pie']['user'])) { pieError("PageLockError"); } // Prepare editing environment. if ($GLOBALS['pie']['edit_timeout']) { pieExpireDirectory($GLOBALS['pie']['run_path'] . "/temp", $GLOBALS['pie']['edit_timeout']); } $_REQUEST['cols'] = 80; $_REQUEST['rows'] = 20; $_REQUEST['author'] = $GLOBALS['pie']['user']; $pref = new UserPref(); if (($t = $pref->read($GLOBALS['pie']['user'], "cols")) !== false) { $_REQUEST['cols'] = $t; } if (($t = $pref->read($GLOBALS['pie']['user'], "rows")) !== false) { $_REQUEST['rows'] = $t; } // Determine the source of the source (so to speak). if ($_POST['source']) { // User provided input via HTTP request. $_REQUEST['source'] = pieCleanString($_REQUEST['source']);