| 1 |
<?php |
| 2 |
/** |
| 3 |
* File functions: |
| 4 |
* Add and modify game updates |
| 5 |
* |
| 6 |
* @name : addupdate.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.3 |
| 10 |
* @since : 19.10.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: addupdate.php 741 2006-10-19 12:14:28Z thindil $ |
| 31 |
|
| 32 |
$title = "Dodaj Wieść"; |
| 33 |
require_once("includes/head.php"); |
| 34 |
|
| 35 |
/** |
| 36 |
* Get the localization for game |
| 37 |
*/ |
| 38 |
require_once("languages/".$player -> lang."/addupdate.php"); |
| 39 |
|
| 40 |
if ($player -> rank != "Admin") |
| 41 |
{ |
| 42 |
error (NOT_HAVE); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Check avaible languages |
| 47 |
*/ |
| 48 |
$path = 'languages/'; |
| 49 |
$dir = opendir($path); |
| 50 |
$arrLanguage = array(); |
| 51 |
$i = 0; |
| 52 |
while ($file = readdir($dir)) |
| 53 |
{ |
| 54 |
if (!ereg(".htm*$", $file)) |
| 55 |
{ |
| 56 |
if (!ereg("\.$", $file)) |
| 57 |
{ |
| 58 |
$arrLanguage[$i] = $file; |
| 59 |
$i = $i + 1; |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
closedir($dir); |
| 64 |
|
| 65 |
$smarty -> assign ( array("Button" => U_ADD, |
| 66 |
"Link" => "addupdate.php?action=add", |
| 67 |
"Title1" => '', |
| 68 |
"Text" => '', |
| 69 |
"Ulangsel" => U_LANG_S, |
| 70 |
"Ulang" => $arrLanguage, |
| 71 |
"Utitle" => U_TITLE, |
| 72 |
"Utext" => U_TEXT)); |
| 73 |
|
| 74 |
/** |
| 75 |
* Add new update |
| 76 |
*/ |
| 77 |
if (isset ($_GET['action']) && $_GET['action'] == 'add') |
| 78 |
{ |
| 79 |
if (empty($_POST['addtitle']) || empty($_POST['addupdate'])) |
| 80 |
{ |
| 81 |
error (EMPTY_FIELDS); |
| 82 |
} |
| 83 |
$_POST['addupdate'] = nl2br($_POST['addupdate']); |
| 84 |
$strTitle = $db -> qstr($_POST['addtitle'], get_magic_quotes_gpc()); |
| 85 |
$strUpdate = $db -> qstr($_POST['addupdate'], get_magic_quotes_gpc()); |
| 86 |
$strDate = $db -> DBDate($data); |
| 87 |
$db -> Execute("INSERT INTO `updates` (`starter`, `title`, `updates`, `time`, `lang`) VALUES('(".$player -> user.")', ".$strTitle.", ".$strUpdate.", ".$strDate.", '".$_POST['addlang']."')") or error(E_DB); |
| 88 |
error (U_SUCCES); |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* Update modyfication |
| 93 |
*/ |
| 94 |
if (isset ($_GET['modify'])) |
| 95 |
{ |
| 96 |
if (!ereg("^[1-9][0-9]*$", $_GET['modify'])) { |
| 97 |
error (ERROR); |
| 98 |
} |
| 99 |
$update = $db -> Execute("SELECT * FROM updates WHERE id=".$_GET['modify']); |
| 100 |
$update -> fields['updates'] = str_replace("<br />", "", $update -> fields['updates']); |
| 101 |
$smarty -> assign(array("Title1" => $update -> fields['title'], |
| 102 |
"Text" => $update -> fields['updates'], |
| 103 |
"Button" => U_MODIFY, |
| 104 |
"Link" => "addupdate.php?action=modify&updid=".$update -> fields['id'])); |
| 105 |
$update -> Close(); |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* Save update modifications |
| 110 |
*/ |
| 111 |
if (isset ($_GET['action']) && $_GET['action'] == 'modify') |
| 112 |
{ |
| 113 |
if (empty($_POST['addtitle']) || empty($_POST['addupdate'])) |
| 114 |
{ |
| 115 |
error (EMPTY_FIELDS); |
| 116 |
} |
| 117 |
if (!ereg("^[1-9][0-9]*$", $_GET['updid'])) |
| 118 |
{ |
| 119 |
error (ERROR); |
| 120 |
} |
| 121 |
$uid = $db -> Execute("SELECT `id`, `lang` FROM `updates` WHERE `id`=".$_GET['updid']); |
| 122 |
if ($uid -> fields['id']) |
| 123 |
{ |
| 124 |
require_once("languages/".$uid -> fields['lang']."/addupdate1.php"); |
| 125 |
$_POST['addupdate'] = $_POST['addupdate']."\n \n ".MODIFY_DATE." ".$data." ".MODIFY_BY." <b>".$player -> user."</b>"; |
| 126 |
$_POST['addupdate'] = nl2br($_POST['addupdate']); |
| 127 |
$strTitle = $db -> qstr($_POST['addtitle'], get_magic_quotes_gpc()); |
| 128 |
$strUpdate = $db -> qstr($_POST['addupdate'], get_magic_quotes_gpc()); |
| 129 |
$db -> Execute("UPDATE `updates` SET `title`=".$strTitle.", `updates`=".$strUpdate." WHERE `id`=".$_GET['updid']); |
| 130 |
error (U_MODIFIED); |
| 131 |
} |
| 132 |
else |
| 133 |
{ |
| 134 |
error (NO_UPD); |
| 135 |
} |
| 136 |
$uid -> Close(); |
| 137 |
} |
| 138 |
|
| 139 |
$smarty -> display('addupdate.tpl'); |
| 140 |
|
| 141 |
require_once("includes/foot.php"); |
| 142 |
?> |