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


PHP awp_ver函数代码示例

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


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

示例1: get_page_ancestors

 function get_page_ancestors()
 {
     $ancestors = get_option("scoper_page_ancestors");
     if (is_array($ancestors)) {
         return $ancestors;
     }
     $ancestors = array();
     global $wpdb;
     if (awp_ver('3.0')) {
         $post_types = get_post_types(array('hierarchical' => true, 'public' => true));
         $where = "WHERE post_type IN ('" . implode("','", $post_types) . "') AND post_status != 'auto-draft'";
     } else {
         $where = "WHERE post_type != 'revision' AND post_type != 'post' AND post_status != 'auto-draft'";
     }
     if ($pages = scoper_get_results("SELECT ID, post_parent FROM {$wpdb->posts} {$where}")) {
         $parents = array();
         foreach ($pages as $page) {
             if ($page->post_parent) {
                 $parents[$page->ID] = $page->post_parent;
             }
         }
         foreach ($pages as $page) {
             $ancestors[$page->ID] = ScoperAncestry::_walk_ancestors($page->ID, array(), $parents);
             if (empty($ancestors[$page->ID])) {
                 unset($ancestors[$page->ID]);
             }
         }
         update_option("scoper_page_ancestors", $ancestors);
     }
     return $ancestors;
 }
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:31,代码来源:ancestry_lib_rs.php

示例2: all_agents_checklist

 function all_agents_checklist($role_bases, $agents, $args, $class = 'rs-agents')
 {
     if (MULTISITE && scoper_get_site_option('mu_sitewide_groups')) {
         $groups_url = awp_ver('3.1') ? 'network/users.php?page=rs-groups' : 'ms-admin.php?page=rs-groups';
     } else {
         $groups_url = 'admin.php?page=rs-groups';
     }
     $div_style = "class='{$class}' style='padding:0.5em 0 0.5em 0.5em'";
     //if ( in_array(ROLE_BASIS_GROUPS, $role_bases) && $agents[ROLE_BASIS_GROUPS] )
     //	$edit_groups_link = sprintf(_ x('%1$s define user groups%2$s', 'Args are link open, close tags', 'scoper'), "<a href='$groups_url'>", '</a>');
     //else
     //	$edit_groups_link = sprintf(_ x('<strong>Note:</strong> To assign roles to user groups, first %1$s define the group(s)%2$s.', 'Args are link open, close tags', 'scoper'), "<a href='$groups_url'>", '</a>');
     if (in_array(ROLE_BASIS_GROUPS, $role_bases) && $agents[ROLE_BASIS_GROUPS]) {
         $edit_groups_link = sprintf(__('%1$s define user groups%2$s', 'scoper'), "<a href='{$groups_url}'>", '</a>');
     } else {
         $edit_groups_link = sprintf(__('<strong>Note:</strong> To assign roles to user groups, first %1$s define the group(s)%2$s.', 'scoper'), "<a href='{$groups_url}'>", '</a>');
     }
     foreach ($role_bases as $role_basis) {
         echo "<div {$div_style}>";
         ScoperAgentsChecklist::agents_checklist($role_basis, $agents[$role_basis], $role_basis, array(), $args);
         if (ROLE_BASIS_GROUPS == $role_basis) {
             echo $edit_groups_link;
         }
         echo "</div>";
     }
     if (!in_array(ROLE_BASIS_GROUPS, $role_bases)) {
         echo "<div {$div_style}>{$edit_groups_link}</div>";
     }
 }
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:29,代码来源:agents_checklist_rs.php

示例3: agp_return_file

function agp_return_file($file_path, $attachment_id = 0)
{
    require_once dirname(__FILE__) . '/uploads_rs.php';
    $uploads = scoper_get_upload_info();
    if (false === strpos($file_path, $uploads['basedir'])) {
        $file_path = untrailingslashit($uploads['basedir']) . "/{$file_path}";
    }
    $file_url = str_replace(untrailingslashit($uploads['basedir']), untrailingslashit($uploads['baseurl']), $file_path);
    //rs_errlog( "agp_return_file: $file_path" );
    if (!$attachment_id) {
        global $wpdb;
        // we've already confirmed that this user can read the file; if it is attached to more than one post any corresponding file key will do
        // Resized copies have -NNNxNNN suffix, but the base filename is stored as attachment.  Strip the suffix out for db query.
        $orig_file_url = preg_replace("/-[0-9]{2,4}x[0-9]{2,4}./", '.', $file_url);
        //rs_errlog( "orig_file_url: $orig_file_url" );
        if (!($attachment_id = scoper_get_var("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid = '{$orig_file_url}' AND post_parent > 0 LIMIT 1"))) {
            return;
        }
    }
    if (!($key = get_post_meta($attachment_id, '_rs_file_key'))) {
        // The key was lost from DB, so regenerate it (and files / uploads .htaccess)
        require_once dirname(__FILE__) . '/rewrite-rules_rs.php';
        ScoperRewrite::resync_file_rules();
        // If the key is still not available, fail out to avoid recursion
        if (!($key = get_post_meta($attachment_id, '_rs_file_key'))) {
            exit(0);
        }
    } elseif (strpos($_SERVER['REQUEST_URI'], 'rs_file_key')) {
        // Apparantly, the .htaccess rules contain an entry for this file, but with invalid file key.  URL with this valid key already passed through RewriteRules.
        // Regenerate .htaccess file in uploads folder, but don't risk recursion by redirecting again.  Note that Firefox browser cache may need to be cleared following this error.
        $last_resync = get_option('scoper_last_htaccess_resync');
        if (!$last_resync || time() - $last_resync > 3600) {
            // prevent abuse (mismatched .htaccess keys should not be a frequent occurance)
            update_option('scoper_last_htaccess_resync', time());
            require_once dirname(__FILE__) . '/rewrite-rules_rs.php';
            ScoperRewrite::resync_file_rules();
        }
        exit(0);
        // If htaccess rewrite was instantaneous, we could just continue without this exit.  But settle for the one-time image access failure to avoid a redirect loop on delayed file update.
    }
    if (is_array($key)) {
        $key = reset($key);
    }
    if (IS_MU_RS && (!awp_ver('3.5') || get_site_option('ms_files_rewriting'))) {
        $basedir = parse_url($uploads['basedir']);
        $baseurl = parse_url($uploads['baseurl']);
        global $base;
        $file_url = str_replace(ABSPATH, $baseurl['scheme'] . '://' . $baseurl['host'] . $base, $file_path);
        $file_url = str_replace('\\', '/', $file_url);
    }
    $redirect = $file_url . "?rs_file_key={$key}";
    //rs_errlog( "redirect: $redirect" );
    usleep(10);
    wp_redirect($redirect);
    exit(0);
}
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:56,代码来源:attachment-filters_rs.php

示例4: available_menu_items_parse_query

 function available_menu_items_parse_query(&$query)
 {
     if (scoper_get_option('admin_nav_menu_filter_items')) {
         $query->query_vars['include'] = '';
         $query->query_vars['post__in'] = '';
         if (!awp_ver('4.0')) {
             $query->query_vars_hash = '';
             $query->query_vars_changed = true;
         }
         $query->query['include'] = '';
         $query->query['post__in'] = '';
         $query->query_vars['suppress_filters'] = false;
         $query->query_vars['post_status'] = '';
         $query->query['suppress_filters'] = false;
         $query->query['post_status'] = '';
     }
 }
开发者ID:btj,项目名称:cscircles-wp-content,代码行数:17,代码来源:filters-nav-menu-query_rs.php

示例5: scoper_mu_users_menu

function scoper_mu_users_menu()
{
    if (!defined('DEFINE_GROUPS_RS') || !scoper_get_site_option('mu_sitewide_groups')) {
        return;
    }
    $cap_req = is_user_administrator_rs() || current_user_can('recommend_group_membership') ? 'read' : 'manage_groups';
    $groups_caption = defined('GROUPS_CAPTION_RS') ? GROUPS_CAPTION_RS : __('Role Groups', 'scoper');
    global $scoper_admin;
    $menu_name = awp_ver('3.1') ? 'users.php' : 'ms-admin.php';
    add_submenu_page($menu_name, $groups_caption, $groups_caption, $cap_req, 'rs-groups', array(&$scoper_admin, 'menu_handler'));
    if (scoper_get_option('mu_sitewide_groups')) {
        global $plugin_page_cr;
        // satisfy WordPress' demand that all admin links be properly defined in menu
        if ('rs-default_groups' == $plugin_page_cr) {
            add_submenu_page($menu_name, __('User Groups', 'scoper'), __('Default Groups', 'scoper'), $cap_req, 'rs-default_groups', array(&$scoper_admin, 'menu_handler'));
        }
        if ('rs-group_members' == $plugin_page_cr) {
            add_submenu_page($menu_name, __('User Groups', 'scoper'), __('Group Members', 'scoper'), $cap_req, 'rs-group_members', array(&$scoper_admin, 'menu_handler'));
        }
    }
}
开发者ID:par-orillonsoft,项目名称:creationOfSociety,代码行数:21,代码来源:admin_lib-mu_rs.php

示例6: defined

    if ('add' == $mode) {
        $group = '';
    }
}
?>

<?php 
if (!$suppress_groups_list) {
    ?>
	<div class="wrap">
	<h2><?php 
    $groups_caption = defined('GROUPS_CAPTION_RS') ? GROUPS_CAPTION_RS : __('Role Groups', 'scoper');
    echo $groups_caption;
    if ($can_manage_all_groups) {
        if (MULTISITE && scoper_get_option('mu_sitewide_groups')) {
            $url = awp_ver('3.1') ? 'users.php' : 'ms-admin.php';
        } else {
            $url = 'admin.php';
        }
        $url_def = "{$url}?page=rs-default_groups'";
        $url_members = "{$url}?page=rs-group_members'";
        echo ' <span style="font-size: 0.6em; font-style: normal">( ';
        echo '<a href="#new">' . __('add new') . '</a>';
        echo " &middot; <a href='{$url_def}'>" . __('set defaults') . '</a>';
        echo " &middot; <a href='{$url_members}'>" . __('browse members') . '</a>';
        echo ' )</span>';
    }
    echo '</h2>';
    if (scoper_get_option('display_hints')) {
        echo '<div class="rs-hint">';
        if (defined('GROUPS_HINT_RS')) {
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:31,代码来源:groups.php

示例7: add_filter

<?php

// filter users list for edit-capable users as a convenience to administrator
add_filter('query', array('ScoperHardwayUsers', 'flt_editable_user_ids'));
// wrapper to users_where filter for "post author" / "page author" dropdown (limit to users who have appropriate caps)
// NOTE: As of 3.0, WP still contains this function but no longer calls it
add_filter('get_editable_authors', array('ScoperHardwayUsers', 'flt_get_editable_authors'), 50, 1);
if (awp_ver('3.1')) {
    add_action('pre_user_query', array('ScoperHardwayUsers', 'act_wp_user_query'), 1);
} else {
    require_once dirname(__FILE__) . '/hardway-users-legacy_rs.php';
}
class ScoperHardwayUsers
{
    // Filter the otherwise unfilterable get_editable_user_ids() result set, which affects the admin UI
    function flt_editable_user_ids($query)
    {
        // Only display users who can read / edit the object in question
        if (strpos($query, "user_id FROM") && strpos($query, "meta_key =")) {
            global $wpdb;
            if (strpos($query, "user_id FROM {$wpdb->usermeta} WHERE meta_key = '{$wpdb->prefix}user_level'")) {
                //log_mem_usage_rs( 'start flt_editable_user_ids()' );
                if (!($post_type = cr_find_post_type())) {
                    return $query;
                }
                if (!($post_type_obj = get_post_type_object($post_type))) {
                    return $query;
                }
                $object_id = scoper_get_object_id();
                // only modify the default authors list if current user can edit_others for the current post/page
                if (current_user_can($post_type_obj->cap->edit_others_posts, $object_id)) {
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:31,代码来源:hardway-users_rs.php

示例8: _rs_determine_selected_menu

function _rs_determine_selected_menu()
{
    $nav_menus = wp_get_nav_menus(array('orderby' => 'name'));
    // Get recently edited nav menu
    $recently_edited = (int) get_user_option('nav_menu_recently_edited');
    if (awp_ver('3.6-dev')) {
        $menu_count = count($nav_menus);
        // Are we on the add new screen?
        $add_new_screen = isset($_GET['menu']) && 0 == $_GET['menu'] ? true : false;
        $locations_screen = isset($_GET['action']) && 'locations' == $_GET['action'] ? true : false;
        // If we have one theme location, and zero menus, we take them right into editing their first menu
        $page_count = wp_count_posts('page');
        $one_theme_location_no_menus = 1 == count(get_registered_nav_menus()) && !$add_new_screen && empty($nav_menus) && !empty($page_count->publish) ? true : false;
        if (empty($recently_edited) && is_nav_menu($nav_menu_selected_id)) {
            $recently_edited = $nav_menu_selected_id;
        }
        // Use $recently_edited if none are selected
        if (empty($nav_menu_selected_id) && !isset($_GET['menu']) && is_nav_menu($recently_edited)) {
            $nav_menu_selected_id = $recently_edited;
        }
        // On deletion of menu, if another menu exists, show it
        if (!$add_new_screen && 0 < $menu_count && isset($_GET['action']) && 'delete' == $_GET['action']) {
            $nav_menu_selected_id = $nav_menus[0]->term_id;
        }
        // Set $nav_menu_selected_id to 0 if no menus
        if ($one_theme_location_no_menus) {
            $nav_menu_selected_id = 0;
        } elseif (empty($nav_menu_selected_id) && !empty($nav_menus) && !$add_new_screen) {
            // if we have no selection yet, and we have menus, set to the first one in the list
            $nav_menu_selected_id = $nav_menus[0]->term_id;
        }
    } else {
        $nav_menu_selected_id = isset($_REQUEST['menu']) ? (int) $_REQUEST['menu'] : 0;
        // If there was no recently edited menu, and $nav_menu_selected_id is a nav menu, update recently edited menu.
        if (!$recently_edited && is_nav_menu($nav_menu_selected_id)) {
            $recently_edited = $nav_menu_selected_id;
            // Else if $nav_menu_selected_id is not a menu and not requesting that we create a new menu, but $recently_edited is a menu, grab that one.
        } elseif (0 == $nav_menu_selected_id && !isset($_REQUEST['menu']) && is_nav_menu($recently_edited)) {
            $nav_menu_selected_id = $recently_edited;
            // Else try to grab the first menu from the menus list
        } elseif (0 == $nav_menu_selected_id && !isset($_REQUEST['menu']) && !empty($nav_menus)) {
            $nav_menu_selected_id = $nav_menus[0]->term_id;
        }
    }
    return $nav_menu_selected_id;
}
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:46,代码来源:filters-admin-nav_menus_rs.php

示例9: define

define('OP_ASSOCIATE_RS', 'associate');
define('OP_EDIT_RS', 'edit');
define('OP_PUBLISH_RS', 'publish');
define('OP_DELETE_RS', 'delete');
define('OP_ADMIN_RS', 'admin');
define('OP_ASSIGN_RS', 'assign');
define('ROLE_BASIS_GROUPS', 'groups');
define('ROLE_BASIS_USER', 'user');
define('ROLE_BASIS_USER_AND_GROUPS', 'ug');
define('ANY_CONTENT_DATE_RS', '');
define('NO_OBJSCOPE_CLAUSE_RS', '');
global $scoper_role_types;
$scoper_role_types = array('rs', 'wp', 'wp_cap');
global $wpdb;
$bail = 0;
if (!awp_ver('3.0')) {
    rs_notice('Sorry, this version of Role Scoper requires WordPress 3.0 or higher.  Please upgrade Wordpress or deactivate Role Scoper.  If you must run WP 2.7 - 2.9.2, try <a href="http://agapetry.net/downloads/role-scoper_legacy">Role Scoper 1.2.x</a>.');
    $bail = 1;
}
if (is_admin() || defined('XMLRPC_REQUEST')) {
    // Early bailout for problematic 3rd party plugin ajax calls
    if (strpos($_SERVER['SCRIPT_NAME'], 'wp-wall-ajax.php')) {
        return;
    }
} elseif (!$bail) {
    require_once dirname(__FILE__) . '/feed-interceptor_rs.php';
    // must define get_currentuserinfo early
}
//log_mem_usage_rs( 'initial requires' );
if (!$bail) {
    require_once dirname(__FILE__) . '/defaults_rs.php';
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:31,代码来源:role-scoper.php

示例10: force_distinct_post_caps

 function force_distinct_post_caps()
 {
     // but only if the post type has RS usage enabled
     global $wp_post_types;
     $type_caps = array();
     $customized = array();
     //scoper_refresh_default_otype_options();
     $use_post_types = scoper_get_option('use_post_types');
     $force_create_posts_cap = awp_ver('3.5-beta') && scoper_get_option('define_create_posts_cap');
     $generic_caps = array();
     foreach (array('post', 'page') as $post_type) {
         if ($force_create_posts_cap && $wp_post_types[$post_type]->cap->create_posts == $wp_post_types[$post_type]->cap->edit_posts) {
             $wp_post_types[$post_type]->cap->create_posts = "create_{$post_type}s";
         }
         $generic_caps[$post_type] = (array) $wp_post_types[$post_type]->cap;
     }
     $skip_caps = array('read_post', 'edit_post', 'delete_post');
     foreach (array_keys($wp_post_types) as $post_type) {
         if (empty($use_post_types[$post_type])) {
             continue;
         }
         if ('post' === $wp_post_types[$post_type]->capability_type) {
             $wp_post_types[$post_type]->capability_type = $post_type;
         }
         $type_caps = (array) $wp_post_types[$post_type]->cap;
         /* $plural_name =  */
         // as of WP 3.1, no basis for determinining this unless type-specific caps are set
         // don't allow any capability defined for this type to match any capability defined for post or page (unless this IS post or page type)
         foreach ($type_caps as $cap_property => $type_cap) {
             if (in_array($cap_property, $skip_caps)) {
                 continue;
             }
             foreach (array('post', 'page') as $generic_type) {
                 if ($post_type != $generic_type && in_array($type_cap, $generic_caps[$generic_type]) && 'read' != $type_cap) {
                     if ('create_posts' == $cap_property) {
                         $type_caps[$cap_property] = str_replace("_{$generic_type}", "_{$post_type}", $generic_caps[$generic_type][$cap_property]);
                     } else {
                         $type_caps[$cap_property] = str_replace($generic_type, $post_type, $cap_property);
                     }
                     $customized[$post_type] = true;
                 }
             }
         }
         $wp_post_types[$post_type]->cap = (object) $type_caps;
         // This simplifies map_meta_cap handling. Actual attachment or revision editing access is still based on access to the parent post
         /*
         if ( ! defined( 'SCOPER_RETAIN_CUSTOM_METACAPS' ) ) {
         	$wp_post_types['attachment']->cap->read_post = 'read_attachment';
         	$wp_post_types['attachment']->cap->edit_post = 'read_attachment';
         	$wp_post_types['attachment']->cap->delete_post = 'read_attachment';
         	$wp_post_types['revision']->cap->read_post = 'read_revision';
         	$wp_post_types['revision']->cap->edit_post = 'read_revision';
         	$wp_post_types['revision']->cap->delete_post = 'read_revision';
         }
         */
     }
     // One-time message alerting Administrators that custom types were auto-enabled for RS filtering
     if ($customized) {
         $logged = !empty($_POST['rs_defaults']) ? array() : (array) scoper_get_option('log_customized_types');
         if ($new_customized = array_diff_key($customized, $logged)) {
             $labels = array();
             foreach (array_keys($new_customized) as $post_type) {
                 $type_obj = get_post_type_object($post_type);
                 $labels[$post_type] = !empty($type_obj->labels->name) ? $type_obj->labels->name : $post_type;
                 $label_str = implode(', ', $labels);
             }
             $msg_format = __('The following Custom Post Types are enabled for RS filtering: <strong>%1$s</strong>. Non-administrators will be unable to edit them until you either disable filtering (<strong>Roles > Options > Realm > Post Type Usage</strong>) or assign type-specific Roles (<strong>Roles > General</strong>).  Disregard this message if you have already done so.', 'scoper');
             $message = sprintf($msg_format, $label_str);
             add_action('admin_notices', create_function('', 'echo \'<div id="message" class="error fade" style="color: black">' . $message . '</div>\';'));
             update_option('scoper_log_customized_types', array_merge($customized, $new_customized));
         }
     }
 }
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:73,代码来源:wp-cap-helper_cr.php

示例11: array

<?php

require_once ABSPATH . '/wp-admin/includes/user.php';
if (isset($_GET['rs_user_search'])) {
    if (empty($_GET['rs_user_search'])) {
        global $wpdb;
        $results = $wpdb->get_results("SELECT ID, user_login FROM {$wpdb->users} ORDER BY user_login");
    } else {
        if (awp_ver('3.1-beta')) {
            $search = new WP_User_Query('search=*' . $_GET['rs_user_search'] . '*');
        } else {
            $search = new WP_User_Search($_GET['rs_user_search']);
        }
        if ($search) {
            global $wpdb;
            $results = $wpdb->get_results("SELECT ID, user_login {$search->query_from} {$search->query_where} ORDER BY user_login");
        }
    }
    if ($results) {
        // determine all current users (of any status) for group in question
        if (!empty($_GET['rs_agent_id'])) {
            $users = ScoperAdminLib::get_group_members($_GET['rs_agent_id'], COL_ID_RS, false, array('status' => 'any'));
        } else {
            $users = array();
        }
        foreach ($results as $row) {
            if (!in_array($row->ID, $users)) {
                echo "<option value='{$row->ID}'>{$row->user_login}</option>";
            }
        }
    }
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:31,代码来源:user_query_rs.php

示例12: dirname

 function &build_blog_file_rules()
 {
     if (defined('SCOPER_NO_HTACCESS')) {
         return '';
     }
     $new_rules = '';
     require_once dirname(__FILE__) . '/analyst_rs.php';
     if (!($attachment_results = ScoperAnalyst::identify_protected_attachments())) {
         return $new_rules;
     }
     global $wpdb;
     require_once dirname(__FILE__) . '/uploads_rs.php';
     $home_root = parse_url(get_option('home'));
     $home_root = trailingslashit($home_root['path']);
     $uploads = scoper_get_upload_info();
     $baseurl = trailingslashit($uploads['baseurl']);
     $arr_url = parse_url($baseurl);
     $rewrite_base = $arr_url['path'];
     $file_keys = array();
     $has_postmeta = array();
     if ($key_results = scoper_get_results("SELECT pm.meta_value, p.guid, p.ID FROM {$wpdb->postmeta} AS pm INNER JOIN {$wpdb->posts} AS p ON p.ID = pm.post_id WHERE pm.meta_key = '_rs_file_key'")) {
         foreach ($key_results as $row) {
             $file_keys[$row->guid] = $row->meta_value;
             $has_postmeta[$row->ID] = $row->meta_value;
         }
     }
     $new_rules = "<IfModule mod_rewrite.c>\n";
     $new_rules .= "RewriteEngine On\n";
     $new_rules .= "RewriteBase {$rewrite_base}\n\n";
     $main_rewrite_rule = "RewriteRule ^(.*) {$home_root}index.php?attachment=\$1&rs_rewrite=1 [NC,L]\n";
     $htaccess_urls = array();
     foreach ($attachment_results as $row) {
         if (false !== strpos($row->guid, $baseurl)) {
             // no need to include any attachments which are not in the uploads folder
             if (!empty($file_keys[$row->guid])) {
                 $key = $file_keys[$row->guid];
             } else {
                 $key = urlencode(str_replace('.', '', uniqid(strval(rand()), true)));
                 $file_keys[$row->guid] = $key;
             }
             if (!isset($has_postmeta[$row->ID]) || $key != $has_postmeta[$row->ID]) {
                 update_post_meta($row->ID, "_rs_file_key", $key);
             }
             if (isset($htaccess_urls[$row->guid])) {
                 // if a file is attached to multiple protected posts, use a single rewrite rule for it
                 continue;
             }
             $htaccess_urls[$row->guid] = true;
             $rel_path = str_replace($baseurl, '', $row->guid);
             // escape spaces
             $file_path = str_replace(' ', '\\s', $rel_path);
             // escape horiz tabs (yes, at least one user has them in filenames)
             $file_path = str_replace(chr(9), '\\t', $file_path);
             // strip out all other nonprintable characters.  Affected files will not be filtered, but we avoid 500 error.  Possible TODO: advisory in file attachment utility
             $file_path = preg_replace('/[\\x00-\\x1f\\x7f]/', '', $file_path);
             // escape all other regular expression operator characters
             $file_path = preg_replace('/[\\^\\$\\.\\+\\[\\]\\(\\)\\{\\}]/', '\\\\$0', $file_path);
             $new_rules .= "RewriteCond %{REQUEST_URI} ^(.*)/{$file_path}" . "\$ [NC]\n";
             $new_rules .= "RewriteCond %{QUERY_STRING} !^(.*)rs_file_key={$key}(.*)\n";
             $new_rules .= $main_rewrite_rule;
             if ($pos_ext = strrpos($file_path, '\\.')) {
                 $thumb_path = substr($file_path, 0, $pos_ext);
                 $ext = substr($file_path, $pos_ext + 2);
                 $new_rules .= "RewriteCond %{REQUEST_URI} ^(.*)/{$thumb_path}" . '-[0-9]{2,4}x[0-9]{2,4}\\.' . $ext . "\$ [NC]\n";
                 $new_rules .= "RewriteCond %{QUERY_STRING} !^(.*)rs_file_key={$key}(.*)\n";
                 $new_rules .= $main_rewrite_rule;
                 // if resized image file(s) exist, include rules for them
                 $guid_pos_ext = strrpos($rel_path, '.');
                 $pattern = $uploads['path'] . '/' . substr($rel_path, 0, $guid_pos_ext) . '-??????????????' . substr($rel_path, $guid_pos_ext);
                 if (glob($pattern)) {
                     $new_rules .= "RewriteCond %{REQUEST_URI} ^(.*)/{$thumb_path}" . '-[0-9,a-f]{14}\\.' . $ext . "\$ [NC]\n";
                     $new_rules .= "RewriteCond %{QUERY_STRING} !^(.*)rs_file_key={$key}(.*)\n";
                     $new_rules .= $main_rewrite_rule;
                 }
             }
         }
     }
     // end foreach protected attachment
     if (IS_MU_RS && (!awp_ver('3.5') || get_site_option('ms_files_rewriting'))) {
         global $blog_id;
         $file_filtered_sites = (array) get_site_option('scoper_file_filtered_sites');
         if (!in_array($blog_id, $file_filtered_sites)) {
             // this site needs a file redirect rule in root .htaccess
             scoper_flush_site_rules();
         }
         if (defined('SCOPER_MU_FILE_PROCESSING')) {
             // unless SCOPER_MU_FILE_PROCESSING is defined (indicating blogs.php has been modified for compatibility), blogs.php processing will be bypassed for all files
             $content_path = trailingslashit(str_replace($strip_path, '', str_replace('\\', '/', WP_CONTENT_DIR)));
             $new_rules .= "\n# Default WordPress cache handling\n";
             $new_rules .= "RewriteRule ^(.*) {$content_path}blogs.php?file=\$1 [L]\n";
         }
     }
     $new_rules .= "</IfModule>\n";
     return $new_rules;
 }
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:95,代码来源:rewrite-rules_rs.php

示例13: switch_to_blog

        switch_to_blog($orig_blog_id);
    }
    return true;
}
?>

<div class='wrap'>
<table width = "100%"><tr>
<td width = "90%">
<h2><?php 
_e('Attachments Utility', 'scoper');
?>
</h2>
<?php 
if (MULTISITE) {
    $name = awp_ver('3.1') ? 'sites' : 'ms-admin';
    $page = 'rs-site_options';
} else {
    $name = 'admin';
    $page = 'rs-options';
}
//printf( _ x('Back to %1$sRole Scoper Options%2$s', 'arguments are link open, link close', 'scoper'), "<a href='admin.php?page=rs-options'>", '</a>');
printf(__('Back to %1$sRole Scoper Options%2$s', 'scoper'), "<a href='{$name}.php?page={$page}'>", '</a>');
?>
</td>
</tr></table>

<?php 
echo '<br />';
_e("Role Scoper can limit direct URL access to files linked from your posts and pages, <strong>but only if</strong> the following requirements are met:", 'scoper');
echo '<div class="rs-instructions"><ol><li>';
开发者ID:par-orillonsoft,项目名称:creationOfSociety,代码行数:31,代码来源:attachments_utility.php

示例14: act_nav_menu_guard_theme_locs

 function act_nav_menu_guard_theme_locs($referer)
 {
     if ('update-nav_menu' == $referer) {
         if (!$this->_can_edit_theme_locs()) {
             if (awp_ver('3.6-dev')) {
                 if ($stored_locs = get_theme_mod('nav_menu_locations')) {
                     $_POST['menu-locations'] = (array) $stored_locs;
                 } else {
                     $_POST['menu-locations'] = array();
                 }
             } else {
                 if (isset($_POST['menu-locations'])) {
                     unset($_POST['menu-locations']);
                 }
             }
         }
     }
 }
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:18,代码来源:filters-admin_rs.php

示例15: posts_teaser_prep_results

 function posts_teaser_prep_results($results, $tease_otypes, $args = '')
 {
     $defaults = array('user' => '', 'use_object_roles' => -1, 'use_term_roles' => -1, 'request' => '', 'object_type' => '');
     $args = array_merge($defaults, (array) $args);
     extract($args);
     global $wpdb, $scoper, $wp_query;
     global $query_interceptor;
     if (did_action('wp_meta') && !did_action('wp_head')) {
         return $results;
     }
     if (empty($request)) {
         // TODO: teaser logs last_request itself
         global $query_interceptor;
         if (empty($query_interceptor->last_request['post'])) {
             // try to get it from wpdb instead
             if (!empty($wpdb->last_query)) {
                 $request = $wpdb->last_query;
             } else {
                 // don't risk exposing hidden content if something goes wrong with query logging
                 return array();
             }
         } else {
             $request = $query_interceptor->last_request['post'];
         }
     }
     // Pagination could be broken by subsequent query for filtered ids, so buffer current paging parameters
     // ( this code mimics WP_Query::get_posts() )
     if (!empty($wp_query->query_vars['posts_per_page'])) {
         $found_posts_query = apply_filters('found_posts_query', 'SELECT FOUND_ROWS()');
         $buffer_found_posts = $wpdb->get_var($found_posts_query);
         if ($buffer_found_posts >= $wp_query->query_vars['posts_per_page']) {
             $restore_pagination = true;
             $buffer_found_posts = apply_filters('found_posts', $buffer_found_posts);
         }
     }
     $list_private = array();
     if (awp_ver('3.0')) {
         $private_stati = get_post_stati(array('private' => true));
     } else {
         $private_stati = array('private');
     }
     if (is_single() || is_page()) {
         $maybe_fudge_private = true;
         $maybe_strip_private = false;
     } else {
         $maybe_strip_private = true;
         $maybe_fudge_private = false;
     }
     if (!is_object($user)) {
         global $current_user;
         $user = $current_user;
     }
     // don't risk exposing hidden content if there is a problem with query parsing
     if (!($pos = strpos(strtoupper($request), " FROM"))) {
         return array();
     }
     $distinct = stripos($request, " DISTINCT ") ? 'DISTINCT' : '';
     // RS does not add any joins, but if DISTINCT clause exists in query, retain it
     $request = "SELECT {$distinct} {$wpdb->posts}.ID " . substr($request, $pos);
     if ($limitpos = strpos($request, ' LIMIT ')) {
         $request = substr($request, 0, $limitpos);
     }
     $args['skip_teaser'] = true;
     $filtered_request = $query_interceptor->flt_objects_request($request, 'post', $object_type, $args);
     global $scoper_teaser_filtered_ids;
     $scoper_teaser_filtered_ids = scoper_get_col($filtered_request);
     if (!isset($scoper->teaser_ids)) {
         $scoper->teaser_ids = array();
     }
     $hide_ungranted_private = array();
     foreach ($tease_otypes as $object_type) {
         $hide_ungranted_private[$object_type] = scoper_get_otype_option('teaser_hide_private', 'post', $object_type);
     }
     foreach (array_keys($results) as $key) {
         if (is_array($results[$key])) {
             $id = $results[$key]['ID'];
         } else {
             $id = $results[$key]->ID;
         }
         if (!$scoper_teaser_filtered_ids || !in_array($id, $scoper_teaser_filtered_ids)) {
             if (isset($results[$key]->post_type)) {
                 $object_type = $results[$key]->post_type;
             } else {
                 $object_type = $scoper->data_sources->get_from_db('type', 'post', $id);
             }
             if (!in_array($object_type, $tease_otypes)) {
                 continue;
             }
             // Defeat a WP core secondary safeguard so we can apply the teaser message rather than 404
             if (in_array($results[$key]->post_status, $private_stati)) {
                 // don't want the teaser message (or presence in category archive listing) if we're hiding a page from listing
                 $type_obj = get_post_type_object($object_type);
                 if ($type_obj && $type_obj->hierarchical) {
                     // TODO: review implementation of this option with custom types
                     if (!isset($list_private[$object_type])) {
                         $list_private[$object_type] = scoper_get_otype_option('private_items_listable', 'post', 'page');
                     }
                 } else {
                     $list_private[$object_type] = true;
                 }
//.........这里部分代码省略.........
开发者ID:par-orillonsoft,项目名称:creationOfSociety,代码行数:101,代码来源:teaser_rs.php


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