All pastes #423679 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-04 10:46 UTC
rendered paste body
damn smarty encoding, this is at the top of the detail tpl

<?php

function urlizeName($name) {literal}{{/literal}
        return preg_replace('/[^A-Za-z0-9_\-\.]/', '', str_replace(Array(' ','&'),Array('_','_and_'),trim(html_entity_decode($name)) ));
{literal}}{/literal}

function redirect(){literal}{{/literal}    
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: /{$category.cat_full_path}{$category.cat_path}/{$site.id}/{$site.url_name}/');
    die();
{literal}}{/literal}

$uri = $_SERVER['REQUEST_URI'];
$uri = rtrim($uri, "/");
$uri = explode('/', $uri);

if ( count($uri) > 1){literal}{{/literal}
    $name = $uri[count($uri) - 1];
    $id = intval($uri[count($uri) - 2]);
{literal}}{/literal}else{literal}{{/literal}
    redirect();
{literal}}{/literal}


if (($id == {$site.id}) && ($name == urlizeName('{$site.site_name|escape:'quote'}')))
{literal}{{/literal}
{literal}}{/literal}
else
{literal}{{/literal}
    redirect();    
{literal}}{/literal}
?>