All pastes #446373 Raw Edit

Stuff

public text v1 · immutable
·published 2007-04-18 13:06 UTC
rendered paste body
<?php

$title="Story Archives";

include("header.php");
include("application.php");
ini_set('default_charset', 'utf-8');

if(!isset($_GET['src']))
	{ 
	$src = 0;
	}
	else
	$src = $_GET['src'];


if(!isset($_GET['type']))
	{ 
	$type = "ALL";
	}
	else
	$type = $_GET['type'];

if(!isset($_GET['topic']))
	{ 
	$topic = "ALL";
	}
	else
	$topic = $_GET['topic'];
	
if(!isset($_GET['topic']))
	{ 
	$topic = "ALL";
	}
	else
	$topic = $_GET['topic'];
	
if(!isset($_GET['month']))
	{ 
	$month = 0;
	}
	else
	$month = $_GET['month'];
	
if(!isset($_GET['year']))
	{ 
	$year = 0;
	}
	else
	$year = $_GET['year'];
$enddate = cal_days_in_month(CAL_GREGORIAN,$month,$year);
$start = "$year-$month-1";
$end = "$year-$month-$enddate";
if(($month != 0) && ($year!= 0))
{
	$THEDATE =  "$year-$month";
	$pdfyear = $year;
	$pdfmonth = $month;
	$PDFFILE = $pdfyear .  $pdfmonth . ".pdf";
		if($pdfmonth < 10)
		{
		$PDFFILE = pdfyear . "0" . pdfmonth . ".pdf";
		}
}


$conn = mysql_connect("localhost","root","");
mysql_select_db("news",$conn);

/* -- Stories Query with approval date -- */
$sql = "select stories.*, countries.* from stories,countries
    where stories.country = countries.countryid";
 
		if(($month != 0) && ($year != 0))
		{
			$sql .= " and stories.approvaldate >= '$start'";
			$sql .= " and stories.approvaldate <= '$end'";
		}
		if($topic != "All")
		{
			$sql .= " and stories.topic = '$topic'";
		}
		if($type != "All")
		{
			$sql .=  " and stories.type = '$type'";
		}
$sql .= " order by approvaldate desc, storyid desc limit 20";

$result = mysql_query($sql, $conn);
$num_of_rows = mysql_num_rows($result);

/*if($num_of_rows > 0)
{
/* -- Stories Query without approvaldate -- 
$sql2 = "select stories.*, countries.* from stories,countries
		where stories.country = countries.countryid
		order by approvaldate desc, storyid desc limit 10";
$result2 = mysql_query($sql2, $conn);
$num_of_rows2 = mysql_num_rows($result2);
}  */

/* -- Topics Query -- */
$sql3 = "select * from topics order by topicname";
$result3 = mysql_query($sql3, $conn);
$num_of_rows3 = mysql_num_rows($result3);

?>


<div id="archivesearch">
<form method="get" action="archives.php" name="archiveForm">
<div class="formLabel">Topic:</div> <select name="topic">
			<option value="All">All</option>
			
	<?php 
	
	while($rows3 = mysql_fetch_assoc($result3))
	{
	echo "INSIDE THE WHILE ";
	$op = '<option value="' . $rows3['TOPICID'] . '"';

			if($rows3['TOPICID'] == $topic)
			{
			$op .="selected = \"selected\" ";
			}
			$op .=">";
			$op .= " $rows3[TOPICNAME]</option>";
		print $op;
	}
	?>	
				
				</select><br />


<div class="formLabel">Type:</div> 	<select name="type">
			<option value="All">All</option>
			<option value="N"<?php if($type == "N") echo "selected=\"selected\""; ?>>News Stories</option>			
			<option value="F"<?php if($type == "F") echo "selected=\"selected\""; ?>>Features</option>
			<option value="P"<?php if($type == "P") echo "selected=\"selected\""; ?>>Profiles</option>
			<option value="R"<?php if($type == "R") echo "selected=\"selected\""; ?>>Reviews</option>
			<!---option value="O"<cfif form.type is "O"> selected="selected"</cfif>>Obituaries</option--->
		</select><br />



<div class="formLabel">Date:</div> 	<select name="month">
			<option value="0">Any</option>
<?php
$months = array (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec); 

for($i=1; $i <=12; $i++)
{
	
	if($month == $i)
	{
		print "<option value=\"$i\" selected = \"selected\">" . $months[$i-1] . "</option>";
	}
	else
	{
		print "<option value=\"$i\">" . $months[$i-1] . "</option>";
	}
}

?>
</select>

<select name="year">
			<option value="0">Any</option>
			
<?php
	$presentyear = date("Y");				
	for($i=2000; $i <=$presentyear; $i++)
	{
	if($year == $i)
		{
		print "<option value=\"$i\" selected = \"selected\">" . $i . "</option>";
		}
		else
		{			
		print "<option value=\"$i\">" . $i . "</option>";
		}
	}
?>

</select>
<input type="submit" name="Submit" value="Submit" /> <a href="http://news.bahai.org/search.cfm">&gt; Advanced Search</a>
</form>
<div class="clear"></div>
</div>

<?php 

if(defined('$PDFFILE'))
	{
		$filename = "/var/www/bic/news.bahai.org/pdf/$PDFFILE";
		if(file_exists($filename))
			{
			print "<a href=\"/pdf/$PDFFILE\" class=\"full_story\">&gt; PDF DIGEST FOR MONTH</a>";
			}
	}
?>

<div id="relatedPhotos">
<?php 	

   while($rows = mysql_fetch_assoc($result))
   {  //start of the main loop through the database
	$list = array ("N" , "F" , "P" , "O" ,"R"); 
	
	foreach($list as $value)
	{  //comparison of the database type with the array list
	  $typeCount = 0;
	  
		  
			   if($rows['TYPE'] == $value)
				{
						$typeCount = 1;
				}
		  
	   	
			if($typeCount == 1)
				{
					$storyType = "NEWS";
					if($value == "B") $storyType = "NEWS BRIEFS";
	   				if($value == "F") $storyType = "FEATURES";
					if($value == "P") $storyType = "PROFILES";
					if($value == "R") $storyType = "REVIEWS";
					if($value == "O") $storyType = "OBITUARIES";
				 
				}
	
	?>
	
	<div class="sectiondivider"><?php print "$storyType"; ?></div>
	
	<?php
	   $firstDone = false;
	   if($rows['TYPE'] == $value)
				{
									$sql4 = "select * from pictures where storyid = '" . $rows[STORYID] . "' limit 1";   
									$result4 = mysql_query($sql4, $conn);
									$num_of_rows4 = mysql_num_rows($result4);
									$rows4 = mysql_fetch_assoc($result4);
						print "<div class=\"photo\">";
											if($num_of_rows4 > 0) { ?>
														
							<img src=<?php getPhotoURL($rows4['PICTUREID'],80,"alt") ?> width="80" class="photo" alt="photo" /></a>					
											
										<?php					   }
				
							print '<h3><a href="/story/' . $rows2['STORYID'] . '">' . $rows2['TITLE'] . '</a></h3>';
							$divisionPoint = summarize($rows['TEXT'],2);
							$byline = "<b>" . strtoupper($rows['CITY']) . ",</b> " . ucfirst($rows['COUNTRYNAME']) . ",";					
							
								if($rows['REGION'] == 20)
								{
									$byline = "</b> " . ucfirst($rows['COUNTRYNAME']) . ",";
								
								 } 
				 
		}

$olddate = substr("$rows[APPROVALDATE]",5);
$getmonth = substr("$olddate",0,2);
$getdate = substr("$olddate",3);
 
$montharray = array ( January => '00' , February => '02' , March => '03'  , April => '04' , May => '05' , June => '06' , July => '07' , August => '08' , September => '09' , October => '10' , November => '11' , December => '12'); 

$datearray = array ( 1 => '01' , 2 => '02' , 3 => '03'  , 4 => '04' , 5 => '05' , 6 => '06' , 7 => '07' , 8 => '08' , 9 => '09');

$tempmonth= array_search("$getmonth", $montharray);

		if( substr("$olddate",3,1) == 0)
		{
		$tempdate = array_search("$getdate", $datearray);
		}
		else
		{
		$tempdate = $getdate;
		}


$finaldate = "$tempdate $tempmonth"; 

$approvaldate = "$tempdate";
$approvalmonth = "$tempmonth";
$approvalyear =  substr("$rows[APPROVALDATE]",0,4);
		 
 echo "<br><b> Division point is  $divisionPoint</b></br>";
	print "<div class=\"caption\"><p>$byline $approvaldate $approvalmonth $approvalyear (BWNS) -- " . substr($rows['TEXT'],0,$divisionPoint) . ".</p></div>";
	print "<a href=\"/story/${rows2['STORYID']}\" class=\"full_story\">&gt; GO TO STORY</a><div class=\"clear\"></div></div>";
		}
}
 
?>

<div id="rightstories">
					
<?php 


	$requestnumHeadlines = 5;
	$mainStoryID = 0;
	$box1ID = 0;
	$box2ID = 0;
	$box3ID = 0;

	include("headlines.php");
	
	print "</div>";
include("footer.php");

?>