function truncate($text, $maxTextLength, $maxLines) { $lines = explode("\n", $text); $visibleLines = array_filter($lines); if (count($visibleLines) > $maxLines) { $newContent = array(); $visibleLinesAdded = 0; $i = 0; while ($visibleLinesAdded < $maxLines && $i < count($lines)) { $line = $lines[$i]; $newContent[] = $line; if (trim($line) != '') { $visibleLinesAdded++; } $i++; } $text = implode("\n", $newContent); // Tack on extra chars and then tell cassis to ellipsize it shorter to take advantage of proper ellipsizing logic. // This is for when the full text is shorter than $maxTextLength but has more lines than $maxLines $text .= ' ....'; $text = truncateString($text, min($maxTextLength, strlen($text) - 1)); } else { $text = truncateString($text, $maxTextLength); } return $text; }
function _make_url_clickable_cb($matches) { $ret = ''; $url = $matches[2]; if (empty($url)) { return $matches[0]; } // removed trailing [.,;:] from URL if (in_array(substr($url, -1), array('.', ',', ';', ':')) === true) { $ret = substr($url, -1); $url = substr($url, 0, strlen($url) - 1); } if (strpos($url, 'pbs.twimg.com') !== false) { return $matches[1] . "<img src=\"{$url}\" alt=\"{$url}\" />" . $ret; } return $matches[1] . "<a href=\"{$url}\" rel=\"nofollow\">" . truncateString($url) . "</a>" . $ret; }
<center><b>Bug tracker allows you to view current bugs on the server, also you are able to send bug notices to be fixed.</b></center> <br /> <?php if (count($bugs) == 0) { alert("No bugs has been submited."); } else { echo "<center>" . $pages . "</cemter>"; echo "<table width='100%'>"; echo "<tr><td width='2%'></td><td width='30%'><center><b>Title</b></center></td><td><center><b>Category</b></center></td><td><center><b>Priority</b></center></td><td><center><b>Author</b></center></td><td><center><b>Done</b></center></td><td><center><b>Time</b></center></td></tr>"; foreach ($bugs as $bug) { $status = $bug['closed'] == 0 ? "open.gif" : "closed.gif"; echo "<tr class='bugtrackerRow'><td><center><img src='" . WEBSITE . "/public/images/bugtracker/" . $status . "'></center></td><td width='30%'><center><a href='" . WEBSITE . "/index.php/bugtracker/view/" . $bug['id'] . "'>" . truncateString($bug['title'], 26) . "</a></center></td><td><center>" . bugtracker_getCategory($bug['category']) . "</center></td><td><center>" . bugtracker_getPriorityImage($bug['priority']) . " " . bugtracker_getPriority($bug['priority']) . "</center></td><td><center><a href='" . WEBSITE . "/index.php/character/view/" . $bug['name'] . "'>" . $bug['name'] . "</a></center></td><td><center><div class='bugtrackerProgressBar'><div class='bugtrackerProgress' style='width: " . $bug['done'] . "%;'></div></div>" . $bug['done'] . "%</center></td><td><center>" . ago($bug['time']) . "</center></td></tr>"; } echo "</table>"; } echo "<center>" . $pages . "</cemter>";
} $answer = array('assignment_id' => $assignmentID, 'scores' => $scores, 'num_reviews' => $numReviews, 'avg_score' => getAvg($scores, $numReviews)); $scoresArr[] = $answer; // push to array } // (reverse) sort answers by average review score usort($scoresArr, 'sortByAvgScore'); foreach ($scoresArr as $s) { $q = sprintf("SELECT * FROM app_db WHERE assignment_id = '%s'", $s['assignment_id']); $results = mysql_query($q); while ($row = mysql_fetch_assoc($results)) { echo '<tr>'; echo '<td class="dash_table_text_vertical_middle">' . truncateString($row['description']) . '</td>'; echo '<td class="dash_table_text_vertical_middle">' . truncateString($row['location']) . '</td>'; echo '<td class="dash_table_text_horizontal_center dash_table_text_vertical_middle">' . $row['confidence'] . '</td>'; echo '<td class="dash_table_text_vertical_middle">' . truncateString($row['why']) . '</td>'; echo '<td class="dash_table_text_horizontal_center dash_table_text_vertical_middle">' . $s['num_reviews'] . '</td>'; echo '<td class="dash_table_text_horizontal_center dash_table_text_vertical_middle">' . number_format($s['avg_score'], 1) . '</td>'; echo '<td> </td>'; echo '</tr>'; } } function sortByAvgScore($a, $b) { $aAvg = $a['avg_score']; $bAvg = $b['avg_score']; if ($aAvg == $bAvg) { return 0; } elseif ($aAvg > $bAvg) { return -1; } else {
$status = "stickclose.png"; } else { if ($thread['sticked'] == 1 and $thread['closed'] == 0) { $status = "sticked.png"; } else { if ($thread['sticked'] == 0 and $thread['closed'] == 1) { $status = "closedthread.png"; } else { $status = "open.png"; } } } if (empty($thread['post_author'])) { $last = "No posts"; } else { $last = "By <a href='" . WEBSITE . "/index.php/character/view/" . $thread['post_author'] . "'>" . truncateString($thread['post_author'], 10) . "</a><br /> " . ago($thread['post_time']); } echo "<div class='threadTable'>"; echo "<div class='threadStatus'>"; echo "<img src='" . WEBSITE . "/public/images/forum/" . $status . "'>"; echo "</div>"; echo "<div class='threadLeft'>"; echo "<div class='threadTitle'><a href='" . WEBSITE . "/index.php/forum/thread/" . $thread['id'] . "'>"; echo $thread['name']; echo "</a></div>"; echo "<div class='threadAuthor'>"; echo "Posted by: " . ucfirst($thread['author']); echo "</div>"; echo "</div>"; echo "<div class='threadRight'>"; echo $last;
} else { if ($primerRenglon == 0) { echo '<div class="row">'; } else { if ($numNoticiasSinNotaPrincipal % 2 != 0) { echo '<hr class="division_notas_listado"><div class="row">'; } } echo ' <div class="col-xs-6 col-lg-6 ">'; echo ' <div class="sub_noticia"> <a href="nota.php?id=' . $objNotice->id . '">'; echo ' <img class="notice_secondary_image" src="' . $objNotice->urlImageMain . '"/>'; echo ' <div class="noticia_secondary_summary">'; echo ' <h3>' . truncateString($objNotice->title, 47) . '</h3>'; echo ' <small> ' . getTimeDate(substr($objNotice->dateRegistration, 0, 10)) . '</small>'; echo ' <p>'; echo ' ' . truncateString($objNotice->summary, 117) . '</p>'; echo ' </div>'; echo ' </a>'; echo ' </div>'; echo ' </div><!--/.col-xs-6.col-lg-4-->'; if ($numNoticiasSinNotaPrincipal % 2 == 0) { echo '</div><!--/row-->'; $primerRenglon++; } $numNoticiasSinNotaPrincipal = $numNoticiasSinNotaPrincipal - 1; } $primernoticia++; } echo createPagination($objNoticeController->objNoticeService->totalNotices, $offset); } else { ?>
echo '<td width=32><a href="visitors.php?pageno=' . $i_pageno_count . $i_url_pages_addon . '"><img src="images/button-last-big.gif" border=0 title="' . $lngstr['button_last_page'] . '"></a></td>'; } else { echo '<td width=32><img src="images/button-next-big-inactive.gif" border=0 title="' . $lngstr['button_next_page'] . '"></td>'; echo '<td width=32><img src="images/button-last-big-inactive.gif" border=0 title="' . $lngstr['button_last_page'] . '"></td>'; } } echo '<td width=2><img src="images/toolbar-right.gif" width=2 height=32></td></tr></table>'; echo '</td></tr><tr><td>'; echo '<table class=rowtable2 cellpadding=5 cellspacing=1 border=0 width="100%">'; echo '<tr vAlign=top><td class=rowhdr1 title="' . $lngstr['label_hdr_select_hint'] . '" width=22><input type=checkbox name=toggleAll onclick="toggleCBs(this);"></td>'; writeQryTableHeaders('visitors.php?action=' . $i_url_limit_addon, $i_tablefields, $i_order_no, $i_direction); echo '<td class=rowhdr1 colspan=2>' . $lngstr['label_hdr_action'] . '</td></tr>'; $i_rSet1 = $g_db->SelectLimit("SELECT *, ip1, ip2, ip3, ip4, " . $srv_settings['table_prefix'] . "users.username FROM " . $srv_settings['table_prefix'] . "visitors, " . $srv_settings['table_prefix'] . "users WHERE ((" . $srv_settings['table_prefix'] . "visitors.id=0 AND " . $srv_settings['table_prefix'] . "users.id=2) OR " . $srv_settings['table_prefix'] . "visitors.id=" . $srv_settings['table_prefix'] . "users.id)" . $i_sql_order_addon, $i_limitcount, $i_limitfrom); if (!$i_rSet1) { showDBError(__FILE__, 1); } else { $i_counter = 0; while (!$i_rSet1->EOF) { $rowname = $i_counter % 2 ? "rowone" : "rowtwo"; $i_ip = $i_rSet1->fields['ip1'] . '.' . $i_rSet1->fields['ip2'] . '.' . $i_rSet1->fields['ip3'] . '.' . $i_rSet1->fields['ip4']; echo '<tr id=tr_' . $i_pagewide_id . ' class=' . $rowname . ' onmouseover="rollTR(' . $i_pagewide_id . ',1);" onmouseout="rollTR(' . $i_pagewide_id . ',0);"><td align=center width=22><input id=cb_' . $i_pagewide_id . ' type=checkbox name=box_visitors[] value="' . $i_rSet1->fields['visitorid'] . '" onclick="toggleCB(this);"></td><td align=right>' . $i_rSet1->fields['visitorid'] . '</td><td>' . getDateLocal($lngstr['language']['date_format'], $i_rSet1->fields['startdate']) . '</td><td><nobr>' . convertTextValue($i_rSet1->fields['username']) . ' [<a href="users.php?id=' . $i_rSet1->fields['id'] . '&action=edit" title="' . $lngstr['label']['view_edit_user'] . '">' . $i_rSet1->fields['id'] . '</a>]</nobr></td><td>' . $i_rSet1->fields['hits'] . '</td><td><a href="http://www.whois.sc/' . $i_ip . '" title="' . $lngstr['page_visitors']['ipwhois'] . '" target=_blank>' . $i_ip . '</a></td><td>' . truncateString(convertTextValue($i_rSet1->fields['host'])) . '</td><td>' . truncateString(convertTextValue($i_rSet1->fields['referer'])) . '</td>'; echo '<td align=center width=22><a href="visitors.php?action=view&visitorid=' . $i_rSet1->fields['visitorid'] . $i_order_addon . $i_url_limit_addon . '"><img width=20 height=20 border=0 src="images/button-view.gif" title="' . $lngstr['label_action_visitors_view'] . '"></a></td><td align=center width=22><a href="visitors.php?action=delete&visitorid=' . $i_rSet1->fields['visitorid'] . $i_order_addon . $i_url_limit_addon . '" onclick="return confirmMessage(this, \'' . $lngstr['qst_delete_visitor'] . '\')"><img width=20 height=20 border=0 src="images/button-cross.gif" title="' . $lngstr['label_action_visitor_delete'] . '"></a></td></tr>'; $i_counter++; $i_pagewide_id++; $i_rSet1->MoveNext(); } $i_rSet1->Close(); } echo '</table>'; echo '</td></tr></table></form>'; displayTemplate('_footer');
<ul> <?php $sel_news = "SELECT * FROM news ORDER BY data DESC, ora DESC LIMIT " . $_SESSION['__config__']['num_news']; $res_news = $db->executeQuery($sel_news); while ($news = $res_news->fetch_assoc()) { ?> <li style="padding-bottom: 5px"><a href="#" onclick="show_news(<?php print $news['id_news']; ?> )"><?php print truncateString($news['abstract'], 80); ?> </a></li> <?php } ?> </ul>
<?php require "config.php"; echo "<h1>Forum boards on " . $config['server_name'] . "</h1><br />"; if (count($boards) == 0) { alert("There is no boards to display."); } else { foreach ($boards as $board) { if (empty($board['author'])) { $last = "No posts"; } else { $last = "<a href='" . WEBSITE . "/index.php/forum/thread/" . $board['thread_id'] . "'>" . truncateString($board['thread_title'], 20) . "</a><br />by <a href='" . WEBSITE . "/index.php/character/view/" . $board['author'] . "'>" . truncateString($board['author'], 10) . "</a> " . ago($board['time']); } $status = $board['closed'] == 0 ? "openBoard.png" : "closed.png"; echo "<div class='forumBoard'>"; echo "<div class='boardStatus'>"; echo "<img src='" . WEBSITE . "/public/images/forum/" . $status . "'>"; echo "</div>"; echo "<div class='leftBoard'>"; echo "<div class='boardTitle'><a href='" . WEBSITE . "/index.php/forum/board/" . $board['id'] . "'>" . $board['name'] . "</a></div>"; echo "<div class='boardDescription'>" . $board['description'] . "</div>"; echo "</div>"; echo "<div class='rightBoard'>"; echo $last; echo "</div>"; echo "</div>"; echo "<div style='clear: both;'></div>"; } }
function getTruncatedHTML($i_html, $i_length = 60) { return truncateString(trim(strip_tags(convertTextAreaHTML(false, $i_html))), $i_length); }