Exemple #1
0
function sigHandler($signo)
{
    switch ($signo) {
        case SIGTERM:
            shutdown("Got SIGTERM");
            break;
        case SIGHUP:
            logWrite(L_SYSTEM, "[SYSTEM] Got SIGHUP, Forced rehash.");
            rehash();
            break;
    }
}
if ($xml_base_path) {
    $package_base_path = $xml_base_path . $package_base_path;
    mkdir(AT_CONTENT_DIR . $_SESSION['course_id'] . '/' . $xml_base_path);
    $package_base_name = $xml_base_path . $package_base_name;
}
/* get the top level content ordering offset */
$sql = "SELECT MAX(ordering) AS ordering FROM " . TABLE_PREFIX . "content WHERE course_id={$_SESSION['course_id']} AND content_parent_id={$cid}";
$result = mysql_query($sql, $db);
$row = mysql_fetch_assoc($result);
$order_offset = intval($row['ordering']);
/* it's nice to have a real number to deal with */
$lti_offset = array();
//since we don't need lti tools, the ordering needs to be subtracted
//reorder the items stack
$common_path = removeCommonPath($items);
$items = rehash($items);
//debug($items);exit;
foreach ($items as $item_id => $content_info) {
    //formatting field, default 1
    $content_formatting = 1;
    //CONTENT_TYPE_CONTENT
    //don't want to display glossary as a page
    if ($content_info['href'] == $glossary_path . 'glossary.xml') {
        continue;
    }
    //if discussion tools, add it to the list of unhandled dts
    if ($content_info['type'] == 'imsdt_xmlv1p0') {
        //if it will be taken care after (has dependency), then move along.
        if (in_array($item_id, $avail_dt)) {
            $lti_offset[$content_info['parent_content_id']]++;
            continue;
Exemple #3
0
function login($login, $passwd)
{
    global $db;
    $query = $db->prepare("SELECT * FROM `users` WHERE `login` =:login");
    $query->bindParam(':login', $login, PDO::PARAM_STR);
    $query->execute();
    if ($query->rowCount() != 1) {
        return 'no_user';
    }
    $row = $query->fetch();
    if (password_verify($passwd, $row['passwd'])) {
        $new_passwd = rehash($passwd, $row['passwd']);
        $_SESSION['id'] = $row['id'];
        $_SESSION['login'] = $login;
        $_SESSION['sess'] = hash('sha256', $login . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']);
        if ($new_passwd != 'no_hash') {
            // Обновляем hash в базе
            $query = $db->prepare("UPDATE `users` SET `passwd` = :passwd WHERE `login` = :login");
            $query->bindParam(':passwd', $new_passwd, PDO::PARAM_STR);
            $query->bindParam(':login', $login, PDO::PARAM_STR);
            $query->execute();
        }
        $query = $db->prepare("UPDATE `users` SET `session` = :sess WHERE `login` = :login");
        $query->bindParam(':login', $login, PDO::PARAM_STR);
        $query->bindParam(':sess', $_SESSION['sess'], PDO::PARAM_STR);
        $query->execute();
        return 'enter';
    } else {
        return 'bad_passwd';
    }
}