السلام عليكم ورحمة الله وبركاته
كيف الحال يا شباب إن شاء الله تمام
انا عندي استفسار عن طريقة إستخدام الـbbcode
فلديه نموذج إرسال في ملف show.php
وهذا الكود بداخله
كود PHP:
include("bbcode.php");
print '
<div align="center"><head>
<title>نموذج إرسال</title>
</head>
<body>
<form action="mail.php" method="post">
عنوان المرسل
<br>
<input type="text" name = "you">
<br>
عنوان المستقبل
<br>
<input type="text" name = "to">
<br>
موضوع الرسالة
<br>
<input type="text" name = "sub">
<br>
الرسالة
<br>';
print '
<textarea rows=10 cols=20 name = "msg" >
</textarea>
<br>
<input type="submit" value = "إرسال">
</form>
</body>
</html></div>';
أيضاً لديه ملف باسم bbcode وفيه دالة bbcode ومحتواه التالي
كود PHP:
function BBCode($Text)
{
// أولاً استبدال وسوم HTML بالرموز الكيانية لها وذلك لمنع تمرير أكواد لا نرغب بها وقد تشكل خطراً مثل الأوامر التنفيذية
$Text = htmlentities($Text);
// ملحوظة htmlentities تؤدي نفس عملية htmlspecialchars باستثناء أنها تقوم بتغيير جميع رموز HTML إلى رموزها الكيانية
// تحويل أسطر اليونكس إلى وسم HTML <br />
$Text = nl2br($Text);
// تعيين ثوابت الروابط
$URLSearchString = " a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'";
// تعيين ثوابت عناوين البريد
$MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@";
// استبدال أكواد الرابط بلغة HTML
$Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="$1" target="_blank">$1</a>', $Text);
$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '<a href="$1" target="_blank">$2</a>', $Text);
// // استبدال أكواد البريد بلغة HTML
$Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href="mailto:$1">$1</a>', $Text);
$Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '<a href="mailto:$1">$2</a>', $Text);
// كود الخط الغامق
$Text = preg_replace("(\[b\](.+?)\[\/b])is",'<span class="bold">$1</span>',$Text);
// كود الخط المائل
$Text = preg_replace("(\[i\](.+?)\[\/i\])is",'<span class="italics">$1</span>',$Text);
// كود الخط السفلي
$Text = preg_replace("(\[u\](.+?)\[\/u\])is",'<span class="underline">$1</span>',$Text);
// كود الخط الفوقي
$Text = preg_replace("(\[s\](.+?)\[\/s\])is",'<span class="strikethrough">$1</span>',$Text);
// كود الخط العلوي
$Text = preg_replace("(\[o\](.+?)\[\/o\])is",'<span class="overline">$1</span>',$Text);
// كود لون الخط
$Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","<span style=\"color: $1\">$2</span>",$Text);
// كود حجم الخط
$Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","<span style=\"font-size: $1px\">$2</span>",$Text);
// كود القوائم بمختلف أنواعها
$Text = preg_replace("/\[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>' ,$Text);
$Text = preg_replace("/\[list=1\](.+?)\[\/list\]/is", '<ul class="listdecimal">$1</ul>' ,$Text);
$Text = preg_replace("/\[list=i\](.+?)\[\/list\]/s", '<ul class="listlowerroman">$1</ul>' ,$Text);
$Text = preg_replace("/\[list=I\](.+?)\[\/list\]/s", '<ul class="listupperroman">$1</ul>' ,$Text);
$Text = preg_replace("/\[list=a\](.+?)\[\/list\]/s", '<ul class="listloweralpha">$1</ul>' ,$Text);
$Text = preg_replace("/\[list=A\](.+?)\[\/list\]/s", '<ul class="listupperalpha">$1</ul>' ,$Text);
$Text = str_replace("[*]", "<li>", $Text);
// كود نوع الخط[font=arial]
$Text = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])","<span style=\"font-family: $1;\">$2</span>",$Text);
// حقل كود [code] للغات البرمجة
$CodeLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> Code:</td>
</tr>
<tr>
<td>$1</td>
</tr>
</table>';
// كود نص [code]
$Text = preg_replace("/\[code\](.+?)\[\/code\]/is","$CodeLayout", $Text);
// حقل كود الاقتباس [quote]
$QuoteLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> Quote:</td>
</tr>
<tr>
<td>$1</td>
</tr>
</table>';
// كود نص [quote]الاقتباس[/quote]
$Text = preg_replace("/\[quote\](.+?)\[\/quote\]/is","$QuoteLayout", $Text);
// كود الصور [img]الرابط[/img]
$Text = preg_replace("/\[img\](.+?)\[\/img\]/", '<img src="$1">', $Text);
// كود صورة بتحديد الأبعاد [img=widthxheight]الرابط[/img]
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '<img src="$3" height="$2" width="$1">', $Text);
// إعادة النتيجة بعد تحريرها
return $Text;
} // نهاية function BBCode
السؤال هو :
كيف أعمل مثل هذا ( الصندوق السحري في الـvb )
وهو موجود هنا في سوالف سوفت في تحريك النص لأعلى ولأسفل
بمعنى أريد الكود الذي أضيفه في النموذج السابق
بحيث يظهر الصندوق السحري وأي عبارة يكتبها المرسل
ويستخدم أكواد BB مثلاً تحريك النص لأعلى أو اللون الأحمر
بعد إرسال الرسالة تظهر للمرسل بتنسيق BBcode
مثل هذا اللون الأزرق
هذا بتنسيق bbcode
والسلام عليكم ،،