Esempio n. 1
0
    $time = microtime();
    $time = explode(' ', $time);
    $time = $time[1] + $time[0];
    $start = $time;
}
require_once 'config.php';
include 'includes/core.php';
// Include language file
include 'language/' . $setting['language'] . '.php';
$time_now = date("Y-m-d H:i:s");
if (isset($_COOKIE['ava_lastpage'])) {
    $prev_page = secure($_COOKIE['ava_lastpage']);
}
// Set current page
if (!isset($_GET['task']) || isset($_GET['task']) && $_GET['task'] != 'register' && $_GET['task'] != 'validate' && $_GET['task'] != 'login') {
    setcookie('ava_lastpage', curPageUrl(), time() + 60 * 60 * 24 * 100, '/');
}
// Get logged in user
$user = getUser();
// Update the user IP if this is a new session, update users last activity
if ($user['login_status'] == 1) {
    $update_new_frs = '';
    $update_topic = '';
    if ($user['new_pms'] == 0) {
        $update_new_frs = ", new_frs = 0";
    }
    if (isset($_GET['task']) && $_GET['task'] == 'topic') {
        $update_topic = ", new_topic = 0";
    }
    if (!isset($_COOKIE['ava_iptrack'])) {
        mysql_query("UPDATE ava_users SET lastip = '{$user['ip']}', last_activity = '{$time_now}', new_pms = 0{$update_new_frs}{$update_topic} WHERE id = {$user['id']}") or die(mysql_error());
Esempio n. 2
0
function fileMaintenance()
{
    include "config.inc.php";
    // get files from database that are too old...
    $db = new PDO("sqlite:f2.sqlite");
    $stmt = $db->prepare("SELECT filename,randname,owner FROM files WHERE validuntil <= DATE('NOW');");
    $stmt->execute();
    $result = $stmt->fetchAll();
    // delete files
    if (!empty($result)) {
        foreach ($result as $file) {
            // delete actual file from filesystem
            unlink($conf['datadir'] . "/" . $file['randname']);
            // delete file entry from database
            $stmt = $db->prepare("DELETE FROM files WHERE randname = :randname;");
            $stmt->bindValue(':randname', $file['randname']);
            $stmt->execute();
        }
    }
    // get files from database that expire in 2 days...
    $db = new PDO("sqlite:f2.sqlite");
    $stmt = $db->prepare("SELECT filename,randname,validuntil,owner FROM files WHERE validuntil BETWEEN DATE('NOW') AND DATE('NOW', '+2 days');");
    $stmt->execute();
    $result = $stmt->fetchAll();
    // send email to owner with expiring information...
    if (!empty($result)) {
        foreach ($result as $file) {
            $stmt = $db->prepare("SELECT email from user where username = :username;");
            $stmt->bindValue(':username', $file['owner']);
            $stmt->execute();
            $owner = $stmt->fetch();
            // send email notification
            $to = $owner['email'];
            $subject = 'File will expire: ' . $file['filename'];
            $headers = "From: " . $conf['mailfrom'] . "\r\nReply-To: " . $conf['mailreplyto'];
            $headers .= "\r\nMIME-Version: 1.0";
            $headers .= "\r\nContent-Type: text/plain; charset=UTF-8";
            $headers .= "\r\nContent-Transfer-Encoding: quoted-printable";
            //define the body of the message.
            ob_start();
            echo "Cheers,\n\n";
            echo "the following file expired will expire soon and will be deleted:\n\n";
            echo "  * Filename:    " . $file['filename'] . "\n";
            echo "  * Expire date: " . $file['validuntil'] . "\n";
            echo "  * URL:         " . dirname(curPageUrl()) . "/" . $file['randname'] . "\n\n\n\n\n";
            echo "Have a nice day! :-) ";
            //copy current buffer contents into $message variable and delete current output buffer
            $message = ob_get_clean();
            $mail_sent = @mail($to, $subject, $message, $headers);
        }
    }
}
Esempio n. 3
0
<?php

require_once "util.php";
session_start();
header('Content-Type: text/html; charset=utf-8');
$text = "// true/false\n::Q1 T/F:: 1+1=2 \\{yada\\} {T}\n\n// multiple choice with specified feedback for right and wrong answers\n::Q2 MC:: Plaintext test < > & ; ' \" &lt; &gt; <b> (answer is &lt;)\n{ =< # right; good! ~> # wrong, it's < ~& # wrong, it's < }\n\n// multiple choice with multiple right and wrong\n::Q3 MA:: Two of these are \\{right\\} and two are wrong \nand GIFT escape character test\n{ =Right \\{1\\} =Right \\= 2 ~Wrong \\~ 1 ~Wrong \\ 2}\n\n// fill-in-the-blank (only right answers)\n::Q4 Short Answer:: Two plus {=two =2} equals four.\n\n// matching (All right answers with -> )\n::Q5 Matching:: Which animal eats which food? \n{ =cat -> cat food =dog -> dog food }\n\n// math range question\n::Q6 Range colon:: What is a number from 1 to 5? {#3:2}\n\n// math range specified with interval end points\n::Q7 Range ..:: What is a number from 1 to 5? {#1..5}\n\n// multiple numeric answers with partial credit and feedback\n::Q8 Partial Credit Numeric:: When was Ulysses S. Grant born? {#\n         =1822:0      # Correct! Full credit.\n         =%50%1822:2  # He was born in 1822. Half credit for being close.\n}\n\n// essay\n::Q9 Essay:: How are you? {}\n\n// HTML with pre tags html code style\n::Q10 HTML::[html]The next two lines are in a pre tag.<br/>\n<pre>\n   Here is a less-than &lt;\n   and an ampersand &amp;\n</pre>\nAn some non-pre text after the pre section is done.\n{ =yellow # right; good! ~red # wrong, it's yellow ~blue # wrong, it's yellow }\n\n// HTML with pre tags python code style\n::Q11 HTML Python::[html]Some code in a pre block<br/>\n<pre>\n    if x &lt; 10 :\n        print \"too low\"\n    else : \n        print \"just right\"\n</pre>\nAn some HTML after the end of the pre block\n{ =yellow # right; good! ~red # wrong, it's yellow ~blue # wrong, it's yellow }\n\n// Make sure < and > make it through in plaintext questions\n::Q12 Plaintext:: In a plaintext question, does the <b> bold tag 'show' \n\"with\" less than's and greater than's instead of turning stuff bold.\n{ =Do we see a < less than ~Do we see a > greater than \n~Do we see a ' single quote ~Do we see a \" double quote}\n\n// HTML with formatting\n::Q11 HTML with formatting::[html]In an HTML question, <b>bold</b> should simply appear as bold?\n{ =yellow # right; good! ~red # wrong, it's yellow ~blue # wrong, it's yellow }\n\n::Q12::[html] What is true about the following HMTL?\n<pre>\n&lt;a href=\"http://www.dr-chuck.com/page2.htm\"&gt;Second Page&lt;/a&gt;\n</pre>\n{\n=The reference is an absolute reference\n~The reference is a relative reference\n~The HTML is improperly formed and will be a syntax error\n~The text \"Second Page\" is improperly placed and will not be seen\n}\n\n::Q13::[html] For the following HTML, what does the \"style=\" attribute\nachieve?\n<pre>\n&lt;p style=\"color: red;\"&gt;\n</pre>\n{\n=It allows the application of CSS rules to the contents of the tag\n~It is an HTML syntax error and will be ignored\n~It changes the background color of the paragreaph to red\n~It contains JavaScript to be executed when the ofer hovers over the paragraph\n~It changes the color of the tab for this page in the borwser to be red\n}\n\n";
unset($_SESSION['content_item_return_url']);
if (isset($_POST['ext_content_return_url'])) {
    $_SESSION['content_item_return_url'] = $_POST['ext_content_return_url'];
}
$config_url = str_replace("convert.php", "lti_config.php", curPageUrl());
?>
<!DOCTYPE html>
<html>
<head>
<title>GIFT2QTI - Quiz format convertor</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">

</head>
<body style="margin: 5px;">
<p>Please enter your <a href="https://docs.moodle.org/28/en/GIFT_format" target="_blank">GIFT</a> 
formatted quiz text below so it can be converted to 
<a href="http://www.imsglobal.org/question/" target="_blank">QTI 1.2.1</a>.
</p><p>
This is still a <a href="https://github.com/csev/gift2qti" target="_blank">work in progress</a>
and currently only supports single-answer multiple-choice, true/false, and essay questions.
The sample text below has some GIFT formats that this tool does not yet support so some of the questions
below will not be converted.  Feel free to send me a Pull request on gitHub :).
Esempio n. 4
0
use Tsugi\Core\LTIX;
use Tsugi\Util\LTI;
use Tsugi\Util\Net;
use Tsugi\Util\Mersenne_Twister;
$sanity = array('urllib' => 'You should use urllib to retrieve the data from the API', 'urlencode' => 'You should use urlencode add parameters to the API url', 'json' => 'You should use the json library to parse the API data');
// Compute the stuff for the output
$code = 42;
$MT = new Mersenne_Twister($code);
$sample = $MT->shuffle($LOCATIONS);
$sample_location = $sample[0];
$code = $USER->id + $LINK->id + $CONTEXT->id;
$MT = new Mersenne_Twister($code);
$actual = $MT->shuffle($LOCATIONS);
$actual_location = $actual[0];
// Retrieve the data
$url = curPageUrl();
$api_url = str_replace('index.php', 'data/geojson', $url);
$google_api = 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=University+of+Michigan';
$sample_url = $api_url . '?sensor=false&address=' . urlencode($sample_location);
$actual_url = $api_url . '?sensor=false&address=' . urlencode($actual_location);
$sample_data = Net::doGet($sample_url);
$sample_count = strlen($sample_data);
$response = Net::getLastHttpResponse();
$sample_json = json_decode($sample_data);
if ($response != 200 || $sample_json == null || !isset($sample_json->results[0])) {
    error_log("DIE: Sample response={$response} url={$sample_url} json_error=" . json_last_error_msg());
    die("Sample response={$response} url={$sample_url} json_error=" . json_last_error_msg());
}
// echo("<pre>\n");echo(jsonIndent(json_encode($sample_json)));echo("</pre>\n");
$sample_place = $sample_json->results[0]->place_id;
$actual_data = Net::doGet($actual_url);
Esempio n. 5
0
          <div class="panel panel-default">
            <div class="panel-heading">All files</div>
            <div class="panel-body">
              <table class="table table-striped table-hover">
                <thead>
                  <tr>
                    <th>File</th>
                    <th class="hidden-xs">Valid until</th>
                    <th>Owner</th>
                  </tr>
                </thead>
                <tbody>
<?php 
            if (!empty($result)) {
                foreach ($result as $file) {
                    echo "                  <tr>\n                    <td> <i class=\"fa " . getFaIcon($file['filename']) . "\" style=\"display:table-cell;\"></i> <a style=\"display:table-cell;\" href=\"" . dirname(curPageUrl()) . "/" . $file['randname'] . "\" target=\"_blank\">" . $file['filename'] . "</a> <span style=\"display:table-cell; color:#bbb; padding-left:5px;\" class=\"hidden-xs\"> (" . human_filesize(filesize($conf['datadir'] . "/" . $file['randname'])) . ")</span>";
                    if ($file['password'] != '') {
                        echo " &nbsp; <i class=\"fa fa-key\"> </i>";
                    }
                    echo "</td>\n                    <td class=\"hidden-xs\"> ";
                    if ($file['validuntil'] == 'unlimited') {
                        echo 'unlimited';
                    } else {
                        echo date("Y-m-d", strtotime($file['validuntil']));
                    }
                    echo " </td>\n                    <td> " . $file['owner'] . "</td>\n                  </tr>\n";
                }
            }
            echo "\n                </tbody>\n              </table>\n            </div>\n          </div>\n        </div>";
        }
        ?>
Esempio n. 6
0
    return $pageURL;
}
//load image info
//load template
$imageId = $_GET['image_id'];
if (strpos($_SERVER["HTTP_USER_AGENT"], "facebookexternalhit/") === false && strpos($_SERVER["HTTP_USER_AGENT"], "Facebot") === false) {
    //It's not Facebook looking, let's redirect the user
    header('Location: ' . str_replace('static.php', '', curPageUrl()));
    /*  echo 'redirects here. Real user assumed. This is user agent: ' . $_SERVER["HTTP_USER_AGENT"];
      var_dump( strpos($_SERVER["HTTP_USER_AGENT"], "facebookexternalhit/"));
      var_dump( strpos($_SERVER["HTTP_USER_AGENT"], "Facebot"));*/
}
/*$url = 'http://'.$_SERVER['HTTP_HOST'];
$url = str_replace(':80','',$url);*/
if (!is_numeric($imageId)) {
    $imageData = [];
    $imageData['image']['resizedUrl'] = curPageUrl() . '/frontimage.jpg';
    $imageData['image']['id'] = null;
    $imageData['tags'] = [];
} else {
    //include('../api/library/UrlHelper.php');
    //$url = UrlHelper::getUrl();
    $jsonurl = substr(curPageUrl(), 0, strrpos(curPageUrl(), '/')) . "/api/image/" . $imageId;
    //echo $jsonurl;
    $imageData = json_decode(file_get_contents($jsonurl), true);
}
if (!$imageData) {
    echo 'no image data found!';
    return;
}
include 'static_template.php';
Esempio n. 7
0
<?php

session_start();
// Load up the LTI Support code
require_once "../util/lti_util.php";
require_once "json_indent.php";
require_once "content_json_messages.php";
ini_set("display_errors", 1);
$content_url = isset($_REQUEST['content_url']) ? $_REQUEST['content_url'] : preg_replace("/json.*\$/", "cc/sakai-export.imscc", curPageUrl());
$result_url = $_REQUEST['content_item_return_url'];
$oauth_consumer_key = $_REQUEST['oauth_consumer_key'];
$oauth_consumer_secret = isset($_REQUEST['secret']) ? $_REQUEST['secret'] : 'secret';
$data = isset($_REQUEST['data']) ? $_REQUEST['data'] : "";
// Note that the opaque data is in $_REQUEST['data'] all the time
if (strlen($oauth_consumer_secret) < 1 || strlen($oauth_consumer_key) < 1 || strlen($result_url) < 1) {
    var_dump($_SESSION);
    die("Must have url, reg_password and reg_key in sesison or as GET parameters");
}
if (isset($_REQUEST['send'])) {
    $parms = array();
    $parms["lti_message_type"] = "ContentItemSelection";
    $parms["lti_version"] = "LTI-1p0";
    if (isset($_REQUEST['data'])) {
        $parms["data"] = $_REQUEST['data'];
    }
    $json = getFileItemJSON($content_url);
    $parms["content_items"] = json_encode($json);
    $parms = signParameters($parms, $result_url, "POST", $oauth_consumer_key, $oauth_consumer_secret, "Finish Content Return");
    $content = postLaunchHTML($parms, $result_url, true);
    echo $content;
    return;
Esempio n. 8
0
<?php

session_start();
// Load up the LTI Support code
require_once "../util/lti_util.php";
require_once "json_indent.php";
require_once "content_json_messages.php";
ini_set("display_errors", 1);
$content_url = isset($_REQUEST['content_url']) ? isset($_REQUEST['content_url']) : preg_replace("/json.*\$/", "images/Sakaiger.png", curPageUrl());
$result_url = isset($_REQUEST['url']) ? $_REQUEST['url'] : false;
$oauth_consumer_key = isset($_REQUEST['key']) ? $_REQUEST['key'] : $_SESSION['reg_key'];
$oauth_consumer_secret = isset($_REQUEST['secret']) ? $_REQUEST['secret'] : $_SESSION['reg_password'];
$grade = isset($_REQUEST['grade']) ? $_REQUEST['grade'] : '';
$comment = isset($_REQUEST['comment']) ? $_REQUEST['comment'] : '';
if (strlen($oauth_consumer_secret) < 1 || strlen($oauth_consumer_key) < 1 || strlen($result_url) < 1) {
    var_dump($_SESSION);
    die("Must have url, reg_password and reg_key in sesison or as GET parameters");
}
if (isset($_REQUEST['send'])) {
    $parms = array();
    $parms["lti_message_type"] = "ContentItemSelection";
    $parms["lti_version"] = "LTI-1p0";
    $parms["data"] = "Yo Yo";
    $retval = json_encode(getContentJSON($content_url));
    $parms["content_items"] = $retval;
    $parms = signParameters($parms, $result_url, "POST", $oauth_consumer_key, $oauth_consumer_secret, "Finish Content Return");
    $content = postLaunchHTML($parms, $result_url, true);
    echo $content;
    return;
}
?>
Esempio n. 9
0
<?php

session_start();
// Load up the LTI Support code
require_once "../util/lti_util.php";
require_once "json_indent.php";
require_once "content_json_messages.php";
ini_set("display_errors", 1);
$content_url = isset($_REQUEST['content_url']) ? $_REQUEST['content_url'] : preg_replace("/json.*\$/", "tool.php?sakai=98765", curPageUrl());
$result_url = isset($_REQUEST['url']) ? $_REQUEST['url'] : $_POST['content_item_return_url'];
$oauth_consumer_key = isset($_REQUEST['key']) ? $_REQUEST['key'] : $_SESSION['oauth_consumer_key'];
$oauth_consumer_secret = isset($_REQUEST['secret']) ? $_REQUEST['secret'] : 'secret';
$title = isset($_REQUEST['title']) ? $_REQUEST['title'] : "The Awesome Sakaiger Title";
$text = isset($_REQUEST['text']) ? $_REQUEST['text'] : "The Awesome Sakaiger Text";
$data = isset($_REQUEST['data']) ? $_REQUEST['data'] : "";
if (strlen($oauth_consumer_secret) < 1 || strlen($oauth_consumer_key) < 1 || strlen($result_url) < 1) {
    var_dump($_SESSION);
    die("Must have url, reg_password and reg_key in sesison or as GET parameters");
}
if (isset($_REQUEST['send'])) {
    $parms = array();
    $parms["lti_message_type"] = "ContentItemSelection";
    $parms["lti_version"] = "LTI-1p0";
    if (isset($_REQUEST['data'])) {
        $parms["data"] = $_REQUEST['data'];
    }
    $json = getLtiLinkJSON($content_url);
    $json->{'@graph'}[0]->{'title'} = $title;
    $json->{'@graph'}[0]->{'text'} = $text;
    $retval = json_encode($json);
    $parms["content_items"] = $retval;
Esempio n. 10
0
<?php

require_once "util.php";
date_default_timezone_set('UTC');
if (isset($_GET[session_name()])) {
    session_id($_GET[session_name()]);
}
session_start();
if (!isset($_SESSION['quiz'])) {
    error_log('GIFT2QTI Missing quiz data ' . curPageUrl());
    die('GIFT2QTI Missing quiz data');
}
// Stuff we substitute...
$quiz_id = 'i' . uniqid();
$today = date('Y-m-d');
$ref_id = 'r' . uniqid();
$manifest_id = 'm' . uniqid();
$title = isset($_SESSION['title']) ? htmlent_utf8($_SESSION['title']) : 'Converted by the Gift2QTI Converter';
$desc = "Description goes here";
$source = array("__DATE__", "__QUIZ_ID__", "__REF_ID__", "__TITLE__", "__DESCRIPTION__", "__MANIFEST_ID__");
$dest = array($today, $quiz_id, $ref_id, $title, $desc, $manifest_id);
// here we go...
$filename = tempnam(sys_get_temp_dir(), "gift2qti");
$zip = new ZipArchive();
if ($zip->open($filename, ZipArchive::CREATE) !== TRUE) {
    die("Cannot open {$filename}\n");
}
if (isset($_SESSION['name']) && strlen($_SESSION['name']) > 0) {
    $download = preg_replace('/[^\\w\\s]/', '', $_SESSION['name']);
    if (strlen($download) < 1) {
        $download = $quiz_id;
Esempio n. 11
0
 * limitations under the License.
 */
error_reporting(-1);
session_start();
include "inc/config.inc.php";
include "inc/functions.inc.php";
createDatabaseIfNotExists();
// download file if password was given
if (isset($_POST['downloadfile']) && $_POST['downloadfile'] != "" && isset($_POST['password']) && $_POST['password'] != "") {
    if (checkPassword($_POST['downloadfile'], $_POST['password']) == TRUE) {
        downloadFile($_POST['downloadfile']);
        exit;
    } else {
        $_SESSION['message']['type'] = "danger";
        $_SESSION['message']['message'] = "The specified Password was wrong.";
        header('Location: ' . dirname(curPageUrl()) . "/" . $_POST['downloadfile']);
        exit;
    }
}
// delete old files and send expiration mails
if (isset($_GET['fileMaintenance']) && $_GET['fileMaintenance'] == "true") {
    fileMaintenance();
    exit;
}
$db = new PDO('sqlite:f2.sqlite');
// parse current URL
$parsedUrl = parse_url(curPageURL());
// split path by /
$boom = explode("/", $parsedUrl['path']);
// get filename and check for password
if ($boom[1] != '') {
Esempio n. 12
0
<center>
<h2>
This screen randomly changes the height between list items and vanishes 
after a while to make sure that you retrieve and process the data
in a Python program rather than simply counting down pressing links, and 
and doing the assignment without writing a Python program :).
The names are in the same order in the HTML even though they 
shift around on the screen visually.
Your Python program can look at the page as long as it likes.
</h2>
</center>
</div>
<ul>
<?php 
                        // $curr_url = getCurrentFileUrl(__FILE__);
                        $curr_url = curPageUrl();
                        $new = getShuffledNames($code);
                        for ($i = 0; $i < count($new) && $i < 100; $i++) {
                            $new_url = deHttps(str_replace("index.php", "known_by_" . $new[$i] . ".html", $curr_url));
                            echo '<li style="margin-top: ' . rand(1, $i + 25) . 'px;"><a href="' . $new_url . '">' . $new[$i] . "</a></li>\n";
                        }
                        ?>
</ul>
<script>
// http://stackoverflow.com/questions/20423322/simple-setting-off-display-none-block-with-javascript
function showHide(id) {
    var el = document.getElementById(id);
    if( el && el.style.display == 'none')    
        el.style.display = 'block';
    else 
        el.style.display = 'none';
Esempio n. 13
0
 public static function token()
 {
     if (isset($_GET['token'])) {
         $_SESSION['token'] = $_GET['token'];
         $loc = curPageUrl();
         $loc = explode('?', $loc);
         $loc = $loc[0];
         header('Location: ' . $loc);
     } elseif (isset($_SESSION['token'])) {
         return $_SESSION['token'];
     } else {
         header('Location: ' . SITE_URL);
     }
 }
Esempio n. 14
0
function dataUrl($file)
{
    global $GLOBAL_PYTHON_DATA_URL;
    if (is_string($GLOBAL_PYTHON_DATA_URL)) {
        return $GLOBAL_PYTHON_DATA_URL . $file;
    }
    $url = curPageUrl();
    $retval = str_replace('index.php', 'data/' . $file, $url);
    return $retval;
}
//var_dump($imageData);
?>
<!DOCTYPE html>
<html>
    <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Open Graph data -->
    <meta property="og:title" content="DR's billeder" />
    <meta property="og:url" content="<?php 
echo curPageUrl();
?>
" />
    <meta property="og:image" content="<?php 
echo $imageData['image']['resizedUrl'];
?>
" />
    <meta property="og:image:width" content="1024" />
    <meta property="og:image:height" content="1024" />
    <meta property="og:description" content="Klik her og hjælp med at få dem på nettet" />

    <title>Opmærkning af DR's billeder</title>
    </head>
    <body>
    	<!--<img src="<?php 
//echo $imageData['image']['resizedUrl'];