-- selected="true" -> selected="selected"
- アプリケーションIDの始めの文字に数値を許していたバグを修正
-- クラス名のprefixになるため、数値を許すと自動生成物がコンパイルエラーを起こす
+- Ethna_Util#getRandom で open_basedir が有効な場合に、 /proc を開けず警告が出る点を回避(thanks. sotarok)
+-- http://d.hatena.ne.jp/sotarok/20070813/1187055110
** 2.3.5
$value = "";
for ($i = 0; $i < 2; $i++) {
// for Linux
- if (file_exists('/proc/net/dev')) {
+ // open_basedir がオンで、かつ /proc が許可されているか?
+ // open_basedir が空なら許可されていると看做す
+ $devfile = '/proc/net/dev';
+ $open_basedir_conf = ini_get('open_basedir');
+ $devfile_enabled = (empty($open_basedir_conf)
+ || (preg_match('#:/proc#', $open_basedir_conf) > 0
+ || preg_match('#^/proc#', $open_basedir_conf) > 0));
+
+ if ($devfile_enabled && file_exists($devfile)) {
$rx = $tx = 0;
- $fp = fopen('/proc/net/dev', 'r');
+ $fp = fopen($devfile, 'r');
if ($fp != null) {
$header = true;
while (feof($fp) === false) {
<?php
+// vim: foldmethod=marker
/**
* Ethna_Util_Test.php
*/
+error_reporting(E_ALL);
/**
* Ethna_Utilクラスのテストケース(1)
*
*/
class Ethna_Util_Test extends Ethna_UnitTestBase
{
+ // {{{ testIsRootDir
function testIsRootDir()
{
$this->assertTrue(DIRECTORY_SEPARATOR);
$this->assertFalse($util->isRootDir("/test.txt"));
}
}
+ // }}}
-
+ // {{{ testCheckMailAddress
function testCheckMailAddress()
{
$fail_words = array(
$result = $util->checkMailAddress('hoge@fuga.net');
$this->assertTrue($result);
}
+ // }}}
+ // {{{ testIsAbsolute
function testIsAbsolute()
{
$absolute_paths = array(
foreach ($invalid_params as $path) {
$this->assertFalse(Ethna_Util::isAbsolute($path));
}
- }
+ }
+ // }}}
+
+ // {{{ testGetRandom
+ function testGetRandom()
+ {
+ // いかなる状態であっても
+ // 値が得られなければならない
+ $r = Ethna_Util::getRandom();
+ $this->assertNotNULL($r);
+ }
+ // }}}
+
+
+
}
+
?>