// Add some extra words because characters are count as words (20% extra)
 if (str_word_count(trim($words)) > $numWords) {
     $AddReadMoreLink = true;
     $words = word_limiter($words, $numWords);
 }
 if ($this->fulltext == 0) {
     $AddReadMoreLink = false;
 }
 if ($this->fulltext == 1 or $AddReadMoreLink) {
     if (strlen(trim($row->mtext)) > 0 or $AddReadMoreLink) {
         $words .= "\n<p><a href=\"" . $item->link . "\">" . JText::_('COM_NINJARSSSYNDICATOR_READ_MORE') . "</a></p>";
     }
 }
 if (!intval($this->renderHTML)) {
     //Remove HTML tags if told not to render them
     $words = noHTML($words);
 } else {
     //Remove images if told not to render them
     //Images will also get remove with HTML tags above
     if (!intval($this->renderImages)) {
         $words = delImagesFromHTML($words);
     }
 }
 /* Convert relative urls to absolute */
 $words = addAbsoluteURL($words);
 $item->description = $words;
 $item->descriptionHtmlSyndicated = true;
 //Many, many failed attempts to get the date right.
 //Kept here for a while in case issues arise again - Dec 2009
 //After some issues with the date not coming out correctly I am trying the exact code from Com_content
 //$itemDate = JFactory::getDate(JHTML::_('date', $row->dsdate, JText::_('DATE_FORMAT_LC2')));
             // store new list of functions
             DB::update(prefix_table("users"), array('fonction_id' => rtrim(implode(";", $tab), ";")), "id = %i", $record['id']);
         }
     }
     echo '[ { "error" : "no" } ]';
     break;
     //-------------------------------------------
     #CASE editing a role
 //-------------------------------------------
 #CASE editing a role
 case "edit_role":
     //Check if role already exist : No similar roles
     DB::query("SELECT * FROM " . prefix_table("roles_title") . " WHERE title = %s AND id != %i", $_POST['title'], $_POST['id']);
     $counter = DB::count();
     if ($counter == 0) {
         DB::update(prefix_table("roles_title"), array('title' => noHTML($_POST['title']), 'complexity' => $_POST['complexity']), 'id = %i', $_POST['id']);
         echo '[ { "error" : "no" } ]';
     } else {
         echo '[ { "error" : "yes" , "message" : "' . $LANG['error_role_exist'] . '" } ]';
     }
     break;
     /******************************************
      *CASE editing a role
      */
 /******************************************
  *CASE editing a role
  */
 case "allow_pw_change_for_role":
     DB::update(prefix_table("roles_title"), array('allow_pw_change' => $_POST['value']), 'id = %i', $_POST['id']);
     break;
     //-------------------------------------------
      */
 /**
  * ADD NEW USER
  */
 case "add_new_user":
     // Check KEY
     if ($_POST['key'] != $_SESSION['key']) {
         // error
         exit;
     }
     // decrypt and retreive data in JSON format
     $dataReceived = prepareExchangedData($_POST['data'], "decode");
     // Prepare variables
     $login = noHTML(htmlspecialchars_decode($dataReceived['login']));
     $name = noHTML(htmlspecialchars_decode($dataReceived['name']));
     $lastname = noHTML(htmlspecialchars_decode($dataReceived['lastname']));
     $pw = htmlspecialchars_decode($dataReceived['pw']);
     // Empty user
     if (mysqli_escape_string($link, htmlspecialchars_decode($login)) == "") {
         echo '[ { "error" : "' . addslashes($LANG['error_empty_data']) . '" } ]';
         break;
     }
     // Check if user already exists
     $data = DB::query("SELECT id, fonction_id, groupes_interdits, groupes_visibles FROM " . prefix_table("users") . "\n                WHERE login = %s", mysqli_escape_string($link, stripslashes($login)));
     if (DB::count() == 0) {
         // Add user in DB
         DB::insert(prefix_table("users"), array('login' => $login, 'name' => $name, 'lastname' => $lastname, 'pw' => bCrypt(stringUtf8Decode($pw), COST), 'email' => $dataReceived['email'], 'admin' => $dataReceived['admin'] == "true" ? '1' : '0', 'gestionnaire' => $dataReceived['manager'] == "true" ? '1' : '0', 'read_only' => $dataReceived['read_only'] == "true" ? '1' : '0', 'personal_folder' => $dataReceived['personal_folder'] == "true" ? '1' : '0', 'user_language' => $_SESSION['settings']['default_language'], 'fonction_id' => $dataReceived['manager'] == "true" ? $_SESSION['fonction_id'] : '0', 'groupes_interdits' => $dataReceived['manager'] == "true" && isset($data['groupes_interdits']) && !is_null($data['groupes_interdits']) ? $data['groupes_interdits'] : '0', 'groupes_visibles' => $dataReceived['manager'] == "true" && isset($data['groupes_visibles']) && !is_null($data['groupes_visibles']) ? $data['groupes_visibles'] : '0', 'isAdministratedByRole' => $dataReceived['isAdministratedByRole']));
         $new_user_id = DB::insertId();
         // Create personnal folder
         if ($dataReceived['personal_folder'] == "true") {
             DB::insert(prefix_table("nested_tree"), array('parent_id' => '0', 'title' => $new_user_id, 'bloquer_creation' => '0', 'bloquer_modification' => '0', 'personal_folder' => '1'));
      * Load item history
      */
 /*
  * CASE
  * Load item history
  */
 case "load_item_history":
     // Check KEY
     if ($_POST['key'] != $_SESSION['key']) {
         echo prepareExchangedData(array("error" => "ERR_KEY_NOT_CORRECT"), "encode");
         break;
     }
     // decrypt and retreive data in JSON format
     $dataReceived = prepareExchangedData($_POST['data'], "decode");
     // Prepare variables
     $id = noHTML(htmlspecialchars_decode($dataReceived['id']));
     // get item info
     $dataItem = DB::queryFirstRow("SELECT *\n                FROM " . prefix_table("items") . "\n                WHERE id=%i", $id);
     // get item history
     $history = '<table style="margin:0px; width:100%; border-collapse: collapse; background-color:#D4D5D5;" cellspacing="0" cellpadding="1">';
     $rows = DB::query("SELECT l.date as date, l.action as action, l.raison as raison, l.raison_iv AS raison_iv,\n                u.login as login, u.avatar_thumb as avatar_thumb\n                FROM " . prefix_table("log_items") . " as l\n                LEFT JOIN " . prefix_table("users") . " as u ON (l.id_user=u.id)\n                WHERE id_item=%i AND action <> %s\n                ORDER BY date ASC", $id, "at_shown");
     foreach ($rows as $record) {
         $reason = explode(':', $record['raison']);
         if ($record['action'] == "at_modification" && $reason[0] == "at_pw ") {
             // check if item is PF
             if ($dataItem['perso'] != 1) {
                 $reason[1] = cryption($reason[1], SALT, $record['raison_iv'], "decrypt");
             } else {
                 $reason[1] = cryption($reason[1], $_SESSION['my_sk'], $record['raison_iv'], "decrypt");
             }
             $reason[1] = @$reason[1]['string'];