2048000) { $dir = opendir($logdir); $length = strlen($file); $maxid = $id = 0; while($entry = readdir($dir)) { if(strpos($entry, $yearmonth.'_'.$file) !== false) { $id = intval(substr($entry, $length + 8, -4)); $id > $maxid && $maxid = $id; } } closedir($dir); $logfilebak = $logdir.$yearmonth.'_'.$file.'_'.($maxid + 1).'.php'; @rename($logfile, $logfilebak); } if($fp = @fopen($logfile, 'a')) { @flock($fp, 2); if(!is_array($log)) { $log = array($log); } foreach($log as $tmp) { fwrite($fp, "\t".str_replace(array(''), '', $tmp)."\n"); } fclose($fp); } } public static function useractionlog($uid, $action) { $uid = intval($uid); if(empty($uid) || empty($action)) { return false; } $action = getuseraction($action); C::t('common_member_action_log')->insert(array('uid' => $uid, 'action' => $action, 'dateline' => TIMESTAMP)); return true; } public static function getuseraction($var) { $value = false; $ops = array('tid', 'pid', 'blogid', 'picid', 'doid', 'sid', 'aid', 'uid_cid', 'blogid_cid', 'sid_cid', 'picid_cid', 'aid_cid', 'topicid_cid', 'pmid'); if(is_numeric($var)) { $value = isset($ops[$var]) ? $ops[$var] : false; } else { $value = array_search($var, $ops); } return $value; } } ?>