本文整理汇总了PHP中Settings::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::read方法的具体用法?PHP Settings::read怎么用?PHP Settings::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings
的用法示例。
在下文中一共展示了Settings::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testResolvePartialPath
public function testResolvePartialPath()
{
$resolver = $this->prophesize('asylgrp\\workbench\\PathResolver');
$resolver->resolve('foo')->willReturn('resolved');
$settings = new Settings(['baz' => '[path:foo]/bar'], $resolver->reveal());
$this->assertSame('resolved/bar', $settings->read('baz'));
}
示例2: _initDb
protected function _initDb()
{
$path = Settings::read("APP_PATH");
require_once $path . "/config/database.php";
if (isset($dbcfg)) {
Settings::write("DB", $dbcfg);
}
}
示例3: test_debug
/** function test_debug
* This function tests the debug given by the
* URL and checks it against the globals debug password
* and if they do not match, doesn't debug
*
* @param void
* @action tests debug pass
* @return bool success
*/
function test_debug()
{
if (!isset($_GET['DEBUG'])) {
return false;
}
if (!class_exists('Settings') || !Settings::test()) {
return false;
}
if ('' == trim(Settings::read('debug_pass'))) {
return false;
}
if (0 !== strcmp($_GET['DEBUG'], Settings::read('debug_pass'))) {
return false;
}
$GLOBALS['_&_DEBUG_QUERY'] = '&DEBUG=' . $_GET['DEBUG'];
$GLOBALS['_?_DEBUG_QUERY'] = '?DEBUG=' . $_GET['DEBUG'];
return true;
}
示例4: render
/**
* pub static render
* Render file contents
* @param $path <string url> path to file to parse
* @param $context <string> the route context info.
* @return <string html, json, xml> return the output
**/
public static function render($template, array $params = array())
{
ob_start();
if (!empty($params)) {
extract($params, EXTR_SKIP);
}
require Settings::read("APP_PATH") . "/views" . $template;
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
示例5: test_nudge
/** public function test_nudge
* Tests if the current player can be nudged or not
*
* @param void
* @return bool player can be nudged
*/
public function test_nudge()
{
call(__METHOD__);
$player_id = (int) $this->_players['opponent']['player_id'];
if ($this->get_my_turn() || in_array($this->state, array('Finished', 'Draw')) || $this->paused) {
return false;
}
try {
$nudge_time = Settings::read('nudge_flood_control');
} catch (MyException $e) {
return false;
}
if (-1 == $nudge_time) {
return false;
} elseif (0 == $nudge_time) {
return true;
}
// check the nudge status for this game/player
// 'now' is taken from the DB because it may
// have a different time from the PHP server
$query = "\n\t\t\tSELECT NOW( ) AS now\n\t\t\t\t, G.modify_date AS move_date\n\t\t\t\t, GN.nudged\n\t\t\tFROM " . self::GAME_TABLE . " AS G\n\t\t\t\tLEFT JOIN " . self::GAME_NUDGE_TABLE . " AS GN\n\t\t\t\t\tON (GN.game_id = G.game_id\n\t\t\t\t\t\tAND GN.player_id = '{$player_id}')\n\t\t\tWHERE G.game_id = '{$this->id}'\n\t\t";
$dates = $this->_mysql->fetch_assoc($query);
if (!$dates) {
return false;
}
// check the dates
// if the move date is far enough in the past
// AND the player has not been nudged
// OR the nudge date is far enough in the past
if (strtotime($dates['move_date']) <= strtotime('-' . $nudge_time . ' hour', strtotime($dates['now'])) && (empty($dates['nudged']) || strtotime($dates['nudged']) <= strtotime('-' . $nudge_time . ' hour', strtotime($dates['now'])))) {
return true;
}
return false;
}
示例6: get_header
top: 2px;
left: 5px;
z-index: 1;
color: #999;
}
</style>
';
$date_format = 'D, M j, Y g:i a';
$approve_users = false;
$new_users = true;
$max_users = 0;
if (class_exists('Settings') && Settings::test()) {
$date_format = Settings::read('long_date');
$approve_users = Settings::read('approve_users');
$new_users = Settings::read('new_users');
$max_users = Settings::read('max_users');
}
echo get_header($meta);
?>
<div id="notes">
<div id="date"><?php
echo date($date_format);
?>
</div>
<p><strong>Welcome to <?php
echo GAME_NAME;
?>
!</strong></p>
<p>Please enter a valid username and password to enter.</p>
<?php
if ($approve_users) {
示例7: admin_reset_pass
/** public function admin_reset_pass
* Reset the password for the given players
*
* @param mixed csv or array of user ids
* @action resets the password for the given players
* @return void
*/
public function admin_reset_pass($user_ids)
{
// make sure the user doing this is an admin
if (!$this->is_admin) {
throw new MyException(__METHOD__ . ': Player is not an admin');
}
array_trim($user_ids, 'int');
$data = array('password' => self::hash_password(Settings::read('default_pass')), 'alt_pass' => self::hash_alt_pass(Settings::read('default_pass')));
$this->_mysql->insert(self::PLAYER_TABLE, $data, " WHERE player_id IN (0," . implode(',', $user_ids) . ") ");
}
示例8: get_header
$prev = $prev_item['message_id'];
}
$prev_item = $item;
}
$meta['title'] = 'Message Viewer';
$meta['head_data'] = '
<script type="text/javascript" src="scripts/messages.js"></script>
';
echo get_header($meta);
?>
<div id="content" class="msg">
<div class="link_date">
<a href="messages.php">Return to Inbox</a>
Sent: <?php
echo @ifdateor(Settings::read('long_date'), strtotime($message['send_date']), strtotime($message['create_date']));
?>
</div>
<h2 class="subject"><?php
echo $message['subject'];
?>
<span class="sender">From: <?php
echo $message['recipients'][0]['sender'];
?>
</span></h2>
<div class="sidebar">
<form method="post" action="<?php
echo $_SERVER['REQUEST_URI'];
?>
"><div class="buttons">
<div class="prevnext">
示例9: get_item
/** function get_item
* Generate the HTML content portion of the page
*
* @param string contents
* @param string instructions for page
* @param string [optional] title for page
* @return string HTML content for page
*/
function get_item($contents, $hint, $title = '', $extra_html = '')
{
$hint_html = "\n\t\t\t<p><strong>Welcome";
if (!empty($GLOBALS['Player']) && !empty($_SESSION['player_id'])) {
$hint_html .= ", {$GLOBALS['Player']->username}";
}
$hint_html .= '</strong></p>';
if (is_array($hint)) {
foreach ($hint as $line) {
$hint_html .= "\n\t\t\t<p>{$line}</p>";
}
} else {
$hint_html .= "\n\t\t\t<p>{$hint}</p>";
}
if ('' != $title) {
$title = '<h2>' . $title . '</h2>';
}
$long_date = class_exists('Settings') && Settings::test() ? Settings::read('long_date') : 'M j, Y g:i a';
$html = '
<aside id="info">
<div id="notes" class="box">
<div>
<div id="date">' . date($long_date) . '</div>
' . $hint_html . '
</div>
</div>
' . $extra_html . '
</aside><!-- #info -->
<div id="content" class="box">
<div>
' . $title . '
' . $contents . '
</div>
</div><!-- #content -->
';
return $html;
}
示例10: foreach
<dl id="chats">';
if (is_array($chat_data)) {
foreach ($chat_data as $chat) {
if ('' == $chat['username']) {
$chat['username'] = '[deleted]';
}
$color = '';
if (isset($players[$chat['player_id']]['color'])) {
$color = substr($players[$chat['player_id']]['color'], 0, 3);
}
// preserve spaces in the chat text
$chat['message'] = htmlentities($chat['message'], ENT_QUOTES, 'UTF-8', false);
$chat['message'] = str_replace("\t", ' ', $chat['message']);
$chat['message'] = str_replace(' ', ' ', $chat['message']);
$chat_html .= '
<dt class="' . $color . '"><span>' . ldate(Settings::read('short_date'), strtotime($chat['create_date'])) . '</span> ' . $chat['username'] . '</dt>
<dd' . ($chat['private'] ? ' class="private"' : '') . '>' . $chat['message'] . '</dd>';
}
}
$chat_html .= '
</dl> <!-- #chats -->
</div> <!-- #chatbox -->';
}
$meta['title'] = htmlentities($Game->name, ENT_QUOTES, 'UTF-8', false) . ' - #' . $_SESSION['game_id'];
$meta['show_menu'] = false;
$meta['head_data'] = '
<link rel="stylesheet" type="text/css" media="screen" href="css/game.css" />
<script type="text/javascript">//<![CDATA[
var state = "' . (!$Game->watch_mode ? !$Game->paused ? strtolower($Game->get_player_state($_SESSION['player_id'])) : 'paused' : 'watching') . '";
/*]]>*/</script>
示例11: get_selected
continue;
}
$recipient_options .= '<option value="' . $player['player_id'] . '"' . get_selected($recipient_id, $player['player_id']) . '>' . $player['username'] . '</option>';
}
}
echo get_header($meta);
?>
<div id="content">
<div class="link_date">
<a href="messages.php<?php
echo $GLOBALS['_?_DEBUG_QUERY'];
?>
">Return to Inbox</a>
<?php
echo date(Settings::read('long_date'));
?>
</div>
<form method="post" action="<?php
echo $_SERVER['REQUEST_URI'];
?>
"><div id="formdiv">
<input type="hidden" name="token" value="<?php
echo $_SESSION['token'];
?>
" />
<ol>
<li>
<div class="info">Press and hold CTRL while selecting to select multiple recipients</div>
<label for="user_ids">Recipients</label><select name="user_ids[]" id="user_ids" multiple="multiple" size="5">
<?php
示例12: write_game_file
/** static public function write_game_file
* Writes the game logs to a file for storage
*
* @param int game id
* @action writes the game data to a file
* @return bool success
*/
public static function write_game_file($game_id)
{
$game_id = (int) $game_id;
if (!Settings::read('save_games')) {
return false;
}
if (0 == $game_id) {
return false;
}
$Mysql = Mysql::get_instance();
$query = "\n\t\t\tSELECT *\n\t\t\tFROM `" . self::GAME_TABLE . "`\n\t\t\tWHERE game_id = '{$game_id}'\n\t\t";
$game = $Mysql->fetch_assoc($query);
if (!$game) {
return false;
}
if (!in_array($game['state'], array('Playing', 'Finished'))) {
return false;
}
$query = "\n\t\t\tSELECT P.player_id\n\t\t\t\t, P.username\n\t\t\t\t, GP.color\n\t\t\t\t, GP.order_num\n\t\t\tFROM `" . self::GAME_PLAYER_TABLE . "` AS `GP`\n\t\t\t\tJOIN `" . Player::PLAYER_TABLE . "` AS `P`\n\t\t\t\t\tON (P.player_id = GP.player_id)\n\t\t\tWHERE GP.game_id = '{$game_id}'\n\t\t\tORDER BY GP.order_num ASC\n\t\t";
$results = $Mysql->fetch_array($query);
if (!$results) {
return false;
}
$players = array();
foreach ($results as $result) {
$players[$result['player_id']] = $result;
}
$logs = self::get_logs($game_id, false);
if (empty($logs)) {
return false;
}
$winner = 'Unknown';
if ('D' === $logs[0]['data'][0]) {
$winner = (int) trim($logs[0]['data'], 'D ');
$winner = "{$winner} - {$players[$winner]['username']}";
}
// open the file for writing
$filename = GAMES_DIR . GAME_NAME . '_' . $game_id . '_' . date('Ymd', strtotime($game['create_date'])) . '.dat';
// don't use ldate() here
$file = fopen($filename, 'w');
if (false === $file) {
return false;
}
fwrite($file, "{$game['game_id']} - {$game['name']} - {$game['game_type']}\n");
fwrite($file, date('Y-m-d', strtotime($game['create_date'])) . "\n");
// don't use ldate() here
fwrite($file, date('Y-m-d', strtotime($game['modify_date'])) . "\n");
// don't use ldate() here
fwrite($file, "{$winner}\n");
fwrite($file, $GLOBALS['_ROOT_URI'] . "\n");
fwrite($file, "=================================\n");
fwrite($file, $game['extra_info'] . "\n");
fwrite($file, "=================================\n");
foreach ($players as $player) {
fwrite($file, "{$player['player_id']} - {$player['color']} - {$player['username']}\n");
}
fwrite($file, "=================================\n");
$logs = array_reverse($logs);
foreach ($logs as $log) {
fwrite($file, $log['data'] . "\n");
}
fwrite($file, "=================================\n");
fwrite($file, "KEY--- (plid = player_id, trid = territory_id, cid = continent_id, atk = attack, dfd = defend)\n");
fwrite($file, "A - Attack - [atk_plid]:[atk_trid]:[dfd_plid]:[dfd_trid]:[atk_rolls],[dfd_rolls]:[atk_lost],[dfd_lost]:[defeated]\n");
fwrite($file, "C - Card - [plid]:[card_id]\n");
fwrite($file, "D - Done (Game Over) - [winner_plid]\n");
fwrite($file, "E - Eradicated - [plid]:[killed_plid]:[cards_received (if any)]\n");
fwrite($file, "F - Fortify - [plid]:[armies_moved]:[from_trid]:[to_trid]\n");
fwrite($file, "I - Board Initialization - Ordered comma-separated list of plids ordered by trids (1-index).\n");
fwrite($file, "N - Next Player - [plid]\n");
fwrite($file, "O - Occupy - [plid]:[armies_moved]:[from_trid]:[to_trid]\n");
fwrite($file, "P - Placement - [plid]:[armies_placed]:[trid]\n");
fwrite($file, "Q - Quit - [plid]\n");
fwrite($file, "R - Reinforce - [plid]:[armies_given]:[num_territories_controlled]:[csv_cids_controlled (if any)]\n");
fwrite($file, "T - Trade - [plid]:[csv_card_list]:[armies_given]:[bonus_trid (if any)]\n");
fwrite($file, "V - Value for Trade - [next_trade_value]\n");
fwrite($file, "\n");
return fclose($file);
}
示例13: foreach
</div></form>';
if (is_array($chat_data)) {
$lobby .= '
<dl id="chats">';
foreach ($chat_data as $chat) {
// preserve spaces in the chat text
$chat['message'] = str_replace("\t", ' ', $chat['message']);
$chat['message'] = str_replace(' ', ' ', $chat['message']);
if (!isset($gravatars[$chat['email']])) {
$gravatars[$chat['email']] = Gravatar::src($chat['email']);
}
$grav_img = '<img src="' . $gravatars[$chat['email']] . '" alt="" /> ';
if ('' == $chat['username']) {
$chat['username'] = '[deleted]';
}
$lobby .= '
<dt>' . $grav_img . '<span>' . $chat['create_date'] . '</span> ' . $chat['username'] . '</dt>
<dd>' . htmlentities($chat['message'], ENT_QUOTES, 'ISO-8859-1', false) . '</dd>';
}
$lobby .= '
</dl> <!-- #chats -->';
}
$lobby .= '
</div> <!-- #chatbox -->
</div> <!-- #lobby -->';
$contents .= $lobby;
$hints = array('Select a game from the list and resume play by clicking anywhere on the row.', 'Invite another player to a game by clicking on the Invitations menu item.', '<span class="highlight">Colored entries</span> indicate that it is your turn.', '<span class="warning">WARNING!</span><br />Games will be deleted after ' . Settings::read('expire_games') . ' days of inactivity.', 'Finished games will be deleted after ' . Settings::read('expire_finished_games') . ' days.');
echo get_header($meta);
echo get_item($contents, $hints, $meta['title']);
call($GLOBALS);
echo get_footer($meta);
示例14: _send
/** protected function _send
* Sends email messages of various types [optional data contents]
*
* @param string message type
* @param mixed player id OR email address OR mixed array of both
* @param array optional message data
* @action send emails
* @return bool success
*/
protected function _send($type, $to, $data = array())
{
call(__METHOD__);
call($type);
call($to);
call($data);
if (is_array($to)) {
$return = true;
foreach ($to as $player) {
$return = $this->_send($type, trim($player), $data) && $return;
}
return $return;
} elseif (preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i', $to)) {
$email = $to;
} else {
// $to is a single player id
$player_id = (int) $to;
// test if this user accepts emails
$query = "\n\t\t\t\tSELECT P.email\n\t\t\t\t\t, PE.allow_email\n\t\t\t\tFROM " . Player::PLAYER_TABLE . " AS P\n\t\t\t\t\tLEFT JOIN " . GamePlayer::EXTEND_TABLE . " AS PE\n\t\t\t\t\t\tON P.player_id = PE.player_id\n\t\t\t\tWHERE P.player_id = '{$player_id}'\n\t\t\t";
list($email, $allow) = Mysql::get_instance()->fetch_row($query);
call($email);
call($allow);
if (empty($allow) || empty($email)) {
// no exception, just quit
return false;
}
}
call($email);
$site_name = Settings::read('site_name');
if (!in_array($type, array_keys($this->email_data))) {
throw new MyException(__METHOD__ . ': Trying to send email with unsupported type (' . $type . ')');
}
$subject = $this->email_data[$type]['subject'];
$message = $this->email_data[$type]['message'];
// replace the meta vars
$replace = array('/\\[\\[\\[GAME_NAME\\]\\]\\]/' => GAME_NAME, '/\\[\\[\\[site_name\\]\\]\\]/' => $site_name, '/\\[\\[\\[opponent\\]\\]\\]/' => ife($data['opponent'], 'opponent'), '/\\[\\[\\[export_data\\]\\]\\]/' => var_export($data, true));
$message = preg_replace(array_keys($replace), $replace, $message);
$subject = GAME_NAME . ' - ' . $subject;
if (!empty($data['game_id'])) {
$message .= "\n\n" . 'Game Link: ' . $GLOBALS['_ROOT_URI'] . 'game.php?id=' . (int) $data['game_id'];
} elseif (!empty($data['page'])) {
$message .= "\n\n" . 'Direct Link: ' . $GLOBALS['_ROOT_URI'] . $data['page'];
}
$message .= '
=============================================
This message was automatically sent by
' . $site_name . '
and should not be replied to.
=============================================
' . $GLOBALS['_ROOT_URI'];
$from_email = Settings::read('from_email');
// send the email
$headers = "From: " . GAME_NAME . " <{$from_email}>\r\n";
$message = html_entity_decode($message);
$this->_log($email . "\n" . $headers . "\n" . $subject . "\n" . $message);
call($subject);
call($message);
call($headers);
if ($GLOBALS['_USEEMAIL']) {
return mail($email, $subject, $message, $headers);
}
return false;
}
示例15: test_debug
/** function test_debug
* This function tests the debug given by the
* URL and checks it against the globals debug password
* and if they do not match, doesn't debug
*
* @param void
* @action tests debug pass
* @return bool success
*/
function test_debug()
{
if (!isset($_GET['DEBUG'])) {
return false;
}
if (!class_exists('Settings') || !Settings::test()) {
return false;
}
if ('' == trim(Settings::read('debug_pass'))) {
return false;
}
if (0 !== strcmp($_GET['DEBUG'], Settings::read('debug_pass'))) {
return false;
}
return true;
}