Seite 13 von 19
Re: Vorlage für in phpBB eingebundene Seiten in phpBB3
Verfasst: 26.07.2009 00:17
von djchrisnet
The Dust hat geschrieben:Meine "mein_template.html"-Datei:
Code: Alles auswählen
<!-- INCLUDE overall_header.html -->
<html>
<head>
<body>
<img src="test.jpg" width="500" height="500" />
</body>
</head>
</html>
<!-- INCLUDE overall_footer.html -->
und
sind zuviel
diese werden bereits in overall_* verwendet.
Re: Vorlage für in phpBB eingebundene Seiten in phpBB3
Verfasst: 26.07.2009 02:29
von The Dust
Oh, habe geglaubt, man müsse den Pfad des Bildes relativ zur Template.html setzten. Geht natürlich nicht

Und danke für den Hinweis mit den überschüssigen <html>'s usw., doppelt hält nicht immer besser

Re: Vorlage für in phpBB eingebundene Seiten in phpBB3
Verfasst: 24.08.2009 21:10
von no-way
Hallo,
ich versuche folgenden Code in einer neuen Seite einzubinden. Es ist ein Code um
Vote ergebnisse für Maps bei einem Online Game darzustellen.
Siehe
http://forums.alliedmods.net/showthread.php?t=69593
Die Datenbank ist die Gleiche wie von meinem PHP 3.0.x Board. Kann mir jemand
helfen dieses zu realisieren?
Dank im Voraus
no-way
Code: Alles auswählen
<?php
/**
* Map Rate Viewer
* Copyright 2008 Ryan Mannion. All Rights Reserved.
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define('MR_DBHOST', 'localhost');
define('MR_DBUSER', 'username');
define('MR_DBPASS', 'password');
define('MR_DBNAME', 'sourcemod_db_name');
define('MR_TABLENAME', 'map_ratings');
define('MR_THRESHOLD', 0);
define('MR_COLUMNS', 3);
define('MR_LEFTWIDTH', 200);
define('MR_RIGHTWIDTH', 100);
$sort = (isset($_GET['sort']) ? $_GET['sort'] : 'rating');
$reverse = (isset($_GET['reverse']) ? $_GET['reverse'] : 'no');
?>
<html>
<head>
<style type="text/css">
body {
font-family: Trebuchet MS, Helvetica, sans-serif;
margin-left: auto;
margin-right: auto;
width: <?php echo MR_COLUMNS * (MR_LEFTWIDTH + MR_RIGHTWIDTH); ?>;
}
div.title {
margin: 0px;
padding: 10px;
color: white;
background-color: #000066;;
}
div.title span.title {
font-weight: bold;
font-size: 18pt;
}
div.title a, a:visited, a:hover, a:link {
color: white;
}
div.ratings {
}
table.map_rating {
border: 2px solid DarkBlue;
background-color: white;
margin: 0;
}
table.map_rating span.map_name {
font-weight: bold;
}
table.rating_graph {
background-color: Lavender;
}
table.rating_graph td {
font-size: 10pt;
}
table.rating_graph tr.bars td {
vertical-align: bottom;
}
table.rating_graph tr.labels td {
text-align: center;
font-weight: bold;
font-size: 8pt;
}
table.rating_graph div.rating_1 {
background-color: #B80000;
}
table.rating_graph div.rating_2 {
background-color: #B85800;
}
table.rating_graph div.rating_3 {
background-color: #B89800;
}
table.rating_graph div.rating_4 {
background-color: #99CC33;
}
table.rating_graph div.rating_5 {
background-color: #33CC00;
}
</style>
</head>
<body>
<?php
class MapRating {
public $name;
public $num_ratings = 0;
public $ratings = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0);
private $max_ratings = 0;
function __construct($name) {
$this->name = $name;
}
function add_rating($rating, $count) {
if (!isset($this->ratings[$rating])) {
throw new Exception('Invalid rating');
}
$this->ratings[$rating] += $count;
$this->num_ratings += $count;
$this->max_ratings = max($this->max_ratings, $count);
}
function get_graph($width = 300, $height = 100) {
$row_bars = array();
$row_labels = array();
for ($i = 1; $i <= 5; $i++) {
/* The weird comment inside the DIV is a fix for IE which renders
* 20px height minimum without the comment */
array_push($row_bars,
"\t\t<td width=\"20%\"><div class=\"rating_$i\" style=\"height: "
.$this->get_rating_height($i, $height)
."\"><!-- --></div></td>\n"
);
array_push($row_labels, "\t\t<td>{$this->ratings[$i]}</td>\n");
}
return "<table class=\"rating_graph\" width=\"$width\" height=\"$height\">\n".
"\t<tr class=\"bars\">\n".implode($row_bars)."\t</tr>\n".
"\t<tr class=\"labels\" height=\"15\">\n".implode($row_labels)."\t</tr>\n".
"</table>\n";
}
function get_average() {
if ($this->num_ratings) {
$rating_sum = 0;
foreach (array_keys($this->ratings) as $key) {
$rating_sum += $key * $this->ratings[$key];
}
return round($rating_sum / $this->num_ratings, 2);
}
else {
return 0;
}
}
private function get_rating_height($rating, $height) {
if ($this->max_ratings) {
return (int)($this->ratings[$rating] / $this->max_ratings * $height);
}
else {
return $height;
}
}
function get_num_ratings() {
return "{$this->num_ratings} rating".($this->num_ratings == 1 ? '' : 's');
}
function get_table() {
return "<table class=\"map_rating\">\n"
."\t<tr>\n"
."\t\t<td width=\"".MR_LEFTWIDTH."\"><span class=\"map_name\">{$this->name}</span><br/>{$this->get_average()} "
."({$this->get_num_ratings()})</td>\n"
."\t\t<td>{$this->get_graph(MR_RIGHTWIDTH, 30)}</td>\n"
."\t</tr>\n"
."</table>\n";
}
}
class MapRatings {
private $map_ratings;
private $maps;
private $db;
function __construct() {
$this->db = mysql_pconnect(MR_DBHOST, MR_DBUSER, MR_DBPASS);
if (!$this->db|| !mysql_select_db(MR_DBNAME)) {
throw new Exception('Could not establish connection to the database');
}
$this->populate_ratings();
}
private function populate_ratings() {
$sort = 'ORDER BY rating DESC';
$query = 'SELECT map, rating, COUNT(*) AS count FROM '.MR_TABLENAME.' GROUP BY map, rating';
$result = mysql_query($query);
$this->map_ratings = array();
while ($row = mysql_fetch_object($result)) {
if (!isset($this->map_ratings[$row->map])) {
$this->map_ratings[$row->map] = new MapRating($row->map);
}
$this->map_ratings[$row->map]->add_rating($row->rating, $row->count);
}
foreach (array_keys($this->map_ratings) as $key) {
if ($this->map_ratings[$key]->num_ratings < MR_THRESHOLD) {
unset($this->map_ratings[$key]);
}
}
$this->maps = array_keys($this->map_ratings);
}
function get_links($sort='name', $dir='no') {
$sort_types = array('rating' => 'Rating', 'name' => 'Map Name', 'ratings' => 'Number of Ratings');
$links = array();
foreach (array_keys($sort_types) as $sort_type) {
$link = '';
if ($sort_type == $sort) {
$link = "<strong>{$sort_types[$sort_type]}</strong>";
}
else {
$link = "<a href=\"{$_SERVER['PHP_SELF']}?sort=$sort_type\">{$sort_types[$sort_type]}</a>";
}
array_push($links, $link);
}
return '<strong>Order By: </strong>'.implode(' | ', $links);
}
function set_sort($sort='rating', $dir='no') {
$rating = array();
$ratings = array();
foreach (array_values($this->map_ratings) as $mr) {
array_push($rating, $mr->get_average());
array_push($ratings, $mr->num_ratings);
}
if ($sort == "name") {
sort($this->maps);
}
else if ($sort == "rating") {
array_multisort($rating, SORT_DESC, $this->maps);
}
else if ($sort == "ratings") {
array_multisort($ratings, SORT_DESC, $this->maps);
}
if ($dir == "yes") {
$this->maps = array_reverse($this->maps);
}
}
function get_ratings_table() {
ob_start();
echo "<table>\n";
$cell = 0;
echo "\t<tr>\n";
foreach ($this->maps as $map) {
$mr = $this->map_ratings[$map];
if (!$cell) {
echo "\t</tr>\n";
echo "\t<tr>\n";
}
echo "\t\t<td>".$mr->get_table()."</td>\n";
$cell = ($cell + 1) % MR_COLUMNS;
}
while ($cell) {
echo "\t\t<td> </td>\n";
$cell = ($cell + 1) % MR_COLUMNS;
}
echo "\t</tr>\n";
echo "</table>\n";
$table = ob_get_contents();
ob_end_clean();
return $table;
}
}
$mr = new MapRatings();
echo "<div class=\"title\"><span class=\"title\">Map Ratings</span><br/>";
echo "<span class=\"links\">".$mr->get_links($sort, $reverse)."</span></div>\n";
echo "<div class=\"ratings\">\n";
$mr->set_sort($sort, $reverse);
echo $mr->get_ratings_table();
echo "</div>\n";
?>
</body>
</html>
Moderative Anweisung
Verfasst: 26.08.2009 20:38
von Boecki91
Du hast zuviel Code gepostet, was das Thema unnötig in die Länge zieht und unübersichtlich macht.
Es wäre besser die Datei bzw. den Code als .txt Datei abzuspeichern und dann hier einen Link zu posten - siehe auch KB:datei .
Bitte passe deinen Beitrag an, lies Dir den
phpBB.de-Knigge und den Hinweis zur
Fragestellung und Rechtschreibung durch und beachte diese zukünftig.
Nun aber zum Thema:
Hast du schon Ansätze?
Z.B. könntest du das ganze HTML schon raus machen weil das dann eh über das Templatesystem von phpBB3 laufen wird, wenn du das in der selben DB machst in der auch das Forum liegt kannst du ganz einfach sogar die DB-Klasse von phpBB3 benutzen.
Mehr kann ich erstmal nicht dazu sagen, wie stellst du dir das den vor?
Vielleicht kann man ja auch phpBB3 eigene Umfragen erstellen?
Re: Vorlage für in phpBB eingebundene Seiten in phpBB3
Verfasst: 10.07.2010 12:24
von JumpFrog
Hallo leute,
So zunächst mal die Fehlermeldung(en):
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /contact.php:1)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /contact.php:1)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /contact.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4194: Cannot modify header information - headers already sent by (output started at /contact.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4196: Cannot modify header information - headers already sent by (output started at /contact.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4197: Cannot modify header information - headers already sent by (output started at /contact.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4198: Cannot modify header information - headers already sent by (output started at /contact.php:1)
So nun noch schnell der inhalt meiner dateien:
contact.php:
Code: Alles auswählen
<?php
// Benötigte Dateien und Variablen von phpBB
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Session auslesen und Benutzer-Informationen laden
$user->session_begin();
$user->setup();
$auth->acl($user->data);
// Header und Titel der Seite
page_header('Contact');
// Angabe eurer Content-Seite
$template->set_filenames(array(
'body' => 'test.html')
);
// Footer
page_footer();
?>
nun die test.html:
Code: Alles auswählen
<!-- INCLUDE overall_header.html -->
Test test test :D
<!-- INCLUDE overall_footer.html -->
Ich habe leider keine Ahnung wieso weshlab warum da was falsch ist. Verstehen tu ich ja die fehlermeldung. Aber mein wissen reicht nicht aus um diesen zu beheben.
Re: Vorlage für in phpBB eingebundene Seiten in phpBB3
Verfasst: 10.07.2010 12:39
von Pyramide
Wenn die contact.php ein 1:1 copy&paste ist, dann solltest du die Einrückung entfernen - die zusätzlichen Leerzeichen in der ersten Zeile zählen nämlich bereits als Ausgabe.
Re: Vorlage für in phpBB eingebundene Seiten in phpBB3
Verfasst: 10.07.2010 16:27
von JumpFrog
Oki fehler sind weg, aber was mich wundert, ich kann es mir nur im IE anschauen, aber nicht im Firefox. Cache und Cokkies schon gelöscht, leider kein erfolg....
Re: Vorlage für in phpBB eingebundene Seiten in phpBB3
Verfasst: 28.07.2010 15:17
von DespoBerry
hallo,
ich habe eine eigene seite erstellt aber leider werden die umlaute nicht ordentlich dargestellt.
die datei hab ich schon mit utf-8 ohne bom gespeichert.
könnt ihr mir sagen wo der fehler begraben ist??
http://www.oberlausitzer-fussball-forum.de/fehler.php
fehler.php
Code: Alles auswählen
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
page_header('aufgerufene Seite leider nicht verfügbar');
$template->set_filenames(array(
'body' => 'fehler.html',
));
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>
fehler.html
Code: Alles auswählen
<!-- INCLUDE overall_header.html -->
<h2>Diese Seite ist leider nicht verfügar</h2>
<div class="panel">
<div class="inner"><span class="corners-top"><span></span></span>
<div class="content">
<p>
Die von Ihnen aufgerufene Seite existiert leider nicht.
</p>
</div>
<span class="corners-bottom"><span></span></span></div>
</div>
<!-- INCLUDE jumpbox.html -->
<!-- INCLUDE overall_footer.html -->
vielen dank
Re: Vorlage für in phpBB eingebundene Seiten in phpBB3
Verfasst: 28.07.2010 15:21
von 7emper5i
Du musst eine neue language-file anlegen.
In dieser kannst du Konstanten erstellen, welche in ihrer Definition auch Umlaute zulassen.
Dazu änderst du deine fehler.php zunächst so ab:
finde:
ersetze:
Code: Alles auswählen
$user->setup('mods/fehler_lang'); // Sprachvariablen aus eigener Sprachdatei laden
Erstelle eine neue php-Datei mit dem Namen "
fehler_lang" und speichere diese mit folgendem Code in den language-Ordner und der Sprache die du nutzt in den Unterordner
mods
Code: Alles auswählen
<?php
/**
*
* groups [German]
*
* @author Mein Benutzername email@domain.de - http://meine-seite.de
*
* @package language
* @version $Id$
* @copyright (c) 2007 Deine Gruppe
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
exit;
if (empty($lang)||!is_array($lang))
$lang = array();
// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
$lang = array_merge($lang, array(
'TOP_FEHLER' => 'Diese Seite ist leider nicht verfügbar!',
));
?>
dann gehst du in deine fehler.html und änderst den Teil zwischen dem <h2> ab:
Abspeichern, feddig.
Viel Erfolg.
Re: Vorlage für in phpBB eingebundene Seiten in phpBB3
Verfasst: 28.07.2010 16:59
von DespoBerry
7emper5i hat geschrieben:Du musst eine neue language-file anlegen.
In dieser kannst du Konstanten erstellen, welche in ihrer Definition auch Umlaute zulassen.
Dazu änderst du deine fehler.php zunächst so ab:
finde:
ersetze:
Code: Alles auswählen
$user->setup('mods/fehler_lang'); // Sprachvariablen aus eigener Sprachdatei laden
Erstelle eine neue php-Datei mit dem Namen "
fehler_lang" und speichere diese mit folgendem Code in den language-Ordner und der Sprache die du nutzt in den Unterordner
mods
dessen bin ich mir schon bewusst, problematisch wird es aber wenn ich ne andere seite includen will. dort kann ich keine sprachvariablen setzen. unter phpbb2 hatte das auch wunderbar geklappt, es gibt da auch best. ne andere lösung.
den für normale posts mit umlauten etc. hat phpbb ja auch keine lang_file.