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.
 
 
 
 
 
 

346 lines
10 KiB

<?php
/**
* @package uForum
* @file includes/class_overall.php
* @version $Id$
* @copyright 2009(c) PioDer <[email protected]>
* @link http://pioder.gim2przemysl.int.pl/
* @license GNU GPL v3
**/
if ( !defined('IN_uF') )
{
die('Hacking attempt');
}
function SetCounter()
{
global $forum_config;
if (!isset($_COOKIE['forum_visited']))
{
setcookie('forum_visited','1');
$visit_count = $forum_config['forum_counter'] +1;
DataBase::sql_query("UPDATE `".CONFIG_TABLE."` SET `value`='$visit_count' WHERE `name`='forum_counter'",'GENERAL','Could not update forum counter');
}
else
{
$visit_count = $forum_config['forum_counter'];
}
return $visit_count;
}
function GenerateHeader($title, $navigator)
{
global $lng;
global $forum_config;
$skin = array(
'forumname' => $forum_config['forumname'],
'forumdesc' => $forum_config['forumdesc'],
'users' => $lng['lusers'],
'pm' => $lng['lpm'],
'register' => $lng['lregister'],
'search' => $lng['lsearch'],
'eprofile' => $lng['leprofile'],
'groups' => $lng['lgroups'],
'keywords' => $forum_config['meta_keywords'],
'description' => $forum_config['meta_description'],
'mainpage' => $title,
'lmainpage' => $navigator,
'lactual_time'=>$lng['lactualtime'],
'modelogin' => ($_SESSION['uid']>0) ? 'logout' : 'login',
'llogin' => ($_SESSION['uid']>0) ? $lng['lunlogin'] : $lng['llogin']
);
return $skin;
}
function UserAgent($agent)
{
global $lng;
/*This original function is in phpBB 1.12.5 modified by Przemo*/
/*Modified by PioDer: added new browsers and systems and other replaces*/
$agent_tst = ' ' . strtolower($agent);
$system = $browser = '';
if (
strpos($agent_tst, 'windows') ||
strpos($agent_tst, 'win9') ||
strpos($agent_tst, 'win32') ||
strpos($agent_tst, 'nt 5.') ||
strpos($agent_tst, 'nt 4') )
{
$system = ( strpos($agent_tst, 'windows 9') || strpos($agent_tst, 'nt 4') || strpos($agent_tst, 'windows') || strpos($agent_tst, 'win32') ) ? 'windows_98_nt_2000' : $system;
$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;
$system = (strpos($agent_tst, 'nt 5.0')) ? 'windows_98_nt_2000' : $system;
$system = (strpos($agent_tst, 'nt 6.0')) ? 'windows_vista' : $system;
}
else
{
$system = (strpos($agent_tst, 'linux')) ? 'linux' : $system;
$system = (strpos($agent_tst, 'suse')) ? 'linux_suse' : $system;
$system = (strpos($agent_tst, 'knoppix')) ? 'linux_knoppix' : $system;
$system = (strpos($agent_tst, 'turbolinux')) ? 'linux_turbolinux' : $system;
$system = (strpos($agent_tst, 'slackware')) ? 'linux_slackware' : $system;
$system = (strpos($agent_tst, 'gentoo')) ? 'linux_gentoo' : $system;
$system = (strpos($agent_tst, 'lycoris')) ? 'linux_lycoris' : $system;
$system = (strpos($agent_tst, 'debian')) ? 'linux_debian' : $system;
$system = (strpos($agent_tst, 'redhat')) ? 'linux_redhat' : $system;
$system = (strpos($agent_tst, 'archlinux')) ? 'linux_arch' : $system;
$system = (strpos($agent_tst, 'ubuntu')) ? 'linux_ubuntu' : $system;
$system = (strpos($agent_tst, 'cdlinux')) ? 'linux_cdlinux' : $system;
$system = (strpos($agent_tst, 'mandriva')) ? 'linux_mandriva' : $system;
$system = (strpos($agent_tst, 'kateos')) ? 'linux_kateos' : $system;
$system = (strpos($agent_tst, 'bsd')) ? 'linux_freebsd' : $system;
}
if ( $system == '')
{
$system = (strpos($agent_tst, 'mac')) ? 'macos' : $system;
$system = (strpos($agent_tst, 'aix')) ? 'aix' : $system;
$system = (strpos($agent_tst, 'lindows')) ? 'lindows' : $system;
$system = (strpos($agent_tst, 'amiga')) ? 'amiga' : $system;
$system = (strpos($agent_tst, 'athe')) ? 'athe' : $system;
$system = (strpos($agent_tst, 'beos')) ? 'beos' : $system;
$system = (strpos($agent_tst, 'zeta')) ? 'beos' : $system;
$system = (strpos($agent_tst, 'BlueEyed')) ? 'beos' : $system;
$system = (strpos($agent_tst, 'nextstep')) ? 'nextstep' : $system;
$system = (strpos($agent_tst, 'warp')) ? 'warp' : $system;
$system = (strpos($agent_tst, 'qnx')) ? 'qnx' : $system;
$system = (strpos($agent_tst, 'risc')) ? 'risc' : $system;
$system = (strpos($agent_tst, 'solaris')) ? 'solaris' : $system;
$system = (strpos($agent_tst, 'unix')) ? 'unix' : $system;
$system = (strpos($agent_tst, 'macos')) ? 'macos' : $system;
$system = (strpos($agent_tst, 'mac os')) ? 'macos' : $system;
$system = (strpos($agent_tst, 'symbian')) ? 'symbian' : $system;
$system = ($system == '' && strpos($agent_tst, 'win9') || strpos($agent_tst, 'win3') || strpos($agent_tst, 'windows') ) ? 'windows_98_nt_2000' : $system;
}
$browser = (strpos($agent_tst, 'mozilla')) ? 'mozilla' : $browser;
$browser = (strpos($agent_tst, 'msie')) ? 'ie' : $browser;
$browser = (strpos($agent_tst, 'msie 7')) ? 'ie7' : $browser;
$browser = (strpos($agent_tst, 'netscape')) ? 'netscape' : $browser;
$browser = (strpos($agent_tst, 'opera')) ? 'opera' : $browser;
$browser = (strpos($agent_tst, 'konqueror')) ? 'konqueror' : $browser;
$browser = (strpos($agent_tst, 'galeon')) ? 'galeon' : $browser;
$browser = (strpos($agent_tst, 'firefox')) ? 'firefox' : $browser;
$browser = (strpos($agent_tst, 'netsprint')) ? 'netsprint' : $browser;
$browser = (strpos($agent_tst, 'firebird')) ? 'firebird' : $browser;
$browser = (strpos($agent_tst, 'links')) ? 'links' : $browser;
$browser = (strpos($agent_tst, 'dillo')) ? 'dillo' : $browser;
$browser = (strpos($agent_tst, 'omniweb')) ? 'omniweb' : $browser;
$browser = (strpos($agent_tst, 'avant')) ? 'avant' : $browser;
$browser = (strpos($agent_tst, 'myie2')) ? 'myie2' : $browser;
$browser = (strpos($agent_tst, 'seamonkey')) ? 'seamonkey' : $browser;
$browser = (strpos($agent_tst, 'maxthon')) ? 'maxthon' : $browser;
$browser = ($browser == '') ? 'unknown' : $browser;
$system = ($system == '') ? 'unknown' : $system;
return array('icon_' . $system . '.gif', 'icon_' . $browser . '.gif', ($system=='unknown') ? $lng['unknown'] : $system, ($browser=='unknown') ? $lng['unknown'] : $browser);
}
function GenerateTime($request_time)
{
global $lng;
if (date('d-m-Y',$request_time)== date('d-m-Y',time()))
{
$date = $lng['today'].', '.date('G:i', $request_time);
}
else
{
if ((date('d',$request_time))== (date('d',time())-1) && (date('m-Y',$request_time)== date('m-Y',time())))
{
$date = $lng['yesterday'].', '.date('G:i', $request_time);
}
else
{
$date = date('d-m-Y, G:i',$request_time);
}
}
return $date;
}
function AddPages()
{
global $count;
global $page;
$content = '';
for ($i=1;$i<=$count;$i++)
{
if ($i==$page)
{
$content .= '<option value="'.$i.'" selected="selected">'.$i.'</option>';
}
else
{
$content .= '<option value="'.$i.'">'.$i.'</option>';
}
}
return $content;
unset($content);
}
function AddPages2($page)//for edit profile, not used in limit!
{
$content = '';
for ($i=1;$i<=50;$i++)
{
if ($i==$page)
{
$content .= '<option value="'.$i.'" selected="selected">'.$i.'</option>';
}
else
{
$content .= '<option value="'.$i.'">'.$i.'</option>';
}
}
return $content;
unset($content);
}
function AddSkins()
{
global $forum_config;
global $default_skin;
$all='';
$query = DataBase::sql_query("SELECT `name`, `s_id` FROM `".SKINS_TABLE."`",'GENERAL','Could not obtain skins information');
while($t = @mysql_fetch_array($query))
{
if ($t['name']==$default_skin)
{
$all .= '<option value="'.$t['s_id'].'" selected="selected">'.$t['name'].'</option>';
}
else
{
$all .= '<option value="'.$t['s_id'].'">'.$t['name'].'</option>';
}
}
return $all;
unset($t, $all);
}
function AddLangs()
{
global $forum_config;
global $default_lang;
$result='';
$rep=opendir('./lngs');
$browseruMoinsUnRepertoire = false;
while ($file = readdir($rep))
{
if($file != '..' && $file !='.' && $file !='')
{
if (is_dir('./lngs/'.$file)){
$browseruMoinsUnRepertoire = true;
if ($file==$default_lang)
{
$result .='<option value="'.$file.'" selected="selected">'.$file.'</option>';
}
else
{
$result .='<option value="'.$file.'">'.$file.'</option>';
}
}
}
}
return $result;
unset($rep, $browseruMoinsUnRepertoire, $file, $result);
}
function TimeGeneration()
{
list($usec, $sec ) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function IfModGroup($guid)
{
global $lng;
$uid = $_SESSION['uid'];
if ($guid==$uid)
{
return'
<tr>
<td class="fitem">
<span class="fstandard">'.$lng['addusrtogrp'].':</span><input type="text" name="nick" style="widtfh:100px; height:15px" value="'.$_POST['nick'].'">
</td>
<td class="fitem">
<span class="fstandard">'.$lng['delusrforgrp'].':</span><input type="text" name="delnick" style="widtfh:100px; height:15px" value="'.$_POST['nick'].'">
</td>
<td class="fitem">
<input type="submit" class="fbutton" value="'.$lng['lgo'].'">
</tr>
';
}
}
function TotalPosts()
{
$sql = "SELECT count(*) as `p_id` FROM ".POSTS_TABLE."";
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain total posts information');
$result = mysql_fetch_array($query);
$result = $result['p_id'];
return($result);
}
function DefaultLang()
{
global $forum_config;
global $userdata;
if ($_SESSION['uid']>0)
{
return $userdata['lang'];
}
else
{
return $forum_config['defaultlang'];
}
}
function ShowQueries($start, $stop)
{
global $forum_config;
global $lng;
if ($forum_config['show_time_generation'])
{
$result = $stop - $start;
$result = round($result,3);
if (extension_loaded('xdebug'))
{
return $lng['script_generated'].$result.' '.$lng['seconds'].'. SQL: '.$_COOKIE['queries'].'.<br>
Wersja Xdebug: '.phpversion('xdebug').', Użycie pamięci: '.round((xdebug_memory_usage()/1024),2).'KB.';
}
else
{
return $lng['script_generated'].$result.' '.$lng['seconds'].'. SQL: '.$_COOKIE['queries'].'.';
}
}
else
{
return '';
}
}
function ViewSkinName()
{
global $forum_config;
global $userdata;
if ($_SESSION['uid']>0)
{
$result = $userdata['skin'];
}
else
{
$result = $forum_config['defaultskin'];
}
$sql = "SELECT * FROM `".SKINS_TABLE."` WHERE `s_id`='$result'";
$result = mysql_fetch_array(DataBase::sql_query($sql,'CRITICAL','Could not obtain skin information.'));
return $result['name'];
}
?>