コード例 #1
0
ファイル: session_handler.php プロジェクト: danorama/orsee
function orsee_session_read($aKey)
{
    $query = "SELECT DataValue FROM " . table('http_sessions') . " WHERE SessionID=:aKey";
    $pars = array(':aKey' => $aKey);
    $result = or_query($query, $pars);
    if (pdo_num_rows($result) == 1) {
        $r = pdo_fetch_assoc($result);
        return $r['DataValue'];
    } else {
        $query = "INSERT INTO " . table('http_sessions') . " (SessionID, LastUpdated, DataValue)\n                       VALUES (:aKey, NOW(), '')";
        or_query($query, $pars);
        return "";
    }
}
コード例 #2
0
ファイル: subpools.php プロジェクト: kfarr2/psu-orsee
function subpools__get_subpools()
{
    global $preloaded_subpools;
    if (is_array($preloaded_subpools) && count($preloaded_subpools) > 0) {
        return $preloaded_subpools;
    } else {
        $subpools = array();
        $query = "SELECT *\n    \t\t\tFROM " . table('subpools') . "  \n      \t\t\tORDER BY subpool_id";
        $result = or_query($query);
        while ($line = pdo_fetch_assoc($result)) {
            $subpools[$line['subpool_id']] = $line;
        }
        $preloaded_subpools = $subpools;
        return $subpools;
    }
}
コード例 #3
0
ファイル: laboratories.php プロジェクト: danorama/orsee
function laboratories__get_laboratories($tlang = "")
{
    if (!$tlang) {
        global $lang;
        $tlang = lang('lang');
    }
    $labs = array();
    $query = "SELECT * FROM " . table('lang') . " WHERE content_type='laboratory'\n            ORDER BY order_number ";
    $result = or_query($query);
    while ($lab = pdo_fetch_assoc($result)) {
        $tlab = array();
        $tlab['lab_name'] = laboratories__strip_lab_name(stripslashes($lab[lang('lang')]));
        $tlab['lab_address'] = laboratories__strip_lab_address(stripslashes($lab[lang('lang')]));
        $labs[$lab['content_name']] = $tlab;
    }
    return $labs;
}
コード例 #4
0
$datasetsLabels = ["Friday", "Saturday", "Sunday"];
$whichDay = htmlspecialchars($_GET["day"]);
$whichDay = array_search($whichDay, array_values($datasetsLabels));
$inputDay = $datasets[$whichDay];
$whichPlace = htmlspecialchars($_GET["place"]);
$whatTime = (int) htmlspecialchars($_GET["time"]);
$position = htmlspecialchars($_GET["position"]);
$firstquery = pdo_query("select * from places where name = '" . $whichPlace . "'");
$firstresult = pdo_fetch_assoc($firstquery);
$xposition = $firstresult["x"];
$yposition = $firstresult["y"];
$selectedCategory = $firstresult["category"];
if (!strcasecmp($position, "after")) {
    $myquery = "Select move.name, count(*) as number, move.category, move.x, move.y from movement_combined move, \n        (select id,min(timestamp) as timestamp from movement_combined where id in (select distinct(id) from movement_combined \n        where name = '" . $whichPlace . "' and HOUR(timestamp) = " . $whatTime . " and day = '" . $inputDay . "') and day = '" . $inputDay . "' and \n        HOUR(timestamp) = " . ($whatTime + 1) . " group by id) as temp where temp.timestamp = move.timestamp and temp.id = move.id \n        group by move.name order by number DESC limit 5";
} else {
    $myquery = "Select move.name, count(*) as number, move.category, move.x, move.y from movement_combined move, \n        (select id,max(timestamp) as timestamp from movement_combined where id in (select distinct(id) from movement_combined \n        where name = '" . $whichPlace . "' and HOUR(timestamp) = " . $whatTime . " and day = '" . $inputDay . "') and day = '" . $inputDay . "' and \n        HOUR(timestamp) = " . ($whatTime - 1) . " group by id) as temp where temp.timestamp = move.timestamp and temp.id = move.id \n        group by move.name order by number DESC limit 5";
}
$query = pdo_query($myquery);
if (!$query) {
    echo pdo_error();
    die;
}
$data[] = [$selectedCategory, 0, 0];
for ($x = 0; $x < pdo_num_rows($query); $x++) {
    $result = pdo_fetch_assoc($query);
    $distance = round(abs(sqrt(pow($xposition - $result["x"], 2) + pow($yposition - $result["y"], 2))));
    $result["distance"] = $distance;
    $data[] = $result;
}
unset($server);
echo json_encode($data);
コード例 #5
0
ファイル: pdo_mysql.php プロジェクト: jalota16/nightcaviar
 function mysql_fetch_assoc($result = NULL)
 {
     return pdo_fetch_assoc(func_get_args());
 }
コード例 #6
0
ファイル: admin_type_show.php プロジェクト: kfarr2/psu-orsee
		<form action="admin_type_edit.php">
		<input class="button" type=submit name="new" value="' . lang('create_new') . '">
		</form>';
    echo '<br>

		<table class="or_listtable" style="width: 90%;"><thead>
			<tr style="background: ' . $color['list_header_background'] . '; color: ' . $color['list_header_textcolor'] . ';">
				<td>' . lang('name') . '</td>
				<td>' . lang('rights') . '</td>
				<td></td>
			</tr></thead>
			<tbody>';
    $query = "SELECT * FROM " . table('admin_types') . " ORDER BY type_name";
    $result = or_query($query);
    $shade = false;
    while ($type = pdo_fetch_assoc($result)) {
        echo '<tr class="small"';
        if ($shade) {
            echo ' bgcolor="' . $color['list_shade1'] . '"';
        } else {
            echo ' bgcolor="' . $color['list_shade2'] . '"';
        }
        echo '>

                        	<td>
                                	' . $type['type_name'] . '
                        	</td>
                        	<td class="small">
                                	' . str_replace(",", ", ", $type['rights']) . '
                        	</td>
                        	<td>
コード例 #7
0
ファイル: options.php プロジェクト: danorama/orsee
function options__get_color_styles()
{
    global $preloaded_color_styles;
    if (isset($preloaded_color_styles) && is_array($preloaded_color_styles) && count($preloaded_color_styles) > 0) {
        return $preloaded_color_styles;
    } else {
        $color_styles = array();
        $query = "select option_style from " . table('options') . "\n                where option_type='color'\n                group by option_style\n                order by option_id";
        $result = or_query($query);
        while ($line = pdo_fetch_assoc($result)) {
            $color_styles[] = $line['option_style'];
        }
        $preloaded_color_styles = $color_styles;
        return $color_styles;
    }
}
コード例 #8
0
ファイル: admin_show.php プロジェクト: danorama/orsee
             <td>' . lang('firstname') . '</td>
             <td>' . lang('lastname') . '</td>
             <td>' . lang('username') . '</td>
             <td>' . lang('type') . '</td>
             <td>' . lang('is_experimenter') . '</td>
             <td>' . lang('account') . '</td>
             <td></td>
         </tr>
         </thead>
         <tbody>';
 $query = "SELECT * FROM " . table('admin') . "\n            ORDER BY disabled, lname, fname";
 $result = or_query($query);
 $enabled_emails = array();
 $emails = array();
 $shade = false;
 while ($admin = pdo_fetch_assoc($result)) {
     if ($admin['email']) {
         $emails[] = $admin['email'];
         if ($admin['disabled'] == 'n') {
             $enabled_emails[] = $admin['email'];
         }
     }
     echo '<tr class="small"';
     if ($admin['disabled'] == 'y') {
         echo ' bgcolor="#999999" style="color: #333333"';
     } else {
         if ($shade) {
             echo ' bgcolor="' . $color['list_shade1'] . '"';
         } else {
             echo ' bgcolor="' . $color['list_shade2'] . '"';
         }
コード例 #9
0
ファイル: language.php プロジェクト: danorama/orsee
function lang__load_lang_cat($content_type, $language = "")
{
    global $lang, $preloaded_lang_cats;
    if (!$language) {
        $language = lang('lang');
    }
    if (isset($preloaded_lang_cats[$content_type][$language]) && is_array($preloaded_lang_cats[$content_type][$language]) && count($preloaded_lang_cats[$content_type][$language]) > 0) {
        return $preloaded_lang_cats[$content_type][$language];
    } else {
        $cat = array();
        $pars = array(':content_type' => $content_type);
        $query = "SELECT content_name, " . $language . " as content_value\n                FROM " . table('lang') . " WHERE content_type= :content_type";
        $result = or_query($query, $pars);
        while ($line = pdo_fetch_assoc($result)) {
            $cat[$line['content_name']] = stripslashes($line['content_value']);
        }
        $preloaded_lang_cats[$content_type][$language] = $cat;
        return $cat;
    }
}
コード例 #10
0
ファイル: expregister.php プロジェクト: kfarr2/psu-orsee
function expregister__get_participation_statuses()
{
    global $participation_statuses, $lang;
    if (!(is_array($participation_statuses) && count($participation_statuses) > 0)) {
        $participation_statuses = array();
        $query = "SELECT *\n    \t\t\tFROM " . table('participation_statuses') . "  \n      \t\t\tORDER BY pstatus_id";
        $result = or_query($query);
        while ($line = pdo_fetch_assoc($result)) {
            $participation_statuses[$line['pstatus_id']] = $line;
        }
        $query = "SELECT *\n    \t\t\tFROM " . table('lang') . "\n    \t\t\tWHERE content_type='participation_status_internal_name' \n    \t\t\tOR content_type='participation_status_display_name'\n      \t\t\tORDER BY content_name";
        $result = or_query($query);
        while ($line = pdo_fetch_assoc($result)) {
            if ($line['content_type'] == 'participation_status_internal_name') {
                $field = 'internal_name';
            } else {
                $field = 'display_name';
            }
            $participation_statuses[$line['content_name']][$field] = $line[lang('lang')];
        }
    }
    return $participation_statuses;
}
コード例 #11
0
ファイル: expadmin.php プロジェクト: kfarr2/psu-orsee
function admin__select_admin_type($fieldname, $selected = "", $return_var = "type_name", $hide = array())
{
    global $settings, $preloaded_admintypes;
    $out = '';
    if (!isset($preloaded_admintypes) || !is_array($preloaded_admintypes)) {
        $preloaded_admintypes = array();
        $query = "SELECT * from " . table('admin_types') . "\n\t\t\t\tORDER by type_name";
        $result = or_query($query);
        while ($line = pdo_fetch_assoc($result)) {
            $preloaded_admintypes[$line['type_name']] = $line;
        }
    }
    if (!isset($preloaded_admintypes[$selected])) {
        $selected = $settings['default_admin_type'];
    }
    $out .= '<SELECT name="' . $fieldname . '">';
    foreach ($preloaded_admintypes as $line) {
        if (!in_array($line['type_id'], $hide)) {
            $out .= '<OPTION value="' . $line[$return_var] . '"';
            if ($line[$return_var] == $selected || $line['type_name'] == $selected) {
                $out .= ' SELECTED';
            }
            $out .= '>' . $line['type_name'] . '</OPTION>';
        }
    }
    $out .= '</SELECT>';
    return $out;
}
コード例 #12
0
ファイル: calendar.php プロジェクト: danorama/orsee
function calendar__get_user_for_ics_token($icstoken)
{
    $pars = array(':icstoken' => $icstoken);
    $query = "SELECT * FROM " . table('admin') . " WHERE MD5(concat(admin_id,'|-|',password_crypt))=:icstoken";
    $result = or_query($query, $pars);
    $admin = false;
    while ($line = pdo_fetch_assoc($result)) {
        $admin = $line;
    }
    return $admin;
}
コード例 #13
0
ファイル: pdfoutput.php プロジェクト: kfarr2/psu-orsee
function pdfoutput__make_part_list($experiment_id, $session_id = "", $pstatus = "", $focus = "", $sort = "", $file = false, $tlang = "")
{
    global $settings;
    if ($tlang == "") {
        global $lang;
    } else {
        $lang = load_language($tlang);
    }
    $experiment = orsee_db_load_array("experiments", $experiment_id, "experiment_id");
    $pstatuses = expregister__get_participation_statuses();
    if ($session_id) {
        $clause = "session_id = '" . $session_id . "'";
        $title = lang('registered_subjects');
    } elseif (isset($pstatuses[$pstatus])) {
        $clause = "pstatus_id = '" . $pstatus . "'";
        if ($pstatus == 0) {
            $clause .= " AND session_id != 0";
        }
        $title = lang('subjects_in_participation_status') . ' "' . $pstatuses[$pstatus]['internal_name'] . '"';
    } elseif ($focus == 'enroled') {
        $clause = "session_id != 0";
        $title = lang('registered_subjects');
    }
    $cols = participant__get_result_table_columns('session_participants_list_pdf');
    if ($session_id) {
        unset($cols['session_id']);
    }
    // load sessions of this experiment
    $pars = array(':experiment_id' => $experiment_id);
    $query = "SELECT *\n\t\t\tFROM " . table('sessions') . "\n\t\t\tWHERE experiment_id= :experiment_id\n\t\t\tORDER BY session_start";
    $result = or_query($query, $pars);
    global $thislist_sessions;
    $thislist_sessions = array();
    while ($line = pdo_fetch_assoc($result)) {
        $thislist_sessions[$line['session_id']] = $line;
    }
    // load participant data for this session/experiment
    $pars = array(':experiment_id' => $experiment_id);
    $select_query = "SELECT * FROM " . table('participate_at') . ", " . table('participants') . "  \n\t\t\t\t\tWHERE " . table('participate_at') . ".experiment_id= :experiment_id\n\t\t\t\t\tAND " . table('participate_at') . ".participant_id=" . table('participants') . ".participant_id\n\t\t\t\t\tAND (" . $clause . ")";
    $order = query__get_sort('session_participants_list_pdf', $sort);
    if (!$order) {
        $order = table('participants') . ".participant_id";
    }
    $select_query .= " ORDER BY " . $order;
    // get result
    $result = or_query($select_query, $pars);
    $participants = array();
    while ($line = pdo_fetch_assoc($result)) {
        $participants[] = $line;
    }
    $result_count = count($participants);
    // load sessions of this experiment
    $pars = array(':texperiment_id' => $experiment_id);
    $squery = "SELECT *\n            FROM " . table('sessions') . "\n\t\t\tWHERE experiment_id= :texperiment_id \n            ORDER BY session_start";
    $result = or_query($squery, $pars);
    $thislist_sessions = array();
    while ($line = pdo_fetch_assoc($result)) {
        $thislist_sessions[$line['session_id']] = $line;
    }
    // reorder by session date if ordered by session id
    if ($sort == "session_id") {
        $temp_participants = $participants;
        $participants = array();
        foreach ($thislist_sessions as $sid => $s) {
            foreach ($temp_participants as $p) {
                if ($p['session_id'] == $sid) {
                    $participants[] = $p;
                }
            }
        }
    }
    unset($temp_participants);
    // determine table title
    $table_title = $experiment['experiment_public_name'];
    if ($session_id) {
        $table_title .= ', ' . lang('session') . ' ' . str_replace("&nbsp;", " ", session__build_name($thislist_sessions[$session_id]));
    }
    $table_title .= ' - ' . $title;
    // determine table headings
    $table_headings = participant__get_result_table_headcells_pdf($cols);
    $table_data = array();
    $pnr = 0;
    foreach ($participants as $p) {
        $pnr++;
        $p['order_number'] = $pnr;
        $row = participant__get_result_table_row_pdf($cols, $p);
        $table_data[] = $row;
    }
    // prepare pdf
    include_once '../tagsets/class.ezpdf.php';
    $pdf = new Cezpdf('a4', 'landscape');
    $pdf->selectFont('../tagsets/fonts/Times-Roman.afm');
    $fontsize = $settings['participant_list_pdf_table_fontsize'] ? $settings['participant_list_pdf_table_fontsize'] : 10;
    $titlefontsize = $settings['participant_list_pdf_title_fontsize'] ? $settings['participant_list_pdf_title_fontsize'] : 12;
    $y = $pdf->ezTable($table_data, $table_headings, $table_title, array('gridlines' => 31, 'showHeadings' => 1, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.9, 0.9, 0.9), 'fontSize' => $fontsize, 'titleFontSize' => $titlefontsize, 'rowGap' => 1, 'colGap' => 3, 'innerLineThickness' => 0.5, 'outerLineThickness' => 1, 'maxWidth' => 800, 'width' => 800, 'protectRows' => 2));
    if ($file) {
        $pdffilecode = $pdf->output();
        return $pdffilecode;
    } else {
        $pdf->ezStream(array('Content-Disposition' => 'participant_list.pdf', 'Accept-Ranges' => 0, 'compress' => 1));
    }
}
コード例 #14
0
ファイル: updownloads.php プロジェクト: bgreiner/orsee
function downloads__list_experiments($showsize = false, $showtype = false, $showdate = false)
{
    global $lang, $color, $expadmindata;
    $out = '';
    $continue = true;
    if (check_allow('file_view_experiment_all')) {
        $experimenter_clause = '';
        $pars = array();
    } elseif (check_allow('file_view_experiment_my')) {
        $experimenter_clause = " AND " . table('experiments') . ".experimenter LIKE :experimenter ";
        $pars = array(':experimenter' => '%|' . $expadmindata['admin_id'] . '|%');
    } else {
        $continue = false;
    }
    if ($continue) {
        $query = "SELECT " . table('experiments') . ".*,\n                (SELECT min(session_start) from or_sessions as s1 WHERE s1.experiment_id=" . table('experiments') . ".experiment_id) as first_session_date,\n                (SELECT max(session_start) from or_sessions as s2 WHERE s2.experiment_id=" . table('experiments') . ".experiment_id) as last_session_date\n                FROM " . table('experiments') . "\n                WHERE " . table('experiments') . ".experiment_id IN\n                (SELECT DISTINCT experiment_id FROM " . table('uploads') . ")\n                " . $experimenter_clause . "\n                ORDER BY last_session_date DESC";
        $result = or_query($query, $pars);
        $experiments = array();
        while ($line = pdo_fetch_assoc($result)) {
            $experiments[] = $line;
        }
        if (count($experiments) > 0) {
            $out .= '<TABLE width=100% border=0>';
            $shade = true;
            foreach ($experiments as $exp) {
                if ($shade) {
                    $bgcolor = ' bgcolor="' . $color['list_shade1'] . '"';
                    $shade = false;
                } else {
                    $bgcolor = ' bgcolor="' . $color['list_shade2'] . '"';
                    $shade = true;
                }
                $out .= '<TR' . $bgcolor . '><TD>';
                $out .= $exp['experiment_name'] . '</TD><TD>(';
                $out .= lang('from') . ' ';
                if ($exp['first_session_date'] == 0) {
                    $out .= '???';
                } else {
                    $out .= ortime__format(ortime__sesstime_to_unixtime($exp['first_session_date']), 'hide_time:true');
                }
                $out .= ' ' . lang('to') . ' ';
                if ($exp['last_session_date'] == 0) {
                    $out .= '???';
                } else {
                    $out .= ortime__format(ortime__sesstime_to_unixtime($exp['last_session_date']), 'hide_time:true');
                }
                $out .= ')</TD><TD>';
                $out .= experiment__list_experimenters($exp['experimenter'], true, true);
                $out .= '</TD><TD><A HREF="download_main.php?experiment_id=' . $exp['experiment_id'] . '">' . lang('show_files') . '</A>';
                $out .= '</TD></TR>';
            }
            $out .= '</TABLE>';
        }
    }
    return $out;
}
コード例 #15
0
ファイル: experimentmail.php プロジェクト: danorama/orsee
function experimentmail__send_participant_statistics()
{
    global $lang, $settings;
    $now = time();
    $from = $settings['support_mail'];
    $headers = "From: " . $from . "\r\n";
    // remember the current language for later reset
    $old_lang = lang('lang');
    // preload details with current language
    $maillang = $old_lang;
    $statistics = stats__get_textstats_for_email();
    $subject = load_language_symbol('subject_pool_statistics', $maillang) . ' ' . ortime__format($now, 'hide_time:true');
    // get experimenters who want to receive the statistics
    $query = "SELECT *\n            FROM " . table('admin') . "\n            WHERE get_statistics_mail='y'\n            AND disabled='n'\n            ORDER BY language";
    $result = or_query($query);
    $i = 0;
    $rec_count = pdo_num_rows($result);
    while ($admin = pdo_fetch_assoc($result)) {
        if ($admin['language'] != $maillang) {
            $maillang = $admin['language'];
            $lang = load_language($maillang);
            $statistics = stats__get_textstats_for_email();
            $subject = load_language_symbol('subject_pool_statistics', $maillang) . ' ' . ortime__format($now, 'hide_time:true', $maillang);
        }
        $mailtext = load_mail("admin_participant_statistics_mailtext", $maillang) . "\n\n" . $statistics . "\n" . experimentmail__get_admin_footer($maillang, $admin) . "\n";
        $message = process_mail_template($mailtext, $admin);
        $done = experimentmail__mail($admin['email'], $subject, $message, $headers);
        if ($done) {
            $i++;
        }
    }
    // reset language
    if ($maillang != $old_lang) {
        $lang = load_language($old_lang);
    }
    return "statistics sent to " . $i . " out of " . $rec_count . " administrators\n";
}
コード例 #16
0
ファイル: payments.php プロジェクト: kfarr2/psu-orsee
function payments__get_default_budget($experiment = array(), $session = array())
{
    $continue = true;
    if ($continue) {
        if (is_array($session) && isset($session['payment_budgets'])) {
            $budgets = db_string_to_id_array($session['payment_budgets']);
            if (count($budgets) > 0) {
                $continue = false;
                return $budgets[0];
            }
        }
    }
    if ($continue) {
        if (is_array($experiment) && isset($experiment['payment_budgets'])) {
            $budgets = db_string_to_id_array($experiment['payment_budgets']);
            if (count($budgets) > 0) {
                $continue = false;
                return $budgets[0];
            }
        }
    }
    if ($continue) {
        $budgets = payments__load_budgets(true);
        ksort($budgets);
        $first = true;
        foreach ($budgets as $k => $budget) {
            if ($first) {
                return $k;
                $first = false;
            }
        }
    }
    if ($continue) {
        $query = "SELECT * FROM " . table('budgets') . " \n\t\t\t\tORDER BY budget_id\n\t\t\t\tLIMIT 1";
        $result = or_query($query);
        $line = pdo_fetch_assoc($result);
        return $line['budget_id'];
    }
}
コード例 #17
0
ファイル: data_import.php プロジェクト: kfarr2/orsee
function copy_table($table, $idvar, $cond = "", $delete = true)
{
    global $do_delete, $do_insert, $new_db_name, $old_db_name;
    $dquery = "DELETE FROM " . $new_db_name . "." . table($table) . "";
    if ($do_delete && $delete) {
        $done = or_query($dquery);
    }
    $squery = "SELECT * FROM " . $old_db_name . "." . table($table);
    if ($cond) {
        $squery .= ' ' . $cond;
    }
    $result = or_query($squery);
    while ($line = pdo_fetch_assoc($result)) {
        $line = convert_array_to_UTF8($line);
        if ($do_insert) {
            $done = orsee_db_save_array($line, $table, $line[$idvar], $idvar);
        }
    }
}
コード例 #18
0
ファイル: query.php プロジェクト: danorama/orsee
function query__load_saved_queries($type, $limit = -1, $experiment_id = 0, $details = false, $order = "query_time DESC")
{
    // type can be participants_search_active, participants_search_all, assign, deassign
    $conditions = array();
    if ($type) {
        $types = explode(",", $type);
        $tqueries = array();
        foreach ($types as $t) {
            $tqueries[] = "query_type='" . trim($t) . "'";
        }
        $conditions[] = "( " . implode(' OR ', $tqueries) . " )";
    }
    if ($experiment_id) {
        $conditions[] = "( experiment_id='" . $experiment_id . "' )";
    }
    $query = "SELECT * FROM " . table('queries');
    if (count($conditions) > 0) {
        $query .= " WHERE " . implode(" AND ", $conditions);
    }
    $query .= " ORDER BY " . $order;
    if ($limit > 0) {
        $query .= " LIMIT " . $limit;
    }
    $result = or_query($query);
    $queries = array();
    while ($q = pdo_fetch_assoc($result)) {
        if ($details) {
            $q['properties'] = db_string_to_property_array($q['properties']);
            $queries[] = $q;
        } else {
            $queries[] = $q['json_query'];
        }
    }
    return $queries;
}
コード例 #19
0
ファイル: participant.php プロジェクト: danorama/orsee
function participant__load_participants_for_ids($ids = array())
{
    $participants = array();
    if (count($ids) > 0) {
        $par_array = id_array_to_par_array($ids);
        $query = "SELECT * FROM " . table('participants') . "\n                WHERE participant_id IN (" . implode(',', $par_array['keys']) . ")";
        $result = or_query($query, $par_array['pars']);
        while ($line = pdo_fetch_assoc($result)) {
            $participants[$line['participant_id']] = $line;
        }
    }
    return $participants;
}
コード例 #20
0
ファイル: mailqueue.php プロジェクト: danorama/orsee
function mailqueue__show_mailqueue($experiment_id = "", $limit = -1)
{
    global $lang, $color, $options, $proceed;
    if ($proceed) {
        $pars = array();
        if ($limit == -1 && $experiment_id && isset($options['mailqueue_experiment_number_of_entries_per_page']) && $options['mailqueue_experiment_number_of_entries_per_page']) {
            $limit = $options['mailqueue_experiment_number_of_entries_per_page'];
        } elseif ($limit == -1 && isset($options['mailqueue_number_of_entries_per_page']) && $options['mailqueue_number_of_entries_per_page']) {
            $limit = $options['mailqueue_number_of_entries_per_page'];
        } else {
            $limit = 100;
        }
        if (isset($_REQUEST['os']) && $_REQUEST['os'] > 0) {
            $offset = $_REQUEST['os'];
        } else {
            $offset = 0;
        }
        if ($experiment_id) {
            $equery = " AND experiment_id=:experiment_id ";
            $pars[':experiment_id'] = $experiment_id;
        } else {
            $equery = "";
        }
        if (isset($_REQUEST['deleteall']) && $_REQUEST['deleteall']) {
            $dall = true;
        } else {
            $dall = false;
        }
        if (isset($_REQUEST['deleteallonpage']) && $_REQUEST['deleteallonpage']) {
            $dallpage = true;
        } else {
            $dallpage = false;
        }
        if (isset($_REQUEST['deletesel']) && $_REQUEST['deletesel']) {
            $dsel = true;
        } else {
            $dsel = false;
        }
    }
    if ($proceed) {
        if ($dall || $dallpage || $dsel) {
            if ($experiment_id) {
                $allow = check_allow('mailqueue_edit_experiment', 'experiment_mailqueue_show?experiment_id=' . $experiment_id);
            } else {
                $allow = check_allow('mailqueue_edit_all', 'mailqueue_show.php');
            }
            $where_clause = " WHERE mail_id IS NOT NULL " . $equery;
            $ok = false;
            if ($dall) {
                $ok = true;
            }
            if ($dallpage) {
                $tallids = array();
                if (isset($_REQUEST['allids']) && trim($_REQUEST['allids'])) {
                    $tallids = explode(",", trim($_REQUEST['allids']));
                }
                if (count($tallids) > 0) {
                    $i = 0;
                    $parnames = array();
                    foreach ($tallids as $id) {
                        $i++;
                        $tparname = ':mailid' . $i;
                        $parnames[] = $tparname;
                        $pars[$tparname] = $id;
                    }
                    $where_clause .= " AND mail_id IN (" . implode(",", $parnames) . ") ";
                    $ok = true;
                } else {
                    message(lang('error__mailqueue_delete_no_emails_selected'));
                    $ok = false;
                }
            }
            if ($dsel) {
                $dids = array();
                if (isset($_REQUEST['del']) && is_array($_REQUEST['del'])) {
                    foreach ($_REQUEST['del'] as $k => $v) {
                        if ($v == 'y') {
                            $dids[] = $k;
                        }
                    }
                }
                if (count($dids) > 0) {
                    $i = 0;
                    $parnames = array();
                    foreach ($dids as $id) {
                        $i++;
                        $tparname = ':mailid' . $i;
                        $parnames[] = $tparname;
                        $pars[$tparname] = $id;
                    }
                    $where_clause .= " AND mail_id IN (" . implode(",", $parnames) . ") ";
                    $ok = true;
                } else {
                    message(lang('error__mailqueue_delete_no_emails_selected'));
                    $ok = false;
                }
            }
            if ($ok) {
                $query = "DELETE FROM " . table('mail_queue') . $where_clause;
                //echo $query;
                $done = or_query($query, $pars);
                $number = pdo_num_rows($done);
                message($number . ' ' . lang('xxx_emails_deleted_from_queue'));
                if ($experiment_id) {
                    if ($number > 0) {
                        log__admin("mailqueue_delete_entries", "Experiment: " . $experiment_id . ", Count: " . $number);
                    }
                } else {
                    if ($number > 0) {
                        log__admin("mailqueue_delete_entries", "Count: " . $number);
                    }
                }
            }
            if ($experiment_id) {
                redirect("admin/experiment_mailqueue_show.php?experiment_id=" . $experiment_id);
            } else {
                redirect("admin/mailqueue_show.php");
            }
        }
    }
    if ($proceed) {
        $pars = array();
        if ($experiment_id) {
            $equery = " AND experiment_id=:experiment_id ";
            $pars[':experiment_id'] = $experiment_id;
        } else {
            $equery = "";
        }
        $pars[':offset'] = $offset;
        $pars[':limit'] = $limit;
        $query = "SELECT * FROM " . table('mail_queue') . "\n        WHERE mail_id IS NOT NULL " . $equery . " ORDER BY timestamp DESC\n        LIMIT :offset , :limit";
        $result = or_query($query, $pars);
        $num_rows = pdo_num_rows($result);
        if ($experiment_id && check_allow('mailqueue_edit_experiment')) {
            echo '<FORM action="experiment_mailqueue_show.php" method="POST">
            <INPUT type="hidden" name="experiment_id" value="' . $experiment_id . '">';
        } elseif (check_allow('mailqueue_edit_all')) {
            echo '<FORM action="mailqueue_show.php" method="POST">';
        }
        echo '<TABLE width=90% border=0>
        <TR><TD width=50%>';
        //echo '<FONT class="small">'.lang('query').': '.$query.'</FONT><BR><BR>';
        echo '&nbsp;</TD>
        <TD align=right width=50%>';
        if (check_allow('mailqueue_edit_all')) {
            echo '
            <TABLE width="100%" border="0">
            <TR><TD width="33%" align="right">
            <input class="button" type=submit name="deleteall" value="' . lang('delete_all') . '">
            </TD><TD width="33%" align="right">
            <input class="button" type=submit name="deleteallonpage" value="' . lang('delete_all_on_page') . '">
            </TD><TD width="33%" align="right">
            <input class="button" type=submit name="deletesel" value="' . lang('delete_selected') . '">
            </TD></TR>
            </TABLE>
            ';
        }
        echo '</TD></TR></TABLE>';
        if ($offset > 0) {
            echo '[' . log__link('os=' . ($offset - $limit)) . lang('previous') . '</A>]';
        } else {
            echo '[' . lang('previous') . ']';
        }
        echo '&nbsp;&nbsp;';
        if ($num_rows >= $limit) {
            echo '[' . log__link('os=' . ($offset + $limit)) . lang('next') . '</A>]';
        } else {
            echo '[' . lang('next') . ']';
        }
        echo '<TABLE class="or_listtable" style="width: 90%;"><thead>';
        // header
        echo '
        <thead>
        <TR style="background: ' . $color['list_header_background'] . '; color: ' . $color['list_header_textcolor'] . ';">
        <TD>' . lang('id') . '</TD>
        <TD>' . lang('date_and_time') . '</TD>
        <TD>' . lang('email_type') . '</TD>
        <TD>' . lang('email_recipient') . '</TD>
        <TD>' . lang('reference') . '</TD>
        <TD>' . lang('error') . '</TD>';
        if (check_allow('mailqueue_edit_all')) {
            echo '<TD>
            ' . lang('select_all') . '
            <INPUT id="selall" type="checkbox" name="selall" value="y">
            <script language="JavaScript">
                $("#selall").change(function() {
                    if (this.checked) {
                        $("input[name*=\'del[\']").each(function() {
                            this.checked = true;
                        });
                    } else {
                        $("input[name*=\'del[\']").each(function() {
                            this.checked = false;
                        });
                    }
                });
            </script>
        </TD>';
        }
        echo '
          </TR>
          </thead>
          <tbody>
        ';
        $shade = false;
        $ids = array();
        $experiment_ids = array();
        $entries = array();
        while ($line = pdo_fetch_assoc($result)) {
            $ids[] = $line['mail_id'];
            if ($line['experiment_id']) {
                $experiment_ids[] = $line['experiment_id'];
            }
            $entries[] = $line;
        }
        $experiments = experiment__load_experiments_for_ids($experiment_ids);
        foreach ($entries as $line) {
            echo '<TR';
            if ($shade) {
                $shade = false;
            } else {
                $shade = true;
            }
            if ($shade) {
                echo ' bgcolor="' . $color['list_shade1'] . '"';
            } else {
                echo ' bgcolor="' . $color['list_shade2'] . '"';
            }
            echo '>
            <TD>' . $line['mail_id'] . '</TD>
            <TD>' . ortime__format($line['timestamp'], 'hide_second:false', lang('lang')) . '</TD>
            <TD>' . $line['mail_type'] . '</TD>
            <TD>' . $line['mail_recipient'] . '</TD>
            <TD>';
            $reference = array();
            if ($line['experiment_id']) {
                $reference[] = 'Experiment: <A HREF="experiment_show.php?experiment_id=' . $line['experiment_id'] . '">' . $experiments[$line['experiment_id']]['experiment_name'] . '</A>';
            }
            if ($line['session_id']) {
                $reference[] = 'Session: <A HREF="session_edit.php?session_id=' . $line['session_id'] . '">' . $line['session_id'] . '</A>';
            }
            if ($line['bulk_id']) {
                $reference[] = 'Bulk email: ' . $line['bulk_id'];
            }
            echo implode('<BR>', $reference);
            echo '</TD>
            <TD>' . $line['error'] . '</TD>';
            if (check_allow('mailqueue_edit_all')) {
                echo '<TD><INPUT type="checkbox" name="del[' . $line['mail_id'] . ']" value="y"></TD';
            }
            echo '</TR>';
        }
        echo '</tbody></TABLE>';
        if (check_allow('mailqueue_edit_all')) {
            echo '<INPUT type="hidden" name="allids" value="' . implode(",", $ids) . '">';
            echo '</FORM>';
        }
        return $num_rows;
    }
}
コード例 #21
0
ファイル: email.php プロジェクト: bgreiner/orsee
function email__get_count($col, $id, $assigned_to = 0)
{
    $pars = array();
    $conditions = array();
    $conditions[] = "thread_id = message_id";
    $conditions[] = "flag_deleted = 0";
    if ($col) {
        $pars[':id'] = $id;
        $conditions[] = $col . " = :id";
    }
    if ($assigned_to) {
        $ass_clause = query__get_experimenter_or_clause(array($assigned_to), 'emails', 'assigned_to');
        $conditions[] = $ass_clause['clause'];
        foreach ($ass_clause['pars'] as $k => $v) {
            $pars[$k] = $v;
        }
    }
    $query = "SELECT flag_processed, count(*) as num_emails\n            FROM " . table('emails') . "\n            WHERE " . implode(" AND ", $conditions) . "\n            GROUP BY flag_processed ";
    $result = or_query($query, $pars);
    $nums = array('num_all' => 0, 'num_new' => 0);
    while ($line = pdo_fetch_assoc($result)) {
        if ($line['flag_processed']) {
            $nums['num_all'] = $line['num_emails'];
        } else {
            $nums['num_new'] = $line['num_emails'];
        }
    }
    $nums['num_all'] = $nums['num_all'] + $nums['num_new'];
    return $nums;
}
コード例 #22
0
ファイル: stats.php プロジェクト: danorama/orsee
function stats__get_participant_action_data($months_backward = 12)
{
    global $lang, $settings;
    $actions = array('subscribe', 'confirm', 'edit', 'delete');
    if (isset($settings['stats_months_backward']) && $settings['stats_months_backward'] > 0) {
        $months_backward = $settings['stats_months_backward'];
    }
    // titles ect ...
    $d['xname'] = lang('month');
    $d['yname'] = lang('count');
    $d['title'] = lang('participant_actions');
    $d['charttype'] = 'multibars';
    $d['type_of_data'] = 'count';
    $d['column_names'] = array();
    foreach ($actions as $action) {
        $d['column_names'][$action] = lang($action);
    }
    // the data
    //first get the stuff from the database
    $nums = array();
    $first_date_unixtime = strtotime("-" . $months_backward . " month", time());
    $query = "SELECT action, date_format(FROM_UNIXTIME(timestamp),'%Y%m') as yearmonth,\n            count(log_id) as nractions\n            FROM " . table('participants_log') . "\n            WHERE date_format(FROM_UNIXTIME(timestamp),'%Y%m')>=date_format(FROM_UNIXTIME(" . $first_date_unixtime . "),'%Y%m')\n            AND action IN ('" . implode("','", $actions) . "')\n            GROUP BY action, yearmonth\n            ORDER BY timestamp DESC";
    $result = or_query($query);
    while ($line = pdo_fetch_assoc($result)) {
        $nums[$line['action']][$line['yearmonth']] = $line['nractions'];
    }
    $d['value_names'] = array();
    foreach ($nums as $action => $months) {
        foreach ($months as $month => $count) {
            $d['value_names'][$month] = $month;
        }
    }
    krsort($d['value_names']);
    foreach ($d['value_names'] as $k => $v) {
        $d['value_names'][$k] = substr($v, 4, 2) . '/' . substr($v, 2, 2);
    }
    $d['data'] = $nums;
    return $d;
}
コード例 #23
0
ファイル: sessions.php プロジェクト: kfarr2/psu-orsee
function sessions__load_sessions_for_ids($ids = array())
{
    $sessions = array();
    if (count($ids) > 0) {
        $par_array = id_array_to_par_array($ids);
        $query = "SELECT * FROM " . table('sessions') . "\n\t\t\t\tWHERE session_id IN (" . implode(',', $par_array['keys']) . ")";
        $result = or_query($query, $par_array['pars']);
        while ($line = pdo_fetch_assoc($result)) {
            $sessions[$line['session_id']] = $line;
        }
    }
    return $sessions;
}
コード例 #24
0
         <tbody>';
 $num_cols = count($cols) + 1;
 foreach ($dupvals as $dv) {
     $mvals = array();
     $pars = array();
     $qclause = array();
     foreach ($columns as $c) {
         $mvals[] = $field_names[$c] . ': ' . $dv[$c];
         $pars[':' . $c] = $dv[$c];
         $qclause[] = ' ' . $c . ' = :' . $c . ' ';
     }
     echo '<TR><TD colspan="' . $num_cols . '"><B>' . implode(", ", $mvals) . '</B></TD></TR>';
     $query = "SELECT * FROM " . table('participants') . "\n                        WHERE " . implode(" AND ", $qclause) . "\n                        ORDER BY creation_time";
     $result = or_query($query, $pars);
     $shade = false;
     while ($p = pdo_fetch_assoc($result)) {
         echo '<tr class="small"';
         if ($shade) {
             echo ' bgcolor="' . $color['list_shade1'] . '"';
         } else {
             echo 'bgcolor="' . $color['list_shade2'] . '"';
         }
         echo '>';
         echo '<TD bgcolor="' . $color['content_background_color'] . '"></TD>';
         echo participant__get_result_table_row($cols, $p);
         echo '</tr>';
         if ($shade) {
             $shade = false;
         } else {
             $shade = true;
         }
コード例 #25
0
ファイル: orsee_mysql.php プロジェクト: kfarr2/psu-orsee
function orsee_db_save_array($array, $table, $key, $keyname)
{
    global $site__database_database;
    // find out which fields i can save
    $query = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS \n\t\t\tWHERE table_name= :table \n\t\t\tAND table_schema = :table_schema";
    $pars = array(':table' => table($table), 'table_schema' => $site__database_database);
    $result = or_query($query, $pars);
    $columns = array();
    while ($line = pdo_fetch_assoc($result)) {
        $columns[] = $line['COLUMN_NAME'];
    }
    // delete key
    if (isset($array[$keyname])) {
        unset($array[$keyname]);
    }
    $arraykeys = array_keys($array);
    $fields_to_save = array_intersect($arraykeys, $columns);
    // build set phrase and param array
    $first = true;
    $set_phrase = "";
    $pars = array();
    foreach ($fields_to_save as $field) {
        if ($first) {
            $first = false;
        } else {
            $set_phrase = $set_phrase . ", ";
        }
        $set_phrase = $set_phrase . $field . "=:" . $field;
        $pars[':' . $field] = $array[$field];
    }
    $pars[':key'] = $key;
    // check if already saved
    $query = "SELECT " . $keyname . " FROM " . table($table) . " WHERE " . $keyname . "=:key";
    $result = or_query($query, array(':key' => $key));
    $num_rows = pdo_num_rows($result);
    if ($num_rows > 0) {
        // update query
        $query = "UPDATE " . table($table) . " SET " . $set_phrase . " WHERE " . $keyname . "=:key";
    } else {
        // insert query
        $query = "INSERT INTO " . table($table) . " SET " . $keyname . "=:key, " . $set_phrase;
    }
    $result = or_query($query, $pars);
    return $result;
}
コード例 #26
0
ファイル: cronjobs.php プロジェクト: kfarr2/psu-orsee
function cron__check_for_participant_exclusion()
{
    global $settings;
    $mess = "";
    if ($settings['automatic_exclusion'] == 'y') {
        $status_query = participant_status__get_pquery_snippet("eligible_for_experiments");
        $query = "SELECT * FROM " . table('participants') . " \n               \tWHERE " . $status_query . "  \n               \tAND number_noshowup >= '" . $settings['automatic_exclusion_noshows'] . "'";
        $result = or_query($query);
        $excluded = 0;
        $informed = 0;
        while ($line = pdo_fetch_assoc($result)) {
            $done = participant__exclude_participant($line);
            if ($done == 'informed') {
                $informed++;
            }
            $excluded++;
        }
        if ($excluded > 0) {
            $mess .= "participants excluded: " . $excluded;
        }
        if ($informed > 0) {
            $mess .= "\nparticipants informed: " . $informed;
        }
    }
    return $mess;
}
コード例 #27
0
ファイル: getdata2.php プロジェクト: psnguyen/enqueue
session_start();
include_once "pdo_mysql.php";
$username = '******';
$password = '******';
$host = 'dbserver.engr.scu.edu';
$database = 'sdb_pnguyen';
if (!($server = pdo_connect("{$host}", $username, $password))) {
    die('Error connecting to ' . $host . '.' . pdo_error());
}
if (!($conn = pdo_select_db($database, $server))) {
    die('Error selecting' . $database . '.' . pdo_error());
}
$classID = $_SESSION['classID'];
$timequery = "UPDATE `enqueue` SET `timeSpent` = TIMEDIFF(`TimeOut`, `timeIn`) WHERE `isSolved` = 1";
$tquery = pdo_query($timequery);
if (!$tquery) {
    echo pdo_error();
    //		die;
}
$myquery = "SELECT DISTINCT(`studentName`) as `studentName`, sum(TIME_TO_SEC(`timeSpent`)/60) as `timeCount`\n\t\t\t\tFROM `enqueue`\n\t\t\t\tWHERE `classID` = {$classID}\n\t\t\t\tGROUP BY `studentName`\n\t\t\t\tHAVING `timeCount` > 0";
$query = pdo_query($myquery);
if (!$myquery) {
    echo pdo_error();
    die;
}
$data = array();
for ($x = 0; $x < pdo_num_rows($query); $x++) {
    $data[] = pdo_fetch_assoc($query);
}
echo json_encode($data);
コード例 #28
0
ファイル: faq_main.php プロジェクト: danorama/orsee
 // load languages
 $languages = get_languages();
 echo '<BR><BR>
     <table class="or_listtable" style="width: 80%;"><thead>
     <TR style="background: ' . $color['list_header_background'] . '; color: ' . $color['list_header_textcolor'] . ';">';
 foreach ($languages as $language) {
     echo '<td class="small">' . $language . '</td>';
 }
 echo '<TD>' . lang('this_faq_answered_questions_of_xxx') . '</TD>
         <TD></TD>
         </TR></thead>
             <tbody>';
 $query = "SELECT *\n            FROM " . table('faqs') . ", " . table('lang') . "\n            WHERE content_type='faq_question'\n            AND " . table('faqs') . ".faq_id=" . table('lang') . ".content_name\n            ORDER BY " . lang('lang');
 $result = or_query($query);
 $shade = false;
 while ($line = pdo_fetch_assoc($result)) {
     echo '  <tr class="small"';
     if ($shade) {
         echo ' bgcolor="' . $color['list_shade1'] . '"';
     } else {
         echo ' bgcolor="' . $color['list_shade2'] . '"';
     }
     echo '>';
     foreach ($languages as $language) {
         echo '  <td class="small">' . stripslashes($line[$language]) . '</td>';
     }
     echo '<TD>' . $line['evaluation'] . ' ' . lang('persons') . '</TD>
             <TD><A HREF="faq_edit.php?faq_id=' . $line['faq_id'] . '">' . lang('edit') . '</A>
             </TD>
             </tr>';
     if ($shade) {
コード例 #29
0
ファイル: logfunctions.php プロジェクト: danorama/orsee
function log__show_log($log)
{
    global $limit;
    if (!$limit) {
        $limit = 50;
    }
    if (isset($_REQUEST['os']) && $_REQUEST['os'] > 0) {
        $offset = $_REQUEST['os'];
    } else {
        $offset = 0;
    }
    global $lang, $color;
    $pars = array();
    if (isset($_REQUEST['action']) && $_REQUEST['action']) {
        $aquery = " AND action=:action ";
        $pars[':action'] = $_REQUEST['action'];
    } else {
        $aquery = "";
    }
    if (isset($_REQUEST['id']) && $_REQUEST['id']) {
        $idquery = " AND id=:id ";
        $pars[':id'] = $_REQUEST['id'];
    } else {
        $idquery = "";
    }
    if (isset($_REQUEST['target']) && $_REQUEST['target']) {
        $tquery = " AND target LIKE :target ";
        $pars[':target'] = '%' . $_REQUEST['target'] . '%';
    } else {
        $tquery = "";
    }
    $logtable = table('participants_log');
    switch ($log) {
        case "participant_actions":
            $logtable = table('participants_log');
            $secondtable = " LEFT JOIN " . table('participants') . " ON id=participant_id ";
            break;
        case "experimenter_actions":
            $logtable = table('admin_log');
            $secondtable = " LEFT JOIN " . table('admin') . " ON id=admin_id ";
            break;
        case "regular_tasks":
            $logtable = table('cron_log');
            $secondtable = " LEFT JOIN " . table('admin') . " ON id=admin_id ";
            break;
    }
    if (isset($_REQUEST['delete']) && $_REQUEST['delete'] && isset($_REQUEST['days']) && $_REQUEST['days']) {
        $allow = check_allow('log_file_' . $log . '_delete', 'statistics_show_log.php?log=' . $log);
        if (isset($_REQUEST['days']) && $_REQUEST['days'] == "all") {
            $where_clause = "";
        } else {
            $now = time();
            $dsec = (int) $_REQUEST['days'] * 24 * 60 * 60;
            $dtime = $now - $dsec;
            $where_clause = " WHERE timestamp < " . $dtime;
        }
        $query = "DELETE FROM " . $logtable . $where_clause;
        $done = or_query($query);
        $number = pdo_num_rows($done);
        message($number . ' ' . lang('xxx_log_entries_deleted'));
        if ($number > 0) {
            log__admin("log_delete_entries", "log:" . $log . "\ndays:" . $_REQUEST['days']);
        }
        redirect("admin/statistics_show_log.php?log=" . $log);
    }
    $pars[':offset'] = $offset;
    $pars[':limit'] = $limit;
    $query = "SELECT * FROM " . $logtable . $secondtable . "\n        WHERE id IS NOT NULL " . $aquery . $idquery . $tquery . " ORDER BY timestamp DESC\n        LIMIT :offset , :limit ";
    $result = or_query($query, $pars);
    $num_rows = pdo_num_rows($result);
    echo '<TABLE width=80% border=0>
        <TR><TD width=50%>';
    //echo '<FONT class="small">'.lang('query').': '.$query.'</FONT><BR><BR>';
    echo '</TD>
        <TD align=right width=50%>';
    if (check_allow('log_file_' . $log . '_delete')) {
        echo '
            <FORM action="statistics_show_log.php">
            <INPUT type=hidden name="log" value="' . $log . '">
            ' . lang('delete_log_entries_older_than') . '
            <select name="days">
            <option value="all">' . lang('all_entries') . '</option>';
        $ddays = array(1, 7, 30, 90, 180, 360);
        if (isset($_REQUEST['days']) && $_REQUEST['days']) {
            $selected = $_REQUEST['days'];
        } else {
            $selected = 90;
        }
        foreach ($ddays as $day) {
            echo '<option value="' . $day . '"';
            if ($day == $selected) {
                echo ' SELECTED';
            }
            echo '>' . $day . ' ';
            if ($day == 1) {
                echo lang('day');
            } else {
                echo lang('days');
            }
            echo '</option>
                ';
        }
        echo '  </select><input type=submit name="delete" value="' . lang('delete') . '">';
    }
    echo '</TD></TR></TABLE>';
    if ($offset > 0) {
        echo '[' . log__link('os=' . ($offset - $limit)) . lang('previous') . '</A>]';
    } else {
        echo '[' . lang('previous') . ']';
    }
    echo '&nbsp;&nbsp;';
    if ($num_rows >= $limit) {
        echo '[' . log__link('os=' . ($offset + $limit)) . lang('next') . '</A>]';
    } else {
        echo '[' . lang('next') . ']';
    }
    echo '<TABLE class="or_listtable" style="width: 90%;">';
    // header
    echo '<thead>
        <TR style="background: ' . $color['list_header_background'] . '; color: ' . $color['list_header_textcolor'] . ';">
        <TD>
            ' . lang('date_and_time') . '
        </TD>
        <TD>';
    if ($log == 'participant_actions') {
        echo lang('lastname') . ', ' . lang('firstname');
    } elseif ($log == 'experimenter_actions' || $log == 'regular_tasks') {
        echo lang('experimenter');
    }
    if (isset($_REQUEST['id']) && $_REQUEST['id']) {
        echo ' ' . log__link('id=', 'os=0') . '<FONT class="small">[' . lang('unrestrict') . ']</FONT></A>';
    }
    echo '  </TD><TD>' . lang('action');
    if (isset($_REQUEST['action']) && $_REQUEST['action']) {
        echo ' ' . log__link('action=', 'os=0') . '<FONT class="small">[' . lang('unrestrict') . ']</FONT></A>';
    }
    echo '  </TD><TD>' . lang('target');
    if (isset($_REQUEST['target']) && $_REQUEST['target']) {
        echo ' ' . log__link('target=', 'os=0') . '<FONT class="small">[' . lang('unrestrict') . ']</FONT></A>';
    }
    echo '  </TD></TR>
            </thead>
            <tbody>';
    $shade = false;
    while ($line = pdo_fetch_assoc($result)) {
        echo '<tr class="small"';
        if ($shade) {
            echo ' bgcolor="' . $color['list_shade1'] . '"';
        } else {
            echo 'bgcolor="' . $color['list_shade2'] . '"';
        }
        echo '>
            <TD>' . ortime__format($line['timestamp'], 'hide_seconds:false', lang('lang')) . '</TD>
            <TD>';
        if ($log == 'participant_actions') {
            if ($line['participant_id']) {
                echo $line['lname'] . ', ' . $line['fname'] . ' <A HREF="participants_edit.php?participant_id=' . $line['participant_id'] . '"><FONT class="small">[' . lang('edit') . ']</FONT></A>';
            } else {
                echo $line['id'];
            }
        } elseif ($log == 'experimenter_actions' || $log == 'regular_tasks') {
            echo $line['adminname'];
        }
        if (!isset($_REQUEST['id']) || $_REQUEST['id'] != $line['id']) {
            echo ' ' . log__restrict_link('id', $line['id']);
        }
        echo '  </TD><TD>' . $line['action'];
        if (!isset($_REQUEST['action']) || $_REQUEST['action'] != $line['action']) {
            echo ' ' . log__restrict_link('action', $line['action']);
        }
        echo '  </TD><TD>' . nl2br(stripslashes($line['target']));
        if (!isset($_REQUEST['target']) || $_REQUEST['target'] != $line['target'] && $log != 'regular_tasks') {
            echo ' ' . log__restrict_link('target', $line['target']);
        }
        echo '  </TD></TR>';
        if ($shade) {
            $shade = false;
        } else {
            $shade = true;
        }
    }
    echo '</tbody></TABLE>';
    return $num_rows;
}