> Include Files require("inc/init.php"); require("inc/mysql.php"); require("inc/functions.php"); require("inc/pfunctions.php"); require("inc/qfunctions.php"); require("inc/vfunctions.php"); //2013-09-24 卸载问卷跳转至新系统的问卷页 /*if($_GET['sid']==88){ header("location:http://pinyin.sogou.com/research/index.php?sid=51367&lang=zh-Hans"); }*/ /* //添加客户端邮件提醒 if($_REQUEST["sid"] == 106){ $q1 = isset($_REQUEST["Q932"])?$_REQUEST["Q932"]:""; $q2 = isset($_REQUEST["Q932O16"])?$_REQUEST["Q932O16"]:""; $q3 = isset($_REQUEST["Q932O17"])?$_REQUEST["Q932O17"]:""; if(empty($q1)){ } else{ $header = "Content-Type:text/html;charset=GB2312\nFrom:cuihao@sogou-inc.com"; $qt = ""; foreach($q1 as $tmp){ //error_log($q1."--".$q2."--".$q3."\n",3,"/tmp/xxx.log"); if($q1 == "N2") $qt .= "安装之后找不到输入法"; elseif($tmp == "N3") $qt .= "搜狗的图标与Mac系统风格不搭,很不喜欢"; elseif($tmp == "N4") $qt .= "词序不好,组词结果不好"; elseif($tmp == "N5") $qt .= "不支持双拼"; elseif($tmp == "N6") $qt .= "不支持词库同步"; elseif($tmp == "N7") $qt .= "不支持全半角切换"; elseif($tmp == "N8") $qt .= "不支持繁简切换"; elseif($tmp == "N9") $qt .= "不支持细胞词库"; elseif($tmp == "N10") $qt .= "皮肤显示不全"; elseif($tmp == "N11") $qt .= "突然打不出汉字"; elseif($tmp == "N12") $qt .= "会导致系统重启或者程序崩溃"; elseif($tmp == "N13") $qt .= "打字不够流畅、很卡"; elseif($tmp == "N14") $qt .= "第一次切出输入法慢、卡"; elseif($tmp == "N15") $qt .= "重装输入法而已"; elseif($tmp == "O16"){ $qt .= "缺少我想用的功能 但别家的有:"; $qt .= $q2; } elseif($tmp == "O17"){ $qt .= "与其他软件冲突(网络游戏、开票软件等):"; $qt .= $q3; } $qt .= "
"; } mail("cuihao@sogou-inc.com,zhouchunying@sogou-inc.com","意见反馈",$qt,$header); } }*/ #-->> Setting Variables $varnames = array("action", "sid", "cq"); SetVars($varnames); $sid = intval($sid); if($sid == 74) exit(); #-->> Admin Preview Only $admin = 0; if ($action == "preview") { if (!IsAdmin()) { header("Location: admin/index.php?errormsg=AdminPreview"); exit(); } $admin = 1; } #-->> State Variables $cq = ($cq) ? $cq : 1; #-->> Checking for SID Validity $qstring = "select *, UNIX_TIMESTAMP(StartDate) as starttime, UNIX_TIMESTAMP(EndDate) as endtime, UNIX_TIMESTAMP(NOW()) as nowtime from phpQSurvey where SID = \"".ProtectMySQL($sid)."\""; if (!($masurvey = mysql_fetch_array(mysql_query($qstring)))) { header("Location: index.php"); exit(); } if ($masurvey["SurveyResults"] == 2 && (isset($_POST["results"]) || isset($_POST["results_x"]))) { header("Location: stats.php?sid=".ProtectHTML($masurvey["SID"])); exit(); } #-->> Set Language... SetLanguage($masurvey['Language']); #-->> Cookie Test $cookiedomain = ($phpQAdmin['CookieDomain'] != '') ? $phpQAdmin['CookieDomain'] : ''; setcookie("phpQTest", "true", 0, '/', $cookiedomain); #-->> Checking Activation if ($masurvey["Active"] == "n" && $action != "preview") { $errormsg = sprintf($phpQlang["SurveyNotActive"], $masurvey["Name"]); } elseif ($action != "preview") { if (substr($masurvey["StartDate"],0,10) != "0000-00-00" && $masurvey["starttime"] > $masurvey["nowtime"]) { $errormsg = sprintf($phpQlang["SurveyPending"], $masurvey["Name"]); } if (substr($masurvey["EndDate"],0,10) != "0000-00-00" && $masurvey["endtime"] < $masurvey["nowtime"]) { $errormsg = sprintf($phpQlang["SurveyExpired"], $masurvey["Name"]); } } #-->> Question Counting $mqqcount = mysql_query("select count(*) as ct from phpQQuestion where SID = \"".ProtectMySQL($sid)."\""); $surveyqcount = ($maqcount = mysql_fetch_array($mqqcount)) ? $maqcount["ct"] : 0; #-->> Simplifying Variables $tablewidth = $masurvey["Width"]; #-->> Checking for Survey Completion $questionresult = GetQuestions($admin, $cq, $surveyqcount, $masurvey); if ($cq == "done" && $questionresult[1] == "complete" && $action != "preview") { if ($surveyqcount > 0) { $storesurvey = true; # Different Methods of Marking Completion # Make sure a user is not submitting a second results set using same form. $ufid = $_POST["ufid"]; if ($ufid != '') { $mqbdtest = mysql_query("select UID,Email,EmailConfirm from phpQUser where BlockDupe = \"".ProtectMySQL($_POST["ufid"])."\" and SID = \"".ProtectMySQL($sid)."\" LIMIT 1"); if ($storeddata = mysql_fetch_array($mqbdtest)) { $storesurvey = false; } } else { $storesurvey = false; } $ip = $REMOTE_ADDR ? $REMOTE_ADDR : $_SERVER["REMOTE_ADDR"]; $suarray = ParseSurveyUsers($masurvey["SurveyUsers"]); if ($suarray[0]) { # Unique IP $mqiptest = mysql_query("select UID,Email,EmailConfirm from phpQUser where IPAddr = \"".ProtectMySQL($ip)."\" and SID = \"".ProtectMySQL($sid)."\" LIMIT 1"); if ($storeddata = mysql_fetch_array($mqiptest)) { $storesurvey = false; } } if ($suarray[1]) { # Cookies $cookiename = "phpQ".$phpQAdmin["phpQID"].$sid; if ($_COOKIE[$cookiename] || !$_COOKIE["phpQTest"]) { $storesurvey = false; $cuid = $_COOKIE[$cookiename]; if ($cuid != '' && is_numeric($cuid)) { $mcquery = mysql_query("select UID,Email,EmailConfirm from phpQUser where SID = \"".ProtectMySQL($sid)."\" and UID = \"".ProtectMySQL($cuid)."\" limit 1"); $storeddata = mysql_fetch_array($mcquery); } else { $storereason = 'cookies'; } } } if ($storesurvey) { $uid = GenerateUID(); $cryptuid = mt_rand(100000, 999999); if ($suarray[1]) { # Cookies setcookie($cookiename, $uid, time()+60*60*24*365, '/', $cookiedomain); } //Modify By ChenXiangjin @ 2009-04-15 12:00 $YYID = (isset($_COOKIE["YYID"]) && !empty($_COOKIE["YYID"])) ? $_COOKIE["YYID"] : ""; $sql = "select UID from phpQUser where YYID = '".$YYID."' and SID = '".ProtectMySQL($sid)."' and CompleteDate>='" . date("Y-m-d H:i:s", time()) . "'"; $rs = mysql_query($sql); if($row = mysql_fetch_row($rs)) { echo ""; exit; } mysql_query("insert into phpQUser (UID, SID, IPAddr, BlockDupe, CheckType, CompleteDate, Confirm, YYID) values (\"".ProtectMySQL($uid)."\", \"".ProtectMySQL($sid)."\", \"".ProtectMySQL($ip)."\", \"".ProtectMySQL($ufid)."\", \"".ProtectMySQL($masurvey["SurveyUsers"])."\", now(), \"".ProtectMySQL($cryptuid)."\", \"".$YYID."\")"); $mqqlist = mysql_query("select * from phpQQuestion where SID = \"".ProtectMySQL($sid)."\" and Type != 'htmlcontent' order by SortOrder"); while ($maqlist = mysql_fetch_array($mqqlist)) { if ($maqlist["Type"] != "pagebreak") { $storeanswer = StoreAnswer($maqlist, $masurvey); if ($storeanswer[0]) { mysql_query("insert into phpQAnswer (UID, SID, QID, Answer) values (\"".ProtectMySQL($uid)."\", \"".ProtectMySQL($sid)."\", \"".ProtectMySQL($maqlist["QID"])."\", \"".ProtectMySQL($storeanswer[1])."\")"); } } } # If a response notice should be emailed to administrators, do so. if ($masurvey["ResponseNotice"] && $masurvey["ResponseEmail"] != '') { $surveydata = ''; $headers = ''; if ($masurvey["ResponseNotice"] == '2') { $surveydata = RecreateSurvey($sid, $uid, '100%', $masurvey, 1); $headers .= "Content-type: text/html\n"; } else { $scriptloc = ''; if ($HTTP_HOST != '') { $scriptloc .= "http://$HTTP_HOST"; } elseif ($_SERVER["HTTP_HOST"] != '') { $scriptloc .= 'http://'.$_SERVER["HTTP_HOST"]; } $php_self = $PHP_SELF ? $PHP_SELF : $_SERVER["PHP_SELF"]; if (!$php_self && $_SERVER['REQUEST_URI']) { $php_self = $_SERVER['REQUEST_URI']; } $scriptloc .= $php_self; $scriptloc = preg_replace("/(.*)\/.*/", "\\1", $scriptloc); $scriptloc = "$scriptloc/view.php?sid=$sid&uid=$uid"; $surveydata = $phpQlang['RNEmailLinkText']; $surveydata = str_replace('::SurveyName::', $masurvey["Name"], $surveydata); $surveydata = str_replace('::ResultsLink::', $scriptloc, $surveydata); $mqinfo = mysql_query("select * from phpQUser where SID = \"".ProtectMySQL($sid)."\" and UID = \"".ProtectMySQL($uid)."\""); if ($mainfo = mysql_fetch_array($mqinfo)) { $ipaddr = ($mainfo["IPAddr"]) ? $mainfo["IPAddr"] : $phpQlang['unavailable']; $surveydata = str_replace('::CompleteDate::', $mainfo["CompleteDate"], $surveydata); $surveydata = str_replace('::IPAddress::', $ipaddr, $surveydata); } } $headers .= 'From: ' . ($masurvey["EmailFrom"] != '' ? $masurvey["EmailFrom"] : $phpQlang["EmailDefaultFrom"]) . "\n"; mail($masurvey["ResponseEmail"],sprintf($phpQlang["ViewSurvey"], $masurvey["Name"]),$surveydata, $headers); } if ($suarray[2] && (ini_get("sendmail_path") || ini_get("SMTP"))) { # Verified Email echo ""; exit(); } # Complete Notice if ($masurvey["OnComplete"] == '1' && $masurvey["SurveyResults"]) { echo ""; exit(); } elseif ($masurvey["OnComplete"] == '2' && $masurvey["RedirectURL"]) { echo ""; exit(); } elseif ($masurvey["OnComplete"] == '3') { $contents = $phpQlang["YourResponse"].'

'; $contents .= RecreateSurvey($sid, $uid, $masurvey["Width"], $masurvey, 1); } elseif ($masurvey["Completed"]) { $contents = $masurvey["Completed"]; } else { $defmesg = sprintf($phpQlang["SurveyCompleted"], $masurvey["Name"]); $contents = PrintMessage($defmesg, $tablewidth); } } else { if ($storereason == 'cookies') { $errormsg = sprintf($phpQlang["SurveyCookieError"], $masurvey["Name"]); } # If the storage failed for another reason, we will try to else { if ($storeddata) { $uid = $storeddata["UID"]; # Verified Email if ($suarray[2] && (ini_get("sendmail_path") || ini_get("SMTP"))) { if ($storeddata["Email"] == '') { header("Location: verify.php?uid=$uid&sid=$sid"); exit(); } elseif ($storeddata["EmailConfirm"] == 'n') { header("Location: confirm.php?uid=$uid&sid=$sid"); exit(); } } # Complete Notice if ($masurvey["OnComplete"] == '1' && $masurvey["SurveyResults"]) { header("Location: stats.php?sid=$sid"); exit(); } elseif ($masurvey["OnComplete"] == '2' && $masurvey["RedirectURL"]) { header("Location: ".ProtectHTML($masurvey["RedirectURL"])); exit(); } elseif ($masurvey["OnComplete"] == '3') { $contents = $phpQlang["YourResponse"].'

'; $contents .= RecreateSurvey($sid, $uid, $masurvey["Width"], $masurvey, 1); } //elseif ($masurvey["Completed"]) { $contents = $masurvey["Completed"]; } else { $errormsg = sprintf($phpQlang["SurveyCompletedAlready"], $masurvey["Name"]); } } else { $errormsg = sprintf($phpQlang["SurveyCompletedAlready"], $masurvey["Name"]); } } } } } elseif ($cq == "done" && $questionresult[1] == "complete" && $action == "preview") { $prevcompmesg = sprintf($phpQlang["SurveyPreviewCompleted"], $masurvey["Name"]); $contents = "\n"; $contents .= "\n"; $contents .= "\n"; $contents .= "\n";; $contents .= "\n"; $contents .= "\n"; $contents .= "
"; $contents .= "$prevcompmesg
".$masurvey["Completed"]."
\n"; } else { $contents .= CreateSurvey($sid, $cq, $tablewidth, $questionresult[2], $admin); } #-->> Checking for Questions in Survey if ($surveyqcount == 0) { $errormsg = sprintf($phpQlang["SurveyEmpty"], $masurvey["Name"]); } #-->> Overwriting Contents if Deactivated $contents = ($errormsg) ? PrintMessage($errormsg, $tablewidth) : $contents; #-->> Output Page CreatePage($sid, $masurvey["Name"], $contents, false, ""); ?>