function mail_read()
{
    global $smarty;
    $mail_id = (int) $_REQUEST['mail_id'];
    $db_query = "\n\t\t\tSELECT \n\t\t\t\t`players`.`name` as 'from', \n\t\t\t\t`mail`.`mail_id`, \n\t\t\t\t`mail`.`from_player_id`, \n\t\t\t\t`mail`.`body`, \n\t\t\t\t`mail`.`subject`, \n\t\t\t\t`mail`.`time`, \n\t\t\t\t`mail`.`status` \n\t\t\tFROM `mail` \n\t\t\tLEFT JOIN `players` ON `players`.`player_id` = `mail`.`from_player_id` \n\t\t\tWHERE \n\t\t\t\t`mail`.`round_id` = '" . $_SESSION['round_id'] . "' AND \n\t\t\t\t`mail`.`mail_id` = '" . $mail_id . "' AND \n\t\t\t\t`mail`.`to_player_id` = '" . $_SESSION['player_id'] . "' AND \n\t\t\t\t`mail`.`status` != '" . MAILSTATUS_DELETED . "'\n\t\t\tORDER BY `time` ASC \n\t\t\tLIMIT 30";
    $db_result = mysql_query($db_query);
    if (mysql_num_rows($db_result) == 0) {
        $status[] = 'That mail does not exist or you do not have permission to view it.';
        $smarty->append('status', $status);
        mail_list();
        exit;
    }
    $mail = mysql_fetch_array($db_result, MYSQL_ASSOC);
    $mail['time'] = format_timestamp($mail['time'] + 3600 * $_SESSION['preferences']['timezone']);
    $mail['subject'] = htmlentities($mail['subject']);
    $mail['body'] = nl2br(htmlentities($mail['body']));
    if ($mail['from_player_id'] == 0) {
        $mail['from'] = 'Administration';
    }
    $bbtags = array('b' => array('Name' => 'b', 'HtmlBegin' => '<span style="font-weight: bold;">', 'HtmlEnd' => '</span>'), 'i' => array('Name' => 'i', 'HtmlBegin' => '<span style="font-style: italic;">', 'HtmlEnd' => '</span>'), 'u' => array('Name' => 'u', 'HtmlBegin' => '<span style="text-decoration: underline;">', 'HtmlEnd' => '</span>'), 's' => array('Name' => 's', 'HtmlBegin' => '<span style="text-decoration: line-through;">', 'HtmlEnd' => '</span>'), 'quote' => array('Name' => 'quote', 'HasParam' => true, 'HtmlBegin' => '<b>Quote %%P%%:</b><div class="mailquote">', 'HtmlEnd' => '</div>'));
    require_once dirname(__FILE__) . '/includes/bbcode.php';
    $bbcode = new bbcode();
    $bbcode->add_tag($bbtags['b']);
    $bbcode->add_tag($bbtags['i']);
    $bbcode->add_tag($bbtags['u']);
    $bbcode->add_tag($bbtags['s']);
    $bbcode->add_tag($bbtags['quote']);
    $mail['body'] = $bbcode->parse_bbcode($mail['body']);
    if ($mail['status'] == 1) {
        $db_query = "UPDATE `mail` SET `status` = '2' WHERE `mail_id` = '" . $mail_id . "' LIMIT 1";
        $db_result = mysql_query($db_query);
    }
    $smarty->assign('mail', $mail);
    $smarty->display('mail_read.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;
}
function add_news_entry($type, $information)
{
    global $sql, $smarty;
    require_once dirname(__FILE__) . '/news_resource.php';
    $sql->select(array('news_entries', 'news_entry_id'));
    $sql->where(array('news_entries', 'type', $type));
    $sql->raw(array('orderby', 'RAND(' . microfloat() . ')'));
    $sql->limit(1);
    $db_result = $sql->execute();
    $db_row = mysql_fetch_array($db_result, MYSQL_ASSOC);
    $news_entry_id = $db_row['news_entry_id'];
    $posted = $information['posted'];
    $information['posted'] = format_timestamp($information['posted']);
    foreach ($information as $key => $value) {
        $smarty->assign($key, $value);
    }
    $smarty->fetch('news:' . $news_entry_id);
    $entry_subject = $smarty->get_template_vars('subject');
    $entry_body = $smarty->get_template_vars('body');
    $news_insert = array('round_id' => $_SESSION['round_id'], 'type' => $type, 'subject' => $entry_subject, 'body' => $entry_body, 'posted' => $posted);
    $fields = array('kingdom_id', 'player_id', 'planet_id');
    foreach ($fields as $value) {
        if (!empty($information[$value])) {
            $news_insert[$value] = $information[$value];
        }
    }
    $sql->execute('news', $news_insert);
}
示例#4
0
function format_message($row)
{
    $msg = irc_split_message($row['data']);
    extract($msg);
    switch ($command) {
        case 'PRIVMSG':
            if ($message[0] == "") {
                $o = "* " . format_nick($origin) . " " . str_replace("ACTION", '', $message);
            } else {
                $o = "&lt;" . format_nick($origin) . "&gt; {$message}";
            }
            break;
        case 'NICK':
            $o = format_nick($origin) . " is now known as\n\t\t\t\t" . format_nick($message);
            break;
        case 'JOIN':
            $o = format_nick($origin) . " has joined {$dest}";
            break;
        case 'QUIT':
            $o = format_nick($origin) . " has quit ({$message})";
            break;
        default:
            $o = $row['data'];
    }
    return format_timestamp($row['timestamp']) . " {$o}<br />";
}
示例#5
0
function print_welcome_block($block = true, $config = "", $side, $index)
{
    global $pgv_lang, $PGV_IMAGE_DIR, $PGV_IMAGES;
    $id = "user_welcome";
    $title = $pgv_lang["welcome"] . " " . getUserFullName(PGV_USER_ID);
    $content = "<table class=\"blockcontent\" cellspacing=\"0\" cellpadding=\"0\" style=\" width: 100%; direction:ltr;\"><tr>";
    $content .= "<td class=\"tab_active_bottom\" colspan=\"3\" ></td></tr><tr>";
    if (get_user_setting(PGV_USER_ID, 'editaccount') == 'Y') {
        $content .= "<td class=\"center details2\" style=\" width: 33%; clear: none; vertical-align: top; margin-top: 2px;\"><a href=\"edituser.php\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["mygedview"]["small"] . "\" border=\"0\" alt=\"" . $pgv_lang["myuserdata"] . "\" title=\"" . $pgv_lang["myuserdata"] . "\" /><br />" . $pgv_lang["myuserdata"] . "</a></td>";
    }
    if (PGV_USER_GEDCOM_ID) {
        $content .= "<td class=\"center details2\" style=\" width: 34%; clear: none; vertical-align: top; margin-top: 2px;\"><a href=\"" . encode_url("pedigree.php?rootid=" . PGV_USER_GEDCOM_ID) . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["pedigree"]["small"] . "\" border=\"0\" alt=\"" . $pgv_lang["my_pedigree"] . "\" title=\"" . $pgv_lang["my_pedigree"] . "\" /><br />" . $pgv_lang["my_pedigree"] . "</a></td>";
        $content .= "<td class=\"center details2\" style=\" width: 33%; clear: none; vertical-align: top; margin-top: 2px;\"><a href=\"" . encode_url("individual.php?pid=" . PGV_USER_GEDCOM_ID) . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["indis"]["small"] . "\" border=\"0\" alt=\"" . $pgv_lang["my_indi"] . "\" title=\"" . $pgv_lang["my_indi"] . "\" /><br />" . $pgv_lang["my_indi"] . "</a></td>";
    }
    $content .= "</tr><tr><td class=\"center\" colspan=\"3\">";
    $content .= print_help_link("mygedview_customize_help", "qm", "", false, true);
    $content .= "<a href=\"javascript:;\" onclick=\"window.open('" . encode_url("index_edit.php?name=" . PGV_USER_NAME . "&ctype=user") . "', '_blank', 'top=50,left=10,width=600,height=350,scrollbars=1,resizable=1');\">" . $pgv_lang["customize_page"] . "</a>";
    $content .= "<br />" . format_timestamp(client_time());
    $content .= "</td>";
    $content .= "</tr></table>";
    global $THEME_DIR;
    if ($block) {
        require $THEME_DIR . 'templates/block_small_temp.php';
    } else {
        require $THEME_DIR . 'templates/block_main_temp.php';
    }
}
示例#6
0
 public function getBlock($block_id, $template = true, $cfg = null)
 {
     global $ctype;
     switch (WT_Filter::get('action')) {
         case 'deletenews':
             $news_id = WT_Filter::getInteger('news_id');
             if ($news_id) {
                 deleteNews($news_id);
             }
             break;
     }
     $block = get_block_setting($block_id, 'block', true);
     if ($cfg) {
         foreach (array('block') as $name) {
             if (array_key_exists($name, $cfg)) {
                 ${$name} = $cfg[$name];
             }
         }
     }
     $usernews = getUserNews(WT_USER_ID);
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = '';
     $title .= $this->getTitle();
     $content = '';
     if (count($usernews) == 0) {
         $content .= WT_I18N::translate('You have not created any journal items.');
     }
     foreach ($usernews as $key => $news) {
         $day = date('j', $news['date']);
         $mon = date('M', $news['date']);
         $year = date('Y', $news['date']);
         $content .= "<div class=\"journal_box\">";
         $content .= "<div class=\"news_title\">" . $news['title'] . '</div>';
         $content .= "<div class=\"news_date\">" . format_timestamp($news['date']) . '</div>';
         if ($news["text"] == strip_tags($news["text"])) {
             // No HTML?
             $news["text"] = nl2br($news["text"], false);
         }
         $content .= $news["text"] . "<br><br>";
         $content .= "<a href=\"#\" onclick=\"window.open('editnews.php?news_id='+" . $key . ", '_blank', indx_window_specs); return false;\">" . WT_I18N::translate('Edit') . "</a> | ";
         $content .= "<a href=\"index.php?action=deletenews&amp;news_id={$key}&amp;ctype={$ctype}\" onclick=\"return confirm('" . WT_I18N::translate('Are you sure you want to delete this journal entry?') . "');\">" . WT_I18N::translate('Delete') . "</a><br>";
         $content .= "</div><br>";
     }
     if (WT_USER_ID) {
         $content .= "<br><a href=\"#\" onclick=\"window.open('editnews.php?user_id='+WT_USER_ID, '_blank', indx_window_specs); return false;\">" . WT_I18N::translate('Add a new journal entry') . "</a>";
     }
     if ($template) {
         if ($block) {
             require WT_THEME_DIR . 'templates/block_small_temp.php';
         } else {
             require WT_THEME_DIR . 'templates/block_main_temp.php';
         }
     } else {
         return $content;
     }
 }
示例#7
0
/**
 * Prints a user news/journal
 *
 */
function print_user_news($block = true, $config = "", $side, $index)
{
    global $pgv_lang, $PGV_IMAGE_DIR, $PGV_IMAGES, $TEXT_DIRECTION, $ctype;
    $usernews = getUserNews(PGV_USER_ID);
    $id = "user_news";
    $title = print_help_link("mygedview_myjournal_help", "qm", "", false, true);
    $title .= $pgv_lang["my_journal"];
    $content = "";
    if (count($usernews) == 0) {
        $content .= $pgv_lang["no_journal"] . ' ';
    }
    foreach ($usernews as $key => $news) {
        $day = date("j", $news["date"]);
        $mon = date("M", $news["date"]);
        $year = date("Y", $news["date"]);
        $content .= "<div class=\"person_box\">";
        $ct = preg_match("/#(.+)#/", $news["title"], $match);
        if ($ct > 0) {
            if (isset($pgv_lang[$match[1]])) {
                $news["title"] = str_replace($match[0], $pgv_lang[$match[1]], $news["title"]);
            }
        }
        $content .= "<span class=\"news_title\">" . PrintReady($news["title"]) . "</span><br />";
        $content .= "<span class=\"news_date\">" . format_timestamp($news["date"]) . "</span><br /><br />";
        if (preg_match("/#(.+)#/", $news["text"], $match)) {
            if (isset($pgv_lang[$match[1]])) {
                $news["text"] = str_replace($match[0], $pgv_lang[$match[1]], $news["text"]);
            }
        }
        if (preg_match("/#(.+)#/", $news["text"], $match)) {
            if (isset($pgv_lang[$match[1]])) {
                $news["text"] = str_replace($match[0], $pgv_lang[$match[1]], $news["text"]);
            }
            if (isset(${$match}[1])) {
                $news["text"] = str_replace($match[0], ${$match}[1], $news["text"]);
            }
        }
        $trans = get_html_translation_table(HTML_SPECIALCHARS);
        $trans = array_flip($trans);
        $news["text"] = strtr($news["text"], $trans);
        $news["text"] = nl2br($news["text"]);
        $content .= PrintReady($news["text"]) . "<br /><br />";
        $content .= "<a href=\"javascript:;\" onclick=\"editnews('{$key}'); return false;\">" . $pgv_lang["edit"] . "</a> | ";
        $content .= "<a href=\"" . encode_url("index.php?action=deletenews&news_id={$key}&ctype={$ctype}") . "\" onclick=\"return confirm('" . $pgv_lang["confirm_journal_delete"] . "');\">" . $pgv_lang["delete"] . "</a><br />";
        $content .= "</div><br />";
    }
    if (PGV_USER_ID) {
        $content .= "<br /><a href=\"javascript:;\" onclick=\"addnews('" . PGV_USER_ID . "'); return false;\">" . $pgv_lang["add_journal"] . "</a>";
    }
    global $THEME_DIR;
    if ($block) {
        require $THEME_DIR . 'templates/block_small_temp.php';
    } else {
        require $THEME_DIR . 'templates/block_main_temp.php';
    }
}
示例#8
0
function print_gedcom_block($block = true, $config = "", $side, $index)
{
    global $hitCount, $pgv_lang, $SHOW_COUNTER;
    $id = "gedcom_welcome";
    $title = PrintReady(get_gedcom_setting(PGV_GED_ID, 'title'));
    $content = "<div class=\"center\">";
    $content .= "<br />" . format_timestamp(client_time()) . "<br />\n";
    if ($SHOW_COUNTER) {
        $content .= $pgv_lang["hit_count"] . " " . $hitCount . "<br />\n";
    }
    $content .= "\n<br />";
    if (PGV_USER_GEDCOM_ADMIN) {
        $content .= "<a href=\"javascript:;\" onclick=\"window.open('" . encode_url("index_edit.php?name=" . PGV_GEDCOM . "&ctype=gedcom") . "', '_blank', 'top=50,left=10,width=600,height=500,scrollbars=1,resizable=1'); return false;\">" . $pgv_lang["customize_gedcom_page"] . "</a><br />\n";
    }
    $content .= "</div>";
    global $THEME_DIR;
    require $THEME_DIR . 'templates/block_main_temp.php';
}
function news()
{
    global $smarty, $sql, $data;
    $scores = news_scores();
    $smarty->assign('scores', $scores);
    $players = news_players();
    $smarty->assign('players', $players);
    $smarty->assign('kingdom_id', $_SESSION['kingdom_id']);
    $playerstats = news_playerstats();
    $smarty->assign('playerstats', $playerstats);
    //		 $type_news = array(
    //			 'military' => array(NEWS_WAR, NEWS_PEACE, NEWS_ALLY, NEWS_PLANETCONQUERED, NEWS_PLAYERCAPTURED, NEWS_KINGDOMDEFEATED),
    //			 'infrastructure' => array(NEWS_FIRSTRESEARCH, NEWS_RESEARCH, NEWS_BUILDING, NEWS_COMMISSION));
    $global_news = array(NEWS_WAR, NEWS_PEACE, NEWS_ALLY, NEWS_FIRSTRESEARCH, NEWS_PLANETCONQUERED, NEWS_PLAYERCAPTURED, NEWS_KINGDOMDEFEATED, NEWS_EXECUTION, NEWS_GAMEANNOUNCEMENT);
    $kingdom_news = array(NEWS_RESEARCH);
    $player_news = array(NEWS_BUILDING, NEWS_COMMISSION);
    $news = array();
    if (!empty($_REQUEST['news_id'])) {
        $news_id = abs((int) $_REQUEST['news_id']);
        $sql->where(array('news', 'news_id', $news_id));
        $db_result = $sql->execute();
        $db_row = mysql_fetch_array($db_result, MYSQL_ASSOC);
        if (in_array($db_row['type'], $global_news) || in_array($db_row['type'], $kingdom_news) && $db_row['kingdom_id'] == $_SESSION['kingdom_id'] || in_array($db_row['type'], $player_news) && $db_row['player_id'] == $_SESSION['player_id']) {
            $news[] = $db_row;
        }
    }
    if (empty($news)) {
        $db_query = "\n\t\t\t\tSELECT * \n\t\t\t\tFROM `news` \n\t\t\t\tWHERE \n\t\t\t\t\t`round_id` = '" . $_SESSION['round_id'] . "' AND \n\t\t\t\t\t(\n\t\t\t\t\t\t`type` IN ('" . implode("', '", $global_news) . "')";
        $player = $data->player($_SESSION['player_id']);
        if ($player['rank'] > 0) {
            $db_query .= " OR \n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t`type` IN ('" . implode("', '", $kingdom_news) . "') AND \n\t\t\t\t\t\t\t`kingdom_id` = '" . $_SESSION['kingdom_id'] . "'\n\t\t\t\t\t\t) OR\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t`type` IN ('" . implode("', '", $player_news) . "') AND \n\t\t\t\t\t\t\t`kingdom_id` = '" . $_SESSION['kingdom_id'] . "' AND \n\t\t\t\t\t\t\t`player_id` = '" . $_SESSION['player_id'] . "'\n\t\t\t\t\t\t)";
        }
        $db_query .= "\n\t\t\t\t\t)\n\t\t\t\tORDER BY `posted` DESC \n\t\t\t\tLIMIT 20";
        $db_result = mysql_query($db_query);
        while ($db_row = mysql_fetch_array($db_result, MYSQL_ASSOC)) {
            $db_row['posted'] = format_timestamp($db_row['posted']);
            $news[] = $db_row;
        }
    }
    $smarty->assign('news', $news);
    $smarty->display('news.tpl');
}
             $rev['count']++;
         }
     }
     if ($rev['count']) {
         $rev['type'] = 'svn';
     }
 }
 if (!$rev['count'] && is_executable($config['git'])) {
     $cmd_dir = escapeshellarg(dirname($device_config_file));
     $git_dir = escapeshellarg(dirname($device_config_file) . '/.git');
     $gitlogs = external_exec($config['git'] . ' --git-dir=' . $git_dir . ' --work-tree=' . $cmd_dir . ' log --pretty=format:"%h %ci" ' . $cmd_file);
     foreach (explode("\n", $gitlogs) as $line) {
         // b6989b9 2014-11-10 00:16:53 +0100
         // 66840ee 2014-11-02 23:34:18 +0100
         if (preg_match('/(?<rev>\\w+) (?<date>[\\d\\-]+ [\\d:]+ [\\+\\-]?\\d+)/', $line, $matches)) {
             $rev['list'][] = array('rev' => $matches['rev'], 'date' => format_timestamp($matches['date']));
             $rev['count']++;
         }
     }
     if ($rev['count']) {
         $rev['type'] = 'git';
     }
 }
 $navbar['options']['latest']['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'));
 $navbar['options']['latest']['class'] = 'active';
 if ($rev['count']) {
     $rev_active_index = 0;
     foreach ($rev['list'] as $i => $entry) {
         $rev_name = $rev['type'] == 'svn' ? 'r' . $entry['rev'] : $entry['rev'];
         if ($i > 9) {
             break;
示例#11
0
             $output .= '<td class="list_label">GEDCOM</td>';
             $output .= '<td class="list_label">' . $pgv_lang['undo'] . '</td>';
             $output .= '</tr>';
         }
         if ($i == count($changes) - 1) {
             $output .= "<td class=\"list_value {$TEXT_DIRECTION}\"><a href=\"" . encode_url("edit_changes.php?action=accept&cid={$cid}") . "\">" . $pgv_lang['accept'] . "</a></td>";
         } else {
             $output .= "<td class=\"list_value {$TEXT_DIRECTION}\">&nbsp;</td>";
         }
         $output .= "<td class=\"list_value {$TEXT_DIRECTION}\"><b>" . $pgv_lang[$change['type']] . "</b></td>";
         $output .= "<td class=\"list_value {$TEXT_DIRECTION}\"><a href=\"javascript:;\" onclick=\"return reply('" . $change['user'] . "', '" . $pgv_lang['review_changes'] . "')\" alt=\"" . $pgv_lang['message'] . "\">";
         if ($user_id = get_user_id($change['user'])) {
             $output .= PrintReady(getUserFullName($user_id));
         }
         $output .= PrintReady("&nbsp;(" . $change['user'] . ")") . "</a></td>";
         $output .= "<td class=\"list_value {$TEXT_DIRECTION}\">" . format_timestamp($change['time']) . "</td>";
         $output .= "<td class=\"list_value {$TEXT_DIRECTION}\">" . $change['gedcom'] . "</td>";
         if ($i == count($changes) - 1) {
             $output .= "<td class=\"list_value {$TEXT_DIRECTION}\"><a href=\"" . encode_url("edit_changes.php?action=undo&cid={$cid}&index={$i}") . "\">" . $pgv_lang['undo'] . "</a></td>";
         } else {
             $output .= "<td class=\"list_value {$TEXT_DIRECTION}\">&nbsp;</td>";
         }
         $output .= '</tr>';
         if ($i == count($changes) - 1) {
             $output .= '</table></div><br />';
         }
     }
 }
 $output .= "</td></tr></table>";
 //-- Now for the global Action bar:
 $output2 = "<br /><table class=\"list_table\">";
function reports_view()
{
    global $smarty, $sql;
    if (!empty($_REQUEST['combatreport_id'])) {
        $combatreport_id = abs((int) $_REQUEST['combatreport_id']);
    }
    $sql->select(array('combatreports', 'report'));
    $sql->where(array(array('combatreports', 'combatreport_id', $combatreport_id), array('combatreports', 'round_id', $_SESSION['round_id']), array('combatreports', 'kingdom_id', $_SESSION['kingdom_id'])));
    $sql->limit(1);
    $db_result = $sql->execute();
    if (!$db_result || mysql_num_rows($db_result) == 0) {
        error(__FILE__, __LINE__, 'INVALID_COMBATREPORT', 'Invalid combat report specified.');
    }
    $db_row = mysql_fetch_array($db_result, MYSQL_ASSOC);
    $combatreport = unserialize($db_row['report']);
    $combatreport['header']['date'] = format_timestamp($combatreport['header']['date']);
    foreach ($combatreport['names'] as $category => $names) {
        if ($category == 'kingdoms' || $category == 'weapons') {
            foreach ($names as $id => $name) {
                $combatreport['names'][$category][$id] = strshort($name, 20, '<span title="' . $name . '">...</span>');
            }
        } else {
            foreach ($names as $type => $more_names) {
                foreach ($more_names as $id => $name) {
                    $combatreport['names'][$category][$type][$id] = strshort($name, 20, '<span title="' . $name . '">...</span>');
                }
            }
        }
    }
    // Format all the numbers
    foreach ($combatreport['details'] as $kingdom_id => $types) {
        foreach ($types as $type => $groups) {
            foreach ($groups as $group_id => $units) {
                foreach ($units as $unit_id => $weapons) {
                    foreach ($weapons as $weapon_id => $target) {
                        foreach ($target as $detail_id => $details) {
                            $combatreport['details'][$kingdom_id][$type][$group_id][$unit_id][$weapon_id][$detail_id]['hits'] = format_number($combatreport['details'][$kingdom_id][$type][$group_id][$unit_id][$weapon_id][$detail_id]['hits'], true);
                            $combatreport['details'][$kingdom_id][$type][$group_id][$unit_id][$weapon_id][$detail_id]['damage'] = format_number($combatreport['details'][$kingdom_id][$type][$group_id][$unit_id][$weapon_id][$detail_id]['damage'], true);
                            $combatreport['details'][$kingdom_id][$type][$group_id][$unit_id][$weapon_id][$detail_id]['kills'] = format_number($combatreport['details'][$kingdom_id][$type][$group_id][$unit_id][$weapon_id][$detail_id]['kills'], true);
                        }
                    }
                }
            }
        }
    }
    $smarty->assign('combatreport', $combatreport);
    $smarty->display('reports_view.tpl');
}
示例#13
0
 public function getBlock($block_id, $template = true, $cfg = null)
 {
     global $ctype, $WEBTREES_EMAIL;
     $changes = WT_DB::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending'" . " LIMIT 1")->fetchOne();
     $days = get_block_setting($block_id, 'days', 1);
     $sendmail = get_block_setting($block_id, 'sendmail', true);
     $block = get_block_setting($block_id, 'block', true);
     if ($cfg) {
         foreach (array('days', 'sendmail', 'block') as $name) {
             if (array_key_exists($name, $cfg)) {
                 ${$name} = $cfg[$name];
             }
         }
     }
     if ($changes && $sendmail == 'yes') {
         // There are pending changes - tell moderators/managers/administrators about them.
         if (WT_TIMESTAMP - WT_Site::getPreference('LAST_CHANGE_EMAIL') > 60 * 60 * 24 * $days) {
             // Which users have pending changes?
             foreach (User::all() as $user) {
                 if ($user->getSetting('contactmethod') !== 'none') {
                     foreach (WT_Tree::getAll() as $tree) {
                         if (exists_pending_change($user, $tree)) {
                             WT_I18N::init($user->getSetting('language'));
                             WT_Mail::systemMessage($tree, $user, WT_I18N::translate('Pending changes'), WT_I18N::translate('There are pending changes for you to moderate.') . WT_Mail::EOL . WT_MAIL::EOL . '<a href="' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'index.php?ged=' . WT_GEDURL . '">' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'index.php?ged=' . WT_GEDURL . '</a>');
                             WT_I18N::init(WT_LOCALE);
                         }
                     }
                 }
             }
             WT_Site::setPreference('LAST_CHANGE_EMAIL', WT_TIMESTAMP);
         }
         if (WT_USER_CAN_EDIT) {
             $id = $this->getName() . $block_id;
             $class = $this->getName() . '_block';
             if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) {
                 $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>';
             } else {
                 $title = '';
             }
             $title .= $this->getTitle() . help_link('review_changes', $this->getName());
             $content = '';
             if (WT_USER_CAN_ACCEPT) {
                 $content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">" . WT_I18N::translate('There are pending changes for you to moderate.') . "</a><br>";
             }
             if ($sendmail == "yes") {
                 $content .= WT_I18N::translate('Last email reminder was sent ') . format_timestamp(WT_Site::getPreference('LAST_CHANGE_EMAIL')) . "<br>";
                 $content .= WT_I18N::translate('Next email reminder will be sent after ') . format_timestamp(WT_Site::getPreference('LAST_CHANGE_EMAIL') + 60 * 60 * 24 * $days) . "<br><br>";
             }
             $changes = WT_DB::prepare("SELECT xref" . " FROM  `##change`" . " WHERE status='pending'" . " AND   gedcom_id=?" . " GROUP BY xref")->execute(array(WT_GED_ID))->fetchAll();
             foreach ($changes as $change) {
                 $record = WT_GedcomRecord::getInstance($change->xref);
                 if ($record->canShow()) {
                     $content .= '<b>' . $record->getFullName() . '</b>';
                     $content .= $block ? '<br>' : ' ';
                     $content .= '<a href="' . $record->getHtmlUrl() . '">' . WT_I18N::translate('View the changes') . '</a>';
                     $content .= '<br>';
                 }
             }
             if ($template) {
                 if ($block) {
                     require WT_THEME_DIR . 'templates/block_small_temp.php';
                 } else {
                     require WT_THEME_DIR . 'templates/block_main_temp.php';
                 }
             } else {
                 return $content;
             }
         }
     }
 }
示例#14
0
文件: _list.php 项目: nubee/nubee
    foreach ($tasks as $i => $task) {
        ?>
    <tr class="<?php 
        echo fmod($i, 2) ? 'even' : 'odd';
        ?>
">
      <td><?php 
        echo link_to($task, 'backlogtask_show', $task);
        ?>
</td>
      <td class="center"><?php 
        echo format_priority($task->getPriority());
        ?>
</td>
      <td class="center"><?php 
        echo format_timestamp($task->getEstimate());
        ?>
</td>
      <td class="center">
        <?php 
        echo edit_link_to('backlogtask_edit', $task);
        ?>
        <?php 
        echo delete_link_to('backlogtask_delete', $task);
        ?>
      </td>
    </tr>
    <?php 
    }
    ?>
  </tbody>
示例#15
0
"><?php 
echo format_timestamp($task->getCurrentEstimate(), 'h');
?>
</td>
      </tr>
      <tr>
        <th>Effort spent</th>
        <td><?php 
echo format_timestamp($task->getEffortSpent(), 'h');
?>
</td>
      </tr>
      <tr>
        <th>Effort left</th>
        <td><?php 
echo format_timestamp($task->getEffortLeft(), 'h');
?>
</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="section">
  <h2>
    Working Units
  </h2>

  <?php 
if ($task->getCurrentEstimate() == 0) {
    ?>
/**
 * Display syslog messages.
 *
 * Display pages with device syslog messages.
 * Examples:
 * print_syslogs() - display last 10 syslog messages from all devices
 * print_syslogs(array('pagesize' => 99)) - display last 99 syslog messages from all device
 * print_syslogs(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 syslog messages from page 3 with pagination header
 * print_syslogs(array('pagesize' => 10, 'device' = 4)) - display last 10 syslog messages for device_id 4
 * print_syslogs(array('short' => TRUE)) - show small block with last syslog messages
 *
 * @param array $vars
 * @return none
 *
 */
function print_syslogs($vars)
{
    // Short events? (no pagination, small out)
    $short = isset($vars['short']) && $vars['short'];
    // With pagination? (display page numbers in header)
    $pagination = isset($vars['pagination']) && $vars['pagination'];
    $pageno = isset($vars['pageno']) && !empty($vars['pageno']) ? $vars['pageno'] : 1;
    $pagesize = isset($vars['pagesize']) && !empty($vars['pagesize']) ? $vars['pagesize'] : 10;
    $start = $pagesize * $pageno - $pagesize;
    $priorities = $GLOBALS['config']['syslog']['priorities'];
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            $cond = array();
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= ' AND `device_id` = ?';
                    $param[] = $value;
                    break;
                case 'priority':
                    if (!is_array($value)) {
                        $value = array($value);
                    }
                    foreach ($value as $k => $v) {
                        // Rewrite priority strings to numbers
                        $value[$k] = priority_string_to_numeric($v);
                    }
                    // Do not break here, it's true!
                // Do not break here, it's true!
                case 'program':
                    if (!is_array($value)) {
                        $value = array($value);
                    }
                    foreach ($value as $v) {
                        $cond[] = '?';
                        $param[] = $v === '[[EMPTY]]' ? '' : $v;
                    }
                    $where .= " AND `{$var}` IN (";
                    $where .= implode(', ', $cond);
                    $where .= ')';
                    break;
                case 'message':
                    foreach (explode(',', $value) as $val) {
                        $param[] = '%' . $val . '%';
                        $cond[] = '`msg` LIKE ?';
                    }
                    $where .= 'AND (';
                    $where .= implode(' OR ', $cond);
                    $where .= ')';
                    break;
                case 'timestamp_from':
                    $where .= ' AND `timestamp` > ?';
                    $param[] = $value;
                    break;
                case 'timestamp_to':
                    $where .= ' AND `timestamp` < ?';
                    $param[] = $value;
                    break;
            }
        }
    }
    // Show events only for permitted devices
    $query_permitted = generate_query_permitted();
    $query = 'FROM `syslog` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(`seq`) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY `seq` DESC ';
    $query .= "LIMIT {$start},{$pagesize}";
    // Query syslog messages
    $entries = dbFetchRows($query, $param);
    // Query syslog count
    if ($pagination && !$short) {
        $count = dbFetchCell($query_count, $param);
    } else {
        $count = count($entries);
    }
    if (!$count) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No syslog entries found!</h4>
Check that the syslog daemon and Observium configuration options are set correctly, that your devices are configured to send syslog to Observium and that there are no firewalls blocking the messages.

See <a href="http://www.observium.org/wiki/Category:Documentation" target="_blank">documentation</a> and <a href="http://www.observium.org/wiki/Configuration_Options#Syslog_Settings" target="_blank">configuration options</a> for more information.');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE, 'priority' => TRUE);
        // For now (temporarily) priority always displayed
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'syslog') {
            $list['device'] = TRUE;
        }
        if ($short || !isset($vars['priority']) || empty($vars['priority'])) {
            $list['priority'] = TRUE;
        }
        $string = '<table class="table table-bordered table-striped table-hover table-condensed-more">' . PHP_EOL;
        if (!$short) {
            $string .= '  <thead>' . PHP_EOL;
            $string .= '    <tr>' . PHP_EOL;
            $string .= '      <th>Date</th>' . PHP_EOL;
            if ($list['device']) {
                $string .= '      <th>Device</th>' . PHP_EOL;
            }
            if ($list['priority']) {
                $string .= '      <th>Priority</th>' . PHP_EOL;
            }
            $string .= '      <th>Message</th>' . PHP_EOL;
            $string .= '    </tr>' . PHP_EOL;
            $string .= '  </thead>' . PHP_EOL;
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($entries as $entry) {
            $string .= '  <tr>';
            if ($short) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= overlib_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td width="160">';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'syslog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['priority']) {
                if (!$short) {
                    $string .= '    <td style="color: ' . $priorities[$entry['priority']]['color'] . '; white-space: nowrap;">' . nicecase($priorities[$entry['priority']]['name']) . ' (' . $entry['priority'] . ')</td>' . PHP_EOL;
                }
            }
            $entry['program'] = empty($entry['program']) ? '[[EMPTY]]' : $entry['program'];
            if ($short) {
                $string .= '    <td class="syslog">';
                $string .= '<strong style="color: ' . $priorities[$entry['priority']]['color'] . ';">' . $entry['program'] . '</strong> : ';
            } else {
                $string .= '    <td>';
                $string .= '<strong>' . $entry['program'] . '</strong> : ';
            }
            $string .= htmlspecialchars($entry['msg']) . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>' . PHP_EOL;
        // Print pagination header
        if ($pagination && !$short) {
            $string = pagination($vars, $count) . $string . pagination($vars, $count);
        }
        // Print syslog
        echo $string;
    }
}
     $show_menu .= generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'));
     $show_menu .= '</span>';
 } else {
     $show_menu .= generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'));
 }
 if (check_extension_exists('svn')) {
     $sep = ' | ';
     $svnlogs = svn_log($device_config_file, SVN_REVISION_HEAD, NULL, 8);
     $revlist = array();
     foreach ($svnlogs as $svnlog) {
         $show_menu .= $sep;
         $revlist[] = $svnlog['rev'];
         if ($vars['rev'] == $svnlog['rev']) {
             $show_menu .= '<span class="pagemenu-selected">';
         }
         $linktext = 'r' . $svnlog['rev'] . ' <small>' . format_timestamp($svnlog['date']) . '</small>';
         $show_menu .= generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog['rev']));
         if ($vars['rev'] == $svnlog['rev']) {
             $show_menu .= '</span>' . PHP_EOL;
         }
     }
 }
 echo $show_menu;
 print_optionbar_end();
 if (check_extension_exists('svn') && in_array($vars['rev'], $revlist)) {
     list($diff, $errors) = svn_diff($device_config_file, $vars['rev'] - 1, $device_config_file, $vars['rev']);
     if (!$diff) {
         $text = '没有区别';
     } else {
         $text = '';
         while (!feof($diff)) {
示例#18
0
/**
 * Print Review Changes Block
 *
 * Prints a block allowing the user review all changes pending approval
 */
function review_changes_block($block = true, $config = "", $side, $index)
{
    global $pgv_lang, $ctype, $QUERY_STRING, $factarray, $PGV_IMAGE_DIR, $PGV_IMAGES;
    global $pgv_changes, $TEXT_DIRECTION, $SHOW_SOURCES, $PGV_BLOCKS;
    global $PHPGEDVIEW_EMAIL;
    if (empty($config)) {
        $config = $PGV_BLOCKS["review_changes_block"]["config"];
    }
    if ($pgv_changes) {
        //-- if the time difference from the last email is greater than 24 hours then send out another email
        $LAST_CHANGE_EMAIL = get_site_setting('LAST_CHANGE_EMAIL');
        if (time() - $LAST_CHANGE_EMAIL > 60 * 60 * 24 * $config["days"]) {
            $LAST_CHANGE_EMAIL = time();
            set_site_setting('LAST_CHANGE_EMAIL', $LAST_CHANGE_EMAIL);
            write_changes();
            if ($config["sendmail"] == "yes") {
                // Which users have pending changes?
                $users_with_changes = array();
                foreach (get_all_users() as $user_id => $user_name) {
                    foreach (get_all_gedcoms() as $ged_id => $ged_name) {
                        if (exists_pending_change($user_id, $ged_id)) {
                            $users_with_changes[$user_id] = $user_name;
                            break;
                        }
                    }
                }
                foreach ($users_with_changes as $user_id => $user_name) {
                    //-- send message
                    $message = array();
                    $message["to"] = $user_name;
                    $message["from"] = $PHPGEDVIEW_EMAIL;
                    $message["subject"] = $pgv_lang["review_changes_subject"];
                    $message["body"] = $pgv_lang["review_changes_body"];
                    $message["method"] = get_user_setting($user_id, 'contactmethod');
                    $message["url"] = PGV_SCRIPT_NAME . "?" . html_entity_decode($QUERY_STRING);
                    $message["no_from"] = true;
                    addMessage($message);
                }
            }
        }
        if (PGV_USER_CAN_EDIT) {
            $id = "review_changes_block";
            $title = print_help_link("review_changes_help", "qm", "", false, true);
            if ($PGV_BLOCKS["review_changes_block"]["canconfig"]) {
                if ($ctype == "gedcom" && PGV_USER_GEDCOM_ADMIN || $ctype == "user" && PGV_USER_ID) {
                    if ($ctype == "gedcom") {
                        $name = PGV_GEDCOM;
                    } else {
                        $name = PGV_USER_NAME;
                    }
                    $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('" . encode_url("index_edit.php?name={$name}&ctype={$ctype}&action=configure&side={$side}&index={$index}") . "', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">";
                    $title .= "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/" . $PGV_IMAGES["admin"]["small"] . "\" width=\"15\" height=\"15\" border=\"0\" alt=\"" . $pgv_lang["config_block"] . "\" /></a>";
                }
            }
            $title .= $pgv_lang["review_changes"];
            $content = "";
            if (PGV_USER_CAN_ACCEPT) {
                $content .= "<a href=\"javascript:;\" onclick=\"window.open('edit_changes.php','_blank','width=600,height=500,resizable=1,scrollbars=1'); return false;\">" . $pgv_lang["accept_changes"] . "</a><br />";
            }
            if ($config["sendmail"] == "yes") {
                $content .= $pgv_lang["last_email_sent"] . format_timestamp($LAST_CHANGE_EMAIL) . "<br />";
                $content .= $pgv_lang["next_email_sent"] . format_timestamp($LAST_CHANGE_EMAIL + 60 * 60 * 24 * $config["days"]) . "<br /><br />";
            }
            foreach ($pgv_changes as $cid => $changes) {
                $change = $changes[count($changes) - 1];
                if ($change["gedcom"] == PGV_GEDCOM) {
                    $record = GedcomRecord::getInstance($change['gid']);
                    if ($record->getType() != 'SOUR' || $SHOW_SOURCES >= PGV_USER_ACCESS_LEVEL) {
                        $content .= '<b>' . PrintReady($record->getFullName()) . '</b> ' . getLRM() . '(' . $record->getXref() . ')' . getLRM();
                        switch ($record->getType()) {
                            case 'INDI':
                            case 'FAM':
                            case 'SOUR':
                            case 'OBJE':
                                $content .= $block ? '<br />' : ' ';
                                $content .= '<a href="' . encode_url($record->getLinkUrl() . '&show_changes=yes') . '">' . $pgv_lang['view_change_diff'] . '</a>';
                                break;
                        }
                        $content .= '<br />';
                    }
                }
            }
            global $THEME_DIR;
            if ($block) {
                require $THEME_DIR . 'templates/block_small_temp.php';
            } else {
                require $THEME_DIR . 'templates/block_main_temp.php';
            }
        }
    }
}
示例#19
0
文件: update.php 项目: EZDM/omeyocan
 $query = $db->DoQuery("SELECT user,type,body,time FROM {$prefix}messages WHERE \n\t\t\t\t\t\t\t\t\troom='{$_GET['room']}' AND time>={$lt1} AND time<{$time1} AND user<>'{$x7s->username}' AND type='1' OR \n\t\t\t\t\t\t\t\t\troom='{$x7s->username}' AND time>{$lt1} AND time<={$time1} AND type='3' OR\n\t\t\t\t\t\t\t\t\ttype='2' AND time>={$lt1} AND time<{$time1} OR\n\t\t\t\t\t\t\t\t\ttype='4' AND time>={$lt1} AND time<{$time1} AND room='{$_GET['room']}' OR \n\t\t\t\t\t\t\t\t\ttype='6' AND room='{$x7s->username}' AND time='0' OR \n\t\t\t\t\t\t\t\t\ttype='5' AND room='{$x7s->username}:0' AND time<'{$pm_time}' \n\t\t\t\t\t\t\t\t\tORDER BY time ASC");
 // Check for any database errors
 if ($db->error == 4) {
     $query = eregi_replace("'", "\\'", $query);
     $query = eregi_replace("\n", "", $query);
     $query = eregi_replace("\r", "", $query);
     $script .= "\n\nwindow.parent.location='./index.php?act=panic&dump={$query}&source=/sources/frame.php:144';\n\n";
 }
 while ($row = $db->Do_Fetch_Row($query)) {
     if (!in_array($row[0], $x7c->profile['ignored'])) {
         $row[2] = eregi_replace("'", "\\'", $row[2]);
         if ($row[1] == 1) {
             $row[2] = parse_message($row[2]);
             // See if they want a timestamp
             if ($x7c->settings['disble_timestamp'] != 1) {
                 $timestamp = format_timestamp($row[3]);
             } else {
                 $timestamp = "";
             }
             $script .= "window.parent.frames['middle_left'].document.write('<span class=\"other_persons\"><a class=\"other_persons\" onClick=\"javascript: window.open(\\'index.php?act=pm&send_to={$row['0']}\\',\\'Pm{$row['0']}\\',\\'location=no,menubar=no,resizable=no,status=no,toolbar=no,scrollbars=yes,width={$x7c->settings['tweak_window_large_width']},height={$x7c->settings['tweak_window_large_height']}\\');\">{$row['0']}</a>{$timestamp}:</span> {$row['2']}<br>');\r\n";
         } elseif ($row[1] == 2 || $row[1] == 3 || $row[1] == 4) {
             $row[2] = parse_message($row[2], 1);
             //$script .= "alert('$row[1] is what got u and $row[0] is who duunit');\r\n";
             $script .= "window.parent.frames['middle_left'].document.write('{$row['2']}<br>');\r\n";
         } elseif ($row[1] == 6) {
             $PM_COUNT++;
         } elseif ($row[1] == 5) {
             $script .= "window.open('index.php?act=pm&send_to={$row['0']}','Pm{$row['0']}','location=no,menubar=no,resizable=no,status=no,toolbar=no,scrollbars=yes,width={$x7c->settings['tweak_window_large_width']},height={$x7c->settings['tweak_window_large_height']}');\r\n";
             $txt[511] = eregi_replace("<a>", "<a style=\"cursor: hand;cursor: pointer;\" onClick=\"window.open(\\'index.php?act=pm&send_to={$row['0']}\\',\\'Pm{$row['0']}\\',\\'location=no,menubar=no,resizable=no,status=no,toolbar=no,scrollbars=yes,width={$x7c->settings['tweak_window_large_width']},height={$x7c->settings['tweak_window_large_height']}\\');\">", $txt[511]);
             $script .= "window.parent.frames['middle_left'].document.write('<span style=\"color: {$sysmsg_color};font-size: {$default_size}; font-family: {$default_font};\"><b>{$txt['511']}</b></span><Br>')\r\n";
         }
示例#20
0
"><?php 
echo format_timestamp($project->getCurrentEstimate(), 'w');
?>
</td>
    </tr>
    <tr>
      <th>Effort spent</th>
      <td><?php 
echo format_timestamp($project->getEffortSpent(), 'w');
?>
</td>
    </tr>
    <tr>
      <th>Effort left</th>
      <td><?php 
echo format_timestamp($project->getEffortLeft(), 'w');
?>
</td>
    </tr>    
    <tr>
      <th>Members</th>
      <td>
        <ul>
          <?php 
if ($project->hasMembers()) {
    ?>
          <?php 
    foreach ($project->getMembers() as $member) {
        ?>
          <li><?php 
        echo link_to($member, 'user_show', $member);
示例#21
0
require WT_ROOT . 'library/pclzip.lib.php';
// TODO - rename and use autoloading
// Check for updates
$latest_version_txt = fetch_latest_version();
if (preg_match('/^[0-9.]+\\|[0-9.]+\\|/', $latest_version_txt)) {
    list($latest_version, $earliest_version, $download_url) = explode('|', $latest_version_txt);
} else {
    // Cannot determine the latest version
    list($latest_version, $earliest_version, $download_url) = explode('|', '||');
}
$latest_version_html = '<span dir="ltr">' . $latest_version . '</span>';
$download_url_html = '<b dir="auto"><a href="' . WT_Filter::escapeHtml($download_url) . '">' . WT_Filter::escapeHtml($download_url) . '</a></b>';
// Show a friendly message while the site is being upgraded
$lock_file = __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'offline.txt';
$lock_file_html = '<span dir="ltr">' . WT_Filter::escapeHtml($lock_file) . '</span>';
$lock_file_text = WT_I18N::translate('This site is being upgraded.  Try again in a few minutes.') . PHP_EOL . format_timestamp(WT_TIMESTAMP) . WT_I18N::translate('UTC');
// Success/failure indicators
$icon_success = '<i class="icon-yes"></i>';
$icon_failure = '<i class="icon-failure"></i>';
// Need confirmation for various actions
$continue = WT_Filter::post('continue', '1') && WT_Filter::checkCsrf();
$modules_action = WT_Filter::post('modules', 'ignore|disable');
$themes_action = WT_Filter::post('themes', 'ignore|disable');
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Upgrade wizard'))->pageHeader();
// Flush output as it happens - only effective on some webserver configurations.
ob_implicit_flush(true);
if (ob_get_level()) {
    ob_end_flush();
}
echo '<h2>', $controller->getPageTitle(), '</h2>';
function info()
{
    global $smarty;
    if (empty($_REQUEST['round_id'])) {
        error(__FILE__, __LINE__, 'INVALID_ID', 'Invalid Round ID');
    }
    $smarty->assign('content', 'info');
    $round_id = abs((int) $_REQUEST['round_id']);
    $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` = '" . $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 * $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);
}
示例#23
0
 /**
  * @dataProvider providerFormatTimestamp
  */
 public function testFormatTimestamp($value, $result)
 {
     $this->assertSame($result, format_timestamp($value));
 }
示例#24
0
/**
 * Display events.
 *
 * Display pages with device/port/system events on some formats.
 * Examples:
 * print_events() - display last 10 events from all devices
 * print_events(array('pagesize' => 99)) - display last 99 events from all device
 * print_events(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 events from page 3 with pagination header
 * print_events(array('pagesize' => 10, 'device' = 4)) - display last 10 events for device_id 4
 * print_events(array('short' => TRUE)) - show small block with last events
 *
 * @param array $vars
 * @return none
 *
 */
function print_events($vars)
{
    // Get events array
    $events = get_events_array($vars);
    if (!$events['count']) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No eventlog entries found!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE, 'port' => FALSE);
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'eventlog') {
            $list['device'] = TRUE;
        }
        if ($events['short'] || !isset($vars['port']) || empty($vars['port'])) {
            $list['port'] = TRUE;
        }
        $string = '<table class="table table-bordered table-striped table-hover table-condensed-more">' . PHP_EOL;
        if (!$events['short']) {
            $string .= '  <thead>' . PHP_EOL;
            $string .= '    <tr>' . PHP_EOL;
            $string .= '      <th>Date</th>' . PHP_EOL;
            if ($list['device']) {
                $string .= '      <th>Device</th>' . PHP_EOL;
            }
            if ($list['port']) {
                $string .= '      <th>Entity</th>' . PHP_EOL;
            }
            $string .= '      <th>Message</th>' . PHP_EOL;
            $string .= '    </tr>' . PHP_EOL;
            $string .= '  </thead>' . PHP_EOL;
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($events['entries'] as $entry) {
            $icon = geteventicon($entry['message']);
            if ($icon) {
                $icon = '<img src="images/16/' . $icon . '" />';
            }
            $string .= '  <tr>' . PHP_EOL;
            if ($events['short']) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= overlib_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td style="width: 160px">';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'eventlog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['port']) {
                if ($entry['type'] == 'port') {
                    $this_if = get_port_by_id_cache($entry['reference']);
                    $entry['link'] = '<span class="entity">' . generate_port_link($this_if, short_ifname($this_if['label'])) . '</span>';
                } else {
                    $entry['link'] = ucfirst($entry['type']);
                }
                if (!$events['short']) {
                    $string .= '    <td>' . $entry['link'] . '</td>' . PHP_EOL;
                }
            }
            if ($events['short']) {
                $string .= '    <td class="syslog">' . $entry['link'] . ' ';
            } else {
                $string .= '    <td>';
            }
            $string .= htmlspecialchars($entry['message']) . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        // Print pagination header
        if ($events['pagination_html']) {
            $string = $events['pagination_html'] . $string . $events['pagination_html'];
        }
        // Print events
        echo $string;
    }
}
        <div class="progress progress-' . $proc['color']['poller'] . ' active" style="margin-bottom: 5px;"><div class="bar" style="text-align: right; width: ' . $proc['time']['poller'] . '%;"></div></div>
      </td>
      <td style="width: 7%">
        ' . $row['last_polled_timetaken'] . 's
      </td>
      <td>' . format_timestamp($row['last_polled']) . ' </td>
      <td>' . formatUptime($config['time']['now'] - strtotime($row['last_polled']), 'shorter') . ' ago</td>';
    // Discovery times
    echo '
      <td style="width: 12%;">
        <div class="progress progress-' . $proc['color']['discovery'] . ' active" style="margin-bottom: 5px;"><div class="bar" style="text-align: right; width: ' . $proc['time']['discovery'] . '%;"></div></div>
      </td>
      <td style="width: 7%">
        ' . $row['last_discovered_timetaken'] . 's
      </td>
      <td>' . format_timestamp($row['last_discovered']) . '</td>
      <td>' . formatUptime($config['time']['now'] - strtotime($row['last_discovered']), 'shorter') . ' ago</td>

    </tr>
';
}
// Calculate root mean square
$proc['avg2']['poller'] = sqrt($proc['avg2']['poller'] / $devices['count']);
$proc['avg2']['poller'] = round($proc['avg2']['poller'], 2);
$proc['avg2']['discovery'] = sqrt($proc['avg2']['discovery'] / $devices['count']);
$proc['avg2']['discovery'] = round($proc['avg2']['discovery'], 2);
echo '    <tr>
      <th colspan="4" style="text-align: right;">所有设备的总时间(平均每设备):</th>
      <th colspan="3" style="text-align: left;">' . $cache['devices']['timers']['polling'] . 's (' . $proc['avg2']['poller'] . 's)</th>
      <th></th>
      <th colspan="3" style="text-align: left;">' . $cache['devices']['timers']['discovery'] . 's (' . $proc['avg2']['discovery'] . 's)</th>
示例#26
0
/**
 * Display syslog messages.
 *
 * Display pages with device syslog messages.
 * Examples:
 * print_syslogs() - display last 10 syslog messages from all devices
 * print_syslogs(array('pagesize' => 99)) - display last 99 syslog messages from all device
 * print_syslogs(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 syslog messages from page 3 with pagination header
 * print_syslogs(array('pagesize' => 10, 'device' = 4)) - display last 10 syslog messages for device_id 4
 * print_syslogs(array('short' => TRUE)) - show small block with last syslog messages
 *
 * @param array $vars
 * @return none
 *
 */
function print_syslogs($vars)
{
    // Short events? (no pagination, small out)
    $short = isset($vars['short']) && $vars['short'];
    // With pagination? (display page numbers in header)
    $pagination = isset($vars['pagination']) && $vars['pagination'];
    pagination($vars, 0, TRUE);
    // Get default pagesize/pageno
    $pageno = $vars['pageno'];
    $pagesize = $vars['pagesize'];
    $start = $pagesize * $pageno - $pagesize;
    $priorities = $GLOBALS['config']['syslog']['priorities'];
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            $cond = array();
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= generate_query_values($value, 'device_id');
                    break;
                case 'priority':
                    if (!is_array($value)) {
                        $value = explode(',', $value);
                    }
                    foreach ($value as $k => $v) {
                        // Rewrite priority strings to numbers
                        $value[$k] = priority_string_to_numeric($v);
                    }
                    // Do not break here, it's true!
                // Do not break here, it's true!
                case 'program':
                    $where .= generate_query_values($value, $var);
                    break;
                case 'message':
                    $where .= generate_query_values($value, 'msg', '%LIKE%');
                    break;
                case 'timestamp_from':
                    $where .= ' AND `timestamp` > ?';
                    $param[] = $value;
                    break;
                case 'timestamp_to':
                    $where .= ' AND `timestamp` < ?';
                    $param[] = $value;
                    break;
            }
        }
    }
    // Show events only for permitted devices
    $query_permitted = generate_query_permitted();
    $query = 'FROM `syslog` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(*) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY `seq` DESC ';
    $query .= "LIMIT {$start},{$pagesize}";
    // Query syslog messages
    $entries = dbFetchRows($query, $param);
    // Query syslog count
    if ($pagination && !$short) {
        $count = dbFetchCell($query_count, $param);
    } else {
        $count = count($entries);
    }
    if (!$count) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No syslog entries found!</h4>
Check that the syslog daemon and Observium configuration options are set correctly, that your devices are configured to send syslog to Observium and that there are no firewalls blocking the messages.

See <a href="' . OBSERVIUM_URL . '/wiki/Category:Documentation" target="_blank">documentation</a> and <a href="' . OBSERVIUM_URL . '/wiki/Configuration_Options#Syslog_Settings" target="_blank">configuration options</a> for more information.');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE, 'priority' => TRUE);
        // For now (temporarily) priority always displayed
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'syslog') {
            $list['device'] = TRUE;
        }
        if ($short || !isset($vars['priority']) || empty($vars['priority'])) {
            $list['priority'] = TRUE;
        }
        $string = generate_box_open($vars['header']);
        $string .= '<table class="' . OBS_CLASS_TABLE_STRIPED_MORE . '">' . PHP_EOL;
        if (!$short) {
            $string .= '  <thead>' . PHP_EOL;
            $string .= '    <tr>' . PHP_EOL;
            $string .= '      <th class="state-marker"></th>' . PHP_EOL;
            #    $string .= '      <th></th>' . PHP_EOL;
            $string .= '      <th>Date</th>' . PHP_EOL;
            if ($list['device']) {
                $string .= '      <th>Device</th>' . PHP_EOL;
            }
            if ($list['priority']) {
                $string .= '      <th>Priority</th>' . PHP_EOL;
            }
            $string .= '      <th>Message</th>' . PHP_EOL;
            $string .= '    </tr>' . PHP_EOL;
            $string .= '  </thead>' . PHP_EOL;
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($entries as $entry) {
            switch ($entry['priority']) {
                case "0":
                    // Emergency
                // Emergency
                case "1":
                    // Alert
                // Alert
                case "2":
                    // Critical
                // Critical
                case "3":
                    // Error
                    $entry['html_row_class'] = "error";
                    break;
                case "4":
                    // Warning
                    $entry['html_row_class'] = "warning";
                    break;
                case "5":
                    // Notification
                    $entry['html_row_class'] = "recovery";
                    break;
                case "6":
                    // Informational
                    $entry['html_row_class'] = "up";
                    break;
                case "7":
                    // Debugging
                    $entry['html_row_class'] = "suppressed";
                    break;
                default:
            }
            $string .= '  <tr class="' . $entry['html_row_class'] . '">' . PHP_EOL;
            $string .= '<td class="state-marker"></td>' . PHP_EOL;
            if ($short) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= generate_tooltip_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td width="130">';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'syslog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['priority']) {
                if (!$short) {
                    $string .= '    <td style="color: ' . $priorities[$entry['priority']]['color'] . '; white-space: nowrap; width: 95px;"><span class="label label-' . $priorities[$entry['priority']]['label-class'] . '">' . nicecase($priorities[$entry['priority']]['name']) . ' (' . $entry['priority'] . ')</span></td>' . PHP_EOL;
                }
            }
            $entry['program'] = empty($entry['program']) ? '[[EMPTY]]' : $entry['program'];
            if ($short) {
                $string .= '    <td class="syslog">';
                $string .= '<span class="label label-' . $priorities[$entry['priority']]['label-class'] . '"><strong>' . $entry['program'] . '</strong></span> ';
            } else {
                $string .= '    <td>';
                $string .= '<span class="label label-' . $priorities[$entry['priority']]['label-class'] . '">' . $entry['program'] . '</span>';
            }
            $string .= escape_html($entry['msg']) . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>' . PHP_EOL;
        $string .= generate_box_close();
        // Print pagination header
        if ($pagination && !$short) {
            $string = pagination($vars, $count) . $string . pagination($vars, $count);
        }
        // Print syslog
        echo $string;
    }
}
示例#27
0
/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage web
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
function print_logalert_log($vars)
{
    global $config;
    foreach (dbFetchRows("SELECT * FROM `syslog_rules` ORDER BY `la_name`") as $la) {
        $syslog_rules[$la['la_id']] = $la;
    }
    $entries = get_logalert_log($vars);
    if (!$entries['count']) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No logging alert entries found!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE);
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'alert_log') {
            $list['device'] = TRUE;
        }
        if (!isset($vars['la_id']) || empty($vars['la_id'])) {
            $list['la_id'] = TRUE;
        }
        $string = generate_box_open($vars['header']);
        $string .= '<table class="table table-striped table-hover table-condensed-more">' . PHP_EOL;
        if (!$entries['short']) {
            $cols = array();
            $cols[] = array(NULL, 'class="state-marker"');
            $cols['date'] = array('Date', 'style="width: 140px"');
            if ($list['device']) {
                $cols['device'] = array('Device', 'style="width: 150px;"');
            }
            if ($list['la_id']) {
                $cols['la_id'] = array('Alert Rule', 'style="width: 150px;"');
            }
            $cols[] = array('Program', 'style="width: 80px"');
            $cols[] = 'Message';
            $cols[] = array('Notified', 'style="width: 40px"');
            $string .= get_table_header($cols);
            // , $vars); // Actually sorting is disabled now
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($entries['entries'] as $entry) {
            $string .= '  <tr class="' . $entry['html_row_class'] . '">' . PHP_EOL;
            $string .= '<td class="state-marker"></td>' . PHP_EOL;
            if ($entries['short']) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= generate_tooltip_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td>';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'alertlog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['la_id']) {
                $string .= '<td><strong><a href="' . generate_url(array('page' => 'syslog_rules', 'la_id' => $entry['la_id'])) . '">' . (is_array($syslog_rules[$entry['la_id']]) ? $syslog_rules[$entry['la_id']]['la_name'] : 'Rule Deleted') . '</td>' . PHP_EOL;
            }
            $string .= '<td>' . (strlen($entry['program']) ? '<span class="label">' . $entry['program'] . '</span> ' : '') . '</td>' . PHP_EOL;
            $string .= '<td>' . escape_html($entry['message']) . '</td>' . PHP_EOL;
            if (!$vars['short']) {
                //$string .= '<td>' . escape_html($entry['log_type']) . '</td>' . PHP_EOL;
                $string .= '<td style="text-align: right">' . ($entry['notified'] == '1' ? '<span class="label label-success">YES</span>' : ($entry['notified'] == '-1' ? '<span class="label label-suppressed">NO</span>' : '<span class="label">NO</span>')) . '</td>' . PHP_EOL;
            }
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        $string .= generate_box_close();
    }
    // Print pagination header
    if ($entries['pagination_html']) {
        $string = $entries['pagination_html'] . $string . $entries['pagination_html'];
    }
    // Print events
    echo $string;
}
示例#28
0
文件: _list.php 项目: nubee/nubee
        echo format_timestamp($story->getOriginalEstimate(), 'd');
        ?>
</td>
        <td class="center <?php 
        echo get_estimate_class($story);
        ?>
"><?php 
        echo format_timestamp($story->getCurrentEstimate(), 'd');
        ?>
</td>
        <td class="center"><?php 
        echo format_timestamp($story->getEffortLeft(), 'd');
        ?>
</td>
        <td class="center"><?php 
        echo format_timestamp($story->getEffortSpent(), 'd');
        ?>
</td>
        <td class="center">
          <?php 
        echo edit_link_to('story_edit', $story);
        ?>
          <?php 
        echo delete_link_to('story_delete', $story);
        ?>
        </td>
      </tr>
    <?php 
    }
    ?>
  </tbody>
示例#29
0
     $datum[2] = edit_field_inline('user-user_name-' . $user_id, $datum[2]);
     $datum[3] = edit_field_inline('user-real_name-' . $user_id, $datum[3]);
     $datum[4] = edit_field_inline('user-email-' . $user_id, $datum[4]);
     // $aData[5] is a link to an email icon
     if ($user_id != WT_USER_ID) {
         $datum[5] = '<i class="icon-email" onclick="return message(\'' . $user_name . '\', \'\', \'\');"></i>';
     }
     $datum[6] = edit_field_language_inline('user_setting-' . $user_id . '-language', $datum[6]);
     // $aData[7] is the sortable registration timestamp
     $datum[8] = $datum[8] ? format_timestamp($datum[8]) : '';
     if (date("U") - $datum[7] > 604800 && !$datum[11]) {
         $datum[8] = '<span class="red">' . $datum[8] . '</span>';
     }
     // $aData[9] is the sortable last-login timestamp
     if ($datum[9]) {
         $datum[10] = format_timestamp($datum[9]) . '<br>' . WT_I18N::time_ago(WT_TIMESTAMP - $datum[9]);
     } else {
         $datum[10] = WT_I18N::translate('Never');
     }
     $datum[11] = edit_field_yes_no_inline('user_setting-' . $user_id . '-verified-', $datum[11]);
     $datum[12] = edit_field_yes_no_inline('user_setting-' . $user_id . '-verified_by_admin-', $datum[12]);
     // Add extra column for "delete" action
     if ($user_id != WT_USER_ID) {
         $datum[13] = '<div class="icon-delete" onclick="delete_user(\'' . WT_I18N::translate('Are you sure you want to delete “%s”?', WT_Filter::escapeJs($user_name)) . '\', \'' . WT_Filter::escapeJs($user_id) . '\');"></div>';
     } else {
         // Do not delete ourself!
         $datum[13] = '';
     }
 }
 // Total filtered/unfiltered rows
 $recordsFiltered = WT_DB::prepare("SELECT FOUND_ROWS()")->fetchOne();
示例#30
0
 public function getBlock($block_id, $template = true, $cfg = null)
 {
     global $ctype, $GEDCOM;
     // Only show this block for certain languages
     $languages = get_block_setting($block_id, 'languages');
     if ($languages && !in_array(WT_LOCALE, explode(',', $languages))) {
         return;
     }
     /*
      * Select GEDCOM
      */
     $gedcom = get_block_setting($block_id, 'gedcom');
     switch ($gedcom) {
         case '__current__':
             break;
         case '':
             break;
         case '__default__':
             $GEDCOM = WT_Site::getPreference('DEFAULT_GEDCOM');
             if (!$GEDCOM) {
                 foreach (WT_Tree::getAll() as $tree) {
                     $GEDCOM = $tree->tree_name;
                     break;
                 }
             }
             break;
         default:
             $GEDCOM = $gedcom;
             break;
     }
     /*
      * Retrieve text, process embedded variables
      */
     $title_tmp = get_block_setting($block_id, 'title');
     $html = get_block_setting($block_id, 'html');
     if (strpos($title_tmp, '#') !== false || strpos($html, '#') !== false) {
         $stats = new WT_Stats($GEDCOM);
         $title_tmp = $stats->embedTags($title_tmp);
         $html = $stats->embedTags($html);
     }
     /*
      * Restore Current GEDCOM
      */
     $GEDCOM = WT_GEDCOM;
     /*
      * Start Of Output
      */
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) {
         $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>';
     } else {
         $title = '';
     }
     $title .= $title_tmp;
     $content = $html;
     if (get_block_setting($block_id, 'show_timestamp', false)) {
         $content .= '<br>' . format_timestamp(get_block_setting($block_id, 'timestamp', WT_TIMESTAMP));
     }
     if ($template) {
         if (get_block_setting($block_id, 'block', false)) {
             require WT_THEME_DIR . 'templates/block_small_temp.php';
         } else {
             require WT_THEME_DIR . 'templates/block_main_temp.php';
         }
     } else {
         return $content;
     }
 }