📄 ofunctions.php
字号:
<?php
function grabentries( $sid, $qid, $oid, $masurvey, $tp, $st, $cc, $admin )
{
global $phpQlang;
$imgurl = $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 ></TD>";
if ( !$admin )
{
$bordercol = "<TD HEIGHT=16 STYLE=\"".$masurvey['ResultsBorder']."\"></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 .= $phpQlang['TextfieldResults'];
}
else
{
$contents .= $phpQlang['TextfieldResults'];
}
$contents .= "</TD></TR><TR><TD>";
$contents .= "<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 WIDTH=100%>\n";
if ( $admin )
{
$contents .= "<TR class=\"TableHeader\"><TD COLSPAN=2 ALIGN=center STYLE=\"padding-left: 5px; padding-right: 5px;\"><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><TR><TD>";
$contents .= "<B>".protecthtml( $title )."</B></TD><TD ALIGN=right><NOBR><B>".$phpQlang['Total'].":</B> {$max}</NOBR></TD></TR></TABLE>";
$contents .= "</TD><TD VALIGN=TOP ALIGN=right></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";
}
$i = 0;
for ( ; $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><TD></TD>";
$contents .= "<TD COLSPAN=2 ALIGN=center> ";
}
else
{
$contents .= "<TR><TD COLSPAN=3 STYLE=\"".$masurvey['ResultsBorder']."\" ALIGN=center HEIGHT=17> ";
}
$next = $cc + $limit;
$prev = $cc - $limit;
$lastindex = ceil( $max / $limit );
if ( $next <= $max || 0 < $prev )
{
$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" : "";
if ( 0 < $prev )
{
$contents .= "<A HREF=\"viewoption.php?{$baseq}&cc={$prev}\"{$class} STYLE=\"{$style}\"><B>".$phpQlang['Previous']."</B></A> : ";
}
$k = 1;
for ( ; $k <= $lastindex; ++$k )
{
$startindex = floor( $start / $limit ) + 1;
if ( $k == 1 || $k == $lastindex || $startindex - $maxleftright <= $k && $k <= $startindex + $maxleftright )
{
$indexcc = ( $k - 1 ) * $limit + 1;
$indexloc = "viewoption.php?{$baseq}&cc={$indexcc}";
$indexlink = "<A HREF=\"{$indexloc}\"{$class} STYLE=\"{$style}\">{$k}</A>";
$contents .= 1 < $k ? " " : "";
$contents .= $k == $lastindex && $startindex + $maxleftright < $k - 1 && 2 * $maxleftright + 1 < $lastindex ? "... " : "";
$contents .= $indexcc - 1 == $start ? "<B{$selstyle}>[{$k}]</B>" : "<B>{$indexlink}</B>";
$contents .= $k == 1 && $k + 1 < $startindex - $maxleftright && 2 * $maxleftright + 1 < $lastindex ? " ..." : "";
}
}
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 );
$i = 0;
for ( ; $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} ";
if ( substr( $masurvey['SurveyUsers'], 2, 1 ) )
{
$email = $maanswer['Email'] ? $maanswer['Email'] : $phpQlang['notentered'];
$email = 20 < strlen( $email ) ? 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> {$heading}</TD>";
}
else
{
$tempanswer .= "<TD WIDTH=100% STYLE=\"padding-left: 5px; padding-right: 5px; ".$masurvey['ResultsAnswer']."\"><B>".( $acount + 1 + $start ).".</B> {$heading}</TD>";
}
$tempanswer .= "{$rightbordera}</TR><TR>{$leftborderr}";
if ( $admin )
{
$tempanswer .= "<TD>".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'] );
$j = 0;
for ( ; $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 class=\"TableLine2\" WIDTH=100%><B>".( $acount + 1 + $start ).".</B> {$heading}</TD>";
}
else
{
$tempanswer .= "<TD WIDTH=100% STYLE=\"padding-left: 5px; padding-right: 5px; ".$masurvey['ResultsAnswer']."\"><B>".( $acount + 1 + $start ).".</B> {$heading}</TD>";
}
$tempanswer .= "{$rightbordera}</TR><TR>{$leftborderr}";
if ( $admin )
{
$tempanswer .= "<TD class=\"TableLine1\">{$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'] );
$i = 0;
for ( ; $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 + -