当前位置: 首页>>代码示例>>PHP>>正文


PHP sanitize_url函数代码示例

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


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

示例1: create_post

 public function create_post($student_id, $group_id, $public, $post, $type = 1, $img_path = NULL)
 {
     if ($this->validate_post($post) === FALSE) {
         return "Empty post. Posting aborted.";
     }
     $safe_post = $this->make_post_safe($post);
     $validation_result = $this->validate_variables($student_id, $group_id, $public);
     if ($validation_result === FALSE) {
         return "Group Permission Error. Posting aborted.";
     } elseif ($validation_result === 0) {
         $public = $validation_result;
     }
     //Check if type is accepted
     if (is_int($type) && ($type === 1 || $type === 2)) {
         //Type is either 1 or 2 (Regular post or Image post)
     } else {
         $type = 1;
         //Set type as 1!
     }
     $safe_image_path = NULL;
     if (!empty($img_path)) {
         if ($type !== 2) {
             $type = 2;
         }
         if (filter_var($img_path, FILTER_VALIDATE_URL)) {
             $safe_image_path = sanitize_url($img_path);
         } else {
             return "There was an error with the uploaded image";
         }
     }
     return $this->save_post($student_id, $group_id, $public, $safe_post, $type, $safe_image_path);
 }
开发者ID:DonBananos,项目名称:studyteam,代码行数:32,代码来源:post_controller.php

示例2: form_html

 function form_html()
 {
     $form = '<div class="wpcf7" id="' . $this->unit_tag . '">';
     $url = wpcf7_get_request_uri();
     if ($frag = strstr($uri, '#')) {
         $uri = substr($uri, 0, -strlen($frag));
     }
     $url .= '#' . $this->unit_tag;
     $url = apply_filters('wpcf7_form_action_url', $url);
     $url = sanitize_url($url);
     $enctype = apply_filters('wpcf7_form_enctype', '');
     $form .= '<form action="' . $url . '" method="post" class="wpcf7-form"' . $enctype . '>' . "\n";
     $form .= '<div style="display: none;">' . "\n";
     $form .= '<input type="hidden" name="_wpcf7" value="' . esc_attr($this->id) . '" />' . "\n";
     $form .= '<input type="hidden" name="_wpcf7_version" value="' . esc_attr(WPCF7_VERSION) . '" />' . "\n";
     $form .= '<input type="hidden" name="_wpcf7_unit_tag" value="' . esc_attr($this->unit_tag) . '" />' . "\n";
     $form .= '</div>' . "\n";
     $form .= $this->form_elements();
     if (!$this->responses_count) {
         $form .= $this->form_response_output();
     }
     $form .= '</form>';
     $form .= '</div>';
     return $form;
 }
开发者ID:aliciente,项目名称:portfolio,代码行数:25,代码来源:classes.php

示例3: mob_boxes_meta_save_url

/**
 * Save the meta box's post metadata. 
 * 
 * @param integer $post_id
 * @param array   $post
 * 
 * @return integer
 */
function mob_boxes_meta_save_url($post_id, $post)
{
    // Verify the nonce before proceeding.
    if (!isset($_POST['mob_boxes_url_nonce']) || !wp_verify_nonce($_POST['mob_boxes_url_nonce'], basename(__FILE__))) {
        return $post_id;
    }
    // Get the post type object.
    $post_type = get_post_type_object($post->post_type);
    // Check if the current user has permission to edit the post.
    if (!current_user_can($post_type->cap->edit_post, $post_id)) {
        return $post_id;
    }
    // Get the posted data and sanitize it for use as an HTML class.
    $new_meta_value = isset($_POST['mob_boxes_url']) ? sanitize_url($_POST['mob_boxes_url']) : '';
    // Get the meta key.
    $meta_key = 'mob_boxes_url';
    // Get the meta value of the custom field key.
    $meta_value = get_post_meta($post_id, $meta_key, true);
    // If a new meta value was added and there was no previous value, add it.
    if ($new_meta_value && '' == $meta_value) {
        add_post_meta($post_id, $meta_key, $new_meta_value, true);
    } elseif ($new_meta_value && $new_meta_value != $meta_value) {
        update_post_meta($post_id, $meta_key, $new_meta_value);
    } elseif ('' == $new_meta_value && $meta_value) {
        delete_post_meta($post_id, $meta_key, $meta_value);
    }
}
开发者ID:markoliverbrawn,项目名称:moby-wordpress-template,代码行数:35,代码来源:boxes.php

示例4: get_link

 public static function get_link(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     if (!empty($configdata['artefactid'])) {
         $data = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $configdata['artefactid'] . '&view=' . $instance->get('view');
         return sanitize_url($data);
     }
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:8,代码来源:lib.php

示例5: force_download

function force_download($a)
{
    if (empty($a)) {
        die('Error: File not specified.');
        return;
    }
    $a = sanitize_url($a);
    if (!file_exists2($a)) {
        die('Error: File not found. $file=' . $a);
        return;
    }
    if (headers_sent()) {
        die('Error: Headers already sent.');
        return;
    }
    if (ini_get('zlib.output_compression')) {
        ini_set('zlib.output_compression', 'Off');
    }
    header('Pragma: public');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Cache-Control: private', false);
    $b = strtolower(pathinfo($a, PATHINFO_EXTENSION));
    switch ($b) {
        case 'jpg':
        case 'jpe':
        case 'jpeg':
            $c = 'image/jpeg';
            break;
        case 'gif':
            $c = 'image/gif';
            break;
        case 'png':
            $c = 'image/png';
            break;
        case 'bmp':
            $c = 'image/bmp';
            break;
        case 'tif':
        case 'tiff':
            $c = 'image/tiff';
            break;
        case 'webp':
            $c = 'image/webp';
            break;
        default:
            die('Error: Unsupported file type. $ext=' . $b);
            return;
    }
    header('Content-Description: File Transfer');
    header('Content-Transfer-Encoding: binary');
    header('Content-Type: ' . $c);
    header('Content-Disposition: attachment; filename="' . unsanitized_basename($a) . '"');
    header('Content-Length: ' . filesize2($a));
    ob_clean();
    flush();
    readfile($a);
}
开发者ID:anaved,项目名称:wordpress-tinkering,代码行数:58,代码来源:download.min.php

示例6: get_link

 public static function get_link(BlockInstance $instance)
 {
     safe_require('module', 'multirecipientnotification');
     if (PluginModuleMultirecipientnotification::is_active()) {
         $data = get_config('wwwroot') . 'module/multirecipientnotification/inbox.php';
     } else {
         $data = get_config('wwwroot') . 'account/activity/index.php';
     }
     return sanitize_url($data);
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:10,代码来源:lib.php

示例7: column_link

 function column_link($atts, $content = null)
 {
     $args = shortcode_atts(array('link' => '#'), $atts);
     $link = sanitize_url($args["link"]);
     $out = '';
     $out .= "<a href=\"{$link}\" class=\"column-link \">";
     $out .= do_shortcode($content);
     $out .= "</a>";
     return $out;
 }
开发者ID:apennell,项目名称:static_portfolio,代码行数:10,代码来源:Pure_ML.php

示例8: wpcf7_admin_url

function wpcf7_admin_url($file, $query = array())
{
    $file = trim($file, ' /');
    if ('admin/' != substr($file, 0, 6)) {
        $file = 'admin/' . $file;
    }
    $path = 'admin.php';
    $path .= '?page=' . WPCF7_PLUGIN_NAME . '/' . $file;
    if ($query = build_query($query)) {
        $path .= '&' . $query;
    }
    $url = admin_url($path);
    return sanitize_url($url);
}
开发者ID:aliciente,项目名称:portfolio,代码行数:14,代码来源:settings.php

示例9: upload

function upload($file, $path = 'uploads/', $all = false)
{
    $uniq_id = substr(strrev(uniqid()), 0, 4);
    $parts = explode('.', $file->getClientOriginalName());
    $ext = array_pop($parts);
    $file_name = $uniq_id . '_' . sanitize_url(implode('.', $parts)) . '.' . $ext;
    if (file_exists($path . $file_name)) {
        $parts = explode('.', $file_name);
        $ext = array_pop($parts);
        $parts[count($parts) - 1] .= rand(0, 99);
        $parts[] = $ext;
        $file_name = implode('.', $parts);
    }
    if ($all == false) {
        return $file->move($path, $file_name)->getFileName();
    } else {
        return $file->move($path, $file_name);
    }
}
开发者ID:davinder17s,项目名称:turbo,代码行数:19,代码来源:url.php

示例10: get_link

 public static function get_link(BlockInstance $instance)
 {
     $data = get_config('wwwroot') . 'blocktype/wall/wall.php?id=' . $instance->get('id');
     return sanitize_url($data);
 }
开发者ID:agwells,项目名称:Mahara-1,代码行数:5,代码来源:lib.php

示例11: make_feed_image_tag

 /**
  * Returns the HTML for the feed icon (not the little RSS one, but the
  * actual logo associated with the feed)
  */
 private static function make_feed_image_tag($image)
 {
     // Depending on whether they're using RSS or ATOM, the image may
     // be an array of properties about the feed image, or it may be
     // just the URL of the image.
     if (is_array($image)) {
         if (isset($image['url'])) {
             $imageurl = $image['url'];
         } else {
             $imageurl = '';
         }
     } else {
         $imageurl = $image;
         $image = array('url' => $imageurl);
     }
     // Make sure it's a valid URL.
     $imageurl = sanitize_url($imageurl);
     if (!$imageurl) {
         return '';
     }
     // If we're in HTTPS, make sure the image URL is not HTTP
     if (is_https()) {
         $imageurl = preg_replace('#^http://#', 'https://', $imageurl);
     }
     $result = "<img src=\"{$imageurl}\"";
     // The specification says there should be a title, but it's not always present.
     if (!empty($image['title'])) {
         $result .= ' alt="' . htmlentities($image['title']) . '"';
     }
     // There may be height & weight attributes
     foreach (array('height', 'width') as $attribute) {
         if (isset($image[$attribute]) && (int) $image[$attribute]) {
             $result .= " {$attribute}=\"" . (int) $image[$attribute] . '"';
         }
     }
     $result .= " />";
     // A "link" tag indicates that the image should be a clickable link to another URL
     if (!empty($image['link'])) {
         $link = sanitize_url($image['link']);
         if ($link) {
             $result = "<a href=\"{$link}\" target=\"_blank\">{$result}</a>";
         }
     }
     return $result;
 }
开发者ID:vohung96,项目名称:mahara,代码行数:49,代码来源:lib.php

示例12: array

if (preg_match('~(\\d+)(.*)~', $height, $match)) {
    $height = $match[1];
    $height_unit = $match[2];
}
$skins = $c->getSkins($c->getSkinPath());
$current_skin = $c->getSkin($config);
$settings = $c->getAdditionalSettings();
$plugins = $c->getAdditionalPlugins();
$filemanager = $c->getFilemanager();
$toolbars = $c->getToolbars();
$preview = NULL;
$plugins_checked = array();
$filemanager_checked = array();
$enable_htmlpurifier = isset($config['enable_htmlpurifier']) ? $config['enable_htmlpurifier'] : false;
if (file_exists(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . WYSIWYG_EDITOR . '/images/' . $current_skin . '.png'))) {
    $preview = '<img src="' . sanitize_url(CAT_URL . '/modules/' . WYSIWYG_EDITOR . '/images/' . $current_skin . '.png') . '" alt="' . $current_skin . '" title="' . $current_skin . '" />';
}
// something to save?
$job = $val->sanitizePost('job');
if ($job && $job == "save") {
    $new_width = $new_height = $new_skin = $new_toolbar = $new_plugins = $new_fm = NULL;
    // validate width and height
    foreach (array('width', 'height') as $key) {
        if ($val->sanitizePost($key)) {
            if (!is_numeric($val->sanitizePost($key))) {
                $errors[$key] = $backend->lang()->translate('Not numeric!');
                continue;
            }
            if ($val->sanitizePost($key . '_unit') && in_array($val->sanitizePost($key . '_unit'), array('em', 'px', '%'))) {
                if ($val->sanitizePost($key . '_unit') == '%' && $val->sanitizePost($key) > 100) {
                    $errors[$key] = $backend->lang()->translate('Invalid ' . $key . ': {{width}}% > 100%!', array('width' => $val->sanitizePost($key)));
开发者ID:ircoco,项目名称:BlackCatCMS,代码行数:31,代码来源:tool.php

示例13: meditor_sanitize_related

 public function meditor_sanitize_related($val)
 {
     if (is_numeric($val) && get_permalink(absint($val))) {
         return absint($val);
     }
     if ($url = sanitize_url($val)) {
         if ($post_id = url_to_postid($url)) {
             return $post_id;
         } else {
             return $url;
         }
     }
     return FALSE;
 }
开发者ID:nrporter,项目名称:scriblio,代码行数:14,代码来源:compatibility.php

示例14: edit_user

/**
 * Edit user settings based on contents of $_POST
 *
 * Used on user-edit.php and profile.php to manage and process user options, passwords etc.
 *
 * @since 2.0
 *
 * @param int $user_id Optional. User ID.
 * @return int user id of the updated user
 */
function edit_user($user_id = 0)
{
    global $current_user, $wp_roles, $wpdb;
    if ($user_id != 0) {
        $update = true;
        $user->ID = (int) $user_id;
        $userdata = get_userdata($user_id);
        $user->user_login = $wpdb->escape($userdata->user_login);
    } else {
        $update = false;
        $user = '';
    }
    if (!$update && isset($_POST['user_login'])) {
        $user->user_login = sanitize_user($_POST['user_login'], true);
    }
    $pass1 = $pass2 = '';
    if (isset($_POST['pass1'])) {
        $pass1 = $_POST['pass1'];
    }
    if (isset($_POST['pass2'])) {
        $pass2 = $_POST['pass2'];
    }
    if (isset($_POST['role']) && current_user_can('edit_users')) {
        $new_role = sanitize_text_field($_POST['role']);
        // Don't let anyone with 'edit_users' (admins) edit their own role to something without it.
        if ($user_id != $current_user->id || $wp_roles->role_objects[$new_role]->has_cap('edit_users')) {
            $user->role = $new_role;
        }
        // If the new role isn't editable by the logged-in user die with error
        $editable_roles = get_editable_roles();
        if (!$editable_roles[$new_role]) {
            wp_die(__('You can&#8217;t give users that role.'));
        }
    }
    if (isset($_POST['email'])) {
        $user->user_email = sanitize_text_field($_POST['email']);
    }
    if (isset($_POST['url'])) {
        if (empty($_POST['url']) || $_POST['url'] == 'http://') {
            $user->user_url = '';
        } else {
            $user->user_url = sanitize_url($_POST['url']);
            $user->user_url = preg_match('/^(https?|ftps?|mailto|news|irc|gopher|nntp|feed|telnet):/is', $user->user_url) ? $user->user_url : 'http://' . $user->user_url;
        }
    }
    if (isset($_POST['first_name'])) {
        $user->first_name = sanitize_text_field($_POST['first_name']);
    }
    if (isset($_POST['last_name'])) {
        $user->last_name = sanitize_text_field($_POST['last_name']);
    }
    if (isset($_POST['nickname'])) {
        $user->nickname = sanitize_text_field($_POST['nickname']);
    }
    if (isset($_POST['display_name'])) {
        $user->display_name = sanitize_text_field($_POST['display_name']);
    }
    if (isset($_POST['description'])) {
        $user->description = trim($_POST['description']);
    }
    foreach (_wp_get_user_contactmethods() as $method => $name) {
        if (isset($_POST[$method])) {
            $user->{$method} = sanitize_text_field($_POST[$method]);
        }
    }
    if ($update) {
        $user->rich_editing = isset($_POST['rich_editing']) && 'false' == $_POST['rich_editing'] ? 'false' : 'true';
        $user->admin_color = isset($_POST['admin_color']) ? sanitize_text_field($_POST['admin_color']) : 'fresh';
    }
    $user->comment_shortcuts = isset($_POST['comment_shortcuts']) && 'true' == $_POST['comment_shortcuts'] ? 'true' : '';
    $user->use_ssl = 0;
    if (!empty($_POST['use_ssl'])) {
        $user->use_ssl = 1;
    }
    $errors = new WP_Error();
    /* checking that username has been typed */
    if ($user->user_login == '') {
        $errors->add('user_login', __('<strong>ERROR</strong>: Please enter a username.'));
    }
    /* checking the password has been typed twice */
    do_action_ref_array('check_passwords', array($user->user_login, &$pass1, &$pass2));
    if ($update) {
        if (empty($pass1) && !empty($pass2)) {
            $errors->add('pass', __('<strong>ERROR</strong>: You entered your new password only once.'), array('form-field' => 'pass1'));
        } elseif (!empty($pass1) && empty($pass2)) {
            $errors->add('pass', __('<strong>ERROR</strong>: You entered your new password only once.'), array('form-field' => 'pass2'));
        }
    } else {
        if (empty($pass1)) {
            $errors->add('pass', __('<strong>ERROR</strong>: Please enter your password.'), array('form-field' => 'pass1'));
//.........这里部分代码省略.........
开发者ID:ericandrewlewis,项目名称:wordpress-mu,代码行数:101,代码来源:user.php

示例15: site_menu

/**
 * Site-level sidebar menu (list of links)
 * There is no admin files table yet so just get the urls.
 * @return $menu a data structure containing the site menu
 */
function site_menu()
{
    global $USER;
    $menu = array();
    if ($menuitems = get_records_array('site_menu', 'public', (int) (!$USER->is_logged_in()), 'displayorder')) {
        foreach ($menuitems as $i) {
            if ($i->url) {
                $safeurl = sanitize_url($i->url);
                if ($safeurl != '') {
                    $menu[] = array('name' => $i->title, 'link' => $safeurl);
                }
            } else {
                if ($i->file) {
                    $menu[] = array('name' => $i->title, 'link' => get_config('wwwroot') . 'artefact/file/download.php?file=' . $i->file);
                }
            }
        }
    }
    return $menu;
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:25,代码来源:web.php


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