本文整理汇总了PHP中date_shift函数的典型用法代码示例。如果您正苦于以下问题:PHP date_shift函数的具体用法?PHP date_shift怎么用?PHP date_shift使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了date_shift函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: emailSender
//.........这里部分代码省略.........
}
if (isset($surveyid) && getEmailFormat($surveyid) == 'html') {
$ishtml = true;
} else {
$ishtml = false;
}
//GET SURVEY DETAILS
$thissurvey = getSurveyInfo($surveyid);
$this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", {$surveyid}, {$type}");
// Texte für Mails aus der Datenbank holen.
$sql = "SELECT surveyls_language, surveyls_email_remind_subj, surveyls_email_remind " . "FROM {$dbprefix}surveys_languagesettings " . "WHERE surveyls_survey_id = " . $surveyid . " ";
$this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", invite ");
$sqlResult = db_execute_assoc($sql);
while ($languageRow = $sqlResult->FetchRow()) {
$_POST['message_' . $languageRow['surveyls_language']] = $languageRow['surveyls_email_remind'];
$_POST['subject_' . $languageRow['surveyls_language']] = $languageRow['surveyls_email_remind_subj'];
}
//$tokenoutput .= ("Sending Reminders")."\n";
$surveylangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselanguage = GetBaseLanguageFromSurveyID($surveyid);
array_unshift($surveylangs, $baselanguage);
foreach ($surveylangs as $language) {
$_POST['message_' . $language] = auto_unescape($_POST['message_' . $language]);
$_POST['subject_' . $language] = auto_unescape($_POST['subject_' . $language]);
}
$SQLemailstatuscondition = " AND emailstatus = 'OK'";
if (isset($_POST['maxremindercount']) && $_POST['maxremindercount'] != '' && intval($_POST['maxremindercount']) != 0) {
$SQLremindercountcondition = " AND remindercount < " . intval($_POST['maxremindercount']);
} else {
$SQLremindercountcondition = "";
}
if (isset($_POST['minreminderdelay']) && $_POST['minreminderdelay'] != '' && intval($_POST['minreminderdelay']) != 0) {
// $_POST['minreminderdelay'] in days (86400 seconds per day)
$compareddate = date_shift(date("Y-m-d H:i:s", time() - 86400 * intval($_POST['minreminderdelay'])), "Y-m-d H:i", $timeadjust);
$SQLreminderdelaycondition = " AND ( " . " (remindersent = 'N' AND sent < '" . $compareddate . "') " . " OR " . " (remindersent < '" . $compareddate . "'))";
} else {
$SQLreminderdelaycondition = "";
}
$ctquery = "SELECT * FROM " . db_table_name("tokens_{$surveyid}") . " WHERE (completed ='N' or completed ='') AND sent<>'' AND sent<>'N' AND token <>'' AND email <> '' {$SQLemailstatuscondition} {$SQLremindercountcondition} {$SQLreminderdelaycondition}";
if (isset($starttokenid)) {
$ctquery .= " AND tid >= '{$starttokenid}'";
}
// if (isset($tokenid) && $tokenid) {$ctquery .= " AND tid = '{$tokenid}'";}
// //$tokenoutput .= "<!-- ctquery: $ctquery -->\n";
$ctresult = $connect->Execute($ctquery) or $this->debugLsrc("Database error!\n" . $connect->ErrorMsg());
$ctcount = $ctresult->RecordCount();
$ctfieldcount = $ctresult->FieldCount();
$emquery = "SELECT * ";
//if ($ctfieldcount > 7) {$emquery .= ", attribute_1, attribute_2";}
// TLR change to put date into sent
$emquery .= " FROM " . db_table_name("tokens_{$surveyid}") . " WHERE (completed = 'N' or completed = '') AND sent <> 'N' and sent <>'' AND token <>'' AND EMAIL <>'' {$SQLemailstatuscondition} {$SQLremindercountcondition} {$SQLreminderdelaycondition}";
if (isset($starttokenid)) {
$emquery .= " AND tid >= '{$starttokenid}'";
}
if (isset($tokenid) && $tokenid) {
$emquery .= " AND tid = '{$tokenid}'";
}
$emquery .= " ORDER BY tid ";
$emresult = db_select_limit_assoc($emquery, $maxemails);
//$emresult = db_execute_assoc($emquery);
$emcount = $emresult->RecordCount();
if ($emcount > 0) {
while ($emrow = $emresult->FetchRow()) {
$c = 1;
unset($fieldsarray);
$to = $emrow['email'];
示例2: elseif
////////////////////////////////////////////////////////////////////////
// SURVEY MENU BAR
////////////////////////////////////////////////////////////////////////
$surveysummary .= "" . "<div class='menubar surveybar'>\n" . "<div class='menubar-title ui-widget-header'>\n" . "<strong>" . $clang->gT("Survey") . "</strong> " . "<span class='basic'>{$surveyinfo['surveyls_title']} (" . $clang->gT("ID") . ":{$surveyid})</span></div>\n" . "<div class='menubar-main'>\n" . "<div class='menubar-left'>\n";
// ACTIVATE SURVEY BUTTON
if ($activated == "N") {
$surveysummary .= "<img src='{$imageurl}/inactive.png' " . "alt='" . $clang->gT("This survey is currently not active") . "' />\n";
if ($sumcount3 > 0 && bHasSurveyPermission($surveyid, 'surveyactivation', 'update')) {
$surveysummary .= "<a href=\"#\" onclick=\"window.open('{$scriptname}?action=activate&sid={$surveyid}', '_top')\"" . " title=\"" . $clang->gTview("Activate this Survey") . "\" >" . "<img src='{$imageurl}/activate.png' name='ActivateSurvey' alt='" . $clang->gT("Activate this Survey") . "'/></a>\n";
} else {
$surveysummary .= "<img src='{$imageurl}/activate_disabled.png' alt='" . $clang->gT("Survey cannot be activated. Either you have no permission or there are no questions.") . "' />\n";
}
} elseif ($activated == "Y") {
if ($surveyinfo['expires'] != '' && $surveyinfo['expires'] < date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i", $timeadjust)) {
$surveysummary .= "<img src='{$imageurl}/expired.png' " . "alt='" . $clang->gT("This survey is active but expired.") . "' />\n";
} elseif ($surveyinfo['startdate'] != '' && $surveyinfo['startdate'] > date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i", $timeadjust)) {
$surveysummary .= "<img src='{$imageurl}/notyetstarted.png' " . "alt='" . $clang->gT("This survey is active but has a start date.") . "' />\n";
} else {
$surveysummary .= "<img src='{$imageurl}/active.png' title='' " . "alt='" . $clang->gT("This survey is currently active.") . "' />\n";
}
if (bHasSurveyPermission($surveyid, 'surveyactivation', 'update')) {
$surveysummary .= "<a href=\"#\" onclick=\"window.open('{$scriptname}?action=deactivate&sid={$surveyid}', '_top')\"" . " title=\"" . $clang->gTview("Deactivate this Survey") . "\" >" . "<img src='{$imageurl}/deactivate.png' alt='" . $clang->gT("Deactivate this Survey") . "' /></a>\n";
} else {
$surveysummary .= "<img src='{$imageurl}/blank.gif' alt='' width='14' />\n";
}
}
$surveysummary .= "<img src='{$imageurl}/seperator.gif' alt='' />\n" . "</div>\n";
// Start of suckerfish menu
$surveysummary .= "<ul class='sf-menu'>\n";
// ACTIVATE SURVEY BUTTON
if ($activated == "N") {
示例3: XMLImportSurvey
/**
* This function imports a LimeSurvey .lss survey XML file
*
* @param mixed $sFullFilepath The full filepath of the uploaded file
*/
function XMLImportSurvey($sFullFilepath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDesiredSurveyId=NULL, $bTranslateInsertansTags=true)
{
global $connect, $dbprefix, $clang, $timeadjust;
$results['error']=false;
if ($sXMLdata == NULL)
{
$xml = simplexml_load_file($sFullFilepath);
} else
{
$xml = simplexml_load_string($sXMLdata);
}
if ($xml->LimeSurveyDocType!='Survey')
{
$results['error'] = $clang->gT("This is not a valid LimeSurvey survey structure XML file.");
return $results;
}
else
{
//$results['error'] = $clang->gT("This is VALID LimeSurvey survey structure XML file.");
//echo $clang->gT("This is VALID LimeSurvey survey structure XML file.");
//return $results;
}
$dbversion = (int) $xml->DBVersion;
$aQIDReplacements=array();
$aQuotaReplacements=array();
$results['defaultvalues']=0;
$results['answers']=0;
$results['surveys']=0;
$results['questions']=0;
$results['subquestions']=0;
$results['question_attributes']=0;
$results['groups']=0;
$results['assessments']=0;
$results['quota']=0;
$results['quotals']=0;
$results['quotamembers']=0;
$results['importwarnings']=array();
$aLanguagesSupported=array();
foreach ($xml->languages->language as $language)
{
$aLanguagesSupported[]=(string)$language;
}
$results['languages']=count($aLanguagesSupported);
// First get an overview of fieldnames - it's not useful for the moment but might be with newer versions
/*
$fieldnames=array();
foreach ($xml->questions->fields->fieldname as $fieldname )
{
$fieldnames[]=(string)$fieldname;
};*/
// Import surveys table ===================================================================================
$tablename=$dbprefix.'surveys';
foreach ($xml->surveys->rows->row as $row)
{
$insertdata=array();
foreach ($row as $key=>$value)
{
$insertdata[(string)$key]=(string)$value;
}
$oldsid=$insertdata['sid'];
if($iDesiredSurveyId!=NULL)
{
$newsid=GetNewSurveyID($iDesiredSurveyId);
}
else
{
$newsid=GetNewSurveyID($oldsid);
}
if ($dbversion<=143)
{
$insertdata['anonymized']=$insertdata['private'];
unset($insertdata['private']);
unset($insertdata['notification']);
}
$insertdata['startdate']=NULL;
//Now insert the new SID and change some values
$insertdata['sid']=$newsid;
//Make sure it is not set active
$insertdata['active']='N';
//Set current user to be the owner
$insertdata['owner_id']=$_SESSION['loginID'];
//Change creation date to import date
$insertdata['datecreated']=$connect->BindTimeStamp(date_shift(date("Y-m-d H:i:s"), "Y-m-d", $timeadjust));
db_switchIDInsert('surveys',true);
$query=$connect->GetInsertSQL($tablename,$insertdata);
//.........这里部分代码省略.........
示例4: getAdminHeader
include $homedir . "/sessioncontrol.php";
/**
* @param string $htmlheader
* This is the html header text for all administration pages
*
*/
$htmlheader = getAdminHeader();
}
//SET LANGUAGE DIRECTORY
if ($sourcefrom == "admin") {
$langdir = "{$publicurl}/locale/" . $_SESSION['adminlang'] . "/help";
$langdirlocal = "{$rootdir}/locale/" . $_SESSION['adminlang'] . "/help";
if (!is_dir($langdirlocal)) {
$langdir = "{$publicurl}/locale/en/help";
//default to english if there is no matching language dir
}
}
if ($sourcefrom == "admin" && $buildnumber != "" && $updatecheckperiod > 0 && $updatelastcheck < date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", "-" . $updatecheckperiod . " days")) {
//updatecheck();
}
//SET LOCAL TIME
if (substr($timeadjust, 0, 1) != '-' && substr($timeadjust, 0, 1) != '+') {
$timeadjust = '+' . $timeadjust;
}
if (strpos($timeadjust, 'hours') === false && strpos($timeadjust, 'minutes') === false && strpos($timeadjust, 'days') === false) {
$timeadjust = $timeadjust . ' hours';
}
// SITE STYLES
$setfont = "<font size='2' face='verdana'>";
$singleborderstyle = "style='border: 1px solid #111111'";
// Closing PHP tag intentionally left out - yes, it is okay
示例5: saveshow
break;
}
//$dataentryoutput .= " [$surveyid"."X"."$gid"."X"."$qid]";
$dataentryoutput .= "</td>\n";
$dataentryoutput .= "\t</tr>\n";
$dataentryoutput .= "\t<tr class='data-entry-separator'><td colspan='3'></td></tr>\n";
}
}
if ($thissurvey['active'] == "Y") {
// Show Finalize response option
$dataentryoutput .= "<script type='text/javascript'>\n\t\t\t\t <!--\n\t\t\t\t\tfunction saveshow(value)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tif (document.getElementById(value).checked == true)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdocument.getElementById(\"closerecord\").checked=false;\n\t\t\t\t\t\t\tdocument.getElementById(\"closerecord\").disabled=true;\n\t\t\t\t\t\t\tdocument.getElementById(\"saveoptions\").style.display=\"\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdocument.getElementById(\"saveoptions\").style.display=\"none\";\n\t\t\t\t\t\t\t document.getElementById(\"closerecord\").disabled=false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t //-->\n\t\t\t\t </script>\n";
$dataentryoutput .= "\t<tr>\n";
$dataentryoutput .= "<td colspan='3' align='center'>\n";
$dataentryoutput .= "<table><tr><td align='left'>\n";
$dataentryoutput .= "\t<input type='checkbox' class='checkboxbtn' name='closerecord' id='closerecord' checked='checked'/><label for='closerecord'>" . $clang->gT("Finalize response submission") . "</label></td></tr>\n";
$dataentryoutput .= "<input type='hidden' name='closedate' value='" . date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust) . "' />\n";
if ($thissurvey['allowsave'] == "Y") {
//Show Save Option
$dataentryoutput .= "\t<tr><td align='left'><input type='checkbox' class='checkboxbtn' name='save' id='save' onclick='saveshow(this.id)' /><label for='save'>" . $clang->gT("Save for further completion by survey user") . "</label>\n";
$dataentryoutput .= "</td></tr></table>\n";
$dataentryoutput .= "<div name='saveoptions' id='saveoptions' style='display: none'>\n";
$dataentryoutput .= "<table align='center' class='outlinetable' cellspacing='0'>\n\t\t\t\t\t <tr><td align='right'>" . $clang->gT("Identifier:") . "</td>\n\t\t\t\t\t <td><input type='text' name='save_identifier' /></td></tr>\n\t\t\t\t\t <tr><td align='right'>" . $clang->gT("Password:") . "</td>\n\t\t\t\t\t <td><input type='password' name='save_password' /></td></tr>\n\t\t\t\t\t <tr><td align='right'>" . $clang->gT("Confirm Password:") . "</td>\n\t\t\t\t\t <td><input type='password' name='save_confirmpassword' /></td></tr>\n\t\t\t\t\t <tr><td align='right'>" . $clang->gT("Email:") . "</td>\n\t\t\t\t\t <td><input type='text' name='save_email' /></td></tr>\n\t\t\t\t\t <tr><td align='right'>" . $clang->gT("Start Language:") . "</td>\n\t\t\t\t\t <td>";
$slangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$sbaselang = GetBaseLanguageFromSurveyID($surveyid);
array_unshift($slangs, $sbaselang);
$dataentryoutput .= "<select name='save_language'>\n";
foreach ($slangs as $lang) {
if ($lang == $baselang) {
$dataentryoutput .= "\t<option value='{$lang}' selected='selected'>" . getLanguageNameFromCode($lang, false) . "</option>\n";
} else {
$dataentryoutput .= "\t<option value='{$lang}'>" . getLanguageNameFromCode($lang, false) . "</option>\n";
示例6: get_current_shifts
public function get_current_shifts($gen_id = null)
{
if ($gen_id) {
$current_gen = Gen::find($gen_id);
} else {
$current_gen = Gen::getCurrentGen();
}
$shifts = $current_gen->shifts()->get();
$weeks = $shifts->pluck('week')->unique()->sortByDesc(function ($week, $key) {
return $week;
});
$return_arr = [];
foreach ($weeks as $week) {
$week_shifts = $shifts->where('week', $week);
$dates = $week_shifts->pluck('date')->unique();
$return_dates = [];
foreach ($dates as $date) {
$obj = new \stdClass();
$obj->date = date_shift(strtotime($date));
$obj->shifts = $shifts->filter(function ($item) use($date) {
return $item->date == $date;
});
$shiftsData = $this->shiftTransfromer->transformCollection($obj->shifts);
$obj->shifts = $shiftsData;
$return_dates[] = $obj;
}
$return_arr[] = ['dates' => $return_dates, 'week' => $week];
}
return response()->json(['weeks' => $return_arr]);
}
示例7: completedump
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: dumpdb.php 10475 2011-07-11 16:14:32Z c_schmitz $
*/
include_once "login_check.php";
//Login Check dies also if the script is started directly
if ($database_exists && ($databasetype == 'mysql' || $databasetype == 'mysqli') && $demoModeOnly != true && $action == 'dumpdb') {
$export = completedump();
$file_name = "LimeSurvey_{$databasename}_dump_" . date_shift(date("Y-m-d H:i:s"), "Y-m-d", $timeadjust) . ".sql";
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename={$file_name}");
Header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
Header("Pragma: Public");
echo $export;
exit;
// needs to be inside the condition so the updater still can include this file
}
/**
* Creates a full dump of the current LimeSurvey database
*
* @returns string Contains the dumped data
*/
function completedump()
{
示例8: _UpdateValuesInDatabase
/**
* Write values to database.
* @param <type> $updatedValues
* @param <boolean> $finished - true if the survey needs to be finalized
*/
private function _UpdateValuesInDatabase($updatedValues, $finished = false, $setSubmitDate = false)
{
// Update these values in the database
global $connect;
// TODO - now that using $this->updatedValues, may be able to remove local copies of it (unless needed by other sub-systems)
$updatedValues = $this->updatedValues;
if (!$this->surveyOptions['deletenonvalues']) {
$nonNullValues = array();
foreach ($updatedValues as $key => $value) {
if (!is_null($value)) {
if (isset($value['value']) && !is_null($value['value'])) {
$nonNullValues[$key] = $value;
}
}
}
$updatedValues = $nonNullValues;
}
$message = '';
if ($this->surveyOptions['datestamp'] == true && $this->surveyOptions['anonymized'] == true) {
// On anonymous datestamped surveys, set the datestamp to 1-1-1980
$datestamp = date("Y-m-d H:i:s", mktime(0, 0, 0, 1, 1, 1980));
} else {
// Otherwise, use the real date/time, it will only be saved when the table holds a
// datestamp field
$datestamp = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $this->surveyOptions['timeadjust']);
}
$_SESSION['datestamp'] = $datestamp;
if ($this->surveyOptions['active'] && !isset($_SESSION['srid'])) {
// Create initial insert row for this record
$sdata = array("datestamp" => $datestamp, "ipaddr" => $this->surveyOptions['ipaddr'] ? getIPAddress() : '', "startlanguage" => $this->surveyOptions['startlanguage'], "token" => $this->surveyOptions['token'], "refurl" => $this->surveyOptions['refurl'] ? getenv("HTTP_REFERER") : NULL, "startdate" => $datestamp);
//One of the strengths of ADOdb's AutoExecute() is that only valid field names for $table are updated
if ($connect->AutoExecute($this->surveyOptions['tablename'], $sdata, 'INSERT')) {
$srid = $connect->Insert_ID($this->surveyOptions['tablename'], "id");
$_SESSION['srid'] = $srid;
} else {
$message .= $this->gT("Unable to insert record into survey table: ") . $connect->ErrorMsg() . "<br/>";
$_SESSION['flashmessage'] = $message;
echo $message;
}
//Insert Row for Timings, if needed
if ($this->surveyOptions['savetimings']) {
$tdata = array('id' => $srid, 'interviewtime' => 0);
if ($connect->AutoExecute($this->surveyOptions['tablename_timings'], $tdata, 'INSERT')) {
$trid = $connect->Insert_ID($this->surveyOptions['tablename_timings'], "sid");
} else {
$message .= $this->gT("Unable to insert record into timings table ") . $connect->ErrorMsg() . "<br/>";
$_SESSION['flashmessage'] = $message;
echo $message;
}
}
}
if (count($updatedValues) > 0 || $finished) {
$query = 'UPDATE ' . $this->surveyOptions['tablename'] . " SET ";
$setter = array();
switch ($this->surveyMode) {
case 'question':
$thisstep = $this->currentQuestionSeq;
break;
case 'group':
$thisstep = $this->currentGroupSeq;
break;
case 'survey':
$thisstep = 1;
break;
}
$setter[] = db_quote_id('lastpage') . "=" . db_quoteall($thisstep);
if ($this->surveyOptions['datestamp'] && isset($_SESSION['datestamp'])) {
$setter[] = db_quote_id('datestamp') . "=" . db_quoteall($_SESSION['datestamp']);
}
if ($this->surveyOptions['ipaddr']) {
$setter[] = db_quote_id('ipaddr') . "=" . db_quoteall(getIPAddress());
}
foreach ($updatedValues as $key => $value) {
if (!empty($key)) {
$val = is_null($value) ? NULL : $value['value'];
$type = is_null($value) ? NULL : $value['type'];
// Clean up the values to cope with database storage requirements
switch ($type) {
case 'D':
//DATE
if (trim($val) == '') {
$val = NULL;
// since some databases can't store blanks in date fields
}
// otherwise will already be in yyyy-mm-dd format after ProcessCurrentResponses()
break;
case '|':
//File upload
// This block can be removed once we require 5.3 or later
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
$val = addslashes($val);
}
break;
case 'N':
//NUMERICAL QUESTION TYPE
//.........这里部分代码省略.........
示例9: _UpdateValuesInDatabase
/**
* Write values to database.
* @param <type> $updatedValues
* @param <boolean> $finished - true if the survey needs to be finalized
*/
private function _UpdateValuesInDatabase($updatedValues, $finished = false)
{
// Update these values in the database
global $connect;
$message = '';
$_SESSION['datestamp'] = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $this->surveyOptions['timeadjust']);
if ($this->surveyOptions['active'] && !isset($_SESSION['srid'])) {
// Create initial insert row for this record
$today = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $this->surveyOptions['timeadjust']);
$sdata = array("datestamp" => $today, "ipaddr" => $this->surveyOptions['ipaddr'] && isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', "startlanguage" => $this->surveyOptions['startlanguage'], "token" => $this->surveyOptions['token'], "datestamp" => $this->surveyOptions['datestamp'] ? $_SESSION['datestamp'] : NULL, "refurl" => $this->surveyOptions['refurl'] ? getenv("HTTP_REFERER") : NULL, "startdate" => $this->surveyOptions['datestamp'] ? $_SESSION['datestamp'] : date("Y-m-d H:i:s", 0));
//One of the strengths of ADOdb's AutoExecute() is that only valid field names for $table are updated
if ($connect->AutoExecute($this->surveyOptions['tablename'], $sdata, 'INSERT')) {
$srid = $connect->Insert_ID($this->surveyOptions['tablename'], "id");
$_SESSION['srid'] = $srid;
} else {
$message .= $this->gT("Unable to insert record into survey table: ") . $connect->ErrorMsg() . "<br/>";
$_SESSION['flashmessage'] = $message;
echo $message;
}
//Insert Row for Timings, if needed
if ($this->surveyOptions['savetimings']) {
$tdata = array('id' => $srid, 'interviewtime' => 0);
if ($connect->AutoExecute($this->surveyOptions['tablename_timings'], $tdata, 'INSERT')) {
$trid = $connect->Insert_ID($this->surveyOptions['tablename_timings'], "sid");
} else {
$message .= $this->gT("Unable to insert record into timings table ") . $connect->ErrorMsg() . "<br/>";
$_SESSION['flashmessage'] = $message;
echo $message;
}
}
}
if (count($updatedValues) > 0 || $finished) {
$query = 'UPDATE ' . $this->surveyOptions['tablename'] . " SET ";
$setter = array();
switch ($this->surveyMode) {
case 'question':
$thisstep = $this->currentQuestionSeq;
break;
case 'group':
$thisstep = $this->currentGroupSeq;
break;
case 'survey':
$thisstep = 1;
break;
}
$setter[] = db_quote_id('lastpage') . "=" . db_quoteall($thisstep);
if ($this->surveyOptions['datestamp'] && isset($_SESSION['datestamp'])) {
$setter[] = db_quote_id('datestamp') . "=" . db_quoteall($_SESSION['datestamp']);
}
if ($this->surveyOptions['ipaddr'] && isset($_SERVER['REMOTE_ADDR'])) {
$setter[] = db_quote_id('ipaddr') . "=" . db_quoteall($_SERVER['REMOTE_ADDR']);
}
if ($finished) {
$setter[] = db_quote_id('submitdate') . "=" . db_quoteall($_SESSION['datestamp']);
}
foreach ($updatedValues as $key => $value) {
$val = is_null($value) ? NULL : $value['value'];
$type = is_null($value) ? NULL : $value['type'];
// Clean up the values to cope with database storage requirements
switch ($type) {
case 'D':
//DATE
if (trim($val) == '') {
$val = NULL;
// since some databases can't store blanks in date fields
}
// otherwise will already be in yyyy-mm-dd format after ProcessCurrentResponses()
break;
case 'N':
//NUMERICAL QUESTION TYPE
//NUMERICAL QUESTION TYPE
case 'K':
//MULTIPLE NUMERICAL QUESTION
if (trim($val) == '') {
$val = NULL;
// since some databases can't store blanks in numerical inputs
}
break;
default:
break;
}
if (is_null($val)) {
$setter[] = db_quote_id($key) . "=NULL";
} else {
$setter[] = db_quote_id($key) . "=" . db_quoteall($val);
}
}
$query .= implode(', ', $setter);
$query .= " WHERE ID=";
if (isset($_SESSION['srid']) && $this->surveyOptions['active']) {
$query .= $_SESSION['srid'];
if (!db_execute_assoc($query)) {
echo submitfailed($connect->ErrorMsg());
if (($this->debugLevel & LEM_DEBUG_VALIDATION_SUMMARY) == LEM_DEBUG_VALIDATION_SUMMARY) {
$message .= 'Error in SQL update: ' . $connect->ErrorMsg() . '<br/>';
//.........这里部分代码省略.........
示例10: Date_Time_Converter
$datetimeobj = new Date_Time_Converter($rows['datecreated'], "Y-m-d H:i:s");
$datecreated = $datetimeobj->convert($dateformatdetails['phpdate']);
if (in_array($rows['owner_id'], getuserlist('onlyuidarray'))) {
$ownername = $rows['users_name'];
} else {
$ownername = "---";
}
$questionsCount = 0;
$questionsCountQuery = "SELECT * FROM " . db_table_name('questions') . " WHERE sid={$rows['sid']} AND language='" . $rows['language'] . "'";
//Getting a count of questions for this survey
$questionsCountResult = $connect->Execute($questionsCountQuery);
//Checked
$questionsCount = $questionsCountResult->RecordCount();
$listsurveys .= "<tr>";
if ($rows['active'] == "Y") {
if ($rows['expires'] != '' && $rows['expires'] < date_shift(date("Y-m-d H:i:s"), "Y-m-d", $timeadjust)) {
$listsurveys .= "<td><img src='{$imageurl}/expired.png' " . "alt='" . $clang->gT("This survey is active but expired.") . "' /></td>";
} else {
if (bHasSurveyPermission($rows['sid'], 'surveyactivation', 'update')) {
$listsurveys .= "<td><a href=\"#\" onclick=\"window.open('{$scriptname}?action=deactivate&sid={$rows['sid']}', '_top')\"" . " title=\"" . $clang->gTview("This survey is active - click here to deactivate this survey.") . "\" >" . "<img src='{$imageurl}/active.png' alt='" . $clang->gT("This survey is active - click here to deactivate this survey.") . "' /></a></td>\n";
} else {
$listsurveys .= "<td><img src='{$imageurl}/active.png' " . "alt='" . $clang->gT("This survey is currently active.") . "' /></td>\n";
}
}
} else {
if ($questionsCount > 0 && bHasSurveyPermission($rows['sid'], 'surveyactivation', 'update')) {
$listsurveys .= "<td><a href=\"#\" onclick=\"window.open('{$scriptname}?action=activate&sid={$rows['sid']}', '_top')\"" . " title=\"" . $clang->gTview("This survey is currently not active - click here to activate this survey.") . "\" >" . "<img src='{$imageurl}/inactive.png' title='' alt='" . $clang->gT("This survey is currently not active - click here to activate this survey.") . "' /></a></td>\n";
} else {
$listsurveys .= "<td><img src='{$imageurl}/inactive.png'" . " title='" . $clang->gT("This survey is currently not active.") . "' alt='" . $clang->gT("This survey is currently not active.") . "' />" . "</td>\n";
}
}
示例11: savedcontrol
function savedcontrol()
{
//This data will be saved to the "saved_control" table with one row per response.
// - a unique "saved_id" value (autoincremented)
// - the "sid" for this survey
// - the "srid" for the survey_x row id
// - "saved_thisstep" which is the step the user is up to in this survey
// - "saved_ip" which is the ip address of the submitter
// - "saved_date" which is the date ofthe saved response
// - an "identifier" which is like a username
// - a "password"
// - "fieldname" which is the fieldname of the saved response
// - "value" which is the value of the response
//We start by generating the first 5 values which are consistent for all rows.
global $connect, $surveyid, $dbprefix, $thissurvey, $errormsg, $publicurl, $sitename, $timeadjust, $clang, $clienttoken, $thisstep;
//Check that the required fields have been completed.
$errormsg = "";
/* queXS Removal
if (!isset($_POST['savename']) || !$_POST['savename']) {$errormsg.=$clang->gT("You must supply a name for this saved session.")."<br />\n";}
if (!isset($_POST['savepass']) || !$_POST['savepass']) {$errormsg.=$clang->gT("You must supply a password for this saved session.")."<br />\n";}
if ((isset($_POST['savepass']) && !isset($_POST['savepass2'])) || $_POST['savepass'] != $_POST['savepass2'])
{$errormsg.=$clang->gT("Your passwords do not match.")."<br />\n";}
// if security question asnwer is incorrect
if (function_exists("ImageCreate") && captcha_enabled('saveandloadscreen',$thissurvey['usecaptcha']))
{
if (!isset($_POST['loadsecurity']) ||
!isset($_SESSION['secanswer']) ||
$_POST['loadsecurity'] != $_SESSION['secanswer'])
{
$errormsg .= $clang->gT("The answer to the security question is incorrect.")."<br />\n";
}
}
if (trim($_POST['saveemail'])!='' && !validate_email($_POST['saveemail']))
{
$errormsg .= $clang->gT("The email address is not valid. Please leave the email field blank or give a valid email address.")."<br />\n";
}
end queXS Removal */
if ($errormsg) {
return;
}
//All the fields are correct. Now make sure there's not already a matching saved item
$query = "SELECT COUNT(*) FROM {$dbprefix}saved_control\n" . "WHERE sid={$surveyid}\n" . "AND identifier=" . db_quoteall($_POST['token'], true);
$result = db_execute_num($query) or safe_die("Error checking for duplicates!<br />{$query}<br />" . $connect->ErrorMsg());
// Checked
list($count) = $result->FetchRow();
if ($count == 1) {
//we should update the field with the latest $_SESSION['step'] - stored in saved_thisstep - queXS addition
$sql = "UPDATE {$dbprefix}saved_control SET saved_thisstep = '{$_SESSION['step']}' WHERE sid={$surveyid} AND identifier='{$_POST['token']}'";
$connect->Execute($sql);
} else {
if ($count > 0) {
$errormsg .= $clang->gT("This name has already been used for this survey. You must use a unique save name.") . "<br />\n";
return;
} else {
//INSERT BLANK RECORD INTO "survey_x" if one doesn't already exist
if (!isset($_SESSION['srid'])) {
$today = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust);
$sdata = array("datestamp" => $today, "ipaddr" => getIPAddress(), "startlanguage" => $_SESSION['s_lang'], "refurl" => getenv("HTTP_REFERER"), "token" => $_POST['token']);
//One of the strengths of ADOdb's AutoExecute() is that only valid field names for $table are updated
if ($connect->AutoExecute($thissurvey['tablename'], $sdata, 'INSERT')) {
$srid = $connect->Insert_ID($thissurvey['tablename'], "sid");
$_SESSION['srid'] = $srid;
} else {
safe_die("Unable to insert record into survey table.<br /><br />" . $connect->ErrorMsg());
}
}
//CREATE ENTRY INTO "saved_control"
$today = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust);
$scdata = array("sid" => $surveyid, "srid" => $_SESSION['srid'], "identifier" => $_POST['token'], "access_code" => md5($_POST['token']), "email" => $_POST['token'], "ip" => getIPAddress(), "refurl" => getenv("HTTP_REFERER"), "saved_thisstep" => $thisstep, "status" => "S", "saved_date" => $today);
if ($connect->AutoExecute("{$dbprefix}saved_control", $scdata, 'INSERT')) {
$scid = $connect->Insert_ID("{$dbprefix}saved_control", 'scid');
$_SESSION['scid'] = $scid;
} else {
safe_die("Unable to insert record into saved_control table.<br /><br />" . $connect->ErrorMsg());
}
$_SESSION['holdname'] = $_POST['token'];
//Session variable used to load answers every page. Unsafe - so it has to be taken care of on output
$_SESSION['holdpass'] = $_POST['token'];
//Session variable used to load answers every page. Unsafe - so it has to be taken care of on output
/* queXS Removal
//Email if needed
if (isset($_POST['saveemail']) && validate_email($_POST['saveemail']))
{
$subject=$clang->gT("Saved Survey Details") . " - " . $thissurvey['name'];
$message=$clang->gT("Thank you for saving your survey in progress. The following details can be used to return to this survey and continue where you left off. Please keep this e-mail for your reference - we cannot retrieve the password for you.","unescaped");
$message.="\n\n".$thissurvey['name']."\n\n";
$message.=$clang->gT("Name","unescaped").": ".$_POST['savename']."\n";
$message.=$clang->gT("Password","unescaped").": ".$_POST['savepass']."\n\n";
$message.=$clang->gT("Reload your survey by clicking on the following link (or pasting it into your browser):","unescaped")."\n";
$message.=$publicurl."/index.php?sid=$surveyid&loadall=reload&scid=".$scid."&loadname=".urlencode($_POST['savename'])."&loadpass=".urlencode($_POST['savepass']);
if ($clienttoken){$message.="&token=".$clienttoken;}
$from="{$thissurvey['adminname']} <{$thissurvey['adminemail']}>";
if (SendEmailMessage(null, $message, $subject, $_POST['saveemail'], $from, $sitename, false, getBounceEmail($surveyid)))
{
$emailsent="Y";
//.........这里部分代码省略.........
示例12: globalsettingsdisplay
//.........这里部分代码省略.........
$editsurvey .= ""
. "\t<li><label for='defaulttemplate'>".$clang->gT("Default template:")."</label>\n"
. "\t\t\t<select name='defaulttemplate' id='defaulttemplate'>\n";
foreach ($templatenames as $templatename)
{
$editsurvey.= "\t\t\t\t<option value='$templatename'";
if ($thisdefaulttemplate==$templatename) {$editsurvey .= " selected='selected'";}
$editsurvey .=">$templatename</option>\n";
}
$editsurvey .="\t\t\t</select></li>\n";
$thisdefaulthtmleditormode=getGlobalSetting('defaulthtmleditormode');
$editsurvey .= ""
. "\t<li><label for='defaulthtmleditormode'>".$clang->gT("Default HTML editor mode:").(($demoModeOnly==true)?'*':'')."</label>\n"
. "\t\t\t<select name='defaulthtmleditormode' id='defaulthtmleditormode'>\n"
. "\t\t\t\t<option value='default'";
if ($thisdefaulthtmleditormode=='default') {$editsurvey .= " selected='selected'";}
$editsurvey .=">".$clang->gT("Default HTML editor mode")."</option>\n"
. "\t\t\t\t<option value='none'";
if ($thisdefaulthtmleditormode=='none') {$editsurvey .= " selected='selected'";}
$editsurvey .=">".$clang->gT("No HTML editor")."</option>\n"
. "<option value='inline'";
if ($thisdefaulthtmleditormode=='inline') {$editsurvey .= " selected='selected'";}
$editsurvey .=">".$clang->gT("Inline HTML editor")."</option>\n"
. "<option value='popup'";
if ($thisdefaulthtmleditormode=='popup') {$editsurvey .= " selected='selected'";}
$editsurvey .=">".$clang->gT("Popup HTML editor")."</option>\n"
. "</select></li>\n";
$dateformatdata=getDateFormatData($_SESSION['dateformat']);
$editsurvey.= "\t<li><label for='timeadjust'>".$clang->gT("Time difference (in hours):")."</label>\n"
. "\t\t<span><input type='text' size='10' id='timeadjust' name='timeadjust' value=\"".htmlspecialchars(str_replace(array('+',' hours'),array('',''),getGlobalSetting('timeadjust')))."\" /> "
. $clang->gT("Server time:").' '.convertDateTimeFormat(date('Y-m-d H:i:s'),'Y-m-d H:i:s',$dateformatdata['phpdate'].' H:i')." - ".$clang->gT("Corrected time :").' '.convertDateTimeFormat(date_shift(date("Y-m-d H:i:s"), 'Y-m-d H:i:s', getGlobalSetting('timeadjust')),'Y-m-d H:i:s',$dateformatdata['phpdate'].' H:i')."
</span></li>\n";
$thisusepdfexport=getGlobalSetting('usepdfexport');
$editsurvey .= "\t<li><label for='usepdfexport'>".$clang->gT("PDF export available:")."</label>\n"
. "<select name='usepdfexport' id='usepdfexport'>\n"
. "<option value='1'";
if ( $thisusepdfexport == true) {$editsurvey .= " selected='selected'";}
$editsurvey .= ">".$clang->gT("On")."</option>\n"
. "<option value='0'";
if ( $thisusepdfexport == false) {$editsurvey .= " selected='selected'";}
$editsurvey .= ">".$clang->gT("Off")."</option>\n"
. "\t\t</select>\n\t</li>\n";
$thisaddTitleToLinks=getGlobalSetting('addTitleToLinks');
$editsurvey .= "\t<li><label for='addTitleToLinks'>".$clang->gT("Screen reader compatibility mode:")."</label>\n"
. "<select name='addTitleToLinks' id='addTitleToLinks'>\n"
. "<option value='1'";
if ( $thisaddTitleToLinks == true) {$editsurvey .= " selected='selected'";}
$editsurvey .= ">".$clang->gT("On")."</option>\n"
. "<option value='0'";
if ( $thisaddTitleToLinks == false) {$editsurvey .= " selected='selected'";}
$editsurvey .= ">".$clang->gT("Off")."</option>\n"
. "</select>\n</li>\n"
. "<li><label for='sessionlifetime'>".$clang->gT("Session lifetime (seconds):")."</label>\n"
. "<input type='text' size='10' id='sessionlifetime' name='sessionlifetime' value=\"".htmlspecialchars(getGlobalSetting('sessionlifetime'))."\" /></li>"
. "<li><label for='ipInfoDbAPIKey'>".$clang->gT("IP Info DB API Key:")."</label>\n"
. "<input type='text' size='35' id='ipInfoDbAPIKey' name='ipInfoDbAPIKey' value=\"".htmlspecialchars(getGlobalSetting('ipInfoDbAPIKey'))."\" /></li>"
. "<li><label for='googleMapsAPIKey'>".$clang->gT("Google Maps API key:")."</label>\n"
. "<input type='text' size='35' id='googleMapsAPIKey' name='googleMapsAPIKey' value=\"".htmlspecialchars(getGlobalSetting('googleMapsAPIKey'))."\" /></li>"
;
示例13: getsurveylist
/**
* getsurveylist() Queries the database (survey table) for a list of existing surveys
*
* @param mixed $returnarray boolean - if set to true an array instead of an HTML option list is given back
*
* @global string $surveyid
* @global string $dbprefix
* @global string $scriptname
* @global string $connect
* @global string $clang
*
* @return string This string is returned containing <option></option> formatted list of existing surveys
*
*/
function getsurveylist($returnarray = false, $returnwithouturl = false)
{
global $surveyid, $dbprefix, $scriptname, $connect, $clang, $timeadjust;
static $cached = null;
if (is_null($cached)) {
$surveyidquery = " SELECT a.*, surveyls_title, surveyls_description, surveyls_welcometext, surveyls_url " . " FROM " . db_table_name('surveys') . " AS a " . "INNER JOIN " . db_table_name('surveys_languagesettings') . " on (surveyls_survey_id=a.sid and surveyls_language=a.language) ";
if (!bHasGlobalPermission('USER_RIGHT_SUPERADMIN')) {
$surveyidquery .= "WHERE a.sid in (select sid from " . db_table_name('survey_permissions') . " where uid={$_SESSION['loginID']} and permission='survey' and read_p=1) ";
}
$surveyidquery .= " order by active DESC, surveyls_title";
$surveyidresult = db_execute_assoc($surveyidquery);
//Checked
if (!$surveyidresult) {
return "Database Error";
}
$surveynames = $surveyidresult->GetRows();
$cached = $surveynames;
} else {
$surveynames = $cached;
}
$surveyselecter = "";
if ($returnarray === true) {
return $surveynames;
}
$activesurveys = '';
$inactivesurveys = '';
$expiredsurveys = '';
if ($surveynames) {
foreach ($surveynames as $sv) {
$surveylstitle = FlattenText($sv['surveyls_title']);
if (strlen($surveylstitle) > 45) {
$surveylstitle = htmlspecialchars(mb_strcut(html_entity_decode($surveylstitle, ENT_QUOTES, 'UTF-8'), 0, 45, 'UTF-8')) . "...";
}
if ($sv['active'] != 'Y') {
$inactivesurveys .= "<option ";
if ($_SESSION['loginID'] == $sv['owner_id']) {
$inactivesurveys .= " style=\"font-weight: bold;\"";
}
if ($sv['sid'] == $surveyid) {
$inactivesurveys .= " selected='selected'";
$svexist = 1;
}
if ($returnwithouturl === false) {
$inactivesurveys .= " value='{$scriptname}?sid={$sv['sid']}'>{$surveylstitle}</option>\n";
} else {
$inactivesurveys .= " value='{$sv['sid']}'>{$surveylstitle}</option>\n";
}
} elseif ($sv['expires'] != '' && $sv['expires'] < date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust)) {
$expiredsurveys .= "<option ";
if ($_SESSION['loginID'] == $sv['owner_id']) {
$expiredsurveys .= " style=\"font-weight: bold;\"";
}
if ($sv['sid'] == $surveyid) {
$expiredsurveys .= " selected='selected'";
$svexist = 1;
}
if ($returnwithouturl === false) {
$expiredsurveys .= " value='{$scriptname}?sid={$sv['sid']}'>{$surveylstitle}</option>\n";
} else {
$expiredsurveys .= " value='{$sv['sid']}'>{$surveylstitle}</option>\n";
}
} else {
$activesurveys .= "<option ";
if ($_SESSION['loginID'] == $sv['owner_id']) {
$activesurveys .= " style=\"font-weight: bold;\"";
}
if ($sv['sid'] == $surveyid) {
$activesurveys .= " selected='selected'";
$svexist = 1;
}
if ($returnwithouturl === false) {
$activesurveys .= " value='{$scriptname}?sid={$sv['sid']}'>{$surveylstitle}</option>\n";
} else {
$activesurveys .= " value='{$sv['sid']}'>{$surveylstitle}</option>\n";
}
}
}
// End Foreach
}
//Only show each activesurvey group if there are some
if ($activesurveys != '') {
$surveyselecter .= "<optgroup label='" . $clang->gT("Active") . "' class='activesurveyselect'>\n";
$surveyselecter .= $activesurveys . "</optgroup>";
}
if ($expiredsurveys != '') {
$surveyselecter .= "<optgroup label='" . $clang->gT("Expired") . "' class='expiredsurveyselect'>\n";
//.........这里部分代码省略.........
示例14: array
$customheaders = array( '1' => "X-surveyid: ".$surveyid,
'2' => "X-tokenid: ".$fieldsarray["{TOKEN}"]);
if (trim($emrow['validfrom'])!='' && convertDateTimeFormat($emrow['validfrom'],'Y-m-d H:i:s','U')*1>date('U')*1)
{
$tokenoutput .= $emrow['tid'] ." ".ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) delayed: Token is not yet valid.")."<br />", $fieldsarray);
}
elseif (trim($emrow['validuntil'])!='' && convertDateTimeFormat($emrow['validuntil'],'Y-m-d H:i:s','U')*1<date('U')*1)
{
$tokenoutput .= $emrow['tid'] ." ".ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) skipped: Token is not valid anymore.")."<br />", $fieldsarray);
}
elseif (SendEmailMessage($sendmessage, $msgsubject, $to, $from, $sitename,$ishtml,getBounceEmail($surveyid),null,$customheaders))
{
// Put date into remindersent
$today = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i", $timeadjust);
$udequery = "UPDATE ".db_table_name("tokens_{$surveyid}")."\n"
."SET remindersent='$today',remindercount = remindercount+1 WHERE tid={$emrow['tid']}";
//
$uderesult = $connect->Execute($udequery) or safe_die ("Could not update tokens<br />$udequery<br />".$connect->ErrorMsg());
//orig: $tokenoutput .= "({$emrow['tid']})[".$clang->gT("Reminder sent to:")." {$emrow['firstname']} {$emrow['lastname']}]<br />\n";
$tokenoutput .= "({$emrow['tid']}) [".$clang->gT("Reminder sent to:")." {$emrow['firstname']} {$emrow['lastname']} ($to)]<br />\n";
}
else
{
$tokenoutput .= $emrow['tid'] ." ".ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) failed. Error Message:")." ".$maildebug."<br />", $fieldsarray);
if ($debug>0)
{
$tokenoutput .= "<pre>Subject : $msgsubject<br /><br />".htmlspecialchars($maildebugbody)."<br /></pre>";
}