Location: PHPKode > scripts > phpMyNewsLetter > phpmynewsletter/include/lib/libconfig.php
<?
// a newsletter configuration class

if (!defined( "_CONFIG_LIB" ))
{
  define("_CONFIG_LIB", 1);

  class config {
  
    var $sending_method;  // normal, nexen.net, online.fr or smtp

    /* database info */
    var $db_host;         // database hostname
    var $db_login;        // database login
    var $db_pass;         // database password
    var $db_name;         // database
    var $db_config_table; //

    var $table_email;
    var $table_temp;
    var $table_listsconfig;
    var $table_archives;
    
    /* admin info */
    var $admin_pass;
    var $archive_limit; //number of old newsletter / archive page
    var $base_url; // http://www.mydomain.com/myweb/
    var $path; // path/to/phpmynewsletter/
    var $language="english";

    var $smtp_host;
    var $smtp_auth;
    var $smtp_login;
    var $smtp_pass;
    
    var $sending_limit;
    var $validation_period;
    

    var $sub_validation;
    var $unsub_validation;

    var $admin_email;
    var $admin_name;
    var $charset;
    var $mod_post;
    var $mod_sub;
    
    var $table_post;
    var $table_sub;
    



    function getConfig($host, $login, $pass, $database, $config_table){
      $this->db_host=$host;
      $this->db_login=$login;
      $this->db_pass=$pass;
      $this->db_name=$database;
      $this->db_config_table=$config_table;
      
      $db= new Db();
      if( !$db->DbConnect($host, $login, $pass, $database))
	return "ERROR_DBCONNECT_CORE";

      $sql = "SELECT * FROM $config_table";
      $db->DbQuery($sql);

      $config_row = $db->DbNextRow();

      $this->admin_pass = $config_row[0];
      $this->archive_limit = $config_row[1];
      $this->base_url = $config_row[2];
      $this->path = $config_row[3];      
      $this->sending_method = $config_row[4];
      $this->language = $config_row[5];
      $this->table_email = $config_row[6];
      $this->table_temp = $config_row[7];
      $this->table_listsconfig = $config_row[8];
      $this->table_archives = $config_row[9];
      $this->smtp_host = $config_row[10];
      $this->smtp_auth = $config_row[11];
      $this->smtp_login = $config_row[12];
      $this->smtp_pass = $config_row[13];
      $this->sending_limit = $config_row[14];
      $this->validation_period = $config_row[15];
      $this->sub_validation = $config_row[16];
      $this->unsub_validation = $config_row[17];
      $this->admin_email = $config_row[18];
      $this->admin_name = $config_row[19];
      //$this->mod_post = $config_row[20];
      $this->mod_sub = $config_row[20];
      //      $this->table_post = $config_row[22];
      $this->table_sub = $config_row[21];
      $this->charset = $config_row[22];
	
      return "SUCCESS";
    }

    
    function saveConfig($host, $login, $pass, $database, $config_table, $admin_pass, $archive_limit, $base_url, $path, $language, $table_email, $table_temp, $table_listsconfig, $table_archives, $sending_method, $smtp_host, $smtp_auth, $smtp_login, $smtp_pass, $sending_limit, $validation_period, $sub_validation, $unsub_validation, $admin_email, $admin_name, $mod_sub, $table_sub, $charset) 
      {
	
	$db= new Db();
	$db->DbConnect($host, $login, $pass, $database);



  if(!get_magic_quotes_gpc()){
   $admin_pass = escape_string($admin_pass);
   $base_url = escape_string($base_url);
   $path = escape_string($path);
   $smtp_host = escape_string($smtp_host);
   $smtp_login = escape_string($smtp_login);
   $smtp_pass = escape_string($smtp_pass);
   $sending_limit = escape_string($sending_limit);
   $validation_period = escape_string($validation_period);
   $sub_validation = escape_string($sub_validation);
   $unsub_validation = escape_string($unsub_validation);
   $admin_email = escape_string($admin_email);
   $admin_name = escape_string($admin_name);
   $mod_sub = escape_string($mod_sub);
  }	


  $sql = "UPDATE $config_table SET ";
  if(!empty($admin_pass)){
    $sql.= "admin_pass='".md5($admin_pass)."', ";
    setcookie("PMNLNG_admin_password",md5($admin_pass));
  }
  $sql.= "archive_limit='$archive_limit', ";
  $sql.= "base_url='$base_url', ";
  $sql.= "path='$path',";
  $sql.= "language='$language', ";
  $sql.= "table_email='$table_email', ";
  $sql.= "table_temp='$table_temp', ";
  $sql.= "table_listsconfig='$table_listsconfig', ";
  $sql.= "table_archives='$table_archives', ";
  $sql.= "sending_limit='$sending_limit' , ";
  $sql.= "sending_method='$sending_method', ";
  $sql.= "sub_validation='$sub_validation', ";
  $sql.= "unsub_validation='$unsub_validation', ";
  $sql.= "admin_email='$admin_email', ";
  $sql.= "admin_name='$admin_name' ,";
  //	$sql.= "mod_post='$mod_post' ,";
  $sql.= "mod_sub='$mod_sub' , ";
  $sql.= "charset='$charset', ";
  $sql.= "mod_sub_table='$table_sub', ";
  $sql.= "validation_period='$validation_period' ";
  if($sending_method=='smtp'){
    $sql.= ", smtp_host='$smtp_host', ";
    $sql.= "smtp_auth='$smtp_auth' ";
    if($smtp_auth==1){
      $sql.= ", smtp_login='$smtp_login', ";
      $sql.= "smtp_pass='$smtp_pass'";
    }	
    else {
      $sql.= ", smtp_login='', ";
      $sql.= "smtp_pass=''";
      
    }
  }
  else 
    {
      $sql.= ", smtp_host='', ";
      $sql.= "smtp_auth='0' ";
      $sql.= ", smtp_login='', ";
      $sql.= "smtp_pass=''";
      
      
    }
	
  $db->DbQuery($sql);
  
  if($db->DbError()) return 0;
      else return 1;
      }
  }
}
?>
Return current item: phpMyNewsLetter