<?php include __DIR__ . '/init.php'; Pix_Table::$_save_memory = true; $last_time = intval(KeyValue::get('snapshot_at')); // dump count while (true) { $min_time = RankData::search("`time` > {$last_time}")->min('time')->time; if (!$min_time) { break; } $month_start = mktime(0, 0, 0, date('m', $min_time), 1, date('Y', $min_time)); $month_end = strtotime('+1 month', $month_start); $filename = 'ptthot-' . date('Ym', $month_start) . '.csv.gz'; $temp = tmpfile(); $meta_data = stream_get_meta_data($temp); $tmp_filename = $meta_data['uri']; $stream = gzopen($tmp_filename, 'w'); fwrite($stream, "#board,timestamp,count\n"); foreach (RankData::search("`time` >= {$month_start} AND `time` < {$month_end}")->order(array('board', 'time'))->volumemode(10000) as $rankdata) { $last_time = max($last_time, $rankdata->time); fwrite($stream, "{$rankdata->board},{$rankdata->time},{$rankdata->count}\n"); } fclose($stream); DropboxLib::putFile($tmp_filename, $filename); fclose($temp); KeyValue::set('snapshot_at', $last_time); } //dump titlehistory $filename = 'ptthot-title.csv.gz'; $temp = tmpfile();
<?php require '../../lib.php'; $open_ids = KeyValue::get(KEY_APP_ALL_CORPORATION); $model = new CSCorpModel(); $data = array(); if (empty($open_ids)) { $data = array(msg => '还没有任何公司主号开启该app'); } else { foreach ($open_ids as $open_id) { $a = $model->getCorpInfo($open_id); $data[$open_id]['info'] = $a; $tokens = $model->getAllToken($open_id); $data[$open_id]['tokens'] = $tokens; } } OpenUtils::outputJson($data);
public function companyId() { $companyId = ''; if ($this->id() !== '') { $model = new CSCorpModel(); $companyId = $model->getCompanyIdByOpenId($this->id()); } else { $open_ids = KeyValue::get(KEY_APP_ALL_CORPORATION); $companyId = $open_ids[0]; } return $companyId; }
<?php require '../../lib.php'; $company_ids = KeyValue::get(KEY_APP_ALL_CORPORATION); $model = new CSCorpModel(); $data = array(); foreach ($company_ids as $company_id) { $tokens = KeyValue::get(KEY_ACCESSTOKEN . $company_id); $result = $model->refreshToken($tokens['refresh_token']); if ($result != false) { $refresh_tokens = $result; $refresh_tokens['company_id'] = $tokens['company_id']; $refresh_tokens['is_open'] = $tokens['is_open']; saveToken($refresh_tokens); } $tokens_after = KeyValue::get(KEY_ACCESSTOKEN . $company_id); $data[$company_id]['刷新前'] = $tokens; $data[$company_id]['刷新结果'] = $result; $data[$company_id]['刷新后'] = $tokens_after; } OpenUtils::outputJson($data);