public static function addDay($file, $data) { return parent::putSomeData($file, $data); }
public static function appendTable($file, $data) { if (file_exists($file)) { $l = filemtime($file); $l = Date("ymdHis", $l); if (substr($file, strlen($file) - 4) == ".txt") { $bakF = substr($file, 0, strlen($file) - 3) . $l . ".txt"; } else { $bakF = $file . "." . $l . ".txt"; } rename($file, $bakF); copy($bakF, $file); } return TableFile::putSomeData($file, $data); }
public static function importOnce() { $dir = dir('D:\\wamp\\www\\ForeShadowAlpha\\data\\tmp'); $filelist = array(); while (($file = $dir->read()) !== false) { if (substr($file, 0, 3) == 'ths') { //echo "filename: " . $file . "<br />"; $filelist[] = $file; } } $dir->close(); sort($filelist); //print_r($filelist); //echo '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body>'; //$i = 1; foreach ($filelist as $file) { //if ( --$i < 0 ) exit(0); //echo "filename: " . $file . "<br />"; $content = DataFile::getFileContent('D:\\wamp\\www\\ForeShadowAlpha\\data\\tmp/' . $file); //echo $content; $rows = explode("\n\r", $content); if (!$file) { continue; } foreach ($rows as $row) { if (!$row) { continue; } $lie = explode('|', $row); //get Code $r = "/[0-9]{6}/"; preg_match($r, $lie[0], $code); //echo $lie[0] . $code[0]; $c = $code[0]; $r = substr($code[0], 0, 1); if ($r == '6') { $code = 'sh' . $c; } else { if ($r == '0') { $code = 'sz' . $c; } else { if ($r == '3') { $code = 'sz' . $c; } } } //echo $code . "<br />"; $thsPath = 'D:\\wamp\\www\\ForeShadowAlpha\\data\\thsdoctor/'; $thsFile = $thsPath . $code . '.txt'; echo $thsFile . "<br />"; $thsRow = array(); //time $r = "/[0-9.]+/"; preg_match_all($r, $lie[3], $k); //if (sizeof($k) < 5 ) continue; $t = $k[0][0] . '-' . $k[0][1] . '-' . $k[0][2]; //echo $t. "<br />"; //echo $k[0][3]. "<br />"; $thsRow['time'] = $t; $thsRow['hour'] = $k[0][3] . ':' . $k[0][4]; //total $r = "/([0-9.]+)分/"; preg_match($r, $lie[2], $k); //echo $k[0].'--'.$k[1]."<br />"; $thsRow['total_score'] = $k[1]; $thsRow['total_text'] = $lie[13]; //shot_trend $thsRow['shot_trend'] = $lie[5]; //mid_trend $thsRow['mid_trend'] = $lie[6]; //long_trend $thsRow['long_trend'] = $lie[7]; //technical $r = "/([0-9.]+)/"; preg_match($r, $lie[8], $k); $thsRow['technical_score'] = $k[0]; //echo $k[0]."<br />"; $k = trim($lie[8]); $kk = preg_split('/\\s/', $k, -1, PREG_SPLIT_NO_EMPTY); $thsRow['technical_text'] = end($kk); //funds $r = "/([0-9.]+)/"; preg_match($r, $lie[9], $k); $thsRow['funds_score'] = $k[0]; //echo $k[0]."<br />"; $k = trim($lie[9]); $kk = preg_split('/\\s/', $k, -1, PREG_SPLIT_NO_EMPTY); $thsRow['funds_text'] = end($kk); //message $r = "/([0-9.]+)/"; preg_match($r, $lie[10], $k); $thsRow['message_score'] = $k[0]; //echo $k[0]."<br />"; $k = trim($lie[10]); $kk = preg_split('/\\s/', $k, -1, PREG_SPLIT_NO_EMPTY); $thsRow['message_text'] = end($kk); //trade $r = "/([0-9.]+)/"; preg_match($r, $lie[11], $k); $thsRow['trade_score'] = $k[0]; //echo $k[0]."<br />"; $k = trim($lie[11]); $kk = preg_split('/\\s/', $k, -1, PREG_SPLIT_NO_EMPTY); $thsRow['trade_text'] = end($kk); //basic $r = "/([0-9.]+)/"; preg_match($r, $lie[12], $k); $thsRow['basic_score'] = $k[0]; //echo $k[0]."<br />"; $k = trim($lie[12]); $kk = preg_split('/\\s/', $k, -1, PREG_SPLIT_NO_EMPTY); $thsRow['basic_text'] = end($kk); //print_r($thsRow); //echo "<br />"; TableFile::putSomeData($thsFile, array($thsRow)); } } }
public static function addThsDoctor($file, $data) { return parent::putSomeData($file, $data); }