Source for file BlockUser.class.php

Documentation is available at BlockUser.class.php

  1. <?php
  2. /**
  3.  * BlockUser, for user blocking in the session
  4.  *
  5.  * LICENSE: CREATIVE COMMONS PUBLIC LICENSE  "Namensnennung — Nicht-kommerziell 2.0"
  6.  *
  7.  * @copyright  2009 <SEDesign />
  8.  * @license    http://creativecommons.org/licenses/by-nc/2.0/de/
  9.  * @version    $3.0.6$
  10.  * @link       http://www.sedesign.de/de_produkte_chat-v3.html
  11.  * @since      File available since Alpha 1.0
  12.  */
  13.  
  14. class BlockUser extends EtChatConfig
  15. {
  16.     /**
  17.     * Constructor
  18.     *
  19.     * @return void 
  20.     */
  21.     public function __construct (){
  22.     
  23.         session_start();
  24.         
  25.         // call parent Constructor from class EtChatConfig
  26.         parent::__construct();
  27.         
  28.         // all documentc requested per AJAX should have this part to turn off the browser and proxy cache for any XHR request
  29.         header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');
  30.         
  31.         if(!is_array($_SESSION['etchat_'.$this->_prefix.'block_priv'])) $_SESSION['etchat_'.$this->_prefix.'block_priv'= array();
  32.         if(!is_array($_SESSION['etchat_'.$this->_prefix.'block_all'])) $_SESSION['etchat_'.$this->_prefix.'block_all'= array();
  33.  
  34.         // Block all messages
  35.         if (isset($_POST['block_all'])){
  36.             // Der User ist bereits blokiert und wird wieder freigegeben
  37.             // The user is blocked now, so hi will be decontrolled
  38.             if (in_array($_POST['block_all']$_SESSION['etchat_'.$this->_prefix.'block_all'])){
  39.                 $key_from_all array_search($_POST['block_all']$_SESSION['etchat_'.$this->_prefix.'block_all']);
  40.                 $_SESSION['etchat_'.$this->_prefix.'block_all'][$key_from_all]=99999999999;
  41.  
  42.                 // Falls der User bereits in privat gesperrt ist, wird dieser Schlüssel gelöscht
  43.                 // If the user is blocked now by privat option, this key will be deleted
  44.                 $key_from_priv array_search($_POST['block_all']$_SESSION['etchat_'.$this->_prefix.'block_priv']);
  45.                 $_SESSION['etchat_'.$this->_prefix.'block_priv'][$key_from_priv]=99999999999;
  46.             }
  47.             // Der User wird erst blokiert
  48.             // The user will be blocked by first time
  49.             else {
  50.                 $_SESSION['etchat_'.$this->_prefix.'block_all'][$_POST['block_all'];
  51.  
  52.                 // Falls der User bereits in privat gesperrt ist, wird dieser Schlüssel gelöscht
  53.                 // If the user is blocked now by privat option, this key will be deleted
  54.                 $key_from_priv array_search($_POST['block_all']$_SESSION['etchat_'.$this->_prefix.'block_priv']);
  55.                 $_SESSION['etchat_'.$this->_prefix.'block_priv'][$key_from_priv]=99999999999;
  56.              }
  57.  
  58.         }
  59.         // Block private messages
  60.         if (isset($_POST['block_priv'])){
  61.             if (in_array($_POST['block_priv']$_SESSION['etchat_'.$this->_prefix.'block_priv'])){
  62.                 $key_from_priv array_search($_POST['block_priv']$_SESSION['etchat_'.$this->_prefix.'block_priv']);
  63.                 $_SESSION['etchat_'.$this->_prefix.'block_priv'][$key_from_priv]=99999999999;
  64.  
  65.  
  66.                 // Falls der User bereits in all gesperrt ist, wird dieser Schlüssel gelöscht
  67.                 // If the user is blocked now by "all" option, this key will be deleted
  68.                 $key_from_all array_search($_POST['block_priv']$_SESSION['etchat_'.$this->_prefix.'block_all']);
  69.                 $_SESSION['etchat_'.$this->_prefix.'block_all'][$key_from_all]=99999999999;
  70.             }
  71.             else {
  72.                 $_SESSION['etchat_'.$this->_prefix.'block_priv'][$_POST['block_priv'];
  73.  
  74.                 // Falls der User bereits in all gesperrt ist, wird dieser Schlüssel gelöscht
  75.                 // If the user is blocked now by "all" option, this key will be deleted
  76.                 $key_from_all array_search($_POST['block_priv']$_SESSION['etchat_'.$this->_prefix.'block_all']);
  77.                 $_SESSION['etchat_'.$this->_prefix.'block_all'][$key_from_all]=99999999999;
  78.             }
  79.         }
  80.  
  81.         // Make output
  82.         if (isset($_POST['show'])){
  83.             if (in_array($_POST['show']$_SESSION['etchat_'.$this->_prefix.'block_priv'])) echo "priv";
  84.             if (in_array($_POST['show']$_SESSION['etchat_'.$this->_prefix.'block_all'])) echo "all";
  85.         }
  86.     }
  87. }

Documentation generated on Tue, 22 Dec 2009 09:42:45 +0100 by phpDocumentor 1.4.1