Esempio n. 1
0
function mystery_session_gc($maxlifetime)
{
    // Delete any sessions older than $maxlifetime seconds old
    global $_MYSTERY;
    $table = $_MYSTERY['table_prefix'] . 'sessions';
    $cutoff = date('YmdHis', time() - $maxlifetime);
    $query = 'DELETE FROM ' . $table . ' WHERE session_timestamp < ?';
    $params = array($cutoff);
    mystery_delete_query($query, $params);
    // trigger_error('gc occurred ' . __FILE__ . ':' . __LINE__ . ':(');
    return true;
}
Esempio n. 2
0
        return $comments;
    }
}
if ($_SESSION['is_logged_in'] != 'yes' || !$_SESSION['portal']['taking_course']) {
    mystery_redirect('/');
}
switch ($_PORTAL['activity']) {
    case 'details':
        $diy_id = @$_PORTAL['action'];
        if ($diy_id == '') {
            mystery_redirect('/course/');
        }
        if (isset($_PORTAL['params']['process'])) {
            $query = 'DELETE FROM portal_comments_ratings WHERE comment_diy_identifier = ? AND comment_author = ?';
            $params = array($diy_id, $_SESSION['portal']['member_id']);
            $status = mystery_delete_query($query, $params, 'portal_dbh');
            if (!isset($_REQUEST['comment_delete'])) {
                $data = array();
                $data['comment_author'] = $_SESSION['portal']['member_id'];
                $data['comment_diy_identifier'] = $diy_id;
                $data['comment_title'] = $_REQUEST['comment_title'];
                $data['comment_body'] = $_REQUEST['comment_body'];
                //$data['comment_rating'] = $_REQUEST['comment_rating'];
                $data['creation_date'] = date('Y-m-d H:i:s');
                $comment_id = mystery_insert_query('portal_comments_ratings', $data, 'comment_id', 'portal_dbh');
                echo '<p style="color: #009900;"><em>Comment saved!</em></p>';
            } else {
                echo '<p style="color: #009900;"><em>Comment deleted!</em></p>';
            }
        }
        $activity_info = portal_get_activity_info_from_diy_id($diy_id);
Esempio n. 3
0
function portal_subscribe_class_to_diy_activities($class_id, $old_activities, $new_activities)
{
    global $_PORTAL;
    //mystery_print_r($old_activities); mystery_print_r($new_activities); exit;
    $to_add = array_values(array_diff($new_activities, $old_activities));
    $to_delete = array_values(array_diff($old_activities, $new_activities));
    //mystery_print_r($to_add); mystery_print_r($to_delete); exit;
    // first delete the old ones
    if (count($to_delete) > 0) {
        $query = 'DELETE FROM portal_class_diy_activities WHERE class_id = ? AND project_id = ? AND diy_activity_id IN (' . implode(',', $to_delete) . ')';
        $params = array($class_id, $_PORTAL['project_info']['project_id']);
        $status = mystery_delete_query($query, $params, 'portal_dbh');
    }
    // now add the new ones
    for ($i = 0; $i < count($to_add); $i++) {
        $data = array();
        $data['class_id'] = $class_id;
        $data['diy_activity_id'] = $to_add[$i];
        $data['project_id'] = $_PORTAL['project_info']['project_id'];
        $id = mystery_insert_query('portal_class_diy_activities', $data, 'class_diy_activity_id', 'portal_dbh');
    }
}