Textpattern PHP Cross Reference Content Management Systems

Source: /textpattern/include/txp_pane.php - 113 lines - 2555 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*
   4   * Textpattern Content Management System
   5   * https://textpattern.com/
   6   *
   7   * Copyright (C) 2020 The Textpattern Development Team
   8   *
   9   * This file is part of Textpattern.
  10   *
  11   * Textpattern is free software; you can redistribute it and/or
  12   * modify it under the terms of the GNU General Public License
  13   * as published by the Free Software Foundation, version 2.
  14   *
  15   * Textpattern is distributed in the hope that it will be useful,
  16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18   * GNU General Public License for more details.
  19   *
  20   * You should have received a copy of the GNU General Public License
  21   * along with Textpattern. If not, see <https://www.gnu.org/licenses/>.
  22   */
  23  
  24  if (!defined('txpinterface')) {
  25      die('txpinterface is undefined.');
  26  }
  27  
  28  /**
  29   * Handles pane states.
  30   *
  31   * @package Admin\Pane
  32   */
  33  
  34  class Textpattern_Admin_Pane
  35  {
  36      /**
  37       * Constructor.
  38       */
  39  
  40      public function __construct()
  41      {
  42          global $step;
  43  
  44          $steps = array(
  45              'visible'    => true,
  46              'tabVisible' => true,
  47          );
  48  
  49          if ($step && bouncer($step, $steps) && has_privs(ps('origin'))) {
  50              $this->$step();
  51          }
  52      }
  53  
  54      /**
  55       * Validates a token.
  56       *
  57       * @return bool
  58       */
  59  
  60      protected function valid_token()
  61      {
  62          $args = func_get_args();
  63  
  64          return ps('token') === md5(join('', $args).ps('origin').form_token().get_pref('blog_uid'));
  65      }
  66  
  67      /**
  68       * Saves pane visibility.
  69       */
  70  
  71      public function visible()
  72      {
  73          extract(psa(array(
  74              'pane',
  75              'visible',
  76              'origin',
  77          )));
  78  
  79          send_xml_response();
  80  
  81          if ($this->valid_token($pane) && preg_match('/^[a-z0-9_-]+$/i', $pane)) {
  82              set_pref("pane_{$pane}_visible", (int) ($visible === 'true'), $origin, PREF_HIDDEN, 'yesnoradio', 0, PREF_PRIVATE);
  83  
  84              return;
  85          }
  86  
  87          trigger_error(gTxt('invalid_pane'), E_USER_WARNING);
  88      }
  89  
  90      /**
  91       * Saves tab visibility.
  92       */
  93  
  94      public function tabVisible()
  95      {
  96          extract(psa(array(
  97              'pane',
  98              'origin',
  99          )));
 100  
 101          send_xml_response();
 102  
 103          if ($this->valid_token($pane) && preg_match('/^[a-z0-9_-]+$/i', $pane)) {
 104              set_pref("pane_{$origin}_visible", ($pane), $origin, PREF_HIDDEN, 'text_input', 0, PREF_PRIVATE);
 105  
 106              return;
 107          }
 108  
 109          trigger_error(gTxt('invalid_pane'), E_USER_WARNING);
 110      }
 111  }
 112  
 113  new Textpattern_Admin_Pane();

title

Description

title

Description

title

Description

title

title

Body