| Autor | Zpráva | ||
|---|---|---|---|
| Chatík Profil |
#1 · Zasláno: 19. 11. 2013, 18:55:58 · Upravil/a: Chatík
Zdravím Vás dámy a pánové chytrý rádcové.
Chtěl bych poprosit někoho s trochou času jestli by nepomohl upravit chat, tak aby pokud se ve zprávě vyskytne http:// nebo www tak aby ho to převedlo na klikající odkaz. Chat jsem tvořil podle jednoho tutoriálu z youtube. Je fakt že jsem něco našel na google ale nějak jsem nepochopil jak to zakomponovat do mého scriptu, už jen proto že převádím různé texty na smajlíky. Přikládám zde script: <?php
session_start();
require_once "../core/init.php";
if (isset($_POST['method']) === true && empty($_POST['method']) === false) {
$chat = new Chat();
$method = trim($_POST['method']);
if ($method === 'fetch') {
$messages = $chat->fetchMessages();
if (empty($messages) === true) {
echo 'Momentálně zde nejsou žádné zprávy!';
} else {
foreach($messages as $message) {
$textsmile = array(':-)', ':-(', ':-D', ':-P', ':-p', ';-)', ';)', ':D', 'X[]', 'B-]', ':-!', ':-/', 'blee', 'web', 'heslo'); $graphicsmile = array('
<img width="25" height="20" src="/chat/smileys/1.gif">', '
<img width="25" height="20" src="/chat/smileys/2.gif">', '
<img width="25" height="20" src="/chat/smileys/3.gif">' , '
<img width="25" height="20" src="/chat/smileys/4.gif">', '
<img width="25" height="20" src="/chat/smileys/4.gif">', '
<img width="25" height="20" src="/chat/smileys/5.gif">', '
<img width="25" height="20" src="/chat/smileys/5.gif">' , '
<img width="25" height="20" src="/chat/smileys/3.gif">' , '
<img width="25" height="20" src="/chat/smileys/6.gif">' , '
<img width="25" height="20" src="/chat/smileys/7.gif">' , '
<img width="25" height="20" src="/chat/smileys/8.gif">' , '
<img width="35" height="20" src="/chat/smileys/9.gif">' , '
<img width="35" height="20" src="/chat/smileys/10.gif">',
'......', '????');
$text = nl2br($message['message']);
$text = str_replace($textsmile, $graphicsmile, $text);
$date = $message['timestamp'];
?>
<div title="<?php echo date('d.m.Y H:i', $date); ?> IP: <?php echo $message['ip']; ?>" class="message">
<a onclick="Names('<?php echo $message['jmeno']; ?>:')" href="#" <?php if($message['admin'] == '1') echo 'style="color: #A52A2A; font-weight:bold; text-decoration: underline;" title="Administrátor"' ;ElseIf($message['admin'] == '0')echo'style="color:green" title="Uživatel"'; ?>><?php echo $message['jmeno']; ?></a> :
<?php echo $text; ?>
</div>
<?php
}
}
} else if ($method === 'throw' && isset($_POST['message']) === true) {
$message = trim($_POST['message']);
if (empty($message) === false) {
$chat->throwMessage($_SESSION['id'], $message);
}
}
}
?>Zkusil jsem toto: $text = preg_replace('#(^|\s)([a-z]+://([^\s\w/]?[\w/])*)#is', '\\1<a target="blank" href="\\2" title="\\2" class="koment"><strong>Odkaz>></strong></a>', $text);
$text = preg_replace('#(^|\s)((www|ftp)\.([^\s\w/]?[\w/])*)#is', '\\1<a target="blank" href="http://\\2" title="\\2" class="koment">Odkaz>></a>', $text);
$text = preg_replace('#(^|\s)(([a-z0-9._%+-]+)@(([.-]?[a-z0-9])*))#is', '\\1<a target="blank" href="mailto:\\2">Email</a>', $text); |
||
|
Časová prodleva: 13 let
|
|||
0