TeknoTR  

Geri Dön   TeknoTR > Webmasterler için > Webmaster Genel
Üye Ol SSS Sxe indir Sosyal Gruplar Takvim Resim Galerisi Etiketler Bütün Forumları okunmuş kabul et


portal yapma

Webmaster Genel bölümünde portal yapma konusu , Önce gidelim kendimize veritabanından bir tablo oluşturalım Code: CREATE TABLE ` dokumanlar ` ( ` id ` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , ` sayfa_adi ` VARCHAR ( 150 ) NOT NULL , ` baslik ` VARCHAR ( 150 ...

Cevapla
 
LinkBack Konu Seçenekleri
Eski 01-12-2007, 11:02   #1 (permalink)
Üye
 
immortal - ait Avatar
 
Giriş: 28-01-2006
Yaş: 2
Mesajlar: 259
Rep Puanı: 305
immortal Rütbe Artı +1immortal Rütbe Artı +1immortal Rütbe Artı +1immortal Rütbe Artı +1
Rep Gücü: 35
E-Güven: (0/0)

portal yapma


Önce gidelim kendimize veritabanından bir tablo oluşturalım
Code:
CREATE TABLE `dokumanlar` ( 
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , 
`sayfa_adi` VARCHAR( 150 ) NOT NULL , 
`baslik` VARCHAR( 150 ) NOT NULL , 
`icerik` TEXT NOT NULL , 
`sayac` INT NOT NULL default '0' 
) TYPE = MYISAM ;  
Yine phpmyadmin kullanarak ekle kısmından sayfa ekleyebilirsiniz

ID kendinden artan olduğundan boş bırakılmalıdır.


Daha sonra aşağıdaki kodlarlada dökümanı veritabanından okutabilirsin. Örneğin aşağıdakini immortal.php olarak kaydettin, çağırmak istediğin sayfa adınada solid_snake girdin.

immortal.php?s=solid_snake

veya direk sayfa idsinide yazarak girebilirsin.

immortal.php?id=1
Code:
 <?php 

//SQL 
/* 

CREATE TABLE `dokumanlar` ( 
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , 
`sayfa_adi` VARCHAR( 150 ) NOT NULL , 
`baslik` VARCHAR( 150 ) NOT NULL , 
`icerik` TEXT NOT NULL , 
`sayac` INT NOT NULL default '0' 
) TYPE = MYISAM ; 

*/ 

//SQL Bağlantısı 
if ( !@mysql_connect('localhost', 'temp', 'temp') ) die(mysql_error()); 
if ( !@mysql_select_db('temp') ) die(mysql_error()); 

if ( isset($_GET['id']) && is_numeric($_GET['id']) ) $id = $_GET['id']; 
else $id = false; 

if ( isset($_GET['s']) ) $sayfa = mysql_real_escape_string(htmlspecialchars($_GET['s'])); 
else $sayfa = false; 

if ( !$id && !$sayfa ) echo 'Sayfa idsi veya adı girilmemiş'; 
else { 

    $sql = 'SELECT * FROM `dokumanlar` WHERE '; 
    if ( $id ) $sql .= '`id` = ' . $id; 
    else if ( $sayfa ) $sql .= '`sayfa_adi` = \'' . $sayfa . '\''; 
    $sql .= ' LIMIT 1;'; 
     
    $result = mysql_query($sql); 
    $row = mysql_fetch_assoc($result); 
    if ( !$row['id'] ) echo 'Aradığınız sayfa veritabanında bulunamamıştır'; 
    else { 
        echo $row['baslik'] . '<br><br>' . $row['icerik']; 
        //Sayac 1 arttırılıyor 
        $row['sayac']++; 
        echo '<br><br>Toplam okuma: ' . $row['sayac']; 
        mysql_query('UPDATE `dokumanlar` SET `sayac` = ' . $row['sayac'] . ' WHERE `id` = ' . $row['id'] . ' LIMIT 1'); 
    } 

} 

?> 
Döküman Ekleme:
Code:
 <?php 

//SQL Bağlantısı 
if ( !@mysql_connect('localhost', 'temp', 'temp') ) die(mysql_error()); 
if ( !@mysql_select_db('temp') ) die(mysql_error()); 


if ( !isset($_POST['Submit']) ) { 
?> 
<form method="post" action=""> 
<table width="100%"  border="0" cellspacing="0" cellpadding="0"> 
  <tr> 
    <td width="120">Sayfa Adı: </td> 
    <td><input name="sayfa_adi" type="text" id="sayfa_adi" style="width: 350px;"></td> 
  </tr> 
  <tr> 
    <td>Başlık:</td> 
    <td><input name="baslik" type="text" id="baslik" style="width: 350px;"></td> 
  </tr> 
  <tr> 
    <td valign="top">İçerik:</td> 
    <td><textarea name="icerik" id="icerik" style="width: 350px; height: 150px;"></textarea></td> 
  </tr> 
  <tr> 
    <td valign="top"><input type="submit" name="Submit" value="Kaydet"></td> 
    <td>&nbsp;</td> 
  </tr> 
</table> 
</form> 
<?php } 
else if ( isset($_POST['sayfa_adi']) && isset($_POST['baslik']) && isset($_POST['icerik']) && $_POST['sayfa_adi'] && $_POST['baslik'] && $_POST['icerik'] ) { 
    $result = mysql_query('INSERT INTO `dokumanlar` ( `id`, `sayfa_adi`, `baslik`, `icerik`, `sayac` ) VALUES ( NULL, \'' . $_POST['sayfa_adi'] . '\', \'' . $_POST['baslik'] . '\', \'' . $_POST['icerik'] . '\', 0 );'); 
    if ( $result ) echo 'Yeni sayfa eklenmiştir.'; 
    else echo mysql_error(); 
} 
else echo 'Lütfen tüm alanları doldurunuz'; 
?> 
Son dökümanlar:
Code:
 <?php 

//SQL Bağlantısı 
if ( !@mysql_connect('localhost', 'temp', 'temp') ) die(mysql_error()); 
if ( !@mysql_select_db('temp') ) die(mysql_error()); 

echo '<ol>'; 
$result = mysql_query('SELECT `id`, `baslik` FROM `dokumanlar` ORDER BY `id` DESC LIMIT 50'); 
while ( $row = mysql_fetch_assoc($result) ) echo '<li><a href="31.php?id=' . $row['id'] . '">' . $row['baslik'] . '</a></li>'; 
echo '</ol>'; 

?> 
Tablo:
Code:
CREATE TABLE `dosyalar` ( 
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , 
`adi` VARCHAR( 150 ) NOT NULL , 
`aciklama` TEXT NOT NULL , 
`url` VARCHAR( 350 ) NOT NULL , 
`eklenme_tarihi` INT( 10 ) NOT NULL DEFAULT '0', 
`sayac` INT NOT NULL DEFAULT '0' 
) TYPE = MYISAM  
Dosya Ekle: Yukarıda verdiğimi editledim pek bi fark yok
Code:
<?php 

//SQL Bağlantısı 
if ( !@mysql_connect('localhost', 'temp', 'temp') ) die(mysql_error()); 
if ( !@mysql_select_db('temp') ) die(mysql_error()); 


if ( !isset($_POST['Submit']) ) { 
?> 
<form method="post" action=""> 
<table width="100%"  border="0" cellspacing="0" cellpadding="0"> 
  <tr> 
    <td width="120">Dosya Adı: </td> 
    <td><input name="adi" type="text" id="adi" style="width: 350px;"></td> 
  </tr> 
  <tr> 
    <td valign="top">Açıklama:</td> 
    <td><textarea name="aciklama" id="aciklama" style="width: 350px; height: 150px;"></textarea></td> 
  </tr> 
  <tr> 
    <td valign="top">URL:</td> 
    <td><input name="url" type="text" id="url" style="width: 350px;" value=""></td> 
  </tr> 
  <tr> 
    <td valign="top"><input type="submit" name="Submit" value="Kaydet"></td> 
    <td>&nbsp;</td> 
  </tr> 
</table> 
</form> 
<?php } 
else if ( isset($_POST['adi']) && isset($_POST['aciklama']) && isset($_POST['url']) && $_POST['adi'] && $_POST['aciklama'] && $_POST['url'] ) { 
    $result = mysql_query('INSERT INTO `dosyalar` ( `id`, `adi`, `aciklama`, `url`, `eklenme_tarihi`, `sayac` ) VALUES ( NULL, \'' . $_POST['adi'] . '\', \'' . $_POST['aciklama'] . '\', \'' . $_POST['url'] . '\', \'' . time() . '\', 0 );'); 
    if ( $result ) echo 'Yeni dosya eklenmiştir.'; 
    else echo mysql_error(); 
} 
else echo 'Lütfen tüm alanları doldurunuz'; 
Dosya İndir:
Not: Aşağıdakileri html içine koymayın. Aksi taktirde çalışmaz. Ben zaten gerekli özelleştirmeleri yapacağınız $html ve $tablo değişkenini koydum
Code:
 <?php 

//SQL Bağlantısı 
if ( !@mysql_connect('localhost', 'temp', 'temp') ) die(mysql_error()); 
if ( !@mysql_select_db('temp') ) die(mysql_error()); 

$html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9"> 
<title>Dosya İndir</title> 
</head> 

<body> 
#ICERIK 
</body> 
</html>'; 

$tablo = '<table width="100%"  border="0" cellspacing="0" cellpadding="0"> 
  <tr> 
    <td width="120">Dosya Adı: </td> 
    <td>#DOSYA_ADI</td> 
  </tr> 
  <tr> 
    <td>Açıklama:</td> 
    <td>#ACIKLAMA</td> 
  </tr> 
  <tr> 
    <td>Eklenme Tarihi: </td> 
    <td>#EKLENME_TARIHI</td> 
  </tr> 
  <tr> 
    <td>Sayaç:</td> 
    <td>#SAYAC</td> 
  </tr> 
  <tr> 
    <td colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?indir=1&amp;id=#ID">Dosyayı İndirmek İçin Tıklayın</a></td> 
  </tr> 
</table>'; 

if ( isset($_GET['id']) && is_numeric($_GET['id']) ) $id = $_GET['id']; 
else die(str_replace('#ICERIK', 'Dosya ID\'si girilmemiş', $html)); 

$result = mysql_query('SELECT * FROM `dosyalar` WHERE `id` = ' . $id . ' LIMIT 1'); 
$row = mysql_fetch_assoc($result); 
if ( !$row['adi'] ) echo str_replace('#ICERIK', 'Aradığınız dosya veritabanında bulunamamıştır', $html); 
else if ( !isset($_GET['indir']) ) echo str_replace('#ICERIK', str_replace(array('#DOSYA_ADI', '#ACIKLAMA', '#EKLENME_TARIHI', '#SAYAC', '#ID'), array($row['adi'], $row['aciklama'], date('d.m.Y H:i', $row['eklenme_tarihi']), $row['sayac'], $id), $tablo), $html); 
else { 
    //Sayac arttırılıyor 
    $row['sayac']++; 
    mysql_query('UPDATE `dosyalar` SET `sayac` = ' . $row['sayac'] . ' WHERE `id` = ' . $id . ' LIMIT 1'); 
    header('location: ' . $row['url']); 
} 
?> 
Buda dosya listeleme:
Code:
 <table width="100%"  border="0" cellspacing="0" cellpadding="0"> 
  <tr> 
    <td>Dosya Adı</td> 
    <td width="120">İndirme</td> 
  </tr> 
<?php 

//SQL Bağlantısı 
if ( !@mysql_connect('localhost', 'temp', 'temp') ) die(mysql_error()); 
if ( !@mysql_select_db('temp') ) die(mysql_error()); 

$result = mysql_query('SELECT * FROM `dosyalar` ORDER BY `sayac` DESC'); 
while ( $row = mysql_fetch_assoc($result) ) echo '  <tr> 
    <td><a href="dosyaindir.php?id=' . $row['id'] . '">' . $row['adi'] . '</a></td> 
    <td width="120">' . $row['indirme'] . '</td> 
  </tr>'; 

?> 
</table>
vbulletindeki üye sayısı user tablosunun satır sayısına eşittir. Bunuda şu şekilde öğrenebilirsin:
PHP Kodu:
<?php

$temp 
mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM `user` LIMIT 1");
$result mysql_query("SELECT FOUND_ROWS()");
$total mysql_fetch_row($result);
echo 
$total[0] . ' üyemiz bulunmaktadır.';

?>
blok sistemi için
PHP Kodu:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
<title>TeknoTr.net immortal Portal</title>
<style type="text/css">
<!--
td {
    /* Tüm satırların sıralaması üste doğru yapılıyor */
    vertical-align: top;
}
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 9px;
    color: #FF0000;
}
body {
    background-color: #000000;
}
a {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 9px;
    color: #FF0000;
}
a:visited {
    color: #FFFFFF;
}
a:hover {
    color: #FF0000;
}
a:active {
    color: #FF0000;
}
h1 {
    font-size: 9px;
    color: #FF0000;
}
h2 {
    font-size: 9px;
    color: #FF0000;
}
h3 {
    font-size: 9px;
    color: #FF0000;
}
h4 {
    font-size: 9px;
    color: #FF0000;
}
h5 {
    font-size: 9px;
    color: #FF0000;
}
h6 {
    font-size: 9px;
    color: #FF0000;
}
.style1 {
    font-size: 12px;
    font-weight: bold;
}
.style4 {font-size: 12px}
-->
</style>
</head>

<body>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="170">
        <!-- BU BİR BLOKTUR SOL ÜSTTE, ALTINA YENİ BLOKLAR EKLEYEBİLİRSİN -->
        <table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="130">Dosya Adı</td>
    <td></td>
  </tr>
<?php

//SQL Bağlantısı
if ( !@mysql_connect('localhost''''') ) die(mysql_error());
if ( !@
mysql_select_db('') ) die(mysql_error());

$result mysql_query('SELECT * FROM `dosyalar` ORDER BY `sayac` DESC');
while ( 
$row mysql_fetch_assoc($result) ) echo '  <tr>
    <td><a href="dosyaindir.php?id=' 
$row['id'] . '">' $row['adi'] . '</a></td>
    <td width="200">' 
$row['indirme'] . '</td>
  </tr>'
;

?>
</table>
              <p>


<p>
<FIELDSET align="center" style="border: 1px solid #9db5d1;">
    <LEGEND><strong><font face="Arial" color="#000080">Son 5</font></strong></LEGEND>
<iframe name="sonkonular" marginheight="0" marginwidth="0" frameborder="0" width="90%" height="90" scrolling="auto" src="http://www.gerekli/portal/login.php"></iframe><br/></fieldset></td>
          </tr>
        </table>
        <!-- / BU BİR BLOKTUR SOL ÜSTTE, ALTINA YENİ BLOKLAR EKLEYEBİLİRSİN -->    </td>
    <td width="10"><!-- BOŞLUK --></td>
    <td width="752"><!-- ANA İÇERİK --><div align="center">
      <h1 class="style1">Forumdan Son Konular </h1>
    </div>
     <? 
// Kodu yazan:immortal
## CUSTOMIZE SETTINGS FOR YOUR SITE ## 
$db_host "localhost"// Change this if your MySQL database host is different. 
$db_name "gerekli"// Change this to the name of your database. 
$db_user "gerekli"// Change this to your database username. 
$db_pw "gerekli"// Change this to your database password. 

$forum_url "http://www.gerekli/forum"// Change this to reflect to your forum's URL. 
$forum_id ""// If you wish to display the posts from a specific forum, enter the forum id here. Otherwise, leave it blank. 
$limit "10"// Number of posts displayed. 
$titlecolor "#FF0000"// This is the color of the title. 
$postedcolor "#FFFFFF"// This is the color of the bottom text. 
$txtlimit "100"// This is the character limit. 
####################################### 

// Connecting to your database 
mysql_connect($db_host$db_user$db_pw
OR die (
"Cannot connect to your database"); 
mysql_select_db($db_name) OR die("Cannot connect to your database"); 

// Below is the beginning of a table. If you feel you don't need it, you may remove it. 
echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" bgcolor=\"#000000\">"

if (
$forum_id) { 
$forumid "AND forumid=$forum_id"


if (
$limit) { 
$limited "LIMIT $limit"

$thread_sql mysql_query("SELECT threadid,title,lastpost,lastposter FROM thread WHERE visible=1 AND open=1 $forumid ORDER BY lastpost DESC $limited"); 

while(
$thread_get=mysql_fetch_array($thread_sql)) 

$lastpost $thread_get['lastpost']; 
$poster $thread_get['lastposter']; 
$tid $thread_get['threadid']; 
$psql mysql_query("SELECT postid FROM post WHERE threadid=$tid ORDER BY postid DESC"); 
$getp=mysql_fetch_array($psql); 
$pid $getp['postid']; 
$date2 date ("m/d/y h:i A" ,$lastpost); 
$title $thread_get['title']; 
$title substr($title,0,$txtlimit); 
echo 
"<tr><td><font size=\"2\" face=\"verdana,arial,geneva\"><a href=\"$forum_url/showthread.php?p=$pid#post$pid\" target=\"_blank\"><FONT SIZE=\"2\" COLOR=\"$titlecolor\" face=\"verdana,arial,geneva\">$title</FONT></a></font><br /><font color=\"$postedcolor\" face=\"verdana,arial,geneva\" size='1'>gönderen: $poster </FONT></td></tr>"

echo 
"</table>"
?> 


</td>
    <td width="10"><!-- BOŞLUK --></td>
    <td width="170">
        <!-- BU BİR BLOKTUR SAĞ ÜSTTE, ALTINA YENİ BLOKLAR EKLEYEBİLİRSİN -->
        <table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><style type="text/css">
<!--
a {
    font-family: Arial, Helvetica, sans-serif;
}
-->
</style>
              <?php

//SQL Bağlantısı
if ( !@mysql_connect('localhost''gerekli''gerekli') ) die(mysql_error());
if ( !@
mysql_select_db('gereklialan') ) die(mysql_error());

echo 
'<ol>';
$result mysql_query('SELECT `id`, `baslik` FROM `dokumanlar` ORDER BY `id` DESC LIMIT 50');
while ( 
$row mysql_fetch_assoc($result) ) echo '<li><a href="31.php?id=' $row['id'] . '">' $row['baslik'] . '</a></li>';
echo 
'</ol>';

?>
<style type="text/css">
<!--
a {
    font-family: Arial, Helvetica, sans-serif;
}
-->
</style>
            <?php

//SQL Bağlantısı
if ( !@mysql_connect('localhost''gerekli''gerekli') ) die(mysql_error());
if ( !@
mysql_select_db('gerekli') ) die(mysql_error());

echo 
'<ol>';
$result mysql_query('SELECT `id`, `baslik` FROM `dokumanlar` ORDER BY `id` DESC LIMIT 50');
while ( 
$row mysql_fetch_assoc($result) ) echo '<li><a href="dokuman.php?id=' $row['id'] . '">' $row['baslik'] . '</a></li>';
echo 
'</ol>';

?>
</td>
          </tr>
        </table>
        <!-- / BU BİR BLOKTUR SAĞ ÜSTTE, ALTINA YENİ BLOKLAR EKLEYEBİLİRSİN -->    </td>
  </tr>
</table>
</body>
</html>__________________
__________________
buraya ne yazım önerirlerinizi pm atın
[Bu Linki Görüntüleyebilmeniz İçin Üye Olmanız Gerekiyor. ]
immortal isimli üyemiz çevrimdışıdır. (Offline)  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Alıntı ile Cevapla
Cevapla

Konu Seçenekleri

Yetkileriniz
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Açık
Smileler Açık
[IMG] Kodları Açık
HTML-KodlarıKapalı
Trackbacks are Açık
Pingbacks are Açık
Refbacks are Açık
Gitmek istediğiniz klasörü seçiniz


Şu an saat 14:47 .
Tarih 09-05-2008


Powered by vBulletin Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd
Türkçe Çeviri : ach

eXTReMe Tracker


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192