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


PHP safe_die函数代码示例

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


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

示例1: do_upload

function do_upload($tid)
{
    global $nick;
    if ($_FILES['attachment-file']['size'] < 1) {
        return "File size is too small!";
    }
    $file_name = $_FILES['attachment-file']['name'];
    $file_ext = strtolower(substr($file_name, -4));
    if ($file_ext != ".jpg" && $file_ext != ".png" && $file_ext != ".pdf" && $file_ext != ".log" && $file_ext != ".txt") {
        return "You can only upload jpg/png/pdf/log/txt files!";
    }
    $file_type = $_FILES['attachment-file']['type'];
    $file_size = $_FILES['attachment-file']['size'];
    $file_desc = "Attachment by " . $nick;
    if (!is_numeric($file_size)) {
        safe_die("Error! Invalid number in file size!");
    }
    $query = squery("INSERT INTO karnaf_files(tid,file_name,file_type,file_desc,file_size,lastupd_time) VALUES(%d,'%s','%s','%s',%d,%d)", $tid, $file_name, $file_type, $file_desc, $file_size, time());
    if (!$query) {
        return "SQL Error! Query failed on do_upload() function: " . mysql_error();
    }
    $id = sql_insert_id();
    $fn = KARNAF_UPLOAD_PATH . "/" . $tid;
    if (!file_exists($fn)) {
        if (!mkdir($fn)) {
            return "Can't create attachment directory!";
        }
    }
    $fn .= "/" . $id . $file_ext;
    if (!copy($_FILES['attachment-file']['tmp_name'], $fn)) {
        return "Couldn't create attachment file!";
    }
    return "";
}
开发者ID:nirn,项目名称:karnaf,代码行数:34,代码来源:view.php

示例2: getUserNameFromUid

 function getUserNameFromUid($uid)
 {
     $query = "SELECT users_name, uid FROM " . db_table_name('users') . " WHERE uid = {$uid};";
     $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
     if ($result->RecordCount() > 0) {
         while ($rows = $result->FetchRow()) {
             return $rows['users_name'];
         }
     }
 }
开发者ID:karime7gezly,项目名称:OpenConextApps-LimeSurvey,代码行数:10,代码来源:usercontrol.php

示例3: safe_die

         if (empty($gid)) {
             safe_die("No GID provided.");
         }
         if (empty($qid)) {
             safe_die("No QID provided.");
         }
         if ($field['gid'] == $gid && $field['qid'] == $qid) {
             $AddQuestion = False;
         }
         break;
     case 'emailtemplates':
         // this is the case for email-conf
         $AddQuestion = True;
         break;
     default:
         safe_die("No Action provided.");
         break;
 }
 if ($AddQuestion === True) {
     if ($action == 'tokens' && $fieldtype == 'email-conf') {
         //For confirmation email all fields are valid
         $previouspagequestion = true;
     } elseif ($surveyformat == "S") {
         $previouspagequestion = true;
     } elseif ($surveyformat == "G") {
         if ($previouspagequestion === true) {
             // Last question was on a previous page
             if ($field["gid"] == $gid) {
                 // This question is on same page
                 $previouspagequestion = false;
             }
开发者ID:himanshu12k,项目名称:ce-www,代码行数:31,代码来源:fck_LimeReplacementFields.php

示例4: generate_statistics


//.........这里部分代码省略.........

        }
    }

    if($q2show=='all' )
    {
        $summarySql=" SELECT gid, parent_qid, qid, type "
        ." FROM {$dbprefix}questions WHERE parent_qid=0"
        ." AND sid=$surveyid ";

        $summaryRs = db_execute_assoc($summarySql);

        foreach($summaryRs as $field)
        {
            $myField = $surveyid."X".$field['gid']."X".$field['qid'];

            // Multiple choice get special treatment
            if ($field['type'] == "M") {$myField = "M$myField";}
            if ($field['type'] == "P") {$myField = "P$myField";}
            //numerical input will get special treatment (arihtmetic mean, standard derivation, ...)
            if ($field['type'] == "N") {$myField = "N$myField";}

            if ($field['type'] == "|") {$myField = "|$myField";}

            if ($field['type'] == "Q") {$myField = "Q$myField";}
            // textfields get special treatment
            if ($field['type'] == "S" || $field['type'] == "T" || $field['type'] == "U"){$myField = "T$myField";}
            //statistics for Date questions are not implemented yet.
            if ($field['type'] == "D") {$myField = "D$myField";}
            if ($field['type'] == "F" || $field['type'] == "H")
            {
                //Get answers. We always use the answer code because the label might be too long elsewise
                $query = "SELECT code, answer FROM ".db_table_name("answers")." WHERE qid='".$field['qid']."' AND scale_id=0 AND language='{$language}' ORDER BY sortorder, answer";
                $result = db_execute_num($query) or safe_die ("Couldn't get answers!<br />$query<br />".$connect->ErrorMsg());
                $counter2=0;

                //check all the answers
                while ($row=$result->FetchRow())
                {
                    $myField = "$myField{$row[0]}";
                }
                //$myField = "{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}[]";


            }
            if($q2show=='all')
            $summary[]=$myField;

            //$allfields[]=$myField;
        }
    }
    else
    {
        // This gets all the 'to be shown questions' from the POST and puts these into an array
        if (!is_array($q2show))
        $summary=returnglobal('summary');
        else
            $summary = $q2show;

        //print_r($_POST);
        //if $summary isn't an array we create one
        if (isset($summary) && !is_array($summary))
        {
            $summary = explode("+", $summary);
        }
    }
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:67,代码来源:statistics_function.php

示例5: surveyCheckStructure

/**
 * Check the structure of the survey to identify any problems with groups, questions, etc
 * Returns an array containing error information
 * @param surveyid
 * @return string
 */
function surveyCheckStructure($surveyid)
{
    global $dbprefix, $connect;
    $baselang = GetBaseLanguageFromSurveyID($surveyid);
    $failedcheck = array();
    // Check for empty groups
    $groupquery = "SELECT g.gid,g.group_name,count(q.qid) as count from {$dbprefix}questions as q RIGHT JOIN {$dbprefix}groups as g ON q.gid=g.gid WHERE g.sid={$surveyid} AND g.language='{$baselang}' AND q.language='{$baselang}' group by g.gid,g.group_name;";
    $groupresult = db_execute_assoc($groupquery) or safe_die($groupquery . "<br />" . $connect->ErrorMsg());
    while ($row = $groupresult->FetchRow()) {
        if ($row['count'] == 0) {
            $failedcheck[] = array($row['gid'], $row['group_name'], ": " . $clang->gT("This group does not contain any question(s)."));
        }
    }
    //CHECK TO MAKE SURE ALL QUESTION TYPES THAT REQUIRE ANSWERS HAVE ACTUALLY GOT ANSWERS
    //THESE QUESTION TYPES ARE:
    //	# "L" -> LIST
    //  # "O" -> LIST WITH COMMENT
    //  # "M" -> Multiple choice
    //	# "P" -> Multiple choice with comments
    //	# "A", "B", "C", "E", "F", "H", "^" -> Various Array Types
    //  # "R" -> RANKING
    //  # "U" -> FILE CSV MORE
    //  # "I" -> LANGUAGE SWITCH
    //  # ":" -> Array Multi Flexi Numbers
    //  # ";" -> Array Multi Flexi Text
    //  # "1" -> MULTI SCALE
    $chkquery = "SELECT qid, question, gid, type FROM {$dbprefix}questions WHERE sid={$surveyid} and parent_qid=0";
    $chkresult = db_execute_assoc($chkquery) or safe_die("Couldn't get list of questions<br />{$chkquery}<br />" . $connect->ErrorMsg());
    while ($chkrow = $chkresult->FetchRow()) {
        if ($qtypes[$chkrow['type']]['subquestions'] > 0) {
            $chaquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid = {$chkrow['qid']} ORDER BY question_order";
            $charesult = $connect->Execute($chaquery);
            $chacount = $charesult->RecordCount();
            if ($chacount == 0) {
                $failedcheck[] = array($chkrow['qid'], $chkrow['question'], ": " . $clang->gT("This question is a subquestion type question but has no configured subquestions."), $chkrow['gid']);
            }
        }
        if ($qtypes[$chkrow['type']]['answerscales'] > 0) {
            $chaquery = "SELECT * FROM {$dbprefix}answers WHERE qid = {$chkrow['qid']} ORDER BY sortorder, answer";
            $charesult = $connect->Execute($chaquery);
            $chacount = $charesult->RecordCount();
            if ($chacount == 0) {
                $failedcheck[] = array($chkrow['qid'], $chkrow['question'], ": " . $clang->gT("This question is a multiple answer type question but has no answers."), $chkrow['gid']);
            }
        }
    }
    //NOW CHECK THAT ALL QUESTIONS HAVE A 'QUESTION TYPE' FIELD SET
    $chkquery = "SELECT qid, question, gid FROM {$dbprefix}questions WHERE sid={$_GET['sid']} AND type = ''";
    $chkresult = db_execute_assoc($chkquery) or safe_die("Couldn't check questions for missing types<br />{$chkquery}<br />" . $connect->ErrorMsg());
    while ($chkrow = $chkresult->FetchRow()) {
        $failedcheck[] = array($chkrow['qid'], $chkrow['question'], ": " . $clang->gT("This question does not have a question 'type' set."), $chkrow['gid']);
    }
    //ChECK THAT certain array question types have answers set
    $chkquery = "SELECT q.qid, question, gid FROM {$dbprefix}questions as q WHERE (select count(*) from {$dbprefix}answers as a where a.qid=q.qid and scale_id=0)=0 and sid={$_GET['sid']} AND type IN ('F', 'H', 'W', 'Z', '1')";
    $chkresult = db_execute_assoc($chkquery) or safe_die("Couldn't check questions for missing answers<br />{$chkquery}<br />" . $connect->ErrorMsg());
    while ($chkrow = $chkresult->FetchRow()) {
        $failedcheck[] = array($chkrow['qid'], $chkrow['question'], ": " . $clang->gT("This question requires answers, but none are set."), $chkrow['gid']);
    }
    // while
    //CHECK THAT DUAL Array has answers set
    $chkquery = "SELECT q.qid, question, gid FROM {$dbprefix}questions as q WHERE (select count(*) from {$dbprefix}answers as a where a.qid=q.qid and scale_id=1)=0 and sid={$_GET['sid']} AND type='1'";
    $chkresult = db_execute_assoc($chkquery) or safe_die("Couldn't check questions for missing 2nd answer set<br />{$chkquery}<br />" . $connect->ErrorMsg());
    while ($chkrow = $chkresult->FetchRow()) {
        $failedcheck[] = array($chkrow['qid'], $chkrow['question'], ": " . $clang->gT("This question requires a second answer set but none is set."), $chkrow['gid']);
    }
    // while
    //CHECK THAT ALL CONDITIONS SET ARE FOR QUESTIONS THAT PRECEED THE QUESTION CONDITION
    //A: Make an array of all the qids in order of appearance
    //	$qorderquery="SELECT * FROM {$dbprefix}questions, {$dbprefix}groups WHERE {$dbprefix}questions.gid={$dbprefix}groups.gid AND {$dbprefix}questions.sid={$_GET['sid']} ORDER BY {$dbprefix}groups.sortorder, {$dbprefix}questions.title";
    //	$qorderresult=$connect->Execute($qorderquery) or safe_die("Couldn't generate a list of questions in order<br />$qorderquery<br />".$connect->ErrorMsg());
    //	$qordercount=$qorderresult->RecordCount();
    //	$c=0;
    //	while ($qorderrow=$qorderresult->FetchRow())
    //		{
    //		$qidorder[]=array($c, $qorderrow['qid']);
    //		$c++;
    //		}
    //TO AVOID NATURAL SORT ORDER ISSUES, FIRST GET ALL QUESTIONS IN NATURAL SORT ORDER, AND FIND OUT WHICH NUMBER IN THAT ORDER THIS QUESTION IS
    $qorderquery = "SELECT * FROM {$dbprefix}questions WHERE sid={$surveyid} AND type not in ('S', 'D', 'T', 'Q')";
    $qorderresult = db_execute_assoc($qorderquery) or safe_die("{$qorderquery}<br />" . $connect->ErrorMsg());
    $qrows = array();
    //Create an empty array in case FetchRow does not return any rows
    while ($qrow = $qorderresult->FetchRow()) {
        $qrows[] = $qrow;
    }
    usort($qrows, 'GroupOrderThenQuestionOrder');
    // Perform a case insensitive natural sort on group name then question title of a multidimensional array
    $c = 0;
    foreach ($qrows as $qr) {
        $qidorder[] = array($c, $qrow['qid']);
        $c++;
    }
    $qordercount = "";
    //1: Get each condition's question id
//.........这里部分代码省略.........
开发者ID:himanshu12k,项目名称:ce-www,代码行数:101,代码来源:surveytable_functions.php

示例6: unset

                {
                    unset($writearray[$column]);
                }
                $dupfound=false;
                $invalidemail=false;

                if ($filterduplicatetoken!=false)
                {
                    $dupquery = "SELECT tid from ".db_table_name("tokens_$surveyid")." where 1=1";
                    foreach($filterduplicatefields as $field)
                    {
                        if (isset($writearray[$field])) {
                            $dupquery.=' and '.db_quote_id($field).' = '.db_quoteall($writearray[$field]);
                        }
                    }
                    $dupresult = $connect->Execute($dupquery) or safe_die ("Invalid field in duplicate check<br />$dupquery<br /><br />".$connect->ErrorMsg());
                    if ( $dupresult->RecordCount() > 0)
                    {
                        $dupfound = true;
                        $duplicatelist[]=$writearray['firstname']." ".$writearray['lastname']." (".$writearray['email'].")";
                    }
                }


                $writearray['email'] = trim($writearray['email']);

                //treat blank emails
                if ($filterblankemail && $writearray['email']=='')
                {
                    $invalidemail=true;
                    $invalidemaillist[]=$line[0]." ".$line[1]." ( )";
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:31,代码来源:tokens.php

示例7: die

 * See COPYRIGHT.php for copyright notices and details.
 *
 * $Id: dumpgroup.php 10925 2011-09-02 14:12:02Z c_schmitz $
 */
// DUMP THE RELATED DATA FOR A SINGLE QUESTION INTO A SQL FILE FOR IMPORTING LATER ON OR
// ON ANOTHER SURVEY SETUP DUMP ALL DATA WITH RELATED QID FROM THE FOLLOWING TABLES
// 1. questions
// 2. answers
//Ensure script is not run directly, avoid path disclosure
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {
    die("Cannot run this script directly");
}
include_once "login_check.php";
require_once "export_data_functions.php";
if (!bHasSurveyPermission($surveyid, 'surveycontent', 'export')) {
    safe_die("You are not allowed to export question groups.");
}
$gid = returnglobal('gid');
$surveyid = returnglobal('sid');
if (!$gid) {
    echo $htmlheader;
    echo "<br />\n";
    echo "<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n";
    echo "\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>" . $clang->gT("Export Question") . "</strong></td></tr>\n";
    echo "\t<tr bgcolor='#CCCCCC'><td align='center'>{$setfont}\n";
    echo "{$setfont}<br /><strong><font color='red'>" . $clang->gT("Error") . "</font></strong><br />\n" . _EQ_NOGID . "<br />\n";
    echo "<br /><input type='submit' value='" . $clang->gT("Main Admin Screen") . "' onclick=\"window.open('{$scriptname}', '_top')\">\n";
    echo "\t</td></tr>\n";
    echo "</table>\n";
    echo "</body></html>\n";
    exit;
开发者ID:himanshu12k,项目名称:ce-www,代码行数:31,代码来源:dumpgroup.php

示例8: array

    $aSRIDConversions = array();
    while ($row = $resultOldValues->FetchRow()) {
        $iOldID = $row['id'];
        unset($row['id']);
        $sInsertSQL = "INSERT into {$activetable} (" . implode(",", array_map("db_quote_id", array_keys($row))) . ") VALUES (" . implode(",", array_map("db_quoteall", array_values($row))) . ")";
        $result = $connect->Execute($sInsertSQL) or safe_die("Error:<br />{$sInsertSQL}<br />" . $connect->ErrorMsg());
        $aSRIDConversions[$iOldID] = $connect->Insert_Id($activetable, "id");
    }
    $_SESSION['flashmessage'] = sprintf($clang->gT("%s old response(s) were successfully imported."), $iRecordCount);
    $sOldTimingsTable = substr($oldtable, 0, strrpos($oldtable, '_')) . '_timings' . substr($oldtable, strrpos($oldtable, '_'));
    $sNewTimingsTable = db_table_name_nq("survey_{$surveyid}_timings");
    if (tableExists(sStripDBPrefix($sOldTimingsTable)) && tableExists(sStripDBPrefix($sNewTimingsTable)) && returnglobal('importtimings') == 'Y') {
        // Import timings
        $aFieldsOldTimingTable = array_values($connect->MetaColumnNames($sOldTimingsTable, true));
        $aFieldsNewTimingTable = array_values($connect->MetaColumnNames($sNewTimingsTable, true));
        $aValidTimingFields = array_intersect($aFieldsOldTimingTable, $aFieldsNewTimingTable);
        $queryOldValues = "SELECT " . implode(", ", $aValidTimingFields) . " FROM {$sOldTimingsTable} ";
        $resultOldValues = db_execute_assoc($queryOldValues) or safe_die("Error:<br />{$queryOldValues}<br />" . $connect->ErrorMsg());
        $iRecordCountT = $resultOldValues->RecordCount();
        $aSRIDConversions = array();
        while ($row = $resultOldValues->FetchRow()) {
            if (isset($aSRIDConversions[$row['id']])) {
                $row['id'] = $aSRIDConversions[$row['id']];
            }
            $sInsertSQL = "INSERT into {$sNewTimingsTable} (" . implode(",", array_map("db_quote_id", array_keys($row))) . ") VALUES (" . implode(",", array_map("db_quoteall", array_values($row))) . ")";
            $result = $connect->Execute($sInsertSQL) or safe_die("Error:<br />{$sInsertSQL}<br />" . $connect->ErrorMsg());
        }
        $_SESSION['flashmessage'] = sprintf($clang->gT("%s old response(s) and according timings were successfully imported."), $iRecordCount, $iRecordCountT);
    }
    $importoldresponsesoutput = browsemenubar($clang->gT("Quick statistics"));
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:importoldresponses.php

示例9: db_table_name

////////////////////////////////////////////////////////////////////////////////
if (isset($surveyid) && $surveyid && $gid && $qid) {
    // TODO: check that surveyid is set and that so is $baselang
    //Show Question Details
    //Count answer-options for this question
    $qrq = "SELECT * FROM " . db_table_name('answers') . " WHERE qid={$qid} AND language='" . $baselang . "' ORDER BY sortorder, answer";
    $qrr = $connect->Execute($qrq);
    //Checked
    $qct = $qrr->RecordCount();
    //Count sub-questions for this question
    $sqrq = "SELECT * FROM " . db_table_name('questions') . " WHERE parent_qid={$qid} AND language='" . $baselang . "'";
    $sqrr = $connect->Execute($sqrq);
    //Checked
    $sqct = $sqrr->RecordCount();
    $qrquery = "SELECT * FROM " . db_table_name('questions') . " WHERE gid={$gid} AND sid={$surveyid} AND qid={$qid} AND language='" . $baselang . "'";
    $qrresult = db_execute_assoc($qrquery) or safe_die($qrquery . "<br />" . $connect->ErrorMsg());
    //Checked
    $questionsummary = "<div class='menubar'>\n";
    // Check if other questions in the Survey are dependent upon this question
    $condarray = GetQuestDepsForConditions($surveyid, "all", "all", $qid, "by-targqid", "outsidegroup");
    // PREVIEW THIS QUESTION BUTTON
    while ($qrrow = $qrresult->FetchRow()) {
        $qrrow = array_map('FlattenText', $qrrow);
        //$qrrow = array_map('htmlspecialchars', $qrrow);
        $questionsummary .= "<div class='menubar-title ui-widget-header'>\n" . "<strong>" . $clang->gT("Question") . "</strong> <span class='basic'>{$qrrow['question']} (" . $clang->gT("ID") . ":{$qid})</span>\n" . "</div>\n" . "<div class='menubar-main'>\n" . "<div class='menubar-left'>\n" . "<img src='{$imageurl}/blank.gif' alt='' width='55' height='20' />\n" . "<img src='{$imageurl}/seperator.gif' alt='' />\n";
        if (bHasSurveyPermission($surveyid, 'surveycontent', 'read')) {
            if (count(GetAdditionalLanguagesFromSurveyID($surveyid)) == 0) {
                $questionsummary .= "<a href=\"#\" accesskey='q' onclick=\"window.open('{$scriptname}?action=previewquestion&amp;sid={$surveyid}&amp;qid={$qid}', '_blank')\"" . "title=\"" . $clang->gTview("Preview This Question") . "\">" . "<img src='{$imageurl}/preview.png' alt='" . $clang->gT("Preview This Question") . "' name='previewquestionimg' /></a>\n" . "<img src='{$imageurl}/seperator.gif' alt='' />\n";
            } else {
                $questionsummary .= "<a href=\"#\" accesskey='q' id='previewquestion'" . "title=\"" . $clang->gTview("Preview This Question") . "\">" . "<img src='{$imageurl}/preview.png' title='' alt='" . $clang->gT("Preview This Question") . "' name='previewquestionimg' /></a>\n" . "<img src='{$imageurl}/seperator.gif' alt=''  />\n";
                $tmp_survlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
开发者ID:himanshu12k,项目名称:ce-www,代码行数:31,代码来源:html.php

示例10: XMLImportLabelsets

function XMLImportLabelsets($sFullFilepath, $options)
{
    global $connect, $dbprefix, $clang;
    $xml = simplexml_load_file($sFullFilepath);
    if ($xml->LimeSurveyDocType != 'Label set') {
        safe_die('This is not a valid LimeSurvey label set structure XML file.');
    }
    $dbversion = (double) $xml->DBVersion;
    $csarray = buildLabelSetCheckSumArray();
    $aLSIDReplacements = array();
    $results['labelsets'] = 0;
    $results['labels'] = 0;
    $results['warnings'] = array();
    // Import labels table ===================================================================================
    $tablename = $dbprefix . 'labelsets';
    foreach ($xml->labelsets->rows->row as $row) {
        $insertdata = array();
        foreach ($row as $key => $value) {
            $insertdata[(string) $key] = (string) $value;
        }
        $oldlsid = $insertdata['lid'];
        unset($insertdata['lid']);
        // save the old qid
        // Insert the new question
        $query = $connect->GetInsertSQL($tablename, $insertdata);
        $result = $connect->Execute($query) or safe_die($clang->gT("Error") . ": Failed to insert data<br />{$query}<br />\n" . $connect->ErrorMsg());
        $results['labelsets']++;
        $newlsid = $connect->Insert_ID($tablename, "lid");
        // save this for later
        $aLSIDReplacements[$oldlsid] = $newlsid;
        // add old and new lsid to the mapping array
    }
    // Import labels table ===================================================================================
    $tablename = $dbprefix . 'labels';
    if (isset($xml->labels->rows->row)) {
        foreach ($xml->labels->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['lid'] = $aLSIDReplacements[$insertdata['lid']];
            $query = $connect->GetInsertSQL($tablename, $insertdata);
            $result = $connect->Execute($query) or safe_die($clang->gT("Error") . ": Failed to insert data<br />{$query}<br />\n" . $connect->ErrorMsg());
            $results['labels']++;
        }
    }
    //CHECK FOR DUPLICATE LABELSETS
    if (isset($_POST['checkforduplicates'])) {
        foreach (array_values($aLSIDReplacements) as $newlid) {
            $thisset = "";
            $query2 = "SELECT code, title, sortorder, language, assessment_value\n                       FROM " . db_table_name('labels') . "\n                       WHERE lid=" . $newlid . "\n                       ORDER BY language, sortorder, code";
            $result2 = db_execute_num($query2) or safe_die("Died querying labelset {$lid}<br />{$query2}<br />" . $connect->ErrorMsg());
            while ($row2 = $result2->FetchRow()) {
                $thisset .= implode('.', $row2);
            }
            // while
            $newcs = dechex(crc32($thisset) * 1);
            unset($lsmatch);
            if (isset($csarray) && $options['checkforduplicates'] == 'on') {
                foreach ($csarray as $key => $val) {
                    if ($val == $newcs) {
                        $lsmatch = $key;
                    }
                }
            }
            if (isset($lsmatch)) {
                //There is a matching labelset. So, we will delete this one and refer
                //to the matched one.
                $query = "DELETE FROM {$dbprefix}labels WHERE lid={$newlid}";
                $result = $connect->Execute($query) or safe_die("Couldn't delete labels<br />{$query}<br />" . $connect->ErrorMsg());
                $results['labels'] = $results['labels'] - $connect->Affected_Rows();
                $query = "DELETE FROM {$dbprefix}labelsets WHERE lid={$newlid}";
                $result = $connect->Execute($query) or safe_die("Couldn't delete labelset<br />{$query}<br />" . $connect->ErrorMsg());
                $results['labelsets']--;
                $newlid = $lsmatch;
                $results['warnings'][] = $clang->gT("Label set was not imported because the same label set already exists.") . " " . sprintf($clang->gT("Existing LID: %s"), $newlid);
            }
        }
        //END CHECK FOR DUPLICATES
    }
    return $results;
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:82,代码来源:importlabel.php

示例11: fSendStatistic

/**
 *
 * Enter description here...
 * @param $sUser Limesurvey user
 * @param $sPass Password
 * @param $iVid	surveyid
 * @param $email e-mail adress of the recipient
 * @param $docType pdf, xls or html
 * @param $graph with 1 it includes graphs in pdf files
 * @return "OK" or SoapFault
 */
function fSendStatistic($sUser, $sPass, $iVid, $email, $docType = 'pdf', $graph = '0')
{
    global $connect;
    global $dbprefix;
    $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
    include "lsrc.config.php";
    $lsrcHelper = new lsrcHelper();
    // Check if all mandatory parameters are present, else abort...
    if (!is_int($iVid) || $iVid == 0 || $email == '') {
        throw new SoapFault("Server: ", "Mandatory Parameters missing");
        exit;
    }
    if (!$lsrcHelper->checkUser($sUser, $sPass)) {
        throw new SoapFault("Authentication: ", "User or password wrong");
        exit;
    }
    if ($lsrcHelper->getSurveyOwner($iVid) != $_SESSION['loginID'] && !$_SESSION['USER_RIGHT_SUPERADMIN'] == '1') {
        throw new SoapFault("Authentication: ", "You have no right to send statistics from other peoples Surveys");
        exit;
    }
    if (!$lsrcHelper->surveyExists($iVid)) {
        throw new SoapFault("Database: ", "Survey {$iVid} does not exists");
        exit;
    }
    $lsrcHelper->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ",sid={$iVid} email={$email} doctype={$docType} graph={$graph} START OK ");
    /**
     * Build up the fields to generate statistics from
     */
    $summarySql = " SELECT gid, lid, qid, type " . " FROM {$dbprefix}questions " . " WHERE sid={$surveyid} ";
    $summaryRs = $connect->Execute($summarySql);
    $lsrcHelper->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ",sid={$iVid} OK ");
    foreach ($summaryRs as $field) {
        $myField = $surveyid . "X" . $field['gid'] . "X" . $field['qid'];
        // Multiple choice get special treatment
        if ($field['type'] == "M" || $field['type'] == "P") {
            $myField = "M{$myField}";
        }
        //numerical input will get special treatment (arihtmetic mean, standard derivation, ...)
        if ($field['type'] == "N") {
            $myField = "N{$myField}";
        }
        if ($field['type'] == "Q") {
            $myField = "Q{$myField}";
        }
        // textfields get special treatment
        if ($field['type'] == "S" || $field['type'] == "T" || $field['type'] == "U") {
            $myField = "T{$myField}";
        }
        //statistics for Date questions are not implemented yet.
        if ($field['type'] == "D") {
            $myField = "D{$myField}";
        }
        if ($field['type'] == "F" || $field['type'] == "H") {
            $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
            //Get answers. We always use the answer code because the label might be too long elsewise
            $query = "SELECT code, answer FROM " . db_table_name("answers") . " WHERE qid='" . $field['qid'] . "' AND language='{$language}' ORDER BY sortorder, answer";
            $result = $connect->Execute($query) or safe_die("Couldn't get answers!<br />{$query}<br />" . $connect->ErrorMsg());
            $counter2 = 0;
            //check all the answers
            while ($row = $result->FetchRow()) {
                $myField = "{$myField}{$row[0]}";
            }
            //$myField = "{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}[]";
        }
        $summary[] = $myField;
    }
    //$lsrcHelper->debugLsrc("wir sind in ".__FUNCTION__." Line ".__LINE__.",".print_r($summary)." ");
    switch ($docType) {
        case 'pdf':
            $tempFile = generate_statistics($iVid, $summary, 'all', $graph, $docType, 'F');
            if ($lsrcHelper->sendStatistic($iVid, $email, $tempFile)) {
                unlink($tempFile);
                return 'PDF send';
            } else {
                unlink($tempFile);
                throw new SoapFault("Mail System", "Mail could not be send! Check LimeSurveys E-Mail Settings.");
                exit;
            }
            break;
        case 'xls':
            $tempFile = generate_statistics($iVid, $summary, 'all', 0, $docType, 'F');
            if ($lsrcHelper->sendStatistic($iVid, $email, $tempFile)) {
                unlink($tempFile);
                return 'XLS send';
            } else {
                unlink($tempFile);
                throw new SoapFault("Mail System", "Mail could not be send! Check LimeSurveys E-Mail Settings.");
                exit;
            }
//.........这里部分代码省略.........
开发者ID:himanshu12k,项目名称:ce-www,代码行数:101,代码来源:lsrc.server.php

示例12: getQuotaAnswers

function getQuotaAnswers($qid, $surveyid, $quota_id)
{
    global $clang;
    $baselang = GetBaseLanguageFromSurveyID($surveyid);
    $query = "SELECT type, title FROM " . db_table_name('questions') . "q JOIN " . db_table_name('groups') . "g on g.gid=q.gid WHERE qid='{$qid}' AND q.language='{$baselang}' AND g.language='{$baselang}' order by group_order, question_order";
    $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
    $qtype = $result->FetchRow();
    if ($qtype['type'] == 'G') {
        $query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
        $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
        $answerlist = array('M' => array('Title' => $qtype['title'], 'Display' => $clang->gT("Male"), 'code' => 'M'), 'F' => array('Title' => $qtype['title'], 'Display' => $clang->gT("Female"), 'code' => 'F'));
        if ($result->RecordCount() > 0) {
            while ($quotalist = $result->FetchRow()) {
                $answerlist[$quotalist['code']]['rowexists'] = '1';
            }
        }
    }
    if ($qtype['type'] == 'M') {
        $query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
        $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
        $query = "SELECT title,question FROM " . db_table_name('questions') . " WHERE parent_qid='{$qid}'";
        $ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
        $answerlist = array();
        while ($dbanslist = $ansresult->FetchRow()) {
            $tmparrayans = array('Title' => $qtype['title'], 'Display' => substr($dbanslist['question'], 0, 40), 'code' => $dbanslist['title']);
            $answerlist[$dbanslist['title']] = $tmparrayans;
        }
        if ($result->RecordCount() > 0) {
            while ($quotalist = $result->FetchRow()) {
                $answerlist[$quotalist['code']]['rowexists'] = '1';
            }
        }
    }
    if ($qtype['type'] == 'L' || $qtype['type'] == 'O' || $qtype['type'] == '!') {
        $query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
        $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
        $query = "SELECT code,answer FROM " . db_table_name('answers') . " WHERE qid='{$qid}' and language='{$baselang}'";
        $ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
        $answerlist = array();
        while ($dbanslist = $ansresult->FetchRow()) {
            $answerlist[$dbanslist['code']] = array('Title' => $qtype['title'], 'Display' => substr($dbanslist['answer'], 0, 40), 'code' => $dbanslist['code']);
        }
        if ($result->RecordCount() > 0) {
            while ($quotalist = $result->FetchRow()) {
                $answerlist[$quotalist['code']]['rowexists'] = '1';
            }
        }
    }
    if ($qtype['type'] == 'A') {
        $query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
        $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
        $query = "SELECT title,question FROM " . db_table_name('questions') . " WHERE parent_qid='{$qid}'";
        $ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
        $answerlist = array();
        while ($dbanslist = $ansresult->FetchRow()) {
            for ($x = 1; $x < 6; $x++) {
                $tmparrayans = array('Title' => $qtype['title'], 'Display' => substr($dbanslist['question'], 0, 40) . ' [' . $x . ']', 'code' => $dbanslist['title']);
                $answerlist[$dbanslist['title'] . "-" . $x] = $tmparrayans;
            }
        }
        if ($result->RecordCount() > 0) {
            while ($quotalist = $result->FetchRow()) {
                $answerlist[$quotalist['code']]['rowexists'] = '1';
            }
        }
    }
    if ($qtype['type'] == 'B') {
        $query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
        $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
        $query = "SELECT code,answer FROM " . db_table_name('answers') . " WHERE qid='{$qid}' and language='{$baselang}'";
        $ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
        $answerlist = array();
        while ($dbanslist = $ansresult->FetchRow()) {
            for ($x = 1; $x < 11; $x++) {
                $tmparrayans = array('Title' => $qtype['title'], 'Display' => substr($dbanslist['answer'], 0, 40) . ' [' . $x . ']', 'code' => $dbanslist['code']);
                $answerlist[$dbanslist['code'] . "-" . $x] = $tmparrayans;
            }
        }
        if ($result->RecordCount() > 0) {
            while ($quotalist = $result->FetchRow()) {
                $answerlist[$quotalist['code']]['rowexists'] = '1';
            }
        }
    }
    if ($qtype['type'] == 'Y') {
        $query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
        $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
        $answerlist = array('Y' => array('Title' => $qtype['title'], 'Display' => $clang->gT("Yes"), 'code' => 'Y'), 'N' => array('Title' => $qtype['title'], 'Display' => $clang->gT("No"), 'code' => 'N'));
        if ($result->RecordCount() > 0) {
            while ($quotalist = $result->FetchRow()) {
                $answerlist[$quotalist['code']]['rowexists'] = '1';
            }
        }
    }
    if ($qtype['type'] == 'I') {
        $slangs = GetAdditionalLanguagesFromSurveyID($surveyid);
        array_unshift($slangs, $baselang);
        $query = "SELECT * FROM " . db_table_name('quota_members') . " WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
        $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
        while (list($key, $value) = each($slangs)) {
//.........这里部分代码省略.........
开发者ID:ddrmoscow,项目名称:queXS,代码行数:101,代码来源:quota.php

示例13: date_shift

}

$message=ReplaceFields($message, $fieldsarray);
$subject=ReplaceFields($subject, $fieldsarray);

$html=""; //Set variable

if (SendEmailMessage($message, $subject, returnglobal('register_email'), $from, $sitename,$useHtmlEmail,getBounceEmail($surveyid)))
{
    // TLR change to put date into sent
    //	$query = "UPDATE {$dbprefix}tokens_$surveyid\n"
    //			."SET sent='Y' WHERE tid=$tid";
    $today = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i", $timeadjust);
    $query = "UPDATE {$dbprefix}tokens_$surveyid\n"
    ."SET sent='$today' WHERE tid=$tid";
    $result=$connect->Execute($query) or safe_die ("$query<br />".$connect->ErrorMsg());     //Checked
    $html="<center>".$clang->gT("Thank you for registering to participate in this survey.")."<br /><br />\n".$clang->gT("An email has been sent to the address you provided with access details for this survey. Please follow the link in that email to proceed.")."<br /><br />\n".$clang->gT("Survey Administrator")." {ADMINNAME} ({ADMINEMAIL})";
    $html=ReplaceFields($html, $fieldsarray);
    $html .= "<br /><br /></center>\n";
}
else
{
    $html="Email Error";
}

//PRINT COMPLETED PAGE
if (!$thissurvey['template'])
{
    $thistpl=sGetTemplatePath(validate_templatedir('default'));
} 
else 
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:31,代码来源:register.php

示例14: safe_die

 if (tableExists("survey_{$surveyid}_timings")) {
     $dsquery = $dict->DropTableSQL("{$dbprefix}survey_{$surveyid}_timings");
     //$dict->ExecuteSQLArray($sqlarraytimings);
     $dsresult = $dict->ExecuteSQLArray($dsquery) or safe_die("Couldn't \"{$dsquery}\" because <br />" . $connect->ErrorMsg());
 }
 if (tableExists("tokens_{$surveyid}")) {
     $dsquery = $dict->DropTableSQL("{$dbprefix}tokens_{$surveyid}");
     $dsresult = $dict->ExecuteSQLArray($dsquery) or safe_die("Couldn't \"{$dsquery}\" because <br />" . $connect->ErrorMsg());
 }
 $dsquery = "SELECT qid FROM {$dbprefix}questions WHERE sid={$surveyid}";
 $dsresult = db_execute_assoc($dsquery) or safe_die("Couldn't find matching survey to delete<br />{$dsquery}<br />" . $connect->ErrorMsg());
 while ($dsrow = $dsresult->FetchRow()) {
     $asdel = "DELETE FROM {$dbprefix}answers WHERE qid={$dsrow['qid']}";
     $asres = $connect->Execute($asdel);
     $cddel = "DELETE FROM {$dbprefix}conditions WHERE qid={$dsrow['qid']}";
     $cdres = $connect->Execute($cddel) or safe_die("Delete conditions failed<br />{$cddel}<br />" . $connect->ErrorMsg());
     $qadel = "DELETE FROM {$dbprefix}question_attributes WHERE qid={$dsrow['qid']}";
     $qares = $connect->Execute($qadel);
 }
 $qdel = "DELETE FROM {$dbprefix}questions WHERE sid={$surveyid}";
 $qres = $connect->Execute($qdel);
 $scdel = "DELETE FROM {$dbprefix}assessments WHERE sid={$surveyid}";
 $scres = $connect->Execute($scdel);
 $gdel = "DELETE FROM {$dbprefix}groups WHERE sid={$surveyid}";
 $gres = $connect->Execute($gdel);
 $slsdel = "DELETE FROM {$dbprefix}surveys_languagesettings WHERE surveyls_survey_id={$surveyid}";
 $slsres = $connect->Execute($slsdel);
 $srdel = "DELETE FROM {$dbprefix}survey_permissions WHERE sid={$surveyid}";
 $srres = $connect->Execute($srdel);
 $srdel = "DELETE FROM {$dbprefix}saved_control WHERE sid={$surveyid}";
 $srres = $connect->Execute($srdel);
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:deletesurvey.php

示例15: Copyright

<?php
##################################################################
# Karnaf HelpDesk System - Copyright (C) 2001-2015 Kobi Shmueli. #
# See the LICENSE file for more information.                     #
##################################################################

require_once("../ktools.php");
check_auth();
CheckOperSession();
$id = $_GET['id'];
if(empty($id) || !is_numeric($id)) safe_die("Invalid Ticket ID!");
$query = squery("SELECT t.id,t.randcode,t.status,t.description,t.unick,t.ufullname,t.uemail,t.uphone,t.uip,t.rep_u,
t.rep_g,t.open_time,t.opened_by,t.is_real,t.is_private,t.email_upd,t.memo_upd,c1.name AS cat1_name,c2.name AS cat2_name,c3.name AS
cat3_name,s.status_name,up.priority_name AS upriority,sp.priority_name AS priority
FROM (karnaf_tickets AS t INNER JOIN karnaf_cat3 AS c3 ON c3.id=t.cat3_id INNER JOIN karnaf_cat2 AS c2 ON c2.id=c3.parent
INNER JOIN karnaf_cat1 AS c1 ON c1.id=c2.parent INNER JOIN karnaf_statuses AS s ON s.status_id=t.status INNER JOIN karnaf_priorities AS up ON
up.priority_id=t.upriority INNER JOIN karnaf_priorities AS sp ON sp.priority_id=t.priority) WHERE t.id=%d", $id);
if($result = sql_fetch_array($query)) {
  if(isset($_POST['action_text'])) {
    $group = $result['rep_g'];
    squery("INSERT INTO karnaf_actions(tid,action,a_by_u,a_by_g,a_time) VALUES(%d,'%s','%s','%s',%d)", $id, $_POST['action_text'], $nick, $group, time());
    echo "<div class=\"status\">The ticket has been updated.</div><br>";
  }
?>
<form name="form1" id="form1" method="post">
<table width="100%">
<tr class="Karnaf_Head2">
<td colspan="2" align="center">Re-assign ticket</td>
</tr>
<tr>
<td>Re-assign to group:</td>
开发者ID:kbuley,项目名称:karnaf,代码行数:31,代码来源:edit_reassign.php


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