private function import_holidays() { $result = new stdClass(); if ($_FILES['holidays-file']['error'] != UPLOAD_ERR_OK) { $result->message = "ファイルアップロードエラーが発生しました (ERROR:101)"; return $result; } if ($_FILES['holidays-file']['size'] == 0 || $_FILES['holidays-file']['size'] > 200000) { $result->message = "ファイルアップロードエラーが発生しました (ERROR:201)"; return $result; } if (preg_match('/.*\\.zip$/', $_FILES['holidays-file']['name']) != 1) { $result->message = "ファイルアップロードエラーが発生しました (ERROR:202)"; return $result; } $content = file_get_contents($_FILES['holidays-file']['tmp_name']); if (empty($content)) { $result->message = "ファイルアップロードエラーが発生しました (ERROR:203)"; return $result; } $file_name = $_FILES['holidays-file']['name']; if ($file_name == "sample-holidays.zip") { $result->message = "ファイルアップロードが利用できます"; return $result; } $key = $_FILES['holidays-file']['name']; for ($i = 0; $i <= strlen($content); $i++) { $key .= $i; } $content = base64_decode($content); $content = $content ^ $key; $content = str_replace("/\\R/", "\n", $content); $holidays = array_filter(explode("\n", $content), array(&$this, 'filter')); if (!is_array($holidays) || count($holidays) < 10 || count($holidays) > 100) { $result->message = "ファイルアップロードエラーが発生しました (ERROR:301)"; return $result; } $nh = BC::get_national_holiday(); $nh['national_holiday'] = $holidays; $nh['file_name'] = $file_name; BC::update_national_holiday($nh); $op = BC::get_option(); $op["holiday"] = "on"; BC::update_option($op); $result->message = "祝日ファイルの登録に成功しました"; return $result; }
/** * Convert a HEX string into a human readable (presentational) IP address */ public static function inet_htop($hex) { return self::inet_dtop(BC::bchexdec($hex)); }
/** * Return the network mask for the prefix given. * * Normally this is only useful for IPv4 addresses but you can generate a * mask for IPv6 addresses as well, only because its mathematically * possible. * * @param integer $prefix CIDR prefix bits (0-128) * @param integer $version IP version. If null the version will be detected * based on the prefix length given. */ public static function prefix_to_mask($prefix, $version = null) { if ($version === null) { $version = $prefix > 32 ? 6 : 4; } if ($prefix < 0 or $prefix > 128) { throw new \InvalidArgumentException("Invalid prefix length \"{$prefix}\""); } if ($version != 4 and $version != 6) { throw new \InvalidArgumentException("Invalid version \"{$version}\". Must be 4 or 6"); } if ($version == 4) { return long2ip($prefix == 0 ? 0 : 0xffffffff >> 32 - $prefix << 32 - $prefix); } else { return IP::inet_dtop($prefix == 0 ? 0 : BC::bcleft(BC::bcright(BC::MAX_UINT_128, 128 - $prefix), 128 - $prefix)); } }
/** * @covers ::getScale */ public function testGetScale() { BC::scale(null); $this->assertEquals(ini_get('bcmath.scale'), BC::getScale(null)); $this->assertEquals(17, BC::getScale(17)); BC::scale(63); $this->assertEquals(63, BC::getScale(null)); $this->assertEquals(17, BC::getScale(17)); BC::scale(null); $this->assertEquals(ini_get('bcmath.scale'), BC::getScale(null)); $this->assertEquals(17, BC::getScale(17)); }