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

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

ส่งหัวข้อนี้พิมพ์ หน้า: 1 
icon message ผู้เขียน หัวข้อ: Related Topics กระทู้ที่เกี่ยวข้อง  (อ่าน 1310 ครั้ง)
0 สมาชิก และ 1 ผู้เยี่ยมชม กำลังดูหัวข้อนี้
*
*


!Personal

Germany   ชาย ผู้เริ่มต้นกระทู้นี้ ออฟไลน์544566157 DexMore DexMore DexMore
เว็บไซต์
icon message
general เมื่อ: 7 กรกฎาคม 2553, 23:05:20
  • ชื่อ: Related Topics
  • ผู้เขียน: Niko
  • นำเสนอโดย: DexMoreGroup
  • ประเภท: New Feature
  • รองรับ: SMF 1.1.xx, 2.0.xx
  • ปรับปรุงล่าสุด: 29 พฤษภาคม 2553
  • ต้นฉบับ: Related Topics

รายละเอียด
      สร้างหัวข้อที่เกี่ยวข้อง หัวข้อที่คล้ายกัน แสดงในหน้าอ่านกระทู้ (Display) เพื่อให้รู้ว่าห้อข้อนั้นๆ มีเนื้อหาใกล้เคียงกับหัวข้อใดบ้าง แต่ mod นี้ค่อนข้างจะใช้ทรัพยากรณ์ของ MySQL มากพอสมควรนะครับ ถ้าหากเป็นบอร์ดขนาดใหญ่มีผู้ใช้มากๆ มีหัวข้อมากๆ
และโฮสต์ไม่เสถียรพอ ก็ทำให้มีอุปสรรค์กับการใช้งานฟอรั่มพอสมควร

ตัวอย่าง


สำหรับ SMF 1.1.xx

แก้ไขไฟล์:

file $boarddir/index.php

ค้นหา -->>
โค๊ด: [Select]
'register2' => array('Register.php', 'Register2'),

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
'related' => array('Subs-Related.php', 'Related'),

file $sourcedir/ModSettings.php

ค้นหา -->>
โค๊ด: [Select]
'',
// Reactive on email, and approve on delete

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
'',
// Related Topics
array('check', 'relatedTopicsEnabled'),
array('int', 'relatedTopicsCount'),
array('select', 'relatedIndex', array('fulltext' => $txt['relatedFulltext'])),


file $sourcedir/RemoveTopic.php

ค้นหา -->>
โค๊ด: [Select]
else
$condition = 'IN (' . implode(', ', $topics) . ')';

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
// Added by Related Topics
require_once($sourcedir . '/Subs-Related.php');
removeRelated($topics);
// Related Topics END

file $sourcedir/Subs-Post.php

ค้นหา -->>
โค๊ด: [Select]
$topicOptions['id'] = db_insert_id();

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
// Added by Related Topics
global $sourcedir;
require_once($sourcedir . '/Subs-Related.php');
addRelated($topicOptions['id'], $msgOptions['subject']);
// Related Topics END

ค้นหา -->>
โค๊ด: [Select]
updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
mysql_free_result($request);

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
// Added by Related Topics
global $sourcedir;
require_once($sourcedir . '/Subs-Related.php');
addRelated($topicOptions['id'], $msgOptions['subject']);
// Related Topics END

file $sourcedir/Display.php

ค้นหา -->>
โค๊ด: [Select]
$topicinfo = mysql_fetch_assoc($request);
mysql_free_result($request);

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
// Added by Related Topics
if (!empty($modSettings['relatedTopicsEnabled']))
{
require_once($sourcedir . '/Subs-Related.php');
$context['related_topics'] = loadRelated($topic);
}

file $themedir/Display.template.php

ค้นหา -->>
โค๊ด: [Select]
echo '
<input type="hidden" name="sc" value="' . $context['session_id'] . '" />
<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
</form>
</td>
</tr>
</table>';
}

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
// Added by Related Topics
if (!empty($context['related_topics']) > 0)
{
echo '
<br />
<div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' : '', '>
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr class="titlebg">
<td colspan="7">', $txt['related_topics'], '</td>
</tr>
<tr>
<td width="9%" colspan="2" class="catbg3"></td>
<td class="catbg3">', $txt[70],'</td>
<td class="catbg3">', $txt[109],'</td>
<td class="catbg3">', $txt[110],'</td>
<td class="catbg3">', $txt[301],'</td>
<td class="catbg3">', $txt[111],'</td>
</tr>';

foreach ($context['related_topics'] as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="5%">
<img src="', $settings['images_url'], '/topic/', $topic['class'], '.gif" alt="" />
</td>
<td class="windowbg2" valign="middle" align="center" width="4%">
<img src="', $topic['first_post']['icon_url'], '" alt="" />
</td>
<td class="windowbg' , !empty($settings['seperate_sticky_lock']) && $topic['is_sticky'] ? '3' : '' , '" valign="middle" ', (!empty($topic['quick_mod']['remove']) ? 'id="topic_' . $topic['first_post']['id'] . '" onmouseout="mouse_on_div = 0;" onmouseover="mouse_on_div = 1;" ondblclick="modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\', \'' . $context['session_id'] . '\');"' : ''), '>';

if (!empty($settings['seperate_sticky_lock']))
echo '
' , $topic['is_locked'] ? '<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" id="lockicon' . $topic['first_post']['id'] . '" style="margin: 0;" />' : '' , '
' , $topic['is_sticky'] ? '<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" id="stickyicon' . $topic['first_post']['id'] . '" style="margin: 0;" />' : '';

echo '
', $topic['is_sticky'] ? '<b>' : '' , '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</b>' : '';

// Is this topic new? (assuming they are logged in!)
if ($topic['new'] && $context['user']['is_logged'])
echo '
<a href="', $topic['new_href'], '" id="newicon' . $topic['first_post']['id'] . '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';

echo '
<small id="pages' . $topic['first_post']['id'] . '">', $topic['pages'], '</small><br />
<small>', $topic['board_link'], '</small>
</td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '
</td>
<td class="windowbg' , $topic['is_sticky'] ? '3' : '' , '" valign="middle" width="4%" align="center">
', $topic['replies'], '
</td>
<td class="windowbg' , $topic['is_sticky'] ? '3' : '' , '" valign="middle" width="4%" align="center">
', $topic['views'], '
</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>';

echo '
</tr>';

}

echo '
</table>
</div>';
}

file $languagedir/Modifications.thia-utf8.php

เพิ่ม -->>
ขออภัย! ท่านไม่สามารถเข้าถึงข้อมูลส่วนนี้ได้ กรุณาอ่าน เงื่อนไขการใช้งาน DexMore.Com

ดาวน์โหลด: Sources.rar
ขออภัย! ท่านไม่สามารถเข้าถึงข้อมูลส่วนนี้ได้ กรุณาอ่าน เงื่อนไขการใช้งาน DexMore.Com

แตกไฟล์แล้วอัพโหลดไปไว้ที่
file Subs-Related.php -->> $sourcedir
file Subs-RelatedFulltext.php -->> $sourcedir

สร้างไฟล์: related_topics.php เพื่อสร้างฐานข้อมูล ไว้ใน $boarddir (ที่เดียวกับไฟล์ SSI.php) รัน http://www.your_url.xxx/$boarddir/related_topics.php -->> Enter เสร็จแล้วลบทิ้ง
โค๊ด: [Select]
<?php
/*******************************************************************************
This is script for installing Related Topics

ATTENTION: If you are trying to INSTALL this package, please access
it directly, with a URL like the following:
http://www.yourdomain.tld/forum/related_topics.php (or similar.)

*******************************************************************************/
global $db_prefix;

// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');

$overwrite_old_settings false;

$mod_settings = array(
'relatedTopicsEnabled' => '1',
'relatedTopicsCount' => '5',
'relatedIndex' => 'fulltext'
);

// Turn the array defined above into a string of MySQL data.
$string '';
foreach (
$mod_settings as $k => $v)
$string .= '
(\'' 
$k '\', \'' $v '\'),';

// Sorted out the array defined above - now insert the data!
if ($string != '')
$result db_query("
. ($overwrite_old_settings 'REPLACE' 'INSERT IGNORE') . " INTO {$db_prefix}settings
(variable, value)
VALUES" 
substr($string0, -1), __FILE____LINE__);

// Uh-oh spaghetti-oh!
if ($result === false)
echo '<b>Error:</b> Database modifications failed!';

db_query("
CREATE TABLE IF NOT EXISTS {$db_prefix}related_topics (
id_topic_first int(10) unsigned NOT NULL,
id_topic_second int(10) unsigned NOT NULL,
score float unsigned NOT NULL,
PRIMARY KEY (id_topic_first, id_topic_second)
)"
__FILE____LINE__);

?>

การตั้งค่า: ผู้ดูแล -->> ส่วนปรับแต่งค่าการใช้งาน -->> เปิดใช้งานกระทู้ที่เกี่ยวข้อ

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


!Personal

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

แก้ไขไฟล์:

file $boarddir/index.php

ค้นหา -->>
โค๊ด: [Select]
'register2' => array('Register.php', 'Register2'),

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
'related' => array('Subs-Related.php', 'Related'),

file $sourcedir/Admin.php

ค้นหา -->>
โค๊ด: [Select]
'current_theme' => array(

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
'relatedtopics' => array(
'label' => $txt['admin_related_topic'],
'file' => 'RelatedTopics.php',
'function' => 'RelatedTopicsAdmin',
'subsections' => array(
'main' => array($txt['admin_related_topics_information']),
'settings' => array($txt['admin_related_topics_settings']),
'methods' => array($txt['admin_related_topics_methods']),
),
),

ค้นหา -->>
โค๊ด: [Select]
// Mod Authors for a "ADD AFTER" on this line. Ensure you end your change with a comma. For example:

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
'related' => array($txt['admin_related_topic']),

file $sourcedir/RemoveTopic.php

ค้นหา -->>
โค๊ด: [Select]
// Recycle topics that aren't in the recycle board...

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
// Added by Related Topics
require_once($sourcedir . '/Subs-Related.php');
relatedRemoveTopics($topics);
// Related Topics END

file $sourcedir/Subs-Post.php

ค้นหา -->>
โค๊ด: [Select]
$topicOptions['id'] = $smcFunc['db_insert_id']('{db_prefix}topics', 'id_topic');

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
// Added by Related Topics
global $sourcedir;
require_once($sourcedir . '/Subs-Related.php');
relatedUpdateTopics($topicOptions['id']);
// Related Topics END

ค้นหา -->>
โค๊ด: [Select]
if ($smcFunc['db_num_rows']($request) == 1)
updateStats('subject', $topicOptions['id'], $msgOptions['subject']);

แก้เป็น -->>
โค๊ด: [Select]
if ($smcFunc['db_num_rows']($request) == 1)
{
updateStats('subject', $topicOptions['id'], $msgOptions['subject']);

// Added by Related Topics
global $sourcedir;
require_once($sourcedir . '/Subs-Related.php');
relatedUpdateTopics($topicOptions['id']);
// Related Topics END
}

file $sourcedir/Display.php

ค้นหา -->>
โค๊ด: [Select]
$topicinfo = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
// Added by Related Topics
if (!empty($modSettings['relatedTopicsEnabled']))
{
require_once($sourcedir . '/Subs-Related.php');
loadRelated($topic);
}

file $themedir/Display.template.php

ค้นหา -->>
โค๊ด: [Select]
if ($context['show_spellchecking'])
echo '
<form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value="" /></form>

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
// Added by Related Topics
if (!empty($context['related_topics'])) // TODO: Have ability to display no related topics?
{
echo '
<h3 class="titlebg"><span class="left"></span>', $txt['related_topics'], '</h3>
<div class="tborder topic_table" id="messageindex">
<table class="table_grid" cellspacing="0">
<thead>
<tr>';

// Are there actually any topics to show?
if (!empty($context['related_topics']))
{
echo '
<th scope="col" class="smalltext first_th" width="8%" colspan="2">&nbsp;</th>
<th scope="col" class="smalltext">', $txt['subject'], ' / ', $txt['started_by'], '</th>
<th scope="col" class="smalltext center" width="14%">', $txt['replies'], '</th>
<th scope="col" class="smalltext last_th" width="22%">', $txt['last_post'], '</th>';
}
// No topics.... just say, "sorry bub".
else
echo '
<th scope="col" class="smalltext first_th" width="8%">&nbsp;</th>
<th class="smalltext" colspan="3"><strong>', $txt['msg_alert_none'], '</strong></th>
<th scope="col" class="smalltext last_th" width="8%">&nbsp;</th>';

echo '
</tr>
</thead>
<tbody>';

foreach ($context['related_topics'] as $topic)
{
// Is this topic pending approval, or does it have any posts pending approval?
if ($topic['board']['can_approve_posts'] && $topic['unapproved_posts'])
$color_class = !$topic['approved'] ? 'approvetbg' : 'approvebg';
// We start with locked and sticky topics.
elseif ($topic['is_sticky'] && $topic['is_locked'])
$color_class = 'stickybg locked_sticky';
// Sticky topics should get a different color, too.
elseif ($topic['is_sticky'])
$color_class = 'stickybg';
// Locked topics get special treatment as well.
elseif ($topic['is_locked'])
$color_class = 'lockedbg';
// Last, but not least: regular topics.
else
$color_class = 'windowbg';

// Some columns require a different shade of the color class.
$alternate_class = $color_class . '2';

echo '
<tr>
<td class="icon1 ', $color_class, '">
<img src="', $settings['images_url'], '/topic/', $topic['class'], '.gif" alt="" />
</td>
<td class="icon2 ', $color_class, '">
<img src="', $topic['first_post']['icon_url'], '" alt="" />
</td>
<td class="subject ', $alternate_class, '">
<div ', (!empty($topic['quick_mod']['modify']) ? 'id="topic_' . $topic['first_post']['id'] . '" onmouseout="mouse_on_div = 0;" onmouseover="mouse_on_div = 1;" ondblclick="modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\', \'' . $context['session_id'] . '\', \'' . $context['session_var'] . '\');"' : ''), '>
', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], (!$topic['board']['can_approve_posts'] && !$topic['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>', $topic['is_sticky'] ? '</strong>' : '' ;

// Is this topic new? (assuming they are logged in!)
if ($topic['new'] && $context['user']['is_logged'])
echo '
<a href="', $topic['new_href'], '" id="newicon' . $topic['first_post']['id'] . '"><img src="', $settings['lang_images_url'], '/new.gif" alt="', $txt['new'], '" /></a>';

echo '
<p>', $txt['started_by'], ' ', $topic['first_post']['member']['link'], '
<small id="pages' . $topic['first_post']['id'] . '">', $topic['pages'], '</small>
<small>', $topic['board']['link'], '</small>
</p>
</div>
</td>
<td class="stats ', $color_class, '">
', $topic['replies'], ' ', $txt['replies'], '
<br />
', $topic['views'], ' ', $txt['views'], '
</td>
<td class="lastpost ', $alternate_class, '">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt['last_post'], '" title="', $txt['last_post'], '" /></a>
', $topic['last_post']['time'], '<br />
', $txt['by'], ' ', $topic['last_post']['member']['link'], '
</td>
</tr>';
}

echo '
</table>
</div><br />';
}


file $languagedir/Modifications.thai-utf8.php

เพิ่ม -->>
โค๊ด: [Select]
// Added by Related Topics
$txt['admin_related_topic'] = 'Related Topics';
$txt['admin_related_topics_information'] = 'Information';
$txt['admin_related_topics_settings'] = 'Settings';
$txt['admin_related_topics_methods'] = 'Methods';

$txt['related_topics_admin_title'] = 'Related Topics';
$txt['related_topics_admin_desc'] = '';

$txt['related_latest_news'] = 'Latest News';
$txt['related_news_unable_to_connect'] = 'Unable to connect to <a href="http://www.smfarcade.info">SMFArcade.info</a> for latest news...';
$txt['related_version_info'] = 'Version Information';
$txt['related_installed_version'] = 'Installed Version';
$txt['related_latest_version'] = 'Latest Version';

$txt['related_topics_settings_title'] = 'Related Topics';

$txt['related_topics_methods_title'] = 'Methods';
$txt['related_topics_methods'] = 'Select methods used for determining Related Topics<div class="smalltext">Rebuild of index is required after changing these settings</div>';

$txt['related_topics_index'] = 'Index';
$txt['related_topics_rebuild'] = 'Rebuild Indexes';
$txt['related_topics_rebuild_desc'] = 'Use this after changing settings or to build initial cache';

$txt['relatedFulltext'] = 'Fulltext';

$txt['relatedTopicsEnabled'] = 'Enable Related Topics';
$txt['relatedTopicsCount'] = 'How many related topics to show';
$txt['relatedIgnoredboards'] = 'Ignored Boards<div class="smalltext">board ids separated with commas</div>';

$txt['no_methods_selected'] = 'You haven\'t selected which methods to use to determine related topics';

$txt['related_topics'] = 'Related Topics';
// END Added by Related Topics

ดาวน์โหลด: Related.rar
ขออภัย! ท่านไม่สามารถเข้าถึงข้อมูลส่วนนี้ได้ กรุณาอ่าน เงื่อนไขการใช้งาน DexMore.Com

แตกไฟล์แล้วอัพโหลดไปไว้ที่
file RelatedTopics.php -->> $sourcedir
file Subs-Related.php -->> $sourcedir
file Subs-RelatedFulltext.php -->> $sourcedir
file RelatedTopicsAdmin.template.php -->> $themedir

สร้างไฟล์: related_topics.php เพื่อสร้างฐานข้อมูล ไว้ใน $boarddir (ที่เดียวกับไฟล์ SSI.php) รัน http://www.your_url.xxx/$boarddir/related_topics.php -->> Enter เสร็จแล้วลบทิ้ง
โค๊ด: [Select]
<?php
/*******************************************************************************
This is script for installing Related Topics

ATTENTION: If you are trying to INSTALL this package, please access
it directly, with a URL like the following:
http://www.yourdomain.tld/forum/related_topics.php (or similar.)

*******************************************************************************/
global $db_prefix$db_type;

// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');

$index_type $db_type == 'mysql' 'fulltext' '';

$relatedSettings = array(
'relatedTopicsEnabled' => array(0false),
'relatedTopicsCount' => array(5false),
'relatedIndex' => array($index_typefalse),
'relatedIgnoredboards' => array(''false),
);

$tables = array(
'related_topics' => array(
'name' => 'related_topics',
'columns' => array(
array(
'name' => 'id_topic_first',
'type' => 'int',
'null' => false,
'unsigned' => true,
),
array(
'name' => 'id_topic_second',
'type' => 'int',
'null' => false,
'unsigned' => true,
),
array(
'name' => 'score',
'type' => 'float',
'null' => false,
'unsigned' => true,
),
),
'indexes' => array(
array(
'type' => 'primary',
'columns' => array('id_topic_first''id_topic_second')
),
)
),
);

doSettings($relatedSettings);
doTables($tables);

// Functions
function doTables($tables$columnRename = array())
{
global $smcFunc$db_prefix$db_type$db_show_debug;

$log = array();
$existingTables $smcFunc['db_list_tables']();

foreach ($tables as $table)
{
$table_name $table['name'];

$tableExists in_array($db_prefix $table_name$existingTables);

// Create table
if (!$tableExists && empty($table['smf']))
$smcFunc['db_create_table']('{db_prefix}' $table_name$table['columns'], $table['indexes']);
// Update table
else
{
$currentTable $smcFunc['db_table_structure']('{db_prefix}' $table_name);

// Renames in this table?
if (!empty($table['rename']))
{
foreach ($currentTable['columns'] as $column)
{
if (isset($table['rename'][$column['name']]))
{
$old_name $column['name'];
$column['name'] = $table['rename'][$column['name']];

$smcFunc['db_change_column']('{db_prefix}' $table_name$old_name$column);
}
}
}

// Global renames? (should be avoided)
if (!empty($columnRename))
{
foreach ($currentTable['columns'] as $column)
{
if (isset($columnRename[$column['name']]))
{
$old_name $column['name'];
$column['name'] = $columnRename[$column['name']];
$smcFunc['db_change_column']('{db_prefix}' $table_name$old_name$column);
}
}
}

// Check that all columns are in
foreach ($table['columns'] as $id => $col)
{
$exists false;

// TODO: Check that definition is correct
foreach ($currentTable['columns'] as $col2)
{
if ($col['name'] === $col2['name'])
{
$exists true;
break;
}
}

// Add missing columns
if (!$exists)
$smcFunc['db_add_column']('{db_prefix}' $table_name$col);
}

// Remove any unnecassary columns
foreach ($currentTable['columns'] as $col)
{
$exists false;

foreach ($table['columns'] as $col2)
{
if ($col['name'] === $col2['name'])
{
$exists true;
break;
}
}

if (!$exists && isset($table['upgrade']['columns'][$col['name']]))
{
if ($table['upgrade']['columns'][$col['name']] == 'drop')
$smcFunc['db_remove_column']('{db_prefix}' $table_name$col['name']);
}
elseif (!$exists && !empty($db_show_debug) && empty($table['smf']))
$log[] = sprintf('Table %s has non-required column %s'$table_name$col['name']);
}

// Check that all indexes are in and correct
foreach ($table['indexes'] as $id => $index)
{
$exists false;

foreach ($currentTable['indexes'] as $index2)
{
// Primary is special case
if ($index['type'] == 'primary' && $index2['type'] == 'primary')
{
$exists true;

if ($index['columns'] !== $index2['columns'])
{
$smcFunc['db_remove_index']('{db_prefix}' $table_name'primary');
$smcFunc['db_add_index']('{db_prefix}' $table_name$index);
}

break;
}
// Make sure index is correct
elseif (isset($index['name']) && isset($index2['name']) && $index['name'] == $index2['name'])
{
$exists true;

// Need to be changed?
if ($index['type'] != $index2['type'] || $index['columns'] !== $index2['columns'])
{
$smcFunc['db_remove_index']('{db_prefix}' $table_name$index['name']);
$smcFunc['db_add_index']('{db_prefix}' $table_name$index);
}

break;
}
}

if (!$exists)
$smcFunc['db_add_index']('{db_prefix}' $table_name$index);
}

// Remove unnecassary indexes
foreach ($currentTable['indexes'] as $index)
{
$exists false;

foreach ($table['indexes'] as $index2)
{
// Primary is special case
if ($index['type'] == 'primary' && $index2['type'] == 'primary')
$exists true;
// Make sure index is correct
elseif (isset($index['name']) && isset($index2['name']) && $index['name'] == $index2['name'])
$exists true;
}

if (!$exists)
{
if (isset($table['upgrade']['indexes']))
{
foreach ($table['upgrade']['indexes'] as $index2)
{
if ($index['type'] == 'primary' && $index2['type'] == 'primary' && $index['columns'] === $index2['columns'])
$smcFunc['db_remove_index']('{db_prefix}' $table_name'primary');
elseif (isset($index['name']) && isset($index2['name']) && $index['name'] == $index2['name'] && $index['type'] == $index2['type'] && $index['columns'] === $index2['columns'])
$smcFunc['db_remove_index']('{db_prefix}' $table_name$index['name']);
elseif (!empty($db_show_debug))
$log[] = $table_name ' has Unneeded index ' var_dump($index);
}
}
elseif (!empty($db_show_debug))
$log[] = $table_name ' has Unneeded index ' var_dump($index);
}
}
}
}

if (!empty($log))
log_error(implode('<br />'$log));

return $log;
}

function 
doSettings($addSettings)
{
global $smcFunc$modSettings;

$update = array();

foreach ($addSettings as $variable => $value)
{
list ($value$overwrite) = $value;

if ($overwrite || !isset($modSettings[$variable]))
$update[$variable] = $value;
}

if (!empty($update))
updateSettings($update);
}

function 
doPermission($permissions)
{
global $smcFunc;

$perm = array();

foreach ($permissions as $permission => $default)
{
$result $smcFunc['db_query']('''
SELECT COUNT(*)
FROM {db_prefix}permissions
WHERE permission = {string:permission}'
,
array(
'permission' => $permission
)
);

list ($num) = $smcFunc['db_fetch_row']($result);

if ($num == 0)
{
foreach ($default as $grp)
$perm[] = array($grp$permission);
}
}

if (empty($perm))
return;

$smcFunc['db_insert']('insert',
'{db_prefix}permissions',
array(
'id_group' => 'int',
'permission' => 'string'
),
$perm,
array()
);
}

function 
updateAdminFeatures($item$enabled false)
{
global $modSettings;

$admin_features = isset($modSettings['admin_features']) ? explode(','$modSettings['admin_features']) : array('cd,cp,k,w,rg,ml,pm');

if (!is_array($item))
$item = array($item);

if ($enabled)
$admin_features array_merge($admin_features$item);
else
$admin_features array_diff($admin_features$item);

updateSettings(array('admin_features' => implode(','$admin_features)));

return true;
}

?>

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



China   ชาย ออฟไลน์
icon message
general ความคิดเห็นที่ 2 เมื่อ: 23 กันยายน 2554, 08:47:31
ทำไมผมทำแล้วเป็นอย่างนี้อะครับ


Table 'smokedar_s2b.smf_related_topics' doesn't exist
ไฟล์: /home/smokedar/domains/siam2bot.com/public_html/Sources/Subs-Related.php
บรรทัด: 108

บันทึก: ฐานข้อมูลคุณต้องการอัพเกรดใหม่ ฟอรั่มของคุณในขณะนี้เป็นเวอร์ชั่น SMF, ด้วยเหตุนี้ SMF ของคุณ 1.1.11. มันถูกแนะนำกับเวอร์ชั่นล่าสุดในไฟล์ upgrade.php.

ลิงค์หัวข้อ: http://dexmore.com/topic/2305
Windows XP    Microsoft Internet Explorer 8.0   see ip บันทึกการเข้า
โฮสต์ดีๆ บริการด้วยใจ
ส่งหัวข้อนี้พิมพ์ หน้า: 1 
กระโดดไป:  

Creative Commons License

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

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

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