• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Gesior AAC] NICE CLASS + Feedback System

Now I get another error;

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND `time` > 1257545759' at line 1' in C:\xampp\htdocs\feedback.php:283 Stack trace: #0 C:\xampp\htdocs\feedback.php(283): PDO->query('SELECT COUNT(`i...') #1 C:\xampp\htdocs\index.php(202): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\feedback.php on line 283


Thanks
 
man could explain better how to put this in Gesior?
..did not understand anything where you have to put everything, you did not explain exactly where to put everything.

<_<
 
Same folder as feedback.php, just the normal folder...
 
man could explain better how to put this in Gesior?
..did not understand anything where you have to put everything, you did not explain exactly where to put everything.

<_<

Lol if you aren't able to figure that out you shouldn't even have an own website..
 
If he could explain better, where to put the codes, I would not be here asking ...
I'm not forced to guess where to put the files ;)
 
If he could explain better, where to put the codes, I would not be here asking ...
I'm not forced to guess where to put the files ;)

If he didn't write where to place them, you should atleast try to place them in the main (probably htdocs) folder.
 
yes .. was what I did, but I get an error

Fatal error: Class 'OTSTable' not found in D:\xampp\htdocs\ feedback.php on line 247

:S
 
yes .. was what I did, but I get an error

Fatal error: Class 'OTSTable' not found in D:\xampp\htdocs\ feedback.php on line 247

:S

Better tell that before spamming.

Add this in the feedback.php script (at the top, preferably).

PHP:
include('table.php');
 
of a help plz ..
is how it has to be the feedback.php?

HTML:
   <?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">Feedback</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?
        Do you know anything that could be improved, or do you have any complaints on things that you dislike, or like less?
        Here is the right place to show us what you think should be changed or added!
        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.
        <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;
}
?>


and the config-and-functions I put so ..

HTML:
<?PHP
// ###################### CONFIG ########################
//load page config file
$config['site'] = parse_ini_file('config/config.ini');
include('config/config.php');
//check install
if($config['site']['install'] != "no")
{
	header("Location: install.php");
	exit;
}
//load server config
$config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
if(isset($config['server']['mysqlHost']))
{
	//new (0.2.6+) ots config.lua file
	$mysqlhost = $config['server']['mysqlHost'];
	$mysqluser = $config['server']['mysqlUser'];
	$mysqlpass = $config['server']['mysqlPass'];
	$mysqldatabase = $config['server']['mysqlDatabase'];
}
elseif(isset($config['server']['sqlHost']))
{
	//old (0.2.4) ots config.lua file
	$mysqlhost = $config['server']['sqlHost'];
	$mysqluser = $config['server']['sqlUser'];
	$mysqlpass = $config['server']['sqlPass'];
	$mysqldatabase = $config['server']['sqlDatabase'];
}
$sqlitefile = $config['server']['sqliteDatabase'];
$passwordency = '';
if(strtolower($config['server']['useMD5Passwords']) == 'yes' || strtolower($config['server']['passwordType']) == 'md5')
	$passwordency = 'md5';
if(strtolower($config['server']['passwordType']) == 'sha1')
	$passwordency = 'sha1';
// loads #####POT mainfile#####
include('pot/OTS.php');
// PDO and POT connects to database
$ots = POT::getInstance();
if(strtolower($config['server']['sqlType']) == "mysql")
{
	//connect to MySQL database
	try
	{
		$ots->connect(POT::DB_MYSQL, array('host' => $mysqlhost, 'user' => $mysqluser, 'password' => $mysqlpass, 'database' => $mysqldatabase) );
	}
	catch(PDOException $error)
	{
	    echo 'Database error - can\'t connect to MySQL database. Possible reasons:<br>1. MySQL server is not running on host.<br>2. MySQL user, password, database or host isn\'t configured in: <b>'.$config['site']['server_path'].'config.lua</b> .<br>3. MySQL user, password, database or host is wrong.';
		exit;
	}
}
elseif(strtolower($config['server']['sqlType']) == "sqlite")
{
	//connect to SQLite database
	$link_to_sqlitedatabase = $config['site']['server_path'].$sqlitefile;
	try
	{
		$ots->connect(POT::DB_SQLITE, array('database' => $link_to_sqlitedatabase));
	}
	catch(PDOException $error)
	{
	    echo 'Database error - can\'t open SQLite database. Possible reasons:<br><b>'.$link_to_sqlitedatabase.'</b> - file isn\'t valid SQLite database.<br><b>'.$link_to_sqlitedatabase.'</b> - doesn\'t exist.<br><font color="red">Wrong PHP configuration. Default PHP does not work with SQLite databases!</font>';
		exit;
	}
}
else
{
	echo 'Database error. Unknown database type in <b>'.$config['site']['server_path'].'config.lua</b> . Must be equal to: "<b>mysql</b>" or "<b>sqlite</b>". Now is: "<b>'.strtolower($config['server']['sqlType']).'"</b>';
	exit;
}

$SQL = POT::getInstance()->getDBHandle();
$layout_name = "layouts/".$layout_name = $config['site']['layout'];;
$layout_ini = parse_ini_file($layout_name.'/layout_config.ini');
foreach($layout_ini as $key => $value)
	$config['site'][$key] = $value;
//###################### FUNCTIONS ######################
function isPremium($premdays, $lastday)
{
	return ($premdays - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $lastday))) - date("z", $lastday)) > 0);
}
//save config in ini file
function saveconfig_ini($config)
{
	$file = fopen("config/config.ini", "w");
	foreach($config as $param => $data)
	{
$file_data .= $param.' = "'.str_replace('"', '', $data).'"
';
	}
	rewind($file);
	fwrite($file, $file_data);
	fclose($file);
}
//return password to db
function password_ency($password)
{
	$ency = $GLOBALS['passwordency'];
	if($ency == 'sha1')
		return sha1($password);
	elseif($ency == 'md5')
		return md5($password);
	elseif($ency == '')
		return $password;
}
//delete player with name
function delete_player($name) {
	$SQL = $GLOBALS['SQL'];
	$player = new OTS_Player();
	$player->find($name);
	if($player->isLoaded()) {
		try { $SQL->query("DELETE FROM player_skills WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
		try { $SQL->query("DELETE FROM guild_invites WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
		try { $SQL->query("DELETE FROM player_items WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
		try { $SQL->query("DELETE FROM player_depotitems WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
		try { $SQL->query("DELETE FROM player_spells WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
		try { $SQL->query("DELETE FROM player_storage WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
		try { $SQL->query("DELETE FROM player_viplist WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
		try { $SQL->query("DELETE FROM player_deaths WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
		try { $SQL->query("DELETE FROM player_deaths WHERE killed_by = '".$player->getId()."';"); } catch(PDOException $error) {}
		$rank = $player->getRank();
		if(!empty($rank)) {
			$guild = $rank->getGuild();
			if($guild->getOwner()->getId() == $player->getId()) {
				$rank_list = $guild->getGuildRanksList();
				if(count($rank_list) > 0) {
					$rank_list->orderBy('level');
					foreach($rank_list as $rank_in_guild) {
						$players_with_rank = $rank_in_guild->getPlayersList();
						$players_with_rank->orderBy('name');
						$players_with_rank_number = count($players_with_rank);
						if($players_with_rank_number > 0) {
							foreach($players_with_rank as $player_in_guild) {
								$player_in_guild->setRank();
								$player_in_guild->save();
							}
						}
						$rank_in_guild->delete();
					}
					$guild->delete();
				}
			}
		}
		$player->delete();
		return TRUE;
	}
}

//delete guild with id
function delete_guild($id) {
	$guild = new OTS_Guild();
	$guild->load($id);
	if($guild->isLoaded()) {
		$rank_list = $guild->getGuildRanksList();
		if(count($rank_list) > 0) {
			$rank_list->orderBy('level');
			foreach($rank_list as $rank_in_guild) {
				$players_with_rank = $rank_in_guild->getPlayersList();
				if(count($players_with_rank) > 0) {
					foreach($players_with_rank as $player_in_guild) {
						$player_in_guild->setRank();
						$player_in_guild->save();
					}
				}
				$rank_in_guild->delete();
			}
		}
		$guild->delete();
		return TRUE;
	}
	else
		return FALSE;
}

//is it valid nick?
function check_name($name)//sprawdza name
{
  $temp = strspn("$name", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- [ ] '");
  if ($temp != strlen($name)) {
	return false;
  }
  else
  {
	$ok = "/[a-zA-Z ']{1,25}/";
	return (preg_match($ok, $name))? true: false;
  }
}

//is it valid nick?
function check_account_name($name)//sprawdza name
{
  $temp = strspn("$name", "QWERTYUIOPASDFGHJKLZXCVBNM0123456789");
  if ($temp != strlen($name))
	return false;
  if(strlen($name) > 32)
	return false;
  else
  {
	$ok = "/[A-Z0-9]/";
	return (preg_match($ok, $name))? true: false;
  }
}

//is it valid nick for new char?
function check_name_new_char($name)//sprawdza name
{
	$name_to_check = strtolower($name);
	//first word can't be:
	//names blocked:
	$names_blocked = array('gm','cm', 'god', 'tutor');
	$first_words_blocked = array('gm ','cm ', 'god ','tutor ', "'", '-');
	//name can't contain:
	$words_blocked = array('gamemaster', 'game master', 'game-master', "Game'Master", '--', "''","' ", " '", '- ', ' -', "-'", "'-", 'fuck', 'sux', 'suck', 'noob', 'tutor');
	foreach($first_words_blocked as $word)
		if($word == substr($name_to_check, 0, strlen($word)))
			return false;
	if(substr($name_to_check, -1) == "'" || substr($name_to_check, -1) == "-")
		return false;
	if(substr($name_to_check, 1, 1) == ' ')
		return false;
	if(substr($name_to_check, -2, 1) == " ")
		return false;
	foreach($names_blocked as $word)
		if($word == $name_to_check)
			return false;
	foreach($GLOBALS['config']['site']['monsters'] as $word)
		if($word == $name_to_check)
			return false;
	foreach($GLOBALS['config']['site']['npc'] as $word)
		if($word == $name_to_check)
			return false;
	for($i = 0; $i < strlen($name_to_check); $i++)
		if($name_to_check[$i-1] == ' ' && $name_to_check[$i+1] == ' ')
			return false;
	foreach($words_blocked as $word)
		if (!(strpos($name_to_check, $word) === false))
			return false;
	for($i = 0; $i < strlen($name_to_check); $i++)
		if($name_to_check[$i] == $name_to_check[($i+1)] && $name_to_check[$i] == $name_to_check[($i+2)])
			return false;
	for($i = 0; $i < strlen($name_to_check); $i++)
		if($name_to_check[$i-1] == ' ' && $name_to_check[$i+1] == ' ')
			return false;
	$temp = strspn("$name", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- '");
	if ($temp != strlen($name))
		return false;
	else
	{
		$ok = "/[a-zA-Z ']{1,25}/";
		return (preg_match($ok, $name))? true: false;
	}
}

//is rank name valid?
function check_rank_name($name)//sprawdza name
{
  $temp = strspn("$name", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789-[ ] ");
  if ($temp != strlen($name)) {
	return false;
  }
  else
  {
	$ok = "/[a-zA-Z ]{1,60}/";
	return (preg_match($ok, $name))? true: false;
  }
}
//is guild name valid?
function check_guild_name($name)
{
  $temp = strspn("$name", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789- ");
  if ($temp != strlen($name)) {
	return false;
  }
  else
  {
	$ok = "/[a-zA-Z ]{1,60}/";
	return (preg_match($ok, $name))? true: false;
  }
}
//is it valid password?
function check_password($pass)//sprawdza haslo
{
  $temp = strspn("$pass", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890");
  if ($temp != strlen($pass)) {
  return false;
  }
  else
  {
  $ok = "/[a-zA-Z0-9]{1,40}/";
  return (preg_match($ok, $pass))? true: false;
  }
}
//is it valid e-mail?
function check_mail($email)//sprawdza mail
{
  $ok = "/[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}/";
  return (preg_match($ok, $email))? true: false;
}

//################### DISPLAY FUNCTIONS #####################
//return shorter text (news ticker)
function short_text($text, $chars_limit) 
{
  if (strlen($text) > $chars_limit) 
    return substr($text, 0, strrpos(substr($text, 0, $chars_limit), " ")).'...';
  else return $text;
}
//return text to news msg
function news_place() {
if($GLOBALS['subtopic'] == "latestnews") {
//add tickers to site - without it tickers will not be showed
//$news .= $GLOBALS['news_content'];
/*
//featured article
$layout_name = $GLOBALS['layout_name'];
$news .= '  <div id="featuredarticle" class="Box">
    <div class="Corner-tl" style="background-image:url('.$layout_name.'/images/content/corner-tl.gif);"></div>
    <div class="Corner-tr" style="background-image:url('.$layout_name.'/images/content/corner-tr.gif);"></div>
    <div class="Border_1" style="background-image:url('.$layout_name.'/images/content/border-1.gif);"></div>
    <div class="BorderTitleText" style="background-image:url('.$layout_name.'/images/content/title-background-green.gif);"></div>
    <img class="Title" src="'.$layout_name.'/images/strings/headline-featuredarticle.gif" alt="Contentbox headline" />
    <div class="Border_2">
      <div class="Border_3">
        <div class="BoxContent" style="background-image:url('.$layout_name.'/images/content/scroll.gif);">
<div id=\'TeaserThumbnail\'><img src="'.$layout_name.'/images/news/features.jpg" width=150 height=100 border=0 alt="" /></div><div id=\'TeaserText\'><div style="position: relative; top: -2px; margin-bottom: 2px;" >
<b>Tutaj wpisz tytul</b></div>
tutaj wpisz tresc newsa<br>
zdjecie laduje sie w <i>tibiacom/images/news/features.jpg</i><br>
skad sie laduje mozesz zmienic linijke ponad komentarzem
</div>        </div>
      </div>
    </div>
    <div class="Border_1" style="background-image:url('.$layout_name.'/images/content/border-1.gif);"></div>
    <div class="CornerWrapper-b"><div class="Corner-bl" style="background-image:url('.$layout_name.'/images/content/corner-bl.gif);"></div></div>
    <div class="CornerWrapper-b"><div class="Corner-br" style="background-image:url('.$layout_name.'/images/content/corner-br.gif);"></div></div>
  </div>';
 */
}
return $news;
}
//set monster of week
function logo_monster() {
	return str_replace(" ", "", trim(mb_strtolower($GLOBALS['layout_ini']['logo_monster'])));
}
$statustimeout = 1;
foreach(explode("*", str_replace(" ", "", $config['server']['statusTimeout'])) as $status_var)
	if($status_var > 0)
		$statustimeout = $statustimeout * $status_var;
$statustimeout = $statustimeout / 1000;
$config['status'] = parse_ini_file('config/serverstatus');
if($config['status']['serverStatus_lastCheck']+$statustimeout < time())
{
	$config['status']['serverStatus_checkInterval'] = $statustimeout+3;
	$config['status']['serverStatus_lastCheck'] = time();
	$info = chr(6).chr(0).chr(255).chr(255).'info';
	$sock = @fsockopen("127.0.0.1", $config['server']['statusPort'], $errno, $errstr, 1);
	if ($sock)
	{
		fwrite($sock, $info); 
		$data=''; 
		while (!feof($sock))
			$data .= fgets($sock, 1024);
		fclose($sock);
		preg_match('/players online="(\d+)" max="(\d+)"/', $data, $matches);
		$config['status']['serverStatus_online'] = 1;
		$config['status']['serverStatus_players'] = $matches[1];
		$config['status']['serverStatus_playersMax'] = $matches[2];
		preg_match('/uptime="(\d+)"/', $data, $matches);
		$h = floor($matches[1] / 3600);
		$m = floor(($matches[1] - $h*3600) / 60);
		$config['status']['serverStatus_uptime'] = $h.'h '.$m.'m';
		preg_match('/monsters total="(\d+)"/', $data, $matches);
		$config['status']['serverStatus_monsters'] = $matches[1];
	}
	else
	{
		$config['status']['serverStatus_online'] = 0;
		$config['status']['serverStatus_players'] = 0;
		$config['status']['serverStatus_playersMax'] = 0;
	}
	$file = fopen("config/serverstatus", "w");
	foreach($config['status'] as $param => $data)
	{
$file_data .= $param.' = "'.str_replace('"', '', $data).'"
';
	}
	rewind($file);
	fwrite($file, $file_data);
	fclose($file);
}

//PAGE VIEWS COUNTER :)
$views_counter = "usercounter.dat";
// checking if the file exists
if (file_exists($views_counter)) {
    // het bestand bestaat, waarde + 1
    $actie = fopen($views_counter, "r+"); 
    $page_views = fgets($actie, 9); 
    $page_views++; 
    rewind($actie); 
    fputs($actie, $page_views, 9); 
    fclose($actie); 
}
else
{ 
    // the file doesn't exist, creating a new one with value 1
    $actie = fopen($views_counter, "w"); 
    $page_views = 1; 
    fputs($actie, $page_views, 9); 
    fclose($actie); 
} 
function makeOrder($arr, $order, $default) {
    // Function by Colandus!
    $type = 'asc';
    if(isset($_GET['order'])) {
        $v = explode('_', strrev($_GET['order']), 2);
        if(count($v) == 2)
            if($orderBy = $arr[strrev($v[1])])
                $default = $orderBy;
                $type = (strrev($v[0]) == 'asc' ? 'desc' : 'asc');
    }
    
    return 'ORDER BY ' . $default . ' ' . $type;
}

function getOrder($arr, $order, $this) {
    // Function by Colandus!
    $type = 'asc';
    if($orderBy = $arr[$this])
        if(isset($_GET[$order])) {
            $v = explode('_', strrev($_GET[$order]), 2);
            if(strrev($v[1]) == $this)
                $type = (strrev($v[0]) == 'asc' ? 'desc' : 'asc');
        }
    
    return $this . '_' . $type;
}  

function write($text) {
    $GLOBALS['main_content'] .= $text;
}

function error($text, $return = null) {
    $err = '<span style="color: red; font-style: italic;">' . $text . '</span>';
    $GLOBALS['ERROR'] = $err;

    if($return === true)
        return $err;
    elseif($return === null)
        write($err);
}

function get_title_color() {
    return $GLOBALS['config']['site']['vdarkborder'];
}

function get_color($set = false) {
    static $i = 0;
    if($set !== false)
        $i = $set;
    return $GLOBALS['config']['site'][($i++ % 2 ? 'light' : 'dark') . 'border'];
}
?>

and received this error:
Fatal error: Call to undefined function write () in D:\ xampp\htdocs\feedback.php on line 172 :(
 
man thx for this.. more could you change it a little, so that one must have an account and logged with a character in it. because if it is the way it is someone can pretend to be someone else give is complicated ... please if you can do that will better the code :thumbup:

/badenglish :(
 
Back
Top