Last active
October 26, 2016 00:46
Revisions
-
WebPlatformDocs revised this gist
Oct 26, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -82,7 +82,7 @@ break; default: $m = $row['message']; $fmt = sprintf('%s %s: %s (type: %s)', $row['time'], $row['name'], $m, $row['type']); break; } echo $fmt.PHP_EOL; -
WebPlatformDocs created this gist
Oct 26, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,103 @@ <?php /** * Export LumberJack IRC log to text **/ $username='lumberjack_user'; $password='secretpassword'; $database='lumberjack'; $host='10.10.10.3'; try { if (!ini_get('mysqli.default_socket')) { $message = 'mysqli.default_socket PHP ini setting is not set, we cannot use this health check'; throw new Exception($message); } $mysqli = new mysqli($host, $username, $password, $database); if ($mysqli->connect_error) { $message = sprintf('Connect error %s: %s', $mysqli->connect_errno, $mysqli->connect_error); throw new Exception($message); } $channel = "webplatform"; $query = sprintf('select * from main WHERE channel = "%s"', $channel); $stmt = $mysqli->prepare($query); $stmt->execute(); /* +--------+ | type | +--------+ | join | | pubmsg | | action | | topic | | quit | | part | | nick | +--------+ */ //echo '['.PHP_EOL; $result = $stmt->get_result(); while ($row = $result->fetch_assoc()) { /** * $row = [ * "id": int(20) * "channel": string(11) "webplatform" * "name": string(7) "shepazu" * "time": string(19) "2012-10-08 00:08:22" * "message": string(15) "wp-logger, help" * "type": string(6) "pubmsg" * "hidden": string(1) "F" * ] **/ unset($row['hidden'], $row['id'], $row['channel']); //$row['message'] = (empty($row['message']))?null:$row['message']; //echo json_encode($row).','.PHP_EOL; ///* switch($row['type']){ case 'quit': case 'part': $m = (!empty($row['message']))?$row['message']:$row['type']; $fmt = sprintf('%s %s: %s', $row['time'], $row['name'], $m); break; case 'join': $fmt = sprintf('%s %s joined', $row['time'], $row['name']); break; case 'nick': $fmt = sprintf('%s %s is now known as %s', $row['time'], $row['name'], $row['message']); break; case 'topic': $fmt = sprintf('%s %s changed topic to: %s', $row['time'], $row['name'], $row['message']); break; case 'action': $fmt = sprintf('%s %s %s', $row['time'], $row['name'], $row['message']); break; case 'pubmsg': $fmt = sprintf('%s %s: %s', $row['time'], $row['name'], $row['message']); break; default: $m = $row['message']; $fmt = sprintf('%s %s: %s foo:%s', $row['time'], $row['name'], $m, $row['type']); break; } echo $fmt.PHP_EOL; //*/ } //echo ']'.PHP_EOL; //echo PHP_EOL; //echo $query.PHP_EOL; $mysqli->close(); } catch(Exception $e) { $message = $e->getMessage(); trigger_error($message); echo $message.PHP_EOL; exit(1); }