-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaol_utility.php
More file actions
54 lines (51 loc) · 1.24 KB
/
Copy pathaol_utility.php
File metadata and controls
54 lines (51 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
// this class want to define some common function for convenient to access aol_log
include_once("kit_lib.php");
class aol_utility {
//public function __construct($argc, $argv){
//$para = ParameterParser($argc, $argv);
//}
public $output_fp;
public $err_fp;
public function __construct($para){
if (isset($para["o"])){
$this->output_fp = fopen($para["o"], "w");
if ($this->output_fp == NULL){
fprintf(STDERR, "%s can't be opened\n", $para["o"]);
$this->output_fp = STDOUT;
}
}else{
$this->output_fp = STDOUT;
}
if (isset($para["err"])){
$this->err_fp = fopen($para["err"], "w");
if ($this->err_fp == NULL){
fprintf(STDERR, "%s can't be opened\n", $para["err"]);
$this->err_fp = STDERR;
}
}else{
$this->err_fp = STDERR;
}
}
public function __destruct(){
if ($this->output_fp != STDOUT){
fclose($this->output_fp);
}
if ($this->err_fp != STDERR){
fclose($this->err_fp);
}
}
public function convert_safe_str($str){
$s_str = preg_replace("/'/", "\\\'", $str);
return $s_str;
}
public function cut_last_newline($str){
$r_str = preg_replace("/\n$/", "", $str);
return $r_str;
}
public function split_tab($str){
$r_array = preg_split("/\t/", $str);
return $r_array;
}
}
?>