<?php

/*++++++++++++++++++++++++++++++++++++++++

  Script: Maian Gallery v2.0
  Written by: David Ian Bennett
  E-Mail: support@maianscriptworld.co.uk
  Website: http://www.maianscriptworld.co.uk

  ++++++++++++++++++++++++++++++++++++++++
  
  This File: class_settings.inc.php
  Description: Settings Class

  ++++++++++++++++++++++++++++++++++++++++*/


class settings extends genericOptions {
  
var $prefix;

// Update general settings..
function update_general($DATA)
{
  // Use callback function to prepare data for importing..
  $DATA = array_map(array($this,'safe_import'),$DATA);
  
  mysql_query("UPDATE ".$this->prefix."settings SET
               website        = '{$DATA['website']}',
               email          = '{$DATA['email']}',
               homepage       = '{$DATA['homepage']}',
               folder         = '".$this->removeTrailingSlash($DATA['folder'])."',
               folder_name    = '{$DATA['folder_name']}',
               date_format    = '{$DATA['date_format']}',
               mysql_date     = '{$DATA['mysql_date']}',
               date_ts        = now(),
               theme          = '{$DATA['theme']}',
               language       = '{$DATA['language']}',
               themeswitcher  = '".(isset($DATA['themeswitcher']) ? $DATA['themeswitcher'] : '0')."',
               modr           = '".(isset($DATA['modr']) ? $DATA['modr'] : '0')."',
               captcha        = '".(isset($DATA['captcha']) ? $DATA['captcha'] : '0')."',
               aboutsite      = '{$DATA['aboutsite']}',
               keywords       = '{$DATA['keywords']}',
               description    = '{$DATA['description']}',
               licence        = '{$DATA['licence']}'
               LIMIT 1
               ") or die(mysql_error());
}

// Update image functions..
function update_images($DATA)
{
  // Use callback function to prepare data for importing..
  $DATA = array_map(array($this,'safe_import'),$DATA);
  
  mysql_query("UPDATE ".$this->prefix."settings SET
               comments         = '".(isset($DATA['comments']) ? $DATA['comments'] : '0')."',
               approve          = '".(isset($DATA['approve']) ? $DATA['approve'] : '0')."',
               verification     = '".(isset($DATA['verification']) ? $DATA['verification'] : '0')."',
               slideshow        = '".(isset($DATA['slideshow']) ? $DATA['slideshow'] : '0')."',
               thumbpage        = '{$DATA['thumbpage']}',
               comthumbpage     = '{$DATA['comthumbpage']}',
               commentsorder    = '{$DATA['commentsorder']}',
               autothumb        = '".(isset($DATA['autothumb']) ? $DATA['autothumb'] : '0')."',
               autowidth        = '{$DATA['autowidth']}',
               autoheight       = '{$DATA['autoheight']}',
               thumbwidth       = '{$DATA['thumbwidth']}',
               thumbheight      = '{$DATA['thumbheight']}',
               imgwidth         = '{$DATA['imgwidth']}',
               imgheight        = '{$DATA['imgheight']}',
               pagedisplaysize  = '{$DATA['pagedisplaysize']}',
               windowsizes      = '{$DATA['windowsizes']}'
               LIMIT 1
               ") or die(mysql_error());
}

// Update slideshow settings..
function update_slideshow($DATA)
{
  // Use callback function to prepare data for importing..
  $DATA = array_map(array($this,'safe_import'),$DATA);
  
  mysql_query("UPDATE ".$this->prefix."settings SET
               slidewindow  = '{$DATA['slidewindow']}',
               mp3          = '{$DATA['mp3']}',
               slidespeeds  = '{$DATA['slidespeeds']}'
               LIMIT 1
               ") or die(mysql_error());
}

// Update watermarks..
function update_watermarks($DATA)
{
  // Use callback function to prepare data for importing..
  $DATA = array_map(array($this,'safe_import'),$DATA);
  
  mysql_query("UPDATE ".$this->prefix."settings SET
               watermarks   = '".(isset($DATA['watermarks']) ? $DATA['watermarks'] : '0')."',
               watertext    = '{$DATA['watertext']}',
               waterhspace  = '{$DATA['waterhspace']}',
               watervspace  = '{$DATA['watervspace']}',
               waterfont    = '{$DATA['waterfont']}',
               watersize    = '{$DATA['watersize']}',
               watertextr   = '{$DATA['watertextr']}',
               watertextg   = '{$DATA['watertextg']}',
               watertextb   = '{$DATA['watertextb']}',
               waterangle   = '{$DATA['waterangle']}'
               LIMIT 1
               ") or die(mysql_error());
}

// Update cart settings..
function update_cart($DATA)
{
  // Use callback function to prepare data for importing..
  $DATA = array_map(array($this,'safe_import'),$DATA);
  
  mysql_query("UPDATE ".$this->prefix."settings SET
               cart = '".(isset($DATA['cart']) ? $DATA['cart'] : '0')."'
               ") or die(mysql_error());
  
  mysql_query("UPDATE ".$this->prefix."paypal SET
                       ppEmail        = '{$DATA['ppEmail']}',
                       ppLog          = '".(isset($DATA['ppLog']) ? $DATA['ppLog'] : '0')."',
                       ppSandbox      = '".(isset($DATA['ppSandbox']) ? $DATA['ppSandbox'] : '0')."',
                       ppStyle        = '{$DATA['ppStyle']}',
                       ppCurrency     = '{$DATA['ppCurrency']}',
                       ppSSL          = '".(isset($DATA['ppSSL']) ? $DATA['ppSSL'] : '0')."',
                       ppShipDefault  = '".number_format($DATA['ppShipDefault'],2)."',
                       ppShipSingle   = '".number_format($DATA['ppShipSingle'],2)."'
                       LIMIT 1
                       ") or die(mysql_error());
}

// Update smtp settings..
function update_smtp($DATA)
{
  // Use callback function to prepare data for importing..
  $DATA = array_map(array($this,'safe_import'),$DATA);
  
  mysql_query("UPDATE ".$this->prefix."settings SET
               smtp        = '".(isset($DATA['smtp']) ? $DATA['smtp'] : '0')."',
               smtp_host   = '{$DATA['smtp_host']}',
               smtp_user   = '{$DATA['smtp_user']}',
               smtp_pass   = '{$DATA['smtp_pass']}',
               smtp_port   = '{$DATA['smtp_port']}'
               LIMIT 1
               ") or die(mysql_error());
}

// Clear image counts..
function clear()
{
  mysql_query("UPDATE ".$this->prefix."images SET
              visits = '0'
              ") or die(mysql_error());
}

}

?>
