Draft Link •
Draft Article
Draft link code:
Draft article code:
exit;
}
$url = substring_before(normalize_space($_GET['u']), ' ');
$title = normalize_space($_GET['t']);
$selection = trim($_GET['s']);
$is_link = isset($_GET['is-link']) && intval($_GET['is-link']);
$slug = trim(preg_replace('/[^a-z0-9-]+/ms', '-', strtolower(summarize($title, 60))), '-');
if (! $slug) $slug = 'draft';
if ($selection) {
$body = "> " . str_replace("\n", "\n> ", trim($selection)) . "\n\n";
if (! $is_link) $body = "[$title]($url):\n\n" . $body;
} else {
$body = '';
}
$draft_contents =
$title . "\n" .
str_repeat('=', max(10, min(40, strlen($title)))) . "\n" .
($is_link ? "Link: " . $url . "\n" : '') .
"publish-not-yet\n" .
"\n" .
$body
;
$output_path = Updater::$source_path . '/drafts';
if (! file_exists($output_path)) die("Drafts path doesn't exist: [$output_path]");
if (! is_writable($output_path)) die("Drafts path isn't writable: [$output_path]");
$output_filename = $output_path . '/' . $slug . Updater::$post_extension;
if (! file_put_contents($output_filename, $draft_contents)) die('File write failed');
if (! chmod($output_filename, 0666)) die('File permission-set failed');
// header('Content-Type: text/plain; charset=utf-8');
// echo "Saving to [$output_filename]:\n-----------------------\n$draft_contents\n------------------------\n";
?>
Saved draft
Saved.
redirecting back...