| 
      1
     | 
    
      <?php
 
     | 
  
  
    | 
      2
     | 
    
      /**
 
     | 
  
  
    | 
      3
     | 
    
       *
 
     | 
  
  
    | 
      4
     | 
    
       * @category        admin
 
     | 
  
  
    | 
      5
     | 
    
       * @package         settings
 
     | 
  
  
    | 
      6
     | 
    
       * @author          WebsiteBaker Project
 
     | 
  
  
    | 
      7
     | 
    
       * @copyright       2009-2013, WebsiteBaker Org. e.V.
 
     | 
  
  
    | 
      8
     | 
    
       * @link            http://www.websitebaker.org/
 
     | 
  
  
    | 
      9
     | 
    
       * @license         http://www.gnu.org/licenses/gpl.html
 
     | 
  
  
    | 
      10
     | 
    
       * @platform        WebsiteBaker 2.8.x
 
     | 
  
  
    | 
      11
     | 
    
       * @requirements    PHP 5.2.2 and higher
 
     | 
  
  
    | 
      12
     | 
    
       * @version         $Id: save.php 1961 2013-09-05 22:43:30Z darkviper $
 
     | 
  
  
    | 
      13
     | 
    
       * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/settings/save.php $
 
     | 
  
  
    | 
      14
     | 
    
       * @lastmodified    $Date: 2013-09-06 00:43:30 +0200 (Fri, 06 Sep 2013) $
 
     | 
  
  
    | 
      15
     | 
    
       *
 
     | 
  
  
    | 
      16
     | 
    
       */
 
     | 
  
  
    | 
      17
     | 
    
      
 
     | 
  
  
    | 
      18
     | 
    
      // prevent this file from being accessed directly in the browser (would set all entries in DB settings table to '')
 
     | 
  
  
    | 
      19
     | 
    
      if(!isset($_POST['default_language']) || $_POST['default_language'] == '') die(header('Location: index.php'));
     | 
  
  
    | 
      20
     | 
    
      
 
     | 
  
  
    | 
      21
     | 
    
      // Find out if the user was view advanced options or not
 
     | 
  
  
    | 
      22
     | 
    
      $advanced = ($_POST['advanced'] == 'yes') ? '?advanced=yes' : '';
 
     | 
  
  
    | 
      23
     | 
    
      
 
     | 
  
  
    | 
      24
     | 
    
      // Print admin header
 
     | 
  
  
    | 
      25
     | 
    
      //require('../../config.php');
     | 
  
  
    | 
      26
     | 
    
      //require_once(WB_PATH.'/framework/class.admin.php');
 
     | 
  
  
    | 
      27
     | 
    
      
 
     | 
  
  
    | 
      28
     | 
    
      // Include config file
 
     | 
  
  
    | 
      29
     | 
    
      $config_file = realpath('../../config.php');
     | 
  
  
    | 
      30
     | 
    
      if(file_exists($config_file) && !defined('WB_URL'))
     | 
  
  
    | 
      31
     | 
    
      {
     | 
  
  
    | 
      32
     | 
    
      	require($config_file);
 
     | 
  
  
    | 
      33
     | 
    
      }
 
     | 
  
  
    | 
      34
     | 
    
      
 
     | 
  
  
    | 
      35
     | 
    
      if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
     | 
  
  
    | 
      36
     | 
    
      
 
     | 
  
  
    | 
      37
     | 
    
      require_once(WB_PATH.'/framework/functions.php');
 
     | 
  
  
    | 
      38
     | 
    
      
 
     | 
  
  
    | 
      39
     | 
    
      // suppress to print the header, so no new FTAN will be set
 
     | 
  
  
    | 
      40
     | 
    
      if($advanced == '')
 
     | 
  
  
    | 
      41
     | 
    
      {
     | 
  
  
    | 
      42
     | 
    
      	$admin = new admin('Settings', 'settings_basic',false);
     | 
  
  
    | 
      43
     | 
    
      } else {
     | 
  
  
    | 
      44
     | 
    
      	$admin = new admin('Settings', 'settings_advanced',false);
     | 
  
  
    | 
      45
     | 
    
      }
 
     | 
  
  
    | 
      46
     | 
    
      
 
     | 
  
  
    | 
      47
     | 
    
      // Create a javascript back link
 
     | 
  
  
    | 
      48
     | 
    
      $js_back = ADMIN_URL.'/settings/index.php'.$advanced;
 
     | 
  
  
    | 
      49
     | 
    
      if( !$admin->checkFTAN() )
 
     | 
  
  
    | 
      50
     | 
    
      {
     | 
  
  
    | 
      51
     | 
    
      	$admin->print_header();
 
     | 
  
  
    | 
      52
     | 
    
      	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$js_back );
 
     | 
  
  
    | 
      53
     | 
    
      }
 
     | 
  
  
    | 
      54
     | 
    
      // After check print the header
 
     | 
  
  
    | 
      55
     | 
    
      $admin->print_header();
 
     | 
  
  
    | 
      56
     | 
    
      
 
     | 
  
  
    | 
      57
     | 
    
      // Ensure that the specified default email is formally valid
 
     | 
  
  
    | 
      58
     | 
    
      if(isset($_POST['server_email']))
 
     | 
  
  
    | 
      59
     | 
    
      {
     | 
  
  
    | 
      60
     | 
    
      	$_POST['server_email'] = strip_tags($_POST['server_email']);
 
     | 
  
  
    | 
      61
     | 
    
      //    // $pattern = '/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9]([-a-z0-9_]?[a-z0-9])*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z]{2})|([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})(\.([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})){3})(:[0-9]{1,5})?\r/im';
     | 
  
  
    | 
      62
     | 
    
      //    $pattern = '/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,6}))$/';
     | 
  
  
    | 
      63
     | 
    
      //    if(false == preg_match($pattern, $_POST['server_email']))
 
     | 
  
  
    | 
      64
     | 
    
      	if(!$admin->validate_email($_POST['server_email']))
 
     | 
  
  
    | 
      65
     | 
    
          {
     | 
  
  
    | 
      66
     | 
    
      		$admin->print_error($MESSAGE['USERS_INVALID_EMAIL'].
 
     | 
  
  
    | 
      67
     | 
    
      			'<br /><strong>Email: '.htmlentities($_POST['server_email']).'</strong>', $js_back);
 
     | 
  
  
    | 
      68
     | 
    
      	}
 
     | 
  
  
    | 
      69
     | 
    
      }
 
     | 
  
  
    | 
      70
     | 
    
      
 
     | 
  
  
    | 
      71
     | 
    
      if($admin->StripCodeFromText($admin->get_post('wbmailer_routine'))=='smtp') {
     | 
  
  
    | 
      72
     | 
    
      
 
     | 
  
  
    | 
      73
     | 
    
      	$checkSmtpHost = (($admin->StripCodeFromText($admin->get_post('wbmailer_smtp_host'))=='') ? false : true);
     | 
  
  
    | 
      74
     | 
    
      //	$checkSmtpHost = (isset($_POST['wbmailer_smtp_host']) && ($_POST['wbmailer_smtp_host']=='') ? false : true);
 
     | 
  
  
    | 
      75
     | 
    
      	$checkSmtpUser = (($admin->StripCodeFromText($admin->get_post('wbmailer_smtp_username'))=='') ? false : true);
     | 
  
  
    | 
      76
     | 
    
      //	$checkSmtpUser = (isset($_POST['wbmailer_smtp_username']) && ($_POST['wbmailer_smtp_username']=='') ? false : true);
 
     | 
  
  
    | 
      77
     | 
    
      	$checkSmtpPassword = (($admin->StripCodeFromText($admin->get_post('wbmailer_smtp_password'))=='') ? false : true);
     | 
  
  
    | 
      78
     | 
    
      //	$checkSmtpPassword = (isset($_POST['wbmailer_smtp_password']) && ($_POST['wbmailer_smtp_password']=='') ? false : true);
 
     | 
  
  
    | 
      79
     | 
    
      
 
     | 
  
  
    | 
      80
     | 
    
      	if(!$checkSmtpHost || !$checkSmtpUser || !$checkSmtpPassword) {
     | 
  
  
    | 
      81
     | 
    
      		$admin->print_error($TEXT['REQUIRED'].' '.$TEXT['WBMAILER_SMTP_AUTH'].
 
     | 
  
  
    | 
      82
     | 
    
      			'<br /><strong>'.$MESSAGE['GENERIC_FILL_IN_ALL'].'</strong>', $js_back);
 
     | 
  
  
    | 
      83
     | 
    
      	}
 
     | 
  
  
    | 
      84
     | 
    
      
 
     | 
  
  
    | 
      85
     | 
    
      }
 
     | 
  
  
    | 
      86
     | 
    
      
 
     | 
  
  
    | 
      87
     | 
    
      // Work-out file mode
 
     | 
  
  
    | 
      88
     | 
    
      if($advanced == '')
 
     | 
  
  
    | 
      89
     | 
    
      {
     | 
  
  
    | 
      90
     | 
    
      	$file_mode = STRING_FILE_MODE;
 
     | 
  
  
    | 
      91
     | 
    
      	$dir_mode = STRING_DIR_MODE;
 
     | 
  
  
    | 
      92
     | 
    
      	// Check if should be set to 777 or left alone
 
     | 
  
  
    | 
      93
     | 
    
      //	if(isset($_POST['world_writeable']) && $_POST['world_writeable'] == 'true')
 
     | 
  
  
    | 
      94
     | 
    
      //    {
     | 
  
  
    | 
      95
     | 
    
      //		$file_mode = '0777';
 
     | 
  
  
    | 
      96
     | 
    
      //		$dir_mode = '0777';
 
     | 
  
  
    | 
      97
     | 
    
      //	} else {
     | 
  
  
    | 
      98
     | 
    
      //		$file_mode = STRING_FILE_MODE;
 
     | 
  
  
    | 
      99
     | 
    
      //		$dir_mode = STRING_DIR_MODE;
 
     | 
  
  
    | 
      100
     | 
    
      //	}
 
     | 
  
  
    | 
      101
     | 
    
      } else {
     | 
  
  
    | 
      102
     | 
    
      	$file_mode = STRING_FILE_MODE;
 
     | 
  
  
    | 
      103
     | 
    
      	$dir_mode = STRING_DIR_MODE;
 
     | 
  
  
    | 
      104
     | 
    
      	if($admin->get_user_id()=='1')
 
     | 
  
  
    | 
      105
     | 
    
      	{
     | 
  
  
    | 
      106
     | 
    
      		// Work-out the octal value for file mode
 
     | 
  
  
    | 
      107
     | 
    
      		$u = 0;
 
     | 
  
  
    | 
      108
     | 
    
      		if(isset($_POST['file_u_r']) && $_POST['file_u_r'] == 'true') {
     | 
  
  
    | 
      109
     | 
    
      			$u = $u+4;
 
     | 
  
  
    | 
      110
     | 
    
      		}
 
     | 
  
  
    | 
      111
     | 
    
      		if(isset($_POST['file_u_w']) && $_POST['file_u_w'] == 'true') {
     | 
  
  
    | 
      112
     | 
    
      			$u = $u+2;
 
     | 
  
  
    | 
      113
     | 
    
      		}
 
     | 
  
  
    | 
      114
     | 
    
      		if(isset($_POST['file_u_e']) && $_POST['file_u_e'] == 'true') {
     | 
  
  
    | 
      115
     | 
    
      			$u = $u+1;
 
     | 
  
  
    | 
      116
     | 
    
      		}
 
     | 
  
  
    | 
      117
     | 
    
      		$g = 0;
 
     | 
  
  
    | 
      118
     | 
    
      		if(isset($_POST['file_g_r']) && $_POST['file_g_r'] == 'true') {
     | 
  
  
    | 
      119
     | 
    
      			$g = $g+4;
 
     | 
  
  
    | 
      120
     | 
    
      		}
 
     | 
  
  
    | 
      121
     | 
    
      		if(isset($_POST['file_g_w']) && $_POST['file_g_w'] == 'true') {
     | 
  
  
    | 
      122
     | 
    
      			$g = $g+2;
 
     | 
  
  
    | 
      123
     | 
    
      		}
 
     | 
  
  
    | 
      124
     | 
    
      		if(isset($_POST['file_g_e']) && $_POST['file_g_e'] == 'true') {
     | 
  
  
    | 
      125
     | 
    
      			$g = $g+1;
 
     | 
  
  
    | 
      126
     | 
    
      		}
 
     | 
  
  
    | 
      127
     | 
    
      		$o = 0;
 
     | 
  
  
    | 
      128
     | 
    
      		if(isset($_POST['file_o_r']) && $_POST['file_o_r'] == 'true') {
     | 
  
  
    | 
      129
     | 
    
      			$o = $o+4;
 
     | 
  
  
    | 
      130
     | 
    
      		}
 
     | 
  
  
    | 
      131
     | 
    
      		if(isset($_POST['file_o_w']) && $_POST['file_o_w'] == 'true') {
     | 
  
  
    | 
      132
     | 
    
      			$o = $o+2;
 
     | 
  
  
    | 
      133
     | 
    
      		}
 
     | 
  
  
    | 
      134
     | 
    
      		if(isset($_POST['file_o_e']) && $_POST['file_o_e'] == 'true') {
     | 
  
  
    | 
      135
     | 
    
      			$o = $o+1;
 
     | 
  
  
    | 
      136
     | 
    
      		}
 
     | 
  
  
    | 
      137
     | 
    
      		$file_mode = "0".$u.$g.$o;
 
     | 
  
  
    | 
      138
     | 
    
      		// Work-out the octal value for dir mode
 
     | 
  
  
    | 
      139
     | 
    
      		$u = 0;
 
     | 
  
  
    | 
      140
     | 
    
      		if(isset($_POST['dir_u_r']) && $_POST['dir_u_r'] == 'true') {
     | 
  
  
    | 
      141
     | 
    
      			$u = $u+4;
 
     | 
  
  
    | 
      142
     | 
    
      		}
 
     | 
  
  
    | 
      143
     | 
    
      		if(isset($_POST['dir_u_w']) && $_POST['dir_u_w'] == 'true') {
     | 
  
  
    | 
      144
     | 
    
      			$u = $u+2;
 
     | 
  
  
    | 
      145
     | 
    
      		}
 
     | 
  
  
    | 
      146
     | 
    
      		if(isset($_POST['dir_u_e']) && $_POST['dir_u_e'] == 'true') {
     | 
  
  
    | 
      147
     | 
    
      			$u = $u+1;
 
     | 
  
  
    | 
      148
     | 
    
      		}
 
     | 
  
  
    | 
      149
     | 
    
      		$g = 0;
 
     | 
  
  
    | 
      150
     | 
    
      		if(isset($_POST['dir_g_r']) && $_POST['dir_g_r'] == 'true') {
     | 
  
  
    | 
      151
     | 
    
      			$g = $g+4;
 
     | 
  
  
    | 
      152
     | 
    
      		}
 
     | 
  
  
    | 
      153
     | 
    
      		if(isset($_POST['dir_g_w']) && $_POST['dir_g_w'] == 'true') {
     | 
  
  
    | 
      154
     | 
    
      			$g = $g+2;
 
     | 
  
  
    | 
      155
     | 
    
      		}
 
     | 
  
  
    | 
      156
     | 
    
      		if(isset($_POST['dir_g_e']) && $_POST['dir_g_e'] == 'true') {
     | 
  
  
    | 
      157
     | 
    
      			$g = $g+1;
 
     | 
  
  
    | 
      158
     | 
    
      		}
 
     | 
  
  
    | 
      159
     | 
    
      		$o = 0;
 
     | 
  
  
    | 
      160
     | 
    
      		if(isset($_POST['dir_o_r']) && $_POST['dir_o_r'] == 'true') {
     | 
  
  
    | 
      161
     | 
    
      			$o = $o+4;
 
     | 
  
  
    | 
      162
     | 
    
      		}
 
     | 
  
  
    | 
      163
     | 
    
      		if(isset($_POST['dir_o_w']) && $_POST['dir_o_w'] == 'true') {
     | 
  
  
    | 
      164
     | 
    
      			$o = $o+2;
 
     | 
  
  
    | 
      165
     | 
    
      		}
 
     | 
  
  
    | 
      166
     | 
    
      		if(isset($_POST['dir_o_e']) && $_POST['dir_o_e'] == 'true') {
     | 
  
  
    | 
      167
     | 
    
      			$o = $o+1;
 
     | 
  
  
    | 
      168
     | 
    
      		}
 
     | 
  
  
    | 
      169
     | 
    
      		$dir_mode = "0".$u.$g.$o;
 
     | 
  
  
    | 
      170
     | 
    
      	}
 
     | 
  
  
    | 
      171
     | 
    
      }
 
     | 
  
  
    | 
      172
     | 
    
      
 
     | 
  
  
    | 
      173
     | 
    
      $allow_tags_in_fields = array(
 
     | 
  
  
    | 
      174
     | 
    
          'website_header',
 
     | 
  
  
    | 
      175
     | 
    
          'website_footer',
 
     | 
  
  
    | 
      176
     | 
    
          'wbmail_signature'
 
     | 
  
  
    | 
      177
     | 
    
          );
 
     | 
  
  
    | 
      178
     | 
    
      $allow_empty_values = array(
 
     | 
  
  
    | 
      179
     | 
    
          'website_title',
 
     | 
  
  
    | 
      180
     | 
    
          'website_description',
 
     | 
  
  
    | 
      181
     | 
    
          'website_keywords',
 
     | 
  
  
    | 
      182
     | 
    
          'website_header',
 
     | 
  
  
    | 
      183
     | 
    
          'website_footer',
 
     | 
  
  
    | 
      184
     | 
    
          'wbmail_signature',
 
     | 
  
  
    | 
      185
     | 
    
          'wysiwyg_style',
 
     | 
  
  
    | 
      186
     | 
    
          'pages_directory',
 
     | 
  
  
    | 
      187
     | 
    
          'page_icon_dir',
 
     | 
  
  
    | 
      188
     | 
    
          'rename_files_on_upload',
 
     | 
  
  
    | 
      189
     | 
    
          'page_spacer',
 
     | 
  
  
    | 
      190
     | 
    
          'page_icon_dir',
 
     | 
  
  
    | 
      191
     | 
    
          );
 
     | 
  
  
    | 
      192
     | 
    
      $aPreventFromUpdate = array(
 
     | 
  
  
    | 
      193
     | 
    
          'sp',
 
     | 
  
  
    | 
      194
     | 
    
          'version',
 
     | 
  
  
    | 
      195
     | 
    
      //    'page_extension',
 
     | 
  
  
    | 
      196
     | 
    
          'wb_version'
 
     | 
  
  
    | 
      197
     | 
    
          );
 
     | 
  
  
    | 
      198
     | 
    
      $StripCodeFromInput = array(
 
     | 
  
  
    | 
      199
     | 
    
          'website_title',
 
     | 
  
  
    | 
      200
     | 
    
          'website_description',
 
     | 
  
  
    | 
      201
     | 
    
          'website_keywords',
 
     | 
  
  
    | 
      202
     | 
    
          'wbmail_signature',
 
     | 
  
  
    | 
      203
     | 
    
          'wysiwyg_style',
 
     | 
  
  
    | 
      204
     | 
    
          'pages_directory',
 
     | 
  
  
    | 
      205
     | 
    
          'page_icon_dir',
 
     | 
  
  
    | 
      206
     | 
    
          'media_directory',
 
     | 
  
  
    | 
      207
     | 
    
          'page_extension',
 
     | 
  
  
    | 
      208
     | 
    
          'rename_files_on_upload',
 
     | 
  
  
    | 
      209
     | 
    
          'page_spacer',
 
     | 
  
  
    | 
      210
     | 
    
          'page_icon_dir',
 
     | 
  
  
    | 
      211
     | 
    
          );
 
     | 
  
  
    | 
      212
     | 
    
      
 
     | 
  
  
    | 
      213
     | 
    
      // Query current settings in the db, then loop through them and update the db with the new value
 
     | 
  
  
    | 
      214
     | 
    
      //$settings = array();
 
     | 
  
  
    | 
      215
     | 
    
      //$old_settings = array();
 
     | 
  
  
    | 
      216
     | 
    
      // Query current settings in the db, then loop through them to get old values
 
     | 
  
  
    | 
      217
     | 
    
      $sql  = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'settings`';
 
     | 
  
  
    | 
      218
     | 
    
      $sql .= 'ORDER BY `name`';
 
     | 
  
  
    | 
      219
     | 
    
      
 
     | 
  
  
    | 
      220
     | 
    
      if($res_settings = $database->query($sql)) {
     | 
  
  
    | 
      221
     | 
    
      	$iQueryStart = $database->getQueryCount;
 
     | 
  
  
    | 
      222
     | 
    
      	while($setting = $res_settings->fetchRow(MYSQL_ASSOC))
 
     | 
  
  
    | 
      223
     | 
    
      	{
     | 
  
  
    | 
      224
     | 
    
      		$passed = false;
 
     | 
  
  
    | 
      225
     | 
    
      		$setting_name = $setting['name'];
 
     | 
  
  
    | 
      226
     | 
    
      //		$old_settings = $setting['value'];
 
     | 
  
  
    | 
      227
     | 
    
      //		$value = $admin->get_post($setting_name);
 
     | 
  
  
    | 
      228
     | 
    
      		if(($value = $admin->get_post($setting_name)) === null) { continue; }
     | 
  
  
    | 
      229
     | 
    
      //		$value = isset($_POST[$setting_name]) ? $value : $old_settings ;
 
     | 
  
  
    | 
      230
     | 
    
      		switch ($setting_name) {
     | 
  
  
    | 
      231
     | 
    
      			case 'default_timezone':
 
     | 
  
  
    | 
      232
     | 
    
      				$value = intval($value);
 
     | 
  
  
    | 
      233
     | 
    
      				$value = ( ($value >= -12 && $value <= 13) ? $value :0 ) * 3600;
 
     | 
  
  
    | 
      234
     | 
    
      				$passed = ($value != $setting['value']);
 
     | 
  
  
    | 
      235
     | 
    
      				break;
 
     | 
  
  
    | 
      236
     | 
    
      			case 'string_dir_mode':
 
     | 
  
  
    | 
      237
     | 
    
      				$value=$dir_mode;
 
     | 
  
  
    | 
      238
     | 
    
      				$passed = ($value != $setting['value']);
 
     | 
  
  
    | 
      239
     | 
    
      				break;
 
     | 
  
  
    | 
      240
     | 
    
      			case 'string_file_mode':
 
     | 
  
  
    | 
      241
     | 
    
      				$value=$file_mode;
 
     | 
  
  
    | 
      242
     | 
    
      	 			$passed = ($value != $setting['value']);
 
     | 
  
  
    | 
      243
     | 
    
      				break;
 
     | 
  
  
    | 
      244
     | 
    
      			case 'page_extension':
 
     | 
  
  
    | 
      245
     | 
    
      				$value = $admin->StripCodeFromText($value);
 
     | 
  
  
    | 
      246
     | 
    
      				if(!preg_match('/^\.[a-z][a-z0-9]+$/siu', $value)) {
     | 
  
  
    | 
      247
     | 
    
      					$value = '.php';
 
     | 
  
  
    | 
      248
     | 
    
      				}
 
     | 
  
  
    | 
      249
     | 
    
      				$passed = ($value != $setting['value']);
 
     | 
  
  
    | 
      250
     | 
    
      				break;
 
     | 
  
  
    | 
      251
     | 
    
      			case 'sec_anchor':
 
     | 
  
  
    | 
      252
     | 
    
      				$value = $admin->StripCodeFromText($value);
 
     | 
  
  
    | 
      253
     | 
    
      				$value=(($value=='') ? 'Sec' : $value);
 
     | 
  
  
    | 
      254
     | 
    
      	 			$passed = ($value != $setting['value']);
 
     | 
  
  
    | 
      255
     | 
    
      				break;
 
     | 
  
  
    | 
      256
     | 
    
      			case 'media_directory':
 
     | 
  
  
    | 
      257
     | 
    
      				$value = trim($value,'/');
 
     | 
  
  
    | 
      258
     | 
    
      				$value = ( ($value != '')  ? '/'.$value : '/media' ); 
 
     | 
  
  
    | 
      259
     | 
    
      	 			$passed = ($value != $setting['value']);
 
     | 
  
  
    | 
      260
     | 
    
      				break;
 
     | 
  
  
    | 
      261
     | 
    
      			 case 'pages_directory':
 
     | 
  
  
    | 
      262
     | 
    
      			 $sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'pages`';
 
     | 
  
  
    | 
      263
     | 
    
      			  if( !($database->get_one($sql)) ) {
     | 
  
  
    | 
      264
     | 
    
      			   $value = rtrim($admin->StripCodeFromText($value));
 
     | 
  
  
    | 
      265
     | 
    
      			   $passed = ($value != $setting['value']);
 
     | 
  
  
    | 
      266
     | 
    
      			  }
 
     | 
  
  
    | 
      267
     | 
    
      			  $value = trim($value,'/');
 
     | 
  
  
    | 
      268
     | 
    
      			  $value = ( ($value != '')  ? '/'.$value : '' ); 
 
     | 
  
  
    | 
      269
     | 
    
      			  break;
 
     | 
  
  
    | 
      270
     | 
    
      			default :
 
     | 
  
  
    | 
      271
     | 
    
      				 if($value == '')  {
     | 
  
  
    | 
      272
     | 
    
      					$passed = ((in_array($setting_name, $allow_empty_values)) && ($value != $setting['value']));
 
     | 
  
  
    | 
      273
     | 
    
      				} else {
     | 
  
  
    | 
      274
     | 
    
      					if(in_array($setting_name, $StripCodeFromInput) ) {
     | 
  
  
    | 
      275
     | 
    
      						$value = trim($admin->StripCodeFromText($value));
 
     | 
  
  
    | 
      276
     | 
    
      					}
 
     | 
  
  
    | 
      277
     | 
    
      					$passed = (($value != '') && ($value != $setting['value']));
 
     | 
  
  
    | 
      278
     | 
    
      				}
 
     | 
  
  
    | 
      279
     | 
    
      				break;
 
     | 
  
  
    | 
      280
     | 
    
      		}
 
     | 
  
  
    | 
      281
     | 
    
      
 
     | 
  
  
    | 
      282
     | 
    
      	    if (!in_array($setting_name, $allow_tags_in_fields))
 
     | 
  
  
    | 
      283
     | 
    
      	    {
     | 
  
  
    | 
      284
     | 
    
      	        $value = strip_tags($value);
 
     | 
  
  
    | 
      285
     | 
    
      	    }
 
     | 
  
  
    | 
      286
     | 
    
      		if( !in_array($setting_name, $aPreventFromUpdate) && $passed )
 
     | 
  
  
    | 
      287
     | 
    
      //	    if ( !in_array($setting_name, $aPreventFromUpdate) && (isset($_POST[$setting_name]) || $passed == true) )
 
     | 
  
  
    | 
      288
     | 
    
      	    {
     | 
  
  
    | 
      289
     | 
    
      	        $value = trim($database->escapeString($value));
 
     | 
  
  
    | 
      290
     | 
    
      	        $sql = 'UPDATE `'.TABLE_PREFIX.'settings` ';
 
     | 
  
  
    | 
      291
     | 
    
      	        $sql .= 'SET `value` = \''.($value).'\' ';
 
     | 
  
  
    | 
      292
     | 
    
      	        $sql .= 'WHERE `name` != \'wb_version\' ';
 
     | 
  
  
    | 
      293
     | 
    
      	        $sql .= 'AND `name` = \''.$setting_name.'\' ';
 
     | 
  
  
    | 
      294
     | 
    
      	        if (!$database->query($sql))
 
     | 
  
  
    | 
      295
     | 
    
      	        {
     | 
  
  
    | 
      296
     | 
    
      				if($database->is_error()) {
     | 
  
  
    | 
      297
     | 
    
      					$admin->print_error($database->get_error, $js_back );
 
     | 
  
  
    | 
      298
     | 
    
      				}
 
     | 
  
  
    | 
      299
     | 
    
      	        } 
 
     | 
  
  
    | 
      300
     | 
    
      		}
 
     | 
  
  
    | 
      301
     | 
    
      	}
 
     | 
  
  
    | 
      302
     | 
    
      	$iQueriesDone = $database->getQueryCount - $iQueryStart;
 
     | 
  
  
    | 
      303
     | 
    
      }
 
     | 
  
  
    | 
      304
     | 
    
      
 
     | 
  
  
    | 
      305
     | 
    
      /**
 
     | 
  
  
    | 
      306
     | 
    
       * now save search settings
 
     | 
  
  
    | 
      307
     | 
    
       */
 
     | 
  
  
    | 
      308
     | 
    
      $StripCodeFromISearch = array(
 
     | 
  
  
    | 
      309
     | 
    
          'search_header',
 
     | 
  
  
    | 
      310
     | 
    
          'search_results_header',
 
     | 
  
  
    | 
      311
     | 
    
          'search_results_loop',
 
     | 
  
  
    | 
      312
     | 
    
          'search_results_footer',
 
     | 
  
  
    | 
      313
     | 
    
          'search_footer',
 
     | 
  
  
    | 
      314
     | 
    
          'search_module_order',
 
     | 
  
  
    | 
      315
     | 
    
          'search_max_excerpt',
 
     | 
  
  
    | 
      316
     | 
    
          'search_no_results',
 
     | 
  
  
    | 
      317
     | 
    
          'search_time_limit',
 
     | 
  
  
    | 
      318
     | 
    
          'search_max_excerpt',
 
     | 
  
  
    | 
      319
     | 
    
          );
 
     | 
  
  
    | 
      320
     | 
    
      $allow_empty_values = array(
 
     | 
  
  
    | 
      321
     | 
    
          'header',
 
     | 
  
  
    | 
      322
     | 
    
          'results_header',
 
     | 
  
  
    | 
      323
     | 
    
          'results_loop',
 
     | 
  
  
    | 
      324
     | 
    
          'results_footer',
 
     | 
  
  
    | 
      325
     | 
    
          'footer',
 
     | 
  
  
    | 
      326
     | 
    
          'module_order',
 
     | 
  
  
    | 
      327
     | 
    
          'no_results',
 
     | 
  
  
    | 
      328
     | 
    
          );
 
     | 
  
  
    | 
      329
     | 
    
      $allow_tags_in_fields = array(
 
     | 
  
  
    | 
      330
     | 
    
          'header',
 
     | 
  
  
    | 
      331
     | 
    
          'results_header',
 
     | 
  
  
    | 
      332
     | 
    
          'results_loop',
 
     | 
  
  
    | 
      333
     | 
    
          'results_footer',
 
     | 
  
  
    | 
      334
     | 
    
          'no_results',
 
     | 
  
  
    | 
      335
     | 
    
          'footer',
 
     | 
  
  
    | 
      336
     | 
    
          );
 
     | 
  
  
    | 
      337
     | 
    
      
 
     | 
  
  
    | 
      338
     | 
    
      // Query current search settings in the db, then loop through them and update the db with the new value
 
     | 
  
  
    | 
      339
     | 
    
      $sql  = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'search` ';
 
     | 
  
  
    | 
      340
     | 
    
      $sql .= 'WHERE `extra` =  \'\' ';
 
     | 
  
  
    | 
      341
     | 
    
      if( !($oSearch = $database->query($sql)) ) {
     | 
  
  
    | 
      342
     | 
    
          if($database->is_error()) {
     | 
  
  
    | 
      343
     | 
    
          	$admin->print_error(explode(';',$database->get_error()), $js_back );
     | 
  
  
    | 
      344
     | 
    
          }
 
     | 
  
  
    | 
      345
     | 
    
      }
 
     | 
  
  
    | 
      346
     | 
    
      
 
     | 
  
  
    | 
      347
     | 
    
      while($aSearch = $oSearch->fetchRow(MYSQL_ASSOC))
 
     | 
  
  
    | 
      348
     | 
    
      {
     | 
  
  
    | 
      349
     | 
    
      	$passed = false;
 
     | 
  
  
    | 
      350
     | 
    
      	$old_value = $aSearch['value'];
 
     | 
  
  
    | 
      351
     | 
    
      	$sSearchName = $aSearch['name'];
 
     | 
  
  
    | 
      352
     | 
    
      	$sPostName = 'search_'.$sSearchName;
 
     | 
  
  
    | 
      353
     | 
    
      
 
     | 
  
  
    | 
      354
     | 
    
          $value = $admin->get_post($sPostName);
 
     | 
  
  
    | 
      355
     | 
    
          $value = isset($value) ?  $value : $old_value;
 
     | 
  
  
    | 
      356
     | 
    
          if(in_array($sPostName, $StripCodeFromISearch) ) {
     | 
  
  
    | 
      357
     | 
    
              $value = $admin->StripCodeFromText($value);
 
     | 
  
  
    | 
      358
     | 
    
          }
 
     | 
  
  
    | 
      359
     | 
    
      
 
     | 
  
  
    | 
      360
     | 
    
      /**
 
     | 
  
  
    | 
      361
     | 
    
       *  hold old value if post is empty
 
     | 
  
  
    | 
      362
     | 
    
       *  check search template
 
     | 
  
  
    | 
      363
     | 
    
       */
 
     | 
  
  
    | 
      364
     | 
    
      	switch ($sSearchName) {
     | 
  
  
    | 
      365
     | 
    
      		case 'template':
 
     | 
  
  
    | 
      366
     | 
    
       			$passed = true;
 
     | 
  
  
    | 
      367
     | 
    
                  $value =  ( !($admin->get_post($sPostName)) || ($value == DEFAULT_TEMPLATE ) ) ? '' : $admin->get_post($sPostName);
 
     | 
  
  
    | 
      368
     | 
    
      			break;
 
     | 
  
  
    | 
      369
     | 
    
      		case 'max_excerpt':
 
     | 
  
  
    | 
      370
     | 
    
       			$passed = true;
 
     | 
  
  
    | 
      371
     | 
    
              	if(preg_match('/[^0-9]+/i', $value)) {
     | 
  
  
    | 
      372
     | 
    
                      $value = $old_value;
 
     | 
  
  
    | 
      373
     | 
    
              	}
 
     | 
  
  
    | 
      374
     | 
    
      			break;
 
     | 
  
  
    | 
      375
     | 
    
      		case 'time_limit':
 
     | 
  
  
    | 
      376
     | 
    
                  $passed = true;
 
     | 
  
  
    | 
      377
     | 
    
              	if(preg_match('/[^0-9]+/i', $value)) {
     | 
  
  
    | 
      378
     | 
    
                      $value = $old_value;
 
     | 
  
  
    | 
      379
     | 
    
              	}
 
     | 
  
  
    | 
      380
     | 
    
      			break;
 
     | 
  
  
    | 
      381
     | 
    
      		default :
 
     | 
  
  
    | 
      382
     | 
    
              	$passed = ($admin->get_post($sPostName) || in_array($sSearchName, $allow_empty_values));
 
     | 
  
  
    | 
      383
     | 
    
      
 
     | 
  
  
    | 
      384
     | 
    
                  if (!in_array($sSearchName, $allow_tags_in_fields))
 
     | 
  
  
    | 
      385
     | 
    
                  {
     | 
  
  
    | 
      386
     | 
    
                      $value = strip_tags($value);
 
     | 
  
  
    | 
      387
     | 
    
                  }
 
     | 
  
  
    | 
      388
     | 
    
      			break;
 
     | 
  
  
    | 
      389
     | 
    
      	}
 
     | 
  
  
    | 
      390
     | 
    
      
 
     | 
  
  
    | 
      391
     | 
    
          if ( ($passed == true) )
 
     | 
  
  
    | 
      392
     | 
    
      	{
     | 
  
  
    | 
      393
     | 
    
      		$value = $admin->add_slashes($value);
 
     | 
  
  
    | 
      394
     | 
    
              $sql  = 'UPDATE `'.TABLE_PREFIX.'search` ';
 
     | 
  
  
    | 
      395
     | 
    
              $sql .= 'SET `value` = \''.$value.'\' ';
 
     | 
  
  
    | 
      396
     | 
    
              $sql .= 'WHERE `name` = \''.$sSearchName.'\' ';
 
     | 
  
  
    | 
      397
     | 
    
              $sql .= 'AND `extra` = \'\' ';
 
     | 
  
  
    | 
      398
     | 
    
      		if($database->query($sql)) {
     | 
  
  
    | 
      399
     | 
    
      
 
     | 
  
  
    | 
      400
     | 
    
      		}
 
     | 
  
  
    | 
      401
     | 
    
      		$sql_info = mysql_info($database->db_handle);
 
     | 
  
  
    | 
      402
     | 
    
          }
 
     | 
  
  
    | 
      403
     | 
    
      }
 
     | 
  
  
    | 
      404
     | 
    
      
 
     | 
  
  
    | 
      405
     | 
    
      // Check if there was an error updating the db
 
     | 
  
  
    | 
      406
     | 
    
      if($database->is_error()) {
     | 
  
  
    | 
      407
     | 
    
      	$admin->print_error($database->get_error, $js_back );
 
     | 
  
  
    | 
      408
     | 
    
      } else {
     | 
  
  
    | 
      409
     | 
    
      //	$admin->print_success($iQueriesDone.' Queries '.$MESSAGE['SETTINGS_SAVED'], $js_back );
 
     | 
  
  
    | 
      410
     | 
    
      	$admin->print_success($MESSAGE['SETTINGS_SAVED'], $js_back );
 
     | 
  
  
    | 
      411
     | 
    
      }
 
     | 
  
  
    | 
      412
     | 
    
      $admin->print_footer();
 
     |