⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fillsurvey.php

📁 泛微协同办公系统标准版E-office V5.5的源代码内含泛微办公系统V5.5自动注册文件。
💻 PHP
字号:
<?php

session_start( );
require( "inc/init.php" );
require( "inc/mysql.php" );
require( "inc/functions.php" );
require( "inc/pfunctions.php" );
require( "inc/qfunctions.php" );
require( "inc/vfunctions.php" );
if ( $SAFE_CHECK_OK == 0 )
{
	echo "<script>window.close();</script>";
}
$varnames = array( "action", "sid", "cq" );
setvars( $varnames );
$admin = 0;
if ( $action == "preview" )
{
	$admin = 1;
}
$cq = $cq ? $cq : 1;
$qstring = "select *, UNIX_TIMESTAMP(StartDate) as starttime, UNIX_TIMESTAMP(EndDate) as endtime, UNIX_TIMESTAMP(NOW()) as nowtime from phpQSurvey where SID = \"".protectmysql( $sid )."\"";
if ( !( $masurvey = mysql_fetch_array( mysql_query( $qstring ) ) ) )
{
	header( "Location: index.php" );
	exit( );
}
if ( $masurvey['SurveyResults'] == 2 && ( isset( $HTTP_POST_VARS['results'] ) || isset( $HTTP_POST_VARS['results_x'] ) ) )
{
	header( "Location: stats.php?sid=".protecthtml( $masurvey['SID'] ) );
	exit( );
}
setlanguage( $masurvey['Language'] );
$cookiedomain = $phpQAdmin['CookieDomain'] != "" ? $phpQAdmin['CookieDomain'] : "";
setcookie( "phpQTest", "true", 0, "/", $cookiedomain );
if ( $masurvey['Active'] == "n" && $action != "preview" )
{
	$errormsg = sprintf( $phpQlang['SurveyNotActive'], $masurvey['Name'] );
}
else if ( $action != "preview" )
{
	if ( substr( $masurvey['StartDate'], 0, 10 ) != "0000-00-00" && $masurvey['nowtime'] < $masurvey['starttime'] )
	{
		$errormsg = sprintf( $phpQlang['SurveyPending'], $masurvey['Name'] );
	}
	if ( substr( $masurvey['EndDate'], 0, 10 ) != "0000-00-00" && $masurvey['endtime'] < $masurvey['nowtime'] )
	{
		$errormsg = sprintf( $phpQlang['SurveyExpired'], $masurvey['Name'] );
	}
}
$mqqcount = mysql_query( "select count(*) as ct from phpQQuestion where SID = \"".protectmysql( $sid )."\"" );
$surveyqcount = ( $maqcount = mysql_fetch_array( $mqqcount ) ) ? $maqcount['ct'] : 0;
$tablewidth = $masurvey['Width'];
$questionresult = getquestions( $admin, $cq, $surveyqcount, $masurvey );
if ( $cq == "done" && $questionresult[1] == "complete" && $action != "preview" )
{
	$sql = "SELECT COUNT(*) AS cnt FROM phpqlog WHERE SID=".$sid." AND USER_ID='".$_SESSION['LOGIN_USER_ID']."'";
	$rs = exequery( $connection, $sql );
	$row = mysql_fetch_array( $rs );
	if ( $row['cnt'] == 0 )
	{
		$sql = "INSERT INTO phpqlog (SID,USER_ID) VALUES (".$sid.",'".$_SESSION['LOGIN_USER_ID']."')";
		exequery( $connection, $sql );
	}
	if ( 0 < $surveyqcount )
	{
		$storesurvey = true;
		$ufid = $HTTP_POST_VARS['ufid'];
		if ( $ufid != "" )
		{
			$mqbdtest = mysql_query( "select UID,Email,EmailConfirm from phpQUser where BlockDupe = \"".protectmysql( $HTTP_POST_VARS['ufid'] )."\" and SID = \"".protectmysql( $sid )."\" LIMIT 1" );
			if ( $storeddata = mysql_fetch_array( $mqbdtest ) )
			{
				$storesurvey = false;
			}
		}
		else
		{
			$storesurvey = false;
		}
		$ip = $REMOTE_ADDR ? $REMOTE_ADDR : $HTTP_SERVER_VARS['REMOTE_ADDR'];
		$suarray = parsesurveyusers( $masurvey['SurveyUsers'] );
		if ( $suarray[0] )
		{
			$sql = "select UID,Email,EmailConfirm from phpQUser where IPAddr = \"".protectmysql( $ip )."\" and SID = \"".protectmysql( $sid )."\" LIMIT 1";
			$mqiptest = mysql_query( "select UID,Email,EmailConfirm from phpQUser where IPAddr = \"".protectmysql( $ip )."\" and SID = \"".protectmysql( $sid )."\" LIMIT 1" );
			if ( $storeddata = mysql_fetch_array( $mqiptest ) )
			{
				$storesurvey = false;
			}
		}
		if ( $suarray[1] )
		{
			$cookiename = "phpQ".$phpQAdmin['phpQID'].$sid;
			if ( $HTTP_COOKIE_VARS[$cookiename] || !$HTTP_COOKIE_VARS['phpQTest'] )
			{
				$storesurvey = false;
				$cuid = $HTTP_COOKIE_VARS[$cookiename];
				if ( $cuid != "" && is_numeric( $cuid ) )
				{
					$mcquery = mysql_query( "select UID,Email,EmailConfirm from phpQUser where SID = \"".protectmysql( $sid )."\" and UID = \"".protectmysql( $cuid )."\" limit 1" );
					$storeddata = mysql_fetch_array( $mcquery );
				}
				else
				{
					$storereason = "cookies";
				}
			}
		}
		if ( $storesurvey )
		{
			$uid = generateuid( );
			$cryptuid = mt_rand( 100000, 999999 );
			if ( $suarray[1] )
			{
				setcookie( $cookiename, $uid, time( ) + 31536000, "/", $cookiedomain );
			}
			mysql_query( "insert into phpQUser (UID, SID, IPAddr, BlockDupe, CheckType, CompleteDate, Confirm) values (\"".protectmysql( $uid )."\", \"".protectmysql( $sid )."\", \"".protectmysql( $ip )."\", \"".protectmysql( $ufid )."\", \"".protectmysql( $masurvey['SurveyUsers'] )."\", now(), \"".protectmysql( $cryptuid )."\")" );
			$mqqlist = mysql_query( "select * from phpQQuestion where SID = \"".protectmysql( $sid )."\" and Type != 'htmlcontent' order by SortOrder" );
			while ( $maqlist = mysql_fetch_array( $mqqlist ) )
			{
				if ( $maqlist['Type'] != "pagebreak" )
				{
					$storeanswer = storeanswer( $maqlist, $masurvey );
					if ( $storeanswer[0] )
					{
						mysql_query( "insert into phpQAnswer (UID, SID, QID, Answer) values (\"".protectmysql( $uid )."\", \"".protectmysql( $sid )."\", \"".protectmysql( $maqlist['QID'] )."\", \"".protectmysql( $storeanswer[1] )."\")" );
					}
				}
			}
			if ( $masurvey['ResponseNotice'] && $masurvey['ResponseEmail'] != "" )
			{
				$surveydata = "";
				$headers = "";
				if ( $masurvey['ResponseNotice'] == "2" )
				{
					$surveydata = recreatesurvey( $sid, $uid, "100%", $masurvey, 1 );
					$headers .= "Content-type: text/html\n";
				}
				else
				{
					$scriptloc = "";
					if ( $HTTP_HOST != "" )
					{
						$scriptloc .= "http://{$HTTP_HOST}";
					}
					else if ( $HTTP_SERVER_VARS['HTTP_HOST'] != "" )
					{
						$scriptloc .= "http://".$HTTP_SERVER_VARS['HTTP_HOST'];
					}
					$php_self = $PHP_SELF ? $PHP_SELF : $HTTP_SERVER_VARS['PHP_SELF'];
					if ( !$php_self && $HTTP_SERVER_VARS['REQUEST_URI'] )
					{
						$php_self = $HTTP_SERVER_VARS['REQUEST_URI'];
					}
					$scriptloc .= $php_self;
					$scriptloc = preg_replace( "/(.*)\\/.*/", "\\1", $scriptloc );
					$scriptloc = "{$scriptloc}/view.php?sid={$sid}&uid={$uid}";
					$surveydata = $phpQlang['RNEmailLinkText'];
					$surveydata = str_replace( "::SurveyName::", $masurvey['Name'], $surveydata );
					$surveydata = str_replace( "::ResultsLink::", $scriptloc, $surveydata );
					$mqinfo = mysql_query( "select * from phpQUser where SID = \"".protectmysql( $sid )."\" and UID = \"".protectmysql( $uid )."\"" );
					if ( $mainfo = mysql_fetch_array( $mqinfo ) )
					{
						$ipaddr = $mainfo['IPAddr'] ? $mainfo['IPAddr'] : $phpQlang['unavailable'];
						$surveydata = str_replace( "::CompleteDate::", $mainfo['CompleteDate'], $surveydata );
						$surveydata = str_replace( "::IPAddress::", $ipaddr, $surveydata );
					}
				}
				$headers .= "From: ".( $masurvey['EmailFrom'] != "" ? $masurvey['EmailFrom'] : $phpQlang['EmailDefaultFrom'] )."\n";
				mail( $masurvey['ResponseEmail'], sprintf( $phpQlang['ViewSurvey'], $masurvey['Name'] ), $surveydata, $headers );
			}
			if ( $suarray[2] && ( ini_get( "sendmail_path" ) || ini_get( "SMTP" ) ) )
			{
				echo "<html><head><meta http-equiv=\"Refresh\" content=\"0; URL=verify.php?uid={$uid}&sid={$sid}\"></head></html>";
				exit( );
			}
			if ( $masurvey['OnComplete'] == "1" && $masurvey['SurveyResults'] )
			{
				echo "<html><head><meta http-equiv=\"Refresh\" content=\"0; URL=stats.php?sid={$sid}\"></head></html>";
				exit( );
			}
			else if ( $masurvey['OnComplete'] == "2" && $masurvey['RedirectURL'] )
			{
				echo "<html><head><meta http-equiv=\"Refresh\" content=\"0; URL=".protecthtml( $masurvey['RedirectURL'] )."\"></head></html>";
				exit( );
			}
			else if ( $masurvey['OnComplete'] == "3" )
			{
				$contents = $phpQlang['YourResponse']."<BR><BR>";
			}
			else if ( $masurvey['Completed'] )
			{
				$contents = $masurvey['Completed'];
			}
			else
			{
				$defmesg = sprintf( $phpQlang['SurveyCompleted'], $masurvey['Name'] );
				$contents = printmessage( $defmesg, $tablewidth );
			}
		}
		else if ( $storereason == "cookies" )
		{
			$errormsg = sprintf( $phpQlang['SurveyCookieError'], $masurvey['Name'] );
		}
		else if ( $storeddata )
		{
			$uid = $storeddata['UID'];
			if ( $suarray[2] && ( ini_get( "sendmail_path" ) || ini_get( "SMTP" ) ) )
			{
				if ( $storeddata['Email'] == "" )
				{
					header( "Location: verify.php?uid={$uid}&sid={$sid}" );
					exit( );
				}
				else if ( $storeddata['EmailConfirm'] == "n" )
				{
					header( "Location: confirm.php?uid={$uid}&sid={$sid}" );
					exit( );
				}
			}
			if ( $masurvey['OnComplete'] == "1" && $masurvey['SurveyResults'] )
			{
				header( "Location: stats.php?sid={$sid}" );
				exit( );
			}
			else if ( $masurvey['OnComplete'] == "2" && $masurvey['RedirectURL'] )
			{
				header( "Location: ".protecthtml( $masurvey['RedirectURL'] ) );
				exit( );
			}
			else if ( $masurvey['OnComplete'] == "3" )
			{
				$contents = $phpQlang['YourResponse']."<BR><BR>";
				$contents .= recreatesurvey( $sid, $uid, $masurvey['Width'], $masurvey, 1 );
			}
			else if ( $masurvey['Completed'] )
			{
				$contents = $masurvey['Completed'];
			}
			else
			{
				$errormsg = sprintf( $phpQlang['SurveyCompletedAlready'], $masurvey['Name'] );
			}
		}
		else
		{
			$errormsg = sprintf( $phpQlang['SurveyCompletedAlready'], $masurvey['Name'] );
		}
	}
}
else if ( $cq == "done" && $questionresult[1] == "complete" && $action == "preview" )
{
	$prevcompmesg = sprintf( $phpQlang['SurveyPreviewCompleted'], $masurvey['Name'] );
	$contents = "<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 WIDTH=100%>\n";
	$contents .= "<FORM>\n";
	$contents .= "<TR><TD ALIGN=center STYLE=\"".$masurvey['ErrorStyle']."\">";
	$contents .= "{$prevcompmesg}</TD></TR>\n";
	$contents .= "<TR><TD>".$masurvey['Completed']."</TD></TR>\n";
	$contents .= "<TR><TD ALIGN=center><INPUT TYPE=button ONCLICK=\"window.close();\" VALUE=\"".$phpQlang['Close']."\"></TD></TR>\n";
	$contents .= "</FORM>\n";
	$contents .= "</TABLE>\n";
}
else
{
	$contents .= createsurvey( $sid, $cq, $tablewidth, $questionresult[2], $admin );
}
if ( $surveyqcount == 0 )
{
	$errormsg = sprintf( $phpQlang['SurveyEmpty'], $masurvey['Name'] );
}
$contents = $errormsg ? printmessage( $errormsg, $tablewidth ) : $contents;
createpage( $sid, $masurvey['Name'], $contents, false, "" );
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -