• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP esc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: content

function content()
{
    if (!user_logged_in()) {
        return must_log_in();
    }
    $user = fetch_one_or_none('users', 'id', user_logged_in());
    if (!array_key_exists('token', $_GET) || !$_GET['token'] || $_GET['token'] != sha1($user->new_email_address)) {
        $errors[] = 'Invalid reset token';
    }
    # This can happen if two accounts try to change address at similar times.
    if (count($errors) == 0 && count(fetch_all('users', 'email_address', $user->new_email_address))) {
        $errors[] = "A user with this email address already exists";
    }
    if (count($errors) == 0) {
        update_all('users', array('email_address' => $user->new_email_address, 'new_email_address' => null), 'id', user_logged_in());
        ?>
    <h2>Address changed</h2>
    <p>Your email address has been changed to
      <tt><?php 
        esc($user->new_email_address);
        ?>
</tt>.</p>
    <?php 
        return;
    }
    page_header('Address verification failed');
    show_error_list($errors);
}
开发者ID:ras52,项目名称:geneopedia,代码行数:28,代码来源:verify-email.php


示例2: esc

 /**
  * Performs simple auto-escaping of data for security reasons.
  * Might consider making this more complex at a later date.
  *
  * If $data is a string, then it simply escapes and returns it.
  * If $data is an array, then it loops over it, escaping each
  * 'value' of the key/value pairs.
  *
  * Valid context values: html, js, css, url, attr, raw, null
  *
  * @param string|array $data
  * @param string       $context
  * @param string       $encoding
  *
  * @return $data
  */
 function esc($data, $context = 'html', $encoding = null)
 {
     if (is_array($data)) {
         foreach ($data as $key => &$value) {
             $value = esc($value, $context);
         }
     }
     if (is_string($data)) {
         $context = strtolower($context);
         // Provide a way to NOT escape data since
         // this could be called automatically by
         // the View library.
         if (empty($context) || $context == 'raw') {
             return $data;
         }
         if (!in_array($context, ['html', 'js', 'css', 'url', 'attr'])) {
             throw new \InvalidArgumentException('Invalid escape context provided.');
         }
         if ($context == 'attr') {
             $method = 'escapeHtmlAttr';
         } else {
             $method = 'escape' . ucfirst($context);
         }
         $escaper = new \Zend\Escaper\Escaper($encoding);
         $data = $escaper->{$method}($data);
     }
     return $data;
 }
开发者ID:fatihmert,项目名称:php-framework-benchmark,代码行数:44,代码来源:Common.php


示例3: navLabel

 private function navLabel($node)
 {
     $nodetype = $node->has('nodetype_name') ? $node->get('nodetype_name') : $node->getNodetype()->displayField();
     $icon = $node->has('nodetype_icon') ? $node->get('nodetype_icon') : $node->getNodetype()->getIcon();
     $label = '<span class="badge-icon" title="' . esc($nodetype) . '"><i class="' . $icon . '"></i></span>';
     return $label . ' <span class="title">' . clean($node->getTitle()) . '</span>';
 }
开发者ID:nabble,项目名称:ajde,代码行数:7,代码来源:AdminCmsController.php


示例4: testEsc

 public function testEsc()
 {
     $expectations = [['Strings', "Strings"], ['Stri"ngs', "Stri&quot;ngs"], ['Stri\'ngs', "Stri&#039;ngs"]];
     foreach ($expectations as $expect) {
         $this->assertEquals($expect[1], esc($expect[0]));
     }
 }
开发者ID:PaulAntunes,项目名称:gclf-paul,代码行数:7,代码来源:GlobalFunctionsTest.php


示例5: content

function content()
{
    $users = fetch_wol('*', 'users', 'date_verified IS NOT NULL AND date_approved IS NOT NULL', 'name ASC');
    ?>
  <h2>Accounts</h2>

  <table>
    <?php 
    foreach ($users as $u) {
        ?>
    <tr>
      <td class="name"><a href="<?php 
        esc($u->id);
        ?>
"><?php 
        esc($u->name);
        ?>
</a></td>
    </tr>
    <?php 
    }
    ?>
  </table>
<?php 
}
开发者ID:ras52,项目名称:geneopedia,代码行数:25,代码来源:index.php


示例6: render

    public function render($doctype, $environment)
    {
        $languages = ipContent()->getLanguages();
        $answer = '';
        foreach ($languages as $language) {
            $langValue = '';
            $fieldValue = $this->getValue();
            if (is_array($fieldValue)) {
                if (!empty($fieldValue[$language->getCode()])) {
                    $langValue = $fieldValue[$language->getCode()];
                }
            }
            if (!is_string($langValue)) {
                //just in case we have an array or something else incompatible with below code in the database
                $langValue = '';
            }
            $answer .= '
<div class="input-group">
  <span class="input-group-addon">' . esc($language->getAbbreviation()) . '</span>
  <input ' . $this->getAttributesStr($doctype) . ' class="form-control ' . implode(' ', $this->getClasses()) . '" name="' . escAttr($this->getName() . '[' . $language->getCode() . ']" ') . $this->getValidationAttributesStr($doctype) . ' type="text" value="' . escAttr($langValue) . '" />
</div>
            ';
        }
        return $answer;
    }
开发者ID:Umz,项目名称:ImpressPages,代码行数:25,代码来源:TextLang.php


示例7: ipRelativeDir

 /**
  * @ignore
  * @param int $callLevel
  * @return string
  * @throws \Ip\Exception
  */
 public static function ipRelativeDir($callLevel = 0)
 {
     $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $callLevel + 1);
     if (!isset($backtrace[$callLevel]['file'])) {
         throw new \Ip\Exception("Can't find caller");
     }
     $absoluteFile = $backtrace[$callLevel]['file'];
     if (DIRECTORY_SEPARATOR == '\\') {
         // Replace windows paths
         $absoluteFile = str_replace('\\', '/', $absoluteFile);
     }
     $overrides = ipConfig()->get('fileOverrides');
     if ($overrides) {
         foreach ($overrides as $relativePath => $fullPath) {
             if (DIRECTORY_SEPARATOR == '\\') {
                 // Replace windows paths
                 $fullPath = str_replace('\\', '/', $fullPath);
             }
             if (strpos($absoluteFile, $fullPath) === 0) {
                 $relativeFile = substr_replace($absoluteFile, $relativePath, 0, strlen($fullPath));
                 return substr($relativeFile, 0, strrpos($relativeFile, '/') + 1);
             }
         }
     }
     $baseDir = ipConfig()->get('baseDir');
     $baseDir = str_replace('\\', '/', $baseDir);
     if (strpos($absoluteFile, $baseDir) !== 0) {
         throw new \Ip\Exception('Cannot find relative path for file ' . esc($absoluteFile));
     }
     $relativeFile = substr($absoluteFile, strlen($baseDir) + 1);
     return substr($relativeFile, 0, strrpos($relativeFile, '/') + 1);
 }
开发者ID:impresspages,项目名称:impresspages,代码行数:38,代码来源:PathHelper.php


示例8: document_save

/**
 * Saves a document in the database
 *
 * @param string $order_id the id of the order
 * @param string $location the current location of the file
 * @return void
 */
function document_save($order_id, $location)
{
    static $count = 0;
    $document_id = sprintf('DOC_%d_%d', $order_id, $count);
    $query = "INSERT INTO document (DOCUMENT_ID, DOCUMENT_TYPE_ID, DATE_CREATED, COMMENTS, DOCUMENT_LOCATION, CREATED_STAMP, CREATED_TX_STAMP)\n\t\t\t  VALUES ('{$document_id}', '" . DOC_REQUISION . "', NOW(), 'Document for order {$order_id}', '" . esc($location) . "', '" . now() . "', NOW())";
    db_query($query);
    $count++;
}
开发者ID:sahartak,项目名称:megamedia,代码行数:15,代码来源:documents.php


示例9: check_true

 public function check_true($value, $field = null)
 {
     if ($field === null) {
         $field = $this->primary_key;
     }
     $sql = "SELECT * FROM `{$this->table}` WHERE `{$field}` = '" . esc($value) . "' LIMIT 1";
     $rows = db_get_all($sql);
     return isset($rows[0]) ? true : false;
 }
开发者ID:nguyenquang2302,项目名称:BlogTaoLao,代码行数:9,代码来源:model.php


示例10: getBy

 public function getBy($value, $field = null)
 {
     if ($field === null) {
         $field = $this->primary_key;
     }
     $sql = "SELECT `{$this->table}`.*,`posts`.`Title` FROM `{$this->table}`,`posts` WHERE `{$this->table}`.`{$field}` = " . esc($value) . " and `{$this->table}`.`{$field}`= `posts`.`post_id`";
     $rows = db_get_all($sql);
     return isset($rows) ? $rows : false;
 }
开发者ID:nguyenquang2302,项目名称:BlogTaoLao,代码行数:9,代码来源:comment.php


示例11: page_header

function page_header($title)
{
    ?>
  <h2><?php 
    esc($title);
    ?>
</h2>
<?php 
}
开发者ID:ras52,项目名称:geneopedia,代码行数:9,代码来源:utils.php


示例12: loadHits

 public function loadHits()
 {
     $page = $_SERVER['REQUEST_URI'];
     $rowAll = Framework::getDb()->getFirstRow("SELECT SUM(hits) AS hits FROM page_hits WHERE page = '" . esc($page) . "'");
     $rowToday = Framework::getDb()->getFirstRow("SELECT SUM(hits) AS hits FROM page_hits WHERE page = '" . esc($page) . "' AND added >= DATE_FORMAT('Y-m-d', NOW())");
     $rowMonth = Framework::getDb()->getFirstRow("SELECT SUM(hits) AS hits FROM page_hits WHERE page = '" . esc($page) . "' AND added >= DATE_FORMAT('Y-m', NOW())");
     $rowYear = Framework::getDb()->getFirstRow("SELECT SUM(hits) AS hits FROM page_hits WHERE page = '" . esc($page) . "' AND added >= DATE_FORMAT('Y', NOW())");
     $this->PageHits = array('all' => $rowAll ? $rowAll['hits'] : 0, 'today' => $rowToday ? $rowToday['hits'] : 0, 'month' => $rowMonth ? $rowMonth['hits'] : 0, 'hits' => $rowYear ? $rowYear['hits'] : 0);
 }
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:9,代码来源:RoItem.class.php


示例13: content

function content()
{
    if (!user_logged_in()) {
        return must_log_in();
    }
    $user = fetch_one_or_none('users', 'id', user_logged_in());
    $errors = array();
    if (array_key_exists('change', $_POST)) {
        if (!isset($_POST['email']) || !$_POST['email']) {
            $errors[] = "Please enter an email address";
        } else {
            $email = $_POST['email'];
            if ($email && !validate_email_address($email)) {
                $errors[] = "Invalid email address";
            }
            if (count($errors) == 0 && count(fetch_all('users', 'email_address', $email))) {
                $errors[] = "A user with this email address already exists";
            }
            if (count($errors) == 0) {
                update_all('users', array('new_email_address' => $email), 'id', user_logged_in());
                send_email_change_email($email, $user->name);
                ?>
        <p>We have sent an email to your new address requesting that you
          confirm that change of address.</p>
        <?php 
                return;
            }
        }
    }
    $fields = array();
    page_header('Change email address');
    show_error_list($errors);
    ?>
 
    <form method="post" action="" accept-charset="UTF-8">
      <div class="fieldrow">
        <div class="field">
          <label>Current address:</label>
          <div><tt><?php 
    esc($user->email_address);
    ?>
</tt></div>
        </div>
      </div>

      <div class="fieldrow">
        <?php 
    text_field($fields, 'email', 'New address');
    ?>
      </div>

      <div class="fieldrow">
        <input type="submit" name="change" value="Change"/>
      </div>
    </form>
  <?php 
}
开发者ID:ras52,项目名称:geneopedia,代码行数:57,代码来源:change-email.php


示例14: content

function content()
{
    global $config;
    ?>
  <p>Welcome to <?php 
    esc($config['title']);
    ?>
.</p>
<?php 
}
开发者ID:ras52,项目名称:geneopedia,代码行数:10,代码来源:index.php


示例15: preview

 /**
  * Generate field value preview for table view. HTML is allowed
  * @param $recordData
  * @internal param array $data current record data
  * @return string
  */
 public function preview($recordData)
 {
     if ($this->previewMethod) {
         return call_user_func($this->previewMethod, $recordData);
     } else {
         if (isset($recordData[$this->field])) {
             return esc($recordData[$this->field]);
         }
     }
 }
开发者ID:Umz,项目名称:ImpressPages,代码行数:16,代码来源:Field.php


示例16: field

 public function field($key, $field = null)
 {
     if (is_null($field)) {
         $field = $key;
     }
     $value = a::get($this->data, $field);
     if ($key == 'url' and !v::url($value)) {
         $value = null;
     }
     $this->{$key} = new Field($this->page, $key, esc($value));
 }
开发者ID:aizlewood,项目名称:2016,代码行数:11,代码来源:mention.php


示例17: preview

 public function preview($recordData)
 {
     $previewValue = $recordData[$this->field];
     foreach ($this->values as $value) {
         if (is_array($value) && isset($value[1]) && $value[0] == $previewValue) {
             $previewValue = $value[1];
             break;
         }
     }
     return esc($previewValue);
 }
开发者ID:Umz,项目名称:ImpressPages,代码行数:11,代码来源:Radio.php


示例18: showImage

 public static function showImage($value, $recordData = null)
 {
     if ($value) {
         $transform = array('type' => 'fit', 'width' => 100, 'height' => 100);
         $thumbnailUrl = ipReflection($value, $transform, 'preview.jpg');
         $imageHtml = '<a href="' . ipFileUrl('file/repository/' . $value) . '" target="blank"><img src="' . $thumbnailUrl . '" alt="' . esc($value) . '"></a>';
         return $imageHtml;
     } else {
         return false;
     }
 }
开发者ID:sspaeti,项目名称:ImpressPages,代码行数:11,代码来源:Model.php


示例19: preview

 public function preview($recordData)
 {
     if ($this->fileLimit == 1) {
         return esc($recordData[$this->field]);
     } else {
         $data = json_decode($recordData[$this->field]);
         if (is_array($data)) {
             $data = implode(', ', $data);
         }
         return esc($data);
     }
 }
开发者ID:Umz,项目名称:ImpressPages,代码行数:12,代码来源:RepositoryFile.php


示例20: error_404_content

function error_404_content()
{
    ?>
  <h2>Error: 404 Not Found</h2>

  <p>The requested URL <tt><?php 
    esc($_SERVER['REQUEST_URI']);
    ?>
</tt> 
    was not found on this server.</p>
<?php 
}
开发者ID:ras52,项目名称:geneopedia,代码行数:12,代码来源:api.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP escAttr函数代码示例发布时间:2022-05-15
下一篇:
PHP es函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap