what would we do without you, Colan
good release, thanks
good release, thanks
Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\table.php on line 11
-.- my table php page is empty colan
btw fix this small bug:
? how does it look? it isn't working for meHEY! You forgot something ...
Nice class is nice.
If you check page 3, you'll know how to make it work.
Fatal error: Class 'OTSTable' not found in C:\xampp\htdocs\feed.php on line 294
<?PHP
include 'table.php';
?>
Fatal error: Cannot redeclare class OTSTable in C:\xampp\htdocs\table.php on line 245
Fatal error: Class 'OTSTable' not found in C:\xampp\htdocs\feed.php on line 236
Hello Colandus
I read all the pages before asking my question;
I don't get it... What should I do?
Thanks
<?php
/*--------------------------*/
##############################
// @Title: Feedback Form //
// @Version: 1.4 //
// @Author: Colandus //
##############################
/*--------------------------*/
//////////////||\\\\\\\\\\\\\\
//..........CONFIG..........\\
##############################
include "table.php";
$image_path = 'images/icons/';
$textarea_cols = 60; // Edit size of the textareas (where you write) width
$send_interval = 1 * 24 * 60 * 60; // Interval to send posts.
$send_amount = 3; // Amount of posts that can be sent within the interval.
$max_name_length = 14; // Maximum length of character name to be displayed.
$max_title_length = 100 - 3; // Maximum length of title to be sent (- 3 for adding dots).
$min_title_length = 10; // Minimum length of title to be sent.
$min_text_length = 15; // Minimum length of text to be sent.
$statuses = array(
0 => 'unread', // Available feedback statuses.
1 => 'observed', // The rules for adding/removing statuses is same as in types,
2 => 'accepted', // check comments below !
3 => 'completed',
4 => 'rejected'
);
$types = array(
0 => 'suggestion', // Available feedback types. Note that feedback types are stored by array index
1 => 'bug report', // in database, so when you add a new type you have to place it in bottom and
2 => 'complaint', // when removing one, you have to put it in disabled types with same index.
4 => 'other'
);
$disabledTypes = array(
3 => 'application' // Feedback types that once existed but was removed.
);
$tags = array('b', 'i', 'u', 'center'); // BBCode tags usable in text.
##############################
//..........CONFIG..........\\
//////////////||\\\\\\\\\\\\\\
class Feedback {
static function get_status($id) {
return $statuses[$id];
}
static function set_status($id, $status) {
if(!(self::get($id) || self::get_status($status)))
return false;
self::query('UPDATE `feedback` SET `status` = ' . $status . ' WHERE `id` = ' . $id . ';');
}
private function query($sql) {
return $GLOBALS['SQL']->query($sql);
}
static function get($id) {
if(!is_numeric($id))
return false;
$feedback = self::query('SELECT * FROM `feedback` WHERE `id` = ' . $id . ';')->fetch();
return ($feedback['id'] ? $feedback : false);
}
static function delete($id) {
if(!self::get($id))
return false;
self::query('DELETE FROM `feedback` WHERE `id` = ' . $id . ';');
return true;
}
static function show($val) {
if(is_array($val))
$feedback = $val;
elseif(!$feedback = Feedback::get($val))
return false;
$sid = $feedback['status'];
$name = $feedback['name'];
if(strlen($name) > 0) {
if($feedback['self'])
$name = '<a href="?subtopic=characters&name=' . urlencode($name) . '">' . $name . '</a>';
} else
$name = '<i>Unknown Player</i>';
$text = $feedback['text'];
$text = htmlspecialchars($text);
$text = stripslashes($text);
$text = nl2br($text);
global $tags, $image_path, $statuses;
$types = $GLOBALS['types'] + $GLOBALS['disabledTypes'];
foreach($tags as $tag)
$text = preg_replace("/\[$tag\](.*?)\[\/$tag\]/", "<$tag>$1</$tag>", $text);
$status = $statuses[$sid];
$title = $feedback['title'];
$table = new OTSTable(short_text($title, 75));
$table->set_attribute('style', 'margin-bottom: 7px;');
$column = $table->get_rows(0)->get_columns(1);
$column->add_icon($image_path . $status . '_tiny.png', 'left', ucwords($status));
if($feedback['locked'])
$column->add_icon($image_path . 'locked_tiny.png', 'right', 'Locked');
$response = $feedback['response'];
if($response)
$column->add_icon($image_path . 'response.png', 'left', 'Response received');
$row = $table->add_row();
$row->set_default_attribute('align', 'center');
$column = $row->add_column('<b>' . ucwords($types[$feedback['type']]) . '</b>');
$column->set_attribute('width', 120);
$column = $row->add_column('<span title="' . long2ip($feedback['ip']) . '">' . $name . '</span>');
$column = $row->add_column('<span style="font-style: italic; font-size: 11px;">' . date("Y-m-d H:i:s", $feedback['time']) . '</span>');
$column->set_attribute('width', 140);
$row = $table->add_row();
$column = $row->add_column($text);
$column->set_attribute('style', 'padding: 15px; font: normal 11px verdana;');
if($response) {
$response = htmlspecialchars($response);
$response = stripslashes($response);
$response = nl2br($response);
$row = $table->add_row();
$column = $row->add_column('<span style="color: red;"><i>' . $response . '</i></span>');
$column->set_attribute('style', 'padding: 15px; font: normal 11px verdana;');
}
write('</table>');
return $table;
}
static function show_short($id) {
if(!$feedback = Feedback::get($id))
return false;
$title = $feedback['title'];
$title = htmlentities($title);
global $i, $image_path;
$types = $GLOBALS['types'] + $GLOBALS['disabledTypes'];
$row = new OTSRow;
$column = $row->add_column(ucwords($types[$feedback['type']]));
$column->set_attribute('width', 110);
$column->set_attribute('align', 'center');
$column = $row->add_column('<a title="' . $title . '" href="' . get_location(true) . '&id=' . $feedback['id'] . '">' . short_text($title, 50) . '</a>');
$column->set_attribute('align', 'center');
if(strlen($feedback['response']) > 0)
$column->add_icon($image_path . 'response.png', 'left', 'Response received');
$column = $row->add_column('<span style="font-style: italic; font-size: 11px;">' . date("Y-m-d", $feedback['time']) . '</span>');
$column->set_attribute('width', 90);
$column->set_attribute('align', 'center');
return $row;
}
}
write('<span class="header"></span>');
if($group_id_of_acc_logged >= $config['site']['access_admin_panel']) {
write('
<b><center>This is the Administrator Panel for the Feedbacks.</center></b>
<br /><br />
');
if(isset($_SESSION['write'])) {
write('<i>' . $_SESSION['write'] . '</i><br /><br />');
unset($_SESSION['write']);
}
if(isset($_GET['id'])) {
$fid = (int)$_GET['id'];
if($table = Feedback::show($fid)) {
$table->show();
$feedback = Feedback::get($fid);
write('<form action="' . get_location() . '" method="post">');
$responseTable = new OTSTable('Response');
$responseTable->set_attribute('style', 'margin-bottom: 7px;');
$row = $responseTable->add_row();
$column = $row->add_column('<textarea name="response" rows="6" cols="87">' . stripslashes($feedback['response']) . '</textarea>');
$column->set_attribute('align', 'center');
$row = $responseTable->add_row();
$row->add_column('<input type="submit" value="Save Response" />');
$responseTable->show();
write('</form><div style="border: 1px black solid;">');
$sid = $feedback['status'];
foreach($statuses as $id => $status)
if($id == $sid)
write('<img title="Status is currently: ' . ucwords($status) . '" src="' . $image_path . $status . '_small.png" /> ');
else
write('<a href="?subtopic=' . $_GET['subtopic'] . '&id=' . $fid . '&status=' . $id . '"><img title="Set status to: ' . ucwords($status) . '" src="' . $image_path . $status . '.png" /></a> ');
write('<a href="?subtopic=' . $_GET['subtopic'] . '&id=' . $fid . '&delete"><img style="position: relative; margin-left: 620px;" title="Delete permanently" src="' . $image_path . 'delete.png" /></a></div><br /><br /><br />');
if(isset($_GET['status'])) {
$status = (int)$_GET['status'];
if($statuses[$status]) {
Feedback::set_status($fid, $status);
$_SESSION['write'] = 'Status has successfully been changed to ' . $statuses[$status] . '!';
send_back(true);
}
} elseif(isset($_GET['delete'])) {
Feedback::delete($fid);
$_SESSION['write'] = 'Feedback has been deleted successfully and cannot be restored!';
send_back(true);
} elseif(isset($_POST['response'])) {
// Feedback::update($fid, 'response', $response);
$SQL->query('UPDATE `feedback` SET response = ' . $SQL->quote($_POST['response']) . ' WHERE `id` = ' . $fid . ';');
send_back();
}
} else
error('Invalid feedback ID!<br /><br />');
}
if(isset($_GET['toggle'])) {
$flag = pow(2, $_GET['toggle']);
if(($_SESSION['hid'] & $flag) == $flag)
$_SESSION['hid'] ^= $flag;
else
$_SESSION['hid'] |= $flag;
send_back();
}
$hidden = $_SESSION['hid'];
$table = new OTSTable;
foreach($statuses as $id => $status) {
$flag = pow(2, $id);
$hide = ($hidden & $flag) == $flag;
$row = $table->add_title_row('<b>' . ucwords($status) . ' Feedbacks</b>');
if(!$hide) {
$feedbacks = $SQL->query('SELECT `id` FROM `feedback` WHERE `status` = ' . $id . ' ORDER BY `time` DESC;');
foreach($feedbacks as $feedback)
$ret = $table->add_row(Feedback::show_short($feedback['id']));
if(!$ret) {
$row = $table->add_row();
$column = $row->add_column('<i>There are no ' . $status . ' feedbacks</i>');
$column->set_attribute('align', 'center');
}
}
$table->add_row(new Row)->add_column(new Column(''))->set_attribute('style', 'margin-bottom: 20px;');
}
$table->show();
} else {
write('
<b>Have you ever thought of a great feature that could be added to the game? <br />
Do you know anything that could be improved, or do you have any complaints on things that you dislike, or like less?<br />
Here is the right place to show us what you think should be changed or added!<br />
We wish all of our players to enjoy the game as much as possible. By sending us suggestions, we can make the gameplay more fun for our players!<br /><br />
If you have any complaint or bug report, please try to write as detailed as possible to ease the proccess of solving this issue.<br />
<u>DO NOT REPORT PLAYERS NOR COMPLAIN ON A BANISHMENT HERE!</u></b><br /><br />
');
$longip = ip2long($_SERVER['REMOTE_ADDR']);
$today_feedbacks = $SQL->query('SELECT COUNT(`id`) AS `count` FROM `feedback` WHERE `ip` = ' . $longip . ' AND `time` > ' . (time() - $send_interval) . ';')->fetch();
$today_count = $today_feedbacks['count'];
if($today_count >= $send_amount)
error('You have already sent ' . $send_amount . ' feedbacks today. We highly appreciate it, but to avoid spam we have limited the max amount of messages per day.');
else {
write('
By writing your characters name in the text field (or select it from the list if you are logged into your account), we might reward you for the feedback, depending on how much we need/like it.
<br /><br />
');
$table = new OTSTable('Available BBCode');
$table->set_attribute('width', 350);
foreach($tags as $tag) {
$row = $table->add_row();
$row->add_column('[' . $tag . ']the text[/' . $tag . ']');
$column = $row->add_column('<' . $tag . '>the text</' . $tag . '>');
$column->set_attribute('width', 100);
}
$table->show();
write('<br /><br />');
if(isset($_POST['type'])) {
$type = (int)$_POST['type'];
if($types[$type]) {
$title = $_POST['title'];
if(strlen($title) >= $min_title_length) {
$text = $_POST['text'];
if(strlen($text) >= $min_text_length) {
$name = $_POST['name'];
if(!empty($name)) {
if(check_name($name)) {
$self = !$_POST['self'] ? 0 : 1;
if($self)
if($logged) {
$characters = $account_logged->getPlayersList();
foreach($characters as $character)
if($character->getName() == $name) {
$found = true;
break;
}
if(!$found)
error('Character does not exist in your account!');
} else
error('An unexpected error has occured.');
} else
error('Invalid character name.');
}
if(!isset($ERROR)) {
$title = short_text($title, $max_title_length);
$feedback = array(
"type" => $type,
'title' => $title,
'text' => $text,
'name' => $name,
'self' => $self,
'time' => time()
);
if((int)$_POST['preview'] == 1)
Feedback::show($feedback)->show();
else {
$_SESSION['feedback'] = $feedback;
send_back();
}
}
} else
error('Text must consist of at least ' . $min_text_length . ' characters.');
} else
error('Title must consist of at least ' . $min_title_length . ' characters.');
} else
error('Invalid feedback type.');
write('<br /><br />');
} elseif(isset($_SESSION['feedback'])) {
$feedback = $_SESSION['feedback'];
$title = $SQL->quote($feedback['title']);
$text = $SQL->quote($feedback['text']);
$name = $feedback['name'];
if(strlen($name) > 0)
$name = $SQL->quote($name);
$SQL->query('INSERT INTO `feedback` (`title`, `text`, `name`, `self`, `ip`, `time`, `type`) VALUES(' . $title . ', ' . $text . ', ' . $name . ', ' . $feedback['self'] . ', ' . $longip . ', ' . time() . ', ' . $feedback['type'] . ');');
unset($_SESSION['feedback']);
send_back();
}
$total_feedbacks = $SQL->query('SELECT COUNT(`id`) AS `count` FROM `feedback` WHERE `ip` = ' . $longip . ';')->fetch();
$total_count = max($total_feedbacks['count'], "0");
write('
<i>You have sent <b>' . $today_count . ' / ' . $send_amount . '</b> feedbacks today and <b>' . $total_count . '</b> in total.</i>
<form name="feedback" action="index.php?subtopic=' . $_GET['subtopic'] . '" method="post">
');
$table = new OTSTable('Feedback Form');
$row = $table->add_row();
$row->set_default_attribute('align', 'center');
$column = $row->add_column('Type: <select name="type">');
$column->set_attribute('width', 160);
foreach($types as $id => $type)
$column->put_text('<option ' . (isset($_POST['type']) && $_POST['type'] == $id ? 'selected' : '') . ' value="' . $id . '">' . ucwords($type) . '</option>');
$column->put_text('</select>');
$column = $row->add_column('Title: <input type="text" value="' . $_POST['title'] . '" size="40" name="title" />');
$column = $row->add_column('Character: ');
$column->set_attribute('width', 230);
$hasChar = false;
if($logged) {
$characters = $account_logged->getPlayersList();
$characters->orderBy('level');
if($characters->count() > 0) {
$hasChar = true;
$column->put_text('<select name="name" style="width: 135px;">');
foreach($characters as $character) {
$name = short_text($character->getName(), $max_name_length);
$column->put_text('<option value="' . $character->getName() . '">' . $name . '</option>');
}
$column->put_text('</select>');
}
}
if(!$hasChar)
$column->put_text('
<input type="text" value="' . $_POST['name'] . '" name="name" />
<input type="hidden" name="self" value="' . ($hasChar ? 1 : 0) . '"/>
');
$row = $table->add_row();
$column = $row->add_column('<textarea name="text" rows="20" cols="' . $textarea_cols . '">' . $_POST['text'] . '</textarea>');
$column->set_attribute('align', 'center');
$row = $table->add_row();
$column = $row->add_column('
<input type="hidden" name="preview" value="0" />
<input type="submit" value="Send Feedback" />
<input type="button" onclick="document.feedback.preview.value = 1; document.feedback.submit();" value="Preview" />
');
$column->set_attribute('width', 160);
$column->set_attribute('align', 'center');
$table->show();
write('</form><br /><br />');
if(isset($_GET['id'])) {
$fid = (int)$_GET['id'];
if($feedback = Feedback::get($fid))
if($feedback['ip'] == $longip && $table = Feedback::show($fid))
$table->show();
else
error('Invalid feedback ID!<br /><br />');
}
$feedbacks = $SQL->query('SELECT `id` FROM `feedback` WHERE `ip` = ' . $longip . ' ORDER BY time DESC;');
$table = new OTSTable('Your Feedbacks');
foreach($feedbacks as $feedback)
$table->add_row(Feedback::show_short($feedback['id']));
if($table->get_count() == 0)
$row = $table->add_row()->add_column('You have not sent any feedbacks.');
$table->show();
}
}
function send_back($ignoreID = false) {
header('location: ' . get_location($ignoreID));
}
function get_location($ignoreID = false) {
$location = '?subtopic=' . $_GET['subtopic'];
if(isset($_GET['id']) && !$ignoreID)
$location .= '&id=' . $_GET['id'];
return $location;
}