| 1 |
<?php |
| 2 |
/** |
| 3 |
* File functions: |
| 4 |
* Show main news in game |
| 5 |
* |
| 6 |
* @name : updates.php |
| 7 |
* @copyright : (C) 2004,2005,2006 Vallheru Team based on Gamers-Fusion ver 2.5 |
| 8 |
* @author : thindil <thindil@users.sourceforge.net> |
| 9 |
* @author : mori <ziniquel@users.sourceforge.net> |
| 10 |
* @version : 1.0 |
| 11 |
* @since : 15.02.2006 |
| 12 |
* |
| 13 |
*/ |
| 14 |
|
| 15 |
// |
| 16 |
// |
| 17 |
// This program is free software; you can redistribute it and/or modify |
| 18 |
// it under the terms of the GNU General Public License as published by |
| 19 |
// the Free Software Foundation; either version 2 of the License, or |
| 20 |
// (at your option) any later version. |
| 21 |
// |
| 22 |
// This program is distributed in the hope that it will be useful, |
| 23 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 |
// GNU General Public License for more details. |
| 26 |
// |
| 27 |
// You should have received a copy of the GNU General Public License |
| 28 |
// along with this program; if not, write to the Free Software |
| 29 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 30 |
// |
| 31 |
// $Id: updates.php 566 2006-09-13 09:31:08Z thindil $ |
| 32 |
|
| 33 |
$title = "Wieści"; |
| 34 |
require_once("includes/head.php"); |
| 35 |
|
| 36 |
/** |
| 37 |
* Get the localization for game |
| 38 |
*/ |
| 39 |
require_once("languages/".$player -> lang."/updates.php"); |
| 40 |
|
| 41 |
/** |
| 42 |
* Informations for new players |
| 43 |
*/ |
| 44 |
if ($player -> logins < 5) |
| 45 |
{ |
| 46 |
$smarty -> assign("Newplayer", NEW_PLAYER); |
| 47 |
} |
| 48 |
else |
| 49 |
{ |
| 50 |
$smarty -> assign("Newplayer", ''); |
| 51 |
} |
| 52 |
|
| 53 |
if (!isset ($_GET['view'])) |
| 54 |
{ |
| 55 |
$upd = $db -> SelectLimit("SELECT * FROM updates WHERE lang='".$player -> lang."' ORDER BY id DESC", 1); |
| 56 |
if ($player -> rank == 'Admin') |
| 57 |
{ |
| 58 |
$modtext = "(<a href=\"addupdate.php?modify=".$upd -> fields['id']."\">".A_CHANGE."</a>)"; |
| 59 |
} |
| 60 |
else |
| 61 |
{ |
| 62 |
$modtext = ''; |
| 63 |
} |
| 64 |
if (isset($upd -> fields['id'])) |
| 65 |
{ |
| 66 |
$objQuery = $db -> Execute("SELECT id FROM upd_comments WHERE updateid=".$upd -> fields['id']); |
| 67 |
$intComments = $objQuery -> RecordCount(); |
| 68 |
$objQuery -> Close(); |
| 69 |
} |
| 70 |
else |
| 71 |
{ |
| 72 |
$intComments = 0; |
| 73 |
} |
| 74 |
$smarty -> assign(array("Title1" => $upd -> fields['title'], |
| 75 |
"Starter" => $upd -> fields['starter'], |
| 76 |
"Update" => $upd -> fields['updates'], |
| 77 |
"Modtext" => $modtext, |
| 78 |
"Date" => T_DAY.$upd -> fields['time'], |
| 79 |
"Alast10" => A_LAST10, |
| 80 |
"Comments" => $intComments, |
| 81 |
"Updid" => $upd -> fields['id'])); |
| 82 |
} |
| 83 |
|
| 84 |
if (isset($_GET['view'])) |
| 85 |
{ |
| 86 |
$upd = $db -> SelectLimit("SELECT * FROM updates WHERE lang='".$player -> lang."' ORDER BY id DESC", 10); |
| 87 |
$arrtitle = array(); |
| 88 |
$arrstarter = array(); |
| 89 |
$arrnews = array(); |
| 90 |
$arrmodtext = array(); |
| 91 |
$arrtimestamp = array(); |
| 92 |
$arrComments = array(); |
| 93 |
$arrUpdid = array(); |
| 94 |
$i = 0; |
| 95 |
while (!$upd -> EOF) |
| 96 |
{ |
| 97 |
if ($player -> rank == 'Admin') |
| 98 |
{ |
| 99 |
$arrmodtext[$i] = "(<a href=\"addupdate.php?modify=".$upd -> fields['id']."\">".A_CHANGE."</a>)"; |
| 100 |
} |
| 101 |
else |
| 102 |
{ |
| 103 |
$arrmodtext[$i] = ''; |
| 104 |
} |
| 105 |
$objQuery = $db -> Execute("SELECT id FROM upd_comments WHERE updateid=".$upd -> fields['id']); |
| 106 |
$arrComments[$i] = $objQuery -> RecordCount(); |
| 107 |
$objQuery -> Close(); |
| 108 |
$arrtitle[$i] = $upd -> fields['title']; |
| 109 |
$arrstarter[$i] = $upd -> fields['starter']; |
| 110 |
$arrnews[$i] = $upd -> fields['updates']; |
| 111 |
$arrUpdid[$i] = $upd -> fields['id']; |
| 112 |
if (isset($upd -> fields['time'])) |
| 113 |
{ |
| 114 |
$arrtimestamp[$i] = T_DAY.$upd -> fields['time']; |
| 115 |
} |
| 116 |
else |
| 117 |
{ |
| 118 |
$arrtimestamp[$i] = ''; |
| 119 |
} |
| 120 |
$upd -> MoveNext(); |
| 121 |
$i = $i + 1; |
| 122 |
} |
| 123 |
$upd -> Close(); |
| 124 |
$smarty -> assign(array("Title1" => $arrtitle, |
| 125 |
"Starter" => $arrstarter, |
| 126 |
"Update" => $arrnews, |
| 127 |
"Modtext" => $arrmodtext, |
| 128 |
"Date" => $arrtimestamp, |
| 129 |
"Comments" => $arrComments, |
| 130 |
"Updid" => $arrUpdid)); |
| 131 |
} |
| 132 |
|
| 133 |
/** |
| 134 |
* Comments to text |
| 135 |
*/ |
| 136 |
if (isset($_GET['step']) && $_GET['step'] == 'comments') |
| 137 |
{ |
| 138 |
$smarty -> assign("Amount", ''); |
| 139 |
|
| 140 |
require_once('includes/comments.php'); |
| 141 |
/** |
| 142 |
* Display comments |
| 143 |
*/ |
| 144 |
if (!isset($_GET['action'])) |
| 145 |
{ |
| 146 |
displaycomments($_GET['text'], 'updates', 'upd_comments', 'updateid'); |
| 147 |
$smarty -> assign(array("Tauthor" => $arrAuthor, |
| 148 |
"Tbody" => $arrBody, |
| 149 |
"Amount" => $i, |
| 150 |
"Cid" => $arrId, |
| 151 |
"Tdate" => $arrDate, |
| 152 |
"Nocomments" => NO_COMMENTS, |
| 153 |
"Addcomment" => ADD_COMMENT, |
| 154 |
"Adelete" => A_DELETE, |
| 155 |
"Aadd" => A_ADD, |
| 156 |
"Aback" => A_BACK, |
| 157 |
"Writed" => WRITED)); |
| 158 |
} |
| 159 |
|
| 160 |
/** |
| 161 |
* Add comment |
| 162 |
*/ |
| 163 |
if (isset($_GET['action']) && $_GET['action'] == 'add') |
| 164 |
{ |
| 165 |
addcomments($_POST['tid'], 'upd_comments', 'updateid'); |
| 166 |
} |
| 167 |
|
| 168 |
/** |
| 169 |
* Delete comment |
| 170 |
*/ |
| 171 |
if (isset($_GET['action']) && $_GET['action'] == 'delete') |
| 172 |
{ |
| 173 |
deletecomments('upd_comments'); |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
/** |
| 178 |
* Initialization of variables |
| 179 |
*/ |
| 180 |
if (!isset($_GET['view'])) |
| 181 |
{ |
| 182 |
$_GET['view'] = ''; |
| 183 |
} |
| 184 |
if (!isset($_GET['step'])) |
| 185 |
{ |
| 186 |
$_GET['step'] = ''; |
| 187 |
} |
| 188 |
if (!isset($_GET['text'])) |
| 189 |
{ |
| 190 |
$_GET['text'] = ''; |
| 191 |
} |
| 192 |
|
| 193 |
/** |
| 194 |
* Assign variables to template and display page |
| 195 |
*/ |
| 196 |
$smarty -> assign(array("View" => $_GET['view'], |
| 197 |
"Writeby" => WRITE_BY, |
| 198 |
"Step" => $_GET['step'], |
| 199 |
"Text" => $_GET['text'], |
| 200 |
"Rank" => $player -> rank, |
| 201 |
"Acomments" => A_COMMENTS)); |
| 202 |
$smarty -> display ('updates.tpl'); |
| 203 |
|
| 204 |
require_once("includes/foot.php"); |
| 205 |
?> |