Exemplo n.º 1
0
<?php

// download data as a csv file
require_once $_SERVER['DOCUMENT_ROOT'] . '/include/main_func.php';
auth();
# filename for download
$filename = ifEmpty($_POST['name'], 'csvfile') . ".csv";
# check that everything went OK
if (!empty($_POST['file'])) {
    header("Content-Disposition: attachment; filename=\"{$filename}\"");
    header("Content-Type: text/plain");
    echo $_POST['file'];
}
exit;
Exemplo n.º 2
0
    curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($ch, CURLOPT_TIMEOUT, 6000);
    $data = curl_exec($ch);
    curl_close($ch);
    $pcadata = json_decode($data, true);
    if (!is_array($pcadata) || !array_key_exists('error', $pcadata) || $pcadata['error'] == 'true') {
        $return['errorText'] = $data;
    } else {
        $return['data'] = $pcadata;
        if (!empty($pcadata['img'])) {
            // save image and associated tem
            include_once DOC_ROOT . '/include/classes/psychomorph.class.php';
            $avgimg = "/.tmp/" . $pcadata['img'];
            $avgtem = "/.tmp/" . $pcadata['tem'];
            $img = new PsychoMorph_ImageTem($avgimg, $avgtem);
            $img->setDescription(array('Desc' => 'Average image for PCA model ' . $theData['pcafile'] . '.pca', 'images' => $theData['images'], 'texture' => $theData['texture'], 'norm' => 'rigid'));
            $newFileName = ifEmpty($theData['pcafile'], $theData['pcifile']);
            if ($img !== null && $img->save($newFileName)) {
                $return['error'] = false;
                $return['newFileName'] = $img->getImg()->getURL();
            } else {
                $return['errorText'] .= 'The image was not saved. ';
                $return['newFileName'] = $newFileName;
            }
        }
    }
}
scriptReturn($return);
exit;
Exemplo n.º 3
0
 function print_form()
 {
     $this->print_instructions();
     echo "<form action='{$this->action}' method='{$this->method}' id='quest_{$this->id}'>" . PHP_EOL;
     // hidden values
     echo "<input type='hidden' name='quest_id' id='quest_id' value='", $this->id, "' />" . PHP_EOL;
     $starttime = ifEmpty($clean['starttime'], date('Y-m-d H:i:s'));
     echo "<input type='hidden' name='starttime' id='starttime' value='{$starttime}' />" . PHP_EOL;
     echo "<table class='questionnaire {$this->type}' id='qTable'>" . PHP_EOL;
     // questions
     $n = 0;
     $num_questions = count($this->questionList);
     foreach ($this->questionList as $q) {
         // print radiorow option row every 10 lines, but not if there are <5 questions left (unless there are <5 questions total)
         if ((++$n % 10 == 1 && $n < $num_questions - 5 || $n == 1) && !empty($this->options)) {
             echo $this->get_option_row();
         }
         if (1 == $n) {
             echo "<tbody id='qTableBody'>", PHP_EOL;
         }
         // start body after first header
         $q->print_formLine();
     }
     echo "</tbody></table>", PHP_EOL, "<div class='buttons'><input type='button' value='submit' onclick='submitQ({$this->id});' /></div>", PHP_EOL, "</form>", PHP_EOL . PHP_EOL;
     // javascripts for ranking
     if ('ranking' == $this->type) {
         echo '<script>', PHP_EOL, '    $j(function() {', PHP_EOL, '        $j("#qTableBody").sortable({update: function() { onReorder(); } });', PHP_EOL, '        $j("#qTableBody").disableSelection();', PHP_EOL, '        onReorder();', PHP_EOL, '    });', PHP_EOL, PHP_EOL, '    function onReorder() {', PHP_EOL, '        stripe("#qTableBody");', PHP_EOL, '        $j("#qTableBody tr td.handle").each( function(i) { $j(this).text(i+1); } );', PHP_EOL, '        var items = $j("#qTableBody tr");', PHP_EOL, '        items.each( function(intIndex) {', PHP_EOL, '            var q_id = "#q" + $j(this).attr("id").replace("row_","");', PHP_EOL, '            $j(q_id).val(intIndex+1);', PHP_EOL, '        });', PHP_EOL, '    }', PHP_EOL, '</script>', PHP_EOL . PHP_EOL;
     }
 }