storage_path = $path; } public function setContent($content, $language, $nick, $description) { global $config; if (!is_subclass_of($config['id_generator'], 'IdGeneratorEngine')) { header('HTTP/1.0 503 Service Unavailable'); die('Invalid config'); } do { $filename = $config['id_generator']->generateId(); } while (file_exists($this->storage_path . '/' . $filename)); if ($config['short_results_path']) { $urlbase = $config['short_results_path']; } else { $urlbase = $config['site_domain'] . $config['site_path'] . $this->storage_path; } $filename = $filename . ".html"; $get_url = $config['site_domain'] . $config['site_path'] . 'get.php?p=' . $filename; $remove_url = $config['site_domain'] . $config['site_path'] . 'remove.php?p=' . $filename . '&t=' . $this->generateToken($filename); $content = PastifyText($content, $language, $description, $get_url, $remove_url); // write content $outfile = $this->storage_path . $filename; $fp = fopen($outfile, "w"); fwrite($fp, $content); fclose($fp); return $get_url; } public function getContent($pid) { global $config; if ($config['short_results_path']) { $urlbase = $config['short_results_path']; } else { $urlbase = $config['site_domain'] . $config['site_path'] . $this->storage_path; } header('Location: ' . $urlbase . $pid); exit; } public function delContent($pid) { $filename = realpath($this->storage_path . $pid); if (!empty($filename) && file_exists($filename)) { if (!@unlink($filename)) { header('HTTP/1.0 503 Service Unavailable'); die('Failed to remove ' . $filename); } } } } ?>