当前位置: 首页>>代码示例>>PHP>>正文


PHP db_quoteall函数代码示例

本文整理汇总了PHP中db_quoteall函数的典型用法代码示例。如果您正苦于以下问题:PHP db_quoteall函数的具体用法?PHP db_quoteall怎么用?PHP db_quoteall使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了db_quoteall函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: db_quote_id

                 $updateqr .= db_quote_id($fieldname) . " = '{$datetimeobj->convert("Y-m-d H:i:s")}', \n";
             }
         } elseif (($irow['type'] == 'N' || $irow['type'] == 'K') && $thisvalue == "") {
             $updateqr .= db_quote_id($fieldname) . " = NULL, \n";
         } elseif ($irow['type'] == '|' && strpos($irow['fieldname'], '_filecount') && $thisvalue == "") {
             $updateqr .= db_quote_id($fieldname) . " = NULL, \n";
         } elseif ($irow['type'] == 'submitdate') {
             if (isset($_POST['completed']) && $_POST['completed'] == "N") {
                 $updateqr .= db_quote_id($fieldname) . " = NULL, \n";
             } elseif (isset($_POST['completed']) && $thisvalue == "") {
                 $updateqr .= db_quote_id($fieldname) . " = " . db_quoteall($_POST['completed'], true) . ", \n";
             } else {
                 $updateqr .= db_quote_id($fieldname) . " = " . db_quoteall($thisvalue, true) . ", \n";
             }
         } else {
             $updateqr .= db_quote_id($fieldname) . " = " . db_quoteall($thisvalue, true) . ", \n";
         }
     }
     $updateqr = substr($updateqr, 0, -3);
     $updateqr .= " WHERE id={$id}";
     $updateres = $connect->Execute($updateqr) or safe_die("Update failed:<br />\n" . $connect->ErrorMsg() . "<br />{$updateqr}");
     $thissurvey = getSurveyInfo($surveyid);
     while (ob_get_level() > 0) {
         ob_end_flush();
     }
     $dataentryoutput .= "<div class='messagebox ui-corner-all'><div class='successheader'>" . $clang->gT("Success") . "</div>\n" . $clang->gT("Record has been updated.") . "<br /><br />\n" . "<input type='submit' value='" . $clang->gT("View This Record") . "' onclick=\"window.open('{$scriptname}?action=browse&amp;sid={$surveyid}&amp;subaction=id&amp;id={$id}', '_top')\" /><br /><br />\n" . "<input type='submit' value='" . $clang->gT("Browse Responses") . "' onclick=\"window.open('{$scriptname}?action=browse&amp;sid={$surveyid}&amp;subaction=all', '_top')\" />\n" . "</div>\n";
 } elseif ($subaction == "delete" && bHasSurveyPermission($surveyid, 'responses', 'delete')) {
     $dataentryoutput .= "<div class='header ui-widget-header'>" . $clang->gT("Data entry") . "</div>\n";
     $dataentryoutput .= "<div class='messagebox ui-corner-all'>\n";
     $thissurvey = getSurveyInfo($surveyid);
     $delquery = "DELETE FROM {$surveytable} WHERE id={$id}";
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:dataentry.php

示例2: foreach

                            // No issue, let's import
                            $iq = "INSERT INTO ".db_table_name("tokens_$surveyid")." \n"
                            . "(firstname, lastname, email, emailstatus, token, language";

                            foreach ($aTokenAttr as $thisattrfieldname)
                            {
                                $attridx=substr($thisattrfieldname,10); // the 'attribute_' prefix is 10 chars long
                                if (!empty($myattrArray[$attridx])) {$iq .= ", $thisattrfieldname";}
                            }
                            $iq .=") \n"
                            . "VALUES (".db_quoteall($myfirstname).", ".db_quoteall($mylastname).", ".db_quoteall($myemail).", 'OK', ".db_quoteall($mytoken).", ".db_quoteall($mylanguage)."";

                            foreach ($aTokenAttr as $thisattrfieldname)
                            {
                                $attridx=substr($thisattrfieldname,10); // the 'attribute_' prefix is 10 chars long
                                if (!empty($myattrArray[$attridx])) {$iq .= ", ".db_quoteall($myattrArray[$attridx]).""; }// dbquote_all encloses str with quotes
                            }
                            $iq .= ")";
                            $ir = $connect->Execute($iq);
                            if (!$ir) $duplicatecount++;
                            $xz++;
                            // or safe_die ("Couldn't insert line<br />\n$buffer<br />\n".htmlspecialchars($connect->ErrorMsg())."<pre style='text-align: left'>$iq</pre>\n");
                        }
                    } // End for each entry
                } // End foreach responseGroup
            } // End of if resnum >= 1

            if ($xz != 0)
            {
                $tokenoutput .= "<span class='successtitle'>".$clang->gT("Success")."</span><br /><br />\n";
            }
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:31,代码来源:tokens.php

示例3: 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";
//.........这里部分代码省略.........
开发者ID:ddrmoscow,项目名称:queXS,代码行数:101,代码来源:save.php

示例4: modlabelsetanswers

function modlabelsetanswers($lid)
{
    global $dbprefix, $connect, $clang, $labelsoutput, $databasetype, $filterxsshtml,$postsortorder;

    $qulabelset = "SELECT * FROM ".db_table_name('labelsets')." WHERE lid='$lid'";
    $rslabelset = db_execute_assoc($qulabelset) or safe_die($connect->ErrorMsg());
    $rwlabelset=$rslabelset->FetchRow();
    $lslanguages=explode(" ", trim($rwlabelset['languages']));

    if (!isset($_POST['method'])) {
        $_POST['method'] = $clang->gT("Save");
    }
    switch($_POST['method'])
    {
        case $clang->gT("Add new label", "unescaped"):
            if (isset($_POST['insertcode']) && $_POST['insertcode']!='')
            {
                $_SESSION['nextlabelcode']=getNextCode($_POST['insertcode']);
                $_POST['insertcode'] = db_quoteall($_POST['insertcode'],true);
                // check that the code doesn't exist yet
                $query = "SELECT code FROM ".db_table_name('labels')." WHERE lid='$lid' AND code=".$_POST['insertcode'];
                $result = $connect->Execute($query);
                $codeoccurences=$result->RecordCount();
                if ($codeoccurences == 0)
                {
                    $query = "select max(sortorder) as maxorder from ".db_table_name('labels')." where lid='$lid'";
                    $result = $connect->Execute($query);
                    $newsortorder=sprintf("%05d", $result->fields['maxorder']+1);
                    if ($filterxsshtml)
                    {
                        require_once("../classes/inputfilter/class.inputfilter_clean.php");
                        $myFilter = new InputFilter('','',1,1,1);
                        $_POST['inserttitle']=$myFilter->process($_POST['inserttitle']);
                    }
                    else
                    {
                        $_POST['inserttitle'] = html_entity_decode($_POST['inserttitle'], ENT_QUOTES, "UTF-8");
                    }

                    // Fix bug with FCKEditor saving strange BR types
                    $_POST['inserttitle']=fix_FCKeditor_text($_POST['inserttitle']);
                     
                    $_POST['inserttitle'] = db_quoteall($_POST['inserttitle'],true);
                    $_POST['insertassessmentvalue']=(int)$_POST['insertassessmentvalue'];
                    foreach ($lslanguages as $lslanguage)
                    {
                        db_switchIDInsert('labels',true);
                        $query = "INSERT INTO ".db_table_name('labels')." (lid, code, title, sortorder,language, assessment_value) VALUES ($lid, {$_POST['insertcode']}, {$_POST['inserttitle']}, '$newsortorder','$lslanguage',{$_POST['insertassessmentvalue']})";
                        if (!$result = $connect->Execute($query))
                        {
                            $labelsoutput.= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Failed to insert label", "js")." - ".$query." - ".$connect->ErrorMsg()."\")\n //-->\n</script>\n";
                        }
                        db_switchIDInsert('labels',false);
                    }
                }
                else
                {
                    $labelsoutput.= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("This label code is already used in this labelset. Please choose another code or rename the existing one.", "js")."\")\n //-->\n</script>\n";
                }
            }
            break;

            // Save all labels with one button
        case $clang->gT("Save Changes", "unescaped"):
            //Determine autoids by evaluating the hidden field
            $sortorderids=explode(' ', trim($_POST['sortorderids']));
            $codeids=explode(' ', trim($_POST['codeids']));
            $count=0;

            // Quote each code_codeid first
            foreach ($codeids as $codeid)
            {
                $_POST['code_'.$codeid] = db_quoteall($_POST['code_'.$codeid],true);
                if (isset($_POST['oldcode_'.$codeid])) $_POST['oldcode_'.$codeid] = db_quoteall($_POST['oldcode_'.$codeid],true);
                // Get the code values to check for duplicates
                $codevalues[] = $_POST['code_'.$codeid];
            }

            // Check that there is no code duplicate
            if (count(array_unique($codevalues)) == count($codevalues))
            {
                if ($filterxsshtml)
                {
                    require_once("../classes/inputfilter/class.inputfilter_clean.php");
                    $myFilter = new InputFilter('','',1,1,1);
                }

                foreach ($sortorderids as $sortorderid)
                {
                    $orderid=substr($sortorderid,strrpos($sortorderid,'_')+1,20);
                    foreach ($lslanguages as $langid)
                        {
                        $sortorderid = $langid . '_' . $orderid;
                        if ($filterxsshtml)
                        {
                            $_POST['title_'.$sortorderid]=$myFilter->process($_POST['title_'.$sortorderid]);
                        }
                        else
                        {
                            $_POST['title_'.$sortorderid] = html_entity_decode($_POST['title_'.$sortorderid], ENT_QUOTES, "UTF-8");
//.........这里部分代码省略.........
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:101,代码来源:labels.php

示例5: fix_FCKeditor_text

             }
             // Fix bug with FCKEditor saving strange BR types
             $_POST['quotals_message_' . $lang] = fix_FCKeditor_text($_POST['quotals_message_' . $lang]);
             include_once dirname(__FILE__) . '/../quexs.php';
             //queXS Addition
             //Now save the language to the database:
             $query = "INSERT INTO " . db_table_name('quota_languagesettings') . " (quotals_quota_id, quotals_language, quotals_name, quotals_message, quotals_url, quotals_urldescrip)\n                    VALUES ('{$quotaid}', '{$lang}', '" . db_quote($_POST['quota_name'], true) . "', '" . db_quote($_POST['quotals_message_' . $lang], true) . "', '" . QUEXS_URL . "rs_quota_end.php" . "', '" . QUEXS_URL . "rs_quota_end.php" . "')";
             $connect->Execute($query) or safe_die($connect->ErrorMsg());
         }
     }
     //End insert language based components
     $viewquota = "1";
 }
 //End foreach $lang
 if ($subaction == "modifyquota" && bHasSurveyPermission($surveyid, 'quotas', 'update')) {
     $query = "UPDATE " . db_table_name('quota') . "\n            SET name=" . db_quoteall($_POST['quota_name'], true) . ",\n            qlimit=" . db_quoteall($_POST['quota_limit'], true) . "\n            WHERE id=" . db_quoteall($_POST['quota_id'], true);
     $connect->Execute($query) or safe_die("Error modifying quota" . $connect->ErrorMsg());
     //Get the languages used in this survey
     $langs = GetAdditionalLanguagesFromSurveyID($surveyid);
     $baselang = GetBaseLanguageFromSurveyID($surveyid);
     array_push($langs, $baselang);
     //Iterate through each language, and make sure there is a quota message for it
     $errorstring = '';
     foreach ($langs as $lang) {
         if (!$_POST['quotals_message_' . $lang]) {
             $errorstring .= GetLanguageNameFromCode($lang, false) . "\\n";
         }
     }
     if ($errorstring != '') {
         $quotasoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"" . $clang->gT("Quota could not be added.\\n\\nIt is missing a quota message for the following languages", "js") . ":\\n" . $errorstring . "\")\n //-->\n</script>\n";
     } else {
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:quota.php

示例6: usedTokens

/**
* Returns true when a token can not be used (either doesn't exist or has less then one usage left
*
* @param mixed $tid Token
*/
function usedTokens($token)
{
    global $dbprefix, $surveyid;
    $utresult = true;
    $query = "SELECT tid, usesleft from {$dbprefix}tokens_{$surveyid} WHERE token=" . db_quoteall($token);
    $result = db_execute_assoc($query, null, true);
    if ($result !== false) {
        $row = $result->FetchRow();
        if ($row['usesleft'] > 0) {
            $utresult = false;
        }
    }
    return $utresult;
}
开发者ID:karime7gezly,项目名称:OpenConextApps-LimeSurvey,代码行数:19,代码来源:common_functions.php

示例7: foreach

 $editsurvey .= "<div id='tabs'><ul>\n            <li><a href='#general'>" . $clang->gT("General") . "</a></li>\n            <li><a href='#presentation'>" . $clang->gT("Presentation & navigation") . "</a></li>\n            <li><a href='#publication'>" . $clang->gT("Publication & access control") . "</a></li>\n            <li><a href='#notification'>" . $clang->gT("Notification & data management") . "</a></li>\n            <li><a href='#tokens'>" . $clang->gT("Tokens") . "</a></li>\n            <li><a href='#import'>" . $clang->gT("Import") . "</a></li>\n            <li><a href='#copy'>" . $clang->gT("Copy") . "</a></li>\n            </ul>\n            \n";
 $editsurvey .= "<form class='form30' name='addnewsurvey' id='addnewsurvey' action='{$scriptname}' method='post' >\n";
 // General & Contact TAB
 $editsurvey .= "<div id='general'>\n";
 // Survey Language
 $editsurvey .= "<ul><li><label for='language' title='" . $clang->gT("This is the base language of your survey and it can't be changed later. You can add more languages after you have created the survey.") . "'><span class='annotationasterisk'>*</span>" . $clang->gT("Base language:") . "</label>\n" . "<select id='language' name='language'>\n";
 foreach (getLanguageData() as $langkey2 => $langname) {
     $editsurvey .= "<option value='" . $langkey2 . "'";
     if ($defaultlang == $langkey2) {
         $editsurvey .= " selected='selected'";
     }
     $editsurvey .= ">" . $langname['description'] . "</option>\n";
 }
 $editsurvey .= "</select>\n";
 //Use the current user details for the default administrator name and email for this survey
 $query = "SELECT full_name, email FROM " . db_table_name('users') . " WHERE users_name = " . db_quoteall($_SESSION['user']);
 $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
 $owner = $result->FetchRow();
 //Degrade gracefully to $siteadmin details if anything is missing.
 if (empty($owner['full_name'])) {
     $owner['full_name'] = $siteadminname;
 }
 if (empty($owner['email'])) {
     $owner['email'] = $siteadminemail;
 }
 //Bounce setting by default to global if it set globally
 if (getGlobalSetting('bounceaccounttype') != 'off') {
     $owner['bounce_email'] = getGlobalSetting('siteadminbounce');
 } else {
     $owner['bounce_email'] = $owner['email'];
 }
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:editsurveysettings.php

示例8: CSVImportGroup


//.........这里部分代码省略.........
                }
                $questionrowdata = array_map('convertCsvreturn2return', $questionrowdata);
                // translate internal links
                $questionrowdata['title'] = translink('survey', $oldsid, $newsid, $questionrowdata['title']);
                $questionrowdata['question'] = translink('survey', $oldsid, $newsid, $questionrowdata['question']);
                $questionrowdata['help'] = translink('survey', $oldsid, $newsid, $questionrowdata['help']);
                $newvalues = array_values($questionrowdata);
                $newvalues = array_map(array(&$connect, "qstr"), $newvalues);
                // quote everything accordingly
                if (isset($questionrowdata['qid'])) {
                    db_switchIDInsert('questions', true);
                }
                $tablename = $dbprefix . 'questions';
                $qinsert = $connect->GetInsertSQL($tablename, $questionrowdata);
                $qres = $connect->Execute($qinsert) or safe_die($clang->gT("Error") . ": Failed to insert question<br />\n{$qinsert}<br />\n" . $connect->ErrorMsg());
                $results['questions']++;
                //GET NEW QID  .... if is not done before and we count a question if a new qid is required
                if (isset($questionrowdata['qid'])) {
                    $saveqid = $questionrowdata['qid'];
                } else {
                    $aQIDReplacements[$oldqid] = $connect->Insert_ID("{$dbprefix}questions", 'qid');
                    $saveqid = $aQIDReplacements[$oldqid];
                }
                $qtypes = getqtypelist("", "array");
                $aSQIDReplacements = array();
                db_switchIDInsert('questions', false);
                // Now we will fix up old label sets where they are used as answers
                if ((isset($oldlid1) || isset($oldlid2)) && ($qtypes[$questionrowdata['type']]['answerscales'] > 0 || $qtypes[$questionrowdata['type']]['subquestions'] > 1)) {
                    $query = "select * from " . db_table_name('labels') . " where lid={$aLIDReplacements[$oldlid1]} and language='{$questionrowdata['language']}'";
                    $oldlabelsresult = db_execute_assoc($query);
                    while ($labelrow = $oldlabelsresult->FetchRow()) {
                        if (in_array($labelrow['language'], $aLanguagesSupported)) {
                            if ($qtypes[$questionrowdata['type']]['subquestions'] < 2) {
                                $qinsert = "insert INTO " . db_table_name('answers') . " (qid,code,answer,sortorder,language,assessment_value)\n                                        VALUES ({$aQIDReplacements[$oldqid]}," . db_quoteall($labelrow['code']) . "," . db_quoteall($labelrow['title']) . "," . db_quoteall($labelrow['sortorder']) . "," . db_quoteall($labelrow['language']) . "," . db_quoteall($labelrow['assessment_value']) . ")";
                                $qres = $connect->Execute($qinsert) or safe_die($clang->gT("Error") . ": Failed to insert answer (lid1) <br />\n{$qinsert}<br />\n" . $connect->ErrorMsg());
                            } else {
                                if (isset($aSQIDReplacements[$labelrow['code'] . '_' . $saveqid])) {
                                    $fieldname = 'qid,';
                                    $data = $aSQIDReplacements[$labelrow['code'] . '_' . $saveqid] . ',';
                                } else {
                                    $fieldname = '';
                                    $data = '';
                                }
                                $qinsert = "insert INTO " . db_table_name('questions') . " ({$fieldname} parent_qid,title,question,question_order,language,scale_id,type, sid, gid)\n                                        VALUES ({$data}{$aQIDReplacements[$oldqid]}," . db_quoteall($labelrow['code']) . "," . db_quoteall($labelrow['title']) . "," . db_quoteall($labelrow['sortorder']) . "," . db_quoteall($labelrow['language']) . ",1,'{$questionrowdata['type']}',{$questionrowdata['sid']},{$questionrowdata['gid']})";
                                $qres = $connect->Execute($qinsert) or safe_die($clang->gT("Error") . ": Failed to insert question <br />\n{$qinsert}<br />\n" . $connect->ErrorMsg());
                                if ($fieldname == '') {
                                    $aSQIDReplacements[$labelrow['code'] . '_' . $saveqid] = $connect->Insert_ID("{$dbprefix}questions", "qid");
                                }
                            }
                        }
                    }
                    if (isset($oldlid2) && $qtypes[$questionrowdata['type']]['answerscales'] > 1) {
                        $query = "select * from " . db_table_name('labels') . " where lid={$aLIDReplacements[$oldlid2]} and language='{$questionrowdata['language']}'";
                        $oldlabelsresult = db_execute_assoc($query);
                        while ($labelrow = $oldlabelsresult->FetchRow()) {
                            $qinsert = "insert INTO " . db_table_name('answers') . " (qid,code,answer,sortorder,language,assessment_value,scale_id)\n                                    VALUES ({$aQIDReplacements[$oldqid]}," . db_quoteall($labelrow['code']) . "," . db_quoteall($labelrow['title']) . "," . db_quoteall($labelrow['sortorder']) . "," . db_quoteall($labelrow['language']) . "," . db_quoteall($labelrow['assessment_value']) . ",1)";
                            $qres = $connect->Execute($qinsert) or safe_die($clang->gT("Error") . ": Failed to insert answer (lid2)<br />\n{$qinsert}<br />\n" . $connect->ErrorMsg());
                        }
                    }
                }
            }
        }
        //Do answers
        $results['subquestions'] = 0;
        if (isset($answerarray) && $answerarray) {
            foreach ($answerarray as $aa) {
开发者ID:ddrmoscow,项目名称:queXS,代码行数:67,代码来源:importgroup.php

示例9: VALUES

		        	      VALUES ('$quotaid', '$lang', '".db_quote($_POST['quota_name'],true)."', '".db_quote($_POST['quotals_message_'.$lang],true)."', '".db_quote($_POST['quotals_url_'.$lang],true)."', '".db_quote($_POST['quotals_urldescrip_'.$lang],true)."')";
                $connect->Execute($query) or safe_die($connect->ErrorMsg());
            }
        } //End insert language based components
        $viewquota = "1";

    } //End foreach $lang

    if($subaction == "modifyquota" && bHasSurveyPermission($surveyid, 'quotas','update'))
    {
        $query = "UPDATE ".db_table_name('quota')."
			      SET name=".db_quoteall($_POST['quota_name'],true).",
				  qlimit=".db_quoteall($_POST['quota_limit'],true).",
				  action=".db_quoteall($_POST['quota_action'],true).",
				  autoload_url=".db_quoteall($_POST['autoload_url'],true)."
				  WHERE id=".db_quoteall($_POST['quota_id'],true);
        $connect->Execute($query) or safe_die("Error modifying quota".$connect->ErrorMsg());

        //Get the languages used in this survey
        $langs = GetAdditionalLanguagesFromSurveyID($surveyid);
        $baselang = GetBaseLanguageFromSurveyID($surveyid);
        array_push($langs, $baselang);
        //Iterate through each language, and make sure there is a quota message for it
        $errorstring = '';
        foreach ($langs as $lang)
        {
            if (!$_POST['quotals_message_'.$lang]) { $errorstring.= GetLanguageNameFromCode($lang,false)."\\n";}
        }
        if ($errorstring!='')
        {
            $quotasoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Quota could not be added.\\n\\nIt is missing a quota message for the following languages","js").":\\n".$errorstring."\")\n //-->\n</script>\n";
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:31,代码来源:quota.php

示例10: GetAdditionalLanguagesFromSurveyID

$js_admin_includes[] = '../scripts/jquery/jquery.selectboxes.min.js';
$_SESSION['FileManagerContext'] = "edit:answer:{$surveyid}";
// Get languages select on survey.
$anslangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$qquery = "SELECT type FROM " . db_table_name('questions') . " WHERE qid={$qid} AND language='" . $baselang . "'";
$qrow = $connect->GetRow($qquery);
$qtype = $qrow['type'];
$scalecount = $qtypes[$qtype]['answerscales'];
//Check if there is at least one answer
for ($i = 0; $i < $scalecount; $i++) {
    $qquery = "SELECT count(*) as num_ans  FROM " . db_table_name('answers') . " WHERE qid={$qid} AND scale_id={$i} AND language='" . $baselang . "'";
    $qresult = $connect->GetOne($qquery);
    //Checked
    if ($qresult == 0) {
        $query = "INSERT into " . db_table_name('answers') . " (qid,code,answer,language,sortorder,scale_id) VALUES ({$qid},'A1'," . db_quoteall($clang->gT("Some example answer option")) . ",'{$baselang}',0,{$i})";
        $connect->execute($query);
    }
}
// check that there are answers for every language supported by the survey
for ($i = 0; $i < $scalecount; $i++) {
    foreach ($anslangs as $language) {
        $iAnswerCount = $connect->GetOne("SELECT count(*) as num_ans  FROM " . db_table_name('answers') . " WHERE qid={$qid} AND scale_id={$i} AND language='" . $language . "'");
        if ($iAnswerCount == 0) {
            $qquery = "INSERT INTO " . db_table_name('answers') . " (qid,code,answer,sortorder,language,scale_id, assessment_value) (SELECT qid,code,answer,sortorder, '" . $language . "','{$i}', assessment_value FROM " . db_table_name('answers') . " WHERE qid={$qid} AND scale_id={$i} AND language='" . $baselang . "')";
            $connect->Execute($qquery);
            //Checked
        }
    }
}
array_unshift($anslangs, $baselang);
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:editansweroptions.php

示例11: CSVImportQuestion


//.........这里部分代码省略.........
            if ($questionrowdata['type'] == 'W') {
                $questionrowdata['type'] = '!';
            } elseif ($questionrowdata['type'] == 'Z') {
                $questionrowdata['type'] = 'L';
            }
            $oldquestion['newtype'] = $questionrowdata['type'];
            $questionrowdata = array_map('convertCsvreturn2return', $questionrowdata);
            // translate internal links
            $questionrowdata['title'] = translink('survey', $oldsid, $newsid, $questionrowdata['title']);
            $questionrowdata['question'] = translink('survey', $oldsid, $newsid, $questionrowdata['question']);
            $questionrowdata['help'] = translink('survey', $oldsid, $newsid, $questionrowdata['help']);
            $newvalues = array_values($questionrowdata);
            $newvalues = array_map(array(&$connect, "qstr"), $newvalues);
            // quote everything accordingly
            $qinsert = "INSERT INTO {$dbprefix}questions (" . implode(',', array_keys($questionrowdata)) . ") VALUES (" . implode(',', $newvalues) . ")";
            $qres = $connect->Execute($qinsert) or safe_die("Error: Failed to insert question<br />\n{$qinsert}<br />\n" . $connect->ErrorMsg());
            // set the newqid only if is not set
            if (!isset($newqid)) {
                $newqid = $connect->Insert_ID("{$dbprefix}questions", "qid");
            } else {
                db_switchIDInsert('questions', false);
            }
        }
        $qtypes = getqtypelist("", "array");
        $results['answers'] = 0;
        $results['subquestions'] = 0;
        // Now we will fix up old label sets where they are used as answers
        if ((isset($oldquestion['lid1']) || isset($oldquestion['lid2'])) && ($qtypes[$oldquestion['newtype']]['answerscales'] > 0 || $qtypes[$oldquestion['newtype']]['subquestions'] > 1)) {
            $query = "select * from " . db_table_name('labels') . " where lid={$aLIDReplacements[$oldquestion['lid1']]} ";
            $oldlabelsresult = db_execute_assoc($query);
            while ($labelrow = $oldlabelsresult->FetchRow()) {
                if (in_array($labelrow['language'], $aLanguagesSupported)) {
                    if ($qtypes[$oldquestion['newtype']]['subquestions'] < 2) {
                        $qinsert = "insert INTO " . db_table_name('answers') . " (qid,code,answer,sortorder,language,assessment_value,scale_id)\n                                    VALUES ({$newqid}," . db_quoteall($labelrow['code']) . "," . db_quoteall($labelrow['title']) . "," . db_quoteall($labelrow['sortorder']) . "," . db_quoteall($labelrow['language']) . "," . db_quoteall($labelrow['assessment_value']) . ",0)";
                        $qres = $connect->Execute($qinsert) or safe_die("Error: Failed to insert answer <br />\n{$qinsert}<br />\n" . $connect->ErrorMsg());
                        $results['answers']++;
                    } else {
                        if (isset($aSQIDReplacements[$labelrow['code']])) {
                            $fieldname = 'qid,';
                            $data = $aSQIDReplacements[$labelrow['code']] . ',';
                            db_switchIDInsert('questions', true);
                        } else {
                            $fieldname = '';
                            $data = '';
                        }
                        $qinsert = "insert INTO " . db_table_name('questions') . " ({$fieldname} sid,gid,parent_qid,title,question,question_order,language,scale_id,type)\n                                    VALUES ({$data} {$newsid},{$newgid},{$newqid}," . db_quoteall($labelrow['code']) . "," . db_quoteall($labelrow['title']) . "," . db_quoteall($labelrow['sortorder']) . "," . db_quoteall($labelrow['language']) . ",1," . db_quoteall($oldquestion['newtype']) . ")";
                        $qres = $connect->Execute($qinsert) or safe_die("Error: Failed to insert subquestion <br />\n{$qinsert}<br />\n" . $connect->ErrorMsg());
                        if ($fieldname == '') {
                            $aSQIDReplacements[$labelrow['code']] = $connect->Insert_ID("{$dbprefix}questions", "qid");
                        } else {
                            db_switchIDInsert('questions', false);
                        }
                    }
                }
            }
            if (isset($oldquestion['lid2']) && $qtypes[$oldquestion['newtype']]['answerscales'] > 1) {
                $query = "select * from " . db_table_name('labels') . " where lid={$aLIDReplacements[$oldquestion['lid2']]}";
                $oldlabelsresult = db_execute_assoc($query);
                while ($labelrow = $oldlabelsresult->FetchRow()) {
                    if (in_array($labelrow['language'], $aLanguagesSupported)) {
                        $qinsert = "insert INTO " . db_table_name('answers') . " (qid,code,answer,sortorder,language,assessment_value,scale_id)\n                                    VALUES ({$newqid}," . db_quoteall($labelrow['code']) . "," . db_quoteall($labelrow['title']) . "," . db_quoteall($labelrow['sortorder']) . "," . db_quoteall($labelrow['language']) . "," . db_quoteall($labelrow['assessment_value']) . ",1)";
                        $qres = $connect->Execute($qinsert) or safe_die($clang->gT("Error") . ": Failed to insert answer <br />\n{$qinsert}<br />\n" . $connect->ErrorMsg());
                    }
                }
            }
        }
开发者ID:ddrmoscow,项目名称:queXS,代码行数:67,代码来源:importquestion.php

示例12: elseif

         } elseif ($meetminirequirements === true) {
             // No issue, let's import
             $iq = "INSERT INTO " . db_table_name("tokens_{$surveyid}") . " \n" . "(firstname, lastname, email, emailstatus, token, language";
             foreach ($aTokenAttr as $thisattrfieldname) {
                 $attridx = substr($thisattrfieldname, 10);
                 // the 'attribute_' prefix is 10 chars long
                 if (!empty($myattrArray[$attridx])) {
                     $iq .= ", {$thisattrfieldname}";
                 }
             }
             $iq .= ") \n" . "VALUES (" . db_quoteall($myfirstname) . ", " . db_quoteall($mylastname) . ", " . db_quoteall($myemail) . ", 'OK', " . db_quoteall($mytoken) . ", " . db_quoteall($mylanguage) . "";
             foreach ($aTokenAttr as $thisattrfieldname) {
                 $attridx = substr($thisattrfieldname, 10);
                 // the 'attribute_' prefix is 10 chars long
                 if (!empty($myattrArray[$attridx])) {
                     $iq .= ", " . db_quoteall($myattrArray[$attridx]) . "";
                 }
                 // dbquote_all encloses str with quotes
             }
             $iq .= ")";
             $ir = $connect->Execute($iq);
             if (!$ir) {
                 $duplicatecount++;
             }
             $xz++;
             // or safe_die ("Couldn't insert line<br />\n$buffer<br />\n".htmlspecialchars($connect->ErrorMsg())."<pre style='text-align: left'>$iq</pre>\n");
         }
     }
     // End for each entry
 }
 // End foreach responseGroup
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:tokens.php

示例13: sRandomChars

//Check that the email is a valid style address
if (!validate_email(returnglobal('register_email')))
{
    $register_errormsg .= $clang->gT("The email you used is not valid. Please try again.");
}

if ($register_errormsg != "")
{
    include "index.php";
    exit;
}

//Check if this email already exists in token database
$query = "SELECT email FROM {$dbprefix}tokens_$surveyid\n"
. "WHERE email = ".db_quoteall(sanitize_email(returnglobal('register_email')));
$result = $connect->Execute($query) or safe_die ($query."<br />".$connect->ErrorMsg());   //Checked
if (($result->RecordCount()) > 0)
{
    $register_errormsg=$clang->gT("The email you used has already been registered.");
    include "index.php";
    exit;
}

$mayinsert = false;
while ($mayinsert != true)
{
    $newtoken = sRandomChars(15);
    $ntquery = "SELECT * FROM {$dbprefix}tokens_$surveyid WHERE token='$newtoken'";
    $ntresult = $connect->Execute($ntquery); //Checked
    if (!$ntresult->RecordCount()) {$mayinsert = true;}
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:30,代码来源:register.php

示例14: db_table_name

    if (count($subquestiondata) == 0) {
        $sQuery = "INSERT INTO " . db_table_name('questions') . " (sid,gid,parent_qid,title,question,question_order,language,scale_id)\n                       VALUES({$surveyid},{$gid},{$qid},'SQ001'," . db_quoteall($clang->gT('Some example subquestion')) . ",1," . db_quoteall($baselang) . ",{$iScale})";
        $connect->Execute($sQuery);
        //Checked
        $sQuery = "SELECT * FROM " . db_table_name('questions') . " WHERE parent_qid={$qid} AND language='{$baselang}' and scale_id={$iScale}";
        $subquestiondata = $connect->GetArray($sQuery);
    }
    // check that there are subquestions for every language supported by the survey
    foreach ($anslangs as $language) {
        foreach ($subquestiondata as $row) {
            $sQuery = "SELECT count(*) FROM " . db_table_name('questions') . " WHERE parent_qid={$qid} AND language='{$language}' AND qid={$row['qid']} and scale_id={$iScale}";
            $qrow = $connect->GetOne($sQuery);
            //Checked
            if ($qrow == 0) {
                db_switchIDInsert('questions', true);
                $sQuery = "INSERT INTO " . db_table_name('questions') . " (qid,sid,gid,parent_qid,title,question,question_order,language, scale_id)\n                               VALUES({$row['qid']},{$surveyid},{$row['gid']},{$qid}," . db_quoteall($row['title']) . "," . db_quoteall($row['question']) . ",{$row['question_order']}," . db_quoteall($language) . ",{$iScale})";
                $connect->Execute($sQuery);
                //Checked
                db_switchIDInsert('questions', false);
            }
        }
    }
}
array_unshift($anslangs, $baselang);
// makes an array with ALL the languages supported by the survey -> $anslangs
$vasummary = "\n<script type='text/javascript'>\n                      var languagecount=" . count($anslangs) . ";\n\n                      var newansweroption_text='" . $clang->gT('New answer option', 'js') . "';\n                      var strcode='" . $clang->gT('Code', 'js') . "';\n                      var strlabel='" . $clang->gT('Label', 'js') . "';\n                      var strCantDeleteLastAnswer='" . $clang->gT('You cannot delete the last subquestion.', 'js') . "';\n                      var lsbrowsertitle='" . $clang->gT('Label set browser', 'js') . "';\n                      var quickaddtitle='" . $clang->gT('Quick-add subquestions', 'js') . "';\n                      var duplicateanswercode='" . $clang->gT('Error: You are trying to use duplicate subquestion codes.', 'js') . "';\n                      var strNoLabelSet='" . $clang->gT('There are no label sets which match the survey default language', 'js') . "';\n                      var langs='" . implode(';', $anslangs) . "';</script>\n";
//delete the subquestions in languages not supported by the survey
$qquery = "SELECT DISTINCT language FROM " . db_table_name('questions') . " WHERE (parent_qid = {$qid}) AND (language NOT IN ('" . implode("','", $anslangs) . "'))";
$qresult = db_execute_assoc($qquery);
//Checked
while ($qrow = $qresult->FetchRow()) {
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:editsubquestions.php

示例15: Updatedefaultvalues

/**
* This is a convenience function to update/delete answer default values. If the given
* $defaultvalue is empty then the entry is removed from table defaultvalues
*
* @param mixed $qid   Question ID
* @param mixed $scale_id  Scale ID
* @param mixed $specialtype  Special type (i.e. for  'Other')
* @param mixed $language     Language (defaults are language specific)
* @param mixed $defaultvalue    The default value itself
* @param boolean $ispost   If defaultvalue is from a $_POST set this to true to properly quote things
*/
function Updatedefaultvalues($qid, $sqid, $scale_id, $specialtype, $language, $defaultvalue, $ispost)
{
    global $connect;
    if ($defaultvalue == '') {
        $connect->execute("DELETE FROM " . db_table_name('defaultvalues') . " WHERE sqid={$sqid} AND qid={$qid} AND specialtype='{$specialtype}' AND scale_id={$scale_id} AND language='{$language}'");
    } else {
        $exists = $connect->GetOne("SELECT qid FROM " . db_table_name('defaultvalues') . " WHERE sqid={$sqid} AND qid={$qid} AND specialtype={$specialtype}'' AND scale_id={$scale_id} AND language='{$language}'");
        if ($exists === false || $exists === null) {
            $connect->execute('INSERT INTO ' . db_table_name('defaultvalues') . " (defaultvalue,qid,scale_id,language,specialtype,sqid) VALUES (" . db_quoteall($defaultvalue, $ispost) . ",{$qid},{$scale_id},'{$language}','{$specialtype}',{$sqid})");
        } else {
            $connect->execute('UPDATE ' . db_table_name('defaultvalues') . " set defaultvalue=" . db_quoteall($defaultvalue, $ispost) . "  WHERE sqid={$sqid} AND qid={$qid} AND specialtype='{$specialtype}' AND scale_id={$scale_id} AND language='{$language}'");
        }
    }
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:25,代码来源:database.php


注:本文中的db_quoteall函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。