Просмотр файла bestwap_news/admin/add.php

Размер файла: 3.56Kb
<?
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>';
print '<head><title>BestWap.wml.su</title><LINK HREF="http://wclick.net.ru/style1.css" REL="stylesheet" TYPE="text/css"></head><body>';
print '<link rel="icon" href="http://bestwap.wml.su/favicon.png"type="image/x-icon"/>';
print '<p align="left">';
include ("cfg.php");

if (empty($text)){
?>
<script language="Javascript" type="text/javascript">
<!--
function x () {
return;
}

function storeCaret (textEl) {
if (textEl.createTextRange)
textEl.caretPos = document.selection.createRange().duplicate();
} // end fn
function insertAtCaret (textEl, text) {
if (textEl.createTextRange && textEl.caretPos) {
var caretPos = textEl.caretPos;
caretPos.text =	caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?	text + ' ' : text;
} else {textEl.value  = textEl.value + text;}
return true;
}// fn
function DoPrompt(action) {
var currentMessage = document.replier.text.value;
if (action == "url") {
var thisURL = prompt("URL:", "http://");
if (thisURL == null){return;}
var thisTitle = prompt("Название ссылки, например: bestwap.wml.su", "bestwap.wml.su");
if (thisTitle == null){return;}
insertAtCaret(document.replier.text, ' ' + "[url=" + thisURL + "]" + thisTitle + "[/url]" + ' ');
document.replier.text.focus();
return;
}
if (action == "bold") {
var thisBold = prompt("Жирный текст:", "");
if (thisBold == null){return;}
insertAtCaret(document.replier.text, ' ' + "[b]" + thisBold + "[/b]" + ' ' );
document.replier.text.focus();
return;
}
if (action == "underline") {
var thisBold = prompt("Подчеркнутый текст:", "");
if (thisBold == null){return;}
insertAtCaret(document.replier.text, ' ' + "[u]" + thisBold + "[/u]" + ' ' );
document.replier.text.focus();
return;
}
// -->
}
//-->
</script>

<form name="replier" method="post" action="add.php?pass=<? print $pass; ?>">
<table width="725" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="585" align="center" valign="middle">
<textarea name="text" onKeyUp="storeCaret(this);" onClick="storeCaret(this);" cols="80" rows="5" wrap="VIRTUAL" id="text; charset=utf-8"></textarea>
</td>
</tr>
<tr>
<td align="center">
<br/><a href="javascript: x()" onClick="DoPrompt('url');">&#1051;&#1080;&#1085;&#1082;</a>
<a href="javascript: x()" onClick="DoPrompt('bold');">&#1046;&#1080;&#1088;&#1085;&#1099;&#1081;</a>
<a href="javascript: x()" onClick="DoPrompt('underline');">&#1055;&#1086;&#1076;&#1095;&#1077;&#1088;&#1082;&#1085;&#1091;&#1090;&#1099;&#1081;</a><br/>
<input type="submit" name="Submit" value="&#1044;&#1086;&#1073;&#1072;&#1074;&#1080;&#1090;&#1100;">
</td>
</tr>
</table>
</form>
<?
;} else {

$text= str_replace('$','$$',$text);
$text= str_replace('[b]','<b>',$text);
$text= str_replace('[/b]','</b>',$text);
$text= str_replace('[u]','<u>',$text);
$text= str_replace('[/u]','</u>',$text);
//$text = eregi_replace('\[url=([[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/])\]([:space:]]+[[:alnum:]])\[url]', '<a href="\\1">\\2</a>', $text);
//$patterns[] = "#\[url\]([\w]+?://[^ \"\n\r\t<]*?)\[/url\]#is";
$text = preg_replace("#\[url=([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)\](.*?)\[/url\]#si", '<a href="\\1\\2">\\3</a>', $text);
if (mysql_query("insert into `news` values(0, '".time()."', '$text','0','0','');")) print '&#1053;&#1086;&#1074;&#1086;&#1089;&#1090;&#1100; &#1076;&#1086;&#1073;&#1072;&#1074;&#1083;&#1077;&#1085;&#1072;!';
}
?>
</BODY>
</HTML>