mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-04 00:24:29 +08:00
46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace app\common\tools;
|
|
|
|
use phpQuery;
|
|
|
|
class PostShow
|
|
{
|
|
public static function handleCopyright($content)
|
|
{
|
|
|
|
// 防采集版权声明,被采集了会在其他网站显示
|
|
// 可以被选中复制,可以被采集,在网页中不会显示,但是在别的网站中可以显示
|
|
$content_copyright = '<blockquote class="post-content-inner-copyright"> 版权声明:' . get_system_config('post_copyright') . '</blockquote>';
|
|
|
|
// 防采集版权声明,被采集了也不会在其他网站显示
|
|
// 可以被选中复制,可以被采集,在网页中不会显示,在别的网站中也不会显示
|
|
$content_copyright_hide = '<p style="height:0;line-height: 0;margin:0;padding:0;overflow: hidden;margin-block-start:0;margin-block-end:0;position: absolute;">版权声明:' . get_system_config('post_copyright') . '</p>';
|
|
|
|
$dom_copyright = phpQuery::newDocumentHTML($content_copyright);
|
|
|
|
$dom_copyright_hide = phpQuery::newDocumentHTML($content_copyright_hide);
|
|
|
|
$dom_content = phpQuery::newDocumentHTML($content);
|
|
|
|
// 找到子元素p
|
|
$p_list = $dom_content->children('p');
|
|
|
|
foreach ($p_list as $index_p => $dom_p) {
|
|
|
|
if ($index_p != 0 && $index_p % 8 == 0) {
|
|
|
|
// $dom_copyright->clone()->children()->insertAfter($dom_p);
|
|
}
|
|
if ($index_p != 0 && $index_p % 6 == 0) {
|
|
|
|
$dom_copyright_hide->clone()->children()->insertAfter($dom_p);
|
|
}
|
|
}
|
|
|
|
$content = $dom_content->html();
|
|
|
|
return $content;
|
|
}
|
|
}
|