function make_redir($params) { unset($params["make_redir"]); unset($params["do_redir"]); $qstring = arr2qstring($params); $domain = $_SERVER['SERVER_NAME']; $script = $_SERVER['SCRIPT_NAME']; $url = "http://{$domain}{$script}?{$qstring}"; # Create tiny URLs for the permalinks $query = "SELECT permalink_id FROM permalinks WHERE permalink = '{$url}'"; $id = select_scalar($query); if (is_null($id)) { $query = "SELECT nextval('permalinks_permalink_id_seq')"; $id = select_scalar($query); $insert = "INSERT INTO " . "permalinks (permalink_id, permalink) " . "VALUES ('{$id}', '{$url}');"; do_pg_query($insert); } $tinyurl = "http://{$domain}{$script}?do_redir={$id}"; # Print tiny link in a tiny window $t = 50; print "<html>\n" . display_header("Tiny link") . "<body>\n<div align=center>\n<p>The original permalink was " . strlen($url) . " chars long.\nHere's a tiny link that is only {$t} chars long:</p>\n\n<p><form name=url_form><code>\n<input type=text name=url value='{$tinyurl}' size={$t}\n onFocus=\"this.value='{$tinyurl}';\" readonly>\n</code>\n</form></p>\n\n<script language='javascript' type='text/javascript'>\ndocument.url_form.url.focus();\ndocument.url_form.url.select();\n</script>\n\n<p><form>\n<input type=button value='Close this window' onClick='javascript:window.close();'>\n</form></p>\n\n</div>\n</body>\n</html>"; exit; }
function link_to_screen($type) { $self = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; $params = $_GET; $params['screen'] = $type; unset($params['go']); $qstring = arr2qstring($params); $ret = "<a href='{$self}?{$qstring}' class='lgray_ln'>[{$type} Mode]</a>"; return $ret; }