/** * Debug a cache call to a non-database cache handler * * @param string $string The cache key * @param string $qtime The time it took to perform the call. * @param boolean $hit Hit or miss status */ function debug_call($string, $qtime, $hit) { global $mybb, $plugins; $debug_extra = ''; if ($plugins->current_hook) { $debug_extra = "<div style=\"float_right\">(Plugin Hook: {$plugins->current_hook})</div>"; } if ($hit) { $hit_status = 'HIT'; } else { $hit_status = 'MISS'; } $cache_data = explode(':', $string); $cache_method = $cache_data[0]; $cache_key = $cache_data[1]; $this->cache_debug = "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n<tr>\n\t<td style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#{$this->call_count} - " . ucfirst($cache_method) . " Call</strong></div></td>\n</tr>\n<tr style=\"background-color: #fefefe;\">\n\t<td><span style=\"font-family: Courier; font-size: 14px;\">({$mybb->config['cache_store']}) [{$hit_status}] " . htmlspecialchars_uni($cache_key) . "</span></td>\n</tr>\n<tr>\n\t<td bgcolor=\"#ffffff\">Call Time: " . format_time_duration($qtime) . "</td>\n</tr>\n</table>\n<br />\n"; $this->calllist[$this->call_count]['key'] = $string; $this->calllist[$this->call_count]['time'] = $qtime; }
$pageName = $langUserDuration; $navigation[] = array('url' => 'index.php?course=' . $course_code, 'name' => $langUsage); statistics_tools($course_code, "userduration"); // display number of users $tool_content .= "\n <div class='alert alert-info'>\n <b>{$langDumpUserDurationToFile}: </b>1. <a href='userduration.php?course={$course_code}&format=csv'>{$langcsvenc2}</a>\n 2. <a href='userduration.php?course={$course_code}&format=csv&enc=1253'>{$langcsvenc1}</a>\n </div>"; $tool_content .= "\n <table class='tbl_alt' width='99%'>\n <tr>\n <th class='left'> {$langSurname} {$langName}</th>\n <th>{$langAm}</th>\n <th>{$langGroup}</th>\n <th>{$langDuration}</th>\n </tr>"; } $result = user_duration_query($course_id); if (count($result) > 0) { $i = 0; foreach ($result as $row) { $i++; $grp_name = user_groups($course_id, $row->id, $format); if ($format == 'html') { if ($i % 2 == 0) { $tool_content .= "<tr class='even'>"; } else { $tool_content .= "<tr class='odd'>"; } $tool_content .= "<td class='bullet'>" . display_user($row->id) . "</td>\n <td class='center'>{$row->am}</td>\n <td class='center'>{$grp_name}</td>\n <td class='center'>" . format_time_duration(0 + $row->duration) . "</td>\n </tr>"; } else { echo csv_escape($row->surname . ' ' . $row->givenname), ';', csv_escape($row->am), ';', csv_escape($grp_name), ';', csv_escape(format_time_duration(0 + $row->duration)), $crlf; } } if ($format == 'html') { $tool_content .= "</table>"; } } if ($format == 'html') { draw($tool_content, 2); }
} else { $num_ungraded = '-'; } } $tool_content .= "<tr class='".(!$row->active ? "not_visible":"")."'>"; $deadline = (int)$row->deadline ? nice_format($row->deadline, true) : $m['no_deadline']; $tool_content .= "<td> <a href='../work/index.php?course=$course_code&id={$row->id}'>" . q($row->title) . "</a> <br><small class='text-muted'>".($row->group_submissions? $m['group_work'] : $m['user_work'])."</small> </td> <td class='text-center'>$num_submitted</td> <td class='text-center'>$num_ungraded</td> <td class='text-center'>$deadline"; if ($row->time > 0) { $tool_content .= " <br><span class='label label-warning'><small>$langDaysLeft" . format_time_duration($row->time) . "</small></span>"; } else if((int)$row->deadline){ $tool_content .= " <br><span class='label label-danger'><small>$m[expired]</small></span>"; } $tool_content .= "</td> </tr>"; $index++; } $tool_content .= '</table></div></div></div>'; } } $tool_content .= action_bar(array( array('title' => $langRegIntoGroup, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&registration=1&group_id=$group_id",
function showStaffTotals($option, &$rows, $dateStart, $dateEnd) { JHTML::_('behavior.calendar'); ?> <h2>Staff Totals: <?php echo "{$dateStart} => {$dateEnd}"; ?> </h2> <form action="index.php" method="post" name="adminForm"> <table> <tr> <td align="left" width="100%"> <strong>Filter:</strong> <span style="margin: 0 1em;"> Start Date: <input class="inputbox" type="text" name="dateStart" id="dateStart" size="11" dateStart="10" value="<?php echo $dateStart; ?> " /> <input type="reset" class="button" value="..." onclick="return showCalendar('dateStart','%Y-%m-%d');" /> </span> <span style="margin: 0 1em;"> End Date: <input class="inputbox" type="text" name="dateEnd" id="dateEnd" size="11" maxlength="10" value="<?php echo $dateEnd; ?> " /> <input type="reset" class="button" value="..." onclick="return showCalendar('dateEnd','%Y-%m-%d');" /> </span> <input type="submit" name="Submit" value="Go" /> </td> </tr> </table> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="task" value="showstafftotals" /> </form> <table class="adminlist"> <thead> <tr> <th width="">Name</th> <th width="">Staff Hours</th> <th width=""># Clock-ins</th> <th width="">Longest Clock-in</th> <th width="">Avg Clock-in</th> <th width="">Show Transactions</th> <th width="">Commission Cash</th> <th width="">Commission Credits</th> </tr> </thead> <?php $k = 0; for ($i = 0, $n = count($rows); $i < $n; $i++) { $row =& $rows[$i]; $checked = JHTML::_('grid.id', $i, $row->memberID); $member_name = $row->nameFirst . ' ' . $row->nameLast; $member_link = JFilterOutput::ampReplace('index.php?option=' . $option . '&task=edit&cid[]=' . $row->memberID); $member_link_markup = "<a href=\"{$member_link}\" title=\"{$member_name} edit\">{$member_name}</a>"; // @TODO: use $transactionTypeArray instead of hardcoding "4" $transactions_link = JFilterOutput::ampReplace('index.php?option=' . $option . '&task=transactions&member_id=' . $row->memberID . '&transaction_type=4&dateStart=' . $dateStart . '&dateEnd=' . $dateEnd); $transactions_link_markup = "<a href=\"{$transactions_link}\" title=\"Go to this period's transactions for {$member_name}\">{$row->nameFirst}'s staff transactions</a>"; ?> <tr class="<?php echo "row{$k}"; ?> "> <td> <?php echo $member_link_markup; ?> </td> <td> <?php echo format_time_duration($row->totalTimeSeconds, false); ?> </td> <td> <?php echo $row->clockins; ?> </td> <td> <?php echo format_time_duration($row->longestClockIn, true); ?> </td> <td> <?php echo format_time_duration($row->avgClockIn, true); ?> </td> <td> <?php echo $transactions_link_markup; ?> </td> <td> <?php if ($row->commissionCash) { setlocale(LC_MONETARY, 'en_US'); echo money_format('%n', $row->commissionCash) . ' / 10 = ' . money_format('%n', $row->commissionCash / 10); } ?> </td> <td> <?php echo $row->commissionCredits * -1 . ' / 10 = ' . money_format('%n', $row->commissionCredits / -10); ?> <!--<?php echo $row->commissionCredits; ?> --> </td> </tr> <?php $k = 1 - $k; } ?> </table> <?php }
</div> </div> <div class='row margin-bottom-fat margin-top-fat'> <div class='col-xs-12'> <ul class='list-group'> <li class='list-group-item disabled'> <div class='row'> <div class='col-sm-12'><b>$langDurationVisitsPerCourse</b></div> </div> </li>"; foreach ($duration as $code => $time) { $tool_content .= " <li class='list-group-item'> <div class='row'> <div class='col-sm-8'><b>" . q(course_code_to_title($code)) . "</b></div> <div class='col-sm-4 text-muted'>" . format_time_duration(0 + $time, 240) . "</div> </div> </li>"; } $tool_content .= " </ul> </div> </div>"; } $tool_content .= " <div class='row margin-bottom-fat margin-top-fat'> <div class='col-xs-12'> <ul class='list-group'> <li class='list-group-item disabled'> <div class='row'>
} if ($is_editor) { if (isset($_GET['enc']) and $_GET['enc'] == '1253') { $charset = 'Windows-1253'; } else { $charset = 'UTF-8'; } $crlf = "\r\n"; header("Content-Type: text/csv; charset={$charset}"); header("Content-Disposition: attachment; filename=groupuserduration.csv"); if (isset($_REQUEST['u_date_start']) and isset($_REQUEST['u_date_end'])) { $u_date_start = $_REQUEST['u_date_start']; $u_date_end = $_REQUEST['u_date_end']; } else { $min_date = Database::get()->querySingle("SELECT MIN(day) AS minday FROM actions_daily WHERE course_id = ?d", $course_id)->minday; $u_date_start = strftime('%Y-%m-%d', strtotime($min_date)); $u_date_end = strftime('%Y-%m-%d', strtotime('now')); } if (isset($u_date_start) and isset($u_date_end)) { $first_line = "{$langFrom} {$u_date_start} {$langAs} {$u_date_end}"; } else { $date_spec = ''; } echo csv_escape($first_line), $crlf, $crlf, join(';', array_map("csv_escape", array($langSurname, $langName, $langAm, $langGroup, $langDuration))), $crlf; $totalDuration = 0; $result = user_duration_query($course_id, $u_date_start, $u_date_end, $group_id); foreach ($result as $row) { echo csv_escape($row->surname) . ";" . csv_escape($row->givenname) . ";" . csv_escape($row->am) . ";" . csv_escape($group_name) . ";" . csv_escape(format_time_duration(0 + $row->duration)) . ";" . csv_escape(round($row->duration / 3600)); echo $crlf; } }
<th class='text-center'>" . $langYourTotalScore2 . "</td> <th class='text-center'>" . $langCurrentStatus. "</th> ". ($is_editor ? "<th class='text-center'>" . icon('fa-gears'). "</th>" : "") ." </tr>"; $k = 0; foreach ($result2 as $row2) { // if ($is_editor && $row2->attempt_status == ATTEMPT_PENDING) { // $class .= ' highlight_row'; // } $tool_content .= "<tr>"; $tool_content .= "<td class='text-center'>" . q($row2->record_start_date) . "</td>"; if ($row2->time_duration == '00:00:00' or empty($row2->time_duration)) { // for compatibility $tool_content .= "<td class='center'>$langNotRecorded</td>"; } else { $tool_content .= "<td class='text-center'>" . format_time_duration($row2->time_duration) . "</td>"; } if ($row2->attempt_status == ATTEMPT_COMPLETED) { $results_link = "<a href='exercise_result.php?course=$course_code&eurId=$row2->eurid'>" . q($row2->total_score) . "/" . q($row2->total_weighting) . "</a>"; } else { if ($row2->attempt_status == ATTEMPT_PAUSED) { $results_link = "-/-"; } else { $results_link = q($row2->total_score). "/" . q($row2->total_weighting); } } $tool_content .= "<td class='text-center'>$results_link</td>"; if ($row2->attempt_status == ATTEMPT_COMPLETED) { $status = $langAttemptCompleted; } elseif ($row2->attempt_status == ATTEMPT_PENDING) { $status = "<a href='exercise_result.php?course=$course_code&eurId=$row2->eurid'>" .$langAttemptPending. "</a>";
$i = 0; foreach ($result as $row) { $i++; $grp_name = user_groups($course_id, $row->id, $format); if ($format == 'html') { if ($i % 2 == 0) { $tool_content .= "<tr class='even'>"; } else { $tool_content .= "<tr class='odd'>"; } $tool_content .= "<td class='bullet'>" . display_user($row->id) . "</td> <td class='center'>$row->am</td> <td class='center'>$grp_name</td> <td class='center'>" . format_time_duration(0 + $row->duration) . "</td> </tr>"; } else { echo csv_escape($row->surname . ' ' . $row->givenname), ';', csv_escape($row->am), ';', csv_escape($grp_name), ';', csv_escape(format_time_duration(0 + $row->duration)), $crlf; } } if ($format == 'html') { $tool_content .= "</table>"; } } if ($format == 'html') { draw($tool_content, 2); }
include 'question.class.php'; $exerciseId = $_GET['exerciseId']; $objExercise = new Exercise(); $objExercise->read($exerciseId); $pageName = $langExerciseStats; $navigation[] = array("url" => "index.php?course={$course_code}", "name" => $langExercices); $tool_content .= action_bar(array(array('title' => $langBack, 'level' => 'primary-label', 'icon' => 'fa-reply', 'url' => "index.php?course={$course_code}"))); $completedAttempts = Database::get()->querySingle("SELECT count(*) AS count FROM exercise_user_record WHERE eid = ?d AND attempt_status = ?d", $exerciseId, ATTEMPT_COMPLETED)->count; $pausedAttempts = Database::get()->querySingle("SELECT count(*) AS count FROM exercise_user_record WHERE eid = ?d AND attempt_status = ?d", $exerciseId, ATTEMPT_PAUSED)->count; $pendingAttempts = Database::get()->querySingle("SELECT count(*) AS count FROM exercise_user_record WHERE eid = ?d AND attempt_status = ?d", $exerciseId, ATTEMPT_PENDING)->count; $cancelledAttempts = Database::get()->querySingle("SELECT count(*) AS count FROM exercise_user_record WHERE eid = ?d AND attempt_status = ?d", $exerciseId, ATTEMPT_CANCELED)->count; $total_attempts = $completedAttempts + $pausedAttempts + $pendingAttempts + $cancelledAttempts; $grade_stats = Database::get()->querySingle("SELECT COUNT(DISTINCT uid) AS unique_users, AVG(TIME_TO_SEC(TIMEDIFF(record_end_date, record_start_date))) AS avg_time, AVG(total_score) AS avg_grade, MIN(total_score) AS min_grade, MAX(total_score) AS max_grade FROM exercise_user_record WHERE eid = ?d AND attempt_status = ?d", $exerciseId, ATTEMPT_COMPLETED); $max_grade = $grade_stats->max_grade; $min_grade = $grade_stats->min_grade; $avg_grade = $grade_stats->avg_grade; $avg_time = $grade_stats->avg_time; $unique_users = $grade_stats->unique_users; //average number of attempts //avg completion time $tool_content .= "\n <div class='table-responsive'>\n <table class='table-default'>\n <thead>\n <tr>\n <th colspan='4' class='text-center'>{$langAttempts}</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>{$langAttemptsCompleted}</th>\n <td>{$completedAttempts}</td>\n <td>{$langAttemptsPaused}</th>\n <td>{$pausedAttempts}</td> \n </tr>\n <tr>\n <td>{$langAttemptPending}</th>\n <td>{$pendingAttempts}</td>\n <td>{$langAttemptsCanceled}</th>\n <td>{$cancelledAttempts}</td> \n </tr>\n </tbody>\n <tfoot>\n <tr class='active'>\n <th colspan='3'>{$langTotal}:</th>\n <th colspan='1'>{$total_attempts}</th>\n </tr> \n </tfoot>\n </table>\n </div>\n <div class='table-responsive'>\n <table class='table-default'>\n <thead>\n <tr>\n <th colspan='2' class='text-center'>{$langScore}</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>{$langHighestGrade}</th>\n <td>{$max_grade}</td>\n \n </tr>\n <tr>\n <td>{$langLowestGrade}</th>\n <td>{$min_grade}</td> \n </tr>\n <tr>\n <td>{$langRatingAverage}</th>\n <td>{$avg_grade}</td> \n </tr> \n </tbody>\n </table>\n </div>\n <div class='table-responsive'>\n <table class='table-default'>\n <thead>\n <tr>\n <th colspan='2' class='text-center'>{$langStudents}</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>{$langStudentsExerciseCompleted}</th>\n <td>{$unique_users}</td> \n </tr> \n <tr>\n <td>{$langAverage} {$langExerciseDuration}</th>\n <td>" . format_time_duration($avg_time) . "</td> \n </tr> \n </tbody>\n </table>\n </div>"; //Questions Table $questionList = $objExercise->selectQuestionList(); $tool_content .= "\n <h3>{$langQuestions}</h3>\n <div class='table-responsive'>\n <table class='table-default'>\n <thead>\n <tr>\n <th>{$langTitle}</th>\n <th>Ποσοστό Επιτυχίας</th>\n </tr>\n </thead>\n <tbody>"; foreach ($questionList as $id) { $objQuestionTmp = new Question(); $objQuestionTmp->read($id); $tool_content .= "\n <tr>\n <td>" . $objQuestionTmp->selectTitle() . "</th>\n <td>\n <div class='progress'>\n <div class='progress-bar progress-bar-success progress-bar-striped' role='progressbar' aria-valuenow='" . $objQuestionTmp->successRate($exerciseId) . "' aria-valuemin='0' aria-valuemax='100' style='width: " . $objQuestionTmp->successRate($exerciseId) . "%;'>\n " . $objQuestionTmp->successRate($exerciseId) . "%\n </div>\n </div></td> \n </tr>"; } $tool_content .= "\n </tbody>\n </table>\n </div>"; draw($tool_content, 2, null, $head_content);
$duration[$code] = $result->duration; $totalDuration += $duration[$code]; } $chart = new Plotter(600, 300); $chart->setTitle($langCourseVisits); foreach ($hits as $code => $count) { if ($count > 0) { $chart->addPoint($course_names[$code], $count); $chart->modDimension(7, 0); } } $tool_content .= $chart->plot(); $totalDuration = format_time_duration(0 + $totalDuration); $tool_content .= "<fieldset>\n <legend>{$langPlatformGenStats}</legend>\n <table class='table-default'>\n <tr>\n <th>{$langTotalVisitsCourses}:</th>\n <td>{$totalHits}</td>\n </tr>\n <tr>\n <th>{$langDurationVisits}:</th>\n <td>{$totalDuration}</td>\n </tr>\n <tr>\n <th valign='top'>{$langDurationVisitsPerCourse}:</th>\n <td>\n <table class='table-default' width='550'>\n <tr>\n <th>{$langCourseTitle}</th> \n <th width='160'>{$langDuration}</th>\n </tr>"; foreach ($duration as $code => $time) { $tool_content .= " \n <td>" . q(course_code_to_title($code)) . "</td>\n <td width='140'>" . format_time_duration(0 + $time) . "</td>\n </tr>"; } $tool_content .= "</table></td></tr>"; } // End of chart display; chart unlinked at end of script. $tool_content .= "<tr><th>{$langLastVisits}:</th><td>"; $tool_content .= "<table class='table-default' width='550'>\n <tr>\n <th>{$langDate}</th>\n <th width='140'>{$langAction}</th>\n </tr>"; $act["LOGIN"] = "******"; $act["LOGOUT"] = "<font color='#FF0000'>{$langLogout}</font>"; $q = Database::get()->queryArray("SELECT * FROM loginout\n WHERE id_user = ?d ORDER by idLog DESC LIMIT 10", $uid); foreach ($q as $result) { $when = $result->when; $action = $result->action; $tool_content .= " \n <td>" . strftime("%d/%m/%Y (%H:%M:%S) ", strtotime($when)) . "</td>\n <td>" . $act[$action] . "</td>\n </tr>"; } $tool_content .= "</table>";
</div> <div class='table-responsive'> <table class='table-default'> <thead> <tr> <th colspan='2' class='text-center'>$langStudents</th> </tr> </thead> <tbody> <tr> <td>$langStudentsExerciseCompleted</th> <td>$unique_users</td> </tr> <tr> <td>$langAverage $langExerciseDuration</th> <td>".format_time_duration($avg_time)."</td> </tr> </tbody> </table> </div>"; //Questions Table $questionList = $objExercise->selectQuestionList(); $tool_content .= " <h3>$langQuestions</h3> <div class='table-responsive'> <table class='table-default'> <thead> <tr> <th>$langTitle</th> <th>Ποσοστό Επιτυχίας</th> </tr>
/** * Output the page footer. * * @param bool $quit */ function output_footer($quit = true) { global $mybb, $maintimer, $db, $lang, $plugins; $args = array('this' => &$this, 'quit' => &$quit); $plugins->run_hooks("admin_page_output_footer", $args); $memory_usage = get_friendly_size(get_memory_usage()); $totaltime = format_time_duration($maintimer->stop()); $querycount = $db->query_count; if (my_strpos(getenv("REQUEST_URI"), "?")) { $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "&debug=1#footer"; } else { $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "?debug=1#footer"; } echo "\t\t\t</div>\n"; echo "\t\t</div>\n"; echo "\t<br style=\"clear: both;\" />"; echo "\t<br style=\"clear: both;\" />"; echo "\t</div>\n"; echo "<div id=\"footer\"><p class=\"generation\">" . $lang->sprintf($lang->generated_in, $totaltime, $debuglink, $querycount, $memory_usage) . "</p><p class=\"powered\">Powered By <a href=\"http://www.mybb.com/\" target=\"_blank\">MyBB</a>, © 2002-" . COPY_YEAR . " <a href=\"http://www.mybb.com/\" target=\"_blank\">MyBB Group</a>.</p></div>\n"; if ($mybb->debug_mode) { echo $db->explain; } echo "</div>\n"; echo "</body>\n"; echo "</html>\n"; if ($quit != false) { exit; } }
$sid = $row->uid; $surname = uid_to_name($sid,'surname'); $name = uid_to_name($sid,'givenname'); $am = uid_to_am($sid); $result2 = Database::get()->queryArray("SELECT DATE_FORMAT(record_start_date, '%Y-%m-%d / %H:%i') AS record_start_date, record_end_date, TIME_TO_SEC(TIMEDIFF(record_end_date, record_start_date)) AS time_duration, total_score, total_weighting FROM `exercise_user_record` WHERE uid = ?d AND eid = ?d", $sid, $exerciseId); foreach ($result2 as $row2) { $output .= csv_escape($surname) . "\t"; $output .= csv_escape($name) . "\t"; $output .= csv_escape($am) . "\t"; $recordStartDate = $row2->record_start_date; $output .= csv_escape($recordStartDate) . "\t"; if ($row2->time_duration == '00:00:00' or empty($row2->time_duration)) { // for compatibility $output .= csv_escape($langNotRecorded) . "\t"; } else { $output .= csv_escape(format_time_duration($row2->time_duration)) . "\t"; } $totalScore = $row2->total_score; $totalWeighting = $row2->total_weighting; $output .= csv_escape("( $totalScore/$totalWeighting )") . "\t"; $output .= "$crlf"; } } echo iconv('UTF-8', 'UTF-16LE', $output); } // end of initial if
$u_date_start = $_REQUEST['u_date_start']; $u_date_end = $_REQUEST['u_date_end']; } else { $min_date = Database::get()->querySingle("SELECT MIN(day) AS minday FROM actions_daily WHERE course_id = ?d", $course_id)->minday; $u_date_start = strftime('%Y-%m-%d', strtotime($min_date)); $u_date_end = strftime('%Y-%m-%d', strtotime('now')); } if (isset($u_date_start) and isset($u_date_end)) { $first_line = "$langFrom $u_date_start $langAs $u_date_end"; } else { $date_spec = ''; } echo csv_escape($first_line), $crlf, $crlf, join(';', array_map("csv_escape", array($langSurname, $langName, $langAm, $langGroup, $langDuration))), $crlf; $totalDuration = 0; $result = user_duration_query($course_id, $u_date_start, $u_date_end, $group_id); foreach ($result as $row) { echo csv_escape($row->surname) . ";" . csv_escape($row->givenname) . ";" . csv_escape($row->am) . ";" . csv_escape($group_name) . ";" . csv_escape(format_time_duration(0 + $row->duration)) . ";" . csv_escape(round($row->duration / 3600)); echo $crlf; }
/** * Explain a query on the database. * * @param string The query SQL. * @param string The time it took to perform the query. */ function explain_query($string, $qtime) { global $plugins; $debug_extra = ''; if ($plugins->current_hook) { $debug_extra = "<div style=\"float_right\">(Plugin Hook: {$plugins->current_hook})</div>"; } if (preg_match("#^\\s*select#i", $string)) { $query = mysqli_query($this->current_link, "EXPLAIN {$string}"); $this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n" . "<tr>\n" . "<td colspan=\"8\" style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#" . $this->query_count . " - Select Query</strong></div></td>\n" . "</tr>\n" . "<tr>\n" . "<td colspan=\"8\" style=\"background-color: #fefefe;\"><span style=\"font-family: Courier; font-size: 14px;\">" . htmlspecialchars_uni($string) . "</span></td>\n" . "</tr>\n" . "<tr style=\"background-color: #efefef;\">\n" . "<td><strong>Table</strong></td>\n" . "<td><strong>Type</strong></td>\n" . "<td><strong>Possible Keys</strong></td>\n" . "<td><strong>Key</strong></td>\n" . "<td><strong>Key Length</strong></td>\n" . "<td><strong>Ref</strong></td>\n" . "<td><strong>Rows</strong></td>\n" . "<td><strong>Extra</strong></td>\n" . "</tr>\n"; while ($table = mysqli_fetch_assoc($query)) { $this->explain .= "<tr bgcolor=\"#ffffff\">\n" . "<td>" . $table['table'] . "</td>\n" . "<td>" . $table['type'] . "</td>\n" . "<td>" . $table['possible_keys'] . "</td>\n" . "<td>" . $table['key'] . "</td>\n" . "<td>" . $table['key_len'] . "</td>\n" . "<td>" . $table['ref'] . "</td>\n" . "<td>" . $table['rows'] . "</td>\n" . "<td>" . $table['Extra'] . "</td>\n" . "</tr>\n"; } $this->explain .= "<tr>\n" . "<td colspan=\"8\" style=\"background-color: #fff;\">Query Time: " . format_time_duration($qtime) . "</td>\n" . "</tr>\n" . "</table>\n" . "<br />\n"; } else { $this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n" . "<tr>\n" . "<td style=\"background-color: #ccc;\">{$debug_extra}<div><strong>#" . $this->query_count . " - Write Query</strong></div></td>\n" . "</tr>\n" . "<tr style=\"background-color: #fefefe;\">\n" . "<td><span style=\"font-family: Courier; font-size: 14px;\">" . htmlspecialchars_uni($string) . "</span></td>\n" . "</tr>\n" . "<tr>\n" . "<td bgcolor=\"#ffffff\">Query Time: " . format_time_duration($qtime) . "</td>\n" . "</tr>\n" . "</table>\n" . "<br />\n"; } $this->querylist[$this->query_count]['query'] = $string; $this->querylist[$this->query_count]['time'] = $qtime; }
function show_assignments() { global $tool_content, $m, $langEditChange, $langDelete, $langNoAssign, $langNewAssign, $langCommands, $course_code, $themeimg, $course_id, $langWorksDelConfirm, $langDaysLeft, $m, $langWarnForSubmissions, $langDelSure, $langGradeScales; $result = Database::get()->queryArray("SELECT *, CAST(UNIX_TIMESTAMP(deadline)-UNIX_TIMESTAMP(NOW()) AS SIGNED) AS time FROM assignment WHERE course_id = ?d ORDER BY CASE WHEN CAST(deadline AS UNSIGNED) = '0' THEN 1 ELSE 0 END, deadline", $course_id); $tool_content .= action_bar(array( array('title' => $langNewAssign, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&add=1", 'button-class' => 'btn-success', 'icon' => 'fa-plus-circle', 'level' => 'primary-label'), array('title' => $langGradeScales, 'url' => "grading_scales.php?course=$course_code", 'icon' => 'fa-sort-alpha-asc', 'level' => 'primary-label'), ),false); if (count($result)>0) { $tool_content .= " <div class='row'><div class='col-sm-12'> <div class='table-responsive'> <table class='table-default'> <tr class='list-header'> <th style='width:45%;'>$m[title]</th> <th class='text-center'>$m[subm]</th> <th class='text-center'>$m[nogr]</th> <th class='text-center'>$m[deadline]</th> <th class='text-center'>".icon('fa-gears')."</th> </tr>"; $index = 0; foreach ($result as $row) { // Check if assignement contains submissions $num_submitted = Database::get()->querySingle("SELECT COUNT(*) AS count FROM assignment_submit WHERE assignment_id = ?d", $row->id)->count; $num_ungraded = Database::get()->querySingle("SELECT COUNT(*) AS count FROM assignment_submit WHERE assignment_id = ?d AND grade IS NULL", $row->id)->count; if (!$num_ungraded) { if ($num_submitted > 0) { $num_ungraded = '0'; } else { $num_ungraded = '-'; } } $tool_content .= "<tr class='".(!$row->active ? "not_visible":"")."'>"; $deadline = (int)$row->deadline ? nice_format($row->deadline, true) : $m['no_deadline']; $tool_content .= "<td> <a href='$_SERVER[SCRIPT_NAME]?course=$course_code&id={$row->id}'>" . q($row->title) . "</a> <br><small class='text-muted'>".($row->group_submissions? $m['group_work'] : $m['user_work'])."</small> </td> <td class='text-center'>$num_submitted</td> <td class='text-center'>$num_ungraded</td> <td class='text-center'>$deadline"; if ($row->time > 0) { $tool_content .= " <br><span class='label label-warning'><small>$langDaysLeft" . format_time_duration($row->time) . "</small></span>"; } else if((int)$row->deadline){ $tool_content .= " <br><span class='label label-danger'><small>$m[expired]</small></span>"; } $tool_content .= "</td> <td class='option-btn-cell'>" . action_button(array( array('title' => $langEditChange, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&id=$row->id&choice=edit", 'icon' => 'fa-edit'), array('title' => $row->active == 1 ? $m['deactivate']: $m['activate'], 'url' => $row->active == 1 ? "$_SERVER[SCRIPT_NAME]?course=$course_code&choice=disable&id=$row->id" : "$_SERVER[SCRIPT_NAME]?course=$course_code&choice=enable&id=$row->id", 'icon' => $row->active == 1 ? 'fa-eye-slash': 'fa-eye'), array('title' => $m['WorkSubsDelete'], 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&id=$row->id&choice=do_purge", 'icon' => 'fa-eraser', 'confirm' => "$langWarnForSubmissions $langDelSure", 'show' => $num_submitted > 0), array('title' => $langDelete, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&id=$row->id&choice=do_delete", 'icon' => 'fa-times', 'class' => 'delete', 'confirm' => $langWorksDelConfirm))). "</td></tr>"; $index++; } $tool_content .= '</table></div></div></div>'; } else { $tool_content .= "<div class='alert alert-warning'>$langNoAssign</div>"; } }
<th class='text-left'>$langSurname $langName</th> <th>$langAm</th> <th>$langGroup</th> <th>$label</th> </tr>"; if ($type == 'duration') { $result = user_duration_query($course_id, $u_date_start, $u_date_end, $group_id); } else { $result = Database::get()->queryArray("SELECT user_id AS id FROM group_members WHERE group_id = ?d", $group_id); } if (count($result) > 0) { foreach ($result as $row) { $user_id = $row->id; if ($type == 'duration') { $value = format_time_duration(0 + $row->duration); $sortkey = $row->duration; $name = $row->surname . ' ' . $row->givenname; $am = $row->am; } elseif ($type == 'lp') { $name = uid_to_name($user_id); $am = uid_to_am($user_id); $iterator = 0; $progress = 0; foreach ($learningPathList as $learningPath) { $progress += get_learnPath_progress($learningPath->learnPath_id, $user_id); $iterator++; } if ($iterator > 0) { $total = round($progress / $iterator); $sortkey = $total;
/** * @brief Print a box with the details of a bbb session * @global type $course_id * @global type $tool_content * @global type $is_editor * @global type $langNewBBBSessionStart * @global type $langNewBBBSessionType * @global type $langConfirmDelete * @global type $langNewBBBSessionPublic * @global type $langNewBBBSessionPrivate * @global type $langBBBSessionJoin * @global type $langNewBBBSessionDesc * @global type $course_code * @global type $langNote * @global type $langBBBNoteEnableJoin * @global type $langTitle * @global type $langActivate * @global type $langDeactivate * @global type $langModify * @global type $langDelete */ function bbb_session_details() { global $course_id, $tool_content, $is_editor, $course_code, $head_content, $langNewBBBSessionStart, $langNewBBBSessionType, $langParticipants, $langConfirmDelete, $langNewBBBSessionPublic, $langNewBBBSessionPrivate, $langBBBSessionJoin, $langNewBBBSessionDesc, $langNote, $langBBBNoteEnableJoin, $langTitle,$langActivate, $langDeactivate, $langEditChange, $langDelete, $langNoBBBSesssions, $langDaysLeft, $m, $langBBBNotServerAvailableStudent, $langBBBNotServerAvailableTeacher, $langBBBImportRecordings; load_js('trunk8'); $myGroups = Database::get()->queryArray("SELECT group_id FROM group_members WHERE user_id=?d", $_SESSION['uid']); $activeClause = $is_editor? '': "AND active = '1'"; $result = Database::get()->queryArray("SELECT * FROM bbb_session WHERE course_id = ?s $activeClause ORDER BY start_date DESC", $course_id); if (get_total_bbb_servers() == '0') { if ($is_editor) { $tool_content .= "<p class='alert alert-danger'><b>$langNote</b>:<br />$langBBBNotServerAvailableTeacher</p>"; } else { $tool_content .= "<p class='alert alert-danger'><b>$langNote</b>:<br />$langBBBNotServerAvailableStudent</p>"; } } elseif ($result) { if (!$is_editor) { $tool_content .= "<div class='alert alert-info'><label>$langNote</label>:<br>$langBBBNoteEnableJoin</div>"; } $headingsSent = false; $headings = "<div class='row'> <div class='col-md-12'> <div class='table-responsive'> <table class='table-default'> <tr class='list-header'> <th style='width:25%'>$langTitle</th> <th class='text-center'>$langNewBBBSessionDesc</th> <th class='text-center'>$langNewBBBSessionStart</th> <th class='text-center'>$langParticipants</th> <th class='text-center'>".icon('fa-gears')."</th> </tr>"; define('DAY_MINUTES', 24 * 40); foreach ($result as $row) { $participants = ''; // Get participants $r_group = explode(",",$row->participants); foreach ($r_group as $participant_uid) { if ($participants) { $participants .= ', '; } $participant_uid = str_replace("'", '', $participant_uid); if (preg_match('/^_/', $participant_uid)) { $participants .= gid_to_name(str_replace("_", '', $participant_uid)); } else { $participants .= uid_to_name($participant_uid, 'fullname'); } } $participants = "<span class='trunk8'>$participants</span>"; $id = $row->id; $title = $row->title; $start_date = $row->start_date; $timeLeft = date_diff_in_minutes($start_date, date('Y-m-d H:i:s')); $timeLabel = $start_date; if ($timeLeft > 0) { $timeLabel .= "<br><span class='label label-warning'><small>$langDaysLeft " . format_time_duration($timeLeft * 60) . "</small></span>"; } elseif (-$timeLeft > DAY_MINUTES) { $timeLabel .= "<br><span class='label label-danger'><small>$m[expired]</small></span>"; } // $row->public == '1' ? $type = $langNewBBBSessionPublic: $type = $langNewBBBSessionPrivate; $meeting_id = $row->meeting_id; $att_pw = $row->att_pw; $mod_pw = $row->mod_pw; $record = $row->record; $desc = isset($row->description)? $row->description: ''; $canJoin = $row->active == '1' && $timeLeft < $row->unlock_interval && -$timeLeft < DAY_MINUTES && get_total_bbb_servers() <> '0'; if ($canJoin) { if($is_editor) { $joinLink = "<a href='$_SERVER[SCRIPT_NAME]?course=$course_code&choice=do_join&meeting_id=" . urlencode($meeting_id) . "&title=".urlencode($title)."&att_pw=".urlencode($att_pw)."&mod_pw=".urlencode($mod_pw)."&record=$record' target='_blank'>" . q($title) . "</a>"; }else { //$joinLink = "<a href='$_SERVER[SCRIPT_NAME]?course=$course_code&choice=do_join&meeting_id=" . urlencode($meeting_id) . "&att_pw=".urlencode($att_pw)."' target='_blank'>" . q($title) . "</a>"; $joinLink = "<a href='$_SERVER[SCRIPT_NAME]?course=$course_code&choice=do_join&meeting_id=" . urlencode($meeting_id) . "&title=".urlencode($title)."&att_pw=".urlencode($att_pw)."&record=$record' target='_blank'>" . q($title) . "</a>"; } } else { $joinLink = q($title); } if ($is_editor) { if (!$headingsSent) { $tool_content .= $headings; $headingsSent = true; } $tool_content .= '<tr' . ($row->active? '': " class='not_visible'") . "> <td class='text-left'>$joinLink</td> <td>$desc</td> <td class='text-center'>$timeLabel</td> <td style='width: 30%'>$participants</td> <td class='option-btn-cell'>". action_button(array( array( 'title' => $langEditChange, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&id=" . getIndirectReference($id) . "&choice=edit", 'icon' => 'fa-edit'), array( 'title' => $langBBBImportRecordings, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&id=" . getIndirectReference($row->id) . "&choice=import_video", 'icon' => "fa-edit"), array( 'title' => $row->active? $langDeactivate : $langActivate, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&id=" . getIndirectReference($row->id) . "&choice=do_". ($row->active? 'disable' : 'enable'), 'icon' => $row->active ? 'fa-eye': 'fa-eye-slash'), array( 'title' => $langDelete, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&id=" . getIndirectReference($row->id) . "&choice=do_delete", 'icon' => 'fa-times', 'class' => 'delete', 'confirm' => $langConfirmDelete) )) . "</td></tr>"; } else { // Allow access to session only if user is in participant group or session is scheduled for everyone $access = false; if(!empty($r_group) && count($r_group)>0 && $r_group[0]<>'') { foreach ($myGroups as $mg) { if (in_array("'_" . $mg->group_id . "'", $r_group)) { $access = true; } } }else{ $access = true; } // Always allow access to editor switched to student view $access = $access || in_array("'".$_SESSION['uid']."'", $r_group) || (isset($_SESSION['student_view']) and $_SESSION['student_view'] == $course_code); if ($access) { if (!$headingsSent) { $tool_content .= $headings; $headingsSent = true; } $tool_content .= "<tr> <td class='text-center'>$joinLink</td> <td>$desc</td> <td class='text-center'>$timeLabel</td> <td style='width: 30%'>$participants</td> <td class='text-center'>"; // Join url will be active only X minutes before scheduled time and if session is visible for users if ($canJoin) { $tool_content .= icon('fa-sign-in', $langBBBSessionJoin,"$_SERVER[SCRIPT_NAME]?course=$course_code&choice=do_join&title=".urlencode($title)."&meeting_id=" . urlencode($meeting_id) . "&att_pw=".urlencode($att_pw)."&record=$record' target='_blank"); } else { $tool_content .= "-</td>"; } $tool_content .= "</tr>"; } } } if ($headingsSent) { $tool_content .= "</table></div></div></div>"; } if (get_total_bbb_servers() == '0') { if ($is_editor) { $tool_content .= "<p class='alert alert-danger'><b>$langNote</b>:<br />$langBBBNotServerAvailableTeacher</p>"; } else { $tool_content .= "<p class='alert alert-danger'><b>$langNote</b>:<br />$langBBBNotServerAvailableStudent</p>"; } } if (!$is_editor and !$headingsSent) { $tool_content .= "<div class='alert alert-warning'>$langNoBBBSesssions</div>"; } } else { $tool_content .= "<div class='alert alert-warning'>$langNoBBBSesssions</div>"; } }
function show_assignments() { global $m, $uid, $group_id, $langSubmit, $langDays, $langNoAssign, $tool_content, $langWorks, $course_id, $course_code, $themeimg, $langCancel, $urlServer; $gids = user_group_info($uid, $course_id); if (!empty($gids)) { $gids_sql_ready = implode(',',array_keys($gids)); } else { $gids_sql_ready = "''"; } $res = Database::get()->queryArray("SELECT *, CAST(UNIX_TIMESTAMP(deadline)-UNIX_TIMESTAMP(NOW()) AS SIGNED) AS time FROM assignment WHERE course_id = ?d AND active = '1' AND (assign_to_specific = '0' OR assign_to_specific = '1' AND id IN (SELECT assignment_id FROM assignment_to_specific WHERE user_id = ?d UNION SELECT assignment_id FROM assignment_to_specific WHERE group_id IN ($gids_sql_ready)) ) ORDER BY CASE WHEN CAST(deadline AS UNSIGNED) = '0' THEN 1 ELSE 0 END, deadline", $course_id, $uid); if (count($res) == 0) { $tool_content .= $langNoAssign; return; } $table_content = ''; foreach ($res as $row) { if (!$row->active) { continue; } $table_content .= "<tr><td width=\"1%\"> <img style='padding-top:2px;' src='$themeimg/arrow.png' alt=''></td> <td><div align='left'><a href='index.php?course=$course_code&id=$row->id'>" . q($row->title) . "</a></td> <td align='center'>" . nice_format($row->deadline); if ($row->time > 0) { $table_content .= "<br>(<small>$langDaysLeft" . format_time_duration($row->time) . "</small>)"; } else if($row->deadline){ $table_content .= "<br> (<small><span class='expired'>$m[expired]</span></small>)"; } $table_content .= "</div></td>\n <td align=\"center\">"; $subm = was_submitted($uid, $group_id, $row->id); if ($subm == 'user') { $table_content .= $m['yes']; } elseif ($subm == 'group') { $table_content .= $m['by_groupmate']; } else { $table_content .= $m['no']; } $table_content .= "</td><td align=\"center\">"; if ($row->time >= 0 and !was_graded($uid, $row->id) and is_group_assignment($row->id)) { $table_content .= "<input type='radio' name='assign' value='$row->id'>"; } else { $table_content .= '-'; } $table_content .= "</td>\n </tr>"; } $tool_content .= " <div class='form-wrapper'> <form class='form-horizontal' action='$_SERVER[SCRIPT_NAME]?course=$course_code' method='post'> <fieldset> <input type='hidden' name='file' value='" . q($_GET['submit']) . "'> <input type='hidden' name='group_id' value='$group_id'> <div class='form-group'> <label for='title' class='col-sm-2 control-label'>$langWorks ($m[select]):</label> <div class='col-sm-10'> <table class='table-default'> <tr> <th class='left' colspan='2'>$m[title]</th> <th align='center' width='30%'>$m[deadline]</th> <th align='center' width='10%'>$m[submitted]</th> <th align='center' width='10%'>$m[select]</th> </tr> $table_content </table> </div> </div> <div class='form-group'> <label for='title' class='col-sm-2 control-label'>$m[comments]:</label> <div class='col-sm-10'> <textarea name='comments' rows='4' cols='60' class='form-control'></textarea> </div> </div> <div class='form-group'> <div class='col-sm-10 col-sm-offset-2'> <input class='btn btn-primary' type='submit' name='submit' value='$langSubmit'> <a class='btn btn-default' href='$urlServer/modules/group/document.php?course=$course_code&group_id=$group_id'>$langCancel</a> </div> </div> </fieldset> </form> </div>"; }
function show_assignments() { global $tool_content, $m, $langEdit, $langDelete, $langNoAssign, $langNewAssign, $langCommands, $course_code, $themeimg, $course_id, $langConfirmDelete, $langDaysLeft, $m, $langWarnForSubmissions, $langDelSure; $result = Database::get()->queryArray("SELECT *, CAST(UNIX_TIMESTAMP(deadline)-UNIX_TIMESTAMP(NOW()) AS SIGNED) AS time\n FROM assignment WHERE course_id = ?d ORDER BY CASE WHEN CAST(deadline AS UNSIGNED) = '0' THEN 1 ELSE 0 END, deadline", $course_id); $tool_content .= action_bar(array(array('title' => $langNewAssign, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&add=1", 'button-class' => 'btn-success', 'icon' => 'fa-plus-circle', 'level' => 'primary-label'))); if (count($result) > 0) { $tool_content .= "\n <div class='row'><div class='col-sm-12'>\n <div class='table-responsive'>\n <table class='table-default'>\n <tr>\n <th>{$m['title']}</th>\n <th class='text-center'>{$m['subm']}</th>\n <th class='text-center'>{$m['nogr']}</th>\n <th class='text-center'>{$m['deadline']}</th>\n <th class='text-center'>" . icon('fa-gears') . "</th>\n </tr>"; $index = 0; foreach ($result as $row) { // Check if assignement contains submissions $num_submitted = Database::get()->querySingle("SELECT COUNT(*) AS count FROM assignment_submit WHERE assignment_id = ?d", $row->id)->count; if (!$num_submitted) { $num_submitted = ' '; } $num_ungraded = Database::get()->querySingle("SELECT COUNT(*) AS count FROM assignment_submit WHERE assignment_id = ?d AND grade IS NULL", $row->id)->count; if (!$num_ungraded) { $num_ungraded = ' '; } $tool_content .= "<tr class='" . (!$row->active ? "not_visible" : "") . "'>"; $deadline = (int) $row->deadline ? nice_format($row->deadline, true) : $m['no_deadline']; $tool_content .= "<td>\n <a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&id={$row->id}'>{$row->title}</a>\n </td>\n <td class='text-center'>{$num_submitted}</td>\n <td class='text-center'>{$num_ungraded}</td>\n <td class='text-center'>{$deadline}"; if ($row->time > 0) { $tool_content .= " <br><span class='label label-warning'>{$langDaysLeft}" . format_time_duration($row->time) . "</span>"; } else { if ((int) $row->deadline) { $tool_content .= " <br><span class='label label-danger'>{$m['expired']}</span>"; } } $tool_content .= "</td>\n <td class='option-btn-cell'>" . action_button(array(array('title' => $langDelete, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&id={$row->id}&choice=do_delete", 'icon' => 'fa-times', 'class' => 'delete', 'confirm' => $langConfirmDelete), array('title' => $langEdit, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&id={$row->id}&choice=edit", 'icon' => 'fa-edit'), array('title' => $m['WorkSubsDelete'], 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&id={$row->id}&choice=do_purge", 'icon' => 'fa-eraser', 'confirm' => "{$langWarnForSubmissions} {$langDelSure}", 'show' => is_numeric($num_submitted) && $num_submitted > 0), array('title' => $row->active == 1 ? $m['deactivate'] : $m['activate'], 'url' => $row->active == 1 ? "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&choice=disable&id={$row->id}" : "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&choice=enable&id={$row->id}", 'icon' => $row->active == 1 ? 'fa-eye' : 'fa-eye-slash'))) . "</td></tr>"; $index++; } $tool_content .= '</table></div></div></div>'; } else { $tool_content .= "<div class='alert alert-warning'>{$langNoAssign}</div>"; } }
/** * Explain a query on the database. * * @param string The query SQL. * @param string The time it took to perform the query. */ function explain_query($string, $qtime) { if (preg_match("#^\\s*select#i", $string)) { $this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n" . "<tr>\n" . "<td colspan=\"8\" style=\"background-color: #ccc;\"><strong>#" . $this->query_count . " - Select Query</strong></td>\n" . "</tr>\n" . "<tr>\n" . "<td colspan=\"8\" style=\"background-color: #fefefe;\"><span style=\"font-family: Courier; font-size: 14px;\">" . htmlspecialchars_uni($string) . "</span></td>\n" . "</tr>\n" . "<tr>\n" . "<td colspan=\"8\" style=\"background-color: #fff;\">Query Time: " . format_time_duration($qtime) . "</td>\n" . "</tr>\n" . "</table>\n" . "<br />\n"; } else { $this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n" . "<tr>\n" . "<td style=\"background-color: #ccc;\"><strong>#" . $this->query_count . " - Write Query</strong></td>\n" . "</tr>\n" . "<tr style=\"background-color: #fefefe;\">\n" . "<td><span style=\"font-family: Courier; font-size: 14px;\">" . htmlspecialchars_uni($string) . "</span></td>\n" . "</tr>\n" . "<tr>\n" . "<td bgcolor=\"#ffffff\">Query Time: " . format_time_duration($qtime) . "</td>\n" . "</tr>\n" . "</table>\n" . "<br />\n"; } $this->querylist[$this->query_count]['query'] = $string; $this->querylist[$this->query_count]['time'] = $qtime; }
function saveTransaction($option) { global $mainframe; $postRow = JRequest::get('post'); $transaction = new CbodbTransaction($postRow['id']); $transaction->setAll($postRow); $msg = ''; if (!isset($transaction->creditRate) || is_empty($transaction->creditRate)) { $transaction->creditRate = $transaction->getMemberCreditRate($transaction->memberID); } if ($transaction->getGranderTransactionType() == "Time") { // Time-based transaction: recalculate total time and credits $transaction->totalTime = calculateTotalTime($transaction->dateOpen, $transaction->dateClosed); $transaction->credits = calculateCredits($transaction->totalTime, $transaction->creditRate); $msg = "Total time: " . format_time_duration($transaction->totalTime) . ", Credits: {$transaction->credits}"; } // added type 2 (Personal) to negative transaction type 2012.07.21 Bart McPherson Givecamp if ($transaction->type == 1001 || $transaction->type == 1003 || $transaction->type == 2) { /* This is a purchase - make sure credits are negative */ if ($transaction->credits > 0) { $transaction->credits = -$transaction->credits; } CbodbItem::markTagAsSold($transaction->itemID); if ($transaction->type == 2) { $msg = "Total time: " . format_time_duration($transaction->totalTime) . ", Credits: {$transaction->credits}"; } } if ($transaction->type == 1003) { /* this is a membership renewal - update the account */ $member = new CbodbMember($transaction->memberID); if (strtotime($member->membershipExpire) < time()) { $member->membershipExpire = date("Y-m-d H:i:s", time() + 365 * 24 * 3600); } else { $member->membershipExpire = date("Y-m-d H:i:s", strtotime($member->membershipExpire) + 365 * 24 * 3600); } $member->isMember = 1; $member->saveData(); } $transaction->saveData(); $msg = "Transaction {$transaction->id} saved. " . $msg; // Going back to Show Transactions list // Saved the listing criteria as hidden form variables... use them to re-generate the previous view //$list_query_limit = $postRow['list_query_limit'] ? ('&limit=' . $postrow['list_query_limit']) : ''; //$list_query_limitstart = $postRow['list_query_limitstart'] ? ('&limitstart=' . $postrow['list_query_limitstart']) : ''; $list_query_member_id = $postRow['list_query_member_id'] ? '&member_id=' . $postrow['list_query_member_id'] : ''; $list_query_dateStart = $postRow['list_query_dateStart'] ? '&dateStart=' . $postrow['list_query_dateStart'] : ''; $list_query_dateEnd = $postRow['list_query_dateEnd'] ? '&dateEnd=' . $postrow['list_query_dateEnd'] : ''; $mainframe->redirect('index.php?option=' . $option . '&task=transactions' . $list_query_member_id . $list_query_dateStart . $list_query_dateEnd, $msg); }
$extra_messages = "config/{$language_codes[$language]}.inc.php"; if (file_exists($extra_messages)) { include $extra_messages; } else { $extra_messages = false; } require "{$webDir}/lang/{$language}/messages.inc.php"; if ($extra_messages) { include $extra_messages; } if (!isset($_SESSION['csrf_token']) || empty($_SESSION['csrf_token'])) { $_SESSION['csrf_token'] = generate_csrf_token(); } if ($upgrade_begin = get_config('upgrade_begin')) { if (!defined('UPGRADE')) { Session::Messages(sprintf($langUpgradeInProgress, format_time_duration(time() - $upgrade_begin)), 'alert-warning'); if (!isset($guest_allowed) or !$guest_allowed) { redirect_to_home_page(); } } } // check if we are admin or power user or manageuser_user if (isset($_SESSION['is_admin']) and $_SESSION['is_admin']) { $is_admin = true; $is_power_user = true; $is_usermanage_user = true; $is_departmentmanage_user = true; } elseif (isset($_SESSION['is_power_user']) and $_SESSION['is_power_user']) { $is_power_user = true; $is_usermanage_user = true; $is_departmentmanage_user = true;
/** * Prints a debug information page */ function debug_page() { global $db, $debug, $templates, $templatelist, $mybb, $maintimer, $globaltime, $ptimer, $parsetime, $lang, $cache; $totaltime = format_time_duration($maintimer->totaltime); $phptime = $maintimer->totaltime - $db->query_time; $query_time = $db->query_time; $globaltime = format_time_duration($globaltime); $percentphp = number_format($phptime / $maintimer->totaltime * 100, 2); $percentsql = number_format($query_time / $maintimer->totaltime * 100, 2); $phptime = format_time_duration($maintimer->totaltime - $db->query_time); $query_time = format_time_duration($db->query_time); $call_time = format_time_duration($cache->call_time); $phpversion = PHP_VERSION; $serverload = get_server_load(); if ($mybb->settings['gzipoutput'] != 0) { $gzipen = "Enabled"; } else { $gzipen = "Disabled"; } echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">"; echo "<head>"; echo "<meta name=\"robots\" content=\"noindex\" />"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"; echo "<title>MyBB Debug Information</title>"; echo "</head>"; echo "<body>"; echo "<h1>MyBB Debug Information</h1>\n"; echo "<h2>Page Generation</h2>\n"; echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n"; echo "<td bgcolor=\"#cccccc\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Page Generation Time:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$totaltime}</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">No. DB Queries:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$db->query_count}</span></td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">PHP Processing Time:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$phptime} ({$percentphp}%)</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">DB Processing Time:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$query_time} ({$percentsql}%)</span></td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Extensions Used:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$mybb->config['database']['type']}, xml</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Global.php Processing Time:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$globaltime}</span></td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">PHP Version:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$phpversion}</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Server Load:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$serverload}</span></td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">GZip Encoding Status:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$gzipen}</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">No. Templates Used:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">" . count($templates->cache) . " (" . (int) count(explode(",", $templatelist)) . " Cached / " . (int) count($templates->uncached_templates) . " Manually Loaded)</span></td>\n"; echo "</tr>\n"; $memory_usage = get_memory_usage(); if (!$memory_usage) { $memory_usage = $lang->unknown; } else { $memory_usage = get_friendly_size($memory_usage) . " ({$memory_usage} bytes)"; } $memory_limit = @ini_get("memory_limit"); echo "<tr>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Usage:</span></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_usage}</span></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Limit:</span></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_limit}</span></td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<h2>Database Connections (" . count($db->connections) . " Total) </h2>\n"; echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n"; echo "<td style=\"background: #fff;\">" . implode("<br />", $db->connections) . "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<br />\n"; echo "<h2>Database Queries (" . $db->query_count . " Total) </h2>\n"; echo $db->explain; if ($cache->call_count > 0) { echo "<h2>Cache Calls (" . $cache->call_count . " Total, " . $call_time . ") </h2>\n"; echo $cache->cache_debug; } echo "<h2>Template Statistics</h2>\n"; if (count($templates->cache) > 0) { echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n"; echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - " . count($templates->cache) . " Total</strong></td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<td style=\"background: #fff;\">" . implode(", ", array_keys($templates->cache)) . "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<br />\n"; } if (count($templates->uncached_templates) > 0) { echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n"; echo "<td style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - " . count($templates->uncached_templates) . " Total</strong></td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<td style=\"background: #fff;\">" . implode(", ", $templates->uncached_templates) . "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<br />\n"; } echo "</body>"; echo "</html>"; exit; }