Seite 2 von 4

Verfasst: 23.04.2004 23:17
von Gumfuzi
Hier meine profile.php:
<?php
/***************************************************************************
* profile.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: profile.php,v 1.193.2.3 2003/03/02 23:16:17 acydburn 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.
*
***************************************************************************/

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_PROFILE);
init_userprefs($userdata);
//
// End session management
//

// session id check
if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
{
$sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
}
else
{
$sid = '';
}

//
// Set default email variables
//
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
$script_name = ( $script_name != '' ) ? $script_name . '/profile.'.$phpEx : 'profile.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';

$server_url = $server_protocol . $server_name . $server_port . $script_name;

$template->assign_var('EP', $posts );

// -----------------------
// Page specific functions
//
function gen_rand_string($hash)
{
$chars = array( 'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0');

$max_chars = count($chars) - 1;
srand( (double) microtime()*1000000);

$rand_str = '';
for($i = 0; $i < 8; $i++)
{
$rand_str = ( $i == 0 ) ? $chars[rand(0, $max_chars)] : $rand_str . $chars[rand(0, $max_chars)];
}

return ( $hash ) ? md5($rand_str) : $rand_str;
}
//
// End page specific functions
// ---------------------------

//
// Start of program proper
//
if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
{
$mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];

if ( $mode == 'viewprofile' )
{
include($phpbb_root_path . 'includes/usercp_viewprofile.'.$phpEx);
exit;
}
else if ( $mode == 'editprofile' || $mode == 'register' )
{
if ( !$userdata['session_logged_in'] && $mode == 'editprofile' )
{
redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=editprofile", true));
}

include($phpbb_root_path . 'includes/usercp_register.'.$phpEx);
exit;
}
else if ( $mode == 'sendpassword' )
{
include($phpbb_root_path . 'includes/usercp_sendpasswd.'.$phpEx);
exit;
}
else if ( $mode == 'activate' )
{
include($phpbb_root_path . 'includes/usercp_activate.'.$phpEx);
exit;
}
else if ( $mode == 'email' )
{
include($phpbb_root_path . 'includes/usercp_email.'.$phpEx);
exit;
}
}

redirect(append_sid("index.$phpEx", true));

?>
Normalerweise sollte dann mit dem Code (ein paar Postings vorher) in der tpl zumindest die Anzahl der Posts stehen, aber beim Profilaufruf bleibt das Feld leer (keine Fehlermeldung).
Was mache ich falsch?

Verfasst: 24.04.2004 17:19
von jonemo
Die profile.php "verteilt" nur die Anfragen. Hier landet jeder, der ein profil anlegen, editen oder anzeigen will.

Code: Alles auswählen

 if ( $mode == 'viewprofile' )
{
include($phpbb_root_path . 'includes/usercp_viewprofile.'.$phpEx);
exit;
} 
sagt, dass man, wenn es ums profil anzeigen geht, mal in der obenstehenden file schauen sollte.

Verfasst: 24.04.2004 19:11
von Gumfuzi
heißt das, daß man neue (bzw. zusätzliche) Variablen in der usercp_viewprofile.php deklarieren muß?

Verfasst: 24.04.2004 19:40
von itst
Je nach dem wo Du eine Template-Variable benutzen willst.

Verfasst: 24.04.2004 19:43
von Gumfuzi
zuerst einmal will ich sie im Profil nutzen, später auch in den Postings.

Noch eine Frage:

Code: Alles auswählen

$template->assign_var('EP', $posts );
Gibt es wo eine Syntax-Referenz zu dem assign_var?
wenn ich zB. vorher

Code: Alles auswählen

$summe = 10
eingebe, dann funzt es nicht.

Lösche ich aber die "$summe = 10"-Zeile, dann funzt es, bzw. es kommt keine Fehlermeldung - aber Wert wird auch keiner angezeigt

Verfasst: 24.04.2004 19:48
von Tuxman
Es heißt assign_vars... und die beiden Bestandteile werden durch => getrennt... und versuch's mal mit 'nem Array, also:

Code: Alles auswählen

$template->assign_vars(array(
'EP' => $posts)
);
:-?

Was für eine Syntax-Referenz hättest du denn gern?

Code: Alles auswählen

$template->assign_vars(array(
'VARIABLE1' => $var1,
'VARIABLE2' => $var2,
'VARIABLE3' => $var3)
);

Verfasst: 24.04.2004 19:53
von Gumfuzi
Das gibt zwar keine Meldung, aber wie spreche ich dann den Array in der TPL an?

Verfasst: 24.04.2004 19:56
von Tuxman
Den Array gar nicht... nur die Variablen darin... also z.B. {EP} ;)

Verfasst: 24.04.2004 20:19
von Gumfuzi
OK.

Aber in der TPL habe ich die Variablen in Klammern:
{NUMBER_OF_VISIT}
{NUMBER_OF_PAGES}
{POSTS}

Wie schreibe ich diese Variablen in der PHP-Datei? anstelle der "{" und "}" nur mit einem "$" am Anfang?

Verfasst: 24.04.2004 20:24
von Tuxman
Nein, ohne alles, siehe mein Beispiel :)