#!/usr/bin/php \n"; exit; } $title = $argv[1]; # Get the date parts and create the permalink require 'init.php'; $var = $smarty->template_dir; $year = date('Y'); check_dir("$var/$year"); $month = date('m'); check_dir("$var/$year/$month"); $day = date('d'); check_dir("$var/$year/$month/$day"); $safe = preg_replace('![^a-z0-9_\-]!', '', preg_replace('!\s+!', '-', trim(strtolower($title)))); $permalink = "/$year/$month/$day/$safe"; # Create files $smarty->assign('smarty_title', "{assign var='title' value=\"$title\"}"); $smarty->assign('title', $title); $smarty->assign('date', date('n/j')); $smarty->assign('permalink', $permalink); ob_start(); $smarty->display("$var/tpl_post.html"); file_put_contents("$var/$year/$month/$day/.$safe.html", ob_get_clean()); # Create directories if they don't exist function check_dir($dir) { if (!is_dir($dir) && !mkdir($dir, 0777)) { echo "[error] Can't create $dir\n"; exit; } } ?>