File:  [mozdev] / cdn / www / b2-include / b2edit.showposts.php
Revision 1.4: download - view: text, annotated - select for diffs - revision graph
Thu Mar 13 09:48:28 2003 UTC (16 years, 5 months ago) by cdn
Branches: MAIN
CVS tags: HEAD
path fun

    1: <?php
    2: 
    3: echo $tabletop;
    4: require_once(PROJECT_PATH . '/b2config.php');
    5: 
    6: if (!$posts) {
    7: 	if ($posts_per_page) {
    8: 		$posts=$posts_per_page;
    9: 	} else {
   10: 		$posts=10;
   11: 		$posts_per_page=$posts;
   12: 	}
   13: }
   14: 
   15: if ((!empty($poststart)) && (!empty($postend)) && ($poststart == $postend)) {
   16: 	$p=$poststart;
   17: 	$poststart=0;
   18: 	$postend=0;
   19: }
   20: 
   21: if (!$poststart) {
   22: 	$poststart=0;
   23: 	$postend=$posts;
   24: }
   25: 
   26: $nextXstart=$postend;
   27: $nextXend=$postend+$posts;
   28: 
   29: $previousXstart=($poststart-$posts);
   30: $previousXend=$poststart;
   31: if ($previousXstart < 0) {
   32: 	$previousXstart=0;
   33: 	$previousXend=$posts;
   34: }
   35: 
   36: ?>
   37: 
   38: <table width="100%">
   39: <tr>
   40: <td valign="top" width="200">
   41: Show posts: </td>
   42: <td>
   43: <table cellpadding="0" cellspacing="0" border="0">
   44: <td colspan="2" align="center"><!-- show next/previous X posts -->
   45: <form name="previousXposts" method="get"><?php
   46: if ($previousXstart > 0) {
   47: ?>
   48: <input type="hidden" name="poststart" value="<?php echo $previousXstart; ?>" />
   49: <input type="hidden" name="postend" value="<?php echo $previousXend; ?>" />
   50: <input type="submit" name="submitprevious" class="search" value="< <?php echo $posts ?>" /><?php
   51: }
   52: ?></form></td><td><form name="nextXposts" method="get">
   53: <input type="hidden" name="poststart" value="<?php echo $nextXstart; ?>" />
   54: <input type="hidden" name="postend" value="<?php echo $nextXend; ?>" />
   55: <input type="submit" name="submitnext" class="search" value="<?php echo $posts ?> >" /></form>
   56: </td>
   57: </tr>
   58: </table>
   59: </td>
   60: </tr>
   61: <tr>
   62: <td valign="top" width="200"><!-- show X first/last posts -->
   63: <form name="showXfirstlastposts" method="get">
   64: <input type="text" name="posts" value="<?php echo $posts ?>" style="width:40px;" /?>
   65: <select name="order">&nbsp;<option value="DESC" <?php
   66: if (!isset($order))
   67: 	$order="DESC";
   68: $i = $order;
   69: if ($i == "DESC")
   70: echo " selected";
   71: ?>>last posts</option>
   72: <option value="ASC" <?php
   73: if ($i == "ASC")
   74: echo " selected";
   75: ?>>first posts</option>
   76: </select>&nbsp;<input type="submit" name="submitfirstlast" class="search" value="OK" />
   77: </form>
   78: </td>
   79: <td valign="top"><!-- show post X to post X -->
   80: <form name="showXfirstlastposts" method="get">
   81: <input type="text" name="poststart" value="<?php echo $poststart ?>" style="width:40px;" /?>&nbsp;to&nbsp;<input type="text" name="postend" value="<?php echo $postend ?>" style="width:40px;" /?>&nbsp;<select name="order">
   82: <option value="DESC" <?php
   83: $i = $order;
   84: if ($i == "DESC")
   85: echo " selected";
   86: ?>>from the end</option>
   87: <option value="ASC" <?php
   88: if ($i == "ASC")
   89: echo " selected";
   90: ?>>from the start</option>
   91: </select>&nbsp;<input type="submit" name="submitXtoX" class="search" value="OK" /></form>
   92: </td>
   93: 
   94: </tr>
   95: </table>
   96: <?php echo $tablebottom ?>
   97: 
   98: <br />
   99: 
  100: <?php echo $tabletop ?>
  101: <table width="100%">
  102: 	<td valign="top" width="33%">
  103: 		<form name="searchform" action="b2edit.php" method="get">
  104: 			<input type="hidden" name="a" value="s" />
  105: 			<input onFocus="this.value='';" onBlur="if (this.value=='') {this.value='search...';}" type="text" name="s" value="search..." size="7" style="width: 100px;" />
  106: 			<input type="submit" name="submit" value="search" class="search" />
  107: 		</form>
  108: 	</td>
  109: <td valign="top" width="33%" align="center">
  110: 	<form name="viewcat" action="b2edit.php" method="get">
  111: 		<select name="cat" style="width:140px;">
  112: 		<option value="all">All Categories</option>
  113: 		<?php
  114: 	$query="SELECT * FROM $tablecategories";
  115: 	$result=mysql_query($query);
  116: 	$querycount++;
  117: 	$width = ($mode=="sidebar") ? "100%" : "170px";
  118: 	while($row = mysql_fetch_object($result)) {
  119: 		echo "<option value=\"".$row->cat_ID."\"";
  120: 		if ($row->cat_ID == $postdata["Category"])
  121: 			echo " selected";
  122: 		echo ">".$row->cat_name."</option>";
  123: 	}
  124: 		?>
  125: 		</select>
  126: 		<input type="submit" name="submit" value="View" class="search" />
  127: 	</form>
  128: </td>
  129: <td valign="top" width="33%" align="right">
  130: <form name="viewarc" action="b2edit.php" method="get">
  131: 	<?php
  132: 
  133: 	if ($archive_mode == "monthly") {
  134: 		echo "<select name=\"m\" style=\"width:120px;\">";
  135: 		$arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date) FROM $tableposts ORDER BY post_date DESC";
  136: 		$querycount++;
  137: 		$arc_result=mysql_query($arc_sql) or die($arc_sql."<br />".mysql_error());
  138: 		while($arc_row = mysql_fetch_array($arc_result)) {
  139: 			$arc_year  = $arc_row["YEAR(post_date)"];
  140: 			$arc_month = $arc_row["MONTH(post_date)"];
  141: 			echo "<option value=\"$arc_year".zeroise($arc_month,2)."\">";
  142: 			echo $month[zeroise($arc_month,2)]." $arc_year";
  143: 			echo "</option>\n";
  144: 		}
  145: 	} elseif ($archive_mode == "daily") {
  146: 		$archive_day_date_format = "Y/m/d";
  147: 		$arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) FROM $tableposts ORDER BY post_date DESC";
  148: 		$querycount++;
  149: 		$arc_result=mysql_query($arc_sql) or die($arc_sql."<br />".mysql_error());
  150: 		while($arc_row = mysql_fetch_array($arc_result)) {
  151: 			$arc_year  = $arc_row["YEAR(post_date)"];
  152: 			$arc_month = $arc_row["MONTH(post_date)"];
  153: 			$arc_dayofmonth = $arc_row["DAYOFMONTH(post_date)"];
  154: 			echo "<option value=\"$arc_year".zeroise($arc_month,2).zeroise($arc_dayofmonth,2)."\">";
  155: 			echo mysql2date($archive_day_date_format, $arc_year.zeroise($arc_month,2).zeroise($arc_dayofmonth,2)." 00:00:00");
  156: 			echo "</option>\n";
  157: 		}
  158: 	} elseif ($archive_mode == "weekly") {
  159: 		echo "<select name=\"w\" style=\"width:120px;\">";
  160: 		if (!isset($start_of_week)) {
  161: 			$start_of_week = 1;
  162: 		}
  163: 		$archive_week_start_date_format = "Y/m/d";
  164: 		$archive_week_end_date_format   = "Y/m/d";
  165: 		$archive_week_separator = " - ";
  166: 		$arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date), WEEK(post_date) FROM $tableposts ORDER BY post_date DESC";
  167: 		$querycount++;
  168: 		$arc_result=mysql_query($arc_sql) or die($arc_sql."<br />".mysql_error());
  169: 		$arc_w_last = '';
  170: 		while($arc_row = mysql_fetch_array($arc_result)) {
  171: 			$arc_year = $arc_row["YEAR(post_date)"];
  172: 			$arc_w = $arc_row["WEEK(post_date)"];
  173: 			if ($arc_w != $arc_w_last) {
  174: 				$arc_w_last = $arc_w;
  175: 				$arc_ymd = $arc_year."-".zeroise($arc_row["MONTH(post_date)"],2)."-" .zeroise($arc_row["DAYOFMONTH(post_date)"],2);
  176: 				$arc_week = get_weekstartend($arc_ymd, $start_of_week);
  177: 				$arc_week_start = date($archive_week_start_date_format, $arc_week['start']);
  178: 				$arc_week_end = date($archive_week_end_date_format, $arc_week['end']);
  179: 				echo "<option value=\"$arc_w\">";
  180: 				echo $arc_week_start.$archive_week_separator.$arc_week_end;
  181: 				echo "</option>\n";
  182: 			}
  183: 		}
  184: 	} elseif ($archive_mode == "postbypost") {
  185: 		echo '<input type="hidden" name="more" value="1" />';
  186: 		echo '<select name="p" style="width:120px;">';
  187: 		$requestarc = " SELECT ID,post_date,post_title FROM $tableposts ORDER BY post_date DESC";
  188: 		$querycount++;
  189: 		$resultarc = mysql_query($requestarc);
  190: 		while($row=mysql_fetch_object($resultarc)) {
  191: 			if ($row->post_date != "0000-00-00 00:00:00") {
  192: 				echo "<option value=\"".$row->ID."\">";
  193: 				if (strip_tags($row->post_title)) {
  194: 					echo strip_tags(stripslashes($row->post_title));
  195: 				} else {
  196: 					echo $row->ID;
  197: 				}
  198: 				echo "</option>\n";
  199: 			}
  200: 		}
  201: 	}
  202: 
  203: 	echo "</select>";
  204: 	?>
  205: 	<input type="submit" name="submit" value="View" class="search" />
  206: </form>
  207: </td>
  208: 
  209: </table>
  210: <br />
  211: 
  212: <table cellspacing="0" cellpadding="5" border="0" width="100%">
  213: 	<?php
  214: 	// these lines are b2's "motor", do not alter nor remove them
  215: 	include(PROJECT_PATH . '/blog.header.php');
  216: 
  217: 	while($row = mysql_fetch_object($result)) {
  218: 		$posts_per_page = 10;
  219: 	start_b2(); ?>
  220: 		<tr>
  221: 		<td>
  222: 			<p>
  223: 				<b><?php the_time('Y/m/d @ H:i:s'); ?></b> [ <a href="b2edit.php?p=<?php echo $id ?>&c=1"><?php comments_number('no comment', '1 comment', "% comments") ?><?php trackback_number('', ', 1 trackback', ', % trackbacks') ?><?php pingback_number('', ', 1 pingback', ', % pingbacks') ?></a>
  224: 				<?php
  225: 				if (($user_level > $authordata[13]) or ($user_login == $authordata[1])) {
  226: 				echo " - <a href=\"b2edit.php?action=edit&post=".$postdata["ID"];
  227: 				if ($m)
  228: 				echo "&m=$m";
  229: 				echo "\">Edit</a>";
  230: 				echo " - <a href=\"b2edit.php?action=delete&post=".$postdata["ID"]."\" onclick=\"return confirm('You are about to delete this post \'".$row->post_title."\'\\n  \'Cancel\' to stop, \'OK\' to delete.')\">Delete</a> ";
  231: 				}
  232: 				?>
  233: 				]
  234: 				<br />
  235: 				<font color="#999999"><b><a href="<?php permalink_single('/' . $blogfilename); ?>" title="permalink"><?php the_title() ?></a></b> by <b><?php the_author() ?> (<a href="javascript:profile(<?php the_author_ID() ?>)"><?php the_author_nickname() ?></a>)</b>, in <b><?php the_category() ?></b></font><br />
  236: 				<?php permalink_anchor(); ?>
  237: 				<?php
  238: 				if ($safe_mode)
  239: 					echo "<xmp>";
  240: 				the_content();
  241: 				if ($safe_mode)
  242: 					echo "</xmp>";
  243: 				?>
  244: 				</p>
  245: 				<?php
  246: 
  247: 				// comments
  248: 				if (($withcomments) or ($c)) {
  249: 
  250: 					$queryc = "SELECT * FROM $tablecomments WHERE comment_post_ID = $id ORDER BY comment_date";
  251: 					$resultc = mysql_query($queryc);
  252: 					if ($resultc) {
  253: 					?>
  254: 
  255: 					<a name="comments"></a>
  256: 					<p><b><font color="#ff3300">::</font> comments</b></p>
  257: 
  258: 					<?php
  259: 					while($rowc = mysql_fetch_object($resultc)) {
  260: 						$commentdata = get_commentdata($rowc->comment_ID);
  261: 					?>
  262: 				
  263: 					<!-- comment -->
  264: 					<p>
  265: 					<b><?php comment_author() ?> ( <?php comment_author_email_link() ?> / <?php comment_author_url_link() ?> )</b> (IP: <?php comment_author_IP() ?>)
  266: 					<br />
  267: 					<?php comment_text() ?>
  268: 					<br />
  269: 					<?php comment_date('Y/m/d') ?> @ <?php comment_time() ?><br />
  270: 					<?php 
  271: 					if (($user_level > $authordata[13]) or ($user_login == $authordata[1])) {
  272: 						echo "[ <a href=\"b2edit.php?action=editcomment&comment=".$commentdata["comment_ID"]."\">Edit</a>";
  273: 						echo " - <a href=\"b2edit.php?action=deletecomment&p=".$postdata["ID"]."&comment=".$commentdata["comment_ID"]."\">Delete</a> ]";
  274: 					}
  275: 					?>
  276: 					</p>
  277: 					<!-- /comment -->
  278: 
  279: 
  280: 					<?php //end of the loop, don't delete
  281: 					}
  282: 
  283: 					if ($comment_error)
  284: 						echo "<p><font color=\"red\">Error: please fill the required fields (name & comment)</font></p>";
  285: 					?>
  286: 
  287: 					<p><b><font color="#ff3300">::</font> leave a comment</b></p>
  288: 
  289: 
  290: 					<!-- form to add a comment -->
  291: 
  292: 					<form action="/b2comments.post.php" method="post">
  293: 						<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
  294: 						<input type="hidden" name="redirect_to" value="<?php echo $HTTP_SERVER_VARS["REQUEST_URI"]; ?>" />
  295: 						<input type="text" name="author" class="textarea" value="<?php echo $user_nickname ?>" size="20" tabindex="1" /><br />
  296: 						<input type="text" name="email" class="textarea" value="<?php echo $user_email ?>" size="20" tabindex="2" /><br />
  297: 						<input type="text" name="url" class="textarea" value="<?php echo $user_url ?>" size="20" tabindex="3" /><br />
  298: 						<textarea cols="40" rows="4" name="comment" tabindex="4" class="textarea">comment</textarea><br />
  299: 						<input type="checkbox" name="comment_autobr" value="1" checked tabindex="6" class="checkbox" /> Auto-BR (line-breaks become &lt;br> tags)<br />
  300: 						<input type="submit" name="submit" class="buttonarea" value="ok" tabindex="5" />
  301: 
  302: 					</form>
  303: 
  304: 
  305: 					<!-- /form -->
  306: 
  307: 
  308: 					<?php // if you delete this the sky will fall on your head
  309: 					}
  310: 				}
  311: 				?>
  312: 			<br />
  313: 			</td>
  314: 		</tr>
  315: 	<?php
  316: 
  317: 	}
  318: 	?>
  319: 	</table>
  320: <?php echo $tablebottom ?>
  321: <br />
  322: <?php echo $tabletop ?>
  323: <table width="100%">
  324: <tr>
  325: <td valign="top" width="200">
  326: Show posts: </td>
  327: <td>
  328: <table cellpadding="0" cellspacing="0" border="0">
  329: <td colspan="2" align="center"><!-- show next/previous X posts -->
  330: <form name="previousXposts" method="get"><?php
  331: if ($previousXstart > -1) {
  332: ?>
  333: <input type="hidden" name="poststart" value="<?php echo $previousXstart; ?>" />
  334: <input type="hidden" name="postend" value="<?php echo $previousXend; ?>" />
  335: <input type="submit" name="submitprevious" class="search" value="< Previous <?php echo $posts ?>" /><?php
  336: }
  337: ?></form></td><td><form name="nextXposts" method="get">
  338: <input type="hidden" name="poststart" value="<?php echo $nextXstart; ?>" />
  339: <input type="hidden" name="postend" value="<?php echo $nextXend; ?>" />
  340: <input type="submit" name="submitnext" class="search" value="Next <?php echo $posts ?> >" /></form>
  341: </td>
  342: </tr>
  343: </table>
  344: </td>
  345: </tr>
  346: <tr>
  347: <td valign="top" width="200"><!-- show X first/last posts -->
  348: <form name="showXfirstlastposts" method="get">
  349: <input type="text" name="posts" value="<?php echo $posts ?>" style="width:40px;" /?>
  350: <select name="order">&nbsp;<option value="DESC" <?php
  351: $i = $order;
  352: if ($i == "DESC")
  353: echo " selected";
  354: ?>>last posts</option>
  355: <option value="ASC" <?php
  356: if ($i == "ASC")
  357: echo " selected";
  358: ?>>first posts</option>
  359: </select>&nbsp;<input type="submit" name="submitfirstlast" class="search" value="OK" />
  360: </form>
  361: </td>
  362: <td valign="top"><!-- show post X to post X -->
  363: <form name="showXfirstlastposts" method="get">
  364: <input type="text" name="poststart" value="<?php echo $poststart ?>" style="width:40px;" /?>&nbsp;to&nbsp;<input type="text" name="postend" value="<?php echo $postend ?>" style="width:40px;" /?>&nbsp;<select name="order">
  365: <option value="DESC" <?php
  366: $i = $order;
  367: if ($i == "DESC")
  368: echo " selected";
  369: ?>>from the end</option>
  370: <option value="ASC" <?php
  371: if ($i == "ASC")
  372: echo " selected";
  373: ?>>from the start</option>
  374: </select>&nbsp;<input type="submit" name="submitXtoX" class="search" value="OK" /></form>
  375: </td>
  376: 
  377: </tr>
  378: </table>
  379: <?php echo $tablebottom ?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>