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

📄 pfunctions.php

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

function validateuid( $uid )
{
	$mqvaliduid = mysql_query( "select * from phpQUser where UID = \"".protectmysql( $uid )."\"" );
	return ( $mavaliduid = mysql_fetch_array( $mqvaliduid ) ) ? true : false;
}

function validateqanswer( $qanswer )
{
	$valid = true;
	$choices = split( "\\|\\|\\|", $qanswer );
	$i = 0;
	for ( ;	$i < sizeof( $choices );	++$i	)
	{
		$parts = split( "\\|\\|", $choices[$i] );
		if ( sizeof( $parts ) != 5 )
		{
			$valid = false;
		}
		else
		{
			$valid = strlen( $parts[0] ) == 4 ? $valid : false;
			$valid = 0 < $parts[1] ? $valid : false;
			$valid = $parts[2] != "" ? $valid : false;
			$valid = $parts[3] == "N" || $parts[3] == "D" ? $valid : false;
			$valid = $parts[4] == "Y" || $parts[4] == "N" ? $valid : false;
		}
	}
	return $valid;
}

function createpage( $sid, $title, $contents, $admin, $jscript )
{
	global $phpQlang;
	global $phpQAdmin;
	$cs = $cs;
	$message = $message;
	if ( ( boolean )$sid == "stats" && !$admin )
	{
		$sid = $title['SID'];
		$title = $title['Name'];
		$jsstats = file( "inc/jsstats.php" );
		$i = 0;
		for ( ;	$i < count( $jsstats );	++$i	)
		{
			$jsinfo .= replacelanguage( $jsstats[$i] );
		}
	}
	else if ( ( boolean )$sid == "stats" )
	{
		$title = $phpQlang['SurveyResultsTitle'];
	}
	if ( $phpQAdmin['Template'] != "" && is_readable( "templates/".$phpQAdmin['Template']."/index.html" ) )
	{
		$template = "templates/".$phpQAdmin['Template']."/index.html";
	}
	else if ( is_readable( "templates/default/index.html" ) )
	{
		$template = "templates/default/index.html";
	}
	if ( $admin )
	{
		$template = ( boolean )$sid == "stats" ? "admin/template.html" : "template.html";
	}
	else if ( is_numeric( $sid ) )
	{
		$masurvey = mysql_fetch_array( mysql_query( "select * from phpQSurvey where SID = \"".protectmysql( $sid )."\"" ) );
		if ( $masurvey['Template'] != "" && is_readable( "templates/".$masurvey['Template']."/index.html" ) )
		{
			$template = "templates/".$masurvey['Template']."/index.html";
		}
	}
	$templatevalid = false;
	if ( is_readable( $template ) )
	{
		$templatevalid = true;
		$templatearray = file( $template );
	}
	$jsinit = "";
	if ( $admin )
	{
		$path = ( boolean )$sid == "stats" ? "" : "../";
		$jsloc = $jscript ? $path."inc/{$jscript}" : "";
		if ( $jsloc != "" && $jsloc != "." && $jsloc != ".." && file_exists( $jsloc ) )
		{
			$jsvalid = true;
			$jsarray = file( $jsloc );
			switch ( $jscript )
			{
			case "jslogin.php" :
				$jsinfo = "";
				$jsinit = "ONLOAD=\"Init()\"";
				break;
			case "jssurvey.php" :
				$jsinfo = "<SCRIPT>\nvar currentsurvey = \"{$cs}\";\n</SCRIPT>\n\n";
				break;
			case "jsquestion.php" :
				$qt = $oQType;
				$cq = $cq;
				$largestid = $largestid;
				$questionlist = $questionlist;
				$jsinit = "ONLOAD=\"Init()\"";
				$jsinfo = "<SCRIPT>\n";
				$jsinfo .= "function QuestionOBJ (QID, SortOrder, Type) {\n";
				$jsinfo .= "this.QID = QID;\n";
				$jsinfo .= "this.SortOrder = SortOrder;\n";
				$jsinfo .= "this.Type = Type;\n";
				$jsinfo .= "}\n\n";
				$jsinfo .= "var ctype = \"{$qt}\";\n";
				$jsinfo .= "var tempquestionobj = new QuestionOBJ();\n";
				$jsinfo .= "var cs = \"{$cs}\";\n";
				$jsinfo .= "var cq = \"{$cq}\";\n";
				$jsinfo .= "var qt = \"{$qt}\";\n";
				$jsinfo .= "var largestid = \"".( $largestid ? $largestid : "0" )."\";\n\n";
				$jsinfo .= "var questions = new Array(";
				$i = 0;
				for ( ;	$i < sizeof( $questionlist );	++$i	)
				{
					if ( 0 < $i )
					{
						$jsinfo .= ", ";
					}
					$jsinfo .= "new QuestionOBJ(";
					$jsinfo .= "\"".protecthtml( $questionlist[$i]['QID'] )."\", ";
					$jsinfo .= "\"".protecthtml( $questionlist[$i]['SortOrder'] )."\", ";
					$jsinfo .= "\"".protecthtml( $questionlist[$i]['Type'] )."\" ";
					$jsinfo .= ")";
				}
				$jsinfo .= ");\n";
				$jsinfo .= "var fieldinit = false;\n";
				$jsinfo .= "var deleteinit = false;\n";
				$jsinfo .= "var checkboxarray = new Array();\n";
				$jsinfo .= "var checkboxarray2 = new Array();\n";
				$jsinfo .= "var addtextfield = false;\n";
				$jsinfo .= "</SCRIPT>\n\n";
				break;
			default :
				$jsinfo = "";
				break;
			}
			$i = 0;
			for ( ;	$i < sizeof( $jsarray );	++$i	)
			{
				$jsinfo .= replacelanguage( $jsarray[$i] );
			}
		}
	}
	switch ( ( boolean )$sid )
	{
	case "login" :
		$menu = "<TD><IMG SRC=\"images/invdot.gif\" WIDTH=5 HEIGHT=1 ALT=\"\"></TD>\n";
		$menu .= "<TD><IMG SRC=\"images/tableft.gif\" WIDTH=4 HEIGHT=15 ALT=\" \"></TD>\n";
		$menu .= "<TD BGCOLOR=#99CCFF><NOBR>\n";
		$menu .= "<B>chumpsoft :: phpQ</B></NOBR></TD>\n";
		$menu .= "<TD><IMG SRC=\"images/tabright.gif\" WIDTH=7 HEIGHT=15 ALT=\" \"></TD>\n";
		break;
	case "main" :
		$menu = printtabs( 1, 0 );
		break;
	case "admin" :
		$menu = printtabs( 4, 0 );
		break;
	case "choose" :
	case "view" :
		$menu = printtabs( 3, 0 );
		break;
	case "stats" :
		$addmin = $admin && ( boolean )$sid == "stats" ? 1 : 0;
		$menu = printtabs( 3, $addmin );
		break;
	case "survey" :
		$menu = printtabs( 2, 0 );
		break;
	case "question" :
		$menu = printtabs( 5, 0 );
	}
	global $HTTP_SERVER_VARS;
	if ( $templatevalid )
	{
		array_splice( $templatearray, 0, 1 );
		$templatedata = join( "", $templatearray );
		if ( $admin && ( boolean )$sid == "stats" )
		{
			$templatedata = str_replace( "HREF=\"../docs/", "HREF=\"docs/", $templatedata );
			$templatedata = str_replace( "HREF=\"index.php", "HREF=\"admin/index.php", $templatedata );
			$templatedata = str_replace( "SRC=\"images/", "SRC=\"admin/images/", $templatedata );
		}
		$templatedata = str_replace( "::TITLE::", $phpQlang['ChooseASurvey'], $templatedata );
		$templatedata = str_replace( "::CHARSET::", $phpQlang['CHARSET'], $templatedata );
		$templatedata = str_replace( "::USERMANUAL::", $phpQlang['UserManual'], $templatedata );
		$templatedata = str_replace( "::SURVEYNAME::", $phpQlang['ChooseASurvey'], $templatedata );
		$templatedata = str_replace( "::PAGENUMBER::", $GLOBALS['PageNumber'], $templatedata );
		$templatedata = str_replace( "::JSINIT::", $jsinit, $templatedata );
		$templatedata = str_replace( "::JSCRIPT::", $jsinfo, $templatedata );
		$templatedata = str_replace( "::MENU::", $menu, $templatedata );
		$templatedata = str_replace( "::MESSAGE::", $message, $templatedata );
		$templatedata = str_replace( "::CONTENT::", $contents, $templatedata );
		echo $templatedata;
	}
	else
	{
		echo $phpQlang['NoTemplate'];
	}
}

function printtabs( $tabindex, $addmin )
{
	global $phpQlang;
	$imgurl = $inAdmin ? "images" : "admin/images";
	$csurl = $cs ? $cs : $sid;
	$csurl = is_numeric( $csurl ) ? "?cs={$csurl}" : "";
	$uri = $addmin ? "admin/" : "";
	if ( $tabindex == 1 )
	{
		$menuarray = array(
			array(
				"<img src='/images/button/addsurvey.gif' border='0'>",
				$uri."survey.php"
			),
			array(
				"<img src='/general/vote/admin/images/viewvote.gif' border='0'>",
				$uri."choose.php{$csurl}"
			)
		);
	}
	else if ( $tabindex == 2 )
	{
		$menuarray = array(
			array(
				"<img src='/general/vote/admin/images/viewvote.gif' border='0'>",
				$uri."choose.php{$csurl}"
			),
			array(
				"<img src='/images/button/return.gif' border='0'>",
				$uri."main.php{$csurl}"
			)
		);
	}
	else if ( $tabindex == 3 )
	{
		if ( $_REQUEST['view'] != 1 )
		{
			$menuarray = array(
				array(
					"<img src='/images/button/addsurvey.gif' border='0'>",
					$uri."survey.php"
				),
				array(
					"<img src='/images/button/return.gif' border='0'>",
					$uri."main.php{$csurl}"
				)
			);
		}
	}
	else if ( $tabindex == 5 )
	{
		$menuarray = array(
			array(
				"<img src='/general/vote/admin/images/viewvote.gif' border='0'>",
				$uri."choose.php{$csurl}"
			),
			array(
				"<img src='/images/button/return.gif' border='0'>",
				$uri."main.php{$csurl}"
			)
		);
	}
	else
	{
		$menuarray = array(
			array(
				"<img src='/general/vote/admin/images/editvote.gif' border='0'>",
				$uri."survey.php"
			),
			array(
				"<img src='/general/vote/admin/images/viewvote.gif' border='0'>",
				$uri."choose.php{$csurl}"
			),
			array(
				"<img src='/images/button/return.gif' border='0'>",
				$uri."main.php{$csurl}"
			)
		);
	}
	$menu .= "<TD><NOBR>";
	if ( $tabindex == 2 && $_REQUEST['cs'] == null )
	{
		$menu .= "<a href='#' ONCLICK='AddSurvey()'><img src='/images/button/savesurvey.gif' alt='增加调查表' border='0'></a>";
	}
	if ( $tabindex == 2 && $_REQUEST['cs'] != null )
	{
		$menu .= "<a href='#' ONCLICK='ModifySurvey()'><img src='/images/button/savesurvey.gif' alt='修改调查表' border='0'></a>";
	}
	$i = 0;
	for ( ;	$i < sizeof( $menuarray );	++$i	)
	{
		if ( $i == $tabindex - 1 )
		{
			$tabcss = "tabon";
			$leftimg = "tablefton.gif";
			$rightimg = "tabrighton.gif";
			$bgcolor = "#BBFF33";
		}
		else
		{
			$tabcss = "tab";
			$leftimg = "tableft.gif";
			$rightimg = "tabright.gif";
			$bgcolor = "#99CCFF";
		}
		$menu .= "<A HREF=\"".$menuarray[$i][1]."\"";
		$menu .= " CLASS={$tabcss}><B>".$menuarray[$i][0]."</B></A>\n";
	}
	$menu .= "</NOBR></TD>";
	return $menu;
}

function printmessage( $message, $width = 400, $align = "center" )
{
	$width = $width ? " WIDTH={$width}" : "";
	$align = $align ? " ALIGN={$align}" : "";
	$msg = "<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0{$width}>\n";
	$msg .= "<TR><TD{$align}>{$message}</TD></TR>\n";
	$msg .= "</TABLE>\n";
	return $msg;
}

function createsurvey( $sid, $cq, $tablewidth, $page, $admin )
{
	global $HTTP_SERVER_VARS;
	global $HTTP_COOKIE_VARS;
	global $HTTP_POST_VARS;
	global $phpQlang;
	$masurvey = mysql_fetch_array( mysql_query( "select * from phpQSurvey where SID = \"".protectmysql( $sid )."\"" ) );
	$width = 0 < $tablewidth ? "WIDTH={$tablewidth}" : "";
	$scriptname = $PHP_SELF ? $PHP_SELF : $HTTP_SERVER_VARS['PHP_SELF'];
	if ( !$scriptname && $HTTP_SERVER_VARS['REQUEST_URI'] )
	{
		$scriptname = $HTTP_SERVER_VARS['REQUEST_URI'];
	}
	$contents = "<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 {$width}>\n";
	$contents .= "<FORM ACTION=\"{$scriptname}\" METHOD=POST>\n";
	if ( strlen( $masurvey['SurveyUsers'] ) == 3 && substr( $masurvey['SurveyUsers'], 1, 1 ) && !$admin && !$HTTP_COOKIE_VARS['phpQTest'] && 1 < $cq )
	{
		$contents .= "<TR><TD STYLE=\"".$masurvey['ErrorStyle']."\">";
		$contents .= $phpQlang['SurveyCookieWarning']."<BR><BR></TD></TR>";
	}
	$contents .= $page;
	$ufid = $HTTP_POST_VARS['ufid'];
	if ( $ufid == "" )
	{
		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( ) );
		$randval = mt_rand( 1000000000, 1999999999 );
		$ufid = "{$ip}-".time( )."-{$randval}";
	}
	$contents .= "<INPUT TYPE=hidden NAME=ufid VALUE=\"{$ufid}\">\n";
	if ( $admin )
	{
		$contents .= "<INPUT TYPE=hidden NAME=action VALUE=preview>\n";
	}
	$contents .= "<INPUT TYPE=hidden NAME=sid VALUE={$sid}>\n";
	$contents .= "</FORM>\n";
	$contents .= "</TABLE>\n";
	return $contents;
}

?>

⌨️ 快捷键说明

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