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

📄 ofunctions.php

📁 调查问卷系统源码。想下的就下吧。不要条件
💻 PHP
字号:
<?
################################################################################
# phpQuestionnaire                           Version 2.2                       #
# Copyright 2003-2005 chumpsoft, inc.        March 28, 2005                    #
################################################################################
#              SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTS              #
################################################################################

function GrabEntries ($sid, $qid, $oid, $masurvey, $tp, $st, $cc, $admin) {
	global $phpQlang;
	$imgurl = $GLOBALS["phpQImageDir"];
	$maxleftright = 4;

	$title = ($tp == "o") ? GrabTitle($sid, $qid, $oid) : GrabTitle2($sid, $qid);
	$limit = GrabLimit(); 

	$cc = $cc ? $cc : 1;

	$moid = ProtectMySQL($oid);
	$qstring = "SELECT COUNT(*) as num FROM phpQAnswer, phpQQuestion WHERE phpQAnswer.SID = \"".ProtectMySQL($sid)."\" AND phpQAnswer.QID = \"".ProtectMySQL($qid)."\" AND phpQAnswer.QID=phpQQuestion.QID AND phpQAnswer.SID=phpQQuestion.SID AND (((phpQQuestion.type='textarea' OR phpQQuestion.type='textfield') AND phpQAnswer.Answer != '') OR (phpQQuestion.type!='textarea' AND phpQQuestion.type !='textfield' AND phpQAnswer.Answer RLIKE \"(^|\\\\|)$moid\\\\|\"))";
	if ($st == 'u' || $st == 'v') {
		$cletter = ($st == 'v') ? 'y' : 'n';
		$qstring = "SELECT COUNT(*) as num FROM phpQAnswer, phpQQuestion, phpQUser WHERE phpQAnswer.SID = \"".ProtectMySQL($sid)."\" AND phpQAnswer.QID = \"".ProtectMySQL($qid)."\" AND phpQAnswer.UID=phpQUser.UID AND phpQAnswer.QID=phpQQuestion.QID AND phpQAnswer.SID=phpQQuestion.SID AND (((phpQQuestion.type='textarea' OR phpQQuestion.type='textfield') AND phpQAnswer.Answer != '') OR (phpQQuestion.type!='textarea' AND phpQQuestion.type !='textfield' AND phpQUser.EmailConfirm=\"$cletter\" AND phpQAnswer.Answer RLIKE \"(^|\\\\|)$moid\\\\|\"))";
	}
	$mqmax = mysql_query($qstring);
	$mamax = mysql_fetch_array($mqmax);
	$max = $mamax["num"];
	$start = ($cc-1 < $max) ? $cc-1 : 0;
	$end = ($cc+$limit-2 < $max) ? $cc+$limit-2 : $max-1;

	$bordercol = "<TD HEIGHT=16 BGCOLOR=#333366 BACKGROUND=\"admin/images/%bound%\"><IMG SRC=\"admin/images/invdot.gif\" WIDTH=2 HEIGHT=1 ALT=\"\"></TD>";
	if (!$admin) {
		$bordercol = "<TD HEIGHT=16 STYLE=\"".$masurvey["ResultsBorder"]."\"><IMG SRC=\"admin/images/invdot.gif\" WIDTH=2 HEIGHT=1 ALT=\"\"></TD>";
	}

	$leftbordera = $bordercol;
	$rightbordera = $bordercol;
	$leftborderr = $bordercol;
	$rightborderr = $bordercol;
	if ($admin) {
		$leftbordera = str_replace('%bound%', 'bound2.gif', $bordercol);
		$rightbordera = str_replace('%bound%', 'bound3.gif', $bordercol);
		$leftborderr = str_replace('%bound%', 'bound7.gif', $bordercol);
		$rightborderr = str_replace('%bound%', 'bound8.gif', $bordercol);
	}

	$answerlist = GrabFieldAnswers ($qid, $oid, $masurvey, $tp, $start, $limit, $st, $admin, $leftbordera, $rightbordera, $leftborderr, $rightborderr);

	$contents = "<TABLE CELLPADDING=2 CELLSPACING=0 BORDER=0 WIDTH=100%><TR><TD>\n";
	if ($admin) {
		$contents .= "<IMG SRC=\"$imgurl/headingwizard1.gif\" WIDTH=112 HEIGHT=17 ALT=\"".$phpQlang['TextfieldResults']."\">";
	}
	else {
		$contents .= "<H2>".$phpQlang['TextfieldResults']."</H2>";
	}
	$contents .= "</TD></TR><TR><TD>";

	$contents .= "<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 WIDTH=100%>\n";
	if ($admin) {
		$contents .= "<TR BGCOLOR=#333366><TD COLSPAN=2 ALIGN=center STYLE=\"padding-left: 5px; padding-right: 5px;\"><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><TR><TD STYLE=\"color: #FFFFFF;\">";
		$contents .= "<B>".ProtectHTML($title)."</B></TD><TD ALIGN=right><SPAN STYLE=\"color: #99CCFF;\"><NOBR><B>".$phpQlang['Total'].":</B> $max</NOBR></SPAN></TD></TR></TABLE>";
		$contents .= "</TD><TD VALIGN=TOP ALIGN=right><IMG SRC=\"admin/images/bound1.gif\" WIDTH=7 HEIGHT=17 ALT=\"\"></TD></TR>\n";
	}
	else {
		$contents .= "<TR><TD HEIGHT=17 COLSPAN=3 ALIGN=center STYLE=\"padding-left: 5px; padding-right: 5px; ".$masurvey["ResultsBorder"]."\"><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>";
		$contents .= "<TR><TD STYLE=\"".$masurvey["ResultsBorder"]."\"><B>".ProtectHTML($title)."</B></TD><TD ALIGN=right STYLE=\"".$masurvey["ResultsBorder"]."\"><NOBR><B>".$phpQlang['Total'].":</B> $max</NOBR></TD></TR></TABLE></TD></TR>\n";
	}

	for ($i=0; $i<$limit && $i<count($answerlist); $i++) {
		$contents .= $answerlist[$i];
	}

	if (!$max) {
		$style = $admin ? ' BGCOLOR=#FFFFFF' : " STYLE=\"".$masurvey["ResultsAnswer"]."\"";
		$contents .= "<TR>$leftbordera";
		$contents .= "<TD WIDTH=100% ALIGN=center$style>".$phpQlang['NoResults']."</TD>";
		$contents .= "$rightbordera</TR>";
	}

	if ($admin) {
		$contents .= "<TR BGCOLOR=#333366><TD><IMG SRC=\"admin/images/bound9.gif\" WIDTH=7 HEIGHT=17 ALT=\"\"></TD>";
		$contents .= "<TD COLSPAN=2 ALIGN=center STYLE=\"color: #FFFFFF;\">&nbsp;";
	}
	else {
		 $contents .= "<TR><TD COLSPAN=3 STYLE=\"".$masurvey["ResultsBorder"]."\" ALIGN=center HEIGHT=17>&nbsp;";
	}

	$next = $cc+$limit;
	$prev = $cc-$limit;
	$lastindex = ceil($max/$limit);

	if ($next <= $max || $prev > 0) {
		$fa = $admin ? '&fa=1' : '';
		$baseq = "sid=$sid&qid=$qid&oid=$oid&tp=$tp&st=$st$fa";
		$style = $admin ? 'color: #FFFFFF;' : $masurvey["ResultsBorder"];
		$selstyle = $admin ? ' STYLE="color: #99CCFF;"' : '';
		$class = $admin ? ' CLASS=link' : '';

		# Previous Link

		if ($prev > 0) {
			$contents .= "<A HREF=\"viewoption.php?$baseq&cc=$prev\"$class STYLE=\"$style\"><B>".$phpQlang['Previous']."</B></A> : ";
		}

		# Index Links

		for ($k=1; $k<=$lastindex; $k++) {
			$startindex = floor($start/$limit) + 1;
			if ($k == 1 || $k == $lastindex ||
					($k >= $startindex-$maxleftright && $k <= $startindex+$maxleftright)) {
				$indexcc = ($k-1) * $limit + 1;
				$indexloc = "viewoption.php?$baseq&cc=$indexcc";
				$indexlink = "<A HREF=\"$indexloc\"$class STYLE=\"$style\">$k</A>";
				$contents .= ($k > 1) ? " " : "";
				$contents .= ($k == $lastindex && $k-1 > $startindex+$maxleftright && $lastindex > 2*$maxleftright+1)
						           ? "... " : "";
				$contents .= ($indexcc-1 == $start) ? "<B$selstyle>[$k]</B>" : "<B>$indexlink</B>";
				$contents .= ($k == 1 && $k+1 < $startindex-$maxleftright && $lastindex > 2*$maxleftright+1)
				    ? " ..." : "";
			}
		}

		# Next Link

		if ($next <= $max) {
			$contents .= " : <A HREF=\"viewoption.php?$baseq&cc=$next\"$class STYLE=\"$style\"><B>".$phpQlang['Next']."</B></A>";
		}
	}

	$contents .= "</TD></TR>\n";
	$contents .= "</TABLE></TD></TR></TABLE>\n";

	return $contents;
}

function GrabFieldAnswers ($qid, $oid, $masurvey, $tp, $start, $limit, $st, $admin, $leftbordera, $rightbordera, $leftborderr, $rightborderr) {
	global $phpQlang;
	$sid = $masurvey["SID"];
	$acount = 0;

	$moid = ProtectMySQL($oid);
	$qclause = '';
	if ($st == 'u' || $st == 'v') {
		$cletter = ($st == 'v') ? 'y' : 'n';
		$qclause = " AND phpQUser.EmailConfirm=\"$cletter\"";
	}
	$qstring = "select phpQAnswer.Answer, phpQUser.UID, phpQUser.Email, phpQUser.IPAddr, date_format(phpQUser.CompleteDate, '".$phpQlang["MySQLDateFormat"]."') as mdate from phpQAnswer, phpQUser, phpQQuestion where phpQAnswer.SID = \"".ProtectMySQL($sid)."\" and phpQAnswer.QID = \"".ProtectMySQL($qid)."\" and phpQAnswer.UID=phpQUser.UID AND phpQAnswer.QID=phpQQuestion.QID AND phpQAnswer.SID=phpQQuestion.SID AND (((phpQQuestion.type='textarea' OR phpQQuestion.type='textfield') AND phpQAnswer.Answer != '') OR (phpQQuestion.type!='textarea' AND phpQQuestion.type !='textfield'$qclause AND phpQAnswer.Answer RLIKE \"(^|\\\\|)$moid\\\\|\")) ORDER BY phpQUser.CompleteDate DESC LIMIT $start,$limit";
	$mqanswer = mysql_query($qstring);

	for ($i=0; $i<mysql_num_rows($mqanswer); $i++) {
		$maanswer = mysql_fetch_array($mqanswer);

		$mdate = $maanswer["mdate"];
		if ($admin) {
			$mdate = "<A HREF=\"view.php?sid=$sid&uid=".$maanswer["UID"]."\" CLASS=link TARGET=_blank>".$maanswer["mdate"]."</A>";
		}
		$heading = "<B>".$phpQlang["Date"].":</B> $mdate&nbsp;&nbsp;&nbsp;";
		if (substr($masurvey["SurveyUsers"],2,1)) {
			$email = $maanswer["Email"] ? $maanswer["Email"] : $phpQlang['notentered'];
			$email = (strlen($email) > 20) ? substr($email,0,20)."..." : $email;
			$heading .= "<B>".$phpQlang['Email'].":</B> ".ProtectHTML($email);
		}
		else {
			$heading .= "<B>".$phpQlang['IP'].":</B> ".$maanswer["IPAddr"];
		}

		if ($tp == "t") {
			$tempanswer = "<TR>$leftbordera";
			if ($admin) {
				$tempanswer .= "<TD BGCOLOR=#FFFFFF WIDTH=100%><B>".($acount+1+$start).".</B>&nbsp;$heading</TD>";
			}
			else {
				$tempanswer .= "<TD WIDTH=100% STYLE=\"padding-left: 5px; padding-right: 5px; ".$masurvey["ResultsAnswer"]."\"><B>".($acount+1+$start).".</B>&nbsp;$heading</TD>";
			}
			$tempanswer .= "$rightbordera</TR><TR>$leftborderr";
			if ($admin) {
				$tempanswer .= "<TD BGCOLOR=#DDEEFF>".ProtectHTML($maanswer["Answer"])."</TD>";
			}
			else {
				$tempanswer .= "<TD STYLE=\"padding-left: 5px; padding-right: 5px; ".$masurvey["ResultsStats"]."\">".ProtectHTML($maanswer["Answer"])."</TD>";
			}
			$tempanswer .= "$rightborderr</TR>";

			$alist[] = $tempanswer;
			$acount++;
		}
		else {
			$choices = split("\|\|", $maanswer["Answer"]);
			for ($j=0; $j<sizeof($choices); $j++) {
				if (substr($choices[$j],0,1) == "O") {
					$answer = split("\|", $choices[$j]);
					if ($answer[0] == $oid) {
						$realanswer = ProtectHTML($answer[1]);

						$tempanswer = "<TR>$leftbordera";
						if ($admin) {
							$tempanswer .= "<TD BGCOLOR=#FFFFFF WIDTH=100%><B>".($acount+1+$start).".</B>&nbsp;$heading</TD>";
						}
						else {
							$tempanswer .= "<TD WIDTH=100% STYLE=\"padding-left: 5px; padding-right: 5px; ".$masurvey["ResultsAnswer"]."\"><B>".($acount+1+$start).".</B>&nbsp;$heading</TD>";
						}
						$tempanswer .= "$rightbordera</TR><TR>$leftborderr";
						if ($admin) {
							$tempanswer .= "<TD BGCOLOR=#DDEEFF>$realanswer</TD>";
						}
						else {
							$tempanswer .= "<TD STYLE=\"padding-left: 5px; padding-right: 5px; ".$masurvey["ResultsStats"]."\">$realanswer</TD>";
						}
						$tempanswer .= "$rightborderr</TR>";

						$alist[] = $tempanswer;
						$acount++;
					}
				}
			}
		}
	}

	return $alist;
}

function GrabTitle ($sid, $qid, $oid) {
	$mqquestion = mysql_query("select * from phpQQuestion where SID = \"".ProtectMySQL($sid)."\" and QID = \"".ProtectMySQL($qid)."\"");
	if ($maquestion = mysql_fetch_array($mqquestion)) {
		$choice = split("\|\|\|", $maquestion["Answer"]);
		for ($i=0; $i<sizeof($choice); $i++) {
			$option = split("\|\|", $choice[$i]);
			if ("O".$option[1] == $oid && substr($option[2],0,11) == "Textfield:(") {
				return substr($option[2],11,-1);
			}
		}
	}

	return "";
}

function GrabTitle2 ($sid, $qid) {
	$mqquestion = mysql_query("select * from phpQQuestion where SID = \"".ProtectMySQL($sid)."\" and QID = \"".ProtectMySQL($qid)."\"");
	if ($maquestion = mysql_fetch_array($mqquestion)) {
		return $maquestion["Question"];
	}

	return "";
}

function GrabLimit () {
	global $phpQAdmin;
	return $phpQAdmin["PopupLimit"] ? $phpQAdmin["PopupLimit"] : 20;
}

?>

⌨️ 快捷键说明

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