Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.56 KB | None | 0 0
  1. <?php
  2. if(!defined('INITIALIZED'))
  3. exit;
  4.  
  5. // DEFINE VARIABLES FOR SCRIPTS AND LAYOUTS (no more notices 'undefinied variable'!)
  6. if(!isset($_REQUEST['subtopic']) || empty($_REQUEST['subtopic']) || is_array($_REQUEST['subtopic']))
  7. {
  8. $_REQUEST['subtopic'] = "latestnews";
  9. }
  10. else
  11. $_REQUEST['subtopic'] = (string) $_REQUEST['subtopic'];
  12.  
  13. if(Functions::isValidFolderName($_REQUEST['subtopic']))
  14. {
  15. if(Website::fileExists("pages/" . $_REQUEST['subtopic'] . ".php"))
  16. {
  17. $subtopic = $_REQUEST['subtopic'];
  18. }
  19. else
  20. exit('access forbidden');
  21. }
  22. else
  23. exit('access forbidden');
  24.  
  25. // action that page should execute
  26. if(isset($_REQUEST['action']))
  27. $action = (string) $_REQUEST['action'];
  28. else
  29. $action = '';
  30.  
  31. $logged = false;
  32. $account_logged = new Account();
  33. $group_id_of_acc_logged = 0;
  34. // with ONLY_PAGE option we want disable useless SQL queries
  35. if(!ONLY_PAGE)
  36. {
  37. // logged boolean value: true/false
  38. $logged = Visitor::isLogged();
  39. // Account object with account of logged player or empty Account
  40. $account_logged = Visitor::getAccount();
  41. // group of acc. logged
  42. if(Visitor::isLogged())
  43. $group_id_of_acc_logged = Visitor::getAccount()->getPageAccess();
  44. }
  45. $layout_name = './layouts/' . Website::getWebsiteConfig()->getValue('layout');
  46.  
  47. $title = ucwords($subtopic) . ' - ' . Website::getServerConfig()->getValue('serverName');
  48.  
  49. $topic = $subtopic;
  50.  
  51. $passwordency = Website::getServerConfig()->getValue('encryptionType');
  52. if($passwordency == 'plain')
  53. $passwordency = '';
  54.  
  55. $news_content = '';
  56. $vocation_name = array();
  57. foreach(Website::getVocations() as $vocation)
  58. {
  59. $vocation_name[$vocation->getPromotion()][$vocation->getBaseId()] = $vocation->getName();
  60. }
  61.  
  62. $layout_ini = parse_ini_file($layout_name.'/layout_config.ini');
  63. foreach($layout_ini as $key => $value)
  64. $config['site'][$key] = $value;
  65.  
  66. //###################### FUNCTIONS ######################
  67. function microtime_float()
  68. {
  69. return microtime(true);
  70. }
  71.  
  72. function isPremium($premdays, $lastday)
  73. {
  74. return Functions::isPremium($premdays, $lastday);
  75. }
  76.  
  77. function saveconfig_ini($config)
  78. {
  79. new Error_Critic('', 'function <i>saveconfig_ini</i> is deprecated. Do not use it.');
  80. }
  81.  
  82. function password_ency($password, $account = null)
  83. {
  84. new Error_Critic('', 'function <i>password_ency</i> is deprecated. Do not use it.');
  85. }
  86.  
  87. function check_name($name)
  88. {
  89. $name = (string) $name;
  90. $temp = strspn("$name", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- [ ] '");
  91. if($temp != strlen($name))
  92. return false;
  93. if(strlen($name) > 25)
  94. return false;
  95.  
  96. return true;
  97. }
  98.  
  99. function check_account_name($name)
  100. {
  101. $name = (string) $name;
  102. $temp = strspn("$name", "QWERTYUIOPASDFGHJKLZXCVBNM0123456789");
  103. if ($temp != strlen($name))
  104. return false;
  105. if(strlen($name) < 1)
  106. return false;
  107. if(strlen($name) > 32)
  108. return false;
  109.  
  110. return true;
  111. }
  112.  
  113. function check_name_new_char($name)
  114. {
  115. $name = (string) $name;
  116. $name_to_check = strtolower($name);
  117. //first word can't be:
  118. $first_words_blocked = array('gm ','cm ', 'god ','tutor ', "'", '-');
  119. //names blocked:
  120. $names_blocked = array('gm','cm', 'god', 'tutor');
  121. //name can't contain:
  122. $words_blocked = array('gamemaster', 'game master', 'game-master', "game'master", '--', "''","' ", " '", '- ', ' -', "-'", "'-", 'fuck', 'sux', 'suck', 'noob', 'tutor');
  123. foreach($first_words_blocked as $word)
  124. if($word == substr($name_to_check, 0, strlen($word)))
  125. return false;
  126. if(substr($name_to_check, -1) == "'" || substr($name_to_check, -1) == "-")
  127. return false;
  128. if(substr($name_to_check, 1, 1) == ' ')
  129. return false;
  130. if(substr($name_to_check, -2, 1) == " ")
  131. return false;
  132. foreach($names_blocked as $word)
  133. if($word == $name_to_check)
  134. return false;
  135. for($i = 0; $i < strlen($name_to_check); $i++)
  136. if($name_to_check[$i-1] == ' ' && $name_to_check[$i+1] == ' ')
  137. return false;
  138. foreach($words_blocked as $word)
  139. if (!(strpos($name_to_check, $word) === false))
  140. return false;
  141. for($i = 0; $i < strlen($name_to_check); $i++)
  142. if($name_to_check[$i] == $name_to_check[($i+1)] && $name_to_check[$i] == $name_to_check[($i+2)])
  143. return false;
  144. for($i = 0; $i < strlen($name_to_check); $i++)
  145. if($name_to_check[$i-1] == ' ' && $name_to_check[$i+1] == ' ')
  146. return false;
  147. $temp = strspn("$name", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- '");
  148. if ($temp != strlen($name))
  149. return false;
  150. if(strlen($name) < 1)
  151. return false;
  152. if(strlen($name) > 25)
  153. return false;
  154.  
  155. return true;
  156. }
  157.  
  158. function check_rank_name($name)
  159. {
  160. $name = (string) $name;
  161. $temp = strspn("$name", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789-[ ] ");
  162. if($temp != strlen($name))
  163. return false;
  164. if(strlen($name) < 1)
  165. return false;
  166. if(strlen($name) > 60)
  167. return false;
  168.  
  169. return true;
  170. }
  171.  
  172. function check_guild_name($name)
  173. {
  174. $name = (string) $name;
  175. $words_blocked = array('--', "''","' ", " '", '- ', ' -', "-'", "'-", ' ');
  176. $temp = strspn("$name", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789-' ");
  177. if($temp != strlen($name))
  178. return false;
  179. if(strlen($name) < 1)
  180. return false;
  181. if(strlen($name) > 60)
  182. return false;
  183.  
  184. foreach($words_blocked as $word)
  185. if (!(strpos($name, $word) === false))
  186. return false;
  187.  
  188. return true;
  189. }
  190.  
  191. function check_password($pass)
  192. {
  193. $pass = (string) $pass;
  194. $temp = strspn("$pass", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890");
  195. if($temp != strlen($pass))
  196. return false;
  197. if(strlen($pass) > 40)
  198. return false;
  199.  
  200. return true;
  201. }
  202.  
  203. function check_mail($email)
  204. {
  205. $email = (string) $email;
  206. $ok = "/[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}/";
  207. return (preg_match($ok, $email))? true: false;
  208. }
  209.  
  210. function items_on_player($characterid, $pid)
  211. {
  212. new Error_Critic('', 'function <i>items_on_player</i> is deprecated. Do not use it. It used too many queries!');
  213. }
  214.  
  215. function getReason($reasonId)
  216. {
  217. return Functions::getBanReasonName($reasonId);
  218. }
  219.  
  220. //################### DISPLAY FUNCTIONS #####################
  221. //return shorter text (news ticker)
  222. function short_text($text, $chars_limit)
  223. {
  224. if(strlen($text) > $chars_limit)
  225. return substr($text, 0, strrpos(substr($text, 0, $chars_limit), " ")).'...';
  226. else
  227. return $text;
  228. }
  229. //return text to news msg
  230. function news_place()
  231. {
  232. return '';
  233. }
  234. //set monster of week
  235. function logo_monster()
  236. {
  237. new Error_Critic('', 'function <i>logo_monster</i> is deprecated. Do not use it!');
  238. }
  239.  
  240. // we don't want to count AJAX scripts/guild images as page views, we also don't need status
  241. if(!ONLY_PAGE)
  242. {
  243. // STATUS CHECKER
  244. $statustimeout = 1;
  245. foreach(explode("*", str_replace(" ", "", $config['server']['statusTimeout'])) as $status_var)
  246. if($status_var > 0)
  247. $statustimeout = $statustimeout * $status_var;
  248. $statustimeout = $statustimeout / 1000;
  249. $config['status'] = parse_ini_file('cache/DONT_EDIT_serverstatus.txt');
  250. if($config['status']['serverStatus_lastCheck']+$statustimeout < time())
  251. {
  252. $config['status']['serverStatus_checkInterval'] = $statustimeout+3;
  253. $config['status']['serverStatus_lastCheck'] = time();
  254. $statusInfo = new ServerStatus($config['server']['ip'], $config['server']['statusPort'], 1);
  255. if($statusInfo->isOnline())
  256. {
  257. $config['status']['serverStatus_online'] = 1;
  258. $config['status']['serverStatus_players'] = $statusInfo->getPlayersCount();
  259. $config['status']['serverStatus_playersMax'] = $statusInfo->getPlayersMaxCount();
  260. $h = floor($statusInfo->getUptime() / 3600);
  261. $m = floor(($statusInfo->getUptime() - $h*3600) / 60);
  262. $config['status']['serverStatus_uptime'] = $h.'h '.$m.'m';
  263. $config['status']['serverStatus_monsters'] = $statusInfo->getMonsters();
  264. }
  265. else
  266. {
  267. $config['status']['serverStatus_online'] = 0;
  268. $config['status']['serverStatus_players'] = 0;
  269. $config['status']['serverStatus_playersMax'] = 0;
  270. }
  271. $file = fopen("cache/DONT_EDIT_serverstatus.txt", "w");
  272. $file_data = '';
  273. foreach($config['status'] as $param => $data)
  274. {
  275. $file_data .= $param.' = "'.str_replace('"', '', $data).'"
  276. ';
  277. }
  278. rewind($file);
  279. fwrite($file, $file_data);
  280. fclose($file);
  281. }
  282. //PAGE VIEWS COUNTER
  283. $views_counter = "cache/DONT_EDIT_usercounter.txt";
  284. // checking if the file exists
  285. if (file_exists($views_counter))
  286. {
  287. $actie = fopen($views_counter, "r+");
  288. $page_views = fgets($actie, 9);
  289. $page_views++;
  290. rewind($actie);
  291. fputs($actie, $page_views, 9);
  292. fclose($actie);
  293. }
  294. else
  295. {
  296. // the file doesn't exist, creating a new one with value 1
  297. $actie = fopen($views_counter, "w");
  298. $page_views = 1;
  299. fputs($actie, $page_views, 9);
  300. fclose($actie);
  301. }
  302. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement