I have an IPB forum installed and on that a mod that allows me to create new pages. The mod add's a header, footer etc and then inserts my page into the body via an iframe. As it's IPB their is already variables included in the url so I don't really want use $_GET['var'] and go adding more. Is their any other way to transfer sessions or variables to my php file.
[RESOLVED] Transfer variable to iframe
you mentioned sessions, why not use them?
I tried to include sessions but I can't seam to get them to work. I'm not great with php but Googled about and tried to add echo session_id(); at the start of the file but the mod doesn't seam to allow sessions to transfer. At the bottom it's own built in permissions which I think may be affecting it. Maybe not, I honestly don't know.
Below is the mod that generates the page. I'd ask the original author but it's no longer supported.
Thanks for you help
<?php
//---------------------------------------------------------------------------
// IP.Board PageMaker for 2.3.x
//
// Copyright 2007 (c) Larry Lewis JLogica ([url]http://jlogica.com[/url])
// All Rights Reserved
//
// Ideas from Custom Pages by cjvj and of course Matt the coder
//
// $Id: page.php 83 2008-02-24 07:05:30Z jenolan $
//---------------------------------------------------------------------------
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
define('SYS_BUILD','$Revision: 83 $');
class component_public
{
var $ipsclass;
var $nav = array();
var $output = "";
var $page_title = "";
function run_component()
{
//-----------------------------------------
// Load what we need
//-----------------------------------------
$this->ipsclass->load_template( 'skin_page' );
$this->ipsclass->load_language( 'lang_page' );
//-----------------------------------------
// Where do you want to go?
//-----------------------------------------
switch( $this->ipsclass->input[ 'do' ])
{
case 'show':
$this->show();
break;
default:
// $this->show_default();
$this->show();
break;
}
}
function show_default()
{
// Will add a default page maybe one day
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'jlogica_pm_no_page' ) );
}
function show()
{
$page_id = intval( $this->ipsclass->input[ 'id' ] );
if( empty( $page_id ) OR $page_id < 1 )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'jlogica_pm_id_empty' ) );
}
//-----------------------------------------
// Get the page
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array(
'select' => '*',
'from' => 'jlogica_pm_pages',
'where' => 'page_id=' . $page_id,
)
);
$this->ipsclass->DB->simple_exec();
if( ! $this->ipsclass->DB->get_num_rows() )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'jlogica_pm_no_page' ) );
}
$page = $this->ipsclass->DB->fetch_row();
$page[ 'page_text' ] = $this->ipsclass->txt_UNhtmlspecialchars( $page[ 'page_text' ] );
//-----------------------------------------
// Check access permission
//-----------------------------------------
if( $page[ 'page_perms' ] != '*' )
{
if ( $this->check_perms( $page[ 'page_perms' ] ) != TRUE )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'no_permission' ) );
}
}
//-----------------------------------------
// Display page
//-----------------------------------------
switch( $page[ 'page_type' ])
{
case 'Inline':
$this->show_inline( $page );
break;
case 'Embed':
$this->show_embed( $page );
break;
case 'Iframe':
$this->show_iframe( $page );
break;
default:
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'jlogica_pm_no_pagetype' ) );
break;
}
//-----------------------------------------
// Update views
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'update' => 'jlogica_pm_pages',
'set' => 'page_views=page_views+1',
'where' => 'page_id='. $page_id,
)
);
$this->ipsclass->DB->simple_shutdown_exec();
$year = date('Y');
//-----------------------------------------
// Remove this and die :( thanks cjvj :)
//-----------------------------------------
$this->output .= $this->ipsclass->compiled_templates['skin_page']->copyright( $year, SYS_BUILD );
//-------------------------------------------
$this->ipsclass->print->add_output( $this->output );
$this->ipsclass->print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
//--------------------------------------------------------
// EMBED :: The page is in the DB record
//--------------------------------------------------------
function show_embed( $page )
{
$this->output .= $this->ipsclass->compiled_templates[ 'skin_page' ]->show_embed_page( $page );
$this->page_title = $this->ipsclass->lang[ 'jlogica_pm_string_page' ] . $page[ 'page_title' ];
$this->nav = array("<a href='{$this->ipsclass->base_url}autocom=page'>{$this->ipsclass->lang['jlogica_pm_string_custompages']}</a>",$this->ipsclass->lang['jlogica_pm_string_viewingpage'].$page[ 'page_title' ]);
}
//--------------------------------------------------------
// INLINE :: The page is a html file no <html> tag allowed
//--------------------------------------------------------
function show_inline( $page )
{
$fname = ROOT_PATH . "jlogica/pagemaker/inline/{$page[ 'page_text' ]}.html";
if( ! file_exists( $fname ) )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'jlogica_pm_no_file', EXTRA => $fname ) );
}
$page[ 'txt' ] = @file_get_contents( $fname );
if( $txt === false )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'jlogica_pm_read_failed', EXTRA => $fname ) );
}
$this->output .= $this->ipsclass->compiled_templates[ 'skin_page' ]->show_inline_page( $page );
$this->page_title = $this->ipsclass->lang[ 'jlogica_pm_string_page' ] . $page[ 'page_title' ];
$this->nav = array("<a href='{$this->ipsclass->base_url}autocom=page'>{$this->ipsclass->lang['jlogica_pm_string_custompages']}</a>",$this->ipsclass->lang['jlogica_pm_string_viewingpage'].$page[ 'page_title' ]);
}
//--------------------------------------------------------
// IFRAME :: The page is a file (full page details <html>)
//--------------------------------------------------------
function show_iframe( $page )
{
//--------------------------------------------------------
// For IFrame to work we need either an index.html or php
//--------------------------------------------------------
$furl = "{$this->ipsclass->vars['board_url']}/jlogica/pagemaker/iframe/{$page[ 'page_text' ]}";
$iframe_name = ROOT_PATH . "jlogica/pagemaker/iframe/{$page[ 'page_text' ]}/";
$fname = "{$iframe_name}index.php";
if( ! file_exists( $fname ) )
{
$fname = "{$iframe_name}index.html";
if( ! file_exists( $fname ) )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'jlogica_pm_no_file', EXTRA => $fname ) );
}
}
//--------------------------------------------------------
// If iframe.html exists use it otherwise we will setup
// a default frame.
//--------------------------------------------------------
$iframe_parm = @file_get_contents( "{$iframe_name}iframe.html" );
if( $iframe_parm === false )
{
$iframe_parm = "<div align='center'>
<iframe src='{$furl}'
marginwidth='0' marginheight='0'
align='middle' frameborder='0' height=400 scrolling='auto' width=100%>
</iframe>
</div> ";
}
$iframe_parm = str_replace( "<!-- File -->", $furl, $iframe_parm );
$page[ 'iframe_parm' ] = $iframe_parm;
$this->output .= $this->ipsclass->compiled_templates[ 'skin_page' ]->show_iframe_page( $page );
$this->page_title = $this->ipsclass->lang[ 'jlogica_pm_string_page' ] . $page[ 'page_title' ];
$this->nav = array("<a href='{$this->ipsclass->base_url}autocom=page'>{$this->ipsclass->lang['jlogica_pm_string_custompages']}</a>",$this->ipsclass->lang['jlogica_pm_string_viewingpage'].$page[ 'page_title' ]);
}
function check_perms( $page_perm="" )
{
if ( $page_perm == '*' )
{
return TRUE;
}
if ( $page_perm == '' )
{
return FALSE;
}
$perm_id_array = explode( ",", $this->ipsclass->perm_id );
if( ! is_array( $perm_id_array ) )
{
return FALSE;
}
$page_perm_array = explode( ",", $page_perm );
foreach( $perm_id_array as $u_id )
{
if ( in_array( $u_id, $page_perm_array ) )
{
return TRUE;
}
}
return FALSE;
}
}
?>