dedecms 的keyword相关性改善

dedecms的相关文章的函数 lib_likearticle 里面是根据  keyword1 or keyword2 or … 这样的规律用一个sql解决的,并且用 order by id desc 来排序,可能导致第一个关键字的文章不在前面,下面的补丁就是解决这个问题。

思路是: 先根据第一个关键字搜索结果后,显示出来,如果数量不够 $row 指定的,那么就用关键字2继续查找,依次类推,直到搜索到 $row 数量。

修改的文件是 include\taglib\likearticle.lib.php 下面的连接是txt格式,请自行修改后缀为 .php

likearticle.lib

补丁文件

teamviewer 正在初始化显示参数的解决办法

在你用win远程桌面安装tw后,启动的tw里面因为你这是在一个远程里面开启的tw,

如果tw启用了多用户的方式,那么在你win控制台的那个tw的id和你在远程桌面里面看到id是不一样的,所以,打开tw的目录,找到一个log文件,
比如 TeamViewer12_Logfile.log,找找里面的 ID: 开头的

ID:  XXXXXXXX ,

那个可能和你原来看到的只相差一点点,试试用这个ID连接,你会有不一样的感受

苹果cms,maccms 关于自定义伪静态的一些二次开发

苹果cms maccms 8 有关伪静态方面列表页和详情页的自定义url

列表页的是 vod-type-id-{id}-pg-{pg} 表示的是分类id的第pg页,可以考虑根据不同的分类设置为 ,比如 type-id = 1 的是 /movie/pg-{pg}.html
比如 /movie/pg-1.html
如果 type-id=2 设置为 /tv/pg-{pg}.html,比如
/tv/pg-1.html,
我们通过修改 inc/common/template.php 的AppTpl类的getLink函数 ,在

 

$str = $jstart . MAC_PATH . $str . $strpg . $ext. $jend;$str = $jstart . MAC_PATH . $str . $strpg . $ext. $jend;
return str_replace(array(‘//’,’/index’.$rgext),array(‘/’,’/’),$str);

修改为

$str = $jstart . MAC_PATH . $str . $strpg . $ext. $jend;$str = $jstart . MAC_PATH . $str . $strpg . $ext. $jend;

$new_str = str_replace(array(‘//’,’/index’.$rgext),array(‘/’,’/’),$str);

// 这里增加伪静态的自定义代码比如

$new_str = preg_replace(“/vod\-type\-id\-1\-/”,”movie/”,$newstr);
// 这样是 吧 vod-type-id-1-pg-1.html 修改为  movie/pg-1.html
return $newstr;

=============================================================

同时需要修改 伪静态配置文件 .htaccess 或者 nginx的rewrite文件

RewriteRule ^movie/pg-(\d+)$   index.php\?m=vod-type-id-1-pg-$1

nginx的

rewrite ^/movie/pg-(.*)$ /index.php?m=vod-type-id-1-pg-$1  break;

 

centos 6.X x86_64 安装 rpm 的mysql 5.6 下载如下包

http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-server-5.6.33-2.el6.x86_64.rpm

http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-client-5.6.33-2.el6.x86_64.rpm

http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-common-5.6.33-2.el6.x86_64.rpm

http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-devel-5.6.33-2.el6.x86_64.rpm

http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-libs-5.6.33-2.el6.x86_64.rpm

http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-libs-compat-5.6.33-2.el6.x86_64.rpm

dedecms 关键字链接 以长的为先,短的不做连接

dedecms后台设置关键字,文章里面会根据关键字自动增加连接

现在根据关键字的rank倒排序,建议比较长的排在前面,比如

你好样的  比 你好 有更大的rank,因为dedecms是根据rank做了倒排序的替换关键字,

如果希望不出现嵌套的连接,那么就需要做一些代码的变化 include\arc.archives.class.php

代码增加了行  1260-1269

// zjpro add 2017-08-22 QQ 733905
foreach($GLOBALS[‘replaced’] as $kk=>$vv)
{
if(strpos($kk, $word) !== FALSE)
{
$GLOBALS[‘replaced’][$word] = 1;
break;
}
}
// end zjpro QQ 733905

 

dedecms 函数扩展之:随机连接

问题背景:

在一个 kw.txt 里面用 “–”分割的 地址和关键字,形如

https://www.google.com–谷歌
https://www.github.com–git

现在模板里面随机调用5个这样的连接

{dede:rndkw runphp=’yes’}
@me = rndkw();
{/dede:rndkw}

在 \include\helpers\extend.helper.php 增加如下

 

if ( ! function_exists('rndkw'))
{
    function rndkw($str) { 
        
       
        
        $kw=file(getcwd() . DIRECTORY_SEPARATOR ."kw.txt");
         
        shuffle($kw);
        $s="";
        for($i=0;$i<5;$i++)
        {
            list($ah,$aw) = explode("--",$kw[$i]);
            $s .= "

".trim($aw)."

"; } return $s; } }

dedecms文章分页后的随机推荐文章在每个分页都相同改为不相同随机的方法

问题背景:

dedecms 发布文章,特别是图片的时候一般会分很多页,模板里面可能设置了随机推荐的其他图片,但是同一个文章的每个分页的这个随机推荐是一样的,如何改为不同?

问题解决:

模板里面一般是这类随机

{dede:arclist row=10 orderby=rand}
<li><a href=”[field:arcurl/]”>[field:title/]</a></li>
{/dede:arclist}

造成每个页面的随机都一样的原因就是 这个模板片段是只在处理一个文章的时候分析一次模板,如果每个分页再生成前再次分析下模板,理论上就再次扫描了一次,从而再次随机运行了一次代码。

方案:

include\arc.archives.class.php 的  MakeHtml 函数

在大概 410行,增加   $this->ParseTempletsFirst();

 

dedecms的GetPageTitlesST函数

include\arc.archives.class.php 里面 GetPageTitlesST 函数,在页面调用是

{dede:pagetitle style=’XXXX’ /}

那么就可以根据style来修改GetPageTitlesST 函数,使之能适用多种情况,比如

{dede:pagetitle style=’subtile_title’ /}

就需要走增加

if($styleName==’subtile_title’)
{
return  $this->SplitTitles[$pageNo-1] . “_” . $this->Fields[“title”] ;
}else{
return $this->Fields[“title”] ;
}

发文章的时候用

#p#第几页的标题#e#

 

 

PS:

可能UTF8的,这个函数有点问题,

最后的 #没能去掉,可以考虑用 sub_str($string,0,-1)消掉

mysql 的 information_schema 库

https://dev.mysql.com/doc/refman/5.7/en/information-schema.html

利用  information_schema 可以做很多事,这个库存储了mysql的元数据!

比如:

1)查询存在哪些 表是 innodb 的

2)查询 innodb 表的大小

3)查询某字段的定义

例子
SELECT table_schema,table_name, table_rows,
ROUND((data_length+index_length)/1024/1024) AS total_mb,
ROUND(data_length/1024/1024) AS data_mb,
ROUND(index_length/1024/1024) AS index_mb
FROM INFORMATION_SCHEMA.TABLES WHERE engine=’InnoDB’
ORDER BY total_mb desc;

php的win版本的一点编译解释

和本文一样的内容 是 这里

vc09 = Visual Studio 2008
vc10 = Visual Studio 2010
vc11 = Visual Studio 2012 2012
vc12 = Visual Studio 2013 2013
vc14 = Visual Studio 2015 2015
vc15 = Visual Studio 2017

VC11, VC14 & VC15
More recent versions of PHP are built with VC11, VC14 or VC15 (Visual Studio 2012, 2015 or 2017 compiler respectively) and include improvements in performance and stability.

– The VC11 builds require to have the Visual C++ Redistributable for Visual Studio 2012 x86 or x64 installed

– The VC14 builds require to have the Visual C++ Redistributable for Visual Studio 2015 x86 or x64 installed

– The VC15 builds require to have the Visual C++ Redistributable for Visual Studio 2017 x64 or x86 installed

TS and NTS
TS refers to multithread capable builds. NTS refers to single thread only builds. Use case for TS binaries involves interaction with a multithreaded SAPI and PHP loaded as a module into a web server. For NTS binaries the widespread use case is interaction with a web server through the FastCGI protocol, utilizing no multithreading (but also for example CLI).

发表在 PHP

nginx 的ssl ,单ip多名ssl,以及方便脚本

首先,nginx 单ip多域名的ssl配置,参考地址是

单ip nginx配置多域名https

另外,利用 脚本可以比较方便的使用 lets-encrypt 提供的免费ssl,

https://github.com/xdtianyu/scripts/tree/master/lets-encrypt

一个配置文件的例子  letsencrypt.conf-myssl

ACCOUNT_KEY=”letsencrypt-account.key”
DOMAIN_KEY=”/www/ssl/myssldomain.com.key”
DOMAIN_DIR=” /www/myssldomain”
DOMAINS=”DNS:myssldomain.com,DNS:www.myssldomain.com”

方法就是配置 conf文件,然后运行就好了,

letsencrypt.sh   letsencrypt.conf-myssl

上面脚本就能自动帮你做注册和生成key的动作。后面只需要修改nginx的配置文件即可

nginx的配置文件,这样写

server
{
listen 80;
listen 443;
if ($scheme = http) {return 301 https://$server_name$request_uri;}
server_name www.myssldomain.com myssldomain.com;
root /www/myssldomain/;
index index.php index.html;
include php.conf;
ssl on;
ssl_certificate “/www/ssl/myssldomain.chained.crt”;
### 注意这里,最好用chained.crt 容易被多数浏览器支持
ssl_certificate_key “/www/ssl/myssldomain.com.key”;
}

 

wdcp的apache编译ssl模块

下载apache的源文件 http://archive.apache.org/dist/httpd/

解压后进入 modules/ssl 运行下面语句

/www/wdlinux/apache/bin/apxs -a -i -DHAVE_OPENSSL=1 -I/usr/include/openssl -L/usr/lib64/openssl -c *.c -lcrypto -lssl -ldl

下面的3行不一定对。一般来说编辑 conf/extra/httpd-ssl.conf 里面启用 https比较好

下面3行仅供参考:

SSLCertficateChainFile /www/wdlinux/apache/conf/1_root_bundle.crt
SSLCertificateFile /www/wdlinux/apache/conf/2_www.域名.com.crt
SSLCertificateKeyFile /www/wdlinux/apache/conf/3_www.域名.com.key

PS:

http 80 转向到 https 443

.htaccess里面

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://www.yourname.com%{REQUEST_URI} [L,R=301]
</IfModule>

dedecms重整dede_arctiny表

症状: dede:list 标签出现混淆,一些分类的文章没有显示,原因是删除文章的时候只删除了dede_archives 表,而dede_arctiny表没做相应的删除行,你会发现有些文章id在dede_arctiny表里依然存在,而dedecms原本为了加快速度的dede_arctiny表反而导致了错误。

select id from dede_arctiny where not exists(select * from dede_archives where dede_arctiny.id=dede_archives.id);

这个语句就可以看出来存在于dede_arctiny表里的多余数据,但是并不保证缺失数据

删除dede_arctiny里面的无效数据的sql语句为

delete from dede_arctiny where not exists(select * from dede_archives where dede_arctiny.id=dede_archives.id);

================================================================

下面是我们写的查缺补漏的全部重新生成最新鲜数据dede_arciny表的方法:

dedecms 织梦的dede_arctiny表的重整

truncate table `dede_arctiny`;
insert into `dede_arctiny`(`id`,`typeid`,`typeid2`,`arcrank`,`channel`,`senddate`,`sortrank`,`mid`) select `id`,`typeid`,`typeid2`,`arcrank`,`channel`,`senddate`,`sortrank`,`mid` from `dede_archives` where `arcrank` > -1 order by `id` asc ;

apache 2.4的Substitute模块使用注意

apache 2.4 的 Substitute 模块是个好东西,可以用来实时修改页面内容,做些替换什么的工作,比如

ProxyPass /  http://other_web_site.com
ProxyPassReverse / http://other_web_site.com
AddOutputFilterByType SUBSTITUTE text/html
Substitute “s|http://other_web_site.com|http://localhost|i”

可以把网页里面的 http://other_web_site.com 字样替换为 http://localhost

那么有时候 你会发现这个没生效,没法替换,但是这也没什么错误啊,
其实问题很可能是因为你proxy的那个站点用来压缩,导致在Substitute看起来页面是压缩的内容,他当然替换不了,那么必须在压缩前进行解压缩,其实并不需要解压,只需要告诉对方的服务器,我这里不接受压缩的文件,那么就需要另外一个模块了
LoadModule headers_module modules/mod_headers.so

这个模块可以更改proxy模块发到对方的header
RequestHeader set Accept-Encoding “”

那么完整就可以可以这样写

ProxyPass /  http://other_web_site.com
ProxyPassReverse /   http://other_web_site.com
RequestHeader set Accept-Encoding ""
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|http://other_web_site.com|http://localhost|i"

一共需要启用如下模块

LoadModule filter_module modules/mod_filter.so
LoadModule headers_module modules/mod_headers.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule substitute_module modules/mod_substitute.so

 

附:有关nginx里面proxy的时候碰到gzip

看这里  http://www.zjpro.com/nginx-substitutions4nginx.html