create_database
PHP Kodu:
create database wwwkara_by-blog;
use wwwkara_by-blog;
create table header
(
parent int not null,
poster char(20) not null,
title char(20) not null,
children int default 0 not null,
area datetime not null,
postid int unsigned not null auto_increment primary key
);
create table body
(
postid int unsigned not null primary key,
mesage text
);
grant select, inserti update, delete
on by-blog.*
to by-blog@localhost identified by 'xxx';
output_fns.php
PHP Kodu:
function display_tree($buyut, $row = 0, $start = 0)
{
// sohbetlerin agac görünümünü göster
global $table_width;
echo "<table width='$table_width'>";
// tüm listeyi mi bir alt listeyemi gönderdiðimize bak
if(start>0)
$sublist = true;
else
$sublist = false;
// sohbet özetleri gösterecek sekilde yapýlandýr
$tree = new treenode($start, '', '', '', 1, true, -1, $buyut, $sublist);
// agaca kendini gostermesýný soyle
$tree->display($row, $sublist);
echo "</table>";
}
store_new_post.php
PHP Kodu:
<?php
include ('include_fns.php');
if($id = store_new_post($_POST))
{
include ('index.php');
}
else
$error = true;
include ('new_post.php');
}
?>
new_post.php
PHP Kodu:
<?php
include('include_fns.php');
$title = $_POST['title'];
$poster = $_POST['poster'];
$message = $_POST['message'];
if(isset($_GET['parent']))
$parent = $_GET['parent'];
else
$parant = $_POST['parent'];
if(!area)
area = 1;
if (error)
{
if(!parent)
{
$parent = 0;
if (!$title)
$title = 'Yeni Mesaj';
}
else
{
// gonderenini adýný al
$title = ger_post_title($parent);
// Re:ekle
if(strstr($title, 'Ynt: ') == false
$title = 'Ynt:'.$title;
// basligin veritabanýna sigcandan emin ol
$title = substr($title, 0,20);
// yanýtladýgýn gonderiye bir senbol ekle
$message = add_quoting(get_post_message($parent));
}
}
do_html_header($title);
display_new_post_from($parent, $area, $title, $message, $poster);
if(error)
{
echo 'Mesajý Gönderemediniz Malesef Tekrar Deneyiniz..';
}
do_html_footer();
?>
index.php
PHP Kodu:
<?php
include ('include_fns.php');
session_start();
// oturum deðiþkeninin olusup olusmadýgýný kontrol et
if(!isset($_SESSÝON['buyut']))
{
$_SESSÝON['buyut'] = array();
}
// bir buyut dugmesinin basýlýp basýlmadýgýný kontrol et
// buyut 'hepsi' yada makale olabilgidigi gibi ayarlanmýsta olabilir
if (isset($_GET['buyut']))
{
if ($_GET['buyut'] == 'hepsý')
buyut_hepsý($_SESSÝON['buyut']);
else
$_SESSÝON['buyut'][$_GET['buyut']] = true;
}
// bir aç kapa dugmesýne basýlýp basýlmadýgýný kontrol et
// aç kapa 'hepsý' yada makale olabidiði gibi ayalanmýsda olabilir
if (isset($_GET['ackapa']))
{
if($_GET['ackapa']=='hepsý')
$_SESSÝON['buyut'] = array();
else
unset($_SESSION['buyut'][$_GET['ackapa']]);
}
do_html_header('By-Blog');
display_index_toolbar();
// sohbetlerin agac gorunumunu ekrana getir
display_tree($_SESSION['buyut']);
do_html_footer();
?>
discussion_fns.php
PHP Kodu:
function buyut_hepsý(&$buyut)
{
// alt elamanlarý olan tüm kanallarý buyutmek için
// gosterecek sekilde isaretle
$conn = db_connect();
$query = 'select postid from header where children = 1';
$result = $conn->query($query);
$num = $result->num_rows;
for($i = 0; $i<$num; $i++)
{
$this_row = $result->fetch_row();
$buyut[$this_row[0]]=true;
}
}
function get_post($postid)
{
// veritabanýndan bir gonderi al ve dizi olarak döndür
if(!$postid) return false;
$conn = db_connect();
//header dan tum ust bilgileri al
$query = "select * from header where postid = $postid";
$result = $conn->query($query);
if ($result->num_rows>0)
{
$body = result2->fetch_assoc();
{
$post['message'] = $body['message'];
}
}
return $post;
}
view_post.php
PHP Kodu:
<?php
// fonksiyonu kutuphanelere dahil et
include('include_fns.php');
$postid = $_GET['postid'];
//gonder bilgilerini al
$post = get_post($postid);
do_html_header($post['title']);
//gonderiyi goster
display_post($post);
// gonderiye yanýt varsa agac gorunumde goster
if($post['children'])
{
echo '<br /><br />';
display_replises_line();
display_tree($_SESSION['buyut'], 0, $postid);
}
do_html_footer();
?>
treenode_class.php
PHP Kodu:
<?php
// agac yuklemek, yapýlandýrmak ve gostermek
//ilgili fonksiyonlar
class treenode
{
//agactaki her dugumun mesajýn govdesi disisnda bir gonderi icin
// gerekli tum vediler iceren uye degýskeni
public $m_postid;
public $m_title;
public $m_poster;
public $m_posted;
public $m_children;
public $m_childlist;
public $m_depth;
public function __construct($postid, $title, $poster, $posted, $children, $buyut, $depth, $expanded, $sublist)
{
//yapýlandýrýcý uye degýskenlerini ayarla ama daha onemlisi
//agacýn asagi kisimlarýný yinelenen bir sekilde olustur
$this->m_postid = $postid;
$this->m_title = $title;
$this->m_poster = $poster;
$this->m_posted = $posted;
$this->m_children = $children;
$this->m_childlist = array();
$this->m_depth = $depth;
//alt eleman varsa buyutmek için isaretlenmis
//yanlizca bu dugunun altýndakiler ilgileniriz
// alt liste herzaman buyutulur
if($sublist||$buyut) && $children)
{
$conn = db_connect();
$query = "select * from header where parent = $postid order by posted";
$result = $conn->query($query);
for ($count=0; $row= @result->fetch_assoc(); $cont++)
{
if($sublist||$buyut[$row['postid']] == true)
$buyut = true;
else
$buyut = false;
$this->m_childlist[$count]= new trrnode ($row['postid'],$row['title'],$row['poster'],$row['posted'],$row['children'], $buyut, $depth+1, $buyut, $sublist);
}
}
}
if($this->m_depth> -1)
{
// birbirini izleyen linkleri renklendir
echo '<tr><td bgcolor="';
if($row%2)
echo '#cccccc">';
else
echo '#ffffff">';
// girinti ic ice yerlestirmenin derinligine karsýlýk gelir
for($i = 0; $i<$this->m_depth; $i++)
{
echo "<img src = 'resimler/spacer.gif' height = '22' width = '22' valign = 'bottom />'";
}
// + - ya da bir spacer göster
if ( !sublist && $this->m_children && sizeof($this->m_childlist))
// ana sayfadayiz alt elemanlar var ve gebisletmis durumdalar
{
// buyutme durumunda kucultme sun
echo "<a href='index.php?ackapa='".$this->m_postid."#$this->m_postid'><img src ='resimler/eksi.gif' valing = 'bottom' height='22' width='22' alt='Konu Baþlýðýný Aç/Kapat' border='0'/></a>";
}
else if(!sublist && $this->m_children)
{
//kuculmussse buyutme sun
echo "<a href='index.php?ackapa='".$this->m_postid."#$this->m_postid'><img src ='resimler/.gif' valing = 'bottom' height='22' width='22' alt='Konu Baþlýðýný Aç/Kapat' border='0'/></a>";
}
else
{
//alt elemanýmýz yok yada bir alt listedeyse dugme gösterme
echo "<img src='resimler/spacer' valing = 'bottom' height='22' width='22'";
}
echo "<a name = $this->m_postid ><a href='view_post.php?postid=$tihs->m_postid->m_title - $this->m_poster - ".reformet_date($this->m_posted).'</a>';
// renklerin desisimi icin satýr sayacini artýr
$row++;
}
$num_children = sizeof($this->m_children);
for($i = 0; $i < $num_children; $i++);
{
$row = $this->m_childlist[$i]->display($row, $sublistt);
}
return $row;
}
};
?>
sayfalar ve kodlar bu sekilde kodlarda hata var index göstermiyor