/*****************************************************/
/* jPORTAL - internetowy system portalowy */
/*****************************************************/
/* autor: Pawel 'jaco' Jaczewski */
/* email: info@websys.pl */
/*****************************************************/
#=====================================================#
if(eregi("main.php",$PHP_SELF)) { header("Location: index.php"); exit; }
###############################################################################
###############################################################################
###############################################################################
set_theme();
include("theme/$theme/functions.inc.php");
###############################################################################
###############################################################################
###############################################################################
function left_menu() {
global $menu_tbl, $PHP_SELF;
left_menu_open();
$query = "SELECT * FROM $menu_tbl WHERE posx='left' AND status=1 ORDER BY posy";
$result = mysql_query($query);
while($r = mysql_fetch_array($result)) {
$title = $r['title'];
$text = $r['text'];
$id = $r['id'];
$title = stripslashes($title);
$text = stripslashes($text);
left_menu_title_open();
echo $title;
left_menu_title_close();
left_menu_text_open();
$text = '?>'.$text.'';
eval($text);
left_menu_text_close();
}
left_menu_close();
}
###############################################################################
###############################################################################
###############################################################################
function right_menu() {
global $menu_tbl;
right_menu_open();
$query = "SELECT * FROM $menu_tbl WHERE posx='right' AND status=1 ORDER BY posy";
$result = mysql_query($query);
while($r = mysql_fetch_array($result)) {
$title = $r['title'];
$text = $r['text'];
$id = $r['id'];
$title = stripslashes($title);
$text = stripslashes($text);
right_menu_title_open();
echo $title;
right_menu_title_close();
right_menu_text_open();
$text = '?>'.$text.'';
eval($text);
right_menu_text_close();
}
right_menu_close();
}
###############################################################################
###############################################################################
###############################################################################
function set_theme() {
global $set_theme, $logs, $theme, $default_theme;
if($set_theme<>'') {
if(file_exists("theme/$set_theme")) {
$theme = $set_theme;
$czas = mktime(0,0,0,date("m"),date("d"),date("Y")+5);
setcookie("theme", $set_theme, $czas);
header("Location: index.php");
exit;
}
}
if($theme=='' OR !file_exists("theme/$theme")) {
$theme = $default_theme;
} else {
if(!file_exists("theme/$set_theme"))
$theme = $default_theme;
}
}
###############################################################################
###############################################################################
###############################################################################
function poll_form($punkt='') {
global $poll_a_tbl, $poll_b_tbl;
$query = "SELECT * FROM $poll_a_tbl ORDER BY id DESC";
$result = mysql_query($query);
$num = mysql_num_rows($result);
if($num==0) {
echo '
aktualnie nie jest prowadzona żadna ankieta
';
} else {
$r = mysql_fetch_array($result);
$id = $r['id'];
$votes = $r['votes'];
$title = $r['title'];
echo '';
}
}
###############################################################################
###############################################################################
###############################################################################
function print_main() {
global $error;
if($error=='') {
site_main();
} else {
site_error($error);
}
}
###############################################################################
###############################################################################
###############################################################################
function is_login()
{
global $user_tbl;
static $re;
if($_SESSION['nick']<>'')
{
if($re=='')
{
$res = mysql_query("SELECT * FROM $user_tbl WHERE nick='{$_SESSION['nick']}' AND access='{$_SESSION['access']}' AND pass='".$_SESSION['pass']."'");
$re = (mysql_num_rows($res)==1 ? 'yes' : 'no' );
}
else
{
return $re;
}
return $re;
}
}
###############################################################################
###############################################################################
###############################################################################
function is_user_login() {
global $gnick, $gpass, $guest_tbl;
$query = "SELECT * FROM $guest_tbl WHERE nick='$_SESSION[gnick]' AND stat='ok'";
$result = mysql_query($query);
$r = mysql_fetch_array($result);
$d = mysql_num_rows($result);
if($d==1) {
$nick_ = $r['nick'];
$pass_ = md5(stripslashes($r['pass']));
if($_SESSION[gnick]==$nick_ AND $_SESSION[gpass]==$pass_ ) $re = 'yes'; else $re = 'no';
} else {
$re = 'no';
}
return $re;
}
###############################################################################
###############################################################################
###############################################################################
function pl_date() {
$dzie2 = date("j");
$dzien = date("D");
if ($dzien == Mon) {$dzien = "poniedziałek";}
if ($dzien == Tue) {$dzien = "wtorek";}
if ($dzien == Wed) {$dzien = "środa";}
if ($dzien == Thu) {$dzien = "czwartek";}
if ($dzien == Fri) {$dzien = "piątek";}
if ($dzien == Sat) {$dzien = "sobota";}
if ($dzien == Sun) {$dzien = "niedziela";}
$miesiac = date("m");
if ($miesiac == 1) {$miesiac = "stycznia";}
if ($miesiac == 2) {$miesiac = "lutego";}
if ($miesiac == 3) {$miesiac = "marca";}
if ($miesiac == 4) {$miesiac = "kwietnia";}
if ($miesiac == 5) {$miesiac = "maja";}
if ($miesiac == 6) {$miesiac = "czerwca";}
if ($miesiac == 7) {$miesiac = "lipca";}
if ($miesiac == 8) {$miesiac = "sierpnia";}
if ($miesiac == 9) {$miesiac = "września";}
if ($miesiac == 10) {$miesiac = "października";}
if ($miesiac == 11) {$miesiac = "listopada";}
if ($miesiac == 12) {$miesiac = "grudnia";}
$rok = date("Y");
$rok = $dzien.', '.$dzie2.' '.$miesiac.' '.$rok;
return $rok;
}
###############################################################################
###############################################################################
###############################################################################
function make_clickable($text, $mode='normal') {
$ret = " " . $text;
if($mode=='normal') {
$ret = preg_replace("#([\n ])([a-z]+?)://([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)#i", "\\1\\2://\\3", $ret);
$ret = preg_replace("#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]*)?)#i", "\\1www.\\2.\\3\\4", $ret);
$ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", "\\1\\2@\\3", $ret);
$ret = preg_replace("#\[url\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si", "\\1\\2", $ret);
$ret = preg_replace("#\[url\]([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si", "\\1", $ret);
$ret = preg_replace("#\[url=([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si", "\\3", $ret);
$ret = preg_replace("#\[url=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si", "\\2", $ret);
$ret = preg_replace("#\[link\]([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/link\]#si", "\\1", $ret);
$ret = preg_replace("#\[link=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/link\]#si", "\\2", $ret);
} else {
$ret = preg_replace("#\[url\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si", "\\1\\2", $ret);
$ret = preg_replace("#\[url\]([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si", "\\1", $ret);
$ret = preg_replace("#\[url=([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si", "\\3", $ret);
$ret = preg_replace("#\[url=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si", "\\2", $ret);
$ret = preg_replace("#\[link\]([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/link\]#si", "\\1", $ret);
$ret = preg_replace("#\[link=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/link\]#si", "\\2", $ret);
}
$ret = preg_replace("#\[code\]\s
#si", "", $ret);
$ret = preg_replace("#
\s\[/code\]\s
#si", "
", $ret);
$ret = preg_replace("#\[cytat\]\s
#si", "", $ret);
$ret = preg_replace("#
\s\[/cytat\]\s
#si", "
", $ret);
$ret = preg_replace("#\[moder\]\s
#si", "", $ret);
$ret = preg_replace("#
\s\[/moder\]\s
#si", "
", $ret);
$ret = str_replace("[code]", "", $ret);
$ret = preg_replace("#\[/code\]\s
#si", "
", $ret);
$ret = str_replace("[cytat]", "", $ret);
$ret = preg_replace("#\[/cytat\]\s
#si", "
", $ret);
$ret = str_replace("[moder]", "", $ret);
$ret = preg_replace("#\[/moder\]\s
#si", "
", $ret);
$ret = preg_replace("#\[/code\]#si", "", $ret);
$ret = preg_replace("#\[/cytat\]#si", "", $ret);
$ret = preg_replace("#\[/moder\]#si", "", $ret);
//=========
$ret = str_replace("[b]", "", $ret);
$ret = str_replace("[/b]", "", $ret);
$ret = str_replace("[i]", "", $ret);
$ret = str_replace("[/i]", "", $ret);
$ret = str_replace("[u]", "", $ret);
$ret = str_replace("[/u]", "", $ret);
$ret = substr($ret, 1);
return($ret);
}
function smilies($text) {
global $smilies;
if($smilies<>'off') {
$text = str_replace(":)","
",$text);
$text = str_replace(":-)","
",$text);
$text = str_replace(":(","
",$text);
$text = str_replace(":-(","
",$text);
$text = str_replace(":P","
",$text);
$text = str_replace(":-P","
",$text);
$text = str_replace(":o","
",$text);
$text = str_replace(":O","
",$text);
$text = str_replace(":-o","
",$text);
$text = str_replace(":-O","
",$text);
$text = str_replace(" :/","
",$text);
$text = str_replace(":lol:","
",$text);
$text = str_replace(":deb:","
",$text);
$text = str_replace(":D","
",$text);
$text = str_replace("8)","
",$text);
$text = str_replace(":@","
",$text);
$text = str_replace(";)","
",$text);
$text = str_replace(";-)","
",$text);
$text = str_replace("???","
",$text);
$text = str_replace(":]","
",$text);
}
return $text;
}
###############################################################################
###############################################################################
###############################################################################
function login_guest($goto='') {
global $guest_tbl, $ga10, $gb10, $gnick, $gmail, $gpass, $REMOTE_ADDR;
if($ga10<>'' AND $gb10<>'') {
$query = "SELECT * FROM $guest_tbl WHERE nick='$ga10' AND stat='ok'";
$result = mysql_query($query);
$r = mysql_fetch_array($result);
$nick_ = $r['nick'];
$pass_ = $r['pass'];
$mail_ = $r['mail'];
if($nick_==$ga10 AND $pass_==$gb10) {
$_SESSION[gnick] = $nick_;
$_SESSION[gpass] = md5($pass_);
$_SESSION[gmail] = $mail_;
if(file_exists($o.'online_g/'.$REMOTE_ADDR)) unlink($o.'online_g/'.$REMOTE_ADDR);
if($goto=='')
header("Location: login.php?cmd=pw_get");
else
header("Location: $goto");
exit;
} else {
return 'no';
}
} else {
return 'no';
}
}
###############################################################################
###############################################################################
###############################################################################
function get_user_info($aaa='nic', $abc='') {
global $guest_tbl, $gnick, $gmail, $gpass, $forum_a;
if($abc=='') {
if($aaa=='nic') $aaa = $_SESSION['gnick'];
$query = "SELECT * FROM $guest_tbl WHERE nick='$aaa' AND stat='ok'";
$result = mysql_query($query);
$r = mysql_fetch_array($result);
$in[0] = $r['post'];
$in[1] = $r['nick'];
$in[2] = $r['mail'];
$in[3] = $r['sign'];
$in[4] = $r['www'];
$in[5] = $r['iname'];
$in[6] = $r['admin'];
$in[7] = $r['date'];
$in[8] = $r['avatar'];
return $in;
} else {
$query = "SELECT * FROM $guest_tbl WHERE stat='ok'";
$result = mysql_query($query);
while($r = mysql_fetch_array($result)) {
$in[$r['nick']][0] = $r['post'];
$in[$r['nick']][1] = $r['nick'];
$in[$r['nick']][2] = $r['mail'];
$in[$r['nick']][3] = $r['sign'];
$in[$r['nick']][4] = $r['www'];
$in[$r['nick']][5] = $r['iname'];
$in[$r['nick']][6] = $r['admin'];
$in[$r['nick']][7] = $r['date'];
$in[$r['nick']][8] = $r['avatar'];
}
$query = "SELECT * FROM $forum_a";
$result = mysql_query($query);
while($r = mysql_fetch_array($result)) {
$in[$r['author']][9]++;
}
return $in;
}
}
###############################################################################
###############################################################################
###############################################################################
function user_logout() {
global $jpu_stat, $gnick, $gpass, $members, $guests;
if(file_exists('online/'.$_SESSION[gnick])) unlink('online/'.$_SESSION[gnick]);
$_SESSION[gnick] = '**************************';
$_SESSION[gpass] = '**************************';
$guests++;
$members = $members-1;
header("Location: index.php");
exit;
}
###############################################################################
###############################################################################
###############################################################################
function set_info($var_name, $data) {
global $gnick, $guest_tbl;
$query = "SELECT * FROM $guest_tbl WHERE nick='$_SESSION[gnick]' AND stat='ok'";
$result = mysql_query($query);
$r = mysql_fetch_array($result);
$info = $r['post'];
if($data=='allallall') {
eval($info);
eval($var_name);
foreach($p AS $v_name => $v_data) {
$inf = $inf."\n".'$p['.$v_name.']="'.$v_data.'";';
}
$info = $inf;
} else {
if(substr_count($info, '$p['.$var_name.']')==0) {
$info = $info."\n".'$p['.$var_name.']="'.$data.'";';
} else {
eval($info);
$p[$var_name] = $data;
foreach($p AS $v_name => $v_data) {
$inf = $inf."\n".'$p['.$v_name.']="'.$v_data.'";';
$info = $inf;
}
}
}
$query = "UPDATE $guest_tbl SET post='$info' WHERE nick='$_SESSION[gnick]'";
$result = mysql_query($query);
}
###############################################################################
###############################################################################
###############################################################################
function user_block($size, $punkt)
{
global $pw_tbl, $gnick;
if(is_user_login()=='yes')
{
$pw = (int) mysql_num_rows(mysql_query("SELECT * FROM $pw_tbl WHERE receiver='$_SESSION[gnick]' AND readed='no'"));
echo '
'.$punkt.'lista użytkowników
'.$punkt.'ustawienia profilu
'.$punkt.'wiadomości ('.$pw.')
'.$punkt.'wyloguj';
}
else
{
$size = 140;
echo '
';
}
}
###############################################################################
###############################################################################
###############################################################################
function save_member($nick) {
global $o;
if(is_user_login()=='yes') {
$date = time();
$file=fopen($o."online/"."$nick", "w");
flock($file, 2);
fwrite($file, $date);
flock($file, 3);
fclose($file);
}
}
function act_member($ile) {
global $guest_tbl, $o;
$date = time();
$dir = opendir($o."online");
while($file = readdir($dir)) {
if($file<>'..' AND $file<>'.' AND $file<>'g') {
$when = file($o.'online/'.$file);
$aaa = $when[0]+$ile;
if($date>$aaa) {
if(file_exists($o.'online/'.$file)) unlink($o.'online/'.$file);
} else {
$a++;
}
}
}
return $a;
}
###############################################################################
###############################################################################
###############################################################################
function save_fmember($nick) {
global $o;
if(is_user_login()=='yes') {
$date = time();
$file=fopen($o."online_f/users/"."$nick", "w");
flock($file, 2);
fwrite($file, $date);
flock($file, 3);
fclose($file);
}
}
function act_fmember($ile) {
global $guest_tbl, $o;
$date = time();
$dir = opendir($o."online_f/users");
while($file = readdir($dir)) {
if($file<>'..' AND $file<>'.' AND $file<>'g') {
$when = file($o.'online_f/users/'.$file);
$aaa = $when[0]+$ile;
if($date>$aaa) {
if(file_exists($o.'online_f/users/'.$file)) unlink($o.'online_f/users/'.$file);
} else {
$a++;
}
}
}
return $a;
}
###############################################################################
###############################################################################
###############################################################################
function save_fguest($ile) {
global $REMOTE_ADDR, $o;
if(is_user_login()<>'yes') {
$date = time();
$file=fopen($o."online_f/guests/"."$REMOTE_ADDR", "w");
flock($file, 2);
fwrite($file, $date);
flock($file, 3);
fclose($file);
}
}
function act_fguest($ile) {
global $REMOTE_ADDR, $o;
$date = time();
$dir = opendir($o."online_f/guests");
while($file = readdir($dir)) {
if($file<>'..' AND $file<>'.' AND $file<>'g') {
$when = file($o.'online_f/guests/'.$file);
$aaa = $when[0]+$ile;
if($date>$aaa) {
if(file_exists($o.'online_f/guests/'.$file)) unlink($o.'online_f/guests/'.$file);
} else {
$a++;
}
}
}
return $a;
}
###############################################################################
###############################################################################
###############################################################################
function save_guest($ile) {
global $REMOTE_ADDR, $o;
if(is_user_login()<>'yes') {
$date = time();
$file=fopen($o."online_g/"."$REMOTE_ADDR", "w");
flock($file, 2);
fwrite($file, $date);
flock($file, 3);
fclose($file);
}
}
function act_guest($ile) {
global $REMOTE_ADDR, $o;
$date = time();
$dir = opendir($o."online_g");
while($file = readdir($dir)) {
if($file<>'..' AND $file<>'.' AND $file<>'g') {
$when = file($o.'online_g/'.$file);
$aaa = $when[0]+$ile;
if($date>$aaa) {
if(file_exists($o.'online_g/'.$file)) unlink($o.'online_g/'.$file);
} else {
$a++;
}
}
}
return $a;
}
###############################################################################
###############################################################################
###############################################################################
function save_anonim($nick, $mail) {
setcookie("f_author", "$nick", mktime(1,1,1,1,1,date("Y")+5));
setcookie("f_mail", "$mail", mktime(1,1,1,1,1,date("Y")+5));
}
###############################################################################
###############################################################################
###############################################################################
function save_sort($co, $jak) {
$jak = str_replace("-"," ", $jak);
if($co=='art') setcookie("uart_sort", "$jak", mktime(1,1,1,1,1,date("Y")+5));
if($co=='link') setcookie("ulink_sort", "$jak", mktime(1,1,1,1,1,date("Y")+5));
if($co=='down') setcookie("udown_sort", "$jak", mktime(1,1,1,1,1,date("Y")+5));
return $jak;
}
###############################################################################
###############################################################################
###############################################################################
function avatar($icon, $err='no') {
if($icon<>'') {
if(ereg("^[a-zA-Z0-9]+://[^ ]+$", $icon)) {
//$size = @getimagesize($icon);
if($size[0]<=110 AND $size[1]<=110)
return '
';
else {
if($err=='no') return '
'; else return '(maksymalny rozmiar obrazka to 110px na 110px)';
}
} else {
if($err=='no') return '
'; else return '(niepoprawny format adresu)';
}
}
}
###############################################################################
###############################################################################
###############################################################################
function is_forum_auth() {
global $forum_c, $forum_a, $gnick, $id;
if(is_user_login()=='yes') {
$result_c = mysql_query("SELECT * FROM $forum_a WHERE id='$id'");
$r_ = mysql_fetch_array($result_c);
$category = $r_['cat'];
$qu = "SELECT * FROM $forum_c WHERE id='$category'";
$re = mysql_query($qu);
$r = mysql_fetch_array($re);
$mod = $r['moderator'];
$nick_i = get_user_info();
if($gnick == $mod) return 'yes';
if($nick_i[6] == 'yes') return 'yes';
}
}
###############################################################################
###############################################################################
###############################################################################
function is_forum_admin() {
if(is_user_login()=='yes') {
$a = get_user_info();
if($a[6]=='yes') return 'yes';
else return 'no';
}
}
###############################################################################
###############################################################################
###############################################################################
function check_ip() {
global $REMOTE_ADDR, $ban_tbl, $site_name, $mailer;
$qu = "SELECT * FROM $ban_tbl WHERE ip='$REMOTE_ADDR'";
$re = mysql_query($qu);
$nu = mysql_num_rows($re);
if($nu>0 AND is_login()<>'yes') {
echo '
'.$site_name.' - brak dostępu
| Brak dostępu! |
 |
Dostęp dla IP tego komputera ('.$REMOTE_ADDR.') jest zablokowany! Jeżeli ten komputer jest ogólnie
dostępny (kafejka internetowa, biblioteka, szkoła, świetlica itp.) poinformuj o tym administratora
strony pisząc na ten adres.
|
 |
';
exit;
}
}
function odetnij($co, $ile) {
$i = strlen($co);
$co = substr($co, 0, $ile);
$co = str_replace(' ', ' ', $co);
return $co;
}
$head_info .= '
';
?>