Source for file ChangeStatus.class.php

Documentation is available at ChangeStatus.class.php

  1. <?php
  2. /**
  3.  * ChangeStatus 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. {
  15.     /**
  16.     * Constructor
  17.     *
  18.     * @uses ConnectDB::sqlSet()
  19.     * @uses ConnectDB::close()
  20.     * @return void 
  21.     */
  22.     public function __construct (){
  23.     
  24.         // call parent Constructor from class DbConectionMaker
  25.         parent::__construct();
  26.     
  27.         session_start();
  28.         
  29.         // all documentc requested per AJAX should have this part to turn off the browser and proxy cache for any XHR request
  30.         header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');
  31.         
  32.         // Test if this status is allowed to be used by this user
  33.         if (!$this->checkRightsOfStatus($_POST['img'])) {
  34.             $_POST['img']=""
  35.             $_POST['text']="";
  36.             echo "Not allowed operation.";
  37.             return false;
  38.         }
  39.         
  40.         // no image is just online status
  41.         if($_POST['img']=="status_online"){$_POST['img']=""$_POST['text']="";}
  42.  
  43.         // if the image is not on the server, and also to prevent the sql-injections
  44.         if (!empty($_POST['img']&& !file_exists("./img/".$_POST['img'].".png")) {$_POST['img']=""$_POST['text']="";}
  45.         
  46.         // change status in the session table
  47.         $this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_useronline SET 
  48.             etchat_user_online_user_status_img = '".addslashes($_POST['img'])."',
  49.             etchat_user_online_user_status_text = '".addslashes(urldecode($_POST['text']))."'
  50.             WHERE etchat_onlineuser_fid = ".(int)$_SESSION['etchat_'.$this->_prefix.'user_id']);
  51.         
  52.         // close DB connection
  53.         $this->dbObj->close();
  54.         
  55.         echo "1";
  56.     }
  57.     
  58.     /**
  59.     * Test if this status is allowed to be used by this user
  60.     *
  61.     * @uses LangXml object creation
  62.     * @uses LangXml::getLang() parser method
  63.     * @return bool
  64.     */
  65.     private function checkRightsOfStatus($statusImagename){
  66.         
  67.         // create new LangXml Object
  68.         $langObj = new LangXml();
  69.         $lang=$langObj->getLang();
  70.         
  71.         foreach($lang->chat_js[0]->status as $status_value
  72.             if ($status_value->tagAttrs['imagename']==$statusImagename && $status_value->tagAttrs['rights']!='all')    
  73.                 $thisStatusImagenameRights[]=$status_value->tagAttrs['rights'];
  74.         
  75.         if (!is_array($thisStatusImagenameRights)) return true;
  76.         else{
  77.             if (in_array($_SESSION['etchat_'.$this->_prefix.'user_priv']$thisStatusImagenameRights)) return true;
  78.             else return false;
  79.         }
  80.     }

Documentation generated on Thu, 05 May 2011 14:05:55 +0000 by phpDocumentor 1.4.3