Wedge
Public area => The Pub => Off-topic => Topic started by: MultiformeIngegno on November 19th, 2012, 10:30 PM
-
So, this is a link I have on a page (page1.php):
<a href="page2.php?t=<?php echo md5($_SERVER['REMOTE_ADDR']); ?>">Click here</a>
On page2.php I have something like this:
<?php
if (isset($_GET['t']) && $_GET['t'] == md5($_SERVER['REMOTE_ADDR'])) {
echo 'You\'ve gone through the hoops';
}
else echo 'Please go back to page1';
?>
It works perfectly (displays "You've gone through the hoops" only if users passes through page1). The problem is that instead of that line of text I should display a complex page (mixed php and html): http://pastebin.com/XQdw64hB
How can I insert that page within that if (isset($_GET['t']) && $_GET['t'] ..?
P.S.: don't blame me for $_GET being spoof-able.. informations in page2 aren't state secrets.. no one would be interested in spoofing it! :D
-
/medoesn't understand what you're trying to do.
-
/medoesn't understand what you're trying to do.
Ok :P
I need to protect page2.php so that it's only accessible by the link on page1.php (not directly).
The 2 snippets on the first post work just fine.
The problem is that instead of having the text "You've gone through the hoops" shown if user access page2 from page1 (correct behavior) I need to run this code: http://pastebin.com/XQdw64hB
-
So, with the exception of the <?php ?> bits, copy/paste it into the { } inside the matching if...
I would not suggest messing about with jumping in and out of tags like that shit pile WP does, and instead convert things into echos.
-
You mean this? I thought there was a nicer/faster method..
<?php
if (isset($_GET['t']) && $_GET['t'] == md5($_SERVER['REMOTE_ADDR'])) {
get_header();
echo '
<section id="primary">
<div id="content" role="main">
';
$my_query = new WP_Query( 'page_id=1788' );
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate2[] = $post->ID;
echo '<div class="textwidget" style="color:#707070">
<h3 class="widget-title">';
the_title();
echo '</h3>';
the_content();
echo '</div>';
endwhile;
if ( have_posts() ) :
echo '<header class="page-header" style="display:none">
<h1 class="page-title">';
printf( __( 'Category Archives: %s', 'twentyeleven' ), '<span>' . single_cat_title( '', false ) . '</span>' );
echo '</h1>';
$category_description = category_description();
if ( ! empty( $category_description ) )
echo apply_filters( 'category_archive_meta', '<div class="category-archive-meta">' . $category_description . '</div>' );
echo '</header>';
while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile;
twentyeleven_content_nav( 'nav-below' );
echo '<p class="navigation">';
posts_nav_link(' - ', '« Pagina Precedente', 'Pagina Successiva »');
else :
echo '<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title">';
_e( 'Nothing Found', 'twentyeleven' );
echo '</h1></header><div class="entry-content">
<p>';
_e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' );
echo '</p>';
get_search_form();
echo '</div></article>';
endif;
echo '</div></section>';
get_sidebar();
get_footer();
}
else echo 'Please go back to page1';
?>
-
Niceness is relative. Not jumping in and out of <?php ?> IS faster. Though the notion of fusing logic and presentation is fundamentally not nice no matter how you do it.
This is what you get for using a system that doesn't understand this fairly basic concept. (I have absolutely no love for WP, other than the fact that there are some nice themes out there for it, but that's a byproduct of the 'ease' of development.)