2013年8月31日 星期六

Windows Server 2012 重複資料刪除功能

Windows PowerShell 輸入以下指令來安裝重複資料刪除功能:
Import-Module ServerManager
Add-WindowsFeature -name FS-Data-Deduplication
Import-Module Deduplication

PHP 標準輸出/輸入/STDIN /STOOUT

$fp = fopen("php://stdin", "r");
$fp2 = fopen("php://stdout", "w");

while (!feof($fp)) {
    $buffer = fgets($fp);
    fputs($fp2, "input:$buffer");
}
fclose($fp);
fclose($fp2);

echo "exit";
?>

/etc/network/interface 範例

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual
        bond-master bond0

auto eth1
iface eth1 inet manual
        bond-master bond0

auto bond0
iface bond0 inet static
        address 10.0.0.1
        netmask 255.255.255.0
        gateway 10.0.0.254
        bond-slaves none
        bond-mode active-backup
        bond-miimon 100
        bond-fail-over-mac 1


auto vlan5
iface vlan5 inet manual
    vlan_raw_device bond0


auto eth2:1
iface eth2:1 inet static
    address 192.168.9.101
    netmask 255.255.0.0
    network 192.168.0.0
    broadcast 192.168.255.255
    gateway 192.168.1.1
    # dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 192.168.1.1

2013年8月30日 星期五

PHP Radius認證範例

$username = 'test';
$password = 'test';
$radserver = '192.168.6.4';
$radport = 1812;
$sharedsecret = '1234567890';

$res = radius_auth_open();
echo "$res
\n";

while(1){
  if (!radius_add_server($res, $radserver, $radport, $sharedsecret, 3, 3)) break;
  if (!radius_create_request($res, RADIUS_ACCESS_REQUEST)) break;

//  if (!radius_put_string($res, RADIUS_NAS_IDENTIFIER, isset($HTTP_HOST) ? $HTTP_HOST : 'localhost')) break;
//  if (!radius_put_int($res, RADIUS_SERVICE_TYPE, RADIUS_FRAMED)) break;
//  if (!radius_put_int($res, RADIUS_FRAMED_PROTOCOL, RADIUS_PPP)) break;
//  if (!radius_put_string($res, RADIUS_CALLING_STATION_ID, isset($REMOTE_HOST) ? $REMOTE_HOST : '127.0.0.1') == -1) break;

  if (!radius_put_string($res, RADIUS_USER_NAME, $username)) break;
  if (!radius_put_string($res, RADIUS_USER_PASSWORD, $password)) break;

  $req = radius_send_request($res);
  if (!$req) break;

  if($req== RADIUS_ACCESS_ACCEPT) echo "ok";
  else echo "fail";

  exit();
}

echo 'RadiusError:' . radius_strerror($res);

?>

參考文件
http://sophie.zarb.org/distrib/Mandriva/cooker/x86_64/rpms/php-radius/files/10 
http://php.net/manual/en/radius.constants.attributes.php

CentOS release 6.3 安裝 php radius 套件

yum install php-pear
yum install php-devel
yum install gcc

pear channel-update pear.php.net
pecl install radius

echo extension=radius.so > /etc/php.d/radius.ini