»Forumlar »SE ? Beginners »Chat.index plugini ve küçük bir değişiklik
  https://seditio.com.tr/eski1/forums.php?m=posts&q=1327
          Geri Dön      -      Sayfayı Yazdırmak için tıklayın
Author: hakan yildiz, Posted: 2011-03-22 19:14 GMT. This post was edited by Kaan (2011-03-23 00:02 GMT, 5633 Gün ago)
Uzunca bir d?nem arad???m chat.index pluginini neocrome sitesinde bulmu?tum, indirdim y?kledim ve kullanmaya ba?lad???mda g?r?nt? olarak hi? ho?uma gitmedi?i i?in kald?rd?m ve tekrar aramaya ba?lad?m

Daha sonra kaan beyin yazm?? oldu?u chat.index pluginini buldum ve onu denedim, g?r?nt? olarak ?ok ho?uma gitti fakat kendimce k?c?k bir sorun g?rd?m

Sorun ise ?u ;
Mesela herhangi birisi Selam yazm?? aradan 6 saat ge?mi? a.selam yazm??lar
<Ali42> S.a
<mustafa78> A.s abii

Buraya bir tarih eklemek istiyorum, mesela
Tarih-Saat /Ali42/ S.a
Tarih-Saat /mustafa78/ A.s abii

chat.index.php
Kod:
<?PHP

/* ====================
Land Down Under - Website engine
Copyright Neocrome
http://www.neocrome.net

[BEGIN_SED]
File=plugins/chat/chat.php
Version=122
Updated=2007
Type=Plugin
Author=Kaan
Description=
[END_SED]

[BEGIN_SED_EXTPLUGIN]
Code=chat
Part=index
File=chat.index
Hooks=index.tags
Tags=index.tpl:{CHAT_MAIN},{CHAT_OPTIONS},{CHAT_SENDBOX},{CHAT_PAGES},{CHAT_JS}
Minlevel=0
Order=10
[END_SED_EXTPLUGIN]

==================== */

if (!defined('SED_CODE')) { die('Wrong URL.'); }

require('plugins/chat/inc/chat.inc.php');


// =============== Presets



unset($chat);
$newline = sed_import('newline','P','TXT');
$c = sed_import('c','G','ALP');
$d = sed_import('d','G','INT');
$d =(empty($d)) ? 0 : $d;
$id = sed_import('id','G','INT');
$jp = sed_import('jp','G','ALP');
$chat['joinpart'] = ($jp) ? TRUE : FALSE;



// =============== Statistics

$sys['day'] = date('Y-m-d');

$hits_today = sed_chat_getstat($sys['day']);

if ($hits_today>0)
{ sed_chat_stathit($sys['day']); }
else
{ sed_chat_statcreate($sys['day']); }


// =============== Handling of the userlist

$chat_timedout = $sys['now_offset'] - $cfg['plugin']['chat']['timeout']*4850000;

$sqltmp = sed_sql_query("SELECT u.user_name, c.chat_online_userid FROM sed_chat_online AS c
LEFT JOIN $db_users AS u ON u.user_id=c.chat_online_userid
WHERE chat_online_lastseen<'".$chat_timedout."'");

while ($row = sed_sql_fetcharray($sqltmp))
{ sed_chat_addline(0, "Quits: ".sed_cc(stripslashes($row['user_name']))." (Timeout)"); }

$sqltmp = sed_sql_query("DELETE FROM sed_chat_online WHERE chat_online_lastseen<'".$chat_timedout."'");

if ($usr['maingrp']>0)
{
$sqltmp = sed_sql_query("SELECT chat_online_userid FROM sed_chat_online WHERE chat_online_userid = '".$usr['id']."'");

if ($row = sed_sql_fetcharray($sqltmp))
{
$sqltmp = sed_sql_query("UPDATE sed_chat_online SET chat_online_lastseen='".$sys['now_offset']."' WHERE chat_online_userid = '".$usr['id']."'");
}
else
        {
        $sqltmp = sed_sql_query("INSERT INTO sed_chat_online (chat_online_userid, chat_online_lastseen, chat_online_status) VALUES ('".$usr['id']."', '".$sys['now_offset']."', '0')");
sed_chat_addline(0, "Joins: ".sed_cc($usr['name']).", ".$sed_level[$usr['maingrp']]." [".$usr['level']."]");
        }
}


// =============== New line ?

if (strlen($newline)>0 && $usr['maingrp']>=$cfg['plugin']['chat']['minlevelwrite'] && $usr['maingrp']>0)
{
sed_shield_protect();
sed_chat_addline($usr['id'], $newline);

if (substr($newline,0,1)=='!')
{
$space_pos=strpos($newline, ' ');
if ($space_pos==0)
{
$c = strtolower(substr($newline, 1, 255));
$f = '';
}
else
{
$c = strtolower(substr($newline, 1, $space_pos-1));
$f = substr($newline, $space_pos, 155);
}
}
else
{
sed_redirect("index.php?e=chat&d=".$d);
exit;
}
}







// =============== Main

$chat['users'] = sed_chat_get_users();
$chat['mode'] = ($c=='edit' && $usr['maingrp']>=$cfg['plugin']['chat']['minleveladmin']) ? 'edit' : '';
$chat['channel'] = sed_chat_get_channel($d, $cfg['plugin']['chat']['numlines'], $chat['mode'], $chat['joinpart']);

$chat['sendbox'] = ($usr['maingrp']>=$cfg['plugin']['chat']['minlevelwrite']) ? "<form id=\"sb\" action=\"index.php?e=chat#sb\" method=\"post\"><input type=\"text\" class=\"text\" name=\"newline\" id=\"newline\" value=\"\" size=\"80\" maxlength=\"500\" /><input type=\"submit\" class=\"submit\" value=\"     G?nder     \"></form>" : 'Mesaj Yazmak i?in Giri? Yapmal?s?n?z..';


// =============== Options and topic

/*
$chat['options'] .= "<form id=\"settings\">Refresh delay (dev) : <select name=\"refreshdelay\" size=\"1\" onchange=\"redirect(this)\">";
$chat['options'] .= "<option value=\"index.php?e=chat\">20 seconds</option>";
$chat['options'] .= "<option value=\"index.php?e=chat\">30 seconds</option>";
$chat['options'] .= "<option value=\"index.php?e=chat\">45 seconds</option>";
$chat['options'] .= "<option value=\"index.php?e=chat\">1 minute</option>";
$chat['options'] .= "<option value=\"index.php?e=chat\">2 minutes</option>";
$chat['options'] .= "</select>";
$chat['options'] .= "</form>";
*/

$sql = sed_sql_query("SELECT COUNT(*) FROM sed_chat WHERE chat_userid>0");
$totallines = sed_sql_result($sql, 0, "COUNT(*)");

$nbpages = ceil($totallines / $cfg['plugin']['chat']['numlines']);
$curpage = $d / $cfg['plugin']['chat']['numlines'];

$chat['pagenav'] .= "Page ".(floor($d/$cfg['plugin']['chat']['numlines'])+1);
$chat['pagenav'] .= "/".ceil($totallines/$cfg['plugin']['chat']['numlines'])." &nbsp; ";
$chat['pagenav'] .= ($d==0) ? " (newest) " : '';

if (($d + $cfg['plugin']['chat']['numlines'])<$totallines)
{
$prevpage = $d + $cfg['plugin']['chat']['numlines'];
$chat['pagenav'] .= "<a href=\"index.php?e=chat&amp;d=".$prevpage."#sb\"> $sed_img_up</a> &nbsp; ";
}

if ($d>0)
{
$nextpage = $d - $cfg['plugin']['chat']['numlines'];
if ($nextpage<0) { $nextpage = 0; }
$chat['pagenav'] .= "<a href=\"index.php?e=chat&amp;d=".$nextpage."#sb\">$sed_img_down</a>";
}

for ($i = 0; $i < $nbpages; $i++)
{
$j = $i * $cfg['plugin']['chat']['numlines'];
if ($i==$curpage)
{ $chat['pages'] .= "> <a href=\"forums.php?m=posts&amp;q=$q&amp;d=".$j."\">".($i+1)."</a> < "; }

elseif (is_int(($i+1)/5) || $i<10 || $i+1==$nbpages)

{ $chat['pages'] .= "<a href=\"index.php?e=chat&amp;d=".$j."\">".($i+1)."</a> "; }
}


$jp_str = ($chat['joinpart']) ? "&jp=1" : '';
$chat['options'] .= ($usr['maingrp']>=$cfg['plugin']['chat']['minleveladmin']) ? "<a href=\"index.php?e=chat&amp;c=edit&amp;d=".$d."\">Edit</a> " : '';
$chat['pagenav'] .= ($totallines>$cfg['plugin']['chat']['numlines'] && $d>0) ? " &nbsp; <a href=\"index.php?e=chat&amp;d=0\">$sed_img_down$sed_img_down</a>" : '';
$chat['options'] .= " &nbsp; Oto yenileme ".$cfg['plugin']['chat']['refreshd']." saniye / Mesaj?n?z? Yaz?n?z.";

$chat['topic'] = sed_chat_parse($cfg['plugin']['chat']['topic']);

// =============== Outputing

$chat['main'] = "<table class=\"cells\" style=\"width:100%\">";

$chat['main'] .= "<tr><td style=\"width:100%\">".$chat['channel']."</td></tr></table>";

$t-> assign(array(
"CHAT_MAIN" => $chat['main'],
"CHAT_OPTIONS" => $chat['options'],
"CHAT_SENDBOX" => $chat['sendbox'],
"CHAT_PAGENAV" => $chat['pagenav'],
"CHAT_PAGES" => $chat['pages'],
"CHAT_JS" => sed_chat_jsclient($cfg['plugin']['chat']['refreshd'], $d, $chat['joinpart'])
));

?>


Te?ekk?r ederim ..
Author: Kaan, Posted: 2011-03-22 23:15 GMT.
Chat.inc.php yi eklermisin.?

eklenti i?erisinde inc klas?r? i?erisinde bulunuyor..
Author: hakan yildiz, Posted: 2011-03-22 23:30 GMT. This post was edited by Kaan (2011-03-23 00:03 GMT, 5633 Gün ago)
Te?ekk?r ederim

chat.inc.php
Kod:
<?PHP

/* ====================
Land Down Under - Website engine
Copyright Neocrome
http://www.neocrome.net

[BEGIN_SED]
File=plugins/chat/inc/chat.inc.php
Version=122
Updated=2007
Type=Plugin
Author=Kaan
Description=
[END_SED]

==================== */

if (!defined('SED_CODE')) { die('Wrong URL.'); }

function sed_chat_jsclient($refreshd, $page, $joinpart)
{
$res = "<script type=\"text/javascript\">
var xmlhttp

function loadXMLDoc(url)
{
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest()
xmlhttp.onreadystatechange=state_Change
xmlhttp.open(\"GET\",url,true)
xmlhttp.send(null)
}
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\")
if (xmlhttp)
{
xmlhttp.onreadystatechange=state_Change
xmlhttp.open(\"GET\",url,true)
xmlhttp.send()
}
}
}
function state_Change()
{
if (xmlhttp.readyState==4)
{
if (xmlhttp.status==200)
{ document.getElementById('chat').innerHTML=xmlhttp.responseText }
else
{ alert(\"Problem retrieving data:\" + xmlhttp.statusText) }
}
}
";

$jp_str = ($joinpart) ? "&jp=1" : '';

$res .= ($page==0) ? "timerID=setInterval('loadXMLDoc(\"chat_io.php?channel=1".$jp_str."\");', ".($refreshd*1000).");" : '';
$res .= "
document.sb.newline.focus();
</script>";

return($res);
}

function sed_chat_addline($userid, $line)
{
global $sys;
$sql = sed_sql_query("INSERT INTO sed_chat (chat_date, chat_userid, chat_text) VALUES ('".$sys['now_offset']."', '".$userid."', '".addslashes($line)."')");
return;
}

function sed_chat_get_users()
{
global $db_users;

$sql = sed_sql_query("SELECT u.user_country, u.user_maingrp, u.user_name, c.* FROM sed_chat_online AS c
LEFT JOIN $db_users AS u ON u.user_id=c.chat_online_userid
WHERE 1 ORDER BY u.user_maingrp DESC, u.user_name ASC");

while ($row = sed_sql_fetcharray($sql))
{
$res .= sed_build_flag($row['user_country'])." ".sed_build_pm($row['chat_online_userid'])." [".$row['user_maingrp']."] ";
$res .= sed_build_user($row['chat_online_userid'], sed_cc(stripslashes($row['user_name'])))." <br />";
}

return($res);
}


function sed_chat_get_channel($start, $num, $mode='read', $joinpart=FALSE)
{
global $db_users, $sys, $cfg, $d, $usr;

if ($joinpart)
{
$sql = sed_sql_query("SELECT c.*, u.user_name FROM sed_chat as c
LEFT JOIN $db_users AS u ON u.user_id=c.chat_userid
WHERE 1 ORDER BY chat_id DESC LIMIT $start, $num");
}
else
{
$sql = sed_sql_query("SELECT c.*, u.user_name FROM sed_chat as c
LEFT JOIN $db_users AS u ON u.user_id=c.chat_userid
WHERE chat_userid>0 ORDER BY chat_id DESC LIMIT $start, $num");
}

$lines = array();

while ($row = sed_sql_fetcharray($sql))
{

$line = ($mode=='edit') ? "[<a href=\"plug.php?e=chat&amp;d=".$d."&amp;c=delete&amp;id=".$row['chat_id']."\">Sil</a>] " : '';

$line .= ($row['chat_userid']==0) ? '<span style="color:#'.$cfg['plugin']['chat']['syscolor'].';"><em>*** ' : "<".sed_build_user($row['chat_userid'], sed_cc(stripslashes($row['user_name'])))."> ";
$line .= sed_chat_parse(sed_cc(stripslashes($row['chat_text'])));
$line .= ($row['chat_userid']==0) ? '</em></span>' : '';
$lines[] = $line;
}

$lines = array_reverse($lines);

$res = "<div id=\"channel\" style=\"width:100%;\">".implode ("<br />", $lines)."</div>";

return($res);
}

function sed_chat_bbcode($text)
{
global $L, $skin, $sys, $cfg;

//$text = sed_BBparseurls($text);
$text = " ".$text;

$bbcodes1 = array(
'$' => '$',
'[b]' => '<strong>',
'[/b]' => '</strong>',
'[red]' => '<span style="color:#F93737">',
'[/red]' => '</span>',
'[white]' => '<span style="color:#FFFFFF">',
'[/white]' => '</span>',
'[green]' => '<span style="color:#09DD09">',
'[/green]' => '</span>',
'[blue]' => '<span style="color:#018BFF">',
'[/blue]' => '</span>',
'[orange]' => '<span style="color:#FF9900">',
'[/orange]' => '</span>',
'[yellow]' => '<span style="color:#FFFF00">',
'[/yellow]' => '</span>',
'[purple]' => '<span style="color:#A22ADA">',
'[/purple]' => '</span>',
'[black]' => '<span style="color:#000000">',
'[/black]' => '</span>',
'[grey]' => '<span style="color:#B9B9B9">',
'[/grey]' => '</span>',
'[pink]' => '<span style="color:#FFC0FF">',
'[/pink]' => '</span>',
'[sky]' => '<span style="color:#D1F4F9">',
'[/sky]' => '</span>',
'[sea]' => '<span style="color:#171A97">',
'[/sea]' => '</span>'
);

$bbcodes2 = array(
'\\[url=([^\\\'\;([]*)\\]([^\\[]*)\\[/url\\]' => '<a href="\\1"'.$cfg['exttarget'].'>\\2</a>',
'\\[url\\]([^\\([]*)\\[/url\\]' => '<a href="\\1"'.$cfg['exttarget'].'>\\1</a>',
'\\[color=([0-9A-F]{6})\\]([^\\[]*)\\[/color\\]' => '<font color=#\\1>\\2</font>',
'\\[email=([._A-z0-9-]+@[A-z0-9-]+\.[.a-z]+)\\]([^\\[]*)\\[/email\\]' => '<a href="mailto:\\1">\\2</a>',
'\\[email\\]([._A-z0-9-]+@[A-z0-9-]+\.[.a-z]+)\\[/email\\]' => '<a href="mailto:\\1">\\1</a>',
'\\[user=([0-9]+)\\]([A-z0-9_\. ]+)\\[/user\\]' => '<a href="users.php?m=details&amp;id=\\1">\\2</a>',
'\\[page=([0-9]+)\\]([^\\[]*)\\[/page\\]' => '<a href="page.php?id=\\1">\\2</a>',
'\\[page\\]([0-9]+)\\[/page\\]' => '<a href="page.php?id=\\1">'.$L['Page'].' #\\1</a>',
'\\[link=([0-9]+)\\]([^\\[]*)\\[/link\\]' => '<a href="links.php?a=jump&amp;id=\\1"'.$cfg['exttarget'].'>\\2</a>',
'\\[link\\]([0-9]+)\\[/link\\]' => '<a href="links.php?a=jump&amp;id=\\1"'.$cfg['exttarget'].'>Link #\\1</a>',
'\\[topic\\]([0-9]+)\\[/topic\\]' => '<a href="forums.php?m=posts&amp;q=\\1"'.$cfg['exttarget'].'>'.$L['Topic'].' #\\1</a>',
'\\[post\\]([0-9]+)\\[/post\\]' => '<a href="forums.php?m=posts&amp;p=\\1#\\1"'.$cfg['exttarget'].'>'.$L['Post'].' #\\1</a>',
'\\[pm\\]([0-9]+)\\[/pm\\]' => '<a href="pm.php?m=send&amp;to=\\1"><img src="skins/'.$skin.'/img/system/icon-pm.gif" alt=""></a>',
'\\[f\\]([a-z][a-z])\\[/f\\]' => '<a href="users.php?f=country_\\1"><img src="system/img/flags/f-\\1.gif" alt="" /></a>',
);

foreach($bbcodes1 as $bbcode => $bbcodehtml)
{ $text = str_replace($bbcode,$bbcodehtml,$text); }

foreach($bbcodes2 as $bbcode => $bbcodehtml)
{ $text = eregi_replace($bbcode,$bbcodehtml,$text); }

return(substr($text,1));
}

function sed_chat_parse($text)
{
global  $sys, $sed_smilies;

$text = ' '.$text;
$code = array();
$unique_seed = $sys['unique'];
$ii = 10000;

if (is_array($sed_smilies))
{
reset($sed_smilies);
while ((list($j,$dat) = each($sed_smilies)))
{
$ii++;
$key = '**'.$ii.$unique_seed.'**';
$code[$key]= "<img src=\"".$dat['smilie_image']."\" alt=\"\" />";
$text = str_replace($dat['smilie_code'], $key, $text);
}
}

$text = sed_chat_bbcode($text);

foreach($code as $x => $y)
{ $text = str_replace($x, $y, $text); }

    return(substr($text, 1));
}

function sed_chat_stathit($name)
{
$sql = sed_sql_query("UPDATE sed_chat_stats SET stat_value=stat_value+1 WHERE stat_name='$name'");
return;
}

/* ------------------ */

function sed_chat_statcreate($name)
{
$sql = sed_sql_query("INSERT INTO sed_chat_stats (stat_name, stat_value) VALUES ('$name', '1')");
return;
}

/* ------------------ */

function sed_chat_getstat($name)
{
$sql = sed_Sql_query("SELECT stat_value FROM sed_chat_stats where stat_name='$name' LIMIT 1");
$result = (sed_sql_numrows($sql)>0) ? sed_sql_result($sql, 0, 'stat_value') : FALSE;
return($result);
}

?>
Author: Kaan, Posted: 2011-03-23 00:00 GMT.
Alttakini bul.
Kod:
while ($row = sed_sql_fetcharray($sql))
{
$res .= sed_build_flag($row['user_country'])." ".sed_build_pm($row['chat_online_userid'])." [".$row['user_maingrp']."] ";
$res .= sed_build_user($row['chat_online_userid'], sed_cc(stripslashes($row['user_name'])))." <br />";
}

Alttaki ile de?i?tirip denermisin.
Kod:
while ($row = sed_sql_fetcharray($sql))
{
$dateformat = ($sys['now'] - $row['chat_date'] < 86400) ? 'H:i' : $cfg['formatmonthdayhourmin'];
$res .= "".date($dateformat, $row['chat_date'] + $usr['timezone'] * 3600)."";
$res .= sed_build_flag($row['user_country'])." ".sed_build_pm($row['chat_online_userid'])." [".$row['user_maingrp']."] ";
$res .= sed_build_user($row['chat_online_userid'], sed_cc(stripslashes($row['user_name'])))." <br />";
}
Author: hakan yildiz, Posted: 2011-03-23 00:18 GMT.
Malesef ba?ar?l? olmad?
Author: Kaan, Posted: 2011-03-23 00:59 GMT.
Alttakini bul
Kod:
while ($row = sed_sql_fetcharray($sql))
{
$line = ($mode=='edit') ? "[<a href=\"plug.php?e=chat&amp;d=".$d."&amp;c=delete&amp;id=".$row['chat_id']."\">Sil</a>] " : '';
$line .= ($row['chat_userid']==0) ? '<span style="color:#'.$cfg['plugin']['chat']['syscolor'].';"><em>*** ' : "<".sed_build_user($row['chat_userid'], sed_cc(stripslashes($row['user_name'])))."> ";
$line .= sed_chat_parse(sed_cc(stripslashes($row['chat_text'])));
$line .= ($row['chat_userid']==0) ? '</em></span>' : '';
$lines[] = $line;
}

Alttakiyle de?i?tir i?lem tamamd?r.
Kod:
while ($row = sed_sql_fetcharray($sql))
{
$dateformat = ($sys['now'] - $row['chat_date'] < 86400) ? 'Y-m-d H:i' : $cfg['formatmonthdayhourmin'];
$line = ($mode=='edit') ? "[<a href=\"plug.php?e=chat&amp;d=".$d."&amp;c=delete&amp;id=".$row['chat_id']."\">Sil</a>] " : '';
$line .= "[".date($dateformat, $row['chat_date'] + $usr['timezone'] * 3600)."] ";
$line .= ($row['chat_userid']==0) ? '<span style="color:#'.$cfg['plugin']['chat']['syscolor'].';"><em>***' : "<".sed_build_user($row['chat_userid'], sed_cc(stripslashes($row['user_name'])))."> ";
$line .= sed_chat_parse(sed_cc(stripslashes($row['chat_text'])));
$line .= ($row['chat_userid']==0) ? '</em></span>' : '';
$lines[] = $line;
}

Ekran G?r?nt?s? bu ?ekilde olucakt?r.
[2011-03-23 00:57] <Admin> Mesaj
Author: hakan yildiz, Posted: 2011-03-23 01:03 GMT.
Tekrar te?ekk?r ederim, harikas?n?z ...

Powered by SeditioPrint version