23 พฤษภาคม 2555, 13:18:33
ยินดีต้อนรับผู้เยี่ยมชม
  • noavata
  • ยินดีต้อนรับคุณ, ผู้เยี่ยมชม กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน
    เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น
Page Rank

ทำเว็บไซต์ | แต่งบอร์ด | ออกแบบ | SMF | Joomla | Drupal | WordPress | JQuery | CMS | ECommerce | Tel. +668-08577477

ส่งหัวข้อนี้พิมพ์ หน้า: 1 
icon message ผู้เขียน หัวข้อ: Word Count Limits จำกัดจำนวนคำต่ำสุด-สูงสุด/กระทู้  (อ่าน 798 ครั้ง)
0 สมาชิก และ 1 ผู้เยี่ยมชม กำลังดูหัวข้อนี้
*
*


!Personal

Germany   ชาย ผู้เริ่มต้นกระทู้นี้ ออฟไลน์544566157 DexMore DexMore DexMore
เว็บไซต์
  • ชื่อ: Word Count Limits
  • ผู้เขียน: ethankcvds
  • นำเสนอโดย: DexMoreGroup
  • ประเภท: Posting
  • รองรับ: SMF 1.1.xx, 2.0.xx
  • ปรับปรุงล่าสุด: 13 กุมภาพันธ์ 2554
  • ต้นฉบับ: Word Count Limits

รายละเอียด
      กำหนดจำนวนคำต่ำสุด และสูงสุดในการตั้งกระทู้ เพื่อป้องกันการตอบด้วยประโยคสั้นๆ เช่น ขอบคุณ, แหล่มเลย, thank ฯลฯ และมีเพียงสัญลักษณ์แสดงอารมณ์ โดยสามารถกำหนดหรือไม่กำหนดจำนวนคำเฉพาะบอร์ดได้อย่างอิสระ

ตัวอย่าง


สำหรับ SMF 1.1.xx

แก้ไขไฟล์:

file $themedir/ManageBoards.template.php

ค้นหา -->>
โค๊ด: [Select]
if (empty($modSettings['permission_enable_by_board']))

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
// Add the min/max word items
echo '
<tr>
<td>
<b>', $txt['limit_min_words'], '</b><br />', $txt['limit_words_note'], '
<br /><br />
</td>
<td valign="top" align="right">
<input type="text" name="min_words" value="', $context['board']['min_words'], '" size="5" />
</td>
</tr><tr>
<td>
<b>', $txt['limit_max_words'], '</b><br />', $txt['limit_words_note'], '
<br /><br />
</td>
<td valign="top" align="right">
<input type="text" name="max_words" value="', $context['board']['max_words'], '" size="5" />
</td>
</tr>';


file $sourcedir/ManageBoards.php

ค้นหา -->>
โค๊ด: [Select]
'permission_mode' => 'normal',

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
'min_words' => 0,
'max_words' => 0,

ค้นหา -->>
โค๊ด: [Select]
// Checkboxes....

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
$boardOptions['min_words'] = abs((int) $_POST['min_words']);
if($boardOptions['min_words'] > 10000) {
$boardOptions['min_words'] = 10000;
}
$boardOptions['max_words'] = abs((int) $_POST['max_words']);
if($boardOptions['max_words'] > 10000) {
$boardOptions['max_words'] = 10000;
}

file $sourcedir/Subs-Boards.php

ค้นหา -->>
โค๊ด: [Select]
b.ID_THEME, b.override_theme,

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
b.min_words, b.max_words,

ค้นหา -->>
โค๊ด: [Select]
'override_theme' => $row['override_theme'],

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
'min_words' => $row['min_words'],
'max_words' => $row['max_words'],

ค้นหา -->>
โค๊ด: [Select]
// Set the theme for this board.

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
if (isset($boardOptions['min_words']))
$boardUpdates[] = 'min_words = ' . abs((int) $boardOptions['min_words']);

if (isset($boardOptions['max_words']))
$boardUpdates[] = 'max_words = ' . abs((int) $boardOptions['max_words']);


file $sourcedir/Post.php

ค้นหา -->>
โค๊ด: [Select]
// Validate the poll...

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
// Now, let's check the post for being too short/tall
$query = db_query("
SELECT min_words, max_words FROM {$db_prefix}boards WHERE ID_BOARD = {$board_info['id']}
", __FILE__, __LINE__);

if(mysql_num_rows($query) == 1) {
list($min_words, $max_words) = mysql_fetch_row($query);
if($min_words > 0 || $max_words > 0) {
$count = wordcount( $func['htmltrim'](strip_tags(parse_bbc($_POST['message'], false))) ); // convert everything to HTML then scrap it to get only content
if($min_words != 0 && $count < $min_words) {
$post_errors[] = 'post_too_few_words';
} elseif($max_words != 0 && $count > $max_words) {
$post_errors[] = 'post_too_many_words';
}
}
}

mysql_free_result($query);

ค้นหา -->>
โค๊ด: [Select]
?>

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
function wordcount($str) {
$str = strip_tags(parse_bbc($str));
$str = un_htmlspecialchars($str);
$str = preg_replace("/[\x80-\xFF]/", "x", $str);
// attempt the clever version
$count = 0;
$count = @preg_match_all("/\p{L}[\p{L}\p{Mn}'\x{2019}]{2,}/u", $str, $matches);

if($count == 0) {
// can mean this one failed, so fallback
$str = preg_replace("/[\x21-\x26\x28-\x40\x5B-\x60\x7B-\x7F]/", " ", $str);
$count = 0;
$words = str_word_count($str, 1); // but this doesn't give us min 3 letters!
foreach($words as $word) {
if(strlen($word) >= 3)
$count++;
}
}
return $count;
}

file $languagedir/Modifications.thai-utf8.php

เพิ่ม -->>
ขออภัย! ส่วนนี้สงวนไว้เฉพาะสมาชิกเท่านั้น กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

file $languagedir/Errors.thai-utf8.php

เพิ่ม -->>
ขออภัย! ส่วนนี้สงวนไว้เฉพาะสมาชิกเท่านั้น กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

สร้างไฟล์: install11.php เพื่อสร้างฐานข้อมูล ไว้ใน $boarddir (ที่เดียวกับไฟล์ SSI.php) รัน http://www.your_url.xxx/$boarddir/install11.php -->> Enter เสร็จแล้วลบทิ้ง
โค๊ด: [Select]
<?php
 
if (!defined('SMF')) {
if(file_exists(dirname(__FILE__) . '/SSI.php'))
include_once(dirname(__FILE__) . '/SSI.php');
else
die('<strong>Error</strong>: Please make sure you have SSI.php in your root directory.');
}
 
global 
$db_prefix;
$min true$max true;
$query db_query("SHOW COLUMNS FROM {$db_prefix}boards LIKE '%words'"__FILE____LINE__);

while(
$row mysql_fetch_row($query)) {
if($row[0] == 'min_words')
$min false;

if($row[0] == 'max_words')
$max false;
}

if(
$min)
db_query("ALTER TABLE {$db_prefix}boards ADD min_words SMALLINT(5) NOT NULL DEFAULT '0'"__FILE____LINE__);

if(
$max)
db_query("ALTER TABLE {$db_prefix}boards ADD max_words SMALLINT(5) NOT NULL DEFAULT '0'"__FILE____LINE__);
?>

การตั้งค่า: ผู้ดูแล -->> แก้ไขบอร์ด -->> [ชื่อบอร์ด] แก้ไข


ลิงค์หัวข้อ: http://dexmore.com/topic/5130
Windows XP    Firefox 3.5.17   see ip บันทึกการเข้า
ดูรายการสิ่งของสำหรับบอกรักใครสักคน ก็ส่งไปให้เขาเลย!  สำหรับติดหมุดกระทู้ของคุณ!  เพิ่มเวลาที่อยู่ในระบบอีก 12 ชั่วโมง  น้องหมี..เอาไว้กอดนอนแทนกิ๊ก  สำหรับบอกรักใครสักคน ก็ส่งไปให้เขาเลย!  
*
*


!Personal

Germany   ชาย ผู้เริ่มต้นกระทู้นี้ ออฟไลน์544566157 DexMore DexMore DexMore
เว็บไซต์
icon message
general ความคิดเห็นที่ 1 เมื่อ: 4 มีนาคม 2554, 14:35:50
สำหรับ SMF 2.0.xx

แก้ไขไฟล์:

file $themedir/ManageBoards.template.php

ค้นหา -->>
โค๊ด: [Select]
<tr class="windowbg2" id="count_posts_div">

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
<tr class="windowbg2" id="min_words_div">
<td>
<b>', $txt['limit_min_words'], ':</b><br />
<span class="smalltext">', $txt['limit_words_note'], '</span><br />
</td>
<td valign="top" align="left">
<input type="text" name="min_words" value="', $context['board']['min_words'], '" size="5" />
</td>
</tr><tr class="windowbg2" id="max_words_div">
<td>
<b>', $txt['limit_max_words'], ':</b><br />
<span class="smalltext">', $txt['limit_words_note'], '</span><br />
</td>
<td valign="top" align="left">
<input type="text" name="max_words" value="', $context['board']['max_words'], '" size="5" />
</td>
</tr>

ค้นหา -->>
โค๊ด: [Select]
document.getElementById("count_posts_div").style.display = redirectEnabled ? "none" : "";

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
document.getElementById("min_words_div").style.display = redirectEnabled ? "none" : "";
document.getElementById("max_words_div").style.display = redirectEnabled ? "none" : "";

file $sourcedir/ManageBoards.php

ค้นหา -->>
โค๊ด: [Select]
'profile' => 1,

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
'min_words' => 0,
'max_words' => 0,

ค้นหา -->>
โค๊ด: [Select]
// Checkboxes....

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
$boardOptions['min_words'] = abs((int) $_POST['min_words']);
if($boardOptions['min_words'] > 10000) {
$boardOptions['min_words'] = 10000;
}
$boardOptions['max_words'] = abs((int) $_POST['max_words']);
if($boardOptions['max_words'] > 10000) {
$boardOptions['max_words'] = 10000;
}

file $sourcedir/Subs-Boards.php

ค้นหา -->>
โค๊ด: [Select]
b.id_theme, b.override_theme,

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
b.min_words, b.max_words,

ค้นหา -->>
โค๊ด: [Select]
'override_theme' => $row['override_theme'],

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
'min_words' => $row['min_words'],
'max_words' => $row['max_words'],

ค้นหา -->>
โค๊ด: [Select]
// Set the theme for this board.

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
if (isset($boardOptions['min_words'])) {
$boardUpdates[] = 'min_words = {int:min_words}';
$boardUpdateParameters['min_words'] = abs((int) $boardOptions['min_words']);
}

if (isset($boardOptions['max_words'])) {
$boardUpdates[] = 'max_words = {int:max_words}';
$boardUpdateParameters['max_words'] = abs((int) $boardOptions['max_words']);
}


file $sourcedir/Post.php

ค้นหา -->>
โค๊ด: [Select]
// Validate the poll...

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
// Now, let's check the post for being too short/tall
$query = $smcFunc['db_query']('', "
SELECT min_words, max_words FROM {db_prefix}boards WHERE ID_BOARD = {int:board}
", array('board' => $board_info['id']));

if($smcFunc['db_num_rows']($query) == 1) {
list($min_words, $max_words) = $smcFunc['db_fetch_row']($query);
if($min_words > 0 || $max_words > 0) {
$count = wordcount( $smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false))) ); // convert everything to HTML then scrap it to get only content
if($min_words != 0 && $count < $min_words) {
$post_errors[] = 'post_too_few_words';
} elseif($max_words != 0 && $count > $max_words) {
$post_errors[] = 'post_too_many_words';
}
}
}

mysql_free_result($query);

ค้นหา -->>
โค๊ด: [Select]
?>

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
function wordcount($str) {
$str = strip_tags(parse_bbc($str));
$str = un_htmlspecialchars($str);
$str = preg_replace("/[\x80-\xFF]/", "x", $str);
// attempt the clever version
$count = 0;
$count = @preg_match_all("/\p{L}[\p{L}\p{Mn}'\x{2019}]{2,}/u", $str, $matches);

if($count == 0) {
// can mean this one failed, so fallback
$str = preg_replace("/[\x21-\x26\x28-\x40\x5B-\x60\x7B-\x7F]/", " ", $str);
$count = 0;
$words = str_word_count($str, 1); // but this doesn't give us min 3 letters!
foreach($words as $word) {
if(strlen($word) >= 3)
$count++;
}
}
return $count;
}

file $languagedir/Modifications.thai-utf8.php

เพิ่ม -->>
ขออภัย! ส่วนนี้สงวนไว้เฉพาะสมาชิกเท่านั้น กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

file $languagedir/Errors.thai-utf8.php

เพิ่ม -->>
ขออภัย! ส่วนนี้สงวนไว้เฉพาะสมาชิกเท่านั้น กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

สร้างไฟล์: install20rc12.php เพื่อสร้างฐานข้อมูล ไว้ใน $boarddir (ที่เดียวกับไฟล์ SSI.php) รัน http://www.your_url.xxx/$boarddir/install20rc12.php -->> Enter เสร็จแล้วลบทิ้ง
โค๊ด: [Select]
<?php
 
if (!defined('SMF')) {
if(file_exists(dirname(__FILE__) . '/SSI.php'))
include_once(dirname(__FILE__) . '/SSI.php');
else
die('<strong>Error</strong>: Please make sure you have SSI.php in your root directory.');
}
 
global 
$db_prefix$smcFunc;

db_extend('packages');

$column = array(
'name' => 'min_words',
'type' => 'smallint',
'size' => 5,
'null' => false,
'default' => 0,
);

$smcFunc['db_add_column']('boards'$column);

$column['name'] = 'max_words';
$smcFunc['db_add_column']('boards'$column);
?>

ลิงค์หัวข้อ: http://dexmore.com/topic/5130
Windows XP    Firefox 3.5.17   see ip บันทึกการเข้า
ดูรายการสิ่งของสำหรับบอกรักใครสักคน ก็ส่งไปให้เขาเลย!  สำหรับติดหมุดกระทู้ของคุณ!  เพิ่มเวลาที่อยู่ในระบบอีก 12 ชั่วโมง  น้องหมี..เอาไว้กอดนอนแทนกิ๊ก  สำหรับบอกรักใครสักคน ก็ส่งไปให้เขาเลย!  
ส่งหัวข้อนี้พิมพ์ หน้า: 1 
กระโดดไป:  

Creative Commons License

SMF Thai Translation Powered by SMF © 2006–2012, Simple Machines LLC

WordPress Google เข้าเยี่ยมชมหน้านี้ล่าสุดเมื่อ : 18 พฤษภาคม 2555, 18:18:43

jQuery Plugin Copyright © 2551-2555 Themes Design & Hosting by DexMoreGroup

Sitemap | Thai Simple Machines Forum support SMF Thai

Web Begining | SMF Modifications | SMF Thai Translation Web Begining

Drupal | WordPress | CMS Joomla | jQuery Plugin | Web Graphics CMS Joomla