• 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] Guild statisctic + extras

Bump great script use it :) Help people to sort fast informations
 
Can't edit above post

My part of guild.php which should I change:
//show guild page
if($action == 'show')
{
$guild_name = $_REQUEST['guild'];
if(!check_guild_name($guild_name))
$guild_errors[] = 'Invalid guild name format.';
if(empty($guild_errors))
{
$guild = $ots->createObject('Guild');
$guild->find($guild_name);
if(!$guild->isLoaded())
$guild_errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
}
if(!empty($guild_errors))
{
//show errors
$main_content .= '<div class="SmallBox" > <div class="MessageContainer" > <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div> <div class="BoxFrameEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div> <div class="BoxFrameEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div> <div class="ErrorMessage" > <div class="BoxFrameVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div> <div class="BoxFrameVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div> <div class="AttentionSign" style="background-image:url('.$layout_name.'/images/content/attentionsign.gif);" /></div><b>The Following Errors Have Occurred:</b><br/>';
foreach($guild_errors as $guild_error)
$main_content .= '<li>'.$guild_error;
//errors and back button
$main_content .= '</div> <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div> <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div> <div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div> </div></div><br/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="index.php?subtopic=guilds" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
}
else
{
//check is it vice or/and leader account (leader has vice + leader rights)
$guild_leader_char = $guild->getOwner();
$rank_list = $guild->getGuildRanksList();
$rank_list->orderBy('level', POT::ORDER_DESC);
$guild_leader = FALSE;
$guild_vice = FALSE;
if($logged)
{
$account_players = $account_logged->getPlayers();
foreach($account_players as $player)
{
$players_from_account_ids[] = $player->getId();
$player_rank = $player->getRank();
if(!empty($player_rank))
{
foreach($rank_list as $rank_in_guild)
{
if($rank_in_guild->getId() == $player_rank->getId())
{
$players_from_account_in_guild[] = $player->getName();
if($player_rank->getLevel() > 1)
{
$guild_vice = TRUE;
$level_in_guild = $player_rank->getLevel();
}
if($guild->getOwner()->getId() == $player->getId())
{
$guild_vice = TRUE;
$guild_leader = TRUE;
}
}
}
}
}
}
//show guild page
$guild_logo = $guild->getCustomField('logo_gfx_name');
if(empty($guild_logo) || !file_exists("guilds/".$guild_logo))
$guild_logo = "default_logo.gif";
$description = $guild->getCustomField('description');
$newlines = array("\r\n", "\n", "\r");
$description_with_lines = str_replace($newlines, '<br />', $description, $count);
if($count < $config['site']['guild_description_lines_limit'])
$description = $description_with_lines;
$guild_owner = $guild->getOwner();
if($guild_owner->isLoaded())
$guild_owner = $guild_owner->getName();
$main_content .= '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR>
<TD><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD><TD>
<TABLE BORDER=0 WIDTH=100%>
<TR><TD WIDTH=64><IMG SRC="guilds/'.$guild_logo.'" WIDTH=64 HEIGHT=64></TD>
<TD ALIGN=center WIDTH=100%><H1>'.$guild->getName().'</H1></TD>
<TD WIDTH=64><IMG SRC="guilds/'.$guild_logo.'" WIDTH=64 HEIGHT=64></TD></TR>
</TABLE><BR>'.$description.'<BR><BR><a href="index.php?subtopic=characters&name='.$guild_owner.'"><b>'.$guild_owner.'</b></a> is guild leader of <b>'.$guild->getName().'</b>.<BR>The guild was founded on '.$config['server']['serverName'].' on '.date("j F Y", $guild->getCreationData()).'.';
if($guild_leader)
$main_content .= '&nbsp;&nbsp;&nbsp;<a href="index.php?subtopic=guilds&action=manager&guild='.$guild->getName().'"><IMG SRC="http://i63.photobucket.com/albums/h122/Mister_Dude/sbutton_manageguild.png" BORDER=0 WIDTH=120 HEIGHT=18 alt="Manage Guild"></a>';
$main_content .= '<BR><BR>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
<TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=3 CLASS=white><B>Guild Members</B></TD></TR>
<TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=30%><B>Rank</B></TD>
<TD WIDTH=70%><B>Name and Title</B></TD></TR>';
$showed_players = 1;
foreach($rank_list as $rank)
{
$players_with_rank = $rank->getPlayersList();
$players_with_rank->orderBy('name');
$players_with_rank_number = count($players_with_rank);
if($players_with_rank_number > 0)
{
if(is_int($showed_players / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $showed_players++;
$main_content .= '<TR BGCOLOR="'.$bgcolor.'"><TD valign="top">'.$rank->getName().'</TD>
<TD><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>';
foreach($players_with_rank as $player)
{
$main_content .= '<TR><TD><FORM ACTION="index.php?subtopic=guilds&action=change_nick&name='.$player->getName().'" METHOD=post><A HREF="index.php?subtopic=characters&name='.$player->getName().'">'.$player->getName().'</A>';
$guild_nick = $player->getGuildNick();
if($logged)
{
if(in_array($player->getId(), $players_from_account_ids))
$main_content .= ' (<input type="text" name="nick" value="'.htmlentities($player->getGuildNick()).'"><input type="submit" value="Change">)';
else
{
if(!empty($guild_nick))
$main_content .= ' ('.htmlentities($player->getGuildNick()).')';
}
}
else
if(!empty($guild_nick))
$main_content .= ' ('.htmlentities($player->getGuildNick()).')';
if($level_in_guild > $rank->getLevel() || $guild_leader)
if($guild_leader_char->getName() != $player->getName())
$main_content .= '&nbsp;<font size=1>{<a href="index.php?subtopic=guilds&action=kickplayer&guild='.urlencode($guild->getName()).'&name='.urlencode($player->getName()).'">KICK</a>}</font>';
$main_content .= '</FORM></TD></TR>';
}
$main_content .= '</TABLE></TD></TR>';
}
}
$main_content .= '</TABLE>';
 
Omg, try next time use
http://otland.net/f16/proper-tagging-110327/

Try use this:
PHP:
//show guild page
if($action == 'show')
{
    $guild_id = (int) $_REQUEST['guild'];
    $guild_name = $guild_id;
    $guild = $ots->createObject('Guild');
    $guild->load($guild_id);
    if(!$guild->isLoaded())
        $guild_errors[] = 'Guild with ID <b>'.$guild_id.'</b> doesn\'t exist.';
    if(!empty($guild_errors))
    {
        //show errors
        $main_content .= '<div class="SmallBox" >  <div class="MessageContainer" >    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="ErrorMessage" >      <div class="BoxFrameVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="BoxFrameVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="AttentionSign" style="background-image:url('.$layout_name.'/images/content/attentionsign.gif);" /></div><b>The Following Errors Have Occurred:</b><br/>';
        foreach($guild_errors as $guild_error)
            $main_content .= '<li>'.$guild_error;
        //errors and back button
        $main_content .= '</div>    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>  </div></div><br/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
    }
    else
    {
        //check is it vice or/and leader account (leader has vice + leader rights)
        $guild_leader_char = $guild->getOwner();
        $rank_list = $guild->getGuildRanksList();
        $rank_list->orderBy('level', POT::ORDER_DESC);
        $guild_leader = FALSE;
        $guild_vice = FALSE;
        if($logged)
        {
            $account_players = $account_logged->getPlayers();
            foreach($account_players as $player)
            {
                $players_from_account_ids[] = $player->getId();
                $player_rank = $player->getRank();
                if(!empty($player_rank))
                    foreach($rank_list as $rank_in_guild)
                        if($rank_in_guild->getId() == $player_rank->getId())
                        {
                            $players_from_account_in_guild[] = $player->getName();
                            if($player_rank->getLevel() > 1)
                            {
                                $guild_vice = TRUE;
                                $level_in_guild = $player_rank->getLevel();
                            }
                            if($guild->getOwner()->getId() == $player->getId())
                            {
                                $guild_vice = TRUE;
                                $guild_leader = TRUE;
                            }
                        }
            }
        }
        //show guild page
        $guild_logo = $guild->getCustomField('logo_gfx_name');
        if(empty($guild_logo) || !file_exists("guilds/".$guild_logo))
            $guild_logo = "default_logo.gif";
        $description = $guild->getCustomField('description');
        $newlines   = array("\r\n", "\n", "\r");
        $description_with_lines = str_replace($newlines, '<br />', $description, $count);
        if($count < $config['site']['guild_description_lines_limit'])
            $description = $description_with_lines;
        $guild_owner = $guild->getOwner();
        if($guild_owner->isLoaded())
            $guild_owner = $guild_owner->getName();
        $main_content .= '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR>
        <TD><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD><TD>
        <TABLE BORDER=0 WIDTH=100%>
        <TR><TD WIDTH=64><IMG SRC="guilds/'.$guild_logo.'" WIDTH=64 HEIGHT=64></TD>
        <TD ALIGN=center WIDTH=100%><H1>'.$guild->getName().'</H1></TD>
        <TD WIDTH=64><IMG SRC="guilds/'.$guild_logo.'" WIDTH=64 HEIGHT=64></TD></TR>
        </TABLE><BR>'.$description.'<BR><BR><a href="?subtopic=characters&name='.urlencode($guild_owner).'"><b>'.$guild_owner.'</b></a> is guild leader of <b>'.$guild->getName().'</b>.<BR>The guild was founded on '.$config['server']['serverName'].' on '.date("j F Y", $guild->getCreationData()).'.';
        if($guild_leader)
            $main_content .= '&nbsp;&nbsp;&nbsp;<a href="?subtopic=guilds&action=manager&guild='.$guild_name.'"><IMG SRC="'.$layout_name.'/images/buttons/sbutton_manageguild.png" BORDER=0 WIDTH=120 HEIGHT=18 alt="Manage Guild"></a>';
        $main_content .= '<BR><BR>
        <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
        <TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=3 CLASS=white><B>Guild Members</B></TD></TR>
        <TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=30%><B>Rank</B></TD>
        <TD WIDTH=70%><B>Name and Title</B></TD></TR>';
        $showed_players = 1;
        foreach($rank_list as $rank)
        {
            $players_with_rank = $rank->getPlayersList();
            $players_with_rank->orderBy('name');
            $players_with_rank_number = count($players_with_rank);
            if($players_with_rank_number > 0)
            {
                if(is_int($showed_players / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $showed_players++;
                $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><TD valign="top">'.$rank->getName().'</TD>
                <TD><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>';
                foreach($players_with_rank as $player)
                {
$main_content .= '';
                    $main_content .= '<TR><TD><FORM ACTION="?subtopic=guilds&action=change_nick&name='.urlencode($player->getName()).'" METHOD=post><A HREF="?subtopic=characters&name='.urlencode($player->getName()).'">'.($player->isOnline() ? "<font color=\"green\">".$player->getName()."</font>" : "<font color=\"red\">".$player->getName()."</font>").'</A> <br><small>Level: '.$player->getLevel().' '.$vocation_name[$player->getWorld()][$player->getPromotion()][$player->getVocation()].'</small>';
                    $guild_nick = $player->getGuildNick();
                    if($logged)
                        if(in_array($player->getId(), $players_from_account_ids))
                            $main_content .= '(<input type="text" name="nick" value="'.htmlentities($player->getGuildNick()).'"><input type="submit" value="Change">)';
                        else
                        if(!empty($guild_nick))
                            $main_content .= ' ('.htmlentities($player->getGuildNick()).')';
                    else
                        if(!empty($guild_nick))
                            $main_content .= ' ('.htmlentities($player->getGuildNick()).')';
                    if($level_in_guild > $rank->getLevel() || $guild_leader)
                        if($guild_leader_char->getName() != $player->getName())
                            $main_content .= '&nbsp;<font size=1>{<a href="?subtopic=guilds&action=kickplayer&guild='.$guild->getId().'&name='.urlencode($player->getName()).'">KICK</a>}</font>';
                    $main_content .= '</FORM></TD></TR>';
                }
                $main_content .= '</TABLE></TD></TR>';
            }
        }
        $main_content .= '</TABLE><br><br>';
        $guild_id = (int)$_GET['guild'];$guildMembers = $SQL->query( 'SELECT COUNT(`gr`.`id`) AS `total` FROM `players` AS `p` LEFT JOIN `guild_ranks` AS `gr` ON `gr`.`id` = `p`.`rank_id` WHERE `gr`.`guild_id` = '.$guild_id )->fetch( );$allM = $SQL->query ('SELECT COUNT(1) as `people` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') AND online = 1')->fetch(); $allM1 = $SQL->query ('SELECT SUM(`level`) as `level` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') ')->fetch(); $allM2 = $SQL->query ('SELECT AVG(`level`) as `level` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') ')->fetch(); $allM3 = $SQL->query ('SELECT `name` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') ORDER BY `level` ASC LIMIT 1')->fetch(); $allM4 = $SQL->query ('SELECT `name` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') ORDER BY `level` DESC LIMIT 1')->fetch(); $invite = $SQL->query( 'SELECT COUNT(*) FROM `guild_invites` WHERE `guild_id` = '.$guild_id.'')->fetch( );                        $main_content .= '<table width="100%" cellspacing="1" cellpadding="4" border="0">        <tbody><tr bgcolor="#505050"><td class="white" colspan="3"><b>Guild Statistic</b></td></tr>        <tr bgcolor="#d4c0a1"><td width="30%"><b>Type</b></td>        <td width="50%"><b>Value</b></td></tr><tr bgcolor="#f1e0c6">                <td valign="top">Number of Members in Guild</td>        <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.$guildMembers['total'].'</td></tr></tbody></table>        </td></tr>                <tr bgcolor="#d4c0a1"><td valign="top">Number of Members Online in Guild</td>                <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.$allM[0].'</td></tr></tbody></table>        </td></tr>                <td valign="top">Total Level in guild</td>        <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.$allM1[0].'</td></tr></tbody></table>        </td></tr>                <tr bgcolor="#d4c0a1"><td valign="top">Avg Level in guild</td>                <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.round($allM2[0]).'</td></tr></tbody></table>        </td></tr>                <td valign="top">Lowest Level in guild</td>        <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.$allM3[0].'</td></tr></tbody></table>        </td></tr>                <tr bgcolor="#d4c0a1"><td valign="top">Highest Level in guild</td>                <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.$allM4[0].'</td></tr></tbody></table>        </td></tr>                <tr bgcolor="#f1e0c6"><td valign="top">Number of Invited Members</td>                <td><table width="100%" cellspacing="0" cellpadding="0" border="0">        <tbody><tr><td>'.$invite[0].'</td></tr></tbody></table>        </td></tr>        </table>';  
		include('pot/InvitesDriver.php');
		new InvitesDriver($guild);
		$invited_list = $guild->listInvites();
		if(count($invited_list) == 0)
			$main_content .= '<BR><BR><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=2 CLASS=white><B>Invited Characters</B></TD></TR><TR BGCOLOR='.$config['site']['lightborder'].'><TD>No invited characters found.</TD></TR></TABLE>';
		else
		{
			$main_content .= '<BR><BR><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=2 CLASS=white><B>Invited Characters</B></TD></TR>';
			$show_accept_invite = 0;
			$showed_invited = 1;
			foreach($invited_list as $invited_player)
			{
				if(count($account_players) > 0)
					foreach($account_players as $player_from_acc)
						if($player_from_acc->getName() == $invited_player->getName())
							$show_accept_invite++;
				if(is_int($showed_invited / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $showed_invited++;
				$main_content .= '<TR bgcolor="'.$bgcolor.'"><TD><a href="?subtopic=characters&name='.urlencode($invited_player->getName()).'">'.$invited_player->getName().'</a>';
				if($guild_vice)
					$main_content .= '  (<a href="?subtopic=guilds&action=deleteinvite&guild='.$guild_name.'&name='.$invited_player->getName().'">Cancel Invitation</a>)';
				$main_content .= '</TD></TR>'; 
			}
			$main_content .= '</TABLE>';
		}
		$main_content .= '<BR><BR>
		<TABLE BORDER=0 WIDTH=100%><TR><TD ALIGN=center><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD>';
		if(!$logged)
			$main_content .= '<TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=login&guild='.$guild_name.'&redirect=guild" METHOD=post><TR><TD>
			<INPUT TYPE=image NAME="Login" ALT="Login" SRC="'.$layout_name.'/images/buttons/sbutton_login.gif" BORDER=0 WIDTH=120 HEIGHT=18>
			</TD></TR></FORM></TABLE></TD>';
		else
		{
			if($show_accept_invite > 0)
				$main_content .= '<TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=acceptinvite&guild='.$guild_name.'" METHOD=post><TR><TD>
				<INPUT TYPE=image NAME="Accept Invite" ALT="Accept Invite" SRC="'.$layout_name.'/images/buttons/sbutton_acceptinvite.png" BORDER=0 WIDTH=120 HEIGHT=18>
				</TD></TR></FORM></TABLE></TD>';
			if($guild_vice)
			{
				$main_content .= '<TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=invite&guild='.$guild_name.'" METHOD=post><TR><TD>
				<INPUT TYPE=image NAME="Invite Player" ALT="Invite Player" SRC="'.$layout_name.'/images/buttons/sbutton_inviteplayer.png" BORDER=0 WIDTH=120 HEIGHT=18>
				</TD></TR></FORM></TABLE></TD>';
				$main_content .= '<TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=changerank&guild='.$guild_name.'" METHOD=post><TR><TD>
				<INPUT TYPE=image NAME="Change Rank" ALT="Change Rank" SRC="'.$layout_name.'/images/buttons/sbutton_changerank.png" BORDER=0 WIDTH=120 HEIGHT=18>
				</TD></TR></FORM></TABLE></TD>';
			}
			if($players_from_account_in_guild > 0)
				$main_content .= '<TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=leaveguild&guild='.$guild_name.'" METHOD=post><TR><TD>
				<INPUT TYPE=image NAME="Leave Guild" ALT="Leave Guild" SRC="'.$layout_name.'/images/buttons/sbutton_leaveguild.png" BORDER=0 WIDTH=120 HEIGHT=18>
				</TD></TR></FORM></TABLE></TD>';
		}
		$main_content .= '<TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&world='.$guild->getWorld().'" METHOD=post><TR><TD>
		<INPUT TYPE=image NAME="Back" ALT="Back" SRC="'.$layout_name.'/images/buttons/sbutton_back.gif" BORDER=0 WIDTH=120 HEIGHT=18>
		</TD></TR></FORM></TABLE>
		</TD><TD ALIGN=center><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD></TR></TABLE>
		</TD><TD><IMG src="'.$layout_name.'/images/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD>
		</TR></TABLE></TABLE>';
	}
}

//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------
//change rank of player in guild
 
I replaced and:

Code:
Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\guilds.php on line 31

Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\guilds.php on line 37

Fatal error: Call to a member function fetch() on a non-object in D:\xampp\htdocs\pot\OTS_Base_List.php on line 247
 
OTS_Base_List.php
PHP:
<?php

/**#@+
 * @version 0.0.5
 * @since 0.0.5
 */

/**
 * @package POT
 * @version 0.1.5
 * @author Wrzasq <[email protected]>
 * @copyright 2007 - 2008 (C) by Wrzasq
 * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3
 * @todo future: Iterator classes (to map id => name iterations) with tutorial.
 * @todo 0.2.0: Use fetchObject() to reduce amount of SQL queries.
 */

/**
 * Basic list class routines.
 * 
 * <p>
 * This class defines entire lists mechanism for classes that represents records set from OTServ database. All child classes only have to define {@link OTS_Base_List::init() init() method} to set table info for queries.
 * </p>
 * 
 * <p>
 * Table on which list will operate has to contain integer <var>"id"</var> field and single row representing class has to support loading by this filed as key.
 * </p>
 * 
 * <p>
 * This class is mostly usefull when you create own extensions for POT code.
 * </p>
 * 
 * @package POT
 * @version 0.1.5
 * @property-write int $limit Sets LIMIT clause.
 * @property-write int $offset Sets OFFSET clause.
 * @property-write OTS_SQLFilter $filter Sets filter for list SQL query.
 */
abstract class OTS_Base_List implements IOTS_DAO, Iterator, Countable
{
/**
 * Database connection.
 * 
 * @var PDO
 * @version 0.1.5
 */
    protected $db;

/**
 * Limit for SELECT query.
 * 
 * @var int
 */
    private $limit = false;

/**
 * Offset for SELECT query.
 * 
 * @var int
 */
    private $offset = false;

/**
 * WHERE clause filter.
 * 
 * @var OTS_SQLFilter
 */
    private $filter = null;

/**
 * List of sorting criteriums.
 * 
 * @var array
 */
    private $orderBy = array();

/**
 * Query results.
 * 
 * @var array
 * @version 0.1.5
 */
    protected $rows;

/**
 * Default table name for queries.
 * 
 * @var string
 */
    protected $table;

/**
 * Class of generated objects.
 * 
 * @var string
 */
    protected $class;

/**
 * Sets database connection handler.
 * 
 * @version 0.1.0
 */
    public function __construct()
    {
        $this->db = POT::getInstance()->getDBHandle();
        $this->init();
    }

/**
 * Sets list parameters.
 */
    abstract public function init();

/**
 * Magic PHP5 method.
 * 
 * <p>
 * Allows object serialisation.
 * </p>
 * 
 * @return array List of properties that should be saved.
 */
    public function __sleep()
    {
        return array('limit', 'offset', 'filter', 'orderBy', 'table', 'class');
    }

/**
 * Magic PHP5 method.
 * 
 * <p>
 * Allows object unserialisation.
 * </p>
 */
    public function __wakeup()
    {
        $this->db = POT::getInstance()->getDBHandle();
    }

/**
 * Magic PHP5 method.
 * 
 * <p>
 * Allows object importing from {@link http://www.php.net/manual/en/function.var-export.php var_export()}.
 * </p>
 * 
 * @version 0.1.3
 * @param array $properties List of object properties.
 */
    public static function __set_state($properties)
    {
        // deletes database handle
        if( isset($properties['db']) )
        {
            unset($properties['db']);
        }

        // initializes new object with current database connection
        $object = new self();

        // loads properties
        foreach($properties as $name => $value)
        {
            $object->$name = $value;
        }

        return $object;
    }

/**
 * Sets LIMIT clause.
 * 
 * <p>
 * Reduces amount of seleced rows up to given number.
 * </p>
 * 
 * @param int|bool $limit Limit for SELECT (false to reset).
 */
    public function setLimit($limit = false)
    {
        if( is_int($limit) )
        {
            $this->limit = $limit;
        }
        else
        {
            $this->limit = false;
        }
    }

/**
 * Sets OFFSET clause.
 * 
 * <p>
 * Moves starting rows of selected set to given position.
 * </p>
 * 
 * @param int|bool $offset Offset for SELECT (false to reset).
 */
    public function setOffset($offset = false)
    {
        if( is_int($offset) )
        {
            $this->offset = $offset;
        }
        else
        {
            $this->offset = false;
        }
    }

/**
 * Returns current row.
 * 
 * <p>
 * Returns object of class which handle single row representation. Object is initialised with ID of current position in result cursor.
 * </p>
 * 
 * @version 0.1.3
 * @return OTS_Base_DAO Current row.
 */
    public function current()
    {
        $id = current($this->rows);

        $class = 'OTS_' . $this->class;
        return new $class( (int) $id['id']);
    }

/**
 * Select rows from database.
 * 
 * @throws PDOException On PDO operation error.
 */
    public function rewind()
    {
        $this->rows = $this->db->query( $this->getSQL() )->fetchAll();
    }

/**
 * Moves to next row.
 */
    public function next()
    {
        next($this->rows);
    }

/**
 * Current cursor position.
 * 
 * @return mixed Array key.
 */
    public function key()
    {
        return key($this->rows);
    }

/**
 * Checks if there are any rows left.
 * 
 * @return bool Does next row exist.
 */
    public function valid()
    {
        return key($this->rows) !== null;
    }

/**
 * Returns number of rows on list in current criterium.
 * 
 * @version 0.1.5
 * @return int Number of rows.
 * @throws PDOException On PDO operation error.
 */
    public function count()
    {
        return $this->db->query( $this->getSQL(true) )->fetchColumn();
    }

/**
 * Sets filter on list.
 * 
 * <p>
 * Call without argument to reset filter.
 * </p>
 * 
 * @param OTS_SQLFilter|null $filter Filter for list.
 */
    public function setFilter(OTS_SQLFilter $filter = null)
    {
        $this->filter = $filter;
    }

/**
 * Clears ORDER BY clause.
 */
    public function resetOrder()
    {
        $this->orderBy = array();
    }

/**
 * Appends sorting rule.
 * 
 * <p>
 * First parameter may be of type string, then it will be used as literal field name, or object of {@link OTS_SQLField OTS_SQLField class}, then it's representation will be used as qualiffied SQL identifier name.
 * </p>
 * 
 * <p>
 * Note: Since 0.0.7 version <var>$field</var> parameter can be instance of {@link OTS_SQLField OTS_SQLField class}.
 * </p>
 * 
 * @version 0.0.7
 * @param OTS_SQLField|string $field Field name.
 * @param int $order Sorting order (ascending by default).
 */
    public function orderBy($field, $order = POT::ORDER_ASC)
    {
        // constructs field name filter
        if($field instanceof OTS_SQLField)
        {
            $table = $field->getTable();

            // full table name
            if( !empty($table) )
            {
                $table = $this->db->tableName($table) . '.';
            }

            $field = $table . $this->db->fieldName( $field->getName() );
        }
        // literal name
        else
        {
            $field = $this->db->fieldName($field);
        }

        $this->orderBy[] = array('field' => $field, 'order' => $order);
    }

/**
 * Returns SQL query for SELECT.
 * 
 * @version 0.1.5
 * @param bool $count Shows if the SQL should be generated for COUNT() variant.
 * @return string SQL query part.
 */
    protected function getSQL($count = false)
    {
        // fields list
        if($count)
        {
            $fields = 'COUNT(' . $this->db->tableName($this->table) . '.' . $this->db->fieldName('id') . ')';
        }
        else
        {
            $fields = $this->db->tableName($this->table) . '.' . $this->db->fieldName('id') . ' AS ' . $this->db->fieldName('id');
        }

        return $this->prepareSQL( array($fields), $count);
    }

/**
 * Returns generic SQL query that can be adaptated by child classes.
 * 
 * @version 0.1.5
 * @since 0.1.5
 * @param array $fields Fields to be selected.
 * @param bool $count Shows if the SQL should be generated for COUNT() variant.
 * @return string SQL query.
 */
    protected function prepareSQL($fields, $count = false)
    {
        $tables = array();

        // generates tables list for current qeury
        if( isset($this->filter) )
        {
            $tables = $this->filter->getTables();
        }

        // adds default table
        if( !in_array($this->table, $tables) )
        {
            $tables[] = $this->table;
        }

        // prepares tables names
        foreach($tables as &$name)
        {
            $name = $this->db->tableName($name);
        }

        // WHERE clause
        if( isset($this->filter) )
        {
            $where = ' WHERE ' . $this->filter->__toString();
        }
        else
        {
            $where = '';
        }

        // ORDER BY clause
        if($count || empty($this->orderBy) )
        {
            $orderBy = '';
        }
        else
        {
            $orderBy = array();

            foreach($this->orderBy as $criterium)
            {
                switch($criterium['order'])
                {
                    case POT::ORDER_ASC:
                        $orderBy[] = $criterium['field'] . ' ASC';
                        break;

                    case POT::ORDER_DESC:
                        $orderBy[] = $criterium['field'] . ' DESC';
                        break;
                }
            }

            $orderBy = ' ORDER BY ' . implode(', ', $orderBy);
        }

        return 'SELECT ' . implode(', ', $fields) . ' FROM ' . implode(', ', $tables) . $where . $orderBy . $this->db->limit($this->limit, $this->offset);
    }

/**
 * Magic PHP5 method.
 * 
 * @version 0.1.0
 * @since 0.1.0
 * @param string $name Property name.
 * @param mixed $value Property value.
 * @throws OutOfBoundsException For non-supported properties.
 */
    public function __set($name, $value)
    {
        switch($name)
        {
            case 'limit':
                $this->setLimit($value);
                break;

            case 'offset':
                $this->setOffset($value);
                break;

            case 'filter':
                $this->setFilter($value);
                break;

            default:
                throw new OutOfBoundsException();
        }
    }
}

/**#@-*/

?>
 
now that:
Code:
Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\guilds.php on line 31

Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\guilds.php on line 37

Fatal error: Call to a member function fetch() on a non-object in D:\xampp\htdocs\pot\OTS_Base_List.php on line 278
 
Hmm, maybe your gesior acc its the problem of this. Try to remplace with the last news.
 
Back
Top