<?php



/* Config file */
include('config.php');

/* Connect to database & query */
if(isset($_POST['submit']) && $_POST['name']!= "" && $_POST['agreement'] == "yes"){

if($connectDatabase == TRUE){$action=TRUE;include('connect.php');}

$insertSQL = "INSERT INTO signaturelist (petition, name, phone, email, comment, region) VALUES ('".$_GET['id']."','".$_POST['name']."', '".$_POST['phone']."', '".$_POST['email']."', '".$_POST['comment']."','".$_POST['region']."')";
$insertresult = mysql_query($insertSQL);

mysql_close();
}
if($connectDatabase == TRUE){$action=TRUE;include('connect.php');}

$query="SELECT * FROM petitionlist WHERE  id = '".$_GET['id']."'" ;
$result=mysql_query($query);
$num=mysql_num_rows($result);
mysql_close();

?>


<?php



$f1=mysql_result($result,$i,"id");
$f2=htmlsymbolreplace(mysql_result($result,$i,"title"));
$f3=mysql_result($result,$i,"description");
$f4=htmlsymbolreplace(mysql_result($result,$i,"endtext"));
$f5=mysql_result($result,$i,"setting");
$f6=mysql_result($result,$i,"timestamp");

//determine display mode
if($f5="active")
{
if(isset($_POST['submit']) && $_POST['name']!= ""&& $_POST['agreement'] == "yes"){
echo "<h2>";
echo $f4;
echo "</h2>";
}
?>
<html>
<head>
<title><?echo $f2;?> - Petitions.GoodEasy.info (免费网络签名系统)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<LINK href="style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="/fckeditor/fckeditor.js"></script> 
	<script type="text/javascript"> 
 
window.onload = function()
{
	// Automatically calculates the editor base path based on the _samples directory.
	// This is usefull only for these samples. A real application should use something like this:
	// oFCKeditor.BasePath = '/include/class/fckeditor/' ;	// '/fckeditor/' is the default value.
	var sBasePath = document.location.href.substring(0,document.location.href.lastIndexOf('_samples')) ;
 
	var oFCKeditor = new FCKeditor( 'comment' ) ;
	oFCKeditor.BasePath	= '/fckeditor/' ;
       oFCKeditor.Height=300;
       oFCKeditor.Width=500;
	oFCKeditor.ReplaceTextarea() ;

}
 
	</script> 
</head>
<body>

<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a href="http://www.addthis.com/bookmark.php?v=250&amp;username=xa-4cfe0d5b239f18be" class="addthis_button_compact">Share</a>
<span class="addthis_separator">|</span>
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4cfe0d5b239f18be"></script>
<!-- AddThis Button END -->
<br />
网络签名编号<?php echo $f1; ?> | 发起时间 <?php echo $f6; ?> | <a href="/register.php">发起您自己的网络签名</a> <br /> 本网络签名网址: http://petitions.goodeasy.info<?php echo $_SERVER['REQUEST_URI'];?> 
<h1><?php echo $f2; ?></h1>
<hr>
<?php echo $f3; ?><br />
<hr>


<?php
}
if($connectDatabase == TRUE){$action=TRUE;include('connect.php');}

$signatureQuery="SELECT * FROM signaturelist WHERE  petition = '".$_GET['id']."'" ;
$signatureResult=mysql_query($signatureQuery);
$signatureNum=mysql_num_rows($signatureResult);

mysql_close();
?>
<table>
<tr>
<td>
征集到签名的总数： <h3><?php echo $signatureNum; ?></h3>
</td>
<td>
<h1>参加签名</h1>
<form method=post  >
姓名<input name=name value=" "> <br />
您对该签名活动的看法，可上传图片加入视频 <br /><textarea name=comment></textarea> <br />
联系电子邮件<input name=email value=" "> <br />
联系电话<input name=phone value=" "> <br />
您所在地区<SELECT size=1 name=region>
                    <OPTION 
                    value=""></OPTION>
                    <OPTION 
                    value="安徽">安徽</OPTION>
                    <OPTION value="北京" 
                    >北京</OPTION>

                    <OPTION value="重庆">重庆</OPTION>
                    <OPTION value="福建">福建</OPTION>
                    <OPTION 
                    value="甘肃">甘肃</OPTION>
                    <OPTION value="广东">广东</OPTION>
                    <OPTION value="广西">广西</OPTION>
                    <OPTION 
                    value="贵州">贵州</OPTION>

                    <OPTION value="海南">海南</OPTION>
                    <OPTION value="河北">河北</OPTION>
                    <OPTION 
                    value="黑龙江">黑龙江</OPTION>
                    <OPTION 
                    value="河南">河南</OPTION>
                    <OPTION value="湖北">湖北</OPTION>
                    <OPTION value="湖南">湖南</OPTION>

                    <OPTION 
                    value="内蒙古">内蒙古</OPTION>
                    <OPTION 
                    value="江苏">江苏</OPTION>
                    <OPTION value="江西">江西</OPTION>
                    <OPTION value="吉林">吉林</OPTION>
                    <OPTION 
                    value="辽宁">辽宁</OPTION>
                    <OPTION value="宁夏">宁夏</OPTION>

                    <OPTION value="青海">青海</OPTION>
                    <OPTION 
                    value="山西">山西</OPTION>
                    <OPTION value="陕西">陕西</OPTION>
                    <OPTION value="山东">山东</OPTION>
                    <OPTION 
                    value="上海">上海</OPTION>
                    <OPTION value="四川">四川</OPTION>

                    <OPTION value="天津">天津</OPTION>
                    <OPTION 
                    value="西藏">西藏</OPTION>
                    <OPTION value="新疆">新疆</OPTION>
                    <OPTION value="云南">云南</OPTION>
                    <OPTION 
                    value="浙江" >浙江</OPTION>
                    <OPTION value="澳门'>澳门</OPTION>
                  <OPTION value="香港">香港</OPTION>

                    <OPTION 
                    value="台湾">台湾</OPTION>
                    <OPTION 
                  value="其他">其他</OPTION>
                  </SELECT> <br />
<input type=hidden name=petition value="<?php echo $_GET['id'];?>">

-姓名一栏必须填写但只显示开始部分 <br />
-您的电话和电子邮件不公开，供主办方联系您之用 <br />
<input type="checkbox" name="agreement" value="yes" checked> 我同意本网络签名网站 <a target="_blank" href="/agreement.php">服务条款</a>
<input type=submit name=submit value="提交签名">
</form>
</td>
</tr>
</table>
<?php
if($signatureNum != 0)
{
?>
<h1>所有接收到的签名</h1>
<table >
<tr>
<th>姓名</th>

<th>来自</th>
<th>签名时间</th>
</tr>

<?php
$si=0;
while ($si < $signatureNum) {

$sf1=left(str_replace("<","&lt;",mysql_result($signatureResult,$si,"name")),4)."...";
$sf2=mysql_result($signatureResult,$si,"comment");
$sf3=mysql_result($signatureResult,$si,"region");
$sf4=mysql_result($signatureResult,$si,"timestamp");



?>
<tr>
<td><?php echo $sf1; ?></td>

<td><?php echo $sf3; ?></td>
<td><?php echo $sf4; ?></td>
</tr>
<tr>
<td colspan=3>看法<br />
<?php echo $sf2; ?>
<hr>
</td>
</tr>
<?php
$si++;
} 
}
?>
<?php

/* Disconnect from database */
if($connectDatabase == TRUE){$action=FALSE;include('connect.php');}
?>
<?php
include('footer_cn.php');
?>
