百度云加速自定义证书与cyberpanel的let’s encrypt 证书搭配使用

个人认证后,弄了个百度云加速的免费版用用,可以上传自定义的证书。
这个玩意,还要人工操作,不方便,翻了下云加速的api:https://su.baidu.com/agency/api.html#/7_kaifazhinan/1_APIcankao/19_zhengshuxiangguan/9.7_zhengshuliebiao-zhengshushangchuan.md

发现可以用api上传。 继续阅读“百度云加速自定义证书与cyberpanel的let’s encrypt 证书搭配使用”

cyberpanel去掉8090端口

cyberpanel的管理端口是8090,这个端口cloudflare是不支持的,怎么办?

办法就是把8090端口去掉。

第一步是新建 域名网站,类似 www.example.com

第二步,为上面的域名签发证书

第三步,修改/usr/local/lsws/conf/httpd_config.conf,添加以下内容

extprocessor cyberpanel {
type proxy
address https://127.0.0.1:8090
maxConns 100
pcKeepAliveTimeout 60
initTimeout 60
retryTimeout 0
respBuffer 0
}

第四步,修改rewriterule如下:
REWRITERULE ^(.*)$ HTTP://cyberpanel/$1 [P]

安装cloudflare railgun过程出现的问题

● railgun.service – LSB: Railgun listener
Loaded: loaded (/etc/rc.d/init.d/railgun; bad; vendor preset: disabled)
Active: failed (Result: resources) since Fri 2019-12-20 21:03:40 CST; 1min 51s ago
Docs: man:systemd-sysv-generator(8)
Process: 4142 ExecStart=/etc/rc.d/init.d/railgun start (code=exited, status=0/SUCCESS)

railgun[4142]: Railgun successfully backgrounded, ensuring proper startup…
railgun[4142]: [FAILED]
railgun[4142]: Error starting Railgun as a daemon. Running in foreground…
su[4167]: (to railgun) root on none
railgun[4142]: Error starting: Error connecting to memcached server 127.0.0.1:11211: dial tcp 127.0.0.1:11211: connect: connection refused
railgun[4142]: [FAILED]
systemd[1]: New main PID 4169 does not exist or is a zombie.
systemd[1]: Failed to start LSB: Railgun listener.
systemd[1]: Unit railgun.service entered failed state.
systemd[1]: railgun.service failed.

继续阅读“安装cloudflare railgun过程出现的问题”

批量修改wordpress内容的代码


include_once('../wp-load.php');
$t = ($_REQUEST['page'])?(int)$_REQUEST['page']:1;
$args = array(
'post_type' => 'post',
'posts_per_page' => 500,
'paged' => $t,
);
global $wp_query;
$wp_query = new WP_Query( $args );
while ( have_posts() ) {
the_post();
$table = get_the_content();
$table = unserialize($table);
array_walk($table,function(&$value,$key){
$value = preg_replace('/ ?/', ' ', $value);
$value = str_ireplace('', $value);
$value = str_ireplace('>>', '>', $value);
$value = str_ireplace('
', '
', $value);
});
$post = array(
'ID' => get_the_ID(),
'post_content' => serialize($table),
'tags_input' => analysis_keyword((preg_match_all('/[\x{4e00}-\x{9fff}]+/u', $table['标题'].$table['标题'].$table['标题'].$table['内容'].$table['回复'].$table['地点'], $matches)?implode('', $matches[0]):'')),
);
kses_remove_filters();
$post_id = wp_update_post( $post,$wp_error);
kses_init_filters();
}
$t++;
if($t < $wp_query->max_num_pages){
$url = "http://www.yaoruisheng.com/somewhere/modify.php?page=" . $t ;
header( 'refresh:3;url='.$url );
echo 'You\'ll be redirected in about 3 secs. If not, click here.';
} else {
echo 'done!';
}

WordPress全局变量

Introduction

WordPress-specific global variables are used throughout WordPress code for various reasons. Almost all data that WordPress generates can be found in a global variable.

Note that it’s best to use the appropriate API functions when available, instead of modifying globals directly.

To access a global variable in your code, you first need to globalize the variable with global $variable;

Accessing other globals besides the ones listed below is not recommended.

Inside the Loop variables

While inside the loop, these globals are set, containing information about the current post being processed.

  • $post (WP_Post) The post object for the current post. Object described in Class_Reference/WP_Post.
  • $posts (Used by some core functions, not to be mistaken for $query->$posts).
  • $authordata (WP_User) The author object for the current post. Object described in Class_Reference/WP_User.
  • $currentday (string) Day that the current post was published.
  • $currentmonth (string) Month that the curent post was published.
  • $page (int) The page of the current post being viewed. Specified by the query var page.
  • $pages (array)The content of the pages of the current post. Each page elements contains part of the content separated by the <!–nextpage–> tag.
  • $multipage (boolean) Flag to know if the current post has multiple pages or not. Returns true if the post has multiple pages, related to $pages.
  • $more (boolean) Flag to know if WordPress should enforce the <!–more–> tag for the current post. WordPress will not enforce the more tag if true.
  • $numpages (int) Returns the number of pages in the post, related to $pages.

Browser Detection Booleans

These globals store data about which browser the user is on.

  • $is_iphone (boolean) iPhone Safari
  • $is_chrome (boolean) Google Chrome
  • $is_safari (boolean) Safari
  • $is_NS4 (boolean) Netscape 4
  • $is_opera (boolean) Opera
  • $is_macIE (boolean) Mac Internet Explorer
  • $is_winIE (boolean) Windows Internet Explorer
  • $is_gecko (boolean) FireFox
  • $is_lynx (boolean)
  • $is_IE (boolean) Internet Explorer
  • $is_edge (boolean) Microsoft Edge

Web Server Detection Booleans

These globals store data about which web server WordPress is running on.

  • $is_apache (boolean) Apache HTTP Server
  • $is_IIS (boolean) Microsoft Internet Information Services (IIS)
  • $is_iis7 (boolean) Microsoft Internet Information Services (IIS) v7.x
  • $is_nginx (boolean) Nginx web server

Version Variables

  • $wp_version (string) The installed version of WordPress
  • $wp_db_version (int) The version number of the database
  • $tinymce_version (string) The installed version of TinyMCE
  • $manifest_version (string) The cache manifest version
  • $required_php_version (string) The version of PHP this install of WordPress requires
  • $required_mysql_version (string) The version of MySQL this install of WordPress requires

Misc

  • $super_admins (array) An array of user IDs that should be granted super admin privileges (multisite). This global is only set by the site owner (e.g., in wp-config.php), and contains an array of IDs of users who should have super admin privileges. If set it will override the list of super admins in the database.
  • $wp_query (object) The global instance of the Class_Reference/WP_Query class.
  • $wp_rewrite (object) The global instance of the Class_Reference/WP_Rewrite class.
  • $wp (object) The global instance of the Class_Reference/WP class.
  • $wpdb (object) The global instance of the Class_Reference/wpdb class.
  • $wp_locale (object)
  • $wp_admin_bar (WP_Admin_Bar)
  • $wp_roles (WP_Roles)
  • $wp_meta_boxes (array) Object containing all registered metaboxes, including their id’s, args, callback functions and title for all post types including custom.
  • $wp_registered_sidebars (array)
  • $wp_registered_widgets (array)
  • $wp_registered_widget_controls (array)
  • $wp_registered_widget_updates (array)

Admin Globals