Skip to content

Instantly share code, notes, and snippets.

@1999
Created March 15, 2010 21:27
Show Gist options
  • Save 1999/333352 to your computer and use it in GitHub Desktop.
Save 1999/333352 to your computer and use it in GitHub Desktop.
<?php
$joinedURI = implode( '/', $url );
$pageObj = getValueFromRegistry( '__database' )->select()
->from( 'pages' )
->columns( '*' )
->where( 'LEFT( ?, LENGTH( uri ) ) = uri', $joinedURI )
->where( 'visible = 1' )
->orderBy( array( 'LENGTH( uri ) DESC' ) )
->limit( 1 )
->getObj();
if ( $pageObj->num_rows == 0 )
displayErrorPage( 404 );
# получаем страницу
$pageObj->bind_result( $page['id'], $page['parent_id'], $page['position'], $page['url'], $page['uri'], $page['name'], $page['announce'], $page['content'], $page['module'], $page['title'], $page['description'], $page['keywords'], $page['visible'] );
$pageObj->fetch();
# в случае, если полученная страница не является модулем, нужно проверить полное совпадение
# URL-адреса и полного адреса полученной страницы
if ( true === empty( $page['module'] ) ) {
if ( $joinedURI != $page['uri'] ) {
displayErrorPage( 404 );
}
} else {
$explodedCurl = ( true === empty( $page['uri'] ) )
? array() :
explode( '/', $page['uri'] );
if ( $explodedCurl != array_slice( $url, 0, count( $explodedCurl ) ) )
displayErrorPage( 404 );
}
return $page;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment