Advertisement
Guest User

Untitled

a guest
Jun 4th, 2017
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.20 KB | None | 0 0
  1. <?php
  2. /**
  3. * File functions:
  4. * Register new players
  5. *
  6. * @name : register.php
  7. * @copyright : (C) 2005,2006 Vallheru Team based on Gamers-Fusion ver 2.5
  8. * @author : thindil <thindil@users.sourceforge.net>
  9. * @version : 1.2
  10. * @since : 14.07.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: register.php 479 2006-07-14 18:57:16Z thindil $
  31.  
  32. require 'libs/Smarty.class.php';
  33. require_once ('includes/config.php');
  34.  
  35. $smarty = new Smarty;
  36. $smarty -> compile_check = true;
  37.  
  38. /**
  39. * Check avaible languages
  40. */
  41. $path = 'languages/';
  42. $dir = opendir($path);
  43. $arrLanguage = array();
  44. $i = 0;
  45. while ($file = readdir($dir))
  46. {
  47. if (!ereg(".htm*$", $file))
  48. {
  49. if (!ereg("\.$", $file))
  50. {
  51. $arrLanguage[$i] = $file;
  52. $i = $i + 1;
  53. }
  54. }
  55. }
  56. closedir($dir);
  57.  
  58. /**
  59. * Get the localization for game
  60. */
  61. $strLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  62. foreach ($arrLanguage as $strTrans)
  63. {
  64. $strSearch = "^".$strTrans;
  65. if (eregi($strSearch, $strLanguage))
  66. {
  67. $strTranslation = $strTrans;
  68. break;
  69. }
  70. }
  71. if (!isset($strTranslation))
  72. {
  73. $strTranslation = 'pl';
  74. }
  75. if (isset($_GET['lang']))
  76. {
  77. if (in_array($_GET['lang'], $arrLanguage))
  78. {
  79. $strTranslation = $_GET['lang'];
  80. }
  81. }
  82. require_once("languages/".$strTranslation."/register.php");
  83.  
  84. $objOpenreg = $db -> Execute("SELECT value FROM settings WHERE setting='register'");
  85. /**
  86. * When registration is closed
  87. */
  88. if ($objOpenreg -> fields['value'] == 'N')
  89. {
  90. $objReason = $db -> Execute("SELECT value FROM settings WHERE setting='close_register'");
  91. $smarty -> assign ("Error", REASON.":<br />".$objReason -> fields['value']);
  92. $objReason -> Close();
  93. $smarty -> display ('error.tpl');
  94. exit;
  95. }
  96. $objOpenreg -> Close();
  97.  
  98. $query = $db -> Execute("SELECT id FROM nau");
  99. $nump = $query -> RecordCount();
  100. $query -> Close();
  101.  
  102. $time = date("H:i:s");
  103. $hour = explode(":", $time);
  104. $newhour = $hour[0] + 0;
  105. if ($newhour > 23)
  106. {
  107. $newhour = $newhour - 24;
  108. }
  109. $arrtime = array($newhour, $hour[1], $hour[2]);
  110. $newtime = implode(":",$arrtime);
  111.  
  112. $span = (time() - 180);
  113. $objQuery = $db -> Execute("SELECT id FROM nau WHERE lpv>=".$span);
  114. $intNumo = $objQuery -> RecordCount();
  115. $objQuery -> Close();
  116.  
  117. $smarty -> assign(array("Gamename" => $gamename,
  118. "Meta" => '',
  119. "Welcome" => WELCOME,
  120. "Register" => REGISTER,
  121. "Rules" => RULES,
  122. "Links" => LINKS,
  123. "Forums" => FORUMS,
  124. "Time" => $newtime,
  125. "Players" => $nump,
  126. "Online" => $intNumo,
  127. "Email" => EMAIL,
  128. "Password" => PASSWORD,
  129. "Login" => LOGIN,
  130. "Lostpasswd" => LOST_PASSWORD,
  131. "Ctime" => CURRENT_TIME,
  132. "Whave" => WE_HAVE,
  133. "Registered" => REGISTERED,
  134. "Ingame" => IN_GAME,
  135. "Charset" => CHARSET,
  136. "Pagetitle" => REGISTER));
  137.  
  138. if (isset($_GET['ref']))
  139. {
  140. $smarty -> assign("Referal",$_GET['ref']);
  141. }
  142. else
  143. {
  144. $smarty -> assign("Referal","");
  145. }
  146.  
  147. if (!isset($_GET['action']))
  148. {
  149. $smarty -> assign(array("Description" => DESCRIPTION,
  150. "Nick" => NICK,
  151. "Confemail" => CONF_EMAIL,
  152. "Referralid" => REFERRAL_ID,
  153. "Ifnoid" => IF_NO_ID,
  154. "Register" => REGISTER,
  155. "Tlang" => T_LANG,
  156. "Lang" => $arrLanguage,
  157. "Shortrules" => SHORT_RULES,
  158. "Rule1" => RULE1,
  159. "Rule2" => RULE2,
  160. "Rule3" => RULE3,
  161. "Rule4" => RULE4,
  162. "Rule5" => RULE5,
  163. "Rule6" => RULE6,
  164. "Rule7" => RULE7,
  165. "Rule8" => RULE8,
  166. "Description2" => DESCRIPTION2));
  167. }
  168.  
  169. if (isset ($_GET['action']) && $_GET['action'] == 'register')
  170. {
  171. /**
  172. * Check for empty fields
  173. */
  174. if (!$_POST['user'] || !$_POST['email'] || !$_POST['vemail'] || !$_POST['pass'] || !$_POST['przedmiot'])
  175. {
  176. $smarty -> assign ("Error", EMPTY_FIELDS);
  177. $smarty -> display ('error.tpl');
  178. exit;
  179. }
  180.  
  181. /**
  182. * Email adress validation
  183. */ require_once('includes/verifymail.php');
  184. if (MailVal($_POST['email'], 2))
  185. {
  186. $smarty -> assign ("Error", BAD_EMAIL);
  187. $smarty -> display ('error.tpl');
  188. exit;
  189. }
  190.  
  191. require_once('includes/verifypass.php');
  192. verifypass($_POST['pass'],'register');
  193.  
  194. /**
  195. * Check nick
  196. */
  197. $strUser = $db -> qstr($_POST['user'], get_magic_quotes_gpc());
  198. $query = $db -> Execute("SELECT id FROM nau WHERE user=".$strUser);
  199. $dupe1 = $query -> RecordCount();
  200. $query -> Close();
  201. if ($dupe1 > 0)
  202. {
  203. $smarty -> assign ("Error", BAD_NICK);
  204. $smarty -> display ('error.tpl');
  205. exit;
  206. }
  207.  
  208. /**
  209. * Check mail adress in database
  210. */
  211. $strEmail = $db -> qstr($_POST['email'], get_magic_quotes_gpc());
  212. $query = $db -> Execute("SELECT id FROM nau WHERE email=".$strEmail);
  213. $dupe2 = $query -> RecordCount();
  214. $query -> Close();
  215. if ($dupe2 > 0)
  216. {
  217. $smarty -> assign ("Error", EMAIL_HAVE);
  218. $smarty -> display ('error.tpl');
  219. exit;
  220. }
  221.  
  222. /**
  223. * Check email adress writed on registration
  224. */
  225. if ($_POST['email'] != $_POST['vemail'])
  226. {
  227. $smarty -> assign ("Error", EMAIL_MISS);
  228. $smarty -> display ('error.tpl');
  229. exit;
  230. }
  231.  
  232. if (!$_POST['ref'])
  233. {
  234. $_POST['ref'] = 0;
  235. }
  236.  
  237. $_POST['lang'] = strip_tags($_POST['lang']);
  238. if (!in_array($_POST['lang'], $arrLanguage))
  239. {
  240. exit;
  241. }
  242. $ref = intval($_POST['ref']);
  243. $_POST['user'] = strip_tags($_POST['user']);
  244. $strUser = $db -> qstr($_POST['user'], get_magic_quotes_gpc());
  245. $_POST['email'] = strip_tags($_POST['email']);
  246. $strEmail = $db -> qstr($_POST['email'], get_magic_quotes_gpc());
  247. $_POST['przedmiot'] = strip_tags($_POST['przedmiot']);
  248. $strEmail = $db -> qstr($_POST['przedmiot'], get_magic_quotes_gpc());
  249. $_POST['pass'] = strip_tags($_POST['pass']);
  250. $aktw = rand(1,10000000);
  251. $data = date("y-m-d");
  252. $strDate = $db -> DBDate($data);
  253. $ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
  254. $message = WELCOME_TO." ".$gamename.YOUR_LINK." ".$gameadress.ACTIV_LINK.$aktw.NICE_PLAYING." ".$gamename.". ".$adminname;
  255. $adress = $_POST['email'];
  256. $subject = SUBJECT." ".$gamename;
  257. require_once('mailer/mailerconfig.php');
  258. if (!$mail -> Send())
  259. {
  260. $smarty -> assign("Error", EMAIL_ERROR.$mail -> ErrorInfo);
  261. $smarty -> display('error.tpl');
  262. exit;
  263. }
  264. $strPass = MD5($_POST['pass']);
  265. $db -> Execute("INSERT INTO nau (user, email, pass, przedmiot, ip, lang) VALUES(".$strUser.", ".$strEmail.", '".MD5($_POST['pass'])."', ".$strprzedmiot.", '".$HTTP_SERVER_VARS['REMOTE_ADDR']."' ,'".$_POST['lang']."')") or die($db -> ErrorMsg());
  266. $smarty -> assign("Registersuccess", REGISTER_SUCCESS);
  267. }
  268.  
  269. /**
  270. * Initialization of variable
  271. */
  272. if (!isset($_GET['action']))
  273. {
  274. $_GET['action'] = '';
  275. }
  276.  
  277. /**
  278. * Assign variables and display page
  279. */
  280. $smarty -> assign(array("Action" => $_GET['action'], "Meta" => ''));
  281. $smarty -> display('rejestracja.tpl');
  282.  
  283. $db -> Close();
  284. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement