public function view() { global $db; $result = $db->query("SELECT * FROM command_queue ORDER BY time"); echo ' <h1>Add new command</h1> <div><form method="get"> <div> Command:<input type="text" name="data" size="20" value=""> <input type="hidden" name="addr" value="' . $this->addr . '"> <input type="hidden" name="page" value="raw_command_queue"> </div> <input type="submit" value="add"> </form></div> <h1>Dump queue</h1> '; echo "<table>\n"; echo "<tr><th>addr</th><th>time</th><th>data</th><th>send</th><th></th></tr>"; while ($row = $result->fetchArray()) { echo "<tr><td>" . $row['addr'] . "</td>"; echo "<td>" . format_time($row['time']) . "</td>"; echo "<td>" . $row['data'] . "</td>"; echo "<td>" . $row['send'] . "</td>"; echo '<td><a href="?page=raw_command_queue&delete_id=' . $row['id'] . '">delete</a></td></tr>'; } echo "</table>\n"; }
public function show_activity() { global $forum_db, $forum_user, $forum_config, $forum_page, $lang_fancy_user_activity, $user, $id; $out = ''; $query = array('SELECT' => 'a.activity_type, INET_NTOA(a.ip) AS ip, a.activity_time', 'FROM' => 'fancy_user_activity AS a', 'WHERE' => 'a.user_id=' . $id, 'ORDER BY' => 'a.id DESC', 'LIMIT' => '50'); $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); $acts = array(); while ($cur_act = $forum_db->fetch_assoc($result)) { $acts[] = $cur_act; } if (empty($acts)) { $out = '<div class="ct-box info-box"><p>' . $lang_fancy_user_activity['No activity'] . '</p></div>'; } else { foreach ($acts as $act) { $out .= '<tr> <td>' . $this->get_activity_name($act['activity_type']) . '</td> <td>' . $act['ip'] . '</td> <td>' . format_time($act['activity_time']) . '</td> </tr>'; } $summary = sprintf($forum_user['id'] == $id ? $lang_fancy_user_activity['Activity welcome'] : $lang_fancy_user_activity['Activity welcome user'], forum_htmlencode($user['username'])); $table = '<div class="ct-group"> <table cellpadding="0" summary="' . $summary . '"> <thead> <tr> <th class="tc0" scope="col">' . $lang_fancy_user_activity['Type'] . '</th> <th class="tc1" scope="col">' . $lang_fancy_user_activity['IP'] . '</th> <th class="tc2" scope="col">' . $lang_fancy_user_activity['Time'] . '</th> </tr> </thead> <tbody>%s</tbody> </table> </div>'; $out = sprintf($table, $out); } echo $out; }
public function view() { global $db, $_GET; $limit = (int) $_GET['limit']; if ($limit <= 0) { $limit = 50; } $offset = (int) $_GET['offset']; if ($offset < 0) { $offset = 0; } if ($this->addr) { $where = ' WHERE addr=' . $this->addr; } else { $where = ''; } $result = $db->query("SELECT * FROM debug_log{$where} ORDER BY time DESC LIMIT {$offset},{$limit}"); echo "<div>"; if ($offset > 0) { echo "<a href=\"?page=debug_log&addr={$this->addr}&offset=" . ($offset - $limit) . "&limit={$limit}\">previous {$limit}</a>"; } echo " <a href=\"?page=debug_log&addr={$this->addr}&offset=" . ($offset + $limit) . "&limit={$limit}\">next {$limit}</a>"; echo "</div>"; echo "<pre>\n"; while ($row = $result->fetchArray()) { if ($row['addr'] > 0) { $x = sprintf("<%02d>", $row['addr']); } else { $x = " "; } printf("%s %s %s\n", format_time($row['time']), $x, $row['data']); } echo "</pre>\n"; }
function get_system_confs() { $result = []; $configs = get_confs('push-settings', 'system'); $configs = @$configs['push-settings']['system']; if (empty($configs)) { return []; } $type_descs = []; foreach ($configs as $conf) { $key = $conf['key']; $value = $conf['value']; if ($conf['type'] === 'integer') { $value = intval($value); } elseif ($conf['type'] === 'date') { $value = format_time($value); } elseif ($conf['type'] === 'json') { $value = json_decode($value); } if ($conf['array'] === 'yes') { if (!array_key_exists($key, $result)) { $result[$key] = []; } $items =& $result[$key]; if (!in_array($value, $items)) { $items[] = $value; } } else { $result[$key] = $value; } $type_descs[$key] = $conf['type']; } $result['type_desc'] = $type_descs; return $result; }
function military_overview() { global $data, $smarty, $sql; $incomingfleets = array(); $combatlocations = array(); $declarations = array(); $microtime = microfloat(); $sql->select(array(array('planets', 'planet_id'), array('planets', 'name', 'planetname'), array('navygroups', 'navygroup_id'), array('navygroups', 'name', 'navygroupname'), array('tasks', 'kingdom_id'), array('tasks', 'completion', 'time'))); $sql->where(array(array('navygroups', 'round_id', $_SESSION['round_id']), array('navygroups', 'navygroup_id', array('tasks', 'group_id')), array('planets', 'round_id', $_SESSION['round_id']), array('planets', 'planet_id', array('tasks', 'planet_id')), array('tasks', 'round_id', $_SESSION['round_id']), array('tasks', 'type', 5), array('tasks', 'kingdom_id', array('tasks', 'target_kingdom_id'), '<>'))); $db_query = $sql->generate(); $db_query .= " AND (`tasks`.`kingdom_id` = '" . $_SESSION['kingdom_id'] . "' OR `tasks`.`target_kingdom_id` = '" . $_SESSION['kingdom_id'] . "') ORDER BY `planets`.`planet_id` ASC, `tasks`.`completion` ASC"; $db_result = mysql_query($db_query); if (mysql_num_rows($db_result) > 0) { while ($db_row = mysql_fetch_array($db_result, MYSQL_ASSOC)) { if ($db_row['kingdom_id'] == $_SESSION['kingdom_id']) { $db_row['direction'] = 'Outgoing'; } else { $db_row['direction'] = 'Incoming'; } unset($db_row['kingdom_id'], $db_row['target_kingdom_id']); $db_row['time'] = format_time(timeparser($db_row['time'] - $microtime)); $incomingfleets[] = $db_row; } } $typearray = array('army', 'navy'); foreach ($typearray as $type) { $sql->property('DISTINCT'); $sql->select(array(array('planets', 'planet_id'), array('planets', 'name', 'planetname'), array('combat', 'completion'))); $sql->where(array(array($type . 'groups', 'kingdom_id', array('planets', 'kingdom_id'), '!='), array($type . 'groups', 'planet_id', array('planets', 'planet_id')), array($type . 'groups', 'units', 'a:0:{}', '<>'), array('combat', 'planet_id', array('planets', 'planet_id')))); if ($type == 'navy') { $sql->where(array(array('navygroups', 'x_current', array('navygroups', 'x_destination')), array('navygroups', 'y_current', array('navygroups', 'y_destination')))); } $db_query = $sql->generate(); $db_query .= " AND (`" . $type . "groups`.`kingdom_id` = '" . $_SESSION['kingdom_id'] . "' OR `planets`.`kingdom_id` = '" . $_SESSION['kingdom_id'] . "') ORDER BY `combat`.`completion` ASC"; $db_result = mysql_query($db_query); if (mysql_num_rows($db_result) > 0) { $location_restarts = array(); while ($db_row = mysql_fetch_array($db_result, MYSQL_ASSOC)) { $db_row['time'] = format_time(timeparser($db_row['completion'] - $microtime)); $combatlocations[$db_row['planet_id']] = $db_row; // If the update hasn't finished after 30 seconds, it has died. if ($db_row['completion'] < $microtime + 30) { $location_restarts[] = $db_row['planet_id']; } } // Restart any dead combats. if (!empty($location_restarts)) { $db_query = "UPDATE `combat` SET `beingupdated` = '0' WHERE `planet_id` IN ('" . implode("', '", $location_restarts) . "')"; $db_result = mysql_query($db_query); } } } $sort_function = create_function('$a,$b', 'if ($a[\'completion\'] == $b[\'completion\']) return 0; return ($a[\'completion\'] < $b[\'completion\']) ? -1 : 1;'); usort($combatlocations, $sort_function); // Declarations military_declarations(); $smarty->assign('incomingfleets', $incomingfleets); $smarty->assign('combatlocations', $combatlocations); $smarty->display('military_overview.tpl'); }
function help_status() { global $smarty; $db_query = "\n\t\t\tSELECT \n\t\t\t\t`round_id`, \n\t\t\t\t`round_engine`, \n\t\t\t\t`name`, \n\t\t\t\t`description`, \n\t\t\t\t`starttime`, \n\t\t\t\t`stoptime`, \n\t\t\t\t`starsystems`, \n\t\t\t\t`planets`, \n\t\t\t\t`resistance`, \n\t\t\t\t`speed`, \n\t\t\t\t`resourcetick`, \n\t\t\t\t`combattick` \n\t\t\tFROM `rounds` \n\t\t\tWHERE `round_id` = '" . $_SESSION['round_id'] . "' \n\t\t\tLIMIT 1"; $db_result = mysql_query($db_query); $round = mysql_fetch_array($db_result, MYSQL_ASSOC); $round['speed'] /= 1000; // Dynamic attack limit based on elapsed time of current round $end_time = 3456000 * $_SESSION['round_speed']; $current_time = microfloat() - $round['starttime']; $attack_limit = 1 - $current_time / $end_time; if ($attack_limit < 0) { $attack_limit = 0; } $round['attack_limit'] = round($attack_limit * 100, 2); $round['description'] = nl2br($round['description']); $round['starttime'] = format_timestamp($round['starttime']); $round['stoptime'] = format_timestamp($round['stoptime']); $round['resistance'] = format_number($round['resistance']); $round['resourcetick'] = format_time(timeparser($round['resourcetick'] / 1000)); $round['combattick'] = format_time(timeparser($round['combattick'] / 1000)); $smarty->assign('round', $round); $smarty->display('help_status.tpl'); exit; }
public function view() { global $db, $_GET; $limit = (int) $_GET['limit']; if ($limit <= 0) { $limit = 50; } $offset = (int) $_GET['offset']; if ($offset < 0) { $offset = 0; } $order = ' ORDER BY time DESC'; $result = $db->query("SELECT * FROM log WHERE addr={$this->addr} ORDER BY time DESC LIMIT {$offset},{$limit}"); if ($offset > 0) { echo "<a href=\"?page=history&addr={$this->addr}&offset=" . ($offset - $limit) . "&limit={$limit}\">previous {$limit}</a>"; } echo " <a href=\"?page=history&addr={$this->addr}&offset=" . ($offset + $limit) . "&limit={$limit}\">next {$limit}</a>"; echo "<table>\n"; echo "<tr><th>time</th><th>mode</th><th>valve</th><th>real</th><th>wanted</th><th>battery</th>"; echo "<th>error</th><th>window</th><th>force</th></tr>"; while ($row = $result->fetchArray()) { echo "<tr><td>" . format_time($row['time']) . "</td>"; echo "<td>" . $row['mode'] . "</td>"; echo "<td>" . $row['valve'] . "</td>"; echo "<td>" . $row['real'] / 100 . "</td>"; echo "<td>" . $row['wanted'] / 100 . "</td>"; echo "<td>" . $row['battery'] / 1000 . "</td>"; echo "<td>" . $row['error'] . "</td>"; echo "<td>" . $row['window'] . "</td>"; echo "<td>" . $row['force'] . "</td></tr>"; } echo "</table>\n"; }
function get_content() { global $USER, $CFG; if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; if (empty($this->instance) or empty($USER->id) or isguest() or empty($CFG->messaging)) { return $this->content; } $this->content->footer = '<a href="' . $CFG->wwwroot . '/message/index.php" onclick="this.target=\'message\'; return openpopup(\'/message/index.php\', \'message\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">' . get_string('messages', 'message') . '</a>...'; $users = get_records_sql("SELECT m.useridfrom as id, COUNT(m.useridfrom) as count,\n u.firstname, u.lastname, u.picture, u.lastaccess\n FROM {$CFG->prefix}user u, \n {$CFG->prefix}message m \n WHERE m.useridto = '{$USER->id}' \n AND u.id = m.useridfrom\n GROUP BY m.useridfrom, u.firstname,u.lastname,u.picture,u.lastaccess"); //Now, we have in users, the list of users to show //Because they are online if (!empty($users)) { $this->content->text .= '<ul class="list">'; foreach ($users as $user) { $timeago = format_time(time() - $user->lastaccess); $this->content->text .= '<li class="listentry"><div class="user"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $this->instance->pageid . '" title="' . $timeago . '">'; $this->content->text .= print_user_picture($user->id, $this->instance->pageid, $user->picture, 0, true, false, '', false); $this->content->text .= fullname($user) . '</a></div>'; $this->content->text .= '<div class="message"><a href="' . $CFG->wwwroot . '/message/discussion.php?id=' . $user->id . '" onclick="this.target=\'message_' . $user->id . '\'; return openpopup(\'/message/discussion.php?id=' . $user->id . '\', \'message_' . $user->id . '\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img class="iconsmall" src="' . $CFG->pixpath . '/t/message.gif" alt="" /> ' . $user->count . '</a>'; $this->content->text .= '</div></li>'; } $this->content->text .= '</ul>'; } else { $this->content->text .= '<div class="info">'; $this->content->text .= get_string('nomessages', 'message'); $this->content->text .= '</div>'; } return $this->content; }
public function definition() { global $OUTPUT; $mform = $this->_form; $user = $this->_customdata['user']; $lastupdate = $this->_customdata['lastupdate']; $dategraded = $this->_customdata['dategraded']; // Hidden params. $mform->addElement('hidden', 'userid', 0); $mform->setType('userid', PARAM_INT); $mform->addElement('hidden', 'id', 0); $mform->setType('id', PARAM_INT); $mform->addElement('static', 'picture', $OUTPUT->user_picture($user), fullname($user, true) . '<br/>' . get_string('lastupdated', 'mod_giportfolio') . date('l jS \\of F Y ', $lastupdate)); $this->add_grades_section(); $mform->addElement('header', 'Feed Back', get_string('feedback', 'grades')); $mform->addElement('textarea', 'feedback', get_string('feedback', 'grades'), 'wrap="virtual" rows="10" cols="50"'); if ($dategraded) { $datestring = userdate($dategraded) . " (" . format_time(time() - $dategraded) . ")"; $mform->addElement('header', 'Last Grade', get_string('lastgrade', 'assignment')); $mform->addElement('static', 'lastgrade', get_string('lastgrade', 'mod_giportfolio') . ':', $datestring); } // Buttons. $this->add_action_buttons(); $mform->setDisableShortforms(true); }
function out_time($var) { global $capture_times; if ($var == "0") { echo "N/A"; } else { echo format_time($capture_times[$var]); } }
public function add_preflight_check_form_fields(mod_quiz_preflight_check_form $quizform, MoodleQuickForm $mform, $attemptid) { global $DB; $timemodifiedoffline = $DB->get_field('quiz_attempts', 'timemodifiedoffline', array('id' => $attemptid)); $lasttime = format_time(time() - $timemodifiedoffline); $mform->addElement('header', 'offlineattemptsheader', get_string('mobileapp', 'quizaccess_offlineattempts')); $mform->addElement('static', 'offlinedatamessage', '', get_string('offlinedatamessage', 'quizaccess_offlineattempts', $lasttime)); $mform->addElement('advcheckbox', 'confirmdatasaved', null, get_string('confirmdatasaved', 'quizaccess_offlineattempts')); }
public function get_shift_session() { $shiftSessions = ShiftSession::all(); foreach ($shiftSessions as &$shiftSession) { $shiftSession->start_time = format_time(strtotime($shiftSession->start_time)); $shiftSession->end_time = format_time(strtotime($shiftSession->end_time)); $shiftSession->active = $shiftSession->active == 1; } return response()->json($shiftSessions); }
function get_today_stats2($current_queue = '%', $operator_restr = '') { global $conf_cdr_db, $conf_realtime_db; if ($operator_restr == '') { $agent_need = '%'; } else { $agent_need = mysql_escape_string($operator_restr); } $calls_c = values("SELECT COUNT(*) AS c, SUM(callduration) AS timesum, AVG(callduration) AS timeavg FROM " . $conf_realtime_db . ".call_status WHERE timestamp BETWEEN '" . Date("Y-m-d") . " 00:00:00' AND '" . Date("Y-m-d") . " 23:59:59' AND queue LIKE '" . $current_queue . "' AND agent LIKE '" . $agent_need . "'"); $calls_num = $calls_c[0]['c']; $input_calls_time = format_time(round($calls_c[0]['timesum']), 1); if ($operator_restr != '') { $out_calls = values("SELECT COUNT(*) AS c FROM `cdr` WHERE src='" . $agent_need . "' AND calldate BETWEEN '" . Date("Y-m-d") . " 00:00:00' AND '" . Date("Y-m-d") . " 23:59:59'"); } $pick = values("SELECT COUNT(*) AS c FROM " . $conf_realtime_db . ".call_status WHERE timestamp BETWEEN '" . Date("Y-m-d") . " 00:00:00' AND '" . Date("Y-m-d") . " 23:59:59' AND queue LIKE '" . $current_queue . "' AND agent LIKE '" . $agent_need . "' AND (status='COMPLETEAGENT' OR status='COMPLETECALLER' OR status='CONNECT')"); $taken_calls = $pick[0]['c']; if ($calls_num != 0) { $taken_calls_perc = round(100 * $taken_calls / $calls_num) . '%'; } else { $taken_calls_perc = '---'; } $avgvoicecalls_c = values("SELECT AVG(callduration) AS timeavg FROM `" . $conf_realtime_db . "`.`call_status` WHERE `queue` LIKE '" . $current_queue . "' AND `callduration`>0 AND `timestamp` BETWEEN '" . Date("Y-m-d") . " 00:00:00' AND '" . Date("Y-m-d") . " 23:59:59' AND agent LIKE '" . $agent_need . "'"); $avg_call_time = round($avgvoicecalls_c[0]['timeavg']) . ' с'; if ($avg_call_time == 0) { $avg_call_time = '---'; } $scalls20_c = values("SELECT COUNT(*) AS c FROM `" . $conf_realtime_db . "`.`call_status` WHERE `queue` LIKE '" . $current_queue . "' AND holdtime<=20 AND `timestamp` BETWEEN '" . Date("Y-m-d") . " 00:00:00' AND '" . Date("Y-m-d") . " 23:59:59' AND agent LIKE '" . $agent_need . "'"); if ($calls_c[0]['c'] != 0) { $service_level = round($scalls20_c[0]['c'] / $calls_c[0]['c'] * 100) . '%'; } else { $service_level = '---'; } $maxacalls_c = values("SELECT MAX(holdtime) AS maxhold FROM `" . $conf_realtime_db . "`.`call_status` WHERE `queue` LIKE '" . $current_queue . "' AND `timestamp` BETWEEN '" . Date("Y-m-d") . " 00:00:00' AND '" . Date("Y-m-d") . " 23:59:59' AND agent LIKE '" . $agent_need . "' AND status!='TRANSFER'"); if (count($maxacalls_c) == 0 or $maxacalls_c[0]['maxhold'] == 0) { $max_await = '---'; } else { $max_await = $maxacalls_c[0]['maxhold'] . ' с'; } if ($operator_restr == '') { return ' <table border=0> <tr><td>' . __('Принято') . ':</td><td>' . $taken_calls . '</td></tr> <tr><td>' . __('Обслужено') . ':</td><td>' . $taken_calls_perc . '</td></tr> <tr><td>' . __('Время') . ':</td><td>' . $input_calls_time . '</td></tr> <tr><td>' . __('Среднее') . ':</td><td>' . $avg_call_time . '</td></tr> <tr><td>Service lvl:</td><td>' . $service_level . '</td></tr> </table>'; } else { return '<span title="' . __('Количество принятых звонков за сегодня') . '">' . __('Принял') . ':</span> ' . $taken_calls . '<br> <span title="' . __('Количество сделаных звонков за сегодня') . '">' . __('Исходящих') . ':</span>' . $out_calls[0]['c'] . '<br> <span title="' . __('Общее время разговоров за сегодня') . '">' . __('Время') . ':</span> ' . $input_calls_time . '<br> <span title="' . __('Среднее время разговора за сегодня') . '">' . __('Среднее') . ':</span> ' . $avg_call_time; } }
function writetofile($file, $data = '', $method = "php") { m_mkdir(dirname($file)); if ($method == 'php') { file_put_contents($file, "<?PHP\n//" . format_time(times()) . "\n" . $data . ";\n?>", LOCK_EX); } elseif ($method == 'serial') { file_put_contents($file, serialize($data), LOCK_EX); } else { file_put_contents($file, $data, LOCK_EX); } return $file; }
function get_content() { global $USER, $CFG, $DB, $OUTPUT; if (!$CFG->messaging) { $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; if ($this->page->user_is_editing()) { $this->content->text = get_string('disabled', 'message'); } return $this->content; } if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; if (empty($this->instance) or !isloggedin() or isguestuser() or empty($CFG->messaging)) { return $this->content; } $link = '/message/index.php'; $action = null; //this was using popup_action() but popping up a fullsize window seems wrong $this->content->footer = $OUTPUT->action_link($link, get_string('messages', 'message'), $action); $ufields = user_picture::fields('u', array('lastaccess')); $users = $DB->get_records_sql("SELECT {$ufields}, COUNT(m.useridfrom) AS count\n FROM {user} u, {message} m\n WHERE m.useridto = ? AND u.id = m.useridfrom AND m.notification = 0\n GROUP BY {$ufields}", array($USER->id)); //Now, we have in users, the list of users to show //Because they are online if (!empty($users)) { $this->content->text .= '<ul class="list">'; foreach ($users as $user) { $timeago = format_time(time() - $user->lastaccess); $this->content->text .= '<li class="listentry"><div class="user"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . SITEID . '" title="' . $timeago . '">'; $this->content->text .= $OUTPUT->user_picture($user, array('courseid' => SITEID)); //TODO: user might not have capability to view frontpage profile :-( $this->content->text .= fullname($user) . '</a></div>'; $link = '/message/index.php?usergroup=unread&id=' . $user->id; $anchortagcontents = '<img class="iconsmall" src="' . $OUTPUT->pix_url('t/message') . '" alt="" /> ' . $user->count; $action = null; // popup is gone now $anchortag = $OUTPUT->action_link($link, $anchortagcontents, $action); $this->content->text .= '<div class="message">' . $anchortag . '</div></li>'; } $this->content->text .= '</ul>'; } else { $this->content->text .= '<div class="info">'; $this->content->text .= get_string('nomessages', 'message'); $this->content->text .= '</div>'; } return $this->content; }
function UpdateINI() { global $db, $tablepre; $time = format_time(times()); $ini = "; 字段信息配置文件\r\n; Created On {$time}\r\n\r\n"; foreach (array(1 => 'USE', 2 => 'FEE', 3 => 'OUT') as $k => $v) { $ini .= "[{$v}]\r\n"; $result = $db->getAll("SELECT * FROM `{$tablepre}cardini` WHERE pid='{$k}' AND disabled=0"); foreach ($result as $r) { $ini .= $r['name'] . " = " . "\"" . $r['value'] . "\"\r\n"; } $ini .= "\r\n"; } @file_put_contents(ROOT_PATH . "data/detail.ini", $ini); }
/** Select data from table * @param string * @param array result of $adminer->selectColumnsProcess()[0] * @param array result of $adminer->selectSearchProcess() * @param array result of $adminer->selectColumnsProcess()[1] * @param array result of $adminer->selectOrderProcess() * @param int result of $adminer->selectLimitProcess() * @param int index of page starting at zero * @param bool whether to print the query * @return Min_Result */ function select($table, $select, $where, $group, $order = array(), $limit = 1, $page = 0, $print = false) { global $adminer, $jush; $is_group = count($group) < count($select); $query = $adminer->selectQueryBuild($select, $where, $group, $order, $limit, $page); if (!$query) { $query = "SELECT" . limit(($_GET["page"] != "last" && +$limit && $group && $is_group && $jush == "sql" ? "SQL_CALC_FOUND_ROWS " : "") . implode(", ", $select) . "\nFROM " . adminer_table($table), ($where ? "\nWHERE " . implode(" AND ", $where) : "") . ($group && $is_group ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : ""), $limit != "" ? +$limit : null, $page ? $limit * $page : 0, "\n"); } $start = microtime(true); $return = $this->_conn->query($query); if ($print) { echo $adminer->selectQuery($query, format_time($start)); } return $return; }
public function view() { global $db; $result = $db->query("SELECT * FROM trace WHERE addr={$this->addr} AND idx=255"); $row = $result->fetchArray(); if ($row) { include 'trace_layouts/' . sprintf("%02x", $row['value']) . '.php'; } $result = $db->query("SELECT * FROM trace WHERE addr={$this->addr} ORDER BY idx"); echo '<div><a href="?page=queue&read_trace=1&addr=' . $this->addr . '">Make refresh requests for all values</a></div>'; echo '<table><tr><th>name</th><th>idx</th><th>value</th><th>last_update</th><th>description</th></tr>'; while ($row = $result->fetchArray()) { printf("<tr><td>%s</td><td>0x%02x</td><td>0x%04x</td><td>%s</td><td>%s</td></tr>\n", $trace_layout_ids_double[$row['idx']][0], $row['idx'], $row['value'], format_time($row['time']), $trace_layout_ids_double[$row['idx']][1]); } echo "</table>"; }
public function splist() { //作品列表 $Model = M('Suipai'); $where['status'] = array('EQ', true); $count = $Model->where($where)->count(); $page = $this->Pages($count, 12); $pageurl = '?page=' . urlencode('[PAGE]'); $page->url = __APP__ . '/suipai/' . $pageurl; $list['total'] = 12; $Model = new Model(); $list['result'] = $Model->table(array(C('DB_PREFIX') . 'suipai' => 'S', C('DB_PREFIX') . 'user' => 'U'))->where('S.userid=U.userid and S.status=true')->field('S.title,S.content,S.id,S.create_time,S.image,U.nickname,U.uavatar,U.openuid,U.userid,U.ifrz')->order('S.create_time DESC')->limit($page->firstRow . ',' . $page->listRows)->select(); foreach ($list['result'] as $key => $value) { $list['result'][$key]['create_time'] = format_time($value['create_time']); $list['result'][$key]['uavatar'] = getUavatar($value['uavatar']); } exit(json_encode($list)); }
/** * Display the listing of hub where a course is registered on */ public function registeredonhublisting($courseid, $publications) { global $CFG; $table = new html_table(); $table->head = array(get_string('type', 'hub'), get_string('hub', 'hub'), get_string('date'), get_string('status', 'hub'), get_string('operation', 'hub')); $table->size = array('10%', '40%', '20%', '%10', '%15'); $brtag = html_writer::empty_tag('br'); foreach ($publications as $publication) { $updatebuttonhtml = ''; $params = array('sesskey' => sesskey(), 'id' => $publication->courseid, 'hubcourseid' => $publication->hubcourseid, 'huburl' => $publication->huburl, 'hubname' => $publication->hubname, 'cancel' => true, 'publicationid' => $publication->id, 'timepublished' => $publication->timepublished); $cancelurl = new moodle_url("/course/publish/index.php", $params); $cancelbutton = new single_button($cancelurl, get_string('removefromhub', 'hub')); $cancelbutton->class = 'centeredbutton'; $cancelbuttonhtml = $this->output->render($cancelbutton); if ($publication->enrollable) { $params = array('sesskey' => sesskey(), 'id' => $publication->courseid, 'huburl' => $publication->huburl, 'hubname' => $publication->hubname, 'share' => !$publication->enrollable, 'advertise' => $publication->enrollable); $updateurl = new moodle_url("/course/publish/metadata.php", $params); $updatebutton = new single_button($updateurl, get_string('update', 'hub')); $updatebutton->class = 'centeredbutton'; $updatebuttonhtml = $this->output->render($updatebutton); $operations = $updatebuttonhtml . $brtag . $cancelbuttonhtml; } else { $operations = $cancelbuttonhtml; } $hubname = html_writer::tag('a', $publication->hubname ? $publication->hubname : $publication->huburl, array('href' => $publication->huburl)); //if the publication check time if bigger than May 2010, it has been checked if ($publication->timechecked > 1273127954) { if ($publication->status == 0) { $status = get_string('statusunpublished', 'hub'); } else { $status = get_string('statuspublished', 'hub'); } $status .= $brtag . html_writer::tag('a', get_string('updatestatus', 'hub'), array('href' => $CFG->wwwroot . '/course/publish/index.php?id=' . $courseid . "&updatestatusid=" . $publication->id . "&sesskey=" . sesskey())) . $brtag . get_string('lasttimechecked', 'hub') . ": " . format_time(time() - $publication->timechecked); } else { $status = get_string('neverchecked', 'hub') . $brtag . html_writer::tag('a', get_string('updatestatus', 'hub'), array('href' => $CFG->wwwroot . '/course/publish/index.php?id=' . $courseid . "&updatestatusid=" . $publication->id . "&sesskey=" . sesskey())); } //add button cells $cells = array($publication->enrollable ? get_string('advertised', 'hub') : get_string('shared', 'hub'), $hubname, userdate($publication->timepublished, get_string('strftimedatetimeshort')), $status, $operations); $row = new html_table_row($cells); $table->data[] = $row; } $contenthtml = html_writer::table($table); return $contenthtml; }
function sign_out($name, $mysqli) { date_default_timezone_set("America/Chicago"); $statement = $mysqli->prepare("SELECT * FROM temp\n\t\t\t\t\t\t\t\t\t\t\tWHERE name = ?"); $statement->bind_param('s', $name); $statement->execute(); $result = $statement->get_result(); if ($result->num_rows === 0) { echo "<script> toastr.error('You aren\\'t signed in...') </script>"; return; } else { $time_in_seconds = time() - $result->fetch_object()->time_in; echo "<script> toastr.info('You have logged: " . format_time($time_in_seconds) . "') </script>"; insert($name, format_date(time()), $time_in_seconds, $mysqli); $statement = $mysqli->prepare("DELETE FROM temp\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE name = ?"); $statement->bind_param('s', $name); $statement->execute(); } }
function calendar_meta($e) { $private = false; if ($e['committee_name']) { $title = $e['committee_name']; if ($e['title'] == 'to consider the Bill') { } elseif ($e['title'] && $e['title'] != 'This is a private meeting.') { $title .= ': ' . $e['title']; } else { $private = true; } } else { $title = $e['title']; if ($pid = $e['person_id']) { $MEMBER = new MEMBER(array('person_id' => $pid)); $name = $MEMBER->full_name(); $title .= " – <a href='/mp/?p={$pid}'>{$name}</a>"; } } $meta = array(); if ($d = $e['debate_type']) { if ($d == 'Adjournment') { $d = 'Adjournment debate'; } $meta[] = $d; } if ($e['time_start'] || $e['location']) { if ($e['time_start']) { $time = format_time($e['time_start'], TIMEFORMAT); if ($e['time_end']) { $time .= ' – ' . format_time($e['time_end'], TIMEFORMAT); } $meta[] = $time; } if ($e['location']) { $meta[] = $e['location']; } } if ($private) { $meta[] = 'Private meeting'; } return array($title, $meta); }
function test_time_limit_access_rule() { $quiz = new stdClass(); $quiz->timelimit = 3600; $quiz->questions = ''; $cm = new stdClass(); $cm->id = 0; $quizobj = new quiz($quiz, $cm, null); $rule = new time_limit_access_rule($quizobj, 10000); $attempt = new stdClass(); $this->assertEqual($rule->description(), get_string('quiztimelimit', 'quiz', format_time(3600))); $attempt->timestart = 10000; $this->assertEqual($rule->time_left($attempt, 10000), 3600); $this->assertEqual($rule->time_left($attempt, 12000), 1600); $this->assertEqual($rule->time_left($attempt, 14000), -400); $this->assertFalse($rule->prevent_access()); $this->assertFalse($rule->prevent_new_attempt(0, $attempt)); $this->assertFalse($rule->is_finished(0, $attempt)); }
public function view() { global $db; $result = $db->query("SELECT * FROM eeprom WHERE addr={$this->addr} AND idx=255"); $row = $result->fetchArray(); if ($row) { include 'ee_layouts/' . sprintf("%02x", $row['value']) . '.php'; } $result = $db->query("SELECT * FROM eeprom WHERE addr={$this->addr} ORDER BY addr,idx"); echo '<div><a href="?page=queue&read_eeprom=1&addr=' . $this->addr . '">Make refresh requests for all values</a></div>'; echo '<form method="post" action="?page=eeprom&addr=' . $this->addr . '" /><table>'; echo '<table><tr><th>idx</th><th>idx</th><th>value</th><th>last_update</th><th>description</th></tr>'; while ($row = $result->fetchArray()) { $label = $layout_ids[$row['idx']]; $comment = $layout_ids_double[$row['idx']][1]; printf('<tr><td>%s</td><td>0x%02x</td><td>0x<input type="text" name="data_%d" size="2" value="%02x"></td><td>%s</td><td>%s</td></tr>', $label, $row['idx'], $row['idx'], $row['value'], format_time($row['time']), $comment); } echo '</table><input type="reset" value="Reset">'; echo '<input type="submit" value="Submit">'; echo "</form>"; }
function createlogs_install() { global $pluginName; $createdate = format_time("Y-m-d", filemtime("../include/config.php")); $arrPlugin['Name'] = "createlogs"; //Plugin name $arrPlugin['Desc'] = "createlogs"; //Plugin title $arrPlugin['Type'] = "Func"; //Plugin type $arrPlugin['Code'] = ""; //Plugin htmlcode $arrPlugin['Path'] = ""; //Plugin Path $arrPlugin['DefaultField'] = array("createdate"); //Default Filed $arrPlugin['DefaultValue'] = array("{$createdate}"); //Default value $ActionMessage = install_plugins($arrPlugin); return $ActionMessage; }
public function export_for_template(\renderer_base $output) { global $USER; $context = clone $this->notification; if ($context->useridto == $USER->id && $context->timeusertodeleted) { $context->deleted = true; } else { $context->deleted = false; } $context->timecreatedpretty = get_string('ago', 'message', format_time(time() - $context->timecreated)); $context->text = message_format_message_text($context); $context->read = $context->timeread ? true : false; $context->shortenedsubject = shorten_text($context->subject, 125); if (!empty($context->component) && substr($context->component, 0, 4) == 'mod_') { $iconurl = $output->pix_url('icon', $context->component); } else { $iconurl = $output->pix_url('i/marker', 'core'); } $context->iconurl = $iconurl->out(); return $context; }
function print_stats_top() { $localtitleprepend = ""; $localtitleappend = ""; $localheadextras = ""; $localbodytags = ""; if (isset($GLOBALS["titleprepend"])) { $localtitleprepend = $GLOBALS["titleprepend"]; } if (isset($GLOBALS["titleappend"])) { $localtitleappend = $GLOBALS["titleappend"]; } if (isset($GLOBALS["headextras"])) { $localheadextras = $GLOBALS["headextras"]; } if (isset($GLOBALS["bodytags"])) { $localbodytags = $GLOBALS["bodytags"]; } if (isset($GLOBALS["ldmain"])) { $ldmain = $GLOBALS["ldmain"]; } include "instant_livedata.php"; $GLOBALS["netdiff"] = $netdiff; $GLOBALS["phash"] = $phash; $GLOBALS["sharesperunit"] = $sharesperunit; $roundduration = format_time($roundduration); $liveluck = round($netdiff / $roundshares * 100); if ($liveluck > 9999) { $liveluck = ">9999%"; } if (!isset($ldmain)) { $ldmain = ""; } $rnd = rand() * rand() + rand(); print "<HTML>\n<HEAD>\n<TITLE>" . $localtitleprepend . $GLOBALS["poolname"] . " Pool Statistics" . $localtitleappend . "</TITLE>\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge,chrome=1\">\n<!--[if lt IE 9]><script src=\"" . $GLOBALS["urlprefix"] . "IE9.js\"></script><![endif]-->\n<script type=\"text/javascript\" src=\"" . $GLOBALS["urlprefix"] . "dygraph-combined.js\"></script>\n<script type=\"text/javascript\" src=\"" . $GLOBALS["urlprefix"] . "jquery.js\"></script>\n<script type=\"text/javascript\" src=\"" . $GLOBALS["urlprefix"] . "sortable.js\"></script>\n<script type=\"text/javascript\" src=\"" . $GLOBALS["urlprefix"] . "instantscripts.php/livedata{$ldmain}.js?rand={$rnd}\"></script>\n<!--[if IE]><script type=\"text/javascript\" src=\"" . $GLOBALS["urlprefix"] . "excanvas.js\"></script><![endif]-->\n<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $GLOBALS["urlprefix"] . "stats-style.css\">\n" . $localheadextras . "\n</HEAD>\n<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#0000FF\" VLINK=\"#0000FF\" ALINK=\"#D3643B\" onLoad=\"initShares();\" " . $localbodytags . ">\n<div id=\"wrapper\">\n<div id=\"Eligius-Title\">\n\t<H2><A HREF=\"" . $GLOBALS["urlprefix"] . "\">" . $GLOBALS["poolname"] . " Pool Statistics</A></H2><!--[if IE]><BR><![endif]-->\n\t<h4>Donations to help stats development:<BR><B>1Stats</B>Qytc7UEZ9sHJ9BGX2csmkj8XZr2</h4>\n</div>\n<div id=\"luck\">\n<TABLE class=\"lucktable\" width=\"100%\">\n<TR>\n<TD width=\"30%\" style=\"text-align: left\">Hashrate:</TD><TD width=\"25%\" style=\"text-align: right; border-right:1px dotted #CCCCCC; padding-right: 3px; white-space: nowrap;\" id=\"livehashrate\">{$phash}</TD>\n<TD width=\"25%\" style=\"text-align: left\">Round Time:</TD><TD width=\"20%\" style=\"text-align: right\" id=\"roundtime\">{$roundduration}</TD>\n</TR>\n<TR>\n<TD width=\"30%\" style=\"text-align: left\">Round Shares:</TD><TD width=\"25%\" style=\"text-align: right; border-right:1px dotted #CCCCCC; padding-right: 3px;\" id=\"sharecounter\">{$roundshares}</TD>\n<TD width=\"25%\" style=\"text-align: left\">Round Luck:</TD><TD width=\"20%\" style=\"text-align: right\" id=\"liveluck\">{$liveluck}%</TD>\n</TR>\n</TABLE>\n</div>\n<br>\n<br>\n<br>\n<br>\n<div id=\"line\"></div>\n<center>\n<ul id=\"menu\">\n <li><a href=\"" . $GLOBALS["urlprefix"] . "\">Home</a></li>\n <li><a href=\"" . $GLOBALS["urlprefix"] . "mystats.php\">My " . $GLOBALS["poolname"] . "</a></li>\n <li><a href=\"" . $GLOBALS["urlprefix"] . "blocks.php\">Blocks</a></li>\n <li><a href=\"" . $GLOBALS["urlprefix"] . "topcontributors.php\">Contributors</a></li>\n <li><a target=\"_blank\" href=\"https://github.com/wizkid057/wizstats\">GitHub</a></li>\n <li><a href=\"/\">" . $GLOBALS["poolname"] . " Homepage</a></li>\n</ul>\n</center>\n<br>\n<br>\n<br>\n<!--[if IE]><H4>This page works best in <A HREF=\"http://www.google.com/chrome\">Google Chrome</A>. You will not have an optimal experience using Internet Explorer.</H4><![endif]-->\n"; if (apc_fetch('cppsrb_ok') == -1) { print "<TABLE BORDER=1><TR><TD><FONT SIZE=\"+2\" COLOR=\"RED\"><B>AUTO-NOTICE</B>: The CPPSRB reward system appears to be in fail-safe mode.</FONT></TD></TR><TR><TD><FONT COLOR=\"RED\">Some stats are likely not updating as they should right now (128/256 second hash rates, balances, balance graph, payout queue). These items will correct themselves soon when CPPSRB is out of fail safe mode. This can take several hours. <B>No earnings are lost as long as your shares are accepted!</B> Sorry for the inconvenience!</FONT></TD></TR></TABLE><BR>"; } }
function blueprints_info() { global $smarty, $sql; $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : ''; $blueprint_id = isset($_REQUEST['blueprint_id']) ? $_REQUEST['blueprint_id'] : ''; if (!in_array($type, array('army', 'navy', 'weapon')) || empty($blueprint_id)) { error(__FILE__, __LINE__, 'INVALID_ID/TYPE', 'Invalid type and/or blueprint_id'); } $sql->where(array($type . 'blueprints', $type . 'blueprint_id', $blueprint_id)); $sql->limit(1); $db_result = $sql->execute(); if (mysql_num_rows($db_result) == 0) { error(__FILE__, __LINE__, 'INVALID_ID', 'Invalid blueprint_id'); } $blueprint = mysql_fetch_array($db_result, MYSQL_ASSOC); if ($blueprint['kingdom_id'] != $_SESSION['kingdom_id']) { error(__FILE__, __LINE__, 'INVALID_ACCESS', 'You do not have permission to access that blueprint.'); } $blueprint['mineralspread'] = unserialize($blueprint['mineralspread']); $blueprint['resources']['time'] = format_time(timeparser($blueprint['time'] * $_SESSION['round_speed'])); $blueprint['resources']['workers'] = format_number($blueprint['workers'], true); $blueprint['resources']['energy'] = format_number($blueprint['energy'], true); if (!empty($blueprint['mineralspread'])) { $mineralnames = array(0 => 'fe', 1 => 'o', 2 => 'si', 3 => 'mg', 4 => 'ni', 5 => 's', 6 => 'he', 7 => 'h'); foreach ($blueprint['mineralspread'] as $key => $value) { $resources['minerals'][$mineralnames[$key]] = format_number($blueprint['minerals'] / $value, true); } $blueprint['resources']['minerals'] = $resources['minerals']; } if ($type == 'weapon') { $blueprint['targets'] = unserialize($blueprint['targets']); } else { $blueprint['weapons'] = unserialize($blueprint['weapons']); } blueprints_stats($type, $blueprint_id); $smarty->assign('type', $type); $smarty->assign('blueprint', $blueprint); $smarty->display('blueprints_info.tpl'); }
function RecentTB($sidename, $sidetitle, $isInstall) { global $DBPrefix, $DMC, $strSideBarAnd, $strHomePagePost; if (isset($_COOKIE["content_{$sidename}"])) { $display = $_COOKIE["content_{$sidename}"]; } else { $display = $isInstall > 0 ? "none" : ""; } ?> <!--RecentTB--> <div id="Side_RecentTB" class="sidepanel"> <h4 class="Ptitle" style="cursor: pointer;" onclick="sidebarTools('<?php echo "content_{$sidename}"; ?> ')"><?php echo $sidetitle; ?> </h4> <div class="Pcontent" id="<?php echo "content_{$sidename}"; ?> " style="display:<?php echo $display; ?> "> <?php $tbsql = "select * from " . $DBPrefix . "trackbacks where isApp='1' order by postTime desc Limit 0,10"; $tbrst = $DMC->query($tbsql); while ($my = $DMC->fetchArray($tbrst)) { $blogSite = str_replace("'", "'", $my['blogSite']); echo "<a class=\"sideA\" id=\"TB_Link\" title=\"" . $blogSite . " {$strSideBarAnd} " . format_time("L", $my['postTime']) . " {$strHomePagePost}\n" . $my['content'] . "\" href=\"index.php?load=read&id=" . $my['logId'] . "#tb" . $my['id'] . "\">" . $my['content'] . "</a> \n"; } ?> </div> <div class="Pfoot"></div> </div> <?php }
function getArrayInfo($include_trash_info = false, $include_archive_info = false) { if ($this->getCreatedOn()){ $dateCreated = $this->getCreatedOn()->isToday() ? lang('today') ." ". format_time($this->getCreatedOn()) : format_datetime($this->getCreatedOn()); } if ($this->getUpdatedOn()){ $dateUpdated = $this->getUpdatedOn()->isToday() ? lang('today') ." ". format_time($this->getUpdatedOn()) : format_datetime($this->getUpdatedOn()); } $info = array( 'object_id' => $this->getId(), 'ot_id' => $this->getObjectTypeId(), 'name' => $this->getName(), 'type' => $this->getObjectTypeName(), 'icon' => $this->getType()->getIconClass(), 'createdBy' => $this->getCreatedByDisplayName(), 'createdById' => $this->getCreatedById(), 'dateCreated' => $dateCreated, 'updatedBy' => $this->getUpdatedByDisplayName(), 'updatedById' => $this->getUpdatedById(), 'dateUpdated' => $dateUpdated, 'url' => $this->getViewUrl() ); if ($include_trash_info) { $dateTrashed = $this->getTrashedOn() instanceof DateTimeValue ? ($this->getTrashedOn()->isToday() ? format_time($this->getTrashedOn()) : format_datetime($this->getTrashedOn())) : lang('n/a'); $info['deletedBy'] = $this->getTrashedByDisplayName(); $info['deletedById'] = $this->getColumnValue('trashed_by_id'); $info['dateDeleted'] = $dateTrashed; } if ($include_archive_info) { $dateArchived = $this->getArchivedOn() instanceof DateTimeValue ? ($this->getArchivedOn()->isToday() ? format_time($this->getArchivedOn()) : format_datetime($this->getArchivedOn())) : lang('n/a'); $archived_by = Contacts::findById($this->getArchivedById()); $info['archivedBy'] = $archived_by instanceof Contact ? $archived_by->getObjectName() : lang('n/a'); $info['archivedById'] = $this->getArchivedById(); $info['dateArchived'] = $dateArchived; } return $info; }