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


PHP sanitizeForUrl函数代码示例

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


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

示例1: section_save

function section_save()
{
    global $txpcfg, $app_mode;
    extract(doSlash(psa(array('page', 'css', 'old_name'))));
    extract(psa(array('name', 'title')));
    $prequel = '';
    $sequel = '';
    if (empty($title)) {
        $title = $name;
    }
    // Prevent non url chars on section names
    include_once txpath . '/lib/classTextile.php';
    $textile = new Textile();
    $title = doSlash($textile->TextileThis($title, 1));
    $name = doSlash(sanitizeForUrl($name));
    if ($old_name && strtolower($name) != strtolower($old_name)) {
        if (safe_field('name', 'txp_section', "name='{$name}'")) {
            $message = array(gTxt('section_name_already_exists', array('{name}' => $name)), E_ERROR);
            if ($app_mode == 'async') {
                // TODO: Better/themeable popup
                send_script_response('window.alert("' . escape_js(strip_tags(gTxt('section_name_already_exists', array('{name}' => $name)))) . '")');
            } else {
                sec_section_list($message);
                return;
            }
        }
    }
    if ($name == 'default') {
        safe_update('txp_section', "page = '{$page}', css = '{$css}'", "name = 'default'");
        update_lastmod();
    } else {
        extract(array_map('assert_int', psa(array('is_default', 'on_frontpage', 'in_rss', 'searchable'))));
        // note this means 'selected by default' not 'default page'
        if ($is_default) {
            safe_update("txp_section", "is_default = 0", "name != '{$old_name}'");
            // switch off $is_default for all sections in async app_mode
            if ($app_mode == 'async') {
                $prequel = '$("input[name=\\"is_default\\"][value=\\"1\\"]").attr("checked", false);' . '$("input[name=\\"is_default\\"][value=\\"0\\"]").attr("checked", true);';
            }
        }
        safe_update('txp_section', "\n\t\t\t\tname         = '{$name}',\n\t\t\t\ttitle        = '{$title}',\n\t\t\t\tpage         = '{$page}',\n\t\t\t\tcss          = '{$css}',\n\t\t\t\tis_default   = {$is_default},\n\t\t\t\ton_frontpage = {$on_frontpage},\n\t\t\t\tin_rss       = {$in_rss},\n\t\t\t\tsearchable   = {$searchable}\n\t\t\t", "name = '{$old_name}'");
        safe_update('textpattern', "Section = '{$name}'", "Section = '{$old_name}'");
        update_lastmod();
    }
    $message = gTxt('section_updated', array('{name}' => $name));
    if ($app_mode == 'async') {
        // Caveat: Use unslashed params for DTO
        $s = psa(array('name', 'title', 'page', 'css')) + compact('is_default', 'on_frontpage', 'in_rss', 'searchable');
        $s = section_detail_partial($s);
        send_script_response($prequel . '$("#section-form-' . $name . '").replaceWith("' . escape_js($s) . '");' . $sequel);
    } else {
        sec_section_list($message);
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:54,代码来源:txp_section.php

示例2: section_save

function section_save()
{
    global $txpcfg;
    extract(doSlash(psa(array('page', 'css', 'old_name'))));
    extract(psa(array('name', 'title')));
    if (empty($title)) {
        $title = $name;
    }
    // Prevent non url chars on section names
    include_once txpath . '/lib/classTextile.php';
    $textile = new Textile();
    $title = doSlash($textile->TextileThis($title, 1));
    $name = doSlash(sanitizeForUrl($name));
    if ($old_name && strtolower($name) != strtolower($old_name)) {
        if (safe_field('name', 'txp_section', "name='{$name}'")) {
            $message = gTxt('section_name_already_exists', array('{name}' => $name));
            sec_section_list($message);
            return;
        }
    }
    if ($name == 'default') {
        safe_update('txp_section', "page = '{$page}', css = '{$css}'", "name = 'default'");
        update_lastmod();
    } else {
        extract(array_map('assert_int', psa(array('is_default', 'on_frontpage', 'in_rss', 'searchable'))));
        // note this means 'selected by default' not 'default page'
        if ($is_default) {
            safe_update("txp_section", "is_default = 0", "name != '{$old_name}'");
        }
        safe_update('txp_section', "\n\t\t\t\tname         = '{$name}',\n\t\t\t\ttitle        = '{$title}',\n\t\t\t\tpage         = '{$page}',\n\t\t\t\tcss          = '{$css}',\n\t\t\t\tis_default   = {$is_default},\n\t\t\t\ton_frontpage = {$on_frontpage},\n\t\t\t\tin_rss       = {$in_rss},\n\t\t\t\tsearchable   = {$searchable}\n\t\t\t", "name = '{$old_name}'");
        safe_update('textpattern', "Section = '{$name}'", "Section = '{$old_name}'");
        update_lastmod();
    }
    $message = gTxt('section_updated', array('{name}' => $name));
    sec_section_list($message);
}
开发者ID:evanfarrar,项目名称:opensprints.org,代码行数:36,代码来源:txp_section.php

示例3: stripSpace

function stripSpace($text, $force = 0)
{
    global $prefs;
    if ($force or !empty($prefs['attach_titles_to_permalinks'])) {
        $text = trim(sanitizeForUrl($text), '-');
        if ($prefs['permalink_title_format']) {
            return function_exists('mb_strtolower') ? mb_strtolower($text, 'UTF-8') : strtolower($text);
        } else {
            return str_replace('-', '', $text);
        }
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:12,代码来源:txplib_misc.php

示例4: section_save

function section_save()
{
    global $app_mode;
    $in = array_map('assert_string', psa(array('name', 'title', 'old_name', 'section_page', 'css')));
    if (empty($in['title'])) {
        $in['title'] = $in['name'];
    }
    // Prevent non url chars on section names
    include_once txpath . '/lib/classTextile.php';
    $textile = new Textile();
    $in['title'] = $textile->TextileThis($in['title'], 1);
    $in['name'] = strtolower(sanitizeForUrl($in['name']));
    extract($in);
    $in = doSlash($in);
    extract($in, EXTR_PREFIX_ALL, 'safe');
    if ($name != strtolower($old_name)) {
        if (safe_field('name', 'txp_section', "name='{$safe_name}'")) {
            // Invalid input. Halt all further processing (e.g. plugin event handlers).
            $message = array(gTxt('section_name_already_exists', array('{name}' => $name)), E_ERROR);
            //				modal_halt($message);
            sec_section_list($message);
            return;
        }
    }
    $ok = false;
    if ($name == 'default') {
        $ok = safe_update('txp_section', "page = '{$safe_section_page}', css = '{$safe_css}'", "name = 'default'");
    } else {
        if ($name) {
            extract(array_map('assert_int', psa(array('on_frontpage', 'in_rss', 'searchable'))));
            if ($safe_old_name) {
                $ok = safe_update('txp_section', "\n\t\t\t\t\tname         = '{$safe_name}',\n\t\t\t\t\ttitle        = '{$safe_title}',\n\t\t\t\t\tpage         = '{$safe_section_page}',\n\t\t\t\t\tcss          = '{$safe_css}',\n\t\t\t\t\ton_frontpage = {$on_frontpage},\n\t\t\t\t\tin_rss       = {$in_rss},\n\t\t\t\t\tsearchable   = {$searchable}\n\t\t\t\t\t", "name = '{$safe_old_name}'");
                // Manually maintain referential integrity
                if ($ok) {
                    $ok = safe_update('textpattern', "Section = '{$safe_name}'", "Section = '{$safe_old_name}'");
                }
            } else {
                $ok = safe_insert('txp_section', "\n\t\t\t\t\tname         = '{$safe_name}',\n\t\t\t\t\ttitle        = '{$safe_title}',\n\t\t\t\t\tpage         = '{$safe_section_page}',\n\t\t\t\t\tcss          = '{$safe_css}',\n\t\t\t\t\ton_frontpage = {$on_frontpage},\n\t\t\t\t\tin_rss       = {$in_rss},\n\t\t\t\t\tsearchable   = {$searchable}");
            }
        }
    }
    if ($ok) {
        update_lastmod();
    }
    if ($ok) {
        sec_section_list(gTxt($safe_old_name ? 'section_updated' : 'section_created', array('{name}' => $name)));
    } else {
        sec_section_list(array(gTxt('section_save_failed'), E_ERROR));
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:50,代码来源:txp_section.php

示例5: section_save

/**
 * Saves a section.
 */
function section_save()
{
    $in = array_map('assert_string', psa(array('name', 'title', 'description', 'old_name', 'section_page', 'css')));
    if (empty($in['title'])) {
        $in['title'] = $in['name'];
    }
    // Prevent non-URL characters on section names.
    $in['name'] = strtolower(sanitizeForUrl($in['name']));
    extract($in);
    $in = doSlash($in);
    extract($in, EXTR_PREFIX_ALL, 'safe');
    if ($name != strtolower($old_name)) {
        if (safe_field('name', 'txp_section', "name='{$safe_name}'")) {
            // Invalid input. Halt all further processing (e.g. plugin event
            // handlers).
            $message = array(gTxt('section_name_already_exists', array('{name}' => $name)), E_ERROR);
            //            modal_halt($message);
            sec_section_list($message);
            return;
        }
    }
    $ok = false;
    if ($name == 'default') {
        $ok = safe_update('txp_section', "page = '{$safe_section_page}', css = '{$safe_css}', description = '{$safe_description}'", "name = 'default'");
    } elseif ($name) {
        extract(array_map('assert_int', psa(array('on_frontpage', 'in_rss', 'searchable'))));
        if ($safe_old_name) {
            $ok = safe_update('txp_section', "\n                name         = '{$safe_name}',\n                title        = '{$safe_title}',\n                page         = '{$safe_section_page}',\n                css          = '{$safe_css}',\n                description  = '{$safe_description}',\n                on_frontpage = {$on_frontpage},\n                in_rss       = {$in_rss},\n                searchable   = {$searchable}\n                ", "name = '{$safe_old_name}'");
            // Manually maintain referential integrity.
            if ($ok) {
                $ok = safe_update('textpattern', "Section = '{$safe_name}'", "Section = '{$safe_old_name}'");
            }
        } else {
            $ok = safe_insert('txp_section', "\n                name         = '{$safe_name}',\n                title        = '{$safe_title}',\n                page         = '{$safe_section_page}',\n                css          = '{$safe_css}',\n                description  = '{$safe_description}',\n                on_frontpage = {$on_frontpage},\n                in_rss       = {$in_rss},\n                searchable   = {$searchable}");
        }
    }
    if ($ok) {
        update_lastmod('section_saved', compact('name', 'title', 'page', 'css', 'description', 'on_frontpage', 'in_rss', 'searchable'));
    }
    if ($ok) {
        sec_section_list(gTxt($safe_old_name ? 'section_updated' : 'section_created', array('{name}' => $name)));
    } else {
        sec_section_list(array(gTxt('section_save_failed'), E_ERROR));
    }
}
开发者ID:hcgtv,项目名称:textpattern,代码行数:48,代码来源:txp_section.php

示例6: cat_event_category_save

function cat_event_category_save($event, $table_name)
{
    global $txpcfg;
    extract(doSlash(psa(array('id', 'name', 'old_name', 'parent', 'title'))));
    $id = assert_int($id);
    $name = sanitizeForUrl($name);
    // make sure the name is valid
    if (!$name) {
        $message = array(gTxt($event . '_category_invalid', array('{name}' => $name)), E_ERROR);
        return cat_category_list($message);
    }
    // don't allow rename to clobber an existing category
    $existing_id = safe_field('id', 'txp_category', "name = '{$name}' and type = '{$event}'");
    if ($existing_id and $existing_id != $id) {
        $message = array(gTxt($event . '_category_already_exists', array('{name}' => $name)), E_ERROR);
        return cat_category_list($message);
    }
    $parent = $parent ? $parent : 'root';
    if (safe_update('txp_category', "name = '{$name}', parent = '{$parent}', title = '{$title}'", "id = {$id}")) {
        safe_update('txp_category', "parent = '{$name}'", "parent = '{$old_name}'");
    }
    rebuild_tree_full($event);
    if ($event == 'article') {
        safe_update('textpattern', "Category1 = '{$name}'", "Category1 = '{$old_name}'");
        safe_update('textpattern', "Category2 = '{$name}'", "Category2 = '{$old_name}'");
    } else {
        safe_update($table_name, "category = '{$name}'", "category = '{$old_name}'");
    }
    $message = gTxt($event . '_category_updated', array('{name}' => doStrip($name)));
    cat_category_list($message);
}
开发者ID:psic,项目名称:websites,代码行数:31,代码来源:txp_category.php

示例7: stripSpace

/**
 * Sanitises a string for use in an article's URL title.
 *
 * @param   string $text  The title or an URL
 * @param   bool   $force Force sanitisation
 * @return  string|null
 * @package URL
 */
function stripSpace($text, $force = false)
{
    if ($force || get_pref('attach_titles_to_permalinks')) {
        $text = trim(sanitizeForUrl($text), '-');
        if (get_pref('permalink_title_format')) {
            return function_exists('mb_strtolower') ? mb_strtolower($text, 'UTF-8') : strtolower($text);
        } else {
            return str_replace('-', '', $text);
        }
    }
}
开发者ID:hcgtv,项目名称:textpattern,代码行数:19,代码来源:txplib_misc.php

示例8: stripSpace

function stripSpace($text, $force = 0)
{
    global $prefs;
    if ($force or !empty($prefs['attach_titles_to_permalinks'])) {
        $text = sanitizeForUrl($text);
        if ($prefs['permalink_title_format']) {
            return strtolower($text);
        } else {
            return str_replace('-', '', $text);
        }
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:12,代码来源:txplib_misc.php

示例9: cat_event_category_save

/**
 * Saves a category from HTTP POST data.
 *
 * @param string $event Type of category
 * @param string $table Affected database table
 */
function cat_event_category_save($event, $table_name)
{
    extract(doSlash(array_map('assert_string', psa(array('id', 'name', 'description', 'old_name', 'parent', 'title')))));
    $id = assert_int($id);
    $rawname = $name;
    $name = sanitizeForUrl($rawname);
    // Make sure the name is valid.
    if (!$name) {
        $message = array(gTxt($event . '_category_invalid', array('{name}' => $rawname)), E_ERROR);
        return cat_event_category_edit($event, $message);
    }
    // Don't allow rename to clobber an existing category.
    $existing_id = safe_field("id", 'txp_category', "name = '{$name}' AND type = '{$event}'");
    if ($existing_id and $existing_id != $id) {
        $message = array(gTxt($event . '_category_already_exists', array('{name}' => $name)), E_ERROR);
        return cat_event_category_edit($event, $message);
    }
    // TODO: validate parent?
    $parent = $parent ? $parent : 'root';
    $message = array(gTxt('category_save_failed'), E_ERROR);
    if (safe_update('txp_category', "name = '{$name}', parent = '{$parent}', title = '{$title}', description = '{$description}'", "id = {$id}") && safe_update('txp_category', "parent = '{$name}'", "parent = '{$old_name}' AND type = '{$event}'")) {
        rebuild_tree_full($event);
        if ($event == 'article') {
            if (safe_update('textpattern', "Category1 = '{$name}'", "Category1 = '{$old_name}'") && safe_update('textpattern', "Category2 = '{$name}'", "Category2 = '{$old_name}'")) {
                $message = gTxt($event . '_category_updated', array('{name}' => doStrip($name)));
            }
        } else {
            if (safe_update($table_name, "category = '{$name}'", "category = '{$old_name}'")) {
                $message = gTxt($event . '_category_updated', array('{name}' => doStrip($name)));
            }
        }
    }
    cat_category_list($message);
}
开发者ID:ClaireBrione,项目名称:textpattern,代码行数:40,代码来源:txp_category.php

示例10: sed_cleaner_addsection_action

function sed_cleaner_addsection_action($args, $debug)
{
    $section_title = doSlash(array_shift($args));
    $section_name = strtolower(sanitizeForUrl($section_title));
    if (!empty($args)) {
        $page = doSlash(array_shift($args));
    } else {
        $page = $default['page'];
    }
    if (!empty($args)) {
        $css = doSlash(array_shift($args));
    } else {
        $css = $default['css'];
    }
    if (!empty($args)) {
        $rss = doSlash(array_shift($args));
    } else {
        $rss = 0;
    }
    if (!empty($args)) {
        $frontpage = doSlash(array_shift($args));
    } else {
        $frontpage = 0;
    }
    if (!empty($args)) {
        $searchable = doSlash(array_shift($args));
    } else {
        $searchable = 0;
    }
    $default = doSlash(safe_row('page, css', 'txp_section', "name = 'default'"));
    if ($debug) {
        echo " attempting to add a section entitled '{$section_title}'.";
    }
    safe_insert('txp_section', "`name` = '{$section_name}',\n\t\t`title` = '{$section_title}',\n\t\t`page`  = '{$page}',\n\t\t`css`   = '{$css}',\n\t\t`is_default` = 0,\n\t\t`in_rss` = {$rss},\n\t\t`on_frontpage` = {$frontpage},\n\t\t`searchable` = {$searchable}", $debug);
}
开发者ID:netcarver,项目名称:sed_cleaner,代码行数:35,代码来源:sed_cleaner.php

示例11: create_category

 /**
  * Create category
  * @param  string $title The title used for the category
  * @return string        name field of the created category
  */
 private function create_category($title)
 {
     $name = strtolower(sanitizeForUrl($title));
     if (!$name) {
         return '';
     }
     $exists = safe_field('name', 'txp_category', "name = '" . doSlash($name) . "' and type = 'image'");
     if ($exists) {
         return $name;
     }
     $q = safe_insert('txp_category', "name = '" . doSlash($name) . "', title = '" . doSlash($title) . "', type = 'image', parent = 'root'");
     if ($q) {
         rebuild_tree_full('image');
         return $name;
     }
     return '';
 }
开发者ID:jbach,项目名称:jbx_multiple_image_upload,代码行数:22,代码来源:jbx_multiple_image_upload.php

示例12: edit_post

 function edit_post()
 {
     extract(doSlash(psa(array('name', 'old_name', 'title', 'type'))));
     $id = $this->psi('id');
     $parent = $this->ps('parent');
     if (!$parent) {
         $parent = tree_root_id('txp_category', "type='" . doSlash($type) . "'");
     }
     $name = sanitizeForUrl($name);
     // make sure the name is valid
     if (!$name) {
         $this->_error(gTxt($type . '_category_invalid', array('{name}' => $name)));
         return;
     }
     // don't allow rename to clobber an existing category
     if (safe_field('id', 'txp_category', "name = '{$name}' and type = '{$type}' and id != {$id}")) {
         $this->_error(gTxt($type . '_category_already_exists', array('{name}' => $name)));
         return;
     }
     safe_update('txp_category', "name = '{$name}', parent = '{$parent}', title = '{$title}'", "id = {$id}");
     tree_rebuild_full('txp_category', "type='{$type}'");
     if ($type == 'article') {
         safe_update('textpattern', "Category1 = '{$name}'", "Category1 = '{$old_name}'");
         safe_update('textpattern', "Category2 = '{$name}'", "Category2 = '{$old_name}'");
     } elseif ($type == 'link') {
         safe_update('txp_link', "category = '{$name}'", "category = '{$old_name}'");
     } elseif ($type == 'image') {
         safe_update('txp_image', "category = '{$name}'", "category = '{$old_name}'");
     } elseif ($type == 'file') {
         safe_update('txp_file', "category = '{$name}'", "category = '{$old_name}'");
     }
     // show a success message and switch back to the list view
     $this->_message(gTxt($type . '_category_updated', array('{name}' => doStrip($name))));
     $this->_set_view('list');
 }
开发者ID:bgarrels,项目名称:textpattern,代码行数:35,代码来源:txp_category.php

示例13: build_options

function build_options($table, $valueCol, $displayCol, $selected = '', $where = '1', $order_by = '')
{
    $returnData = '';
    $datas = safe_rows("*", $table, $where . " " . $order_by);
    foreach ($datas as $data) {
        if ($data[$valueCol] == sanitizeForUrl($selected)) {
            $selectOption = " selected=\"selected\"";
        } else {
            $selectOption = "";
        }
        $returnData .= "<option value=\"" . $data[$valueCol] . "\"{$selectOption}>" . $data[$displayCol] . "</option>" . n;
    }
    return $returnData;
}
开发者ID:duongcuong96,项目名称:textcommerce,代码行数:14,代码来源:tc_core_library.php

示例14: cnk_section_create

function cnk_section_create()
{
    // get name
    $name = sanitizeForUrl(ps('name'));
    // if new section was created, add to node to default
    $chk = safe_field('name', 'txp_section', "name='" . $name . "' and lft is null");
    if ($chk) {
        cnk_st_add_node($name, 'default');
    }
}
开发者ID:netcarver,项目名称:cnk_section_tree,代码行数:10,代码来源:cnk_section_tree.php

示例15: _l10n_post_sectionsave

function _l10n_post_sectionsave($event, $step)
{
    //echo br , "_l10n_post_sectionsave( $event , $step )";
    $old_name = doSlash(ps('old_name'));
    $name = doSlash(sanitizeForUrl(ps('name')));
    if ($name !== $old_name) {
        $langs = MLPLanguageHandler::get_site_langs();
        foreach ($langs as $lang) {
            $table = _l10n_make_textpattern_name(array('long' => $lang));
            @safe_update($table, "Section = '{$name}'", "Section = '{$old_name}'");
        }
    }
}
开发者ID:netcarver,项目名称:mlp_pack,代码行数:13,代码来源:l10n_admin.php


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