本文整理汇总了PHP中Format::htmlchars方法的典型用法代码示例。如果您正苦于以下问题:PHP Format::htmlchars方法的具体用法?PHP Format::htmlchars怎么用?PHP Format::htmlchars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Format
的用法示例。
在下文中一共展示了Format::htmlchars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onTicketCreated
function onTicketCreated($answer)
{
try {
global $ost;
if (!($ticket = Ticket::lookup($answer->object_id))) {
die('Unknown or invalid ticket ID.');
}
//Slack payload
$payload = array('attachments' => array(array('pretext' => "New Ticket <" . $ost->getConfig()->getUrl() . "scp/tickets.php?id=" . $ticket->getId() . "|#" . $ticket->getId() . "> in " . Format::htmlchars($ticket->getDept() instanceof Dept ? $ticket->getDept()->getName() : '') . " via " . $ticket->getSource() . " (" . Format::db_datetime($ticket->getCreateDate()) . ")", 'fallback' => "New Ticket <" . $ost->getConfig()->getUrl() . "scp/tickets.php?id=" . $ticket->getId() . "|#" . $ticket->getId() . "> in " . Format::htmlchars($ticket->getDept() instanceof Dept ? $ticket->getDept()->getName() : '') . " via " . $ticket->getSource() . " (" . Format::db_datetime($ticket->getCreateDate()) . ")", 'color' => "#D00000", 'fields' => array(array('title' => "From: " . mb_convert_case(Format::htmlchars($ticket->getName()), MB_CASE_TITLE) . " (" . $ticket->getEmail() . ")", 'value' => '', 'short' => false)))));
//Curl to webhook
$data_string = utf8_encode(json_encode($payload));
$url = $this->getConfig()->get('slack-webhook-url');
if (!function_exists('curl_init')) {
error_log('osticket slackplugin error: cURL is not installed!');
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
if ($result === false) {
error_log($url . ' - ' . curl_error($ch));
} else {
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != '200') {
error_log($url . ' Http code: ' . $statusCode);
}
}
curl_close($ch);
} catch (Exception $e) {
error_log('Error posting to Slack. ' . $e->getMessage());
}
}
示例2: validate
function validate(&$data, $format)
{
global $ost;
//Call parent to Validate the structure
if (!parent::validate($data, $format)) {
$this->exerr(400, 'Unexpected or invalid data received');
}
//Nuke attachments IF API files are not allowed.
if (!$ost->getConfig()->allowAPIAttachments()) {
$data['attachments'] = array();
}
//Validate attachments: Do error checking... soft fail - set the error and pass on the request.
if ($data['attachments'] && is_array($data['attachments'])) {
foreach ($data['attachments'] as &$attachment) {
if (!$ost->isFileTypeAllowed($attachment)) {
$attachment['error'] = 'Invalid file type (ext) for ' . Format::htmlchars($attachment['name']);
} elseif ($attachment['encoding'] && !strcasecmp($attachment['encoding'], 'base64')) {
if (!($attachment['data'] = base64_decode($attachment['data'], true))) {
$attachment['error'] = sprintf('%s: Poorly encoded base64 data', Format::htmlchars($attachment['name']));
}
}
}
unset($attachment);
}
return true;
}
示例3: validate
function validate(&$data, $format, $strict = true)
{
global $ost;
//Call parent to Validate the structure
if (!parent::validate($data, $format, $strict) && $strict) {
$this->exerr(400, __('Unexpected or invalid data received'));
}
// Use the settings on the thread entry on the ticket details
// form to validate the attachments in the email
$tform = TicketForm::objects()->one()->getForm();
$messageField = $tform->getField('message');
$fileField = $messageField->getWidget()->getAttachments();
// Nuke attachments IF API files are not allowed.
if (!$messageField->isAttachmentsEnabled()) {
$data['attachments'] = array();
}
//Validate attachments: Do error checking... soft fail - set the error and pass on the request.
if ($data['attachments'] && is_array($data['attachments'])) {
foreach ($data['attachments'] as &$file) {
if ($file['encoding'] && !strcasecmp($file['encoding'], 'base64')) {
if (!($file['data'] = base64_decode($file['data'], true))) {
$file['error'] = sprintf(__('%s: Poorly encoded base64 data'), Format::htmlchars($file['name']));
}
}
// Validate and save immediately
try {
$file['id'] = $fileField->uploadAttachment($file);
} catch (FileUploadError $ex) {
$file['error'] = $file['name'] . ': ' . $ex->getMessage();
}
}
unset($file);
}
return true;
}
示例4: display
function display($value)
{
$config = $this->getConfiguration();
if ($config['html']) {
return Format::safe_html($value);
} else {
return Format::htmlchars($value);
}
}
示例5: display
function display($text)
{
global $cfg;
$text = Format::htmlchars($text);
//take care of html special chars
if ($cfg && $cfg->clickableURLS() && $text) {
$text = Format::clickableurls($text);
}
return nl2br($text);
}
示例6: display
function display($text)
{
global $cfg;
$text = Format::htmlchars($text);
//take care of html special chars
if ($cfg && $cfg->clickableURLS() && $text) {
$text = Format::clickableurls($text);
}
//Wrap long words...
$text = preg_replace_callback('/\\w{75,}/', create_function('$matches', 'return wordwrap($matches[0],70,"\\n",true);'), $text);
return nl2br($text);
}
示例7: current
/**
* Ajax: GET /sequence/<id>
*
* Fetches the current value of a sequence
*
* Get-Arguments:
* format - (string) format string used to format the current value of
* the sequence.
*
* Returns:
* (string) Current sequence number, optionally formatted
*
* Throws:
* 403 - Not logged in
* 404 - Unknown sequence id
* 422 - Invalid sequence id
*/
function current($id)
{
global $thisstaff;
if (!$thisstaff) {
Http::response(403, 'Login required');
} elseif ($id == 0) {
$sequence = new RandomSequence();
} elseif (!$id || !is_numeric($id)) {
Http::response(422, 'Id is required');
} elseif (!($sequence = Sequence::lookup($id))) {
Http::response(404, 'No such object');
}
return $sequence->current(Format::htmlchars($_GET['format']));
}
示例8: render
function render()
{
$config = $this->field->getConfiguration();
if (isset($config['size'])) {
$size = "size=\"{$config['size']}\"";
}
if (isset($config['length'])) {
$maxlength = "maxlength=\"{$config['length']}\"";
}
if (isset($config['classes'])) {
$classes = 'class="' . $config['classes'] . '"';
}
if (isset($config['autocomplete'])) {
$autocomplete = 'autocomplete="' . ($config['autocomplete'] ? 'on' : 'off') . '"';
}
?>
<span style="display:inline-block">
<input type="<?php
echo static::$input_type;
?>
"
id="<?php
echo $this->name;
?>
"
<?php
echo $size . " " . $maxlength;
?>
<?php
echo $classes . ' ' . $autocomplete . ' placeholder="' . $config['placeholder'] . '"';
?>
name="<?php
echo $this->name;
?>
"
value="<?php
echo Format::htmlchars($this->value);
?>
"/>
</span>
<?php
}
示例9: csrf_token
$info = Format::htmlchars($errors && $_POST ? $_POST : $info);
?>
<h2>Email Address</h2>
<form action="emails.php?<?php
echo $qstr;
?>
" method="post" id="save">
<?php
csrf_token();
?>
<input type="hidden" name="do" value="<?php
echo $action;
?>
">
<input type="hidden" name="a" value="<?php
echo Format::htmlchars($_REQUEST['a']);
?>
">
<input type="hidden" name="id" value="<?php
echo $info['id'];
?>
">
<table class="form_table" width="940" border="0" cellspacing="0" cellpadding="2">
<thead>
<tr>
<th colspan="2">
<h4><?php
echo $title;
?>
</h4>
<em><strong>Email Information</strong>: Login details are optional BUT required when IMAP/POP or SMTP are enabled.</em>
示例10: sprintf
<td width=7px>
<input type="checkbox" class="ckb" name="ids[]"
value="<?php echo $row['id']; ?>" <?php echo $sel?'checked="checked"':''; ?> >
</td>
<td>
<a class="userPreview"
href="users.php?id=<?php echo $row['id']; ?>"><?php
echo Format::htmlchars($name); ?></a>
<?php
if ($row['tickets'])
echo sprintf('<i class="icon-fixed-width icon-file-text-alt"></i>
<small>(%d)</small>', $row['tickets']);
?>
</td>
<td><?php echo Format::htmlchars($row['email']); ?></td>
<td><?php echo $status; ?></td>
<td><?php echo Format::db_date($row['created']); ?></td>
</tr>
<?php
} //end of while.
endif; ?>
</tbody>
<tfoot>
<tr>
<td colspan="5">
<?php
if ($res && $num) {
?>
<?php echo __('Select'); ?>:
<a id="selectAll" href="#ckb"><?php echo __('All'); ?></a>
示例11: die
<?php
if (!defined('OSTADMININC') || !$thisuser->isadmin()) {
die('Access Denied');
}
//Get the config info.
$config = Format::htmlchars($errors && $_POST ? $_POST : $cfg->getConfig());
//Basic checks for warnings...
$warn = array();
if ($config['allow_attachments'] && !$config['upload_dir']) {
$errors['allow_attachments'] = 'You need to setup upload dir.';
} else {
if (!$config['allow_attachments'] && $config['allow_email_attachments']) {
$warn['allow_email_attachments'] = '*Attachments Disabled.';
}
if (!$config['allow_attachments'] && ($config['allow_online_attachments'] or $config['allow_online_attachments_onlogin'])) {
$warn['allow_online_attachments'] = '<br>*Attachments Disabled.';
}
}
//Not showing err on post to avoid alarming the user...after an update.
if (!$errors['err'] && !$msg && $warn) {
$errors['err'] = 'Possible errors detected, please check the warnings below';
}
$gmtime = Misc::gmtime();
$depts = db_query('SELECT dept_id,dept_name FROM ' . DEPT_TABLE . ' WHERE ispublic=1');
$templates = db_query('SELECT tpl_id,name FROM ' . EMAIL_TEMPLATE_TABLE . ' WHERE tpl_id=1 AND cfg_id=' . db_input($cfg->getId()));
?>
<div class="msg">System Preferences and Settings (v<?php
echo $config['ostversion'];
?>
)</div>
示例12: Copyright
<?php
/*********************************************************************
file.php
Simply downloads the file...on hash validation as follows;
* Hash must be 64 chars long.
* First 32 chars is the perm. file hash
* Next 32 chars is md5(file_id.session_id().file_hash)
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2013 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require 'staff.inc.php';
require_once INCLUDE_DIR . 'class.file.php';
$h = trim($_GET['h']);
//basic checks
if (!$h || strlen($h) != 64 || !($file = AttachmentFile::lookup(substr($h, 0, 32))) || strcasecmp(substr($h, -32), md5($file->getId() . session_id() . $file->getHash()))) {
//next 32 is file id + session hash.
die('Unknown or invalid file. #' . Format::htmlchars($_GET['h']));
}
$file->download();
示例13: implode
?>
js/redactor-fonts.js?19292ad"></script>
<?php
if ($ost && ($headers = $ost->getExtraHeaders())) {
echo "\n\t" . implode("\n\t", $headers) . "\n";
}
?>
</head>
<body>
<div id="container">
<div id="header">
<div class="pull-right flush-right">
<p>
<?php
if ($thisclient && is_object($thisclient) && $thisclient->isValid() && !$thisclient->isGuest()) {
echo Format::htmlchars($thisclient->getName()) . ' |';
?>
<a href="<?php
echo ROOT_PATH;
?>
profile.php"><?php
echo __('Profile');
?>
</a> |
<a href="<?php
echo ROOT_PATH;
?>
tickets.php"><?php
echo sprintf(__('Tickets <b>(%d)</b>'), $thisclient->getNumTickets());
?>
</a> -
示例14: db_input
}
?>
<tr class="info">
<td><?php
echo Format::display($msg_row['message']);
?>
</td></tr>
</table>
<?php
//get answers for messages
$sql = 'SELECT resp.*,count(attach_id) as attachments FROM ' . TICKET_RESPONSE_TABLE . ' resp ' . ' LEFT JOIN ' . TICKET_ATTACHMENT_TABLE . ' attach ON resp.ticket_id=attach.ticket_id AND resp.response_id=attach.ref_id AND ref_type=\'R\' ' . ' WHERE msg_id=' . db_input($msg_row['msg_id']) . ' AND resp.ticket_id=' . db_input($ticket->getId()) . ' GROUP BY resp.response_id ORDER BY created';
//echo $sql;
$resp = db_query($sql);
while ($resp_row = db_fetch_array($resp)) {
$respID = $resp_row['response_id'];
$name = $cfg->hideStaffName() ? 'staff' : Format::htmlchars($resp_row['staff_name']);
?>
<table align="center" class="response" cellspacing="0" cellpadding="1" width="100%" border=0>
<tr>
<th><?php
echo Format::db_daydatetime($resp_row['created']);
?>
- <?php
echo $name;
?>
</th></tr>
<?php
if ($resp_row['attachments'] > 0) {
?>
<tr class="header">
<td><?php
示例15: elseif
case 'update':
if (!$user) {
$errors['err'] = 'Unknown or invalid user.';
} elseif (($acct = $user->getAccount()) && !$acct->update($_POST, $errors)) {
$errors['err'] = 'Unable to update user account information';
} elseif ($user->updateInfo($_POST, $errors)) {
$msg = 'User updated successfully';
$_REQUEST['a'] = null;
} elseif (!$errors['err']) {
$errors['err'] = 'Unable to update user profile. Correct any error(s) below and try again!';
}
break;
case 'create':
$form = UserForm::getUserForm()->getForm($_POST);
if ($user = User::fromForm($form)) {
$msg = Format::htmlchars($user->getName()) . ' added successfully';
$_REQUEST['a'] = null;
} elseif (!$errors['err']) {
$errors['err'] = 'Unable to add user. Correct any error(s) below and try again.';
}
break;
case 'confirmlink':
if (!$user || !$user->getAccount()) {
$errors['err'] = 'Unknown or invalid user account';
} elseif ($user->getAccount()->isConfirmed()) {
$errors['err'] = 'Account is already confirmed';
} elseif ($user->getAccount()->sendConfirmEmail()) {
$msg = 'Account activation email sent to ' . $user->getEmail();
} else {
$errors['err'] = 'Unable to send account activation email - try again!';
}