[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

/include/inc_lib/ -> backend.functions.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2012 Oliver Georgi <oliver@phpwcms.de> // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // ----------------------------------------------------------------
  24  // obligate check for phpwcms constants
  25  if (!defined('PHPWCMS_ROOT')) {
  26     die("You Cannot Access This Script Directly, Have a Nice Day.");
  27  }
  28  // ----------------------------------------------------------------
  29  
  30  // general functions used in backend only
  31  
  32  function update_cache() {
  33      // used to update cache setting all current cache entries 
  34      // will be forced to update cache but will not be deleted
  35      //$sql = "UPDATE ".DB_PREPEND."phpwcms_cache SET cache_timeout='0'";
  36      //mysql_query($sql, $GLOBALS['db']) or die("error while updating cache");
  37  }
  38  
  39  function set_chat_focus($do, $p) { //set_chat_focus("chat", 1)
  40      if($do == "chat" && $p == 1) {
  41          echo "<script type=\"text/javascript\">\n";
  42          echo "document.sendchatmessage.chatmsg.focus();\ndocument.sendchatmessage.chatmsg.value=get_cookie('chatstring');\n";
  43          echo "timer = chat_reload(20000);\nfunction chat_reload(zeit) {\n";
  44          echo "timer=setTimeout(\"write_cookie(1);self.location.href='phpwcms.php?do=chat&p=1&l=".$chatlist."'\", zeit);\n";
  45          echo "return timer;\n}\nfunction restart_reload(timer) {\n";
  46          echo "if(timer != null) { clearTimeout(timer); timer=null; timer = chat_reload(20000); }\nreturn timer;\n}\n</script>\n";
  47      }
  48  }
  49  
  50  function forward_to($to, $link, $time=2500) { //Javascript forwarding
  51      if($to) echo "<script type=\"text/javascript\">\n setTimeout(\"document.location.href='".$link."'\", ".(intval($time))."); \n</script>\n";
  52  }
  53  
  54  function subnavtext($text, $link, $is, $should, $getback=1, $js='') {
  55      //generate subnavigation based on text
  56      $id = "subnavid".randpassword(5);
  57      $sn = '';
  58      if($is == $should) {
  59          $sn .= '<tr><td><img src="img/subnav/subnav_B.gif" width="15" height="13" border="0" alt="" /></td>';    
  60          $sn .= '<td class="subnavactive"><a href="'.$link.'">'.$text.'</a></td></tr>';
  61      } else {
  62          $sn .= "<tr><td><img name=\"".$id."\" src=\"img/subnav/subnav_A.gif\" width=\"15\" height=\"13\" border=\"0\" alt=\"\" /></td>";
  63          $sn .= "<td class=\"subnavinactive\"><a href=\"".$link."\" ".$js;
  64          $sn .= "onMouseOver=\"".$id.".src='img/subnav/subnav_B.gif'\" onMouseOut=\"".$id;
  65          $sn .= ".src='img/subnav/subnav_A.gif'\">".$text."</a></td></tr>";
  66      }
  67      $sn .= "\n";
  68      if(!$getback) { 
  69          return $sn; 
  70      } else {
  71          echo $sn;
  72      }
  73  }
  74  
  75  function subnavtextext($text, $link, $target='_blank', $getback=1) {
  76      //generate subnavigation based on text and links to new page
  77      $id  = 'subnavid'.randpassword(5);
  78      $sn  = '<tr><td><img src="img/subnav/subnav_A.gif" width="15" height="13" border="0" name="'.$id.'" alt="" /></td>';    
  79      $sn .= '<td class="subnavinactive"><a href="'.$link.'" target="'.$target.'" ';
  80      $sn .= "onMouseOver=\"".$id.".src='img/subnav/subnav_B.gif'\" onMouseOut=\"".$id.".src='img/subnav/subnav_A.gif'\"";
  81      $sn .= '>'.$text.'</a></td></tr>';
  82      $sn .= "\n";
  83      if(!$getback) { return $sn; } else { echo $sn; }
  84  }
  85  
  86  function subnavback($text, $link, $h_before=0, $h_after=0) {
  87      $id = "subbackid".randpassword(5);
  88      $sn  = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
  89      $sn .= (intval($h_before)) ? "<tr><td colspan=\"2\"><img src=\"img/leer.gif\" width=\"1\" height=\"".intval($h_before)."\" alt=\"\" /></td></tr>\n" : "";
  90      $sn .= "<tr>";
  91      $sn .= "<td><img name=\"".$id."\" src=\"img/subnav/subnav_back_0.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" /></td>";
  92      $sn .= "<td class=\"subnavinactive\">&nbsp;<a href=\"".$link."\" onMouseOver=\"".$id.".src='img/subnav/subnav_back_1.gif'\" ";
  93      $sn .= "onMouseOut=\"".$id.".src='img/subnav/subnav_back_0.gif'\"><strong>".$text."</strong></a></td>";
  94      $sn .= "</tr>\n";
  95      $sn .= (intval($h_after)) ? "<tr><td colspan=\"2\"><img src=\"img/leer.gif\" width=\"1\" height=\"".intval($h_after)."\" alt=\"\" /></td></tr>\n" : "";
  96      $sn .= "</table>\n";
  97      echo $sn;
  98  }
  99  
 100  function clearfilename($formvar) {
 101      //Filename anpassen und säubern
 102      $formvar = trim($formvar);
 103      if( get_magic_quotes_gpc() ) $formvar = stripslashes ($formvar);
 104      $formvar = str_replace(array("'", ':', '/', '\\', '"'), '_', $formvar);
 105      return $formvar;
 106  }
 107  
 108  function check_image_extension($file, $filename='') {
 109      // only checks against correct image extension
 110      $image_info    = getimagesize($file);    
 111      $result        = false;
 112      if(false != $image_info) {
 113          switch($image_info[2]) {
 114              case  1: $result = 'gif';    break;
 115              case  2: $result = 'jpg';    break;
 116              case  3: $result = 'png';    break;
 117              case  4: $result = 'swf';    break;
 118              case  5: $result = 'psd';    break;
 119              case  6: $result = 'bmp';    break;
 120              case  7: $result = 'tif';    break; //(intel byte order), 
 121              case  8: $result = 'tif';    break; //(motorola byte order), 
 122              case  9: $result = 'jpc';    break;
 123              case 10: $result = 'jp2';    break;
 124              case 11: $result = 'jpx';    break;
 125              case 12: $result = 'jb2';    break;
 126              
 127              case 13: // there is a problem in some cases swf -> swc ? why ever!
 128                       // do an additional extension check and compare against swf
 129                       $result = (strtolower(which_ext($file)) == 'swf') ? 'swf' : 'swc';
 130                       break;
 131              
 132              case 14: $result = 'iff';    break;
 133  
 134              case 15: // there seems to be a problem with getimagesize and Quicktime VR
 135                       // mov -> wmbf ? why ever!
 136                       // do an additional extension check and compare against mov
 137                       $result = (strtolower(which_ext( empty($filename) ? $file : $filename )) == 'mov') ? 'mov' : 'wbmp';
 138                       break;
 139  
 140              case 16: $result = 'xbm';    break;
 141          }
 142      }    
 143      return $result;
 144  }
 145  
 146  function getParentStructArray($structID) {
 147      $structID    = intval($structID);
 148      $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_id=".$structID." LIMIT 1";
 149      if($result = mysql_query($sql, $GLOBALS['db'])) {
 150          if($row = mysql_fetch_assoc($result)) {
 151              return $row;
 152          }
 153          mysql_free_result($result);
 154      }
 155      return $GLOBALS['indexpage'];
 156  }
 157  
 158  /*
 159   * Get sort value for an article based on category
 160   */
 161  function getArticleSortValue($cat_id=0) {
 162      
 163      // default sort value
 164      $sort        = 0;
 165      $cat_id        = intval($cat_id);
 166      $count        = 0;
 167      $max_sort    = 0;
 168      // Count all articles within the given structure ID
 169      $sql  = "SELECT article_id, article_sort FROM ".DB_PREPEND."phpwcms_article ";
 170      $sql .= "WHERE article_cid=".$cat_id." ";
 171      $sql .= "ORDER BY article_sort DESC";
 172      if($result = mysql_query($sql, $GLOBALS['db'])) {
 173          // this is the max articles in structure
 174          $count = mysql_num_rows($result);
 175          // but neccessary trying to get the highest article sort value
 176          if($row = mysql_fetch_assoc($result)) {
 177              $max_sort = $row['article_sort'];
 178          }
 179          mysql_free_result($result);
 180      }
 181      $count = ($count + 1) * 10;
 182      $count = ($max_sort < $count) ? $count : $max_sort + 10;
 183      return $count;
 184  }
 185  
 186  /*
 187   * Make a re-sort for given structure ID and 
 188   * return new sorted articles as array
 189   */
 190  function getArticleReSorted(& $cat_id, & $ordered_by) {
 191      
 192      // get all articles including deleted and update sorting
 193      // in correct sort order by adding sort + 10
 194      $sort                = 10;
 195      $sort_multiply_by    = 1;
 196      $count_article        = 0;
 197      $ao                 = get_order_sort($ordered_by);
 198      
 199      $sql  = "SELECT article_id, article_cid, article_title, article_public, article_aktiv, article_uid, ";
 200      $sql .= "date_format(article_tstamp, '%Y-%m-%d %H:%i:%s') AS article_date, article_sort, article_deleted, article_tstamp ";
 201      $sql .= "FROM ".DB_PREPEND."phpwcms_article ";
 202      $sql .= "WHERE article_cid='".$cat_id."' ORDER BY ".$ao[2];
 203      
 204      if($result = mysql_query($sql, $GLOBALS['db'])) {
 205      
 206          // now check if it's sorted manually and DESC
 207          // then sort has to be lowerd by -10
 208          if($ao[0] == 0 && $ao[1] == 1) {
 209              $max_article_count    = mysql_num_rows($result);
 210              $sort                 = ($max_article_count + 1) * 10;
 211              $sort_multiply_by    = -1;
 212          }
 213      
 214          // take all entries and build new array with it
 215          while($row = mysql_fetch_assoc($result)) {
 216  
 217              // SQL update query with new sort value
 218              $update_sql  = "UPDATE ".DB_PREPEND."phpwcms_article SET ";
 219              $update_sql .= "article_sort=".$sort.", ";
 220              $update_sql .= "article_tstamp='".$row['article_tstamp']."' ";
 221              $update_sql .= "WHERE article_id=".$row['article_id']." LIMIT 1";
 222              @mysql_query($update_sql, $GLOBALS['db']);
 223  
 224              // add entry to the returning array only for article_deleted=0
 225              // drops all deleted articles or articles having another status
 226              if($row['article_deleted'] == 0) {
 227              
 228                  $article[$count_article]                    = $row;
 229                  $article[$count_article]['article_sort']    = $sort;
 230                          
 231                  // count up for article array index
 232                  $count_article++;
 233                  
 234              }
 235  
 236              // count sort up by 10
 237              $sort = $sort + (10 * $sort_multiply_by);
 238  
 239          }
 240          mysql_free_result($result);
 241      }
 242  
 243      return $article;    
 244  
 245  }
 246  
 247  function phpwcmsversionCheck() {
 248  
 249      // Check for new version
 250      
 251      global $phpwcms;
 252      global $BL;
 253      
 254      if(empty($phpwcms['version_check'])) return '';
 255  
 256      $errno                         = 0;
 257      $errstr                     = '';
 258      $version_info                = '';
 259  
 260      if ($fsock = @fsockopen('www.phpwcms.de', 80, $errno, $errstr, 10))    {
 261  
 262          $identify = '?version='.rawurlencode(PHPWCMS_VERSION.'-'.str_replace('/', '', PHPWCMS_RELEASE_DATE)).'&hash='.md5($_SERVER['REQUEST_URI']);
 263      
 264          @fputs($fsock, "GET /versioncheck/phpwcms_releaseinfo.txt".$identify." HTTP/1.1\r\n");
 265          @fputs($fsock, "HOST: www.phpwcms.de\r\n");
 266          @fputs($fsock, "Connection: close\r\n\r\n");
 267  
 268          $get_info = false;
 269          while (!@feof($fsock)) {
 270              if ($get_info) {
 271                  $version_info .= @fread($fsock, 1024);
 272              } else {
 273                  if (@fgets($fsock, 1024) == "\r\n") {
 274                      $get_info = true;
 275                  }
 276              }
 277          }
 278          @fclose($fsock);
 279  
 280          $version_info        = explode("\n", $version_info);
 281          
 282          $latest_version        = trim($version_info[0]);
 283          $latest_revdate        = trim($version_info[1]);
 284          $latest_revision    = intval(trim($version_info[2]));
 285  
 286          // do version check
 287          $check = $latest_revision > $phpwcms['revision'] ? false : true;
 288          
 289          
 290          if ($check)    {
 291              $version_info  = '<p class="valid">' . $BL['Version_up_to_date'] . '</p>';
 292              $version_info .= '<p class="valid">'.sprintf($BL['Latest_version_info'], $latest_version.' ('.$latest_revdate.', r'.$latest_revision.')'). ' ';
 293              $version_info .= sprintf($BL['Current_version_info'], PHPWCMS_VERSION.' ('.PHPWCMS_RELEASE_DATE.', r'.PHPWCMS_REVISION.')') . '</p>';
 294          
 295          } else {
 296              $version_info  = '<p class="error">' . $BL['Version_not_up_to_date'] . '</p>';
 297              $version_info .= '<p class="error">'.sprintf($BL['Latest_version_info'], ' ' . $latest_version . ' ('.$latest_revdate.', r'.$latest_revision.')'). ' ';
 298              $version_info .= sprintf($BL['Current_version_info'], PHPWCMS_VERSION.' ('.PHPWCMS_RELEASE_DATE.', r'.PHPWCMS_REVISION.')') . '</p>';
 299  
 300          }
 301          
 302  
 303      } else {
 304      
 305          if ($errstr) {
 306              $version_info = '<p class="error">' . sprintf($BL['Connect_socket_error'], $errstr) . '</p>';
 307          } else {
 308              $version_info = '<p>' . $BL['Socket_functions_disabled'] . '</p>';
 309          }
 310      }
 311      
 312      //$version_info .= '<p>' . $BL['Mailing_list_subscribe_reminder'] . '</p>';
 313  
 314      return '<div class="versioncheck"><h1>'.$BL['Version_information'].'</h1> '.$version_info.'</div>';
 315  
 316  }
 317  
 318  
 319  function createOptionTransferSelectList($id='', $leftData, $rightData, $option = array()) {
 320      // used to create
 321      
 322      global $BL;
 323  
 324      $id_left                = $id.'_left';
 325      $id_right                = $id.'_right';
 326      $id_left_box            = $id_left.'list';
 327      $id_right_box            = $id_right.'list';
 328      $option_object            = generic_string(4, 4);
 329      
 330      $table                    = '';
 331      
 332      $option['rows']            = empty($option['rows']) || !intval($option['rows']) ? 5 : $option['rows'];
 333      $option['delimeter']    = empty($option['delimeter']) ? ',' : $option['delimeter'];
 334      $option['encode']        = (isset($option['encode']) && $option['encode'] === false) ? false : true;
 335      $option['style']        = empty($option['style']) ? '' : ' style="'.$option['style'].'"';
 336      $option['class']        = empty($option['class']) ? ' class="#SIDE#"' : ' class="#SIDE# '.$option['class'].'"';
 337      $option['formname']        = empty($option['formname']) ? 'document.forms[0]' : 'document.getElementById(\''.$option['formname'].'\')';
 338      
 339      
 340      $GLOBALS['BE']['HEADER']['optionselect.js'] = getJavaScriptSourceLink('include/inc_js/optionselect.js');
 341      
 342      $table .= '<table border="0" cellspacing="0" cellpadding="0">'.LF.'<tr>'.LF;
 343      
 344      // left select list
 345      $table .= '<td valign><select name="'.$id_left_box.'" id="'.$id_left_box.'" size="'.$option['rows'].'" multiple="multiple"';
 346      $table .= $option['style'].str_replace('#SIDE#', 'leftSide', $option['class']).' ondblclick="'.$option_object.'.transferRight()">'.LF;
 347      if(!empty($leftData) && is_array($leftData)) {
 348          foreach($leftData as $key => $value) {
 349              $table .= '        <option value="'.$key.'">'.$value.'</option>'.LF;
 350          }
 351      }    $table .= '</select></td>'.LF;
 352      
 353      // left <-> right buttons
 354      $table .= '<td'.$option['style'].$option['class'].'>';
 355      $table .= '<img src="img/leer.gif" alt="" width="1" height="1" />'.LF;
 356      $table .= '</td>'.LF;
 357      
 358      // right select list
 359      $table .= '<td><select name="'.$id_right_box.'" id="'.$id_right_box.'" size="'.$option['rows'].'" multiple="multiple"';
 360      $table .= $option['style'].str_replace('#SIDE#', 'rightSide', $option['class']).' ondblclick="'.$option_object.'.transferLeft()">'.LF;
 361      if(!empty($rightData) && is_array($rightData)) {
 362          foreach($rightData as $key => $value) {
 363              $table .= '        <option value="'.$key.'">'.$value.'</option>'.LF;
 364          }
 365      }
 366      $table .= '</select></td>'.LF;
 367      $table .= '</tr>'.LF;
 368      
 369      $table .= '<tr>'.LF.'<td>';
 370      $table .= '<img src="img/button/list_pos_up.gif" alt="" border="0" onclick="moveOptionUp('.$option['formname'].'.'.$id_left_box.');'.$option_object.'.update();">';
 371      $table .= '<img src="img/leer.gif" width="2" height="2" alt="" />';
 372      $table .= '<img src="img/button/list_pos_down.gif" alt="" border="0" onclick="moveOptionDown('.$option['formname'].'.'.$id_left_box.');'.$option_object.'.update();">';
 373      $table .= '<img src="img/leer.gif" width="4" height="4" alt="" />';
 374      $table .= '<img src="img/button/put_right_a.gif" alt="Move selected to right" border="0" onclick="'.$option_object.'.transferRight();" />';
 375      $table .= '<img src="img/leer.gif" width="2" height="2" alt="" />';
 376      $table .= '<img src="img/button/put_right.gif" alt="Move all to right" border="0" onclick="'.$option_object.'.transferAllRight();"/>';
 377      $table .= '</td>'.LF;
 378      
 379      $table .= '<td><img src="img/leer.gif" alt="" width="1" height="1" /></td>'.LF;
 380      
 381      $table .= '<td>';
 382      $table .= '<img src="img/button/put_left_a.gif" alt="Move selected to left" border="0" onclick="'.$option_object.'.transferLeft();" />';
 383      $table .= '<img src="img/leer.gif" width="2" height="2" alt="" />';
 384      $table .= '<img src="img/button/put_left.gif" alt="Move all to left" border="0" onclick="'.$option_object.'.transferAllLeft();" />';
 385      $table .= '</td>'.LF;
 386      
 387      $table .= '</tr>'.LF.'</table>'.LF;
 388      
 389      $table .= '<input type="hidden" name="'.$id_left.'" id="'.$id_left.'" value="" />';
 390      $table .= '<input type="hidden" name="'.$id_right.'" id="'.$id_right.'" value="" />';
 391      
 392      $table .= '<script language="javascript">'.LF;
 393      $table .= SCRIPT_CDATA_START.LF;
 394      $table .= '    var '.$option_object.' = new OptionTransfer("'.$id_left_box.'","'.$id_right_box.'");'.LF;
 395      $table .= '    '.$option_object.'.setAutoSort(false);'.LF;
 396      $table .= '    '.$option_object.'.setDelimiter("'.$option['delimeter'].'");'.LF;
 397      $table .= '    '.$option_object.'.saveNewLeftOptions("'.$id_left.'");'.LF;
 398      $table .= '    '.$option_object.'.saveNewRightOptions("'.$id_right.'");'.LF;
 399      $table .= '    '.$option_object.'.init('.$option['formname'].');'.LF;
 400      
 401      $table .= LF.SCRIPT_CDATA_END.LF;
 402      $table .= '</script>'.LF;
 403  
 404      return $table;
 405  }
 406  
 407  function countNewsletterRecipients($target) {
 408      // try to count all recipients for special newsletter
 409      $recipients    = _dbQuery('SELECT * FROM '.DB_PREPEND.'phpwcms_address WHERE address_verified=1');
 410      $counter    = 0;
 411      $check        = (empty($target) || !is_array($target) || !count($target)) ? false : true;
 412      foreach($recipients as $value) {
 413          if(empty($value['address_subscription'])) {
 414              $counter++;
 415              continue;
 416          } elseif($check) {
 417              $value['address_subscription'] = unserialize($value['address_subscription']);
 418              if(is_array($value['address_subscription'])) {
 419                  foreach($value['address_subscription'] as $subscr) {
 420                      if(in_array(intval($subscr), $target)) {
 421                          $counter++;
 422                          break;
 423                      }
 424                  }
 425              }
 426          }
 427      }
 428      return $counter;
 429  }
 430  
 431  function getContentPartOptionTag($value='', $text='', $selected='', $module='') {
 432  
 433      $result = '';
 434      
 435  
 436      // neccessary plugin check
 437      if($value == 30) {
 438      
 439          if(!isset($GLOBALS['temp_count'])) {
 440              $GLOBALS['temp_count'] = 0;
 441          }
 442      
 443          foreach($GLOBALS['phpwcms']['modules'] as $module_value) {
 444          
 445              if($module_value['cntp'] && file_exists($module_value['path'].'inc/cnt.list.php')) {
 446                  $result .= '<option value="'.$value.':'.$module_value['name'].'"';
 447                  if($value == $selected && $module_value['name'] == $module) {
 448                      $result .= ' selected="selected"';
 449                      $GLOBALS['contentpart_temp_selected'] = $GLOBALS['temp_count'];
 450                  }
 451                  $result .= '>'.$text;
 452                  $result .= ': '.$GLOBALS['BL']['modules'][ $module_value['name'] ]['listing_title'];
 453                  $result .= '</option>'.LF;
 454                  $GLOBALS['temp_count']++;
 455              }
 456          
 457          }
 458      
 459      } else {
 460      
 461          $result .= '<option value="'.$value.'"';
 462          if($value == $selected) {
 463              $result .= ' selected="selected"';
 464              $GLOBALS['contentpart_temp_selected'] = $GLOBALS['temp_count'];
 465          }
 466          $result .= '>'.$text.'</option>'.LF;
 467      
 468      }
 469      
 470      return $result;
 471  
 472  }
 473  
 474  function isContentPartSet($value='') {
 475      
 476      $value = explode(':', $value);
 477      $value[0] = intval($value[0]);
 478      
 479      // check for set module
 480      if(empty($value[1])) {
 481  
 482          $value[1] = 1;
 483          
 484      } elseif(        isset($GLOBALS['phpwcms']['modules'][$value[1]]) 
 485                  &&    $GLOBALS['phpwcms']['modules'][$value[1]]['cntp']
 486                  &&    file_exists($GLOBALS['phpwcms']['modules'][$value[1]]['path'].'inc/cnt.list.php')) {
 487          
 488          $value[1] = 1;
 489      
 490      } else {
 491      
 492          $value[1] = 0;
 493      
 494      }
 495      
 496      // check if content part ID exists
 497      if(isset($GLOBALS['wcs_content_type'][ $value[0] ]) && $value[1]) {
 498      
 499          return true;
 500      
 501      } else {
 502      
 503          return false;
 504      
 505      }
 506  
 507  }
 508  
 509  /*
 510   *    Show System Status Message
 511   */
 512  function show_status_message($return_status=false) {
 513      if(empty($_SESSION['system_status']['msg'])) {
 514          $status = '';
 515      } else {
 516          $status  = '<div class="status_message_' . $_SESSION['system_status']['type'] .'">';
 517          $status .= nl2br( trim( html_specialchars($_SESSION['system_status']['msg']) ) ) . '</div>';
 518          $_SESSION['system_status']['msg'] = '';
 519      }
 520      if($return_status) {
 521          return $status;
 522      } else {
 523          echo $status;
 524          return NULL;
 525      }
 526  }
 527  /*
 528   *    Set System Status Message
 529   */
 530  function set_status_message($msg='', $type='info', $replace=array()) {
 531      if(is_array($replace) && count($replace)) {
 532          foreach($replace as $key => $item) {
 533              $msg = str_replace('{'.strtoupper($key).'}', $item, $msg);
 534          }
 535      }
 536      $_SESSION['system_status']['msg']  = $msg;
 537      switch($type) {
 538          case 'success':
 539          case 'info':
 540          case 'help':
 541          case 'error':
 542          case 'warning':    break;
 543          default: $type = 'info';
 544      }
 545      $_SESSION['system_status']['type'] = $type;
 546      return NULL;
 547  }
 548  
 549  function set_language_cookie() {
 550      setcookie('phpwcmsBELang', $_SESSION["wcs_user_lang"], time()+(3600*24*365), '/', getCookieDomain() );
 551  }
 552  
 553  // checks for alias and sets unique value
 554  function proof_alias($current_id, $alias='', $mode='CATEGORY') {
 555  
 556      $current_id    = intval($current_id);
 557      $alias        = uri_sanitize( clean_slweg(strtolower($alias), 150) );
 558      $reserved    = array(
 559          'print',
 560          'newsdetail',
 561          'newspage',
 562          'id',
 563          'aid',
 564          'subgallery',
 565          'listpage',
 566          'page',
 567          'subscribe',
 568          'unsubscribe',
 569          'email',
 570          'u',
 571          's',
 572          'q',
 573          'feedimport'
 574      );
 575  
 576      if($mode == 'CATEGORY' && $alias == '' && isset($_POST["acat_name"])) {
 577          $alias = $_POST["acat_name"];
 578          $set = true;
 579      } elseif($mode == 'ARTICLE' && $alias == '' && isset($_POST["article_title"])) {
 580          $alias = $_POST["article_title"];
 581          $set = true;
 582      } elseif($mode == 'CONTENT' && $alias == '' && ( isset($_POST["cnt_title"]) || isset($_POST["cnt_name"]) )) {
 583          $alias = trim($_POST["cnt_title"]) == '' ? $_POST["cnt_name"] : $_POST["cnt_title"];
 584          $set = true;
 585      } else {
 586          $set = false;
 587      }
 588      
 589      if($set) {
 590          $alias = clean_slweg(strtolower($alias), 150);
 591          $alias = pre_remove_accents($alias);
 592          $alias = get_alnum_dashes($alias, true);
 593          if($alias != '') {
 594              $alias        = trim( preg_replace('/\-\-+/', '-', $alias), '-' );
 595              $alias        = trim( preg_replace('/__+/', '_', $alias), '_' );
 596          }
 597      }
 598      
 599      // new reserved alias can be defined in $phpwcms['reserved_alias']
 600      if( isset($phpwcms['reserved_alias']) && is_array($phpwcms['reserved_alias']) && count($phpwcms['reserved_alias']) ) {
 601          $reserved = array_merge($reserved, $phpwcms['reserved_alias']);
 602      }
 603      
 604      if( $alias == '' || in_array($alias, $reserved) || ($alias == 'index' && $current_id != 'index') ) {
 605      
 606          if($mode == 'CONTENT') {
 607              $alias .= date('-Y-n-j');
 608          } else {
 609              $alias .= '-view';
 610          }
 611      }
 612      
 613      $alias = trim( $alias, '-' );
 614  
 615      $where_acat        = '';
 616      $where_article    = '';
 617      $where_content    = '';
 618  
 619      switch($mode) {
 620          case 'CATEGORY':    $where_acat        = 'acat_id != '.$current_id.' AND ';    break;
 621          case 'ARTICLE':        $where_article    = 'article_id != '.$current_id.' AND ';    break;
 622          case 'CONTENT':        $where_content    = 'cnt_id != '.$current_id.' AND ';        break;
 623      }
 624      
 625      // check alias against all structure alias
 626      $sql  = "SELECT COUNT(acat_id) FROM ".DB_PREPEND."phpwcms_articlecat WHERE ";
 627      $sql .= $where_acat;
 628      $sql .= "acat_alias='".aporeplace($alias)."'";
 629      $acat_count = _dbQuery($sql, 'COUNT');
 630      
 631      // check alias against all articles
 632      $sql  = "SELECT COUNT(article_id) FROM ".DB_PREPEND."phpwcms_article WHERE ";
 633      $sql .= $where_article;
 634      $sql .= "article_alias='".aporeplace($alias)."'";
 635      $article_count = _dbQuery($sql, 'COUNT');
 636      
 637      // check alias against all "sub" contents like news
 638      $sql  = "SELECT COUNT(cnt_id) FROM ".DB_PREPEND."phpwcms_content WHERE ";
 639      $sql .= $where_content;
 640      $sql .= "cnt_alias='".aporeplace($alias)."'";
 641      $content_count = _dbQuery($sql, 'COUNT');
 642  
 643      if( $acat_count > 0 || $article_count > 0 || $content_count > 0 ) {
 644      
 645          $sql  = "SELECT acat_alias FROM ".DB_PREPEND."phpwcms_articlecat WHERE ";
 646          $sql .= $where_acat;
 647          $sql .= "acat_alias LIKE '".aporeplace($alias)."%'";
 648          $all_acat_alias = _dbQuery($sql);
 649          
 650          $sql  = "SELECT article_alias FROM ".DB_PREPEND."phpwcms_article WHERE ";
 651          $sql .= $where_article;
 652          $sql .= "article_alias LIKE '".aporeplace($alias)."%'";
 653          $all_article_alias = _dbQuery($sql);
 654          
 655          $sql  = "SELECT cnt_alias FROM ".DB_PREPEND."phpwcms_content WHERE ";
 656          $sql .= $where_content;
 657          $sql .= "cnt_alias LIKE '".aporeplace($alias)."%'";
 658          $all_content_alias = _dbQuery($sql);
 659  
 660          $all_alias = array();
 661          foreach($all_acat_alias as $item) {
 662              $item = $item['acat_alias'];
 663              $all_alias[$item] = $item;
 664          }
 665          foreach($all_article_alias as $item) {
 666              $item = $item['article_alias'];
 667              $all_alias[$item] = $item;
 668          }
 669          foreach($all_content_alias as $item) {
 670              $item = $item['cnt_alias'];
 671              $all_alias[$item] = $item;
 672          }
 673          $all_alias_count = count($all_alias);
 674          while( isset( $all_alias[ $alias.'-'.$all_alias_count ] ) ) {
 675              $all_alias_count++;
 676          }
 677                  
 678          if(preg_match('/\-(\d+)$/', $alias)) {
 679              $alias .= $all_alias_count;
 680          } else {
 681              $alias .= '-'.$all_alias_count;
 682          }
 683      }
 684      
 685      return $alias;
 686  }
 687  
 688  function _getTime($time='', $delimeter=':', $default_time='H:i:s') {
 689  
 690      $timeformat        = explode($delimeter, trim($default_time));
 691      $time            = explode($delimeter, trim($time));
 692      
 693      $hour            = 0;
 694      $minute            = 0;
 695      $second            = 0;
 696      
 697      for($x=0; $x<=2; $x++) {
 698      
 699          if(isset($timeformat[$x])) {
 700          
 701              $value = trim($timeformat[$x]);
 702              switch( $value{0} ) {
 703              
 704                  case 'H':     if(isset($time[$x])) {
 705                                  $hour = intval($time[$x]);
 706                                  if($hour < 0 || $hour > 23) $hour = 0;
 707                              }
 708                              break;
 709                              
 710                  case 'i':     if(isset($time[$x])) {
 711                                  $minute = intval($time[$x]);
 712                                  if($minute < 0 || $minute > 59) $minute = 0;
 713                              }
 714                              break;
 715                              
 716                  case 's':     if(isset($time[$x])) {
 717                                  $second = intval($time[$x]);
 718                                  if($second < 0 || $second > 59) $second = 0;
 719                              }
 720                              break;
 721              }
 722          
 723          }
 724      
 725      }
 726      
 727      $time = str_replace($delimeter, ':', $default_time);
 728      $time = str_replace('H', $hour, $time);
 729      $time = str_replace('i', $minute, $time);
 730      $time = str_replace('s', $second, $time);
 731  
 732      return $time;
 733  }
 734  
 735  function _getDate($date='', $delimeter='', $default_date='') {
 736  
 737      global $BL;
 738      
 739      $delimeter        = $delimeter == '' ? $BL['default_date_delimiter'] : $delimeter;
 740      $default_date    = $default_date == '' ? $BL['default_date'] : $default_date;
 741      
 742      $dateformat        = explode($delimeter, trim($default_date));
 743      $date            = explode($delimeter, trim($date));
 744      
 745      $day            = '';
 746      $month            = '';
 747      $year            = '';
 748      
 749      for($x=0; $x<=2; $x++) {
 750      
 751          if(isset($dateformat[$x])) {
 752          
 753              $value = trim($dateformat[$x]);
 754              $value = strtolower($value);
 755              switch( $value{0} ) {
 756              
 757                  case 'y':     if(isset($date[$x])) {
 758                                  $year = intval($date[$x]);
 759                                  if($year < 0) $year = '';
 760                              }
 761                              break;
 762                              
 763                  case 'd':     if(isset($date[$x])) {
 764                                  $day = intval($date[$x]);
 765                                  if($day < 1 || $day > 31) $day = '';
 766                              }
 767                              break;
 768                              
 769                  case 'm':     if(isset($date[$x])) {
 770                                  $month = intval($date[$x]);
 771                                  if($month < 1 || $month > 12) $month = '';
 772                              }
 773                              break;
 774              
 775              }
 776          
 777          }
 778      
 779      }
 780      
 781      if($year && $month && $day) {
 782      
 783          return $year.'-'.$month.'-'.$day;
 784      
 785      } else {
 786      
 787          return '0000-00-00';
 788      
 789      }
 790      
 791  }
 792  
 793  function _dbSaveCategories($categories=array(), $type='', $pid=0, $seperator=',') {
 794  
 795      $pid    = intval($pid);
 796      $type    = trim($type);
 797      
 798      if(is_string($categories)) {
 799          $categories = convertStringToArray($categories, $seperator);
 800      }
 801      
 802      // delete all related categories first
 803      if($type && $pid) {
 804          
 805          $sql = 'DELETE FROM '.DB_PREPEND.'phpwcms_categories WHERE cat_pid='.$pid." AND cat_type='".aporeplace( $type )."'";
 806          _dbQuery($sql, 'DELETE');
 807      
 808      }
 809  
 810      if(is_array($categories) && count($categories) && $type && $pid) {
 811      
 812          $data = array(    'cat_type'            => $type,
 813                          'cat_pid'             => $pid,
 814                          'cat_status'        => 1,
 815                          'cat_createdate'    => date('Y-m-d H:i:s'),
 816                          'cat_changedate'    => date('Y-m-d H:i:s'),
 817                          'cat_name'            => '',
 818                          'cat_info'            => ''
 819                          );
 820      
 821          foreach($categories as $value) {
 822              $value = trim($value);
 823              if($value != '') {
 824                  
 825                  $data['cat_name'] = $value;
 826                  _dbInsert('phpwcms_categories', $data);
 827                  
 828              }
 829          }
 830      }
 831  }
 832  
 833  function setItemsPerPage($default=25) {
 834      if( isset($_GET['showipp']) ) {
 835          $ipp = intval( is_numeric($_GET['showipp']) ? $_GET['showipp'] : $default );
 836          setcookie('phpwcmsBEItemsPerPage', $ipp, time()+157680000, '/', getCookieDomain() );
 837      } elseif(isset($_SESSION['PAGE_FILTER'])) {
 838          $ipp = $_SESSION['PAGE_FILTER']['IPP'];
 839      } elseif( isset($_COOKIE['phpwcmsBEItemsPerPage']) ) {
 840          $ipp = intval( $_COOKIE['phpwcmsBEItemsPerPage'] );
 841      } else {
 842          $ipp = $default;
 843      }
 844      
 845      if(!isset($_SESSION['PAGE_FILTER'])) {
 846          $_SESSION['PAGE_FILTER'] = array();
 847      }
 848      
 849      $_SESSION['PAGE_FILTER']['IPP'] = $ipp;
 850      
 851      return $ipp;
 852  }
 853  
 854  function getItemsPerPageMenu($base_url='', $steps=array(10,25,50,100,250,0), $separator=' ') {
 855  
 856      $ipp = isset($_SESSION['PAGE_FILTER']['IPP']) ? $_SESSION['PAGE_FILTER']['IPP'] : setItemsPerPage();
 857      
 858      if(!in_array($ipp, $steps)) {
 859          array_unshift($steps, $ipp);
 860      }
 861      
 862      $menu = array();
 863      $x = 0;
 864      foreach($steps as $item) {
 865      
 866          $menu[$x]  = '<a href="'.$base_url.'&amp;showipp='.$item.'"';
 867          if($ipp == $item) {
 868              $menu[$x] .= ' class="active"';
 869          }
 870          $menu[$x] .= '>';
 871          $menu[$x] .= $item == 0 ? $GLOBALS['BL']['be_ftptakeover_all'] : $item;
 872          $menu[$x] .= '</a>';
 873      
 874          $x++;
 875      }
 876      
 877      return implode($separator, $menu);
 878  }
 879  
 880  function initJsCalendar() {
 881      $GLOBALS['BE']['HEADER']['date.js']            = getJavaScriptSourceLink('include/inc_js/date.js');
 882      $GLOBALS['BE']['HEADER']['dynCalendar.js']    = getJavaScriptSourceLink('include/inc_js/dynCalendar.js');
 883  }
 884  function initMootools($mode='1.1', $more=array()) {
 885      switch($mode) {
 886          // MooTools 1.1
 887          case '1.1':
 888              $GLOBALS['BE']['HEADER']['mootools.js'] = getJavaScriptSourceLink(TEMPLATE_PATH.'lib/mootools/mootools-1.1-yc.js');
 889              break;
 890              
 891          // MooTools 1.2 + More
 892          default:
 893              unset($GLOBALS['BE']['HEADER']['mootools.js']);
 894              $GLOBALS['BE']['HEADER']['mootools-1.2-core.js'] = getJavaScriptSourceLink(TEMPLATE_PATH.'lib/mootools/mootools-1.2-core-yc.js');
 895              
 896              if(is_array($more) && count($more)) {
 897                  array_unshift($more, 'Core/More');
 898                  foreach($more as $item) {
 899                      $name = 'mootools-more-'.$item;
 900                      if(empty($GLOBALS['BE']['HEADER'][$name]) && is_file(PHPWCMS_TEMPLATE.'lib/mootools/more/'.$item.'.js')) {
 901                          $GLOBALS['BE']['HEADER'][$name] = getJavaScriptSourceLink(TEMPLATE_PATH.'lib/mootools/more/'.$item.'.js');
 902                      }
 903                  }
 904              }
 905      }
 906      $GLOBALS['phpwcms']['mootools_mode'] = $mode;
 907  }
 908  function initMootoolsAutocompleter($mode='1.1') {
 909      initMootools($mode);
 910      $GLOBALS['BE']['HEADER']['Autocompleter.js']        = getJavaScriptSourceLink('include/inc_js/mootools/cnet/Autocompleter.js');
 911      $GLOBALS['BE']['HEADER']['Autocompleter.Remote.js']    = getJavaScriptSourceLink('include/inc_js/mootools/cnet/Autocompleter.Remote.js');
 912      $GLOBALS['BE']['HEADER']['Observer.js']                = getJavaScriptSourceLink('include/inc_js/mootools/cnet/Observer.js');
 913  }
 914  function initJsOptionSelect() {
 915      $GLOBALS['BE']['HEADER']['optionselect.js']    = getJavaScriptSourceLink('include/inc_js/optionselect.js');
 916  }
 917  function initMultipleUpload($mode='1.2') {
 918      switch($mode) {
 919          case '1.1':
 920              initMootools('1.1');
 921              $GLOBALS['BE']['HEADER']['Swiff.Base.js']        = getJavaScriptSourceLink('include/inc_js/mootools/FancyUpload/v1/Swiff.Base.js');
 922              $GLOBALS['BE']['HEADER']['Swiff.Uploader.js']    = getJavaScriptSourceLink('include/inc_js/mootools/FancyUpload/v1/Swiff.Uploader.js');
 923              $GLOBALS['BE']['HEADER']['FancyUpload.js']        = getJavaScriptSourceLink('include/inc_js/mootools/FancyUpload/v1/FancyUpload.js');
 924              break;
 925  
 926          default:
 927              initMootools('1.2');
 928              $GLOBALS['BE']['HEADER']['Swiff.Uploader.js']    = getJavaScriptSourceLink('include/inc_js/mootools/FancyUpload/Swiff.Uploader.js');
 929              $GLOBALS['BE']['HEADER']['FX.ProgressBar.js']    = getJavaScriptSourceLink('include/inc_js/mootools/FancyUpload/Fx.ProgressBar.js');
 930              $GLOBALS['BE']['HEADER']['FancyUpload2.js']        = getJavaScriptSourceLink('include/inc_js/mootools/FancyUpload/FancyUpload2.js');
 931      }
 932  }
 933  
 934  // make phpwcms compatibility and upgrade check
 935  function phpwcms_revision_check($revision) {
 936  
 937      $revision_file = PHPWCMS_ROOT.'/include/inc_lib/revision/r';
 938  
 939      // loop while trying to find the latest revision file (for r407 and up)
 940      // then there is no need to implement new revision updater for each revision
 941      while(!is_file( $revision_file . $revision.'.php')) {
 942          $revision--;
 943          if($revision < 406) {
 944              return false;
 945          }
 946      }
 947  
 948      $revision_temp = phpwcms_revision_check_temp($revision);
 949      if($revision_temp === NULL) {
 950          return false;
 951      } elseif($revision_temp) {
 952          return true;
 953      }
 954      
 955      include_once($revision_file . $revision.'.php');
 956  
 957      $revision_function = 'phpwcms_revision_r'.$revision;
 958      if(function_exists($revision_function) && empty($GLOBALS['phpwcms']['check_r'.$revision])) {
 959          if( call_user_func($revision_function) !== false ) {
 960              $GLOBALS['phpwcms']['check_r'.$revision] = true;
 961              @write_textfile(PHPWCMS_TEMP.'r'.$revision.'.checked.tmp', date('Y-d-m H:i:s'));
 962              return true;
 963          } else {
 964              return false;
 965          }
 966      }
 967  
 968      return true;
 969  }
 970  
 971  // check upgrade temp file for current revision
 972  function phpwcms_revision_check_temp($revision) {
 973      if(empty($revision) || !preg_match('/^\d+$/', $revision)) {
 974          return NULL;
 975      }
 976      return is_file(PHPWCMS_TEMP.'r'.$revision.'.checked.tmp');
 977  }
 978  
 979  /*
 980   * Parse backend for language related BBCode [EN][/EN] or {EN}{/EN} unsing JavaScript
 981   * 
 982   * To enable backend language parser set config in conf.inc.php
 983   * $phpwcms['be_lang_parse'] = 'BBCode'; // to enable parsing for [EN][/EN]
 984   * $phpwcms['be_lang_parse'] = 'BraceCode'; // to enable parsing for {EN}{/EN}
 985   * $phpwcms['be_lang_parse'] = 'i18n'; // ToDo: to enable parsing for @@Default@@
 986   * $phpwcms['be_lang_parse'] = false; // to disable backend language parsing
 987   */ 
 988  function backend_language_parser() {
 989      
 990      global $phpwcms, $BE, $BL;
 991          
 992      
 993      if(!$phpwcms['be_parse_lang_process'] || empty($phpwcms['be_lang_parse'])) {
 994          
 995          return backend_language_replace('');
 996          
 997      } elseif(empty($phpwcms['allowed_lang']) || !is_array($phpwcms['allowed_lang']) || count($phpwcms['allowed_lang']) < 2) {
 998          
 999          return backend_language_replace('');
1000      
1001      } else {
1002          
1003          $parse_mode = strtoupper($phpwcms['be_lang_parse']);
1004          
1005          if(!in_array($parse_mode, array('BBCODE', 'BRACECODE'))) { // i18n later
1006              
1007              return backend_language_replace('');
1008      
1009          }
1010  
1011      }
1012      
1013      // cut main backend content innerHTML
1014      $html_pos1    = strpos($BE['HTML'], '<!--BE_MAIN_CONTENT_START//-->');
1015      $html_pos2    = strpos($BE['HTML'], '<!--BE_MAIN_CONTENT_END//-->');
1016      
1017      if($html_pos1 !== false && $html_pos2 !== false) {
1018      
1019          $html_pos1 += strlen('<!--BE_MAIN_CONTENT_START//-->');
1020          $html_pos2 -= 1;
1021          
1022      }
1023      
1024      $html        = trim( preg_replace('/\s+/', ' ', substr($BE['HTML'], $html_pos1, $html_pos2-$html_pos1) ) );
1025      $BE['HTML']    = substr($BE['HTML'], 0, $html_pos1) . substr($BE['HTML'], $html_pos2);
1026      
1027      // load MooTools too
1028      if(empty($phpwcms['mootools_mode'])) {
1029          initMootools();
1030      }
1031      
1032      // init language replacements
1033      $regexp     = array( 'search' => array(), 'replace' => array() );
1034      $bracket    = array('BBCODE_OPEN' => '[', 'BRACECODE_OPEN' => '{', 'BBCODE_CLOSE' => ']', 'BRACECODE_CLOSE' => '}');
1035      $cookie        = (empty($_COOKIE['phpwcms_be_parse_lang']) || !in_array($_COOKIE['phpwcms_be_parse_lang'], $phpwcms['allowed_lang'])) ? false : $_COOKIE['phpwcms_be_parse_lang'];
1036      
1037      // init menu
1038      $menu        = array(
1039          '<ul id="be_lang">',
1040          '<li class="be-lang-label chatlist">'.$BL['be_profile_label_lang'].':</li>',
1041          '<li><a href="#" class="be-disabled'.
1042              ($cookie === false ? ' be-active' : '').
1043              '" rel="disabled" title="'.
1044              $BL['be_profile_label_lang'].': '.$BL['be_off'].'">'.$BL['be_off'].'</a></li>'
1045      );
1046      
1047      // Header CSS section
1048      $BE['HEADER']['be_parse_lang']  = '    <style type="text/css">' . LF;
1049      
1050      // JavaScript section
1051      $BE['BODY_CLOSE']['hidden_main_content']  = '    <script type="text/javascript">' . LF;
1052      $BE['BODY_CLOSE']['hidden_main_content'] .= "        var be_lang_html = [];" . LF;
1053      $BE['BODY_CLOSE']['hidden_main_content'] .= "        var cur_be_lang = 'disabled';" . LF;
1054      $BE['BODY_CLOSE']['hidden_main_content'] .= "        be_lang_html['disabled'] = '" . trim(str_replace(array("\\", "'"), array("\\\\", "\\'"), $html)) . "';" . LF . LF;
1055      
1056      // build regular expression at first
1057      foreach($phpwcms['allowed_lang'] as $lang) {
1058          $regexp['search'][$lang]    = '/\\'.$bracket[$parse_mode.'_OPEN'].$lang.'\\'.$bracket[$parse_mode.'_CLOSE'].'(.*?)\\'.$bracket[$parse_mode.'_OPEN'].'\/'.$lang.'\\'.$bracket[$parse_mode.'_CLOSE'].'/is';
1059          $regexp['replace'][$lang]    = '';
1060      }
1061      // parse each language at second
1062      foreach($phpwcms['allowed_lang'] as $lang) {
1063          $replace        = $regexp['replace'];
1064          $replace[$lang]    = '$1';
1065          $lang_html        = preg_replace($regexp['search'], $replace, $html);
1066          
1067          $BE['HEADER']['be_parse_lang'] .= '    #be_lang a.be-lang-'.$lang.' {background-image:url(img/famfamfam/lang/'.$lang.'.png);}'.LF;
1068          
1069          
1070          $menu_item        = '<li><a href="#" class="be-lang be-lang-'.$lang;
1071          
1072          // check which is current default
1073          if($lang == $cookie) {
1074              $new_html = $lang_html;    // phpwcms should use the curent lang html
1075              $BE['BODY_CLOSE']['hidden_main_content'] .= "        cur_be_lang = '" . $lang . "';" . LF;
1076              $menu_item .= ' be-active';
1077          }
1078          
1079          $menu[] = $menu_item . '" rel="'.$lang.'" title="'.$BL['be_profile_label_lang'].': '.strtoupper($lang).'">'.$lang.'</a></li>';
1080  
1081          $BE['BODY_CLOSE']['hidden_main_content'] .= "        be_lang_html['".$lang."'] = '" . trim(str_replace(array("\\", "'"), array("\\\\", "\\'"), $lang_html)) . "';" . LF . LF;
1082      }
1083      
1084      $BE['HEADER']['be_parse_lang']             .= '    </style>';
1085      
1086      $BE['BODY_CLOSE']['hidden_main_content'] .= '    window.addEvent("domready", function() {' . LF;
1087      $BE['BODY_CLOSE']['hidden_main_content'] .= '        var be_lang = $("be_lang");' . LF;
1088      $BE['BODY_CLOSE']['hidden_main_content'] .= '        var be_lang_cnt = $("be_lang_cnt");' . LF;
1089      $BE['BODY_CLOSE']['hidden_main_content'] .= '        if(be_lang && be_lang_cnt) {' . LF;
1090      $BE['BODY_CLOSE']['hidden_main_content'] .= '            var be_lang_items = be_lang.getElements("a");' . LF;
1091      $BE['BODY_CLOSE']['hidden_main_content'] .= '            be_lang_items.each(function(l) {' . LF;
1092  
1093      $BE['BODY_CLOSE']['hidden_main_content'] .= '                l.addEvent("click", function(){' . LF;
1094      
1095      $BE['BODY_CLOSE']['hidden_main_content'] .= "                    if(cur_be_lang == l.rel) {return;}" . LF;
1096      
1097      $BE['BODY_CLOSE']['hidden_main_content'] .= "                    cur_be_lang = l.rel;" . LF;
1098      $BE['BODY_CLOSE']['hidden_main_content'] .= '                    be_lang_items.each(function(el){el.removeClass("be-active");});' . LF;
1099      $BE['BODY_CLOSE']['hidden_main_content'] .= '                    l.addClass("be-active");' . LF;
1100      $BE['BODY_CLOSE']['hidden_main_content'] .= '                    be_lang_cnt.setHTML(be_lang_html[l.rel]);' . LF;
1101      $BE['BODY_CLOSE']['hidden_main_content'] .= '                    Cookie.set("phpwcms_be_parse_lang", cur_be_lang);' . LF;
1102      
1103      $BE['BODY_CLOSE']['hidden_main_content'] .= '                });' . LF;
1104      $BE['BODY_CLOSE']['hidden_main_content'] .= '            });' . LF;
1105      $BE['BODY_CLOSE']['hidden_main_content'] .= '        }' . LF;
1106      $BE['BODY_CLOSE']['hidden_main_content'] .= '    });' . LF;
1107      $BE['BODY_CLOSE']['hidden_main_content'] .= '    </script>';
1108      
1109      $menu[] = '</ul>';
1110      
1111      // wrap current lang/html with <div>
1112      $BE['HTML']    = replace_tmpl_section('BE_MAIN_CONTENT', $BE['HTML'], '<div id="be_lang_cnt">' . (empty($new_html) ? $html : $new_html) . '</div>');
1113      
1114      backend_language_replace( implode(LF, $menu) );
1115      
1116  }
1117  
1118  function backend_language_replace($result) {
1119      
1120      $GLOBALS['BE']['HTML'] = str_replace('{BE_PARSE_LANG}', $result, $GLOBALS['BE']['HTML']);
1121      return NULL;
1122      
1123  }
1124  
1125  ?>


Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1