Copyright (C) 2007 nso Copyright (C) 2007 Espen Volden Copyright (c) 2007 Victor Vikene This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ************************************************************************************/ include('init.php'); include($includedir . 'header.php'); $passchange = FALSE; switch ($_REQUEST['a']) { default: if(!isset($_SESSION['uid'])) { die("not logged in"); } $uid = $_SESSION['uid']; break; case "showmyprofile": if(!isset($_SESSION['uid'])) { die("not logged in"); } $uid = $_SESSION['uid']; break; case "showprofile": $uid = $_GET['uid']; if(!isset($uid) or $uid == 0) { dialogbox($lang['userdontexist'], 'warning'); include($includedir . 'tail.php'); die(); } break; case "changepwform": $uid = $_GET['uid']; $passchange = TRUE; break; case "changepw": $pwcheck = $_POST['pwcheck']; $passwd = $_POST['pass']; $uid = $_SESSION['uid']; if ($chngpw($pwcheck, $passwd, $uid)) { dialogbox($lang['passwordchanged'], 'info'); } else { dialogbox($lang['passwordsnotequal'], 'warning'); $passchange = TRUE; } break; case "logout": session_destroy(); die("logged out"); break; } // Caching enabled? if($tplcache) { $xtpl = new CachingXTemplate('user.xtpl', $tpldir, null, 'main', true, 0, $cacheuniqid, $cachedir, $cacheext); } else { $xtpl = new XTemplate('user.xtpl', $tpldir); } // Show the user-submenu if the user browsing own profile if($uid === $_SESSION['uid']) { $rows = ''; $rows[1]=array('MENU_ALT' => $lang['changepassword'], 'LINK' => CHANGEPWFORM ); $rows[2]=array('MENU_ALT' => $lang['myimages'], 'LINK' => SHOWUSERSIMAGES ); $rows[3]=array('MENU_ALT' => $lang['myprofile'], 'LINK' => SHOWUSERSPROFILE ); for ($i = 1; $i <= count($rows); $i++) { $xtpl->assign('TEXT', $rows[$i]); $xtpl->parse('main.showmenu.row'); } $xtpl->parse('main.showmenu'); } // If the user has requestet a password change if($passchange) { $xtpl->assign('TEXT_NEWPASSWORD', $lang['newpassword']); $xtpl->assign('TEXT_RETYPEPASSWORD', $lang['retype_password']); $xtpl->assign('TEXT_CHANGEPASS', $lang['changepassword']); $xtpl->assign('PASSWORDCHANGEURL', CHANGEPW); $xtpl->parse('main.passwordchange'); $xtpl->parse('main'); $xtpl->out('main'); include($includedir . 'tail.php'); die(); } $db = new dbcon(); //Initialize the database. $uid = mysql_real_escape_string($uid,$db->link); $sql = "SELECT * FROM `%slusers` WHERE `uid` = '$uid'"; $db->query($sql); $bruker = mysql_fetch_array($db->result); $brukernavn = $bruker['username']; //Brukernavn $userlevel = $bruker['userlevel']; $registrert = date("d.m.y",$bruker['date']); //Registrert dato. $sql = "SELECT SUM(views) AS `views` FROM `%sfiles` WHERE `owner` = '$uid'"; $db->query($sql); $rarray = mysql_fetch_array($db->result); $views = $rarray['views']; $sql = "SELECT `id` FROM `%sfiles` WHERE `owner` = '$uid'"; $db->query($sql); $nums = mysql_num_rows($db->result); $xtpl->assign('TEXT_REGISTERED', $lang['registered']); $xtpl->assign('TEXT_USERNAME', $lang['username']); $xtpl->assign('TEXT_IMAGECOUNT', $lang['imagecount']); $xtpl->assign('SHOWIMAGESURL', SHOWIMAGES.$uid); $xtpl->assign('UID', $uid); $xtpl->assign('USERNAME', $brukernavn); $xtpl->assign('REGISTERED', $registrert); $xtpl->assign('NUMS', $nums); // Here we'll parse the userinfo $xtpl->parse('main.userinfo'); // Show the template and language select if the user browsing own profile if($uid === $_SESSION['uid']) { $xtpl->assign('TEXT_SELECT', $lang['select']); /* Template select */ for ($i = 1; $i <= count($tpls); $i++) { $xtpl->assign('TPLNAME', $tpls[$i]['TPLNAME']); $xtpl->assign('TPLNUMBER', $i); $xtpl->parse('main.templateselect.options'); } $xtpl->assign('TPLCHANGEURL', TPLCHANGE); $xtpl->assign('TEXT_CHOICETEMPLATE', $lang['choicetemplate']); $xtpl->parse('main.templateselect'); /* Language select */ for ($i = 1; $i <= count($langs); $i++) { $xtpl->assign('LANGNAME', $langs[$i]['LANGNAME']); $xtpl->assign('LANGNUMBER', $i); $xtpl->parse('main.languageselect.options'); } $xtpl->assign('LANGCHANGEURL', LANGCHANGE); $xtpl->assign('TEXT_CHOICELANGUAGE', $lang['choicelanguage']); $xtpl->parse('main.languageselect'); if($userlevel == ADMIN) { $xtpl->assign('TEXT_DELETE', $lang['delete']); $xtpl->assign('TEXT_APPROVE', $lang['approve']); $xtpl->assign('TEXT_VIEWS', $lang['shows']); $query = "SELECT * FROM `files` WHERE `flagged` = '1'"; $result = mysql_query($query); while ($item = mysql_fetch_array($result)) { if ($simpleurl) { $imgurl = $burl.$item['id']; } else { $imgurl = $burl.$item['id'].'x'.$item['code']; } $xtpl->assign('admin', array('IMGURL' => $imgurl)); $xtpl->assign('admin', array('VIEWS' => $item['views'])); $xtpl->assign('admin', array('IMGSOURCEURL' => $imgurl . '.jpg')); $xtpl->assign('admin', array('DEL_REPORTED_IMG_URL' => ADMIN_DEL_REPORTED_IMG)); $xtpl->assign('admin', array('APPROVE_REPORTED_IMG_URL' => ADMIN_APPROVE_REPORTED_IMG)); $xtpl->parse('main.admin_reported_table.reported_rows'); } $xtpl->parse('main.admin_reported_table'); } } // Here we'll parse the data for the whole function $xtpl->parse('main'); // Finally we parse the variables to the templatefile $xtpl->out('main'); // Never underestimate the power of a boiled tail include($includedir . 'tail.php'); ?>