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

📄 qfunctions.php

📁 泛微协同办公系统标准版E-office V5.5的源代码内含泛微办公系统V5.5自动注册文件。
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		$contents .= "<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0><TR>\n";
		$choices = split( "\\|\\|\\|", $answer );
		$count = 0;
		$i = 0;
		for ( ;	$i < sizeof( $choices );	++$i	)
		{
			$tfanswer = "";
			$parts = split( "\\|\\|", $choices[$i] );
			$subqid = $parts[1];
			if ( $HTTP_POST_VARS["Q".$qid."Answered"] )
			{
				$checked = "";
				$checked = substr( $HTTP_POST_VARS["Q".$qid], 1 ) == $subqid ? "CHECKED" : "";
				$tfanswer = $HTTP_POST_VARS["Q".$qid."O".$subqid];
			}
			else
			{
				$checked = $parts[3] == "D" ? "CHECKED" : "";
			}
			if ( $uidanswer )
			{
				if ( substr( $uidanswer, 0, 1 ) == "O" )
				{
					$radiochoice = split( "\\|", $uidanswer );
					$checked = substr( $radiochoice[0], 1 ) == $subqid ? "CHECKED" : "";
					$tfanswer = $radiochoice[0] == "O".$subqid && $radiochoice[1] ? $radiochoice[1] : "";
				}
				else
				{
					$checked = substr( $uidanswer, 1 ) == $subqid ? "CHECKED" : "";
				}
			}
			$radioid = "Q".$qid."_".$subqid;
			if ( substr( $parts[2], 0, 11 ) == "Textfield:(" )
			{
				$tfanswer = protecthtml( $tfanswer );
				$choicetext = substr( $parts[2], 11, strlen( $parts[2] ) - 12 );
				if ( $print )
				{
					$contents .= $checked ? "<TD STYLE=\"{$answertextstyle}\">".freehtml( $choicetext )."&nbsp;[{$tfanswer}]</TD>" : "";
				}
				else
				{
					$contents .= "<TD STYLE=\"{$answerinputstyle}\"><INPUT TYPE=radio NAME=Q{$qid} {$checked} ID=\"{$radioid}\" VALUE=\"O{$subqid}\"></TD>";
					$contents .= "<TD STYLE=\"{$answertextstyle}\"><LABEL FOR=\"{$radioid}\">".freehtml( $choicetext )."</LABEL>&nbsp;</TD>";
					$contents .= "<TD STYLE=\"{$answerinputstyle}\"><INPUT TYPE=text STYLE=\"{$answerstyle}\" {$attributes} ";
					$contents .= "NAME=Q".$qid."O{$subqid} VALUE=\"{$tfanswer}\"></TD>\n";
				}
			}
			else if ( $print )
			{
				$contents .= $checked ? "<TD STYLE=\"{$answertextstyle}\">".freehtml( $parts[2] )."</TD>\n" : "";
			}
			else
			{
				$contents .= "<TD STYLE=\"{$answerinputstyle}\"><INPUT TYPE=radio NAME=Q{$qid} {$checked} ID=\"{$radioid}\" VALUE=\"N{$subqid}\"></TD>";
				$contents .= "<TD STYLE=\"{$answertextstyle}\" COLSPAN=2><LABEL FOR=\"{$radioid}\">".freehtml( $parts[2] )."</LABEL>&nbsp;</TD>\n";
			}
			if ( $print )
			{
				$count += $checked ? 1 : 0;
			}
			else
			{
				$count = $i;
			}
			if ( ( $count + 1 ) % $colnumb == 0 && $count != sizeof( $choices ) )
			{
				$contents .= "</TR><TR>\n";
			}
		}
		$contents .= "</TR></TABLE>\n";
		$contents .= "</TD></TR></TABLE>\n";
		break;
	case "select" :
		$contents .= "<TABLE CELLPADDING=2 CELLSPACING=0 BORDER=0>\n";
		if ( $print )
		{
			$contents .= "<TR><TD WIDTH={$indent}></TD><TD>\n";
			$contents .= "<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0><TR>\n";
		}
		else
		{
			$contents .= "<TR><TD WIDTH={$indent}></TD><TD STYLE=\"{$answerinputstyle}\">\n";
			$contents .= "<SELECT NAME=Q{$qid} STYLE=\"{$answertextstyle}\">";
		}
		$choices = split( "\\|\\|\\|", $answer );
		$seltextfield = 0;
		$tfanswer = "";
		$i = 0;
		for ( ;	$i < sizeof( $choices );	++$i	)
		{
			$parts = split( "\\|\\|", $choices[$i] );
			$subqid = $parts[1];
			if ( $HTTP_POST_VARS["Q".$qid."Answered"] )
			{
				$selected = "";
				$selected = substr( $HTTP_POST_VARS["Q".$qid], 1 ) == $subqid ? "SELECTED" : "";
				$tfanswer = $HTTP_POST_VARS["Q".$qid."O".$subqid] != "" ? $HTTP_POST_VARS["Q".$qid."O".$subqid] : $tfanswer;
			}
			else
			{
				$selected = $parts[3] == "D" ? "SELECTED" : "";
			}
			if ( $uidanswer )
			{
				if ( substr( $uidanswer, 0, 1 ) == "O" )
				{
					$radiochoice = split( "\\|", $uidanswer );
					$selected = substr( $radiochoice[0], 1 ) == $subqid ? "SELECTED" : "";
					$tfanswer = substr( $radiochoice[0], 1 ) == $subqid && $radiochoice[1] != "" ? $radiochoice[1] : "";
				}
				else
				{
					$selected = substr( $uidanswer, 1 ) == $subqid ? "SELECTED" : "";
				}
			}
			if ( substr( $parts[2], 0, 11 ) == "Textfield:(" )
			{
				$seltextfield = $subqid;
				$choicetext = substr( $parts[2], 11, -1 );
				if ( $print )
				{
					$tfanswer = $html->protecthtml( $tfanswer );
					$contents .= $selected ? "<TD STYLE=\"{$answertextstyle}\">{$choicetext}&nbsp;[{$tfanswer}]</TD>" : "";
				}
				else
				{
					$contents .= "<OPTION {$selected} VALUE=\"O{$subqid}\">".$choicetext."</OPTION>";
				}
			}
			else if ( $print )
			{
				$contents .= $selected ? "<TD STYLE=\"{$answertextstyle}\">".$parts[2]."</TD>" : "";
			}
			else
			{
				$contents .= "<OPTION {$selected} VALUE=\"N{$subqid}\">".$parts[2]."</OPTION>";
			}
		}
		if ( $print )
		{
			$contents .= "</TR></TABLE></TD></TR>\n";
		}
		else
		{
			$contents .= "</SELECT></TD></TR>\n";
		}
		if ( $seltextfield && !$print )
		{
			$tfanswer = protecthtml( $tfanswer );
			$contents .= "<TR><TD></TD><TD STYLE=\"{$answerinputstyle}\"><INPUT TYPE=text STYLE=\"{$answerstyle}\" {$attributes} ";
			$contents .= "NAME=Q".$qid."O".$seltextfield." VALUE=\"{$tfanswer}\" size=\"50\"></TD></TR>\n";
		}
		$contents .= "</TABLE>\n";
		break;
	case "checkbox" :
		$contents .= "<TABLE CELLPADDING=2 CELLSPACING=0 BORDER=0>\n";
		$contents .= "<TR><TD WIDTH={$indent}></TD><TD>\n";
		$contents .= "<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0><TR>\n";
		$choices = split( "\\|\\|\\|", $answer );
		$count = 0;
		$i = 0;
		for ( ;	$i < sizeof( $choices );	++$i	)
		{
			$parts = split( "\\|\\|", $choices[$i] );
			$subqid = $parts[1];
			$tfanswer = "";
			if ( $HTTP_POST_VARS["Q".$qid."Answered"] )
			{
				$checked = "";
				$j = 0;
				for ( ;	$j < sizeof( $HTTP_POST_VARS["Q".$qid] );	++$j	)
				{
					$checked = substr( $HTTP_POST_VARS["Q".$qid][$j], 1 ) == $subqid ? "CHECKED" : $checked;
				}
				$tfanswer = $HTTP_POST_VARS["Q".$qid."O".$subqid];
			}
			else
			{
				$checked = $parts[3] == "D" ? "CHECKED" : "";
			}
			if ( $uidanswer )
			{
				$tfanswer = "";
				$tempchecked = "";
				$uidchoices = split( "\\|\\|", $uidanswer );
				$j = 0;
				for ( ;	$j < sizeof( $uidchoices );	++$j	)
				{
					if ( substr( $uidchoices[$j], 0, 1 ) == "O" )
					{
						$txtchoice = split( "\\|", $uidchoices[$j] );
						$tempchecked = substr( $txtchoice[0], 1 ) == $subqid ? "CHECKED" : $tempchecked;
						if ( substr( $txtchoice[0], 1 ) == $subqid && $txtchoice[1] != "" )
						{
							$tfanswer = $txtchoice[1];
						}
					}
					else
					{
						$tempchecked = substr( $uidchoices[$j], 1 ) == $subqid ? "CHECKED" : $tempchecked;
					}
				}
				$checked = $tempchecked ? $tempchecked : "";
			}
			$checkid = "Q".$qid."_".$subqid;
			if ( substr( $parts[2], 0, 11 ) == "Textfield:(" )
			{
				$tfanswer = protecthtml( $tfanswer );
				$choicetext = substr( $parts[2], 11, strlen( $parts[2] ) - 12 );
				if ( $print )
				{
					$contents .= $checked ? "<TD STYLE=\"{$answertextstyle}\">".freehtml( $choicetext )."&nbsp;[{$tfanswer}]</TD>" : "";
				}
				else
				{
					$contents .= "<TD STYLE=\"{$answerinputstyle}\"><INPUT TYPE=checkbox NAME=Q".$qid."[] {$checked} ID=\"{$checkid}\" VALUE=\"O{$subqid}\"></TD>";
					$contents .= "<TD STYLE=\"{$answertextstyle}\"><LABEL FOR=\"{$checkid}\">".freehtml( $choicetext )."</LABEL>&nbsp;</TD>";
					$contents .= "<TD STYLE=\"{$answerinputstyle}\"><INPUT TYPE=text STYLE=\"{$answerstyle}\" {$attributes} ";
					$contents .= "NAME=Q".$qid."O{$subqid} VALUE=\"{$tfanswer}\" size=\"45\"></TD>\n";
				}
			}
			else if ( $print )
			{
				$contents .= $checked ? "<TD STYLE=\"{$answertextstyle}\">".freehtml( $parts[2] )."</TD>" : "";
			}
			else
			{
				$contents .= "<TD STYLE=\"{$answerinputstyle}\"><INPUT TYPE=checkbox NAME=Q".$qid."[] {$checked} ID=\"{$checkid}\" VALUE=\"N{$subqid}\"></TD>";
				$contents .= "<TD STYLE=\"{$answertextstyle}\" COLSPAN=2><LABEL FOR=\"{$checkid}\">".freehtml( $parts[2] )."</LABEL>&nbsp;</TD>\n";
			}
			if ( $print )
			{
				$count += $checked ? 1 : 0;
			}
			else
			{
				$count = $i;
			}
			if ( ( $count + 1 ) % $colnumb == 0 && $count != sizeof( $choices ) )
			{
				$contents .= "</TR><TR>\n";
			}
		}
		$contents .= "</TR></TABLE>\n";
		$contents .= "</TD></TR></TABLE>\n";
		break;
	case "selectmult" :
		$contents .= "<TABLE CELLPADDING=2 CELLSPACING=0 BORDER=0>\n";
		if ( $print )
		{
			$contents .= "<TR><TD WIDTH={$indent}></TD><TD>\n";
			$contents .= "<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0><TR>\n";
		}
		else
		{
			$contents .= "<TR><TD WIDTH={$indent}></TD><TD STYLE=\"{$answerinputstyle}\">\n";
			$contents .= "<SELECT NAME=Q".$qid."[] STYLE=\"{$answertextstyle}\" SIZE={$mult} MULTIPLE>";
		}
		$choices = split( "\\|\\|\\|", $answer );
		$seltextfield = 0;
		$optext = "";
		$i = 0;
		for ( ;	$i < sizeof( $choices );	++$i	)
		{
			$parts = split( "\\|\\|", $choices[$i] );
			$subqid = $parts[1];
			if ( $HTTP_POST_VARS["Q".$qid."Answered"] )
			{
				$optext = $HTTP_POST_VARS["Q".$qid."O".$subqid] != "" ? $HTTP_POST_VARS["Q".$qid."O".$subqid] : $optext;
				$selected = "";
				if ( $HTTP_POST_VARS["Q".$qid."O".$subqid] != "" )
				{
					echo "test";
				}
				$j = 0;
				for ( ;	$j < sizeof( $HTTP_POST_VARS["Q".$qid] );	++$j	)
				{
					$selected = substr( $HTTP_POST_VARS["Q".$qid][$j], 1 ) == $subqid ? "SELECTED" : $selected;
				}
			}
			else
			{
				$selected = $parts[3] == "D" ? "SELECTED" : "";
			}
			if ( $uidanswer )
			{
				$tempselected = "";
				$uidchoices = split( "\\|\\|", $uidanswer );
				$j = 0;
				for ( ;	$j < sizeof( $uidchoices );	++$j	)
				{
					$optionsplit = split( "\\|", $uidchoices[$j] );
					$optext = sizeof( $optionsplit ) == 2 ? $optionsplit[1] : "";
					$tempselected = substr( $optionsplit[0], 1 ) == $subqid ? "SELECTED" : $tempselected;
				}
				$selected = $tempselected ? $tempselected : "";
			}
			if ( substr( $parts[2], 0, 11 ) == "Textfield:(" )
			{
				$seltextfield = $subqid;
				$choicetext = substr( $parts[2], 11, strlen( $parts[2] ) - 12 );
				if ( $print )
				{
					$contents .= $selected ? "<TR><TD STYLE=\"{$answertextstyle}\">{$choicetext}&nbsp;[".protecthtml( $optext )."]</TD></TR>" : "";
				}
				else
				{
					$contents .= "<OPTION {$selected} VALUE=\"O{$subqid}\">".$choicetext."</OPTION>";
				}
			}
			else if ( $print )
			{
				$contents .= $selected ? "<TR><TD STYLE=\"{$answertextstyle}\">{$parts['2']}</TD></TR>" : "";
			}
			else
			{
				$contents .= "<OPTION {$selected} VALUE=\"N{$subqid}\">".$parts[2]."</OPTION>";
			}
		}
		if ( $print )
		{
			$contents .= "</TABLE></TD></TR>";
		}
		else
		{
			$contents .= "</SELECT></TD></TR>\n";
		}
		if ( $seltextfield && !$print )
		{
			$tfanswer = protecthtml( $optext );
			$contents .= "<TR><TD></TD><TD STYLE=\"{$answerinputstyle}\"><INPUT TYPE=text STYLE=\"{$answerstyle}\" {$attributes} ";
			$contents .= "NAME=Q".$qid."O".$seltextfield." VALUE=\"{$tfanswer}\" size=\"50\"></TD></TR>\n";
		}
		$contents .= "</TABLE>\n";
		break;
	case "textfield" :
		$defaultanswer = $uidanswer ? $uidanswer : $defaultanswer;
		$defaultanswer = $HTTP_POST_VARS["Q".$qid."Answered"] ? $HTTP_POST_VARS["Q".$qid] : $defaultanswer;
		$defaultanswer = protecthtml( $defaultanswer );
		$contents .= "<TABLE CELLPADDING=2 CELLSPACING=0 BORDER=0><TR>\n";
		$contents .= "<TD WIDTH={$indent}></TD>\n";
		if ( $print )
		{
			$contents .= "<TD STYLE=\"{$answertextstyle}\">{$defaultanswer}</TD>\n";
		}
		else
		{
			$contents .= "<TD STYLE=\"{$answerinputstyle}\">";
			$contents .= "<INPUT TYPE=text STYLE=\"{$answerstyle}\" NAME=Q{$qid} {$attributes} VALUE=\"{$defaultanswer}\" ></TD>\n";
		}
		$contents .= "</TR></TABLE>\n";
		break;
	case "textarea" :
		$defaultanswer = $uidanswer ? $uidanswer : $defaultanswer;
		$defaultanswer = $HTTP_POST_VARS["Q".$qid."Answered"] ? $HTTP_POST_VARS["Q".$qid] : $defaultanswer;
		$defaultanswer = protecthtml( $defaultanswer );
		$contents .= "<TABLE CELLPADDING=2 CELLSPACING=0 BORDER=0><TR>\n";
		$contents .= "<TD WIDTH={$indent}></TD>\n";
		if ( $print )
		{
			$defaultanswer = str_replace( "\n", "<br>", $defaultanswer );
			$contents .= "<TD STYLE=\"{$answertextstyle}\">{$defaultanswer}</TD>\n";
		}
		else
		{
			$contents .= "<TD STYLE=\"{$answerinputstyle}\">\n";
			$contents .= "<TEXTAREA STYLE=\"{$answerstyle}\" NAME=Q{$qid} {$attributes} cols=60 rows=10>{$defaultanswer}</TEXTAREA></TD>\n";
		}
		$contents .= "</TR></TABLE>\n";
		break;
	case "htmlcontent" :
		return "<TR><TD>&nbsp;</TD></TR>\n";
	}
	$contents .= "</TD></TR>\n";
	$contents .= "<TR><TD>&nbsp;</TD></TR>\n";
	return $contents;
}

function printclose( )
{
	global $phpQlang;
	$contents = "<TR><TD ALIGN=center>\n";
	$contents .= "<TABLE CELLPADDING=2 CELLSPACING=0 BORDER=0><TR>\n";
	$contents .= "<TD><INPUT TYPE=button ONCLICK=\"window.close();\" VALUE=\"".$phpQlang['Close']."\"></TD>\n";
	$contents .= "</TR></TABLE>\n";
	$contents .= "</TD></TR>\n";
	return $contents;
}

function printsubmit( $buttontext, $masurvey, $preview )
{
	global $phpQlang;
	if ( $buttontext == $phpQlang['Next'] )
	{
		$buttonsubmit = getbutton( $masurvey, "next" );
	}
	else
	{
		$buttonsubmit = getbutton( $masurvey, "submit" );
	}
	$contents = "<TR><TD ALIGN=center>\n";
	$contents .= "<TABLE CELLPADDING=2 CELLSPACING=0 BORDER=0><TR>\n";
	$contents .= "<TD>{$buttonsubmit}</TD>\n";
	if ( $masurvey['SurveyResults'] == 2 )
	{
		$buttonsubmit = getbutton( $masurvey, "results" );
		$contents .= "<TD>&nbsp;</TD><TD>{$buttonsubmit}</TD>";
	}
	if ( $preview )
	{
		$sep = "-&nbsp;";
		if ( $buttontext != $phpQlang['Submit'] )
		{
			$contents .= "<TD>&nbsp;{$sep}</TD><TD><INPUT TYPE=submit VALUE=\"".$phpQlang['Skip']."\" NAME=\"skip\"></TD>";
			$sep = "";
		}
		$contents .= "<TD>&nbsp;{$sep}</TD><TD><INPUT TYPE=button ONCLICK=\"window.close();\" VALUE=\"".$phpQlang['Close']."\"></TD>";
	}
	$contents .= "</TR></TABLE>\n";
	$contents .= "</TD></TR>\n";
	return $contents;
}

function getbutton( $masurvey, $buttontext )
{
	global $phpQlang;
	switch ( $buttontext )
	{
	case "submit" :
		$index = "Submit";
		$text = "确定";
		break;
	case "next" :
		$index = "Next";
		$text = "Next";
		break;
	case "results" :
		$index = "Result";
		$text = "ShowResults";
	}
	$buttonalt = $masurvey[$index."ImageText"];
	if ( $masurvey[$index."ImageSrc"] )
	{
		$buttonsrc = protecthtml( $masurvey[$index."ImageSrc"] );
		$buttonwidth = 0 < $masurvey[$index."ImageWidth"] ? "WIDTH=".protecthtml( $masurvey[$index."ImageWidth"] ) : "";
		$buttonheight = 0 < $masurvey[$index."ImageHeight"] ? "HEIGHT=".protecthtml( $masurvey[$index."ImageHeight"] ) : "";
		$button = "<INPUT TYPE=\"image\" NAME=\"{$buttontext}\" SRC=\"{$buttonsrc}\" {$buttonwidth} {$buttonheight} BORDER=0 ALT=\"{$buttonalt}\" VALUE=\"1\">";
	}
	else
	{
		$buttonwidth = 0 < $masurvey[$index."ImageWidth"] ? "width: ".protecthtml( $masurvey[$index."ImageWidth"] )."px;" : "";
		$buttonheight = 0 < $masurvey[$index."ImageHeight"] ? "height: ".protecthtml( $masurvey[$index."ImageHeight"] )."px;" : "";
		$bstyle = $buttonwidth || $buttonheight ? "style=\"{$buttonwidth} {$buttonheight}\"" : "";
		$button = "<INPUT TYPE=submit NAME=\"{$buttontext}\" VALUE=\"{$text}\" {$bstyle}>";
	}
	return $button;
}

function printhiddenvars( $qid )
{
	$contents = "<INPUT TYPE=hidden NAME=Q".$qid."Answered VALUE=1>\n";
	return $contents;
}

function generateuid( )
{
	global $HTTP_SERVER_VARS;
	global $REMOTE_ADDR;
	list( $usec, $sec ) = explode( " ", microtime( ) );
	$usec *= 1000000;
	$ip = $REMOTE_ADDR ? $REMOTE_ADDR : $HTTP_SERVER_VARS['REMOTE_ADDR'];
	mt_srand( time( ) ^ ( integer )$usec ^ ip2long( $ip ) ^ ( integer )getmypid( ) );
	$loop = true;
	while ( $loop )
	{
		$randval = mt_rand( 1000000000, 1999999999 );
		$mquser = mysql_query( "select * from phpQUser where UID = \"{$randval}\"" );
		if ( !( $mauser = mysql_fetch_array( $mquser ) ) )
		{
			$loop = false;
		}
	}
	return $randval;
}

?>

⌨️ 快捷键说明

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