1
<?php
2
/**
3
 *   File functions:
4
 *   Player notes
5
 *
6
 *   @name                 : notatnik.php                            
7
 *   @copyright            : (C) 2004,2005,2006 Vallheru Team based on Gamers-Fusion ver 2.5
8
 *   @author               : thindil <thindil@users.sourceforge.net>
9
 *   @version              : 1.2
10
 *   @since                : 11.09.2006
11
 *
12
 */
13
14
//
15
//
16
//       This program is free software; you can redistribute it and/or modify
17
//   it under the terms of the GNU General Public License as published by
18
//   the Free Software Foundation; either version 2 of the License, or
19
//   (at your option) any later version.
20
//
21
//   This program is distributed in the hope that it will be useful,
22
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
23
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
//   GNU General Public License for more details.
25
//
26
//   You should have received a copy of the GNU General Public License
27
//   along with this program; if not, write to the Free Software
28
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29
//
30
// $Id: notatnik.php 566 2006-09-13 09:31:08Z thindil $
31
32
$title = "Notatnik";
33
require_once("includes/head.php");
34
35
/**
36
* Get the localization for game
37
*/
38
require_once("languages/".$player -> lang."/notatnik.php");
39
40
$log = $db -> SelectLimit("SELECT `id`, `tekst`, `czas` FROM `notatnik` WHERE `gracz`=".$player -> id." ORDER BY `id` DESC", 25);
41
$arrtime = array();
42
$arrtext = array();
43
$arrid = array();
44
$i = 0;
45
while (!$log -> EOF) 
46
{
47
    $arrtime[$i] = $log -> fields['czas'];
48
    $arrtext[$i] = $log -> fields['tekst'];
49
    $arrid[$i] = $log -> fields['id'];
50
    $log -> MoveNext();
51
    $i = $i + 1;
52
}
53
$log -> Close();
54
$smarty -> assign(array("Notetime" => $arrtime, 
55
                        "Notetext" => $arrtext, 
56
                        "Noteid" => $arrid,
57
                        "Notesinfo" => NOTES_INFO,
58
                        "Ntime" => N_TIME,
59
                        "Adelete" => A_DELETE,
60
                        "Aadd" => A_ADD,
61
                        "Aedit" => A_EDIT));
62
/**
63
 * Delete post
64
 */
65
if (isset ($_GET['akcja']) && $_GET['akcja'] == 'skasuj') 
66
{
67
    if (!ereg("^[1-9][0-9]*$", $_GET['nid'])) 
68
    {
69
        error (ERROR);
70
    }
71
    $did = $db -> Execute("SELECT `id`, `gracz` FROM `notatnik` WHERE `id`=".$_GET['nid']);
72
    if (!$did -> fields['id']) 
73
    {
74
        error (NO_TEXT);
75
    }
76
    if ($player -> id != $did -> fields['gracz']) 
77
    {
78
        error (NOT_YOUR);
79
    }
80
    $db -> Execute("DELETE FROM `notatnik` WHERE `gracz`=".$player -> id." AND `id`=".$_GET['nid']);
81
    error (YOU_DELETE);
82
}
83
84
/**
85
 * Add post
86
 */
87
if (isset ($_GET['akcja']) && $_GET['akcja'] == 'dodaj') 
88
{
89
    $smarty -> assign(array("Note" => NOTE,
90
                            "Asave" => A_SAVE,
91
                            "Nlink" => "dodaj&amp;step=send",
92
                            "Ntext" => ''));
93
    if (isset ($_GET['step']) && $_GET['step'] == 'send') 
94
    {
95
        if (empty ($_POST['body'])) 
96
        {
97
            error (EMPTY_FIELD);
98
        }
99
        require_once('includes/bbcode.php');
100
        $_POST['body'] = bbcodetohtml($_POST['body']);
101
        $strBody = $db -> qstr($_POST['body'], get_magic_quotes_gpc());
102
        $strDate = $db -> DBDate($newdate);
103
        $db -> Execute("INSERT INTO `notatnik` (`gracz`, `tekst`, `czas`) VALUES(".$player -> id.", ".$strBody.", ".$strDate.")");
104
        error (YOU_ADD);
105
    }
106
}
107
108
/**
109
 * Edit post
110
 */
111
if (isset($_GET['akcja']) && $_GET['akcja'] == 'edit')
112
{
113
    if (!ereg("^[1-9][0-9]*$", $_GET['nid'])) 
114
    {
115
        error(ERROR);
116
    }
117
    $objText = $db -> Execute("SELECT `id`, `gracz`, `tekst` FROM `notatnik` WHERE `id`=".$_GET['nid']);
118
    if (!$objText -> fields['id']) 
119
    {
120
        error(NO_TEXT);
121
    }
122
    if ($player -> id != $objText -> fields['gracz']) 
123
    {
124
        error(NOT_YOUR);
125
    }
126
    require_once('includes/bbcode.php');
127
    $strNbody = htmltobbcode($objText -> fields['tekst']);
128
    $smarty -> assign(array("Note" => NOTE,
129
                            "Asave" => A_SAVE,
130
                            "Ntext" => $strNbody,
131
                            "Nlink" => "edit&amp;nid=".$_GET['nid']."&amp;step=edit"));
132
    $objText -> Close();
133
    if (isset($_GET['step']) && $_GET['step'] == 'edit') 
134
    {
135
        if (empty ($_POST['body'])) 
136
        {
137
            error(EMPTY_FIELD);
138
        }
139
        require_once('includes/bbcode.php');
140
        $_POST['body'] = bbcodetohtml($_POST['body']);
141
        $strBody = $db -> qstr($_POST['body'], get_magic_quotes_gpc());
142
        $strDate = $db -> DBDate($newdate);
143
        $db -> Execute("UPDATE `notatnik` SET `tekst`=".$strBody.", `czas`=".$strDate." WHERE `id`=".$_GET['nid']);
144
        error(YOU_EDIT);
145
    }
146
}
147
148
/**
149
* Initialization of variable
150
*/
151
if (!isset($_GET['akcja'])) 
152
{
153
    $_GET['akcja'] = '';
154
}
155
156
/**
157
* Assign variable to template and display page
158
*/
159
$smarty -> assign("Action", $_GET['akcja']);
160
$smarty -> display ('notatnik.tpl');
161
162
require_once("includes/foot.php");
163
?>