Browse Source

php - encode text where required to avoid messing up the html display

master
kanoi 10 years ago
parent
commit
c0ccf9b8ec
  1. 10
      pool/base.php
  2. 11
      pool/page.php
  3. 2
      pool/page_blocks.php
  4. 4
      pool/page_settings.php
  5. 2
      pool/page_stats.php
  6. 4
      pool/page_userset.php
  7. 2
      pool/page_workers.php
  8. 7
      pool/page_workmgt.php

10
pool/base.php

@ -18,6 +18,16 @@ function adddbg($str)
} }
} }
# #
function sq($str)
{
return str_replace("'", "\\'", $str);
}
#
function dq($str)
{
return str_replace('"', "\\\"", $str);
}
#
function howlongago($sec) function howlongago($sec)
{ {
if ($sec < 60) if ($sec < 60)

11
pool/page.php

@ -315,10 +315,15 @@ function pgtop($info, $dotop, $user, $douser)
} }
else else
{ {
if (substr($who, 0, 1) == '1' && strlen($who) > 12) $extra = '';
$who = substr($who, 0, 11) . '&#133;'; $first = substr($who, 0, 1);
if (($first == '1' || $first == '3') && strlen($who) > 12)
{
$who = substr($who, 0, 11);
$extra = '&#133;';
}
$top .= " $top .= "
<span class=topwho>$who&nbsp;</span> <span class=topwho>".htmlspecialchars($who)."$extra&nbsp;</span>
<span class=topdes>Hash Rate:</span> <span class=topdes>Hash Rate:</span>
<span class=topdat>$uhr/$u1hr</span>"; <span class=topdat>$uhr/$u1hr</span>";
$top .= makeForm('')." $top .= makeForm('')."

2
pool/page_blocks.php

@ -111,7 +111,7 @@ function doblocks($data, $user)
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= "<td class=dl$ex>$hifld</td>"; $pg .= "<td class=dl$ex>$hifld</td>";
$pg .= "<td class=dl$ex>".$ans['workername:'.$i].'</td>'; $pg .= "<td class=dl$ex>".htmlspecialchars($ans['workername:'.$i]).'</td>';
$pg .= "<td class=dr$ex>".btcfmt($ans['reward:'.$i]).'</td>'; $pg .= "<td class=dr$ex>".btcfmt($ans['reward:'.$i]).'</td>';
$pg .= "<td class=dl$ex>".gmdate('Y-m-d H:i:s+00', $ans['firstcreatedate:'.$i]).'</td>'; $pg .= "<td class=dl$ex>".gmdate('Y-m-d H:i:s+00', $ans['firstcreatedate:'.$i]).'</td>';
$pg .= "<td class=dr$ex>".$stat.'</td>'; $pg .= "<td class=dr$ex>".$stat.'</td>';

4
pool/page_settings.php

@ -18,7 +18,7 @@ function settings($data, $user, $email, $addr, $err)
$pg .= '<tr class=dc><td class=dr>'; $pg .= '<tr class=dc><td class=dr>';
$pg .= 'EMail:'; $pg .= 'EMail:';
$pg .= '</td><td class=dl>'; $pg .= '</td><td class=dl>';
$pg .= "<input type=text name=email value='$email' size=20>"; $pg .= "<input type=text name=email value='".sq($email)."' size=20>";
$pg .= '</td></tr>'; $pg .= '</td></tr>';
$pg .= '<tr class=dc><td class=dr>'; $pg .= '<tr class=dc><td class=dr>';
$pg .= 'Password:'; $pg .= 'Password:';
@ -41,7 +41,7 @@ function settings($data, $user, $email, $addr, $err)
$pg .= '<tr class=dc><td class=dr>'; $pg .= '<tr class=dc><td class=dr>';
$pg .= 'BTC Address:'; $pg .= 'BTC Address:';
$pg .= '</td><td class=dl>'; $pg .= '</td><td class=dl>';
$pg .= "<input type=text name=baddr value='$addr' size=42>"; $pg .= "<input type=text name=baddr value='".sq($addr)."' size=42>";
$pg .= '</td></tr>'; $pg .= '</td></tr>';
$pg .= '<tr class=dc><td class=dr>'; $pg .= '<tr class=dc><td class=dr>';
$pg .= 'Password:'; $pg .= 'Password:';

2
pool/page_stats.php

@ -84,7 +84,7 @@ function dostats($data, $user)
$row = 'odd'; $row = 'odd';
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= '<td class=dl>'.$all[$i]['username'].'</td>'; $pg .= '<td class=dl>'.htmlspecialchars($all[$i]['username']).'</td>';
$uhr = $all[$i]['u_hashrate5m']; $uhr = $all[$i]['u_hashrate5m'];
if ($uhr == '?') if ($uhr == '?')
$dsp = '?GHs'; $dsp = '?GHs';

4
pool/page_userset.php

@ -30,7 +30,9 @@ function uset($data, $user, $api, $err)
$pg .= '<tr class=dc><td>&nbsp;</td></tr>'; $pg .= '<tr class=dc><td>&nbsp;</td></tr>';
$pg .= '<tr class=dc><td>You can access the API via:'; $pg .= '<tr class=dc><td>You can access the API via:';
$pg .= '</td></tr><tr class=dc><td>'; $pg .= '</td></tr><tr class=dc><td>';
$pg .= "<span class=hil>/index.php?k=api&username=$user&api=$api&json=y</span><br>"; $pg .= "<span class=hil>/index.php?k=api&username=";
$pg .= htmlspecialchars(urlencode($user));
$pg .= "&api=$api&json=y</span><br>";
$pg .= '</td></tr>'; $pg .= '</td></tr>';
} }
$pg .= '</table></form>'; $pg .= '</table></form>';

2
pool/page_workers.php

@ -41,7 +41,7 @@ function workuser($data, $user, &$offset, &$totshare, &$totdiff,
$row = 'odd'; $row = 'odd';
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= '<td class=dl>'.$ans['workername:'.$i].'</td>'; $pg .= '<td class=dl>'.htmlspecialchars($ans['workername:'.$i]).'</td>';
if ($ans['w_lastdiff:'.$i] > 0) if ($ans['w_lastdiff:'.$i] > 0)
$ld = difffmt($ans['w_lastdiff:'.$i]); $ld = difffmt($ans['w_lastdiff:'.$i]);
else else

7
pool/page_workmgt.php

@ -29,12 +29,13 @@ function workmgtuser($data, $user, $err)
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$wn = $ans['workername:'.$i]; $wn = htmlspecialchars($ans['workername:'.$i]);
$wnv = sq($ans['workername:'.$i]);
$pg .= '<td class=dl>'; $pg .= '<td class=dl>';
$pg .= "<input type=hidden name='workername:$i' value='$wn'>"; $pg .= "<input type=hidden name='workername:$i' value='$wnv'>";
$pg .= $wn.'</td>'; $pg .= $wn.'</td>';
$md = $ans['difficultydefault:'.$i]; $md = intval($ans['difficultydefault:'.$i]);
$pg .= '<td class=dr>'; $pg .= '<td class=dr>';
$pg .= "<input type=text size=6 name='difficultydefault:$i' value='$md'>"; $pg .= "<input type=text size=6 name='difficultydefault:$i' value='$md'>";
$pg .= "<input type=submit name=OK value=OK>"; $pg .= "<input type=submit name=OK value=OK>";

Loading…
Cancel
Save