From 2c2bf879ba151597584f4283b97856f38c847536 Mon Sep 17 00:00:00 2001 From: kanoi Date: Tue, 10 May 2016 13:59:47 +1000 Subject: [PATCH] php - shorten long wokernames on the blocks page --- pool/base.php | 13 +++++++++++++ pool/page_blocks.php | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pool/base.php b/pool/base.php index a016fc3e..64f7ee5c 100644 --- a/pool/base.php +++ b/pool/base.php @@ -233,6 +233,19 @@ function difffmt($amt) return siprefmt($amt, 3); } # +function dspname($name) +{ + if (strlen($name) < 23) + return array(false, htmlspecialchars($name)); + + if (strpbrk($name, '._') === false) + return array(false, htmlspecialchars(substr($name, 0, 20)).'…'); + + $left = htmlspecialchars(substr($name, 0, 17)); + $right = htmlspecialchars(substr($name, -3)); + return array(true, $left.'…'.$right); +} +# function emailStr($str) { $all = '/[^A-Za-z0-9_+\.@-]/'; // no space = trim diff --git a/pool/page_blocks.php b/pool/page_blocks.php index 231703ad..6a1591a9 100644 --- a/pool/page_blocks.php +++ b/pool/page_blocks.php @@ -330,7 +330,10 @@ function doblocks($data, $user) $pg .= "$seq"; $pg .= "$hifld"; if ($user !== null) - $pg .= "".htmlspecialchars($ans['workername:'.$i]).''; + { + list($abr, $nam) = dspname($ans['workername:'.$i]); + $pg .= "$nam"; + } $pg .= "".btcfmt($ans['reward:'.$i]).''; $pg .= "".utcd($ans['firstcreatedate:'.$i], false, false).''; $pg .= "$tt$stat";