/**
  * @inheritDoc
  */
 public function formatValue(string $typeSpecifier, $value) : string
 {
     $valueTypeCheck = $this->valueTypeCheck;
     $valueTypeCheck($value);
     // MessageFormatter supports IntlCalendar, but HHVM does a strange date format.
     if ($value instanceof IntlCalendar) {
         $value = $value->toDateTime();
     }
     return Message::formatMessage($this->locale, $this->messageFormats[$typeSpecifier], [$value]);
 }
Exemplo n.º 2
0
 public function format($message, $params, $language)
 {
     $params_new = [];
     $matches = [];
     preg_match_all("/\\{[A-z0-9]+\\}/isU", $message, $matches);
     if (count($matches[0])) {
         foreach ($matches[0] as $k => $val) {
             $message = str_replace($val, "{" . $k . "}", $message);
             $val_search = str_replace("{", "", str_replace("}", "", $val));
             $params_new[$k] = $params[$val_search];
         }
     }
     return MessageFormatter::formatMessage($language, $message, $params_new);
 }
Exemplo n.º 3
0
 public function getDetails($isbn = null)
 {
     if ($isbn != null && apiUtils::isValidISBN($isbn)) {
         $url = MessageFormatter::formatMessage("nl_NL", BookloveApi::baseUrl . BookloveApi::editionInfoEndpoint, array($this->apikey, $isbn));
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $response = curl_exec($ch);
         curl_close($ch);
         if ($response !== false) {
             return $response;
         }
         return null;
     }
 }
Exemplo n.º 4
0
 static function getByISBN($isbn)
 {
     $url = MessageFormatter::formatMessage("nl_NL", NurApi::baseURL . NurApi::isbnEndpoint, array($isbn));
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $response = curl_exec($ch);
     curl_close($ch);
     if ($response !== false) {
         try {
             $response = str_replace("xmlns=\"http://www.editeur.org/onix/2.1/reference\"", "", $response);
             $xml = new SimpleXMLElement($response);
             $xpathResult = $xml->xpath("/ONIXMessage/Product/Subject/SubjectCode/text()");
             return $xpathResult[0]->__toString();
         } catch (Exception $e) {
             // die ( $e );
         }
     }
     return null;
 }
Exemplo n.º 5
0
function generate_delete_link()
{
    global $CURUSER, $user_lang, $res;
    stdhead($res['msg_delete_association_title']);
    ?>

<form method="post">
	<p><?php 
    echo MessageFormatter::formatMessage($user_lang, $res['msg_delete_association_text'], array(htmlspecialchars($CURUSER['cc98id'])));
    ?>
</p>
	<input type="hidden" name="action" value="delete" />
	<button type="submit"><?php 
    echo $res['msg_delete_association_button_text'];
    ?>
</button>
</form>

<?php 
    stdfoot();
}
Exemplo n.º 6
0
/**
 * 登录相关操作。
 */
function dologon($cc98_id)
{
    global $res;
    $user_lang = get_current_user_lang();
    $sql = new_mysqli();
    $query = $sql->prepare('SELECT `id`, `passhash`, `username` FROM `users` WHERE `cc98id` = ?');
    $query->bind_param('s', $cc98_id);
    $query->execute();
    $query->bind_result($id, $passhash, $username);
    // 是否匹配到结果。
    if ($query->fetch()) {
        logincookie($id, md5($passhash));
        ?>
<meta http-equiv="refresh" content="3; url=/" />
<?php 
        $title = $res['msg_logon_success_title'];
        $msg = MessageFormatter::formatMessage($user_lang, $res['msg_logon_success_text'], array($username));
        stdhead($title);
        stdmsg($title, $msg);
        stdfoot();
        die;
        break;
        // 没有关联到账户
    } else {
        stderr($res['msg_no_associated_account_title'], $res['msg_no_associated_account_text']);
        die;
    }
}
Exemplo n.º 7
0
?>

<h1><?php 
echo MessageFormatter::formatMessage($user_lang, $lang_bbcode['text_title_format'], $title);
?>
</h1>
<p><?php 
echo $lang_bbcode['text_instruction'];
?>
</p>

<table style="width: 95%; margin: 10px;">
	<thead>
		<tr>
			<th class="colhead" align="center"><?php 
echo MessageFormatter::formatMessage($user_lang, $lang_bbcode['text_title_format'], $title);
?>
</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>
				<blockquote style="white-space: pre-wrap; overflow:scroll; font-family: 'Segoe UI';">
					<?php 
echo htmlspecialchars($descrption);
?>
				</blockquote>
			</td>
		</tr>
	</tbody>
Exemplo n.º 8
0
    echo $maxloginattempts;
    ?>
</b>] <?php 
    echo $lang_login['p_fail_ban'];
    ?>
		<?php 
}
?>

	</p>

	<?php 
if (!is_special_ip()) {
    ?>
	<p><?php 
    echo MessageFormatter::formatMessage("", $lang_login['p_login_remaing_tries_format'], array(remaining()));
    ?>
		<?php 
}
?>

	</p>
	<table border="0" cellpadding="5">
		<tr>
			<td class="rowhead"><?php 
echo $lang_login['rowhead_username'];
?>
</td>
			<td class="rowfollow" align="left">
				<input type="text" name="username" style="width: 180px; border: 1px solid gray" /></td>
		</tr>
Exemplo n.º 9
0
 /**
  * Returns translated string
  * 
  * @param string $key    The key to translate
  * @param array  $params The string values to passe in
  * @param string $target The target locale string if diferent than current
  * 
  * @return string The resulting string
  */
 public function translate($key, $params = array(), $target = null)
 {
     // Load defauts
     $current = $this->current;
     $directory = $this->directory . DIRECTORY_SEPARATOR . $current;
     $params = (array) $params;
     // Validate and load different $target
     if (!empty($target) && $target != $current) {
         $current = $target;
         $directory = $this->directory . DIRECTORY_SEPARATOR . $current;
         // Validate locale and translations directory
         if (\Locale::canonicalize($current) === null || !is_dir($this->directory . DIRECTORY_SEPARATOR . $current)) {
             throw new DualityException("Error Locale: target code ", DualityException::E_LOCALE_NOTFOUND);
         }
     }
     // Finally, return result
     $storage = new Storage();
     $storage->importArray(include $directory . DIRECTORY_SEPARATOR . 'messages.php');
     return \MessageFormatter::formatMessage($current, $storage->get($key), $params);
 }
Exemplo n.º 10
0
Arquivo: Intl.php Projeto: vakata/intl
 /**
  * Get a translated string using its key in the translations array.
  * @param  array|string $key     the translation key, if an array all values will be checked until a match is found
  * @param  array        $replace any variables to replace with
  * @param  string|null  $default optional value to return if key is not found, `null` returns the key
  * @return string       the final translated string
  */
 public function get($key, array $replace = [], string $default = null) : string
 {
     if (is_array($key)) {
         foreach ($key as $k) {
             $tmp = $this->get($k, $replace, chr(0));
             if ($tmp !== chr(0)) {
                 return $tmp;
             }
         }
         return $default;
     }
     if ($default === null) {
         $default = $key;
     }
     $tmp = explode('.', strtolower($key));
     $val = $this->data;
     foreach ($tmp as $k) {
         $ok = false;
         if (is_array($val)) {
             foreach ($val as $kk => $vv) {
                 if ($k === strtolower($kk)) {
                     $val = $vv;
                     $ok = true;
                     break;
                 }
             }
         }
         if (!$ok) {
             return $default;
         }
     }
     $val = MF::formatMessage($this->code, (string) $val, $replace);
     return $val === false ? $default : $val;
 }
Exemplo n.º 11
0

      <form id="new-pl-form" class="container-fluid" action="#" method="post"
          onsubmit="return false;"
          autocomplete="off"
      >

        <div class="row">

          <div class="col-md-8 col-xs-12">
            <div id="new-pl-help" class="alert alert-info" role="alert">
              <?php 
$m = html($msg->raw('commands_h'));
$locale = $msg->get_locale();
$args = ['<code>%</code>', '<code>%%</code>', '<code>gcc %% -o %</code>', '<code>gcc "myfile.c" -o "myfile"</code>'];
print MessageFormatter::formatMessage($locale, $m, $args);
?>
            </div>
          </div>

          <div class="col-md-4 col-xs-12">
            &nbsp;
          </div>
        </div>

        <div class="row">

          <div class="col-md-2 col-xs-12">
            <div class="form-group">
              <div class="btn-group">
                <button type="button" class="btn btn-default dropdown-toggle"
Exemplo n.º 12
0
         die;
     } else {
         KPS("-", $uploadsubtitle_bonus, $a["uppedby"]);
         //subtitle uploader loses bonus for deleted subtitle
     }
     if ($CURUSER['id'] != $a['uppedby']) {
         $owner_res = get_user_resource($a['uppedby'])['delete_sub_target'];
         $owner_lang = get_fix_user_lang($a['uppedby']);
         // 标题
         $subject = $owner_res['msg_deleted_your_sub'];
         // 带有用户链接的用户信息。
         $deleter_info = MessageFormatter::formatMessage("", "[url=userdetails.php?id={0}]{1}[/url]", array($CURUSER['id'], $CURUSER['username']));
         // 消息模板,根据是否有注释,使用不同类型。
         $msg_format = $reason ? $owner_res['msg_delete_sub_format_reason'] : $owner_res['msg_delete_sub_format'];
         // 正文。
         $msg = MessageFormatter::formatMessage($owner_lang, $msg_format, array($a['id'], $a['title'], $deleter_info, $reason));
         $time = (string) date("Y-m-d H:i:s");
         $sql = new_mysqli();
         $query = $sql->prepare("INSERT INTO `messages` (`sender`, `receiver`, `added`, `msg`, `subject`) VALUES (0, ?, ?, ?, ?)");
         $query->bind_param("isss", $a['uppedby'], $time, $msg, $subject);
         $query->execute() or sqlerr(__FILE__, __LINE__);
         $sql->close();
     }
     $res = sql_query("SELECT lang_name from language WHERE sub_lang=1 AND id = " . sqlesc($a["lang_id"])) or sqlerr(__FILE__, __LINE__);
     $arr = mysql_fetch_assoc($res);
     write_log("{$arr['lang_name']} Subtitle {$delete} ({$a['title']}) was deleted by " . ($a["anonymous"] == 'yes' && $a["uppedby"] == $CURUSER["id"] ? "Anonymous" : $CURUSER['username']) . ($a["uppedby"] != $CURUSER["id"] ? ", Mod Delete" : "") . ($reason != "" ? " (" . $reason . ")" : ""));
 } else {
     stdmsg($lang_subtitles['std_delete_subtitle'], $lang_subtitles['std_delete_subtitle_note'] . "<br /><form method=post action=subtitles.php?delete={$delete}&sure=1>" . $lang_subtitles['text_reason_is'] . "<input type=text style=\"width: 200px\" name=reason><input type=submit value=\"" . $lang_subtitles['submit_confirm'] . "\"></form>");
     stdfoot();
     die;
 }
Exemplo n.º 13
0
 /**
  * {@inheritdoc}
  *
  * @param  string $translateKey
  * @param  array  $placeholders
  * @return string
  */
 public function query($translateKey, $placeholders = null)
 {
     $options = $this->options;
     $translation = $options['db']->fetchOne($this->stmtSelect, Db::FETCH_ASSOC, ['language' => $options['language'], 'key_name' => $translateKey]);
     $value = empty($translation['value']) ? $translateKey : $translation['value'];
     if (is_array($placeholders) && !empty($placeholders)) {
         if (true === $this->useIcuMessageFormatter) {
             $value = \MessageFormatter::formatMessage($options['language'], $value, $placeholders);
         } else {
             foreach ($placeholders as $placeHolderKey => $placeHolderValue) {
                 $value = str_replace('%' . $placeHolderKey . '%', $placeHolderValue, $value);
             }
         }
     }
     return $value;
 }
Exemplo n.º 14
0
<?php

/*
 * CC98 登录页面
 * 
 * 版本:1.0
 * 作者:樱桃
 * 时间:2014-10-13
 * 
 * 修订记录:
 * 无
 * 
 */
require_once "include/bittorrent.php";
global $cc98_client_id, $cc98_redirect_uri;
$state = array('action' => 'logon', 'returnto' => $_GET['returnto']);
$state_str = protect_data($state);
$url = MessageFormatter::formatMessage('', 'https://login.cc98.org/OAuth/Authorize?client_id={0}&redirect_uri={1}&response_type=code&state={2}', array(urlencode($cc98_client_id), urlencode($cc98_redirect_uri), urlencode($state_str)));
// 重定向到登录页面。
header('Location: ' . $url, true);
exit;
Exemplo n.º 15
0
 public function _($key, $args = array())
 {
     $bundle = $this->raw($key);
     return MessageFormatter::formatMessage($this->locale, $bundle, $args);
 }
Exemplo n.º 16
0
$send_email = $email;
$email = sqlesc($email);
$country = sqlesc($country);
$gender = sqlesc($gender);
$sitelangid = sqlesc(get_langid_from_langcookie());
$res_check_user = sql_query("SELECT * FROM users WHERE username = "******"INSERT INTO users (username, passhash, secret, editsecret, email, country, gender, status, class, invites, " . ($type == 'invite' ? "invited_by," : "") . " added, last_access, lang, stylesheet" . ($showschool == 'yes' ? ", school" : "") . ", uploaded,ip) VALUES (" . $wantusername . "," . $wantpasshash . "," . $secret . "," . $editsecret . "," . $email . "," . $country . "," . $gender . ", 'pending', " . $defaultclass_class . "," . $invite_count . ", " . ($type == 'invite' ? "'{$inviter}'," : "") . " '" . date("Y-m-d H:i:s") . "' , " . " '" . date("Y-m-d H:i:s") . "' , " . $sitelangid . "," . $defcss . ($showschool == 'yes' ? "," . $school : "") . "," . ($iniupload_main > 0 ? $iniupload_main : 0) . ",'" . getip() . "')") or sqlerr(__FILE__, __LINE__);
$id = mysql_insert_id();
// 发送欢迎消息
// 消息可选参数
$messageParams = array($wantusernameraw, $SITENAME);
$title = MessageFormatter::formatMessage(get_current_user_lang(), get_current_user_resource()['signup']['welcome_message_title'], $messageParams);
$text = MessageFormatter::formatMessage(get_current_user_lang(), get_current_user_resource()['signup']['welcome_message_text'], $messageParams);
send_message(0, $id, $title, $text);
//write_log("User account $id ($wantusername) was created");
$res = sql_query("SELECT passhash, secret, editsecret, status FROM users WHERE id = " . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_assoc($res);
$psecret = md5($row['secret']);
$ip = getip();
$usern = htmlspecialchars($wantusername);
$title = $SITENAME . $lang_takesignup['mail_title'];
$body = <<<EOD
{$lang_takesignup['mail_one']}{$usern}{$lang_takesignup['mail_two']}({$email}){$lang_takesignup['mail_three']}{$ip}{$lang_takesignup['mail_four']}
<b><a href="http://{$BASEURL}/confirm.php?id={$id}&secret={$psecret}" target="_blank">
{$lang_takesignup['mail_this_link']} </a></b><br />
http://{$BASEURL}/confirm.php?id={$id}&secret={$psecret}
{$lang_takesignup['mail_four_1']}
<b><a href="http://{$BASEURL}/confirm_resend.php" target="_blank">{$lang_takesignup['mail_here']}</a></b><br />
Exemplo n.º 17
0
tr_small($lang_usercp['row_email_address'], $CURUSER['email'], 1);
if ($enablelocation_tweak == 'yes') {
    list($loc_pub, $loc_mod) = get_ip_location($CURUSER["ip"]);
    tr_small($lang_usercp['row_ip_location'], $CURUSER["ip"] . " <span title='" . $loc_mod . "'>[" . $loc_pub . "]</span>", 1);
} else {
    tr_small($lang_usercp['row_ip_location'], $CURUSER["ip"], 1);
}
if ($CURUSER["avatar"]) {
    tr_small($lang_usercp['row_avatar'], "<img src=\"" . $CURUSER["avatar"] . "\" border=0>", 1);
}
tr_small($lang_usercp['row_passkey'], $CURUSER["passkey"], 1);
// CC98 ID
if ($CURUSER["cc98id"]) {
    $cc98id_str = MessageFormatter::formatMessage('', '<a href="http://www.cc98.org/dispuser.asp?name={0}">{0}</a> <a href="/cc98id.php?action=edit">[{1}]</a> <a href="/cc98id.php?action=delete">[{2}]</a>', array($CURUSER["cc98id"], $res['cc98_id_action_edit'], $res['cc98_id_action_delete']));
} else {
    $cc98id_str = MessageFormatter::formatMessage('', '<span style="color: gray">{0}</span> <a  href="/cc98id.php?action=new">[{1}]</a>', array($res['cc98_id_text_none'], $res['cc98_id_action_create']));
}
tr_small($res['cc98_id_association_title'], $cc98id_str, 1);
if ($prolinkpoint_bonus) {
    $prolinkclick = get_row_count("prolinkclicks", "WHERE userid=" . $CURUSER['id']);
    tr_small($lang_usercp['row_promotion_link'], $prolinkclick . " [<a href=\"promotionlink.php\">" . $lang_usercp['text_read_more'] . "</a>]", 1);
    //tr_small($lang_usercp['row_promotion_link'], $prolinkclick. " [<a href=\"promotionlink.php?updatekey=1\">".$lang_usercp['text_update_promotion_link']."</a>] [<a href=\"promotionlink.php\">".$lang_usercp['text_read_more']."</a>]", 1);
}
tr_small($lang_usercp['row_invitations'], $CURUSER[invites] . " [<a href=\"invite.php?id=" . $CURUSER[id] . "\" title=\"" . $lang_usercp['link_send_invitation'] . "\">" . $lang_usercp['text_send'] . "</a>]", 1);
tr_small($lang_usercp['row_karma_points'], $CURUSER['seedbonus'] . " [<a href=\"mybonus.php\" title=\"" . $lang_usercp['link_use_karma_points'] . "\">" . $lang_usercp['text_use'] . "</a>]", 1);
tr_small($lang_usercp['row_written_comments'], $commentcount . " [<a href=\"userhistory.php?action=viewcomments&id=" . $CURUSER[id] . "\" title=\"" . $lang_usercp['link_view_comments'] . "\">" . $lang_usercp['text_view'] . "</a>]", 1);
if ($forumposts) {
    tr($lang_usercp['row_forum_posts'], $forumposts . " [<a href=\"userhistory.php?action=viewposts&id=" . $CURUSER[id] . "\" title=\"" . $lang_usercp['link_view_posts'] . "\">" . $lang_usercp['text_view'] . "</a>] (" . $dayposts . $lang_usercp['text_posts_per_day'] . "; " . $percentages . $lang_usercp['text_of_total_posts'] . ")", 1);
}
?>
</table>
Exemplo n.º 18
0
//===remove karma
KPS("-", $uploadtorrent_bonus, $row["owner"]);
//Send pm to torrent uploader
if ($CURUSER["id"] != $row["owner"]) {
    // 作者语言
    $owner_lang = get_fix_user_lang($row["owner"]);
    // 删除种子相关的资源。
    $owner_delete_res = get_user_resource($row["owner"])['delete_torrent_target'];
    // 返回给种子作者的原因说明
    $reason_str = generate_delete_reason($row["owner"], $rt, $reason);
    // 带有用户链接的用户信息。
    $deleter_info = MessageFormatter::formatMessage("", "[url=userdetails.php?id={0}]{1}[/url]", array($CURUSER['id'], $CURUSER['username']));
    // 删除消息标题。
    $subject = $owner_delete_res['msg_torrent_deleted'];
    // 删除消息正文。
    $msg = MessageFormatter::formatMessage($owner_lang, $owner_delete_res['msg_torrent_deleted_format'], array($id, $row['name'], $deleter_info, $reason_str));
    // 时间。
    $dt = (string) date("Y-m-d H:i:s");
    $sql = new_mysqli();
    $query = $sql->prepare("INSERT INTO `messages` (`sender`, `receiver`, `subject`, `added`, `msg`) VALUES (0, ?, ?, ?, ?)");
    $query->bind_param("isss", $row['owner'], $subject, $dt, $msg);
    $query->execute() or sqlerr(__FILE__, __LINE__);
    $sql->close();
}
stdhead($res_delete['torrent_deleted_title']);
if (isset($_POST["returnto"])) {
    $ret = "<a href=\"" . htmlspecialchars($_POST["returnto"]) . "\">" . $lang_delete['text_go_back'] . "</a>";
} else {
    $ret = "<a href=\"index.php\">" . $lang_delete['text_back_to_index'] . "</a>";
}
?>