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

📄 efunctions.php

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

function grabstats( $sid, $stattype, $type )
{
	$mqquestion = mysql_query( "select * from phpQQuestion where SID = \"".protectmysql( $sid )."\" order by SortOrder" );
	$maxcolumn = 1;
	while ( $maquestion = mysql_fetch_array( $mqquestion ) )
	{
		$answerarray = $maquestion['Answer'] ? split( "\\|\\|\\|", $maquestion['Answer'] ) : array( );
		$maxcolumn = $maxcolumn < sizeof( $answerarray ) + 1 ? sizeof( $answerarray ) + 1 : $maxcolumn;
		if ( $maquestion['Type'] != "pagebreak" && $maquestion['Type'] != "htmlcontent" )
		{
			$qarray[] = $maquestion;
		}
	}
	$contents .= "<TABLE BORDER=1>";
	$i = 0;
	for ( ;	$i < sizeof( $qarray );	++$i	)
	{
		if ( $qarray[$i]['Type'] == "textfield" || $qarray[$i]['Type'] == "textarea" )
		{
			$colspan = $maxcolumn;
			$totcolumn = "";
		}
		else if ( $qarray[$i]['Type'] == "select" || $qarray[$i]['Type'] == "selectmult" )
		{
			$answers = split( "\\|\\|\\|", $qarray[$i]['Answer'] );
			$colspan = 0;
			$j = 0;
			for ( ;	$j < sizeof( $answers );	++$j	)
			{
				$tempsplit = split( "\\|\\|", $answers[$j] );
				if ( $tempsplit[4] != "Y" )
				{
				}
				else
				{
					++$colspan;
				}
			}
			$totcolumn = "<TD BGCOLOR=#333366>&nbsp;</TD></TR>";
		}
		else
		{
			$colspan = sizeof( split( "\\|\\|\\|", $qarray[$i]['Answer'] ) );
			$totcolumn = "<TD BGCOLOR=#333366>&nbsp;</TD></TR>";
		}
		$contents .= ( "<TR><TD COLSPAN={$colspan} BGCOLOR=#333366><FONT COLOR=#FFFFFF><B>Question ".( $i + 1 ) ).":</B> ".$qarray[$i]['Question']."</FONT></TD>{$totcolumn}</TR>";
		$contents .= grabanswersex( $sid, $qarray[$i], $stattype, $maxcolumn );
		$contents .= "<TR><TD COLSPAN={$maxcolumn} BGCOLOR=#EEEEEE>&nbsp;</TD></TR>";
	}
	$contents .= "</TABLE>";
	return $contents;
}

function grabanswersex( $sid, $maquestion, $stattype, $colsize )
{
	global $phpQlang;
	$qid = $maquestion['QID'];
	switch ( $maquestion['Type'] )
	{
	case "select" :
	case "selectmult" :
	case "checkbox" :
	case "radio" :
		$totalcount = 0;
		$largestcount = 0;
		$answerarray = array( );
		$countarray = array( );
		$answerid = array( );
		$temparray = split( "\\|\\|\\|", $maquestion['Answer'] );
		$diffcolsize = $colsize - sizeof( $temparray ) - 1;
		$contents .= "<TR>";
		$icount = 0;
		$i = 0;
		for ( ;	$i < sizeof( $temparray );	++$i	)
		{
			$tempsplit = split( "\\|\\|", $temparray[$i] );
			if ( $tempsplit[4] != "Y" && ( $maquestion['Type'] == "select" || $maquestion['Type'] == "selectmult" ) )
			{
			}
			else
			{
				$answerarray[] = $tempsplit;
				$countarray[] = 0;
				$bgcolor = $icount % 2 == 0 ? "#999999" : "#DDDDDD";
				if ( substr( $answerarray[$icount][2], 0, 11 ) == "Textfield:(" )
				{
					$answerid["O".$answerarray[$icount][1]] = $icount;
					$ochoice = substr( substr( $answerarray[$icount][2], 11 ), 0, -1 );
					$contents .= "<TD BGCOLOR={$bgcolor}>".$ochoice."</TD>";
				}
				else
				{
					$answerid["N".$answerarray[$icount][1]] = $icount;
					$contents .= "<TD BGCOLOR={$bgcolor}>".$answerarray[$icount][2]."</TD>";
				}
				++$icount;
			}
		}
		$contents .= "<TD BGCOLOR=#336699><FONT COLOR=#FFFFFF><B>".$phpQlang['Total']."</B></FONT></TD></TR>";
		$qstring = "select Answer, COUNT(*) as total from phpQAnswer where SID = \"".protectmysql( $sid )."\" and QID = \"".protectmysql( $qid )."\" GROUP BY Answer";
		if ( $stattype == "u" || $stattype == "v" )
		{
			$cletter = $stattype == "u" ? "n" : "y";
			$qstring = "select phpQAnswer.Answer, COUNT(*) as total from phpQAnswer,phpQUser where phpQAnswer.SID = \"".protectmysql( $sid )."\" and phpQAnswer.QID = \"".protectmysql( $qid )."\" AND phpQAnswer.UID=phpQUser.UID AND phpQUser.EmailConfirm = \"{$cletter}\" GROUP BY phpQAnswer.Answer";
		}
		$mqanswercount = mysql_query( $qstring );
		$j = 0;
		for ( ;	$j < mysql_num_rows( $mqanswercount );	++$j	)
		{
			$maanswercount = mysql_fetch_array( $mqanswercount );
			$qanswers = split( "\\|\\|", $maanswercount['Answer'] );
			$x = 0;
			for ( ;	$x < count( $qanswers );	++$x	)
			{
				if ( preg_match( "/^O/", $qanswers[$x] ) )
				{
					$oanswers = split( "\\|", $qanswers[$x] );
					if ( isset( $answerid[$oanswers[0]] ) )
					{
						$countarray[$answerid[$oanswers[0]]] += $maanswercount['total'];
					}
				}
				else if ( isset( $answerid[$qanswers[$x]] ) )
				{
					$countarray[$answerid[$qanswers[$x]]] += $maanswercount['total'];
				}
			}
		}
		$largestcount = $totalcount = 0;
		$x = 0;
		for ( ;	$x < count( $countarray );	++$x	)
		{
			$largestcount = $largestcount < $countarray[$x] ? $countarray[$x] : $largestcount;
			$totalcount += $countarray[$x];
		}
		$contents .= "<TR>";
		$k = 0;
		for ( ;	$k < sizeof( $countarray );	++$k	)
		{
			$bgcolor = $k % 2 == 0 ? "#DDDDDD" : "#FFFFFF";
			$contents .= "<TD ALIGN=LEFT BGCOLOR={$bgcolor}>".$countarray[$k]."</TD>";
		}
		$contents .= "<TD ALIGN=LEFT BGCOLOR=#99CCFF>{$totalcount}</TD></TR>";
		$contents .= "<TR>";
		$k = 0;
		for ( ;	$k < sizeof( $answerarray );	++$k	)
		{
			$bgcolor = $k % 2 == 0 ? "#DDDDDD" : "#FFFFFF";
			$percent = 0 < $totalcount ? number_format( $countarray[$k] / $totalcount * 100, 1 ) : 0;
			$contents .= "<TD ALIGN=LEFT BGCOLOR={$bgcolor}>".$percent."%</TD>";
		}
		$contents .= "<TD ALIGN=LEFT BGCOLOR=#99CCFF>100%</TD></TR>";
		break;
	case "textfield" :
	case "textarea" :
		$contents .= "<TR><TD COLSPAN={$colsize} BGCOLOR=#DDDDDD>".$phpQlang['PEXNoText']."</TD></TR>";
	}
	return $contents;
}

function str2csv( $mystring )
{
	$mystring = str_replace( "\r", "", $mystring );
	$mystring = str_replace( "\n", " ", $mystring );
	if ( strstr( $mystring, "\"" ) )
	{
		$mystring = str_replace( "\"", "\"\"", $mystring );
	}
	if ( strstr( $mystring, "\"" ) || strstr( $mystring, "," ) || strstr( $mystring, "\n" ) )
	{
		return "\"".$mystring."\",";
	}
	return $mystring.",";
}

function str2xml( $mystring )
{
	$mystring = str_replace( "\r", "", $mystring );
	$mystring = str_replace( "&", "&amp;", $mystring );
	$mystring = str_replace( "<", "&lt;", $mystring );
	$mystring = str_replace( ">", "&gt;", $mystring );
	$mystring = str_replace( "\"", "&quot;", $mystring );
	return $mystring;
}

function str2sql( $mystring )
{
	if ( function_exists( "is_null" ) && is_null( $mystring ) )
	{
		return "NULL";
	}
	return "\"".protectmysql( $mystring )."\"";
}

function str2phpq( $mystring )
{
	if ( function_exists( "is_null" ) && is_null( $mystring ) )
	{
		return "=NULL=";
	}
	return urlencode( $mystring );
}

function terminate( $mystring )
{
	$mystring = substr( $mystring, 0, -1 )."\n";
	return $mystring;
}

function verificationbits( $mystring )
{
	if ( strlen( $mystring ) != 3 )
	{
		return array( 0, 0, 0 );
	}
	$bits[0] = substr( $mystring, 0, 1 );
	$bits[1] = substr( $mystring, 1, 1 );
	$bits[2] = substr( $mystring, 2, 1 );
	$sumcheck = $bits[0] + $bits[1] + $bits[2];
	if ( $sumcheck < 0 || 3 < $subcheck )
	{
		return array( 0, 0, 0 );
	}
	else
	{
		return $bits;
	}
}

function findvalue( $key, $answerchoices )
{
	$i = 0;
	for ( ;	$i < sizeof( $answerchoices );	++$i	)
	{
		$value = substr( $answerchoices[$i][2], 0, 11 ) == "Textfield:(" ? substr( $answerchoices[$i][2], 11, -1 ) : $answerchoices[$i][2];
		if ( substr( $key, 1 ) == $answerchoices[$i][1] )
		{
			return $value;
		}
	}
	return "";
}

function backupalldata( $sid, $swap )
{
	$sid = $sid && is_numeric( $sid ) ? ( integer )$sid : 0;
	global $phpQAdmin;
	$swap = $swap ? 1 : 0;
	$phpQF['Admin'] = array( "phpQID", "Version", "Template", "Language", "AdminLanguage", "SummaryLimit", "TextareaLimit", "PopupLimit", "AdvanceInterface", "ListSurvey", "TimeOut", "CookieDomain" );
	$phpQF['Answer'] = array( "UID", "SID", "QID", "Answer" );
	$phpQF['Question'] = array( "SID", "QID", "SortOrder", "Question", "Type", "Mult", "QuestionStyle", "Instructions", "Answer", "Choose", "DefaultAnswer", "LargestAID", "ColNumb", "AnswerInputStyle", "AnswerTextStyle", "AnswerStyle", "Attributes", "Required", "Summary" );
	$phpQF['Survey'] = array( "SID", "AddDate", "Name", "SurveyUsers", "SurveyResults", "Width", "Indent", "QuestionNumb", "QuestionStyle", "AnswerInputStyle", "AnswerTextStyle", "AnswerStyle", "ErrorStyle", "VerifyEmail", "EmailFrom", "EmailSubject", "Template", "Language", "OnComplete", "RedirectURL", "Completed", "Description", "AdminNotes", "Active", "StartDate", "EndDate", "AdvanceInterface", "ResultsWidth", "ResultsBorder", "ResultsAnswer", "ResultsStats", "ResultsGraph", "SubmitImageSrc", "SubmitImageWidth", "SubmitImageHeight", "SubmitImageText", "ResultImageSrc", "ResultImageWidth", "ResultImageHeight", "ResultImageText", "NextImageSrc", "NextImageWidth", "NextImageHeight", "NextImageText", "ResponseNotice", "ResponseEmail" );
	$phpQF['User'] = array( "UID", "SID", "IPAddr", "BlockDupe", "CheckType", "Email", "Confirm", "EmailConfirm", "CompleteDate" );
	$version = ( double )$phpQAdmin['Version'];
	if ( $version < 2.2 )
	{
		array_splice( $phpQF['Survey'], 44, 2 );
	}
	if ( $version < 2.1 )
	{
		array_splice( $phpQF['Survey'], 32, 12 );
	}
	if ( $version < 2 )
	{
		$version = "1.2";
		array_splice( $phpQF['Admin'], 11, 1 );
		array_splice( $phpQF['Admin'], 3, 2 );
		array_splice( $phpQF['Survey'], 27, 5 );
		array_splice( $phpQF['Survey'], 17, 1 );
		array_splice( $phpQF['Survey'], 9, 1 );
		array_splice( $phpQF['Question'], 13, 1 );
		array_splice( $phpQF['User'], 3, 1 );
	}
	$id = "PHPQBACKUP";
	if ( $sid )
	{
		$id = "SURVEYBACKUP";
		if ( $swap )
		{
			$id = "SURVEYSWAP";
			array_splice( $phpQF['Survey'], 0, 2 );
			array_splice( $phpQF['Question'], 0, 2 );
		}
	}
	echo "<!--PHPQBACKUP ".$phpQAdmin['Version']." {$id}-->\n";
	if ( !$sid )
	{
		echo "TABLE|phpQAdmin|COLUMNS|".join( ",", $phpQF['Admin'] )."\n";
	}
	echo "TABLE|phpQSurvey|COLUMNS|".join( ",", $phpQF['Survey'] )."\n";
	echo "TABLE|phpQQuestion|COLUMNS|".join( ",", $phpQF['Question'] )."\n";
	if ( !$swap )
	{
		echo "TABLE|phpQUser|COLUMNS|".join( ",", $phpQF['User'] )."\n";
		echo "TABLE|phpQAnswer|COLUMNS|".join( ",", $phpQF['Answer'] )."\n";
	}
	if ( !$sid )
	{
		$values = array( );
		$m = 0;
		for ( ;	$m < sizeof( $phpQF['Admin'] );	++$m	)
		{
			$values[] = str2phpq( $phpQAdmin[$phpQF['Admin'][$m]] );
		}
		echo "TABLE|phpQAdmin|VALUES|".join( "&", $values )."\n";
	}
	$where = $sid ? " WHERE SID=".protectmysql( $sid ) : "";
	$tables = $swap ? array( "Survey", "Question" ) : array( "Survey", "Question", "User", "Answer" );
	foreach ( $tables as $table )
	{
		if ( function_exists( "mysql_unbuffered_query" ) )
		{
			$mqquery = mysql_unbuffered_query( "select * from phpQ{$table}{$where}" );
		}
		else
		{
			$mqquery = mysql_query( "select * from phpQ{$table}{$where}" );
		}
		while ( $maquery = mysql_fetch_array( $mqquery ) )
		{
			$values = array( );
			$m = 0;
			for ( ;	$m < count( $phpQF[$table] );	++$m	)
			{
				$values[] = str2phpq( $maquery[$phpQF[$table][$m]] );
			}
			echo "TABLE|phpQ".$table."|VALUES|".join( "&", $values )."\n";
		}
	}
}

function formatsurveydata( $sid, $stattype, $format )

⌨️ 快捷键说明

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