A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

328 lines
11 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file includes/class_overall.php
  5. * @version $Id$
  6. * @copyright 2009(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/
  8. * @license GNU GPL v3
  9. **/
  10. if ( !defined('IN_uF') )
  11. {
  12. die('Hacking attempt');
  13. }
  14. class Over
  15. {
  16. function set_counter()
  17. {
  18. global $forum_config;
  19. if (!isset($_COOKIE['forum_visited']))
  20. {
  21. setcookie('forum_visited','1');
  22. $visit_count = $forum_config['forum_counter'] +1;
  23. DataBase::sql_query("UPDATE `".CONFIG_TABLE."` SET `value`='$visit_count' WHERE `name`='forum_counter'",'GENERAL','Could not update forum counter');
  24. }
  25. else
  26. {
  27. $visit_count = $forum_config['forum_counter'];
  28. }
  29. return $visit_count;
  30. }
  31. function generate_header($title, $navigator)
  32. {
  33. global $lng;
  34. global $forum_config;
  35. $skin = array(
  36. 'forumname' => $forum_config['forumname'],
  37. 'forumdesc' => $forum_config['forumdesc'],
  38. 'users' => $lng['lusers'],
  39. 'pm' => $lng['lpm'],
  40. 'register' => $lng['lregister'],
  41. 'search' => $lng['lsearch'],
  42. 'eprofile' => $lng['leprofile'],
  43. 'groups' => $lng['lgroups'],
  44. 'keywords' => $forum_config['meta_keywords'],
  45. 'description' => $forum_config['meta_description'],
  46. 'mainpage' => $title,
  47. 'lmainpage' => $navigator,
  48. 'lactual_time'=>$lng['lactualtime'],
  49. 'modelogin' => ($_SESSION['uid']>0) ? 'logout' : 'login',
  50. 'llogin' => ($_SESSION['uid']>0) ? $lng['lunlogin'] : $lng['llogin']
  51. );
  52. return $skin;
  53. }
  54. function user_agent($agent)
  55. {
  56. global $lng;
  57. /*This original function is in phpBB 1.12.5 modified by Przemo*/
  58. /*Modified by PioDer: added new browsers and systems and other replaces*/
  59. $agent_tst = ' ' . strtolower($agent);
  60. $system = $browser = '';
  61. if (
  62. strpos($agent_tst, 'windows') ||
  63. strpos($agent_tst, 'win9') ||
  64. strpos($agent_tst, 'win32') ||
  65. strpos($agent_tst, 'nt 5.') ||
  66. strpos($agent_tst, 'nt 4') )
  67. {
  68. $system = ( strpos($agent_tst, 'windows 9') || strpos($agent_tst, 'nt 4') || strpos($agent_tst, 'windows') || strpos($agent_tst, 'win32') ) ? 'windows_98_nt_2000' : $system;
  69. $system = ( strpos($agent_tst, 'nt 5.') || strpos($agent_tst, 'nt 6.') || strpos($agent_tst, 'nt 7.') || strpos($agent_tst, 'nt 8.') ) ? 'windows_xp_2003' : $system;
  70. $system = (strpos($agent_tst, 'nt 5.0')) ? 'windows_98_nt_2000' : $system;
  71. $system = (strpos($agent_tst, 'nt 6.0')) ? 'windows_vista' : $system;
  72. }
  73. else
  74. {
  75. $system = (strpos($agent_tst, 'linux')) ? 'linux' : $system;
  76. $system = (strpos($agent_tst, 'suse')) ? 'linux_suse' : $system;
  77. $system = (strpos($agent_tst, 'knoppix')) ? 'linux_knoppix' : $system;
  78. $system = (strpos($agent_tst, 'turbolinux')) ? 'linux_turbolinux' : $system;
  79. $system = (strpos($agent_tst, 'slackware')) ? 'linux_slackware' : $system;
  80. $system = (strpos($agent_tst, 'gentoo')) ? 'linux_gentoo' : $system;
  81. $system = (strpos($agent_tst, 'lycoris')) ? 'linux_lycoris' : $system;
  82. $system = (strpos($agent_tst, 'debian')) ? 'linux_debian' : $system;
  83. $system = (strpos($agent_tst, 'redhat')) ? 'linux_redhat' : $system;
  84. $system = (strpos($agent_tst, 'archlinux')) ? 'linux_arch' : $system;
  85. $system = (strpos($agent_tst, 'ubuntu')) ? 'linux_ubuntu' : $system;
  86. $system = (strpos($agent_tst, 'cdlinux')) ? 'linux_cdlinux' : $system;
  87. $system = (strpos($agent_tst, 'mandriva')) ? 'linux_mandriva' : $system;
  88. $system = (strpos($agent_tst, 'kateos')) ? 'linux_kateos' : $system;
  89. $system = (strpos($agent_tst, 'bsd')) ? 'linux_freebsd' : $system;
  90. }
  91. if ( $system == '')
  92. {
  93. $system = (strpos($agent_tst, 'mac')) ? 'macos' : $system;
  94. $system = (strpos($agent_tst, 'aix')) ? 'aix' : $system;
  95. $system = (strpos($agent_tst, 'lindows')) ? 'lindows' : $system;
  96. $system = (strpos($agent_tst, 'amiga')) ? 'amiga' : $system;
  97. $system = (strpos($agent_tst, 'athe')) ? 'athe' : $system;
  98. $system = (strpos($agent_tst, 'beos')) ? 'beos' : $system;
  99. $system = (strpos($agent_tst, 'zeta')) ? 'beos' : $system;
  100. $system = (strpos($agent_tst, 'BlueEyed')) ? 'beos' : $system;
  101. $system = (strpos($agent_tst, 'nextstep')) ? 'nextstep' : $system;
  102. $system = (strpos($agent_tst, 'warp')) ? 'warp' : $system;
  103. $system = (strpos($agent_tst, 'qnx')) ? 'qnx' : $system;
  104. $system = (strpos($agent_tst, 'risc')) ? 'risc' : $system;
  105. $system = (strpos($agent_tst, 'solaris')) ? 'solaris' : $system;
  106. $system = (strpos($agent_tst, 'unix')) ? 'unix' : $system;
  107. $system = (strpos($agent_tst, 'macos')) ? 'macos' : $system;
  108. $system = (strpos($agent_tst, 'mac os')) ? 'macos' : $system;
  109. $system = (strpos($agent_tst, 'symbian')) ? 'symbian' : $system;
  110. $system = ($system == '' && strpos($agent_tst, 'win9') || strpos($agent_tst, 'win3') || strpos($agent_tst, 'windows') ) ? 'windows_98_nt_2000' : $system;
  111. }
  112. $browser = (strpos($agent_tst, 'mozilla')) ? 'mozilla' : $browser;
  113. $browser = (strpos($agent_tst, 'msie')) ? 'ie' : $browser;
  114. $browser = (strpos($agent_tst, 'msie 7')) ? 'ie7' : $browser;
  115. $browser = (strpos($agent_tst, 'netscape')) ? 'netscape' : $browser;
  116. $browser = (strpos($agent_tst, 'opera')) ? 'opera' : $browser;
  117. $browser = (strpos($agent_tst, 'konqueror')) ? 'konqueror' : $browser;
  118. $browser = (strpos($agent_tst, 'galeon')) ? 'galeon' : $browser;
  119. $browser = (strpos($agent_tst, 'firefox')) ? 'firefox' : $browser;
  120. $browser = (strpos($agent_tst, 'netsprint')) ? 'netsprint' : $browser;
  121. $browser = (strpos($agent_tst, 'firebird')) ? 'firebird' : $browser;
  122. $browser = (strpos($agent_tst, 'links')) ? 'links' : $browser;
  123. $browser = (strpos($agent_tst, 'dillo')) ? 'dillo' : $browser;
  124. $browser = (strpos($agent_tst, 'omniweb')) ? 'omniweb' : $browser;
  125. $browser = (strpos($agent_tst, 'avant')) ? 'avant' : $browser;
  126. $browser = (strpos($agent_tst, 'myie2')) ? 'myie2' : $browser;
  127. $browser = (strpos($agent_tst, 'seamonkey')) ? 'seamonkey' : $browser;
  128. $browser = (strpos($agent_tst, 'maxthon')) ? 'maxthon' : $browser;
  129. $browser = ($browser == '') ? 'unknown' : $browser;
  130. $system = ($system == '') ? 'unknown' : $system;
  131. return array('icon_' . $system . '.gif', 'icon_' . $browser . '.gif', ($system=='unknown') ? $lng['unknown'] : $system, ($browser=='unknown') ? $lng['unknown'] : $browser);
  132. }
  133. function GenerateTime($request_time)
  134. {
  135. global $lng;
  136. if (date('d-m-Y',$request_time)== date('d-m-Y',time()))
  137. {
  138. $date = $lng['today'].', '.date('G:i', $request_time);
  139. }
  140. else
  141. {
  142. if ((date('d',$request_time))== (date('d',time())-1) && (date('m-Y',$request_time)== date('m-Y',time())))
  143. {
  144. $date = $lng['yesterday'].', '.date('G:i', $request_time);
  145. }
  146. else
  147. {
  148. $date = date('d-m-Y, G:i',$request_time);
  149. }
  150. }
  151. return $date;
  152. }
  153. function AddPages()
  154. {
  155. global $count;
  156. global $page;
  157. $content = '';
  158. for ($i=1;$i<=$count;$i++)
  159. {
  160. if ($i==$page)
  161. {
  162. $content .= '<option value="'.$i.'" selected="selected">'.$i.'</option>';
  163. }
  164. else
  165. {
  166. $content .= '<option value="'.$i.'">'.$i.'</option>';
  167. }
  168. }
  169. return $content;
  170. unset($content);
  171. }
  172. function AddPages2($page)//for edit profile, not used in limit!
  173. {
  174. $content = '';
  175. for ($i=1;$i<=50;$i++)
  176. {
  177. if ($i==$page)
  178. {
  179. $content .= '<option value="'.$i.'" selected="selected">'.$i.'</option>';
  180. }
  181. else
  182. {
  183. $content .= '<option value="'.$i.'">'.$i.'</option>';
  184. }
  185. }
  186. return $content;
  187. unset($content);
  188. }
  189. function AddSkins()
  190. {
  191. global $forum_config;
  192. global $default_skin;
  193. $all='';
  194. $query = DataBase::sql_query("SELECT `name`, `s_id` FROM `".SKINS_TABLE."`",'GENERAL','Could not obtain skins information');
  195. while($t = @mysql_fetch_array($query))
  196. {
  197. if ($t['name']==$default_skin)
  198. {
  199. $all .= '<option value="'.$t['s_id'].'" selected="selected">'.$t['name'].'</option>';
  200. }
  201. else
  202. {
  203. $all .= '<option value="'.$t['s_id'].'">'.$t['name'].'</option>';
  204. }
  205. }
  206. return $all;
  207. unset($t, $all);
  208. }
  209. function AddLangs()
  210. {
  211. global $forum_config;
  212. global $default_lang;
  213. $result='';
  214. $rep=opendir('./lngs');
  215. $browseruMoinsUnRepertoire = false;
  216. while ($file = readdir($rep))
  217. {
  218. if($file != '..' && $file !='.' && $file !='')
  219. {
  220. if (is_dir('./lngs/'.$file)){
  221. $browseruMoinsUnRepertoire = true;
  222. if ($file==$default_lang)
  223. {
  224. $result .='<option value="'.$file.'" selected="selected">'.$file.'</option>';
  225. }
  226. else
  227. {
  228. $result .='<option value="'.$file.'">'.$file.'</option>';
  229. }
  230. }
  231. }
  232. }
  233. return $result;
  234. unset($rep, $browseruMoinsUnRepertoire, $file, $result);
  235. }
  236. function TimeGeneration()
  237. {
  238. list($usec, $sec ) = explode(" ",microtime());
  239. return ((float)$usec + (float)$sec);
  240. }
  241. function IfModGroup($guid)
  242. {
  243. global $lng;
  244. $uid = $_SESSION['uid'];
  245. if ($guid==$uid)
  246. {
  247. return'
  248. <tr>
  249. <td class="fitem">
  250. <span class="fstandard">'.$lng['addusrtogrp'].':</span><input type="text" name="nick" style="widtfh:100px; height:15px" value="'.$_POST['nick'].'">
  251. </td>
  252. <td class="fitem">
  253. <span class="fstandard">'.$lng['delusrforgrp'].':</span><input type="text" name="delnick" style="widtfh:100px; height:15px" value="'.$_POST['nick'].'">
  254. </td>
  255. <td class="fitem">
  256. <input type="submit" class="fbutton" value="'.$lng['lgo'].'">
  257. </tr>
  258. ';
  259. }
  260. }
  261. function TotalPosts()
  262. {
  263. $sql = "SELECT count(*) as `p_id` FROM ".POSTS_TABLE."";
  264. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain total posts information');
  265. $result = mysql_fetch_array($query);
  266. $result = $result['p_id'];
  267. return($result);
  268. }
  269. function DefaultLang()
  270. {
  271. global $forum_config;
  272. global $userdata;
  273. if ($_SESSION['uid']>0)
  274. {
  275. //$sql = "SELECT `u_id`, `lang` FROM ".USERS_TABLE." WHERE `u_id`='".$_SESSION['uid']."' LIMIT 1";
  276. //$result = @mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain user information'));
  277. return $userdata['lang'];
  278. }
  279. else
  280. {
  281. return $forum_config['defaultlang'];
  282. }
  283. }
  284. function ShowQueries($start, $stop)
  285. {
  286. global $forum_config;
  287. global $lng;
  288. if ($forum_config['show_time_generation'])
  289. {
  290. $result = $stop - $start;
  291. $result = round($result,3);
  292. if (extension_loaded('xdebug'))
  293. {
  294. return $lng['script_generated'].$result.' '.$lng['seconds'].'. SQL: '.$_COOKIE['queries'].'.<br>
  295. Wersja Xdebug: '.phpversion('xdebug').', Użycie pamięci: '.round((xdebug_memory_usage()/1024),2).'KB.';
  296. }
  297. else
  298. {
  299. return $lng['script_generated'].$result.' '.$lng['seconds'].'. SQL: '.$_COOKIE['queries'].'.';
  300. }
  301. }
  302. else
  303. {
  304. return '';
  305. }
  306. }
  307. function ViewSkinName()
  308. {
  309. global $forum_config;
  310. global $userdata;
  311. if ($_SESSION['uid']>0)
  312. {
  313. $result = $userdata['skin'];
  314. }
  315. else
  316. {
  317. $result = $forum_config['defaultskin'];
  318. }
  319. $sql = "SELECT * FROM `".SKINS_TABLE."` WHERE `s_id`='$result'";
  320. $result = mysql_fetch_array(DataBase::sql_query($sql,'CRITICAL','Could not obtain skin information.'));
  321. return $result['name'];
  322. }
  323. }
  324. ?>