<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/*                       Köşe Yazıları v2.0                             */
/*                               By Rojhat Tolhildan                    */
/*                        Webmaster@Rojame.Org                          */
/*       http://www.rojame.org --- http://www.radyoserhildan.net        */
/************************************************************************/

defined('mxMainFileLoaded') or die('access denied');

if (!mxGetAdminPref('radminkoseyazilari')) {
    mxErrorScreen("Access Denied");
    die();
}

function kose_yazilari_get_lang($module) {
    global $currentlang, $language;
    if ($module == admin) {
                if (file_exists("admin/language/kose_yazilari/lang-$currentlang.php")) {
                        include_once("admin/language/kose_yazilari/lang-$currentlang.php");
                } else {
                        include_once("admin/language/kose_yazilari/lang-turkish.php");
                }
    }
}
kose_yazilari_get_lang(admin);

function koseyazimenu() {
    global $prefix, $db, $sitename;
       OpenTable();
       echo "<center><a href=\"admin.php?op=koseyazilari\"><font class='title'>"._KSYZYONETIM."</font></a>";
       echo "<br><br>";
       echo "<table border=\"0\" width=\"100%\" cellspacing=\"1\"><tr>"
            ."<td><center><a href=\"admin.php?op=yazaryonetim\">"._KYAZYONETIM."</a></td>"
            ."<td><center><a href=\"admin.php?op=koseyazarekle\">"._KYYAZAREKLE."</a></td>"
            ."<td><center><a href=\"admin.php?op=yaziekle\">"._KOSEYAZIEKLE."</a></td>"
            ."<td><center><a href=\"admin.php\">"._ADMINMENU."</a></td>";
       echo "</tr></table>";

    CloseTable();
 echo "<br>";


}

function koseyazilari() {
    global $language, $admin, $aid, $prefix, $db, $sitename;
	$result = $db->sql_query("select radminsuper from ".$prefix."_authors where aid='$aid'");
    list($radminsuper) = $db->sql_fetchrow($result);
    $radminsuper = intval($radminsuper);
    include("header.php");
koseyazimenu();
 echo "<br>";
    OpenTable();
    echo "<center><b>"._LAST." 10 "._STANDART."</b></center><br>";
    $result6 = $db->sql_query("SELECT sid, aid, title, time, topic, alanguage FROM ".$prefix."_kose_yazilari $queryalang ORDER BY time DESC LIMIT 0,10");
    echo "<center><table border=\"1\" width=\"100%\" bgcolor=\"$bgcolor1\">";
    while ($row6 = $db->sql_fetchrow($result6)) {
                $sid = intval($row6['sid']);
                $aid = $row6['aid'];
                $said = substr("$aid", 0,25);
                $title = $row6['title'];
                $time = $row6['time'];
                $topic = $row6['topic'];
                $informant = $row6['informant'];
                $alanguage = $row6['alanguage'];
                $row7 = $db->sql_fetchrow($db->sql_query("SELECT yazaradi FROM ".$prefix."_kose_yazarlari WHERE yazarno='$topic'"));
                $yazaradi = $row7['yazaradi'];
                if ($alanguage == "") {
                    $alanguage = ""._ALL."";
                }
                formatTimestamp($time);
                echo "<tr><td align=\"right\"><b>$sid</b>"
                    ."</td><td align=\"left\" width=\"100%\"><a href=\"modules.php?name=Kose_Yazilari&amp;file=yazi_oku&amp;sid=$sid\">$title</a>"
                    ."</td><td align=\"right\">$yazaradi";
                if (($aid == $said) OR ($radminsuper==1))  {
                    if (($aid == $said) OR ($radminsuper==1)) {
                                echo "</td><td align=\"right\" nowrap>(<a href=\"admin.php?op=yaziduzenle&amp;sid=$sid\">"._DUZENLE."</a>-<a href=\"admin.php?op=koseyazisil&amp;sid=$sid\">"._SIL."</a>)"
                                    ."</td></tr>";
                    } else {
                                echo "</td><td align=\"right\" nowrap><font class=\"content\"><i>("._KYKY.")</i></font>"
                                    ."</td></tr>";
                    }
                } else {
                    echo "</td></tr>";
                }
    }
    echo "</table>";
 if (($aid == $said) OR ($radminsuper==1))  {
        echo "<center>"
            ."<form action=\"admin.php\" method=\"post\">"
            .""._YAZINO.": <input type=\"text\" NAME=\"sid\" SIZE=\"10\">"
            ."<select name=\"op\">"
            ."<option value=\"yaziduzenle\" SELECTED>"._DUZENLE."</option>"
            ."<option value=\"koseyazisil\">"._SIL."</option>"
            ."</select>"
            ."<input type=\"submit\" value=\""._GO."\">"
            ."</form></center>";
    }
    CloseTable();

 include ("footer.php");
}
function yaziduzenle($sid) {
    global $user, $bgcolor1, $bgcolor2, $aid, $prefix, $db, $multilingual;
    $aid = substr("$aid", 0,25);
    $result = $db->sql_query("select radminsuper from ".$prefix."_authors where aid='$aid'");
    list($radminsuper) = $db->sql_fetchrow($result);
    $radminsuper = intval($radminsuper);
    $result2 = $db->sql_query("select aid from ".$prefix."_kose_yazilari where sid='$sid'");
    list($aaid) = $db->sql_fetchrow($result2);
    $aaid = substr("$aaid", 0,25);
    if (($aaid == $aid) OR ($radminsuper == 1)) {
        include ('header.php');
        koseyazimenu();
        echo "<br>";
        $result = $db->sql_query("SELECT catid, title, bodytext, topic, notes, alanguage FROM ".$prefix."_kose_yazilari where sid='$sid'");
        list($catid, $subject, $bodytext, $topic, $notes, $alanguage) = $db->sql_fetchrow($result);
        $catid = intval($catid);
        $subject = stripslashes($subject);
        $bodytext = stripslashes($bodytext);
        $notes = stripslashes($notes);
        $result2=$db->sql_query("select yazarresim from ".$prefix."_kose_yazarlari where yazarno='$topic'");
        list($yazarresim) = $db->sql_fetchrow($result2);
        OpenTable();
        echo "<center><font class=\"option\"><b>"._KOSEYAZIDUZENLE."</b></font></center><br>"
            ."<table width=\"80%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"$bgcolor2\" align=\"center\"><tr><td>"
            ."<table width=\"100%\" border=\"0\" cellpadding=\"8\" cellspacing=\"1\" bgcolor=\"$bgcolor1\"><tr><td>"
            ."<img src=\"images/kose_yazilari/$yazarresim\" border=\"0\" width=\"80\" align=\"right\">";
        themepreview($subject, $bodytext, $notes);
        echo "</td></tr></table></td></tr></table><br><br>"
            ."<form action=\"admin.php\" method=\"post\">"
            ."<b>"._BASLIK."</b><br>"
            ."<input type=\"text\" name=\"subject\" size=\"50\" value=\"$subject\"><br><br>"
            ."<b>"._YAZAR."</b> <select name=\"topic\">";
        $toplist = $db->sql_query("select yazarno, yazarmail from ".$prefix."_kose_yazarlari order by yazarmail");
        echo "<option value=\"\">"._TUMYAZARLAR."</option>\n";
        while(list($yazarno, $topics) = $db->sql_fetchrow($toplist)) {
            $yazarno = intval($yazarno);
                if ($yazarno==$topic) { $sel = "selected "; }
                echo "<option $sel value=\"$yazarno\">$topics</option>\n";
                $sel = "";
        }
        echo "</select>";
        echo "<br><br>";

        $cat = $catid;

        echo "<br>";
        if ($multilingual == 1) {
            echo "<br><b>"._DIL.":</b>"
                ."<select name=\"alanguage\">";
            $handle=opendir('language');
            while ($file = readdir($handle)) {
                if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
                        $langFound = $matches[1];
                        $languageslist .= "$langFound ";
                    }
            }
            closedir($handle);
            $languageslist = explode(" ", $languageslist);
            sort($languageslist);
            for ($i=0; $i < sizeof($languageslist); $i++) {
                if($languageslist[$i]!="") {
                    echo "<option name=\"alanguage\" value=\"$languageslist[$i]\" ";
                    if($languageslist[$i]==$alanguage) echo "selected";
                    echo ">".ucfirst($languageslist[$i])."\n</option>";
                }
            }
            if ($alanguage == "") {
                $sellang = "selected";
            } else {
                    $sellang = "";
            }
            echo "<option value=\"\" $sellang>"._ALL."</option></select>";
        } else {
            echo "<input type=\"hidden\" name=\"alanguage\" value=\"\">";
        }
        echo "<br><br><b></b><br>"

            ."<b>"._KOSEYAZIYAZIN."</b><br>"
            ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"10\" name=\"bodytext\">$bodytext</textarea><br>"
            ."<font class=\"content\">"._LINKEKLEDINIZMI."</font><br><br>"
            ."<b>"._NOTLAR."</b><br>"
            ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"4\" name=\"notes\">$notes</textarea><br><br>"
            ."<input type=\"hidden\" NAME=\"sid\" size=\"50\" value=\"$sid\">"
            ."<input type=\"hidden\" name=\"op\" value=\"yazidegistir\">"
            ."<input type=\"submit\" value=\""._SAVECHANGES."\">"
            ."</form>";
        CloseTable();
        include ('footer.php');
    } else {
        include ('header.php');
        OpenTable();
        echo "<center><font class=\"title\"><b>"._KSYZYONETIM."</b></font></center>";
        CloseTable();
        echo "<br>";
        OpenTable();
        echo "<center><b>"._YETKIYOK."</b><br><br>"
            .""._YETKIYOK2."<br><br>"
            .""._GOBACK."";
        CloseTable();
        include("footer.php");
    }
}

function yazidegistir($sid, $subject, $bodytext, $topic, $notes, $catid, $alanguage, $acomm, $assotop) {
    global $aid, $ultramode, $prefix, $db;
    for ($i=0; $i<sizeof($assotop); $i++) {
        $associated .= "$assotop[$i]-";
    }
    $sid = intval($sid);
    $aid = substr("$aid", 0,25);
    $result = $db->sql_query("select radminsuper from ".$prefix."_authors where aid='$aid'");
    list($radminsuper) = $db->sql_fetchrow($result);
    $radminsuper = intval($radminsuper);
    $result2 = $db->sql_query("select aid from ".$prefix."_kose_yazilari where sid='$sid'");
    list($aaid) = $db->sql_fetchrow($result2);
    $aaid = substr("$aaid", 0,25);
    if (($aaid == $aid) OR ($radminsuper == 1)) {
        $subject = stripslashes(FixQuotes($subject));
        $bodytext = stripslashes(FixQuotes($bodytext));
        $notes = stripslashes(FixQuotes($notes));
             $db->sql_query("update ".$prefix."_kose_yazilari set catid='$catid', title='$subject', bodytext='$bodytext', topic='$topic', notes='$notes', alanguage='$alanguage', acomm='$acomm', associated='$associated' where sid='$sid'");
        if ($ultramode) {
                ultramode();
        }
        Header("Location: admin.php?op=yazaryonetim");
    }
}


function yaziekle() {
    global $prefix, $db, $language, $multilingual;
    include ('header.php');
    koseyazimenu();
    echo "<br>";

    OpenTable();
    echo "<center><font class=\"option\"><b>"._KOSEYAZIEKLE."</b></font></center><br><br>"
            ."<form action=\"admin.php\" method=\"post\">"
        ."<b>"._BASLIK."</b><br>"
        ."<input type=\"text\" name=\"subject\" size=\"50\"><br><br>"
        ."<b>"._YAZAR."</b> ";
    $toplist = $db->sql_query("select yazarno, yazaradi from ".$prefix."_kose_yazarlari order by yazaradi");
    echo "<select name=\"topic\">";
    echo "<option value=\"\">"._YAZARSECIN."</option>\n";
    while(list($yazarno, $topics) = $db->sql_fetchrow($toplist)) {
            $yazarno = intval($yazarno);
        if ($yazarno == $topic) {
            $sel = "selected ";
        }
            echo "<option $sel value=\"$yazarno\">$topics</option>\n";
        $sel = "";
    }
    echo "</select><br><br>";
    $sql = "SELECT yazarno, yazarmail FROM ".$prefix."_kose_yazarlari ORDER BY yazarmail";
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        if ($a == 3) {
            echo "</tr><tr>";
            $a = 0;
        }
        $a++;
    }

    $cat = 0;
    if ($multilingual == 1) {
        echo "<br><b>"._LANGUAGE.": </b>"
            ."<select name=\"alanguage\">";
        $handle=opendir('language');
        while ($file = readdir($handle)) {
            if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
                $langFound = $matches[1];
                $languageslist .= "$langFound ";
            }
        }
        closedir($handle);
        $languageslist = explode(" ", $languageslist);
        sort($languageslist);
        for ($i=0; $i < sizeof($languageslist); $i++) {
            if($languageslist[$i]!="") {
                echo "<option value=\"$languageslist[$i]\" ";
                if($languageslist[$i]==$language) echo "selected";
                echo ">".ucfirst($languageslist[$i])."</option>\n";
            }
        }
        echo "<option value=\"\">"._ALL."</option></select>";
    } else {
        echo "<input type=\"hidden\" name=\"alanguage\" value=\"$language\">";
    }
    echo "<br><br><b>"._KOSEYAZIYAZIN."</b><br>"
        ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"12\" name=\"bodytext\"></textarea><br>"
        ."<font class=\"content\">"._LINKEKLEDINIZMI."</font>";

    echo "<br><br>"
        ."<select name=\"op\">"
        ."<option value=\"yazionizleme\" selected>"._ONIZLEME."</option>"
        ."<option value=\"yaziyigonder\">"._YOLLA."</option>"
        ."</select>"
        ."<input type=\"submit\" value=\""._OK."\">";
    CloseTable();
    echo "<br>";
    echo "</form>";
    include ('footer.php');
}

function yazionizleme($year, $day, $month, $hour, $min, $subject, $bodytext, $topic, $catid, $alanguage) {
    global $user, $bgcolor1, $bgcolor2, $prefix, $db, $alanguage, $multilingual;
    include ('header.php');
    if ($topic<1) {
        $topic = 1;
    }
    koseyazimenu();
    echo "<br>";

    OpenTable();
    echo "<center><font class=\"option\"><b>"._ONIZLEME."</b></font></center><br><br>"
        ."<form action=\"admin.php\" method=\"post\">"
        ."<input type=\"hidden\" name=\"catid\" value=\"$catid\">";
    $subject = stripslashes($subject);
    $subject = ereg_replace("\"", "''", $subject);
    $bodytext = stripslashes($bodytext);
    $result=$db->sql_query("select yazarresim from ".$prefix."_kose_yazarlari where yazarno='$topic'");
    list($yazarresim) = $db->sql_fetchrow($result);
    echo "<table border=\"0\" width=\"75%\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"$bgcolor2\" align=\"center\"><tr><td>"
        ."<table border=\"0\" width=\"100%\" cellpadding=\"8\" cellspacing=\"1\" bgcolor=\"$bgcolor1\"><tr><td>"
        ."<img src=\"images/kose_yazilari/$yazarresim\" border=\"0\" width=\"120\" align=\"right\" alt=\"\">";
    themepreview($subject, $bodytext);
    echo "</td></tr></table></td></tr></table>"
        ."<br><br><b>"._BASLIK."</b><br>"
        ."<input type=\"text\" name=\"subject\" size=\"50\" value=\"$subject\"><br><br>"
        ."<b>"._YAZAR."</b><select name=\"topic\">";
    $toplist = $db->sql_query("select yazarno, yazaradi from ".$prefix."_kose_yazarlari order by yazaradi");
    echo "<option value=\"\">"._TUMYAZARLAR."</option>\n";
    while(list($yazarno, $topics) = $db->sql_fetchrow($toplist)) {
            $yazarno = intval($yazarno);
        if ($yazarno==$topic) {
            $sel = "selected ";
        }
        echo "<option $sel value=\"$yazarno\">$topics</option>\n";
        $sel = "";
    }
    echo "</select><br><br>";

    $cat = $catid;
    echo "<br>";
    if ($multilingual == 1) {
        echo "<br><b>"._LANGUAGE.": </b>"
            ."<select name=\"alanguage\">";
        $handle=opendir('language');
        while ($file = readdir($handle)) {
            if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
                $langFound = $matches[1];
                $languageslist .= "$langFound ";
            }
        }
        closedir($handle);
        $languageslist = explode(" ", $languageslist);
        sort($languageslist);
        for ($i=0; $i < sizeof($languageslist); $i++) {
            if($languageslist[$i]!="") {
                echo "<option value=\"$languageslist[$i]\" ";
                if($languageslist[$i]==$alanguage) echo "selected";
                echo ">".ucfirst($languageslist[$i])."</option>\n";
            }
        }
        if ($alanguage == "") {
            $sellang = "selected";
        } else {
                $sellang = "";
        }
        echo "<option value=\"\" $sellang>"._ALL."</option></select>";
    } else {
        echo "<input type=\"hidden\" name=\"alanguage\" value=\"$language\">";
    }
    echo "<br><br><b>"._KOSEYAZIYAZIN."</b><br>"
        ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"12\" name=\"bodytext\">$bodytext</textarea><br><br>";
    echo "<br><br>"
        ."<select name=\"op\">"
        ."<option value=\"yazionizleme\" selected>"._ONIZLEME."</option>"
        ."<option value=\"yaziyigonder\">"._YOLLA."</option>"
        ."</select>"
        ."<input type=\"submit\" value=\""._OK."\">";
    CloseTable();
    echo "<br>";
    echo "</form>";
    include ('footer.php');
}

function yaziyigonder($automated, $year, $day, $month, $hour, $min, $subject, $bodytext, $topic, $catid, $alanguage) {
    global $ultramode, $aid, $prefix, $db;

        $subject = stripslashes(FixQuotes($subject));
        $bodytext = stripslashes(FixQuotes($bodytext));

        $result = $db->sql_query("insert into ".$prefix."_kose_yazilari values (NULL, '$topic', '$subject', '$bodytext', '0', '$alanguage', '$catid', '$aid', now(), '$aid', '$notes', '$acomm', '0', '0', '$associated', '0')");
        $result = $db->sql_query("select sid from ".$prefix."_kose_yazilari WHERE title='$subject' order by time DESC limit 0,1");
        list($artid) = $db->sql_fetchrow($result);
        $artid = intval($artid);
        $result = $db->sql_query("update ".$prefix."_authors set counter=counter+1 where aid='$aid'");
        if ($ultramode) {
            ultramode();
        }
        Header("Location: admin.php?op=yaziekle");
    }


function koseyazisil($sid, $ok=0) {
    global $ultramode, $aid, $prefix, $db;
    $aid = substr("$aid", 0,25);
    $result = $db->sql_query("select counter, radminsuper from ".$prefix."_authors where aid='$aid'");
    list($counter, $radminsuper) = $db->sql_fetchrow($result);
    $radminsuper = intval($radminsuper);
    $counter = intval($counter);
    $sid = intval($sid);
    $result2 = $db->sql_query("select aid from ".$prefix."_kose_yazilari where sid='$sid'");
    list($aaid) = $db->sql_fetchrow($result2);
    $aaid = substr("$aaid", 0,25);
    if (($aaid == $aid) OR ($radminsuper == 1)) {
        if($ok) {
            $counter--;
                $db->sql_query("DELETE FROM ".$prefix."_kose_yazilari where sid='$sid'");
            $db->sql_query("DELETE FROM ".$prefix."_kose_yazi_yorumlar where sid='$sid'");
            $result = $db->sql_query("update ".$prefix."_authors set counter='$counter' where aid='$aid'");
            if ($ultramode) {
                ultramode();
            }
            Header("Location: admin.php?op=koseyazilari");
        } else {
            include("header.php");
            koseyazimenu();
            echo "<br>";
            OpenTable();
            echo "<center> $sid "._KYYAZISIL."";
            echo "<br><br>[ <a href=\"admin.php\">"._NO."</a> | <a href=\"admin.php?op=koseyazisil&amp;sid=$sid&amp;ok=1\">"._YES."</a> ]</center>";
                CloseTable();
            include("footer.php");
        }
    } else {
        include ('header.php');
        koseyazimenu();
        echo "<br>";
        OpenTable();
        echo "<center><b>"._NOTAUTHORIZED1."</b><br><br>"
            .""._NOTAUTHORIZED2."<br><br>"
            .""._GOBACK."";
        CloseTable();
        include("footer.php");
    }
}

function kyazialtyorumsil($tid) {
    global $prefix, $db;
    $tid = intval($tid);
    $result = $db->sql_query("SELECT tid from " . $prefix . "_kose_yazi_yorumlar where pid='$tid'");
    $numrows = $db->sql_numrows($result);
    if($numrows>0) {
    while ($row = $db->sql_fetchrow($result)) {
        $stid = intval($row['tid']);
            kyazialtyorumsil($stid);
            $stid = intval($stid);
            $db->sql_query("delete from " . $prefix . "_kose_yazi_yorumlar where tid='$stid'");
        }
    }
    $db->sql_query("delete from " . $prefix . "_kose_yazi_yorumlar where tid='$tid'");
}

function kyaziyorumsil ($tid, $sid, $ok=0) {
    global $ultramode, $prefix, $db;
    if($ok) {
        $tid = intval($tid);
        $result = $db->sql_query("SELECT date from " . $prefix . "_kose_yazi_yorumlar where pid='$tid'");
        $numresults = $db->sql_numrows($result);
        $sid = intval($sid);
        $db->sql_query("update " . $prefix . "_kose_yazilari set comments=comments-1-'$numresults' where sid='$sid'");
    /* Call recursive delete function to delete the comment and all its childs */
        kyazialtyorumsil($tid);
        if ($ultramode) {
                ultramode();
        }
        Header("Location: modules.php?name=Kose_Yazilari&file=yazi_oku&sid=$sid");
    } else {
        include("header.php");
        koseyazimenu();
        OpenTable();
        echo "<center><font class=\"title\"><b>" . _KYYORUMSIL . "</b></font></center>";
        CloseTable();
        echo "<br>";
        OpenTable();
        echo "<center>" . _KYYORUMSILONAY . "";
        echo "<br><br>[ <a href=\"javascript:history.go(-1)\">" . _NO . "</a> | <a href=\"admin.php?op=kyaziyorumsil&tid=$tid&sid=$sid&ok=1\">" . _YES . "</a> ]</center>";
        CloseTable();
        include("footer.php");
    }
}


function yazaryonetim() {
    global $prefix, $db;
    include("header.php");
    koseyazimenu();
    echo "<br>";
    OpenTable();
    echo "<center><font class=\"option\"><b>"._KOSEYAZARLARI . "</b></font><br>"._YZDUZENLE . "</font></center><br>"
        ."<table border=\"0\" width=\"100%\" align=\"center\" cellpadding=\"2\">";
    $count = 0;
    $result = $db->sql_query("SELECT yazarno, yazaradi, yazarresim, yazarmail from " . $prefix . "_kose_yazarlari order by yazaradi");
    while ($row = $db->sql_fetchrow($result)) {
        $yazarno = intval($row['yazarno']);
        $yazaradi = $row['yazaradi'];
        $yazarresim = $row['yazarresim'];
        $yazarmail = $row['yazarmail'];
        echo "<td align=\"center\">"
            ."<a href=\"admin.php?op=yazarduzenle&amp;yazarno=$yazarno\"><img src=\"images/kose_yazilari/$yazarresim\" border=\"0\" width=\"120\" alt=\"\"></a><br>"
            ."<font class=\"content\"><b>$yazaradi</td>";
        $count++;
        if ($count == 5) {
            echo "</tr><tr>";
            $count = 0;
        }
    }
    echo "</table>";
    CloseTable();
    echo "<br><a name=\"Add\">";
    include("footer.php");
}

function koseyazarekle() {
    global $prefix, $db;
    include("header.php");

koseyazimenu();
    echo "<br>";
    echo "<br><a name=\"Add\">";
    OpenTable();
    echo "<center><font class=\"option\"><b>"._KYYAZAREKLE . "</b></font></center><br>"
            ."<form action=\"admin.php\" method=\"post\">"
        ."<b>"._YAZARADI . ":</b><br><font class=\"tiny\">"._YAZARADI1 . "<br>"
        ."</font>"
        ."<input type=\"text\" name=\"yazaradi\" size=\"20\" maxlength=\"20\" value=\"$yazaradi\"><br><br>"
        ."<b>"._YAZARMAIL . ":</b><br><font class=\"tiny\">"._YAZARMAIL1 . "<br>"
        ."</font>"
        ."<input type=\"text\" name=\"yazarmail\" size=\"40\" maxlength=\"40\" value=\"$yazarmail\"><br><br>"
        ."<b>"._YAZARRESIM . ":</b><br><font class=\"tiny\">"._YAZARRESIM1 . "<br></font>"
        ."<select name=\"yazarresim\">";
    $path1 = explode ("/", "images/kose_yazilari/");
    $path = "$path1[0]/$path1[1]";
    $handle=opendir($path);
    while ($file = readdir($handle)) {
        if ( (ereg("^([_0-9a-zA-Z]+)([.]{1})([_0-9a-zA-Z]{3})$",$file)) AND $file != "resimyok.gif") {
            $tlist .= "$file ";
        }
    }
    closedir($handle);
    $tlist = explode(" ", $tlist);
    sort($tlist);
    for ($i=0; $i < sizeof($tlist); $i++) {
        if($tlist[$i]!="") {
            echo "<option name=\"yazarresim\" value=\"$tlist[$i]\">$tlist[$i]\n";
        }
    }
    echo "</select><br><br>"
        ."<input type=\"hidden\" name=\"op\" value=\"yazarekle\">"
        ."<input type=\"submit\" value=\""._KYAZAREKLE . "\">"
        ."</form>";
    CloseTable();
    include("footer.php");
}





function yazarduzenle($yazarno) {
    global $prefix, $db;
    include("header.php");
   koseyazimenu();
    echo "<br>";
    OpenTable();
    $yazarno = intval($yazarno);
    $row = $db->sql_fetchrow($db->sql_query("SELECT yazarno, yazaradi, yazarresim, yazarmail from ".$prefix . "_kose_yazarlari where yazarno='$yazarno'"));
        $yazarno = intval($row['yazarno']);
        $yazaradi = $row['yazaradi'];
        $yazarresim = $row['yazarresim'];
        $yazarmail = $row['yazarmail'];
    echo "<img src=\"images/kose_yazilari/$yazarresim\" border=\"0\" width=\"120\" align=\"right\" alt=\"$yazaradi\">"
        ."<font class=\"option\"><b>"._YAZARDUZENLE . ": $yazaradi</b></font>"
        ."<br><br>"
        ."<form action=\"admin.php\" method=\"post\"><br>"
        ."<b>"._YAZARADI . ":</b><br><font class=\"tiny\">"._YAZARADI1 . "<br>"
        ."</font>"
        ."<input type=\"text\" name=\"yazaradi\" size=\"20\" maxlength=\"20\" value=\"$yazaradi\"><br><br>"
        ."<b>"._YAZARMAIL . ":</b><br><font class=\"tiny\">"._YAZARMAIL1 . "<br>"
        ."</font>"
        ."<input type=\"text\" name=\"yazarmail\" size=\"40\" maxlength=\"40\" value=\"$yazarmail\"><br><br>"
        ."<b>"._YAZARRESIM . ":</b><br><font class=\"tiny\">"._YAZARRESIM1 . "<br></font>"
        ."<select name=\"yazarresim\">";
    $path1 = explode ("/", "images/kose_yazilari/");
    $path = "$path1[0]/$path1[1]";
    $handle=opendir($path);
    while ($file = readdir($handle)) {
        if ( (ereg("^([_0-9a-zA-Z]+)([.]{1})([_0-9a-zA-Z]{3})$",$file)) AND $file != "resimyok.gif") {
            $tlist .= "$file ";
        }
    }
    closedir($handle);
    $tlist = explode(" ", $tlist);
    sort($tlist);
    for ($i=0; $i < sizeof($tlist); $i++) {
        if($tlist[$i]!="") {
            if ($yazarresim == $tlist[$i]) {
                $sel = "selected";
            } else {
                $sel = "";
            }
            echo "<option name=\"yazarresim\" value=\"$tlist[$i]\" $sel>$tlist[$i]\n";
        }
    }
    echo "</select><br><br>";

    echo "<br><br>"
        ."<input type=\"hidden\" name=\"yazarno\" value=\"$yazarno\">"
        ."<input type=\"hidden\" name=\"op\" value=\"yazardegistir\">"
        ."<INPUT type=\"submit\" value=\""._SAVECHANGES . "\"> <font class=\"content\">[ <a href=\"admin.php?op=yazarsil&amp;yazarno=$yazarno\">"._DELETE . "</a> ]</font>"
        ."</form>";
    CloseTable();
    include("footer.php");
}

function yazarekle($yazaradi, $yazarresim, $yazarmail) {
    global $prefix, $db;
    $yazaradi = stripslashes(FixQuotes($yazaradi));
    $yazarresim = stripslashes(FixQuotes($yazarresim));
    $yazarmail = stripslashes(FixQuotes($yazarmail));
    $db->sql_query("INSERT INTO ".$prefix . "_kose_yazarlari VALUES (NULL,'$yazaradi','$yazarresim','$yazarmail','0')");
    Header("Location: admin.php?op=yazaryonetim#Add");
}

function yazardegistir($yazarno, $yazaradi, $yazarresim, $yazarmail) {
    global $prefix, $db;
    $yazaradi = stripslashes(FixQuotes($yazaradi));
    $yazarresim = stripslashes(FixQuotes($yazarresim));
    $yazarmail = stripslashes(FixQuotes($yazarmail));
    $yazarno = intval($yazarno);
    $db->sql_query("update ".$prefix . "_kose_yazarlari set yazaradi='$yazaradi', yazarresim='$yazarresim', yazarmail='$yazarmail' where yazarno='$yazarno'");

    Header("Location: admin.php?op=yazarduzenle&yazarno=$yazarno");
}

function yazarsil($yazarno, $ok=0) {
    global $prefix, $db;
    $yazarno = intval($yazarno);
    if ($ok==1) {
    $row = $db->sql_fetchrow($db->sql_query("SELECT sid from " . $prefix . "_kose_yazilari where topic='$yazarno'"));
        $sid = intval($row['sid']);
        $db->sql_query("delete from " . $prefix . "_kose_yazilari where topic='$yazarno'");
        $db->sql_query("delete from " . $prefix . "_kose_yazarlari where yazarno='$yazarno'");

    $row2 = $db->sql_fetchrow($db->sql_query("SELECT sid from " . $prefix . "_kose_yazi_yorumlar where sid='$sid'"));
        $sid = intval($row2['sid']);
        $db->sql_query("delete from " . $prefix . "_kose_yazi_yorumlar where sid='$sid'");
        Header("Location: admin.php?op=yazaryonetim");
    } else {
        global $yazarresim;
        include("header.php");
        koseyazimenu();
        echo "<br>";
    $row3 = $db->sql_fetchrow($db->sql_query("SELECT yazarresim, yazaradi from " . $prefix . "_kose_yazarlari where yazarno='$yazarno'"));
        $yazarresim = $row3['yazarresim'];
        $yazaradi = $row3['yazaradi'];
        OpenTable();
        echo "<center><img src=\"images/kose_yazilari/$yazarresim\" border=\"0\" width=\"120\" alt=\"$yazarmail\"><br><br>"
            ."<b>" . _YAZARISIL . " $yazaradi</b><br><br>"
            ."" . _YAZARSILDIKKAT . " <i>$yazaradi</i><br>"
            ."" . _YAZARSILDIKKAT1 . "<br><br>"
            ."[ <a href=\"admin.php?op=yazaryonetim\">" . _NO . "</a> | <a href=\"admin.php?op=yazarsil&amp;yazarno=$yazarno&amp;ok=1\">" . _YES . "</a> ]</center><br><br>";
        CloseTable();
        include("footer.php");
    }
}


switch($op) {

    case "onizleme":
    yazionizle($year, $day, $month, $hour, $min, $qid, $uid, $author, $subject, $bodytext, $topic, $notes, $catid, $alanguage);
    break;

    case "yazigonder":
    yazigonder($year, $day, $month, $hour, $min, $qid, $uid, $author, $subject, $bodytext, $topic, $notes, $catid, $alanguage);
    break;

    case "yaziduzenle":
    yaziduzenle($sid);
    break;

    case "yazikaldir":
    yazikaldir($sid, $ok);
    break;

    case "yazidegistir":
    yazidegistir($sid, $subject, $bodytext, $topic, $notes, $catid);
    break;

    case "yaziekle":
    yaziekle($sid);
    break;

    case "yazionizleme":
    yazionizleme($year, $day, $month, $hour, $min, $subject, $bodytext, $topic, $catid, $alanguage);
    break;

    case "yaziyigonder":
    yaziyigonder($automated, $year, $day, $month, $hour, $min, $subject, $bodytext, $topic, $catid, $alanguage);
    break;

    case "yazaryonetim":
    yazaryonetim();
    break;

    case "koseyazarekle":
    koseyazarekle();
    break;

    case "yazarduzenle":
    yazarduzenle($yazarno);
    break;

    case "yazarekle":
    yazarekle($yazaradi, $yazarresim, $yazarmail);
    break;

    case "koseyazisil":
    koseyazisil($sid, $ok);
    break;

    case "kyaziyorumsil":
    kyaziyorumsil ($tid, $sid, $ok);
    break;

    case "kyazialtyorumsil":
    kyazialtyorumsil($tid);
    break;

    case "yazarsil":
    yazarsil($yazarno, $ok);
    break;

    case "yazardegistir":
    yazardegistir($yazarno, $yazaradi, $yazarresim, $yazarmail);
    break;

    case "koseyazilari":
    koseyazilari();
    break;

    case "koseyazimenu":
    koseyazimenu();
    break;

}



?>