当前位置: 首页>>代码示例>>PHP>>正文


PHP format_time函数代码示例

本文整理汇总了PHP中format_time函数的典型用法代码示例。如果您正苦于以下问题:PHP format_time函数的具体用法?PHP format_time怎么用?PHP format_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了format_time函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: view

    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";
    }
开发者ID:hannemann,项目名称:openhr20-webapp,代码行数:27,代码来源:raw_command_queue.php

示例2: show_activity

    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;
    }
开发者ID:mdb-webdev,项目名称:Fancy-Extensions,代码行数:33,代码来源:functions.inc.php

示例3: view

 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";
 }
开发者ID:esven,项目名称:OpenHR20,代码行数:34,代码来源:debug_log.php

示例4: get_system_confs

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;
}
开发者ID:sdgdsffdsfff,项目名称:html-sensor,代码行数:35,代码来源:funcs.php

示例5: military_overview

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');
}
开发者ID:WilliamJamesDalrympleWest,项目名称:imperial-kingdoms,代码行数:60,代码来源:military.php

示例6: help_status

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;
}
开发者ID:WilliamJamesDalrympleWest,项目名称:imperial-kingdoms,代码行数:25,代码来源:help.php

示例7: view

 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";
 }
开发者ID:esven,项目名称:OpenHR20,代码行数:33,代码来源:history.php

示例8: get_content

 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 . '&amp;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="" />&nbsp;' . $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;
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:34,代码来源:block_messages.php

示例9: definition

 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) . "&nbsp; (" . 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);
 }
开发者ID:andrewhancox,项目名称:moodle-mod_giportfolio,代码行数:25,代码来源:updategrade_form.php

示例10: out_time

function out_time($var)
{
    global $capture_times;
    if ($var == "0") {
        echo "N/A";
    } else {
        echo format_time($capture_times[$var]);
    }
}
开发者ID:nstroustrup,项目名称:lifespan,代码行数:9,代码来源:view_movement_data.php

示例11: add_preflight_check_form_fields

 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'));
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:9,代码来源:rule.php

示例12: get_shift_session

 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);
 }
开发者ID:Kaelcao,项目名称:colormev2,代码行数:10,代码来源:ManageShiftController.php

示例13: get_today_stats2

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;
    }
}
开发者ID:kipkaev55,项目名称:asterisk,代码行数:54,代码来源:operators_status.php

示例14: writetofile

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;
}
开发者ID:haseok86,项目名称:millkencode,代码行数:12,代码来源:global.func.php

示例15: get_content

 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 . '&amp;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="" />&nbsp;' . $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;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:52,代码来源:block_messages.php


注:本文中的format_time函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。