Файл: CMS/core/modules/smiles.inc.php
Строк: 63
<?php
if (!defined('CMS')) { die('Access Denied!'); }
$id = !empty($_GET['id']) ? intval($_GET['id']) : '';
$mod = !empty($_GET['m']) ? check($_GET['m']) : '/smiles';
$page = !empty($_GET['page']) ? $_GET['page'] : 1;
$onpage = 30;
$smiles = array();
$globsmiles = glob( ROOTPATH . '/images/smiles/*.gif' );
foreach($globsmiles as $filename) {
$smiles[] = basename($filename, '.gif');
}
sort($smiles);
$total = @count($smiles);
if ($total > 0) {
$output = '';
$output .= <<<HTML
<div class="b">
<table align="center" width="100%">
<tr align="center">
<td>Смайлик</td>
<td>—</td><td>Название</td>
<td>Смайлик</td>
<td>—</td><td>Название</td>
<td>Смайлик</td>
<td>—</td><td>Название</td>
</tr>
<tr align="center">
HTML;
$start = ($page - 1) * $onpage;
if ($start < 0) $start = 0;
if ($start > $total - 1) $start = $total - 1;
$stop = $start + $onpage;
if ($stop > $total) $stop = $total;
for ($i = $start; $i < $stop; $i++) {
$code = str_replace('.gif', '', $smiles[$i]);
$n = $i+1;
if ($n%3 == 0 AND $i < $total) $output .= '</tr><tr>';
else $output .= '';
$output .= <<<HTML
<td align="center">
<a title="{$code}" href="#form" onclick="javascript:tag(' :{$code}', '');">
<img src="/images/smiles/{$smiles[$i]}.gif" alt="{$code}" />
</a>
</td>
<td align="center"> — </td>
<td align="center">:{$code}</td>
HTML;
}
$output .= <<<HTML
</tr>
</table>
</div>
HTML;
echo $output;
echo show_pages($_SERVER['REQUEST_URI']);
echo '<div class="b">Всего cмайлов: <b>' . $total . '</b><br /></div>';
echo <<<HTML
<script language="JavaScript" type="text/javascript">
function tag(text1, text2) {
if ((document.selection)) {
document.form.text.focus();
document.form.document.selection.createRange().text = text1+document.form.document.selection.createRange().text+text2;
} else if(document.forms['form'].elements['text'].selectionStart!=undefined) {
var element = document.forms['form'].elements['text'];
var str = element.value;
var start = element.selectionStart;
var length = element.selectionEnd - element.selectionStart;
element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
} else document.form.text.value += text1+text2;
}
</script>
HTML;
}
else {
echo '<div class="b"><b>К соделению смайлов пока нет!</b></div>';
}
?>