phpBB2.de Foren-Übersicht  
[netclusive - internet broadcasting]
 FAQ  •  Suchen  •  Download  •  Lesezeichen  •  Mitgliederliste  •  Benutzergruppen   •  Registrieren  •  Profil  •  Einloggen, um private Nachrichten zu lesen  •  Login
 
        
 
        
 

LinkLift

Nächstes Thema anzeigen
Vorheriges Thema anzeigen

Dieses Forum ist gesperrt, du kannst keine Beiträge editieren, schreiben oder beantworten.Dieses Thema ist gesperrt, du kannst keine Beiträge editieren oder beantworten.
Autor Nachricht
lipps
phpBB2.de User
phpBB2.de User



Anmeldungsdatum: 20.11.2002
Beiträge: 3

BeitragVerfasst am: Mi 20 Nov, 2002 14:13 Antworten mit ZitatNach oben 

Ich habe folgende Frage und auch schon im ganzen Forum gesucht, aber leider keine Antwort gefunden:

Über einen MOD kann ich sog. portal.php Seiten erstellen in die wiederum einfach nur der php Quelltext einer normalen Seite kopiert werden kann. Über einen Link im Menü rufe ich nun diese Seite auf.

Meine Frage:

gibt es eine Möglichkeit, dass genau diese Seite nur für Administratoren zugänlich ist, also dass der registrierte User einen Hinweis bekommt, dass er für diese Seite keinen Zugang hat?

Ich bedanke mich schon jetzt ganz herzlich für Eure Bemühungen.

Der Quelltext der Datei zugang.php

<?

/***************************************************************************

* portal.php

* -------------------

* This Portal Site was created from the Portal Hack

* written by Dwing <dwing@weingarten-net.de>

* Supporting phpBBHacks.com and http://www.dseitz.de/Neo_phpBB

*

* To view a documentation visit:

* https://sourceforge.net/docman/?group_id=50877

*


***************************************************************************/



/***************************************************************************

*

* This program is free software; you can redistribute it and/or modify

* it under the terms of the GNU General Public License as published by

* the Free Software Foundation; either version 2 of the License, or

* (at your option) any later version.

*

* uses phpBB Technology (c) <http://www.phpbb.com>

*

***************************************************************************/



define('IN_PHPBB', true);

$phpbb_root_path = './';

include($phpbb_root_path . 'extension.inc');

include($phpbb_root_path . 'common.'.$phpEx);



//

// Start session management

//

$userdata = session_pagestart($user_ip, PAGE_INDEX);

init_userprefs($userdata);

//

// End session management

//

include($phpbb_root_path . 'includes/page_header.'.$phpEx);







?>

<h1>Online Rechnungsformular!</h1>

<!-- date -->





<!--

//

// Insert Your Stuff below

//

-->
An dieser Stelle füge ich den eigentlichen Quelltext ein!!!!
<!--

//

// Do not Insert somethin below this line unless you know what you are doing !

//

-->

<!-- recent -->

<!-- calendar -->


<!-- This Portal Site was created by Portal Creator
Diese Portal Seite wurde durch den Portal Creater erstellt
Copyright Portal Creator Dimitri Seitz -->

<?

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
OfflineBenutzer-Profile anzeigenPrivate Nachricht sendenE-Mail senden
Google







Verfasst am: Nach oben

Highfly
phpBB2.de User
phpBB2.de User



Anmeldungsdatum: 12.11.2002
Beiträge: 100

BeitragVerfasst am: Mi 20 Nov, 2002 19:07 Antworten mit ZitatNach oben 

Wie sieht es denn damit aus ???

In der Datei pagestart.php wird im Gegensatz zur page_header.php überprüft ob der User Admin ist und damit sollte das eigentlich lösbar sein.

Also bei mir funktionierts.


Code:
//
// Let's set the root dir for phpBB
//
$phpbb_root_path = "./../";

$no_page_header = ( $cancel ) ? TRUE : FALSE;
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_selects.'.$phpEx);

_________________
Gruß Highfly

Linklist Mod
http://www.phpbb2.de/phpBB/viewtopic.php?t=1790

http://www.corpsofdeath.org/board/
OfflineBenutzer-Profile anzeigenPrivate Nachricht senden
lipps
phpBB2.de User
phpBB2.de User



Anmeldungsdatum: 20.11.2002
Beiträge: 3

BeitragVerfasst am: Do 21 Nov, 2002 13:28 Antworten mit ZitatNach oben 

Hallo Highfly,

bitte entschuldige, dass ich dich noch mal belästigen muss. Ich habe Probleme den root path richtig zu setzen. Wahrscheinlich sind das Grundlagen, die man eigentlich wissen sollte.

1. Ich habe die datei jobmanager.php in das Forum integriert. Diese Datei liegt im Verzeichnis phpBB2/jobmanager.php

2. Den Quelltext, den du mir geschickt hast kopiere ich an den Anfang:

//
// Let's set the root dir for phpBB
//
$phpbb_root_path = "./../";

$no_page_header = ( $cancel ) ? TRUE : FALSE;
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_selects.'.$phpEx);


3. Wenn ich dich richtig verstanden habe, dann wird beim Aufrufen der Seite jobmanager.php in admin/pagestart.php nachgeschaut ob ich als admin eingeloggt bin.

4. Ich habe für den $phpbb_root_path = "./../"; folgende Möglichkeiten erfolglos ausprobiert:



[list=]$phpbb_root_path = "admin/";
[/list]$phpbb_root_path = "admin/pagestart.php";

Ich würde mich sehr freuen, wenn du mir nochmal helfen könntest, kann aber auch verstehen, wenn du besseres zutun hast. Danke




<?

/***************************************************************************

* portal.php

* -------------------

* This Portal Site was created from the Portal Hack

* written by Dwing <dwing@weingarten-net.de>

* Supporting phpBBHacks.com and http://www.dseitz.de/Neo_phpBB

*

* To view a documentation visit:

* https://sourceforge.net/docman/?group_id=50877

*


***************************************************************************/



/***************************************************************************

*

* This program is free software; you can redistribute it and/or modify

* it under the terms of the GNU General Public License as published by

* the Free Software Foundation; either version 2 of the License, or

* (at your option) any later version.

*

* uses phpBB Technology (c) <http://www.phpbb.com>

*

***************************************************************************/



define('IN_PHPBB', true);

$phpbb_root_path = './';

include($phpbb_root_path . 'extension.inc');

include($phpbb_root_path . 'common.'.$phpEx);



//

// Start session management

//

$userdata = session_pagestart($user_ip, PAGE_INDEX);

init_userprefs($userdata);

//

// End session management

//

include($phpbb_root_path . 'includes/page_header.'.$phpEx);


//ist das Script an dieser Stelle richtig?
//
// Let's set the root dir for phpBB
//
$phpbb_root_path = "./../";

$no_page_header = ( $cancel ) ? TRUE : FALSE;
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_selects.'.$phpEx);





?>

<h1>Online Rechnungsformular!</h1>

<!-- date -->





<!--

//

// Insert Your Stuff below

//

-->
An dieser Stelle füge ich den eigentlichen Quelltext ein!!!!
<!--

//

// Do not Insert somethin below this line unless you know what you are doing !

//

-->

<!-- recent -->

<!-- calendar -->


<!-- This Portal Site was created by Portal Creator
Diese Portal Seite wurde durch den Portal Creater erstellt
Copyright Portal Creator Dimitri Seitz -->

<?

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
OfflineBenutzer-Profile anzeigenPrivate Nachricht sendenE-Mail senden
Highfly
phpBB2.de User
phpBB2.de User



Anmeldungsdatum: 12.11.2002
Beiträge: 100

BeitragVerfasst am: Do 21 Nov, 2002 19:04 Antworten mit ZitatNach oben 

Hiho,

erstmal ist das hier ein Forum wo man Fragen stellen soll, also wieso belästigen??? Wenn ich keine Lust habe zu antworten muss ich das doch auch nicht aber ich tue es gerne.

Hier also die hoffentlich funktionierende Variante :

Code:


define('IN_PHPBB', true);

//Hier sollte es stehen :)
//
// Let's set the root dir for phpBB
//
$phpbb_root_path = "./";
/* Der root Path bezeichnet immer den Weg zu dem phpBB Verzeichnis,
soll heissen befindet sich Deine Datei in diesem reicht das oben. Machst Du eine Datei für das Verzeichnis /admin dann muss da ./../ stehen. Also 1 Verzeichnis hoch und dann kliegt da die Datei heisst das. .. bedeutet Verzeichnis über diesem. Hoffe das wird nun klarer ??!! */

$no_page_header = ( $cancel ) ? TRUE : FALSE;
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_selects.'.$phpEx);
include($phpbb_root_path . 'common.'.$phpEx);



//

// Start session management

//

$userdata = session_pagestart($user_ip, PAGE_INDEX);

init_userprefs($userdata);

//

// End session management

//

?>

<h1>Online Rechnungsformular!</h1>

<!-- date -->





<!--

//

// Insert Your Stuff below

//

-->
An dieser Stelle füge ich den eigentlichen Quelltext ein!!!!
<!--

//

// Do not Insert somethin below this line unless you know what you are doing !

//

-->

<!-- recent -->

<!-- calendar -->


<!-- This Portal Site was created by Portal Creator
Diese Portal Seite wurde durch den Portal Creater erstellt
Copyright Portal Creator Dimitri Seitz -->

<?

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>

_________________
Gruß Highfly

Linklist Mod
http://www.phpbb2.de/phpBB/viewtopic.php?t=1790

http://www.corpsofdeath.org/board/
OfflineBenutzer-Profile anzeigenPrivate Nachricht senden
lipps
phpBB2.de User
phpBB2.de User



Anmeldungsdatum: 20.11.2002
Beiträge: 3

BeitragVerfasst am: Fr 22 Nov, 2002 15:36 Antworten mit ZitatNach oben 

nochmals vielen Dank für Deine Hilfe. Ich bin jetzt der Sache ein bisschen näher gekommen, bekomme aber im IE folgenden Fehler:

Warning: Failed opening './page_header_admin.php' for inclusion (include_path='') in /home/sites/site4/web/bacardi/phpBB2/admin/pagestart.php on line 55

Fatal error: Cannot redeclare class template in /home/sites/site4/web/bacardi/phpBB2/includes/template.php on line 30


Falls ich es auf diese Art nicht hinbekommmen sollte habe ich ein zweite Idee bzw. Frage:

Über den folgenden Code kann ich bestimmten, ob ein user eingeloggt sein muss, um einen link zu sehen. Kann man den Code so verfeinern, dass man sagt der User muss ein admin sein, um den link zu sehen, oder habe ich mir das zu einfach vorgestellt?

Die entsprechende Datei im Template Ordner bearbeiten.
Um die Teile, die ausgeblendet werden sollen das hier setzten:

Noch mal Vielen Dank für Deine Hilfe und ein schönes Wochenende.

Gruss Jakob

Code:
<!-- BEGIN switch_user_logged_in -->
**Code, der nur eingeloggte User sehen sollen**
<!-- END switch_user_logged_in -->


Das kann man auch umkehren, so dass nur ausgeloggte User entsprechende Teile sehen:

Code:
<!-- BEGIN switch_user_logged_out -->
**Code hier**
<!-- END switch_user_logged_out -->



Code: jobmanager.php

<?

/***************************************************************************

* portal.php

* -------------------

* This Portal Site was created from the Portal Hack

* written by Dwing <dwing@weingarten-net.de>

* Supporting phpBBHacks.com and http://www.dseitz.de/Neo_phpBB

*

* To view a documentation visit:

* https://sourceforge.net/docman/?group_id=50877

*

***************************************************************************/



/***************************************************************************

*

* This program is free software; you can redistribute it and/or modify

* it under the terms of the GNU General Public License as published by

* the Free Software Foundation; either version 2 of the License, or

* (at your option) any later version.

*

* uses phpBB Technology (c) <http://www.phpbb.com>

*

***************************************************************************/
//

define('IN_PHPBB', true);

//Hier sollte es stehen Smile
//
// Let's set the root dir for phpBB
//
$phpbb_root_path = "./";
/* Der root Path bezeichnet immer den Weg zu dem phpBB Verzeichnis,
soll heissen befindet sich Deine Datei in diesem reicht das oben. Machst Du eine Datei für das Verzeichnis /admin dann muss da ./../ stehen. Also 1 Verzeichnis hoch und dann kliegt da die Datei heisst das. .. bedeutet Verzeichnis über diesem. Hoffe das wird nun klarer ??!! */

$no_page_header = ( $cancel ) ? TRUE : FALSE;
require($phpbb_root_path . 'extension.inc');
require('admin/pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_selects.'.$phpEx);
include($phpbb_root_path . 'common.'.$phpEx);



//

// Start session management

//

$userdata = session_pagestart($user_ip, PAGE_INDEX);

init_userprefs($userdata);

//

// End session management

//

?>


<h1>Job Manager!</h1>

<!-- date -->





<!--

//

// Insert Your Stuff below

//

-->
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
@import url(../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/stylesheet.css);
-->
</style>
</head>

<body>
<table width="100%" border="0">
<tr>
<td valign="bottom"><span class="kontrollfeld"><a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/jobmanager.php" class="kontrollfeld">Job
Manager</a> |</span><span class="rot"><a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/einsatz.php" class="kontrollfeld">Job
einf&uuml;gen</a> </span><a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/rechnungsformular/editor.php" target="bottom" class="kontrollfeld">|</a><span class="rot">
<a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/editor.php" class="kontrollfeld">Job editieren</a><span class="rot">
<a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/personalbogen/index.html" target="bottom" class="kontrollfeld">|</a></span>
<span class="rot"><a href="file:///C|/Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/personalbogen/index.html" class="kontrollfeld">Promoter
Database </a><br>
<br>
</span> </span></td>
</tr>
</table>
<?php require_once('../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/Connections/vaporisateur.php'); ?>
<?php
if ($order == "") {
$order ="peinsatznummer";
}
mysql_select_db($database_vaporisateur, $vaporisateur);
$query_editor = "SELECT * FROM rechnungsformular ORDER BY $order DESC";
$editor = mysql_query($query_editor, $vaporisateur) or die(mysql_error());
$row_editor = mysql_fetch_assoc($editor);
$totalRows_editor = mysql_num_rows($editor);
?>


<title>Editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/stylesheet.css" rel="stylesheet" type="text/css">
<table width="100%" border="0" bgcolor="EFEFEF" class="kontrollfeld">
<tr bgcolor="#056B9E">
<td bgcolor="#056B9E">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr bgcolor="#CDD5DB">
<td bgcolor="#CDD5DB"><font color="#000000"><a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/jobmanager.php?order=peinsatznummer" class="minilink">Einsatznummer</a></font></td>
<td bgcolor="#CDD5DB"><font color="#FFFFFF"><a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/jobmanager.php?order=plocation" class="minilink">Location</a></font></td>
<td><font color="#FFFFFF"><a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/jobmanager.php?order=pregion" class="minilink">Region</a></font></td>
<td><font color="#FFFFFF"><a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/jobmanager.php?order=port" class="minilink">Ort</a></font></td>
<td><font color="#FFFFFF"><a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/jobmanager.php?order=pdatumvon" class="minilink">von</a></font></td>
<td><font color="#FFFFFF"><a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/jobmanager.php?order=pdatumbis" class="minilink">bis</a>
</font></td>
<td><font color="#FFFFFF"><a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/jobmanager.php?order=status" class="minilink">Status</a></font></td>
<td><font color="#FFFFFF">&nbsp;</font></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<?php do { ?>
<tr>
<td><a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/editieren.php?peinsatznummer=<?php echo $row_editor['peinsatznummer']; ?>(%22der=<? echo $order; ?>" class="minilink"><?php echo $row_editor['peinsatznummer']; ?></a></td>
<td><?php echo $row_editor['plocation']; ?></td>
<td><?php echo $row_editor['pregion']; ?></td>
<td><?php echo $row_editor['port']; ?></td>
<td><?php echo $row_editor['pdatumvon']; ?></td>
<td><?php echo $row_editor['pdatumbis']; ?></td>
<td><?php echo $row_editor['status']; ?></td>
<td><a href="../../../Programme/Apache%20Group/Apache2/htdocs/vaporisateur_orginal/bacardi/phpBB2/delete.php?peinsatznummer=<?php echo $row_editor['peinsatznummer']; ?>(%22der=<? echo $order; ?>" class="rot">l&ouml;schen</a></td>
</tr>
<tr>
<td colspan="8">
<hr size="1" noshade></td>
</tr>
<?php } while ($row_editor = mysql_fetch_assoc($editor)); ?>
</table>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($editor);
?>


<p>&nbsp;</p></body>
</head>

<body>


<!--

//

// Do not Insert somethin below this line unless you know what you are doing !

//

-->

<!-- recent -->

<!-- calendar -->

<!-- This Portal Site was created by Portal Creator
Diese Portal Seite wurde durch den Portal Creater erstellt
Copyright Portal Creator Dimitri Seitz -->

<?

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>

Code: pagestart.php

<?php

/***************************************************************************

* pagestart.php

* -------------------

* begin : Thursday, Aug 2, 2001

* copyright : (C) 2001 The phpBB Group

* email : support@phpbb.com

*

* $Id: pagestart.php,v 1.1.2.2 2002/05/13 13:18:17 psotfx Exp $

*

*

***************************************************************************/



/***************************************************************************

*

* This program is free software; you can redistribute it and/or modify

* it under the terms of the GNU General Public License as published by

* the Free Software Foundation; either version 2 of the License, or

* (at your option) any later version.

*

***************************************************************************/



if ( !defined('IN_PHPBB') )

{

die("Hacking attempt");

}


//Zeile 55
define('IN_ADMIN', true);



include($phpbb_root_path . 'common.'.$phpEx);



//

// Start session management

//

$userdata = session_pagestart($user_ip, PAGE_INDEX);

init_userprefs($userdata);

//

// End session management

//

if( !$userdata['session_logged_in'] )

{

$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';

header($header_location . '../' . append_sid("login.$phpEx?redirect=admin/"));

exit;

}

else if( $userdata['user_level'] != ADMIN )

{

message_die(GENERAL_MESSAGE, $lang['Not_admin']);

}



if ( empty($no_page_header) )

{

// Not including the pageheader can be neccesarry if META tags are

// needed in the calling script.

include('./page_header_admin.'.$phpEx);

}



?>

Code: template.php

<?php

/***************************************************************************

* template.php

* -------------------

* begin : Saturday, Feb 13, 2001

* copyright : (C) 2001 The phpBB Group

* email : support@phpbb.com

*

* $Id: template.php,v 1.10 2002/04/02 21:13:47 the_systech Exp $

*

*

***************************************************************************/



/***************************************************************************

*

* This program is free software; you can redistribute it and/or modify

* it under the terms of the GNU General Public License as published by

* the Free Software Foundation; either version 2 of the License, or

* (at your option) any later version.

*

***************************************************************************/



/**

* Template class. By Nathan Codding of the phpBB group.

* The interface was originally inspired by PHPLib templates,

* and the template file formats are quite similar.

*

*/



class Template {

var $classname = "Template";



// variable that holds all the data we'll be substituting into

// the compiled templates.

// ...

// This will end up being a multi-dimensional array like this:

// $this->_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value

// if it's a root-level variable, it'll be like this:

// $this->_tpldata[.][0][varname] == value

var $_tpldata = array();



// Hash of filenames for each template handle.

var $files = array();



// Root template directory.

var $root = "";



// this will hash handle names to the compiled code for that handle.

var $compiled_code = array();



// This will hold the uncompiled code for that handle.

var $uncompiled_code = array();



/**

* Constructor. Simply sets the root dir.

*

*/

function Template($root = ".")

{

$this->set_rootdir($root);

}



/**

* Destroys this template object. Should be called when you're done with it, in order

* to clear out the template data so you can load/parse a new template set.

*/

function destroy()

{

$this->_tpldata = array();

}



/**

* Sets the template root directory for this Template object.

*/

function set_rootdir($dir)

{

if (!is_dir($dir))

{

return false;

}



$this->root = $dir;

return true;

}



/**

* Sets the template filenames for handles. $filename_array

* should be a hash of handle => filename pairs.

*/

function set_filenames($filename_array)

{

if (!is_array($filename_array))

{

return false;

}



reset($filename_array);

while(list($handle, $filename) = each($filename_array))

{

$this->files[$handle] = $this->make_filename($filename);

}



return true;

}





/**

* Load the file for the handle, compile the file,

* and run the compiled code. This will print out

* the results of executing the template.

*/

function pparse($handle)

{

if (!$this->loadfile($handle))

{

die("Template->pparse(): Couldn't load template file for handle $handle");

}



// actually compile the template now.

if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle]))

{

// Actually compile the code now.

$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]);

}



// Run the compiled code.

eval($this->compiled_code[$handle]);

return true;

}



/**

* Inserts the uncompiled code for $handle as the

* value of $varname in the root-level. This can be used

* to effectively include a template in the middle of another

* template.

* Note that all desired assignments to the variables in $handle should be done

* BEFORE calling this function.

*/

function assign_var_from_handle($varname, $handle)

{

if (!$this->loadfile($handle))

{

die("Template->assign_var_from_handle(): Couldn't load template file for handle $handle");

}



// Compile it, with the "no echo statements" option on.

$_str = "";

$code = $this->compile($this->uncompiled_code[$handle], true, '_str');



// evaluate the variable assignment.

eval($code);

// assign the value of the generated variable to the given varname.

$this->assign_var($varname, $_str);



return true;

}



/**

* Block-level variable assignment. Adds a new block iteration with the given

* variable assignments. Note that this should only be called once per block

* iteration.

*/

function assign_block_vars($blockname, $vararray)

{

if (strstr($blockname, '.'))

{

// Nested block.

$blocks = explode('.', $blockname);

$blockcount = sizeof($blocks) - 1;

$str = '$this->_tpldata';

for ($i = 0; $i < $blockcount; $i++)

{

$str .= '[\'' . $blocks[$i] . '.\']';

eval('$lastiteration = sizeof(' . $str . ') - 1;');

$str .= '[' . $lastiteration . ']';

}

// Now we add the block that we're actually assigning to.

// We're adding a new iteration to this block with the given

// variable assignments.

$str .= '[\'' . $blocks[$blockcount] . '.\'][] = $vararray;';



// Now we evaluate this assignment we've built up.

eval($str);

}

else

{

// Top-level block.

// Add a new iteration to this block with the variable assignments

// we were given.

$this->_tpldata[$blockname . '.'][] = $vararray;

}



return true;

}



/**

* Root-level variable assignment. Adds to current assignments, overriding

* any existing variable assignment with the same name.

*/

function assign_vars($vararray)

{

reset ($vararray);

while (list($key, $val) = each($vararray))

{

$this->_tpldata['.'][0][$key] = $val;

}



return true;

}



/**

* Root-level variable assignment. Adds to current assignments, overriding

* any existing variable assignment with the same name.

*/

function assign_var($varname, $varval)

{

$this->_tpldata['.'][0][$varname] = $varval;



return true;

}





/**

* Generates a full path+filename for the given filename, which can either

* be an absolute name, or a name relative to the rootdir for this Template

* object.

*/

function make_filename($filename)

{

// Check if it's an absolute or relative path.

if (substr($filename, 0, 1) != '/')

{

$filename = $this->root . '/' . $filename;

}



if (!file_exists($filename))

{

die("Template->make_filename(): Error - file $filename does not exist");

}



return $filename;

}





/**

* If not already done, load the file for the given handle and populate

* the uncompiled_code[] hash with its code. Do not compile.

*/

function loadfile($handle)

{

// If the file for this handle is already loaded and compiled, do nothing.

if (isset($this->uncompiled_code[$handle]) && !empty($this->uncompiled_code[$handle]))

{

return true;

}



// If we don't have a file assigned to this handle, die.

if (!isset($this->files[$handle]))

{

die("Template->loadfile(): No file specified for handle $handle");

}



$filename = $this->files[$handle];



$str = implode("", @file($filename));

if (empty($str))

{

die("Template->loadfile(): File $filename for handle $handle is empty");

}



$this->uncompiled_code[$handle] = $str;



return true;

}







/**

* Compiles the given string of code, and returns

* the result in a string.

* If "do_not_echo" is true, the returned code will not be directly

* executable, but can be used as part of a variable assignment

* for use in assign_code_from_handle().

*/

function compile($code, $do_not_echo = false, $retvar = '')

{

// replace \ with \\ and then ' with \'.

$code = str_replace('\\', '\\\\', $code);

$code = str_replace('\'', '\\\'', $code);



// change template varrefs into PHP varrefs



// This one will handle varrefs WITH namespaces

$varrefs = array();

preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}#is', $code, $varrefs);

$varcount = sizeof($varrefs[1]);

for ($i = 0; $i < $varcount; $i++)

{

$namespace = $varrefs[1][$i];

$varname = $varrefs[3][$i];

$new = $this->generate_block_varref($namespace, $varname);



$code = str_replace($varrefs[0][$i], $new, $code);

}



// This will handle the remaining root-level varrefs

$code = preg_replace('#\{([a-z0-9\-_]*?)\}#is', '\' . ( ( isset($this->_tpldata[\'.\'][0][\'\1\']) ) ? $this->_tpldata[\'.\'][0][\'\1\'] : \'\' ) . \'', $code);



// Break it up into lines.

$code_lines = explode("\n", $code);



$block_nesting_level = 0;

$block_names = array();

$block_names[0] = ".";



// Second: prepend echo ', append ' . "\n"; to each line.

$line_count = sizeof($code_lines);

for ($i = 0; $i < $line_count; $i++)

{

$code_lines[$i] = chop($code_lines[$i]);

if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m))

{

$n[0] = $m[0];

$n[1] = $m[1];



// Added: dougk_ff7-Keeps templates from bombing if begin is on the same line as end.. I think. Smile

if ( preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $n) )

{

$block_nesting_level++;

$block_names[$block_nesting_level] = $m[1];

if ($block_nesting_level < 2)

{

// Block is not nested.

$code_lines[$i] = '$_' . $a[1] . '_count = ( isset($this->_tpldata[\'' . $n[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $n[1] . '.\']) : 0;';

$code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)';

$code_lines[$i] .= "\n" . '{';

}

else

{

// This block is nested.



// Generate a namespace string for this block.

$namespace = implode('.', $block_names);

// strip leading period from root level..

$namespace = substr($namespace, 2);

// Get a reference to the data array for this block that depends on the

// current indices of all parent blocks.

$varref = $this->generate_block_data_ref($namespace, false);

// Create the for loop code to iterate over this block.

$code_lines[$i] = '$_' . $a[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;';

$code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)';

$code_lines[$i] .= "\n" . '{';

}



// We have the end of a block.

unset($block_names[$block_nesting_level]);

$block_nesting_level--;

$code_lines[$i] .= '} // END ' . $n[1];

$m[0] = $n[0];

$m[1] = $n[1];

}

else

{

// We have the start of a block.

$block_nesting_level++;

$block_names[$block_nesting_level] = $m[1];

if ($block_nesting_level < 2)

{

// Block is not nested.

$code_lines[$i] = '$_' . $m[1] . '_count = ( isset($this->_tpldata[\'' . $m[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $m[1] . '.\']) : 0;';

$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';

$code_lines[$i] .= "\n" . '{';

}

else

{

// This block is nested.



// Generate a namespace string for this block.

$namespace = implode('.', $block_names);

// strip leading period from root level..

$namespace = substr($namespace, 2);

// Get a reference to the data array for this block that depends on the

// current indices of all parent blocks.

$varref = $this->generate_block_data_ref($namespace, false);

// Create the for loop code to iterate over this block.

$code_lines[$i] = '$_' . $m[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;';

$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';

$code_lines[$i] .= "\n" . '{';

}

}

}

else if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $m))

{

// We have the end of a block.

unset($block_names[$block_nesting_level]);

$block_nesting_level--;

$code_lines[$i] = '} // END ' . $m[1];

}

else

{

// We have an ordinary line of code.

if (!$do_not_echo)

{

$code_lines[$i] = 'echo \'' . $code_lines[$i] . '\' . "\\n";';

}

else

{

$code_lines[$i] = '$' . $retvar . '.= \'' . $code_lines[$i] . '\' . "\\n";';

}

}

}



// Bring it back into a single string of lines of code.

$code = implode("\n", $code_lines);

return $code ;



}





/**

* Generates a reference to the given variable inside the given (possibly nested)

* block namespace. This is a string of the form:

* ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . '

* It's ready to be inserted into an "echo" line in one of the templates.

* NOTE: expects a trailing "." on the namespace.

*/

function generate_block_varref($namespace, $varname)

{

// Strip the trailing period.

$namespace = substr($namespace, 0, strlen($namespace) - 1);



// Get a reference to the data block for this namespace.

$varref = $this->generate_block_data_ref($namespace, true);

// Prepend the necessary code to stick this in an echo line.



// Append the variable reference.

$varref .= '[\'' . $varname . '\']';



$varref = '\' . ( ( isset(' . $varref . ') ) ? ' . $varref . ' : \'\' ) . \'';



return $varref;



}





/**

* Generates a reference to the array of data values for the given

* (possibly nested) block namespace. This is a string of the form:

* $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']

*

* If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.

* NOTE: does not expect a trailing "." on the blockname.

*/

function generate_block_data_ref($blockname, $include_last_iterator)

{

// Get an array of the blocks involved.

$blocks = explode(".", $blockname);

$blockcount = sizeof($blocks) - 1;

$varref = '$this->_tpldata';

// Build up the string with everything but the last child.

for ($i = 0; $i < $blockcount; $i++)

{

$varref .= '[\'' . $blocks[$i] . '.\'][$_' . $blocks[$i] . '_i]';

}

// Add the block reference for the last child.

$varref .= '[\'' . $blocks[$blockcount] . '.\']';

// Add the iterator for the last child if requried.

if ($include_last_iterator)

{

$varref .= '[$_' . $blocks[$blockcount] . '_i]';

}



return $varref;

}



}



?>
OfflineBenutzer-Profile anzeigenPrivate Nachricht sendenE-Mail senden
Highfly
phpBB2.de User
phpBB2.de User



Anmeldungsdatum: 12.11.2002
Beiträge: 100

BeitragVerfasst am: Di 26 Nov, 2002 02:07 Antworten mit ZitatNach oben 

Code:
$no_page_header = 'TRUE';

setze das nochmal in Deine Datei und zwar vor das

Code:
require('admin/pagestart.' . $phpEx);

_________________
Gruß Highfly

Linklist Mod
http://www.phpbb2.de/phpBB/viewtopic.php?t=1790

http://www.corpsofdeath.org/board/
OfflineBenutzer-Profile anzeigenPrivate Nachricht senden
Beiträge der letzten Zeit anzeigen:      
Dieses Forum ist gesperrt, du kannst keine Beiträge editieren, schreiben oder beantworten.Dieses Thema ist gesperrt, du kannst keine Beiträge editieren oder beantworten.

Nächstes Thema anzeigen
Vorheriges Thema anzeigen
Du kannst keine Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen

Ähnliche Beiträge
Thema Autor Forum Antworten Verfasst am
Link zur Benutzerverwaltung nur für A... distanzcheck phpBB2.x - Support 0 Sa 17 Jan, 2009 12:18 Letzten Beitrag anzeigen
Phpbb2 in Selbst erstellte Website ei... monsterkiller phpBB2.x - Support 0 Mo 14 Jul, 2008 09:09 Letzten Beitrag anzeigen
Forum plötzlich nicht zugänglich, help! PyRoMaNIN phpBB2.x - Support 0 Mo 16 Jun, 2008 16:42 Letzten Beitrag anzeigen
News Admin hat im Portal kein gif nur... kitechris phpBB2.x - Support 3 So 11 Mai, 2008 19:14 Letzten Beitrag anzeigen
Signatur: Nur Link statt Bild Fanatico phpBB2.x - Support 0 Sa 05 Apr, 2008 23:20 Letzten Beitrag anzeigen