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

📄 functions.php

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

function ProtectHTML ($mytext) {
	$mytext = str_replace("&", "&amp;", $mytext);
	$mytext = str_replace("<", "&lt;", $mytext);
	$mytext = str_replace(">", "&gt;", $mytext);
	$mytext = str_replace("\"", "&quot;", $mytext);

	return $mytext;
}

function ProtectMySQL($mytext) {
	# mysql_escape_string() was not introduced until PHP 4.0.3...
	if (function_exists('mysql_escape_string')) {
		return mysql_escape_string($mytext);
	}

	# Emulate mysql_escape_string if we must...
	$mytext = addslashes($mytext);
	$mytext = str_replace("\n", "\\n", $mytext);
	$mytext = str_replace("\r", "\\r", $mytext);

	return $mytext;
}

function FreeHTML ($mytext) {
	$mytext = str_replace("&quot;", "\"", $mytext);
	$mytext = str_replace("&gt;", ">", $mytext);
	$mytext = str_replace("&lt;", "<", $mytext);
	$mytext = str_replace("&amp;", "&", $mytext);

	return $mytext;
}

function Login () {
	global $HTTP_POST_VARS, $HTTP_SERVER_VARS, $phpQAdmin, $phpQlang;

	$password = $HTTP_POST_VARS["phpQpasswd"];
	if ($password == '') { return 0; }

	if ($phpQAdmin["Passwd"] == $password) {
		list($usec, $sec) = explode(' ', microtime());
		$usec *= 1000000;
		$ip = $REMOTE_ADDR ? $REMOTE_ADDR : $HTTP_SERVER_VARS['REMOTE_ADDR'];
		mt_srand(time() ^ (int)$usec ^ ip2long($ip) ^ (int)@getmypid());

		$sesschars = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N',
		    'O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
		    'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x',
		    'y','z','0','1','2','3','4','5','6','7','8','9');
		$session_id = '';
		for ($i = 0; $i<25; $i++) {
			$session_id .= $sesschars[mt_rand(0,(count($sesschars)-1))];
		}

		mysql_query("insert into phpQSession (SessionID, RecentTime) values (\"$session_id\", " . time() . ")");
		$domain = ($phpQAdmin['CookieDomain'] != '') ? $phpQAdmin['CookieDomain'] : '';
		setcookie('phpQSession', $session_id, 0, '/', $domain);
		echo "<html><head><meta http-equiv=\"Refresh\" content=\"0; URL=main.php\"></head></html>";
		exit();
	}
	else {
		$GLOBALS["message"] = $phpQlang['InvalidPassword'];
	}

	return 0;
}

function LogOut () {
	global $HTTP_COOKIE_VARS, $phpQAdmin;

	$session_id = $HTTP_COOKIE_VARS["phpQSession"];
	if (!$session_id) { return 1; }

	mysql_query("delete from phpQSession where SessionID=\"" . ProtectMySQL($session_id) . "\"");

	$domain = ($phpQAdmin['CookieDomain'] != '') ? $phpQAdmin['CookieDomain'] : '';
	setcookie('phpQSession', '', 0, '/', $domain);
	echo "<html><head><meta http-equiv=\"Refresh\" content=\"0; URL=index.php\"></head></html>";
	exit();
}

function IsAdmin ($redirecterrors = 0, $ispopup = 0) {
	global $HTTP_COOKIE_VARS, $phpQAdmin;

	$session_id = $HTTP_COOKIE_VARS["phpQSession"];
	if (!$session_id) {
		if ($redirecterrors) {
			if ($ispopup) {
				header("Location: popuperror.php?errormsg=PopupLogin");
			}
			else {
				header("Location: index.php");
			}
			exit();
		}
		else { return 0; }
	}

	$timeout = ($phpQAdmin["TimeOut"] >= 60) ? $phpQAdmin["TimeOut"] : 86400;

	$mqsession = mysql_query("select * from phpQSession WHERE SessionID=\"".ProtectMySQL($session_id)."\"");
	if ($masession = mysql_fetch_array($mqsession)) {
		if ((time() - $masession["RecentTime"]) < $timeout) {
			mysql_query("delete from phpQSession where (" . time() . " - RecentTime) > $timeout and SessionID != \"" . ProtectMySQL($session_id) . "\"");
			mysql_query("update phpQSession set RecentTime=" . time() . " where SessionID=\"" . ProtectMySQL($session_id) . "\"");
			return 1;
		}
	}

	if ($redirecterrors) {
		if ($ispopup) {
			header("Location: popuperror.php?errormsg=PopupLoggedOut");
		}
		else {
			header("Location: index.php?errormsg=LoggedOut");
		}
		exit();
	}

	return 0;
}

function ValidNumber ($number, $default) {
	if ($number > 0) {
		return $number;
	} else {
		return $default;
	}
}

function CheckSurveyUsers ($surveyuser) {
	$valid = true;

	if (strlen($surveyuser) == 3) {
		$ip = substr($surveyuser,0,1);
		$ck = substr($surveyuser,1,1);
		$em = substr($surveyuser,2,1);
		$valid = ($ip == "0" || $ip == "1") ? $valid : false;
		$valid = ($ck == "0" || $ck == "1") ? $valid : false;
		$valid = ($em == "0" || $em == "1") ? $valid : false;
	} else {
		return false;
	}

	return $valid;
}

function ParseSurveyUsers ( $surveyuser) {
	$ip = substr($surveyuser,0,1);
	$ck = substr($surveyuser,1,1);
	$em = substr($surveyuser,2,1);

	return array($ip, $ck, $em);
}

function ProcessSurveyUsers ($checkedip, $checkedck, $checkedem) {
	$surveyusers .= ($checkedip) ? "1" : "0";
	$surveyusers .= ($checkedck) ? "1" : "0";
	$surveyusers .= ($checkedem) ? "1" : "0";

	return $surveyusers;
}

function CheckDateTime ($mn, $dm, $yr, $hr, $mt, $sc) {
	return (checkdate($mn,$dm,$yr) && $hr >= 0 && $hr < 24 && $mt >= 0 && $mt < 60 && $sc >= 0 && $sc < 60) ? true : false;
}

function CheckACount ($control, $answer, $answercount) {
	$answerchoice = split("\|\|\|", $answer);
	$acount = 0;
	for ($i=0; $i<sizeof($answerchoice); $i++) {
		if (substr($answerchoice[$i], -1) == "Y")
			$acount++;
	}
	return ($control == "a" || ($answercount >= 1 && $answercount <= $acount)) ? true : false;
}

function SetVars ($vars) {
	global $HTTP_POST_VARS, $HTTP_GET_VARS;

	for ($j=0; $j<sizeof($vars); $j++) {
		$varname = $vars[$j];
		if (!empty($HTTP_POST_VARS[$varname])) {
			$GLOBALS[$varname] = $HTTP_POST_VARS[$varname];
		}
		elseif (!empty($HTTP_GET_VARS[$varname])) {
			$GLOBALS[$varname] = $HTTP_GET_VARS[$varname];
		}
	}
}

?>

⌨️ 快捷键说明

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