<?php
/*
OekakiPoteto 5.x ©Copyright 2000-2002 RanmaGuy (Theo Chakkapark, http://suteki.nu) and Marcello Bastéa-Forte (http://marcello.cellosoft.com). Modification to the files are permitted as long as my name remains on the files.

Wacintaki Poteto modifications ©Copyright 2004-2008 Marc "Waccoon" Leveille
http://www.NineChime.com/products/
Version 1.4.0 - Last modified 7/28/2008
*/


// Load bootstrap
define ('BOOT', 1);
require ('boot.php');


// ===================================================================
// Start HTML (header)
//
include ('header.php');

//$ref_return = '';
//if ($wactest) {
//	include ('ref.php');
//	$ref_return = get_refs();
//}


// ===================================================================
// Index sorting
//
if (!empty ($artist)) {
	$sort = 6;
}
if (!empty ($a_match)) {
	$sort = 7;
	$artist = '';
}
$sql_where = '';
$sql_limit = 'LIMIT '.intval ($pageno * $cfg['pic_pages']).', '.$cfg['pic_pages'];

switch ($sort) {
	case 1:
		$sql_where = 'WHERE postlock=1 ORDER BY lastcmt DESC';
		break;
	case 2:
		$sql_where = 'WHERE postlock=1 AND animation=1 ORDER BY postdate DESC';
		break;
	case 3:
		$sql_where = 'WHERE postlock=1 AND animation=1 ORDER BY lastcmt DESC';
		break;
	case 4:
		$sql_where = 'WHERE postlock=1 AND archive=1 ORDER BY postdate DESC';
		break;
	case 5:
		$sql_where = 'WHERE postlock=1 AND archive=1 ORDER BY lastcmt DESC';
		break;
	case 6:
		$sql_where = "WHERE usrname LIKE '%{$artist}%' ORDER BY postdate DESC";
		break;
	case 7:
		$sql_where = "WHERE usrname='{$a_match}' ORDER BY postdate DESC";
		break;
	case 8:
		$sql_where = "WHERE password='public' ORDER BY postdate DESC";
		break;
	default:
		$sql_where = 'WHERE postlock=1 ORDER BY postdate DESC';
		break;
}

$result = mysql_query ("SELECT ID_2 FROM {$OekakiPoteto_Prefix}oekakidta {$sql_where}");
$pages = ceil (mysql_num_rows ($result) / $cfg['pic_pages']);

$result = mysql_query ("SELECT * FROM {$OekakiPoteto_Prefix}oekakidta {$sql_where} {$sql_limit}");
$rownum = mysql_num_rows ($result);


// ===================================================================
// CGI pass-through
// This is used for links, so HTML/URL encode
//
$pic_redirect = '';
if ($pageno) {
	$pic_redirect .= '&amp;pageno='.$pageno;
}
if ($sort) {
	$pic_redirect .= '&amp;sort='.$sort;
}
if (!empty ($artist)) {
	$pic_redirect .= '&amp;artist='.urlencode($artist);
}
if (!empty ($a_match)) {
	$pic_redirect .= '&amp;a_match='.urlencode($a_match);
}


// ===================================================================
// Page numbers
//
$pages_query = '';
if ($sort != 0) {
	$pages_query .= '&amp;sort='.$sort;
}
if ($artist) {
	$pages_query .= '&amp;artist='.urlencode($artist);
}
if ($a_match) {
	$pages_query .= '&amp;a_match='.urlencode($a_match);
}

// $pages_link is for page numbers only!
$pages_link = 'index.php?pageno={page_link}'.$pages_query;

// Fourth parameter is how many digits on each side of the current page number will be printed
$page_numbers_formatted = quick_page_numbers(0, $pageno, $pages, 5, $pages_link)."\n";


// ===================================================================
// Main HTML
//
echo "<!-- Notice -->\n";
if (file_not_empty($cfg['res_path'].'/notice.php')) {
	echo "<div id=\"notice\">\n";
	include ($cfg['res_path'].'/notice.php');
	echo "\n</div>\n"
	."<!-- /Notice -->\n\n\n"
	."<hr />\n"
	."<br />\n";
} else {
	echo "<!-- /Notice -->\n\n\n"
	."<hr />\n";
}

?>
<!-- Pages Top -->
<div id="pagestop" class="pages">
	<?= $page_numbers_formatted ?>
</div>
<!-- /Pages Top -->


<hr />
<br />


<?
/*
	MAIN LOOP
*/
?>
<!-- Content -->
<div id="contentmain">
<?
	// Outer loop, for posts
	for ($current_post = 0; $current_post < $rownum; $current_post++) {

		// Get DB results, one row at a time
		$outerrow = mysql_fetch_array ($result);

?>
	<!-- Pic -->
	<div id="pic<?=$outerrow['PIC_ID'];?>" class="postheader">
		<hr />
<?		// Picture ID ?>
		[<?=$outerrow['ID_2']?>]
<?

		// Retouch
		if ($flags['D']) {
			if ($outerrow['usrname'] == $OekakiU || !empty ($outerrow['password'])) {
				switch ($outerrow['datatype']) {
					case '0':
						$use_app = 'noteBBS.php?';
						break;
					case '1':
						$use_app = 'oekakiBBS.php?';
						break;
					case '2':
						$use_app = 'shiBBS.php?';
						break;
					case '3':
						$use_app = 'shiBBS.php?tools=pro&amp;';
						break;
					case '4':
						$use_app = 'chibipaint.php?';
						break;
				}
				if ($outerrow['usrname'] != $OekakiU) {
					$use_app = 'retouch.php?';
				}
			
				echo "		[<a href=\"{$use_app}edit={$outerrow['PIC_ID']}\">{$langop_word_retouch}</a>]\n";
			}
		}

		// Comment
		if ($outerrow['threadlock'] == '0' || $flags['admin']) {
			if ($cfg['guest_post'] == 'yes' || $OekakiU != '') {
				?>
		[<a href="comment.php?mode=add&amp;resno=<?=$outerrow['PIC_ID']?><?=$pic_redirect?>"><?=$langop_word_comment?></a>]
<?
			}
		}

		// Artist & Title
?>
		<strong><?=$langop_word_artist?>:</strong>
		<a onclick="openWindow('profile.php?user=<?=urlencode ($outerrow['usrname']);?>', 400, 600); return false" href="profile.php?user=<?=urlencode ($outerrow['usrname']);?>"><?=w_html_chars($outerrow['usrname']);?></a>
		| <strong><?=$langop_install_title2?>:</strong> <?=nifty2_convert($outerrow['title']);?> 
<?

		// Time
		if ($outerrow['edittime'] > 10 ) {
			$edit_s = ceil ($outerrow['edittime'] % 60);
			$edit_m = ceil ($outerrow['edittime'] / 60 % 60);
			$edit_h = ceil ($outerrow['edittime'] / 3600 % 60);

			if ($edit_h)
				$edit_s = 0;

			$edit_out = '';
			if ($edit_h)
				$edit_out .= "{$edit_h}h ";
			if ($edit_m)
				$edit_out .= "{$edit_m}m ";
			if ($edit_s)
				$edit_out .= "{$edit_s}s ";
		} else {
			$edit_out = $langop_word_unknown;
		}
		echo "		| <strong>{$langop_word_time}:</strong> {$edit_out}\n";


		// Delete Picture
		if ($outerrow['usrname'] == $OekakiU) {
			// Delete
			if (!empty ($a_match)) {
				$a_tag = '&amp;return=a_match';
			} else {
				$a_tag = '';
			}
			echo "		| [<a href=\"delconf.php?mode=del{$a_tag}&amp;picno={$outerrow['PIC_ID']}\">{$langop_word_delete}</a>]\n";
		} elseif ($flags['admin']) {
			// Admin Delete
			echo "		| [<a href=\"delconf.php?mode=dela&amp;picno={$outerrow['PIC_ID']}\">{$langop_word_delete}</a>]\n";
		}


		// Admin-only options
		if ($flags['admin']) {
			// Lock
			if ($outerrow['threadlock'] != 0) {
?>
		[<a href="functions.php?mode=unlock&amp;picno=<?=$outerrow['PIC_ID']?><?=$pic_redirect?>"><?=$langop_word_unlock?></a>]
<?
			} else {
?>
		[<a href="functions.php?mode=lock&amp;picno=<?=$outerrow['PIC_ID']?><?=$pic_redirect?>"><?=$langop_word_lock?></a>]
<?
			}

			// Archive
?>
		[<a href="functions.php?picid=<?=$outerrow['PIC_ID'];?>&amp;mode=archive<?=$pic_redirect?>"><?
			if ($outerrow['archive'] == '0') {
				echo $langop_word_archive;
			} else {
				echo $langop_word_unarchive;
			}
			?></a>]
<?

			// Bump
?>
		[<a href="functions.php?mode=bump&amp;resno=<?=$outerrow['PIC_ID'];?>"><?=$langop_word_bump?></a>]
<?

		}
		// Block adult images
		if ($flags['admin'] || $outerrow['usrname'] == $OekakiU) {

			if ($outerrow['adult'] == 0) {
?>
		[<a href="functions.php?mode=block&amp;picno=<?=$outerrow['PIC_ID']?><?=$pic_redirect?>">18+</a>]
<?
			} else {
?>
		[<a href="functions.php?mode=unblock&amp;picno=<?=$outerrow['PIC_ID']?><?=$pic_redirect?>"><?=$langop_abrc_un?> 18+</a>]
<?
			}
		}
		// WIP
		if ($flags['admin']) {
?>
		[<a href="functions.php?mode=wip_pic&amp;picno=<?=$outerrow['PIC_ID']?><?=$pic_redirect?>"><?=$langop_word_WIP?></a>]
<?
		}

		// Thumbnail
		if ($flags['admin']) {
			if ($wactest && $flags['owner']) {
?>
		[<a href="functions.php?mode=make_thumb&amp;picno=<?=$outerrow['PIC_ID']?>&amp;type=png<?=$pic_redirect?>"><?=$langop_abrc_tp?></a>
		/ <a href="functions.php?mode=make_thumb&amp;picno=<?=$outerrow['PIC_ID']?>&amp;type=jpg<?=$pic_redirect?>"><?=$langop_abrc_tj?></a>]
<?
			} else {
?>
		[<a href="functions.php?mode=make_thumb&amp;picno=<?=$outerrow['PIC_ID']?><?=$pic_redirect?>"><?=$langop_word_thumb?></a>]
<?
			}
		}
?>
		<hr />
	</div>
	<!-- /Postheader -->

<?


		/*
			PICTURE RENDINGING CODE

			This is complex.

			To improve browsing visibility and reduce bandwidth, we do three things:  use thumbnails when available for large images, scale large images down if no thumbnail is available/practical, and use vertical layout for wide images so comments don't get squashed (if member has not specified a layout).

			If thumbnail support is on, a ttype (thumbnail) is always made unless the source picture is less than 15K.  ttypes are used mostly for speeding up load times on menus and when in uniformity mode, but also substitute a missing rtype if the filesize is large.

			rtypes (reduced previews) are made if a file is too large, either in filesize or dimmentions.  rtypes are *always* used if the filesize is large, and sometimes used if the layout demands it.

			When the display mode is automatic, vertical layout is only used if not using an rtype/ttype.

			VARS:

			$_GLOBALS['thumbDisplay']: 0=none, 1=layout, 2=scaled, 3=uniform
			$use_thumbnail: 0=no, 1=rtype, 2=ttype
			$use_scaling  : 0=no, >0=scale_in_pixels

			$_GLOBALS['display']: 0=auto, 1=horizontal, 2=vertical
			$this_row_display   : 0=horizontal, 1=vertical

			TRUTH TABLE:

			td=thumbDisplay value
			h=horizontal, v=vertical
			R=rtype thumbnail, T=ttype thumbnail

			     Picture type  | td=0 | td=1 | td=2 | td=3 |
			-------------------+------+------+------+------+
			           Normal  |  Nh  |  Nh  |  Nh  |  Th  |
			   Large Filesize  |  Rh  |  Rh  |  Rh  |  Th  |
			       > Comments  |  Nv  |  Nv  |  Rh  |  Th  |
			         > Screen  |  Rh  |  Rh  |  Rh  |  Th  |
		*/

		$use_thumbnail = 0;
		$use_scaling   = 0;
		$have_r = (!empty ($outerrow['rtype'])) ? 1 : 0;
		$have_t = (!empty ($outerrow['ttype'])) ? 1 : 0;
		$bandwidth = (!empty ($outerrow['usethumb'])) ? 1 : 0;


		// Set H/V mode to default
		$this_row_display = ($display == 2) ? 1 : 0;

		// Choose thumbnail and layout
		if ($thumbDisplay == 3) {
			// Uniformity mode always uses ttype, H mode
			$use_thumbnail = 2;
			$this_row_display = 0;

			// No thumbnail?
			if (!$have_t) {
				if ($have_r) {
					$use_thumbnail = 1;
				} else {
					$use_thumbnail = 0;
					$use_scaling = $cfg['thumb_t'];
				}
			}
		} else {
			if ($bandwidth && ($have_r || $have_t)) {
				// Always use thumbnail if avail
				$use_thumbnail = 1;

				if (!$have_r) {
					$use_thumbnail = 2;
				}
			} else {
				// Bandwidth OK, or we don't have a thumbnail

				// Check width of picture
				if ($outerrow['px'] > ($screensize - 60)) {
					// Width too large for screen?
					if ($have_r) {
						$use_thumbnail = 1;
					} else {
						$use_thumbnail = 0;
						$use_scaling = $cfg['thumb_r'];
					}
				} elseif ($outerrow['px'] > ($screensize - 400)) {
					// Width too large for comments?
					// For 800x600, a picture larger than 400px is too big
					if ($thumbDisplay == 2 && $have_r) {
						// Scaled mode, use thumbnail
						$use_thumbnail = 1;
					} else {
						// Non-scaled, use V layout
						$use_thumbnail = 0;
						$this_row_display = 1;
					}
				}
			}

			// How about user overrides?
			// Layout override works with all modes but uniformity
			if ($display > 0) {
				$this_row_display = ($display == 2) ? 1 : 0;
			}
		}
		// At this point we know thumbnail, layout is valid


		// Put our selections together
		{
			$master_image    = $p_pic.$outerrow['PIC_ID'].'.'.$outerrow['ptype'];
			$thumbnail_image = $master_image;

			if ($use_thumbnail == 2) {
				$thumbnail_image = $t_pic.$outerrow['PIC_ID'].'.'.$outerrow['ttype'];
			} elseif ($use_thumbnail == 1) {
				$thumbnail_image = $r_pic.$outerrow['PIC_ID'].'.'.$outerrow['rtype'];
			}


			// Get longest side of picture
			if ($outerrow['py'] > $outerrow['px']) {
				$long_mode  = 1;
				$long_side  = $outerrow['py'];
				$short_side = $outerrow['px'];
			} else {
				$long_mode  = 0;
				$long_side  = $outerrow['px'];
				$short_side = $outerrow['py'];
			}

			// Set scaling
			$scale_size = '';
			if ($use_scaling && ($long_side > $use_scaling)) {
				// No thumbnail.  Scale it.
				if ($long_mode == 1) {
					// Vertical
					$scale_size = 'height="'.$use_scaling.'"';
				} else {
					// Horizontal
					$scale_size = 'width="'.$use_scaling.'"';
				}
			}
		}


		// Set CSS class for anchored image
		if ($use_thumbnail && $thumbDisplay != 3) {
			$img_class_type = 'imgthumb';
		} else {
			$img_class_type = 'imghover';
		}


		// OK, we can render the div/table, now

?>
	<!-- Postmain -->
	<div class="postmain">
<?
		// Watch for these!  ;)
		if ($this_row_display == 0) {
			?>
		<table cellspacing="0" cellpadding="0" border="0">
		<tr>
		<!-- Postdata -->
		<td style="vertical-align: top; text-align: center;" valign="top">
<?
		} else {
		?>
		<div class="postdata">
<?
		}

		// Insert the picture + thumbnail
		$adult_block_mode = 0;
		if (!$flags['X'] && $outerrow['adult'] == 1) {
			if ($cfg['guest_adult'] == 'yes' || $flags['admin']) {
				// block image only (worksafe)
				$adult_block_mode = 1;
			} else {
				// block image and link
				$adult_block_mode = 2;
			}
		}

		// Paint type
		if ($outerrow['datatype'] == '0') {
			$applet_mode = $langop_word_paintbbs;
		}
		elseif ($outerrow['datatype'] == '1') {
			$applet_mode = $langop_word_oekakibbs;
		}
		elseif ($outerrow['datatype'] == '2') {
			$applet_mode = 'ShiPainter';
		}
		elseif ($outerrow['datatype'] == '3') {
			$applet_mode = 'ShiPainter Pro';
		}
		elseif ($outerrow['datatype'] == '4') {
			$applet_mode = 'Chibi Paint';
		}



		// Print image
if ($adult_block_mode == 0) {
echo <<<EOF
			<a href="$master_image"><img src="$thumbnail_image" class="$img_class_type" {$scale_size} alt="Pic #{$outerrow['PIC_ID']}" title="Pic #{$outerrow['PIC_ID']}" /></a><br />

EOF;
} elseif ($adult_block_mode == 1) {
echo <<<EOF
			<a href="$master_image"><img src="{$cfg['res_path']}/{$cfg['porn_img']}" class="$img_class_type" alt="Pic #{$outerrow['PIC_ID']}" title="Pic #{$outerrow['PIC_ID']} ({$langop_clicktoview})" /></a><br />

EOF;
} else {
echo <<<EOF
			<img src="{$cfg['res_path']}/{$cfg['porn_img']}" alt="Pic #{$outerrow['PIC_ID']}" title="Pic #{$outerrow['PIC_ID']}" /><br />

EOF;
}
		//	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=

		if ($use_thumbnail && $thumbDisplay != 3) {
			echo '			('.$langop_clickenlarg.')<br />'."\n";
		}
		?>
			<br />
			<?= $applet_mode; ?> 
			<br />
<?

		// Animation type (Chibi Paint hack)
		if ($outerrow['animation'] == '1' && $outerrow['datatype'] != 4) {
			switch ($outerrow['datatype']) {
				case '0':
				case '2':
				case '3':
					$viewani_size = array(75 , 175);
					break;

				case '1':
				case '4':
					$viewani_size = array(100, 185);
					break;

				default:
					break;
			}

			if ($adult_block_mode == 0 || $adult_block_mode == 1) {
				// NOTE: Use ID_2, not PIC_ID for $resno
?>
			[<a href="#" onclick="openWindow('viewani.php?recno=<?=$outerrow['ID_2']?>', '<?=$outerrow['px'] + $viewani_size[0];?>', '<?=$outerrow['py'] + $viewani_size[1];?>'); return false;"><?=$langop_viewani_title?></a>]<br />
<?
			} else {
?>
			[<?=$langop_word_animated?>]<br />
<?
			}
		}

		if ($outerrow['archive'] == '1') {
			echo "			($langop_word_archived)<br />";
		}
		if ($outerrow['adult'] != 0 && $flags['X']) {
			echo "			($langop_word_adult)<br />\n";
		}
		if (!empty ($outerrow['password'])) {
			if ($outerrow['password'] == 'public' && $cfg['public_retouch'] == 'yes') {
				echo "			($langop_word_public)<br />\n";
			} else {
				echo "			($langop_install_password)<br />\n";
			}
		}
		if ($outerrow['threadlock'] != 0) {
			echo "			<br />\n			<strong>(".$langop_tlocked.")</strong><br />\n";
		}

		if ($this_row_display == 0) {
			?>
		</td>
<?
		} else {
			?>
		</div>
		<br />
<?
		}
		?>

<?
		if ($this_row_display == 0) {
			?>
		<td style="width: 100%;" valign="top">
<?
		}
		?>
		<div class="commentmain">
			<div class="commentheader">
				<strong>
					<a onclick="openWindow('profile.php?user=<?=urlencode($outerrow['usrname']);?>', 400, 500); return false" href="profile.php?user=<?=urlencode($outerrow['usrname']);?>"><?=w_html_chars($stupid_name.$outerrow['usrname']);?></a>
				</strong>
				<span class="commentinfo">@ <?= date($datef['post_header'], strtotime($outerrow['postdate'])); ?></span>
				<?
					if ($outerrow['usrname'] == $OekakiU || $flags['admin'])
						echo "<a href=\"editpic.php?picno={$outerrow['PIC_ID']}\">[{$langop_word_edit}]</a>\n";
				?>
			</div>
			<div class="commentdata">
<?
		// Avatar
		$avatar = '';
		$ava_sql = '';
		if ($cfg['use_avatars'] == 'yes' && strtolower ($OekakiU) != 'screenshot') {
			$ava_sql = mysql_query ("SELECT avatar FROM {$OekakiPoteto_MemberPrefix}oekaki WHERE usrname='{$outerrow['usrname']}'");
			if ($ava_sql && mysql_num_rows ($ava_sql) > 0)
				$avatar = mysql_result ($ava_sql, 0);
		}
		if (!empty ($avatar)) {
?>
				<table>
				<tr>
				<td valign="top">
					<img src="<?=$cfg['avatar_folder'].'/'.$avatar;?>" alt="avatar" /><br />
				</td>
				<td valign="top" width="100%">
<?
		}
		if (!empty ($outerrow['comment'])) {
			?>
				<?= nifty2_convert($outerrow['comment']); ?> 
<?
		} else {
			?>
				<small>&hellip;</small>
<?
		}
		if (!empty ($outerrow['origart'])) {
			echo "<br />\n<br />\n<strong>(".$langop_originalby." {$outerrow['origart']})</strong>\n";
		}
		if (!empty ($avatar)) { ?>
				</td>
				</tr>
				</table>
<?
		}
?>
			</div>

<?
		// Comments
		$result2 = mysql_query ("SELECT * FROM {$OekakiPoteto_Prefix}oekakicmt WHERE PIC_ID='{$outerrow['PIC_ID']}' ORDER BY postdate ASC");
		$rownum2 = mysql_num_rows ($result2);

		$i2 = 0;
		while ($i2 < $rownum2) {
			// Get DB results, one row at a time.
			$innerrow = mysql_fetch_array ($result2);

			?>
			<div class="commentheader">
<?
			if ($innerrow['usrname'] == 'Guest'){
				// Only reg members can see e-mails
				// E-mails are set here only if a guest, so don't bother with 'email_show'
				if (!empty ($OekakiU) && !empty ($innerrow['email'])) {
					?>
				<b><i><a href="mailto:<?= email_code($innerrow['email'], TRUE); ?>"><?=w_html_chars($stupid_guest.$innerrow['postname']);?></a></i></b>
<?
				} else {
					?>
				<span class="nolink"><i><?=w_html_chars($stupid_guest.$innerrow['postname']);?></i></span>
<?
				}
			} else {
				?>
				<b><a onclick="openWindow('profile.php?user=<?=urlencode($innerrow['usrname']);?>', 400, 500); return false" href="profile.php?user=<?=urlencode($innerrow['usrname']);?>"><?=w_html_chars($stupid_name.$innerrow['usrname']);?></a></b>
<?
			}
			// Print homepage only if available
			if (strlen ($innerrow['url']) > 8) {
				?>
			- <a href="<?=$innerrow['url']?>">[<?=$langop_word_homepage?>]</a>
<?
			}
?>
				<span class="commentinfo">@ <?= date($datef['post_header'], strtotime($innerrow['postdate'])); ?></span>
<?
			// Print Guest IP/Host
			if ($flags['admin'] && $innerrow['usrname'] == 'Guest') {
?>
				[<acronym title="<?=$innerrow['IP'].' / '.$innerrow['hostname']?>">IP &amp; host</acronym>]
<?
			}

			// Edit/Delete comment
			if ($innerrow['usrname'] == $OekakiU || $flags['admin']) {
?>
				[<a href="editcomm.php?id_3=<?=$innerrow['ID_3']?>"><?=$langop_word_edit?></a>]
<?
				// Confirm
				if (defined ('DISABLE_CMT_DEL_CONF') && DISABLE_CMT_DEL_CONF) {
					// No
?>
				[<a href="functions.php?mode=udelcmt&amp;cmtno=<?=$innerrow['ID_3']?>"><?=$langop_word_delete?></a>]
<?
				} else {
					// Yes
					$my_pageno = '';
					if ($pageno) {
						$my_pageno = "&amp;page={$pageno}";
					}
?>
				[<a href="delconf.php?cmtno=<?=$innerrow['ID_3'].$my_pageno;?>&amp;post=<?=$outerrow['PIC_ID'];?>"><?=$langop_word_delete?></a>]
<?
				}
			}
?>
			</div>
<?
		// Avatar
		$avatar = '';
		$ava_sql = '';
		if ($cfg['use_c_avatars'] == 'yes' && $cfg['use_avatars'] == 'yes' && $innerrow['usrname'] != 'Guest' && strtolower ($OekakiU) != 'screenshot') {
			$ava_sql = mysql_query ("SELECT avatar FROM {$OekakiPoteto_MemberPrefix}oekaki WHERE usrname='{$innerrow['usrname']}'");
			if ($ava_sql && mysql_num_rows ($ava_sql) > 0)
				$avatar = mysql_result ($ava_sql, 0);
		}
		if (!empty ($avatar)) {
?>
			<div class="commentdata"<? if (FULL_AVATARS != 1) echo ' style="padding-top: 0; padding-bottom: 0; margin-top: 0; margin-bottom: 0;"';?>>
				<table>
				<tr>
				<td valign="top">
					<img src="<?=$cfg['avatar_folder'].'/'.$avatar;?>" alt="avatar" /><br />
				</td>
				<td valign="top" width="100%">
<?
		} else {
?>
				<div class="commentdata">
<?
		}
		if (!empty ($innerrow['comment'])) {
?>
				<?= nifty2_convert($innerrow['comment']); ?> 
<?
		} else {
?>
				<small>...</small>
<?
		}
		if (!empty ($avatar)) { ?>
				</td>
				</tr>
				</table>
<?
		}
?>
			</div>

<?
			$i2++;
		} // endwhile inner

		if ($this_row_display == 0) {
			// Horizontal
			?>
		</div>
		</td>
		</tr>
		</table>
<?
		} else {
			// Vertical
			?>
		</div>
<?
		}
		?>
		<!-- /Commentmain -->
	</div>
	<br />

<?
	} // endwhile outer
?>

</div>
<!-- /Content -->
<?
/*
	END MAIN LOOP
*/
?>


<hr />


<!-- Pages Bottom -->
<div id="pagesbottom" class="pages">
	<?= $page_numbers_formatted ?>
</div>

<? if (SELECT_PAGES == 1) { ?>
<!--Jump Page Dropdown Menu-->
<div align="right">
<form name="jump">
	<?=$langop_gotopg?> 
	<select name="menu" class="txtinput">
<?
$i4 = 0;
while ($i4 < $pages) {
	if($i4 != $pageno) {
?>
		<option value="index.php?pageno=<?=$i4?><?=$pages_query;?>"><?= $i4 + 1; ?></a>
<?
	} else {
?>
		<option selected="selected" value="index.php?pageno=<?=$i4;?><?=$pages_query;?>"><b><?= $i4 + 1; ?></b></option>
<? }
	$i4++;
}
?></option>
	</select>
	<input type="button" onclick="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="<?=$langop_word_go?>" class="submit">&nbsp;
</form>
</div>

<!-- /Pages Bottom -->
<? } ?>

<hr />


<? include ('footer.php'); ?>