حسناً لدي وقت فراغ اكثر من 10 دقائق
اليك طريقة عمل هذا الهاك بشكل احترافي اكثر ..
1- أنشأ ملف php جديد باسم who_visit_subject.class.php
وضع به الكلاس التالي :
CODE
<?php
/**
* PowerBB Engine - The Engine Helps You To Create Bulletin Board System.
*/
/**
* @package : PowerBBWhoVisitSubject (WhoVisitSubjects)
* @author : MSHRAQ abu-rakan (xxx_abu_rakan_xxx@hotmail.com)
* @start : 7/12/2010 , 03:25 AM
*/
class PowerBBWhoVisitSubject
{
var $id;
var $Engine;
function PowerBBWhoVisitSubject($Engine)
{
$this->Engine = $Engine;
}
/**
* Insert new WhoVisitSubject
*
* @param :
* Oh :O it's a long list
*/
function InsertWhoVisitSubject($param)
{
if (!isset($param)
or !is_array($param))
{
$param = array();
}
$query = $this->Engine->records->Insert($this->Engine->table['who_visit_subject'],$param['field']);
if ($param['get_id'])
{
$this->id = $this->Engine->DB->sql_insert_id();
}
return ($query) ? true : false;
}
/**
* Get the list of WhoVisitSubject
*
* $param =
* array( 'sql_statment' => 'complete SQL statement',
* 'proc' => true // When you want proccess the outputs
* );
*
* @return :
* array -> of information
* false -> when found no information
*/
function GetWhoVisitSubjectList($param)
{
if (!isset($param)
or !is_array($param))
{
$param = array();
}
$param['select'] = '*';
$param['from'] = $this->Engine->table['who_visit_subject'];
$rows = $this->Engine->records->GetList($param);
return $rows;
}
/**
* Get WhoVisitSubject info
*
* $param =
* array( 'id' => 'the id of Supermemberlogs');
*
* @return :
* array -> of information
* false -> when found no information
*/
function GetWhoVisitSubjectInfo($param)
{
if (!isset($param)
or !is_array($param))
{
$param = array();
}
$param['select'] = '*';
$param['from'] = $this->Engine->table['who_visit_subject'];
$rows = $this->Engine->records->GetInfo($param);
return $rows;
}
function GetWhoVisitSubjectNumber($param)
{
if (!isset($param))
{
$param = array();
}
$param['select'] = '*';
$param['from'] = $this->Engine->table['who_visit_subject'];
$num = $this->Engine->records->GetNumber($param);
return $num;
}
/**
* Check if the who_visit_subject exists in database or not
*/
function IsWhoVisitSubject($param)
{
if (!isset($param)
or !is_array($param))
{
$param = array();
}
$param['select'] = '*';
$param['from'] = $this->Engine->table['who_visit_subject'];
$num = $this->Engine->records->GetNumber($param);
return ($num <= 0) ? false : true;
}
}
?>
وارفعه على المسار التالي :
CODE
engine/systems/who_visit_subject.class.php
2- حرر ملف : engine/Engine.class.php
وابحث عن :
CODE
$files[] = ($CALL_SYSTEM['FRIENDS']) ? 'friends.class.php' : null;
اضف اسفله :
CODE
$files[] = ($CALL_SYSTEM['WHOVISITSUBJECT']) ? 'who_visit_subject.class.php' : null;
وابحث عن :
CODE
var $friends;
اضف اسفله :
CODE
var $who_visit_subject;
وابحث عن :
CODE
$this->table['friends'] = $this->prefix . 'friends';
اضف اسفله :
CODE
$this->table['who_visit_subject'] = $this->prefix . 'who_visit_subject';
وابحث عن :
CODE
$this->friends = ($CALL_SYSTEM['FRIENDS']) ? new PowerBBFriends($this) : null;
أضف اسفله :
CODE
$this->friends = ($CALL_SYSTEM['WHOVISITSUBJECT']) ? new PowerBBWhoVisitSubject($this) : null;
أغلق الملف واحفظة ..
3- حرر ملف common.php
وابحث عن :
CODE
$CALL_SYSTEM['FRIENDS'] = true;
اضف اسفله :
CODE
$CALL_SYSTEM['WHOVISITSUBJECT'] = true;
أغلق الملف واحفظة ..
4- اضف الجدول التالي في قاعدة البيانات :
CODE
CREATE TABLE `pbb_who_visit_subjects` (
`id` int(9) NOT NULL auto_increment,
`subject_id` int(10) NOT NULL,
`member_id` int(10) NOT NULL,
`username` varchar(255) NOT
NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
5- حرر ملف الـ modules/topic.module.php
وابحث عن :
CODE
$PowerBB->template->display('subject_top');
اضف بعده :
CODE
if ($PowerBB->_CONF['member_permission'])
{
$WhoVisitSubjectInfoArr = array();
$WhoVisitSubjectInfoArr['where'] = array('subject_id',$PowerBB->_GET['id']);
$WhoVisitSubjectInfo = $PowerBB->who_visit_subject->GetWhoVisitSubjectInfo($WhoVisitSubjectInfoArr);
if (!$PowerBB->who_visit_subject->IsWhoVisitSubject(array('where' => array('member_id',$PowerBB->_CONF['rows']['member_row']['id']))))
{
$WhoVisitSubjectArr = array();
$WhoVisitSubjectArr['field'] = array();
$WhoVisitSubjectArr['field']['username'] = $PowerBB->_CONF['rows']['member_row']['username'];
$WhoVisitSubjectArr['field']['member_id'] = $PowerBB->_CONF['rows']['member_row']['id'];
$WhoVisitSubjectArr['field']['subject_id'] = $PowerBB->_GET['id'];
$insert_visit_subject = $PowerBB->who_visit_subject->InsertWhoVisitSubject($WhoVisitSubjectArr);
}
}
وابحث عن :
CODE
$PowerBB->template->display('topic_end');
اضف فوقه :
CODE
$VisitSubjectArr = array();
$VisitSubjectArr ['where'] = array('subject_id',$PowerBB->_GET['id']);
$PowerBB->_CONF['template']['while']['WhoVisitSubjectList'] = $PowerBB->who_visit_subject->GetWhoVisitSubjectList($VisitSubjectArr);
$VisitSubjectNumber = $PowerBB->who_visit_subject->GetWhoVisitSubjectNumber($VisitSubjectArr);
$PowerBB->template->assign('VisitSubjectNumber',$VisitSubjectNumber);
أغلق الملف واحفظة ..
6- حرر قالب : topic_end.tpl
وابحث عن :
CODE
{template}show_tags_topic{/template}
اضف اسفله :
CODE
<table border="0" cellspacing="1" class="border" width="98%" align="center">
<tr>
<td width="98%" class="thead1" align="right">الأعضاء الذين شاهدوا الموضوع
{$VisitSubjectNumber}
</td>
</tr>
<tr>
<td width="98%" class="row1" align="right">
{Des::while}{WhoVisitSubjectList}
<a href="index.php?page=profile&show=1&id={$WhoVisitSubjectList['member_id']}">{$WhoVisitSubjectList['username_style']}</a>،
{/Des::while}
{if {$VisitSubjectNumber} <= 0}
لم تتم مشاهدة الموضوع من قبل اي عضو حتى الآن ..
{/if}
</td>
</tr>
</table>
اغلق القالب واحفظة ..
أنتهى ..
ملاحظة لم اقم بالتدقيق والتجربة فقد كتبت الأكواد بشكل سريع ..قم بتركيبه وتجربتة وتصحيح اي اخطاء
بالتوفيق .....