国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.9KB

  1. <?php
  2. /**
  3. * 文档随机模板
  4. *
  5. * @version $Id: article_template_rand.php 1 14:31 2010年7月12日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__).'/config.php');
  12. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  13. CheckPurview('sys_StringMix');
  14. if (empty($dopost)) $dopost = '';
  15. $templates = empty($templates) ? '' : stripslashes($templates);
  16. $m_file = DEDEDATA.'/template.rand.php';
  17. $okmsg = '';
  18. //保存配置
  19. if ($dopost == 'save') {
  20. CheckCSRF();
  21. $fp = fopen($m_file, 'w');
  22. flock($fp, 3);
  23. fwrite($fp, $templates);
  24. fclose($fp);
  25. $okmsg = '成功保存配置信息 AT:('.MyDate('H:i:s', time()).')';
  26. }
  27. //对旧文档进行随机模板处理
  28. else if ($dopost == 'makeold') {
  29. CheckCSRF();
  30. set_time_limit(3600);
  31. if (!file_exists($m_file)) {
  32. AjaxHead();
  33. echo "配置文件不存在";
  34. exit();
  35. }
  36. require_once($m_file);
  37. if ($cfg_tamplate_rand == 0) {
  38. AjaxHead();
  39. echo "系统没开启允许随机模板的选项";
  40. exit();
  41. }
  42. $totalTmp = count($cfg_tamplate_arr) - 1;
  43. if ($totalTmp < 1) {
  44. AjaxHead();
  45. echo "随机模板的数量必须为2个或以上";
  46. exit();
  47. }
  48. for ($i = 0; $i < 10; $i++) {
  49. $temp = $cfg_tamplate_arr[mt_rand(0, $totalTmp)];
  50. $dsql->ExecuteNoneQuery(" Update `#@__addonarticle` set templet='$temp' where RIGHT(aid, 1)='$i' ");
  51. }
  52. AjaxHead();
  53. echo "全部随机操作成功";
  54. exit();
  55. }
  56. //清除全部的指定模板
  57. else if ($dopost == 'clearold') {
  58. CheckCSRF();
  59. $dsql->ExecuteNoneQuery(" Update `#@__addonarticle` set templet='' ");
  60. $dsql->ExecuteNoneQuery(" OPTIMIZE TABLE `#@__addonarticle` ");
  61. AjaxHead();
  62. echo "全部清除操作成功";
  63. exit();
  64. }
  65. //读出
  66. if (empty($templates) && filesize($m_file) > 0) {
  67. $fp = fopen($m_file, 'r');
  68. $templates = fread($fp, filesize($m_file));
  69. fclose($fp);
  70. }
  71. $wintitle = "随机模板防采集设置";
  72. $wecome_info = "随机模板防采集设置";
  73. make_hash();
  74. $msg = "
  75. <link rel='stylesheet' href='../static/web/css/admin.css'>
  76. <script src='js/main.js'></script>
  77. <script src='../static/web/js/webajax.js'></script>
  78. <script>
  79. function DoRand(jobname)
  80. {
  81. ChangeFullDiv('show');
  82. \$DE('loading').style.display = 'block';
  83. fetch('article_template_rand.php?dopost='+jobname+'&token={$_SESSION['token']}').then(resp=>resp.text()).then((d)=>{
  84. \$DE('tmpct').innerHTML = d;
  85. \$DE('loading').style.display = 'none';
  86. ChangeFullDiv('hide');
  87. });
  88. }
  89. </script>
  90. <div id='loading' style='position:absolute;top:160;display:none;z-index:3000'>
  91. <img src='../static/web/img/loadinglit.gif'>请稍后,正在操作中
  92. </div>
  93. <table width='100%' align='center'>
  94. <tr>
  95. <td height='26'>
  96. 如果您想对旧的文章应用随机模板设置,请点击此对旧文章进行处理(必须设置好模板项)
  97. <a href='javascript:;' onclick='DoRand(\"makeold\")' class='btn btn-success btn-sm'>设置全部</a>
  98. <a href='javascript:;' onclick='DoRand(\"clearold\")' class='btn btn-success btn-sm'>取消全部</a>
  99. <span id='tmpct' style='color:#dc3545;font-weight:bold'>$okmsg</span>
  100. </td>
  101. </tr>
  102. <tr>
  103. <td><textarea name='templates' id='templates' style='width:100%;height:250px'>$templates</textarea></td>
  104. </tr>
  105. </table>";
  106. $win = new OxWindow();
  107. $win->Init('article_template_rand.php', 'js/blank.js', 'POST');
  108. $win->AddHidden('dopost', 'save');
  109. $win->AddHidden('token', $_SESSION['token']);
  110. $win->AddTitle("本设置仅适用于系统默认的文章模型,设置后发布文章时会自动按指定的模板随机获取一个,如果不想使用此功能,把它设置为空即可");
  111. $win->AddMsgItem($msg);
  112. $winform = $win->GetWindow('ok');
  113. $win->Display();