Tag Archives: config

PHP: DBConfig Class

This is a short note, my own bicycle:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
class DBConfig{
    private $hostname;
    private $port;
    private $username;
    private $password;
    private $dbname;
   
    public function &__get($property) {
        if(property_exists($this, $property)){
            return $this->$property;
        }
    }

    public function __set($property, $value) {
        if(property_exists($this, $property)){
            $this->$property = $value;
        }
    }
}
?>

How to use:

1
2
3
4
5
6
    $dbconf = new DBConfig();
    $dbconf->hostname = "127.0.0.1";
    $dbconf->port = 6432;
    $dbconf->username = "user_ro";
    $dbconf->password = "user_ro_pass";
    $dbconf->dbname = "test_db";

Then you could use it where do you want:
pgsql:

1
$dbconn = pg_connect("host = $dbconf->hostname port = $dbconf->port, dbname = $dbconf->dbname, user = $dbconf->username, password = $dbconf->password options='--client_encoding=UTF8'");

backup mp-124

Save the config with Audiocodes MediaPack 124 on the list of ip:

#!/bin/sh
 day=`/bin/date "+%Y%m%d"`
 home_dir="/home/alter/backups/mp124/$day"
 /bin/mkdir $home_dir;
 /bin/cat /home/alter/mp124ip.txt | /usr/bin/awk '{system("/usr/local/bin/curl --digest --url http://Admin:Admin@"$1"/FS/BOARD.ini>'$home_dir'/"$1".ini")}'

Create a text file mp124ip.txt and fill it with the principle of one-row 1 IP Address:

10.166.10.4
192.168.1.34

and etc...