register_callback('smd_short_url', 'pretext'); function smd_short_url($atts, $thing=NULL) { $urlparts = parse_url(hu); // Probably better regexes for this using [\d] etc $re = '#^'.$urlparts['path'].'([0-9].*)#'; $have_id = preg_match($re, $_SERVER['REQUEST_URI'], $m); if ($have_id) { $id = $m[1]; $permlink = permlinkurl_id($id); if ($permlink) { ob_end_clean(); header("HTTP/1.0 302 Moved Temporarily"); header("Location: $permlink"); die(); } } } function smd_canonical($atts, $thing='') { global $pretext; extract(lAtts(array( 'type' => 'link', ), $atts)); assert_article(); $link = hu.$pretext['id']; $out = ''; if ($type=="link") { $out = ''; } else { $out = $link; } return $out; }