2025-06-23 20:13:52 +02:00
< ? php global $session ;
2025-06-20 19:10:23 +02:00
/**
2025-06-20 20:13:51 +02:00
* Project : BeCast WebEngine - simple site engine
* File : / admin / editusers . apnl . php
2025-06-20 19:10:23 +02:00
*
* This library is free software ; you can redistribute it and / or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation ; either
* version 2.1 of the License , or ( at your option ) any later version .
*
* This library 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
* Lesser General Public License for more details .
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*
2025-06-20 20:13:51 +02:00
* @ link http :// www . becast . at
* @ copyright 2009 - 2025 becast . at
2025-06-20 19:10:23 +02:00
* @ author Bernhard Jaud < bernhard at becast dot at >
2025-06-20 20:13:51 +02:00
* @ package BcWe core
2025-06-20 19:10:23 +02:00
* @ license http :// opensource . org / licenses / gpl - license . php GNU Public License
* @ version $Id $
*/
2025-06-23 19:41:29 +02:00
If ( ! defined ( " IN_BCWE_ADMIN " )) {
2025-06-20 19:10:23 +02:00
die ( " Dieses Script kann nicht ausserhalb des Frameworks laufen! " );
}
$addnav [ " right " ] = FALSE ;
$session -> page_begin ( " edituser " , True );
class editusers_panel extends admin_module {
function output (){
global $plugin , $session , $config , $db , $panel , $admin , $module , $root , $firephp , $lang ;
if ( isset ( $_GET [ " edituser " ]) && $_GET [ " edituser " ] != " " ){
if ( isset ( $_POST [ " send " ]) && ! empty ( $_POST [ " name " ]) && ! empty ( $_POST [ " uid " ])){
$pwd = " " ;
if ( $_POST [ 'role' ] == 2 && $session -> userdata [ 'role' ] != 2 ){
2025-06-20 20:13:51 +02:00
$panel -> admin_message ( $lang -> _ ( 'ERROR' ), $lang -> _ ( 'CANTASSIGNHIGHERRIGHT' ), True , " editusers " , 3 );
2025-06-20 19:10:23 +02:00
}
$_POST [ 'key' ] = $session -> generate_key ( 50 );
2025-06-20 20:13:51 +02:00
$salt = $session -> generate_Key ( 6 );
2025-06-20 19:10:23 +02:00
if ( $_POST [ " password " ] != " " ){
2025-06-20 20:13:51 +02:00
$pwd = " , `password`=' " . hash ( " sha256 " , $salt . $db -> escape ( $_POST [ " password " ])) . " ', `loginkey`=' " . $_POST [ 'key' ] . " ',`salt` = ' " . $salt . " ' " ;
2025-06-20 19:10:23 +02:00
}
2025-06-24 21:56:48 +02:00
$plugin -> run_hook ( 'admin_user_before_update' , array ( 'data' => $_POST , 'user_fid' => $session -> userdata [ 'fuid' ]));
2025-06-20 20:13:51 +02:00
$db -> query ( " UPDATE ` " . $config [ " prefix " ] . " users` SET `username`=' " . $db -> escape ( $_POST [ " name " ]) . " ',`realname`=' " . $db -> escape ( $_POST [ " realname " ]) . " ',`email`=' " . $db -> escape ( $_POST [ " email " ]) . " ',`from`=' " . $db -> escape ( $_POST [ " from " ]) . " ',`gender`=' " . $db -> escape ( $_POST [ " gender " ]) . " ',`bio`=' " . $db -> escape ( $_POST [ " bio " ]) . " ',`homepage`=' " . $db -> escape ( $_POST [ " homepage " ]) . " ',`role`=' " . $db -> escape ( $_POST [ " role " ]) . " ',`active`=' " . $db -> escape ( $_POST [ " active " ]) . " ', " . $pwd . " WHERE `uid`=' " . intval ( $_POST [ " uid " ]) . " ' " );
2025-06-20 19:10:23 +02:00
$_POST [ 'user_fid' ] = $session -> userdata [ 'fuid' ];
$plugin -> run_hook ( 'admin_user_after_update' , array ( 'data' => $_POST ));
$panel -> admin_message ( $lang -> _ ( 'SUCCESS' ), $lang -> _ ( 'DATASAVED' ), True , " editusers " , 3 );
} else {
$panel -> title = $lang -> _ ( 'EDITUSER' );
$panel -> form ( array ( " action " => $config [ " path " ] . " /admin/index.php?panel=editusers&edituser= " . $_GET [ " edituser " ]));
$result = $db -> query ( " SELECT * FROM ` " . $config [ " prefix " ] . " users` WHERE uid=' " . intval ( $_GET [ " edituser " ]) . " ' " );
$data = $db -> fetch_array ( $result );
$panel -> content .= " <h3> " . $lang -> _ ( 'USERNAME' ) . " :</h3> " ;
$panel -> field ( array ( " name " => " name " , " typ " => " text " , " value " => $data [ " username " ]));
$panel -> content .= " <h3> " . $lang -> _ ( 'REALNAME' ) . " :</h3> " ;
$panel -> field ( array ( " name " => " realname " , " typ " => " text " , " value " => $data [ " realname " ]));
$panel -> content .= " <h3> " . $lang -> _ ( 'MAIL' ) . " :</h3> " ;
$panel -> field ( array ( " name " => " email " , " value " => $data [ " email " ], " typ " => " text " ));
$panel -> content .= " <h3> " . $lang -> _ ( 'PASSWORD' ) . " :</h3> " ;
$panel -> field ( array ( " name " => " password " , " value " => " " , " typ " => " password " ));
$panel -> content .= " <h3> " . $lang -> _ ( 'LOCATION' ) . " :</h3> " ;
$panel -> field ( array ( " name " => " from " , " value " => $data [ " from " ], " typ " => " text " ));
$panel -> content .= " <h3> " . $lang -> _ ( 'GENDER' ) . " :</h3> " ;
2025-06-20 20:13:51 +02:00
$panel -> select ( array ( $lang -> _ ( 'DIV' ) => " u " , $lang -> _ ( 'FEMALE' ) => " f " , $lang -> _ ( 'MALE' ) => " m " ), $data [ " gender " ], " gender " );
2025-06-20 19:10:23 +02:00
$panel -> content .= " <h3> " . $lang -> _ ( 'HOMEPAGE' ) . " :</h3> " ;
$panel -> field ( array ( " name " => " homepage " , " value " => $data [ " homepage " ], " typ " => " text " ));
$panel -> content .= " <h3> " . $lang -> _ ( 'BANREASON' ) . " :</h3> " ;
$panel -> textarea ( array ( " name " => " bio " , " value " => $data [ " bio " ], " typ " => " text " ));
$panel -> content .= " <br /> " ;
$panel -> content .= " <h3> " . $lang -> _ ( 'ROLE' ) . " :</h3> " ;
$result = $db -> query ( " SELECT `id`,`role_name` FROM ` " . $config [ " prefix " ] . " role` " );
while ( $rdata = $db -> fetch_array ( $result )){
$dd [ $rdata [ " role_name " ]] = $rdata [ " id " ];
}
$panel -> select ( $dd , $data [ " role " ], " role " );
$panel -> content .= " <br /> " ;
$panel -> content .= " <h3> " . $lang -> _ ( 'STATUS' ) . " :</h3> " ;
$panel -> select ( array ( $lang -> _ ( 'ACTIVE' ) => 1 , $lang -> _ ( 'INACTIVE' ) => 0 , $lang -> _ ( 'BANNED' ) => 2 ), $data [ " active " ], " active " );
2025-06-20 20:13:51 +02:00
$panel -> content .= " <br /> " ;
2025-06-20 19:10:23 +02:00
$panel -> field ( array ( " name " => " send " , " typ " => " hidden " , " value " => " 1 " ));
$panel -> field ( array ( " name " => " uid " , " typ " => " hidden " , " value " => $data [ " uid " ]));
$panel -> content .= " <br /> " ;
$panel -> submit ();
$panel -> formClose ();
$panel -> parse_page ();
}
2025-06-23 20:27:41 +02:00
} elseif ( isset ( $_GET [ " action " ]) && $_GET [ " action " ] == " delete " && isset ( $_GET [ " user " ])){
2025-06-20 19:10:23 +02:00
$result = $db -> query ( " SELECT * FROM ` " . $config [ " prefix " ] . " users` WHERE `uid`=' " . intval ( $_GET [ " user " ]) . " ' " );
$data = $db -> fetch_array ( $result );
$plugin -> run_hook ( 'admin_user_before_delete' , array ( 'data' => $data ));
$db -> query ( " DELETE FROM ` " . $config [ " prefix " ] . " users` WHERE `uid`=' " . intval ( $_GET [ " user " ]) . " ' " );
$plugin -> run_hook ( 'admin_user_after_delete' , array ( 'data' => $data ));
2025-06-20 20:13:51 +02:00
$panel -> admin_message ( $lang -> _ ( 'USERDELETED' ), $lang -> _ ( 'USERDELETEDSUCCESS' ), True , " editusers " , 3 );
2025-06-20 19:10:23 +02:00
} else {
$left = " " ;
$right = " " ;
$asmodule = " " ;
$mainmodule = " " ;
$result = $db -> query ( " SELECT * FROM ` " . $config [ " prefix " ] . " users` u LEFT JOIN ` " . $config [ " prefix " ] . " role` r ON r.id=u.role ORDER BY u.`uid` " );
while ( $row = $db -> fetch_array ( $result )){
$user [] = $row ;
}
$panel -> title = $lang -> _ ( 'USERS' );
2025-06-24 21:25:19 +02:00
$panel -> content .= " <table id= \" users \" style= \" width: 90%; border-spacing: 2px; \" >
2025-06-20 19:10:23 +02:00
< thead >
< tr >
2025-06-24 21:25:19 +02:00
< th style = \ " text-align: center; \" > " . $lang -> _ ( 'ID' ) . " </th>
< th style = \ " text-align: center; \" > " . $lang -> _ ( 'USERNAME' ) . " </th>
< th style = \ " text-align: center; \" > " . $lang -> _ ( 'REALNAME' ) . " </th>
< th style = \ " text-align: center; \" > " . $lang -> _ ( 'ROLE' ) . " </th>
< th style = \ " text-align: center; \" > " . $lang -> _ ( 'STATUS' ) . " </th>
< th style = \ " text-align: center; \" > " . $lang -> _ ( 'ACTION' ) . " </th>
2025-06-20 19:10:23 +02:00
</ tr ></ thead >< tbody > " ;
if ( ! empty ( $user )){
foreach ( $user as $u ){
if ( $u [ 'active' ] == 1 ){
$u [ 'activetext' ] = $lang -> _ ( 'ACTIVE' );
2025-06-20 20:13:51 +02:00
$u [ 'activestyle' ] = '' ;
2025-06-20 19:10:23 +02:00
} elseif ( $u [ 'active' ] == 2 ){
$u [ 'activetext' ] = $lang -> _ ( 'BANNED' );
2025-06-20 20:13:51 +02:00
$u [ 'activestyle' ] = 'style="text-decoration:line-through;"' ;
2025-06-20 19:10:23 +02:00
} else {
$u [ 'activetext' ] = $lang -> _ ( 'INACTIVE' );
2025-06-20 20:13:51 +02:00
$u [ 'activestyle' ] = 'style="font-style:italic;"' ;
2025-06-20 19:10:23 +02:00
}
2025-06-20 20:13:51 +02:00
$panel -> content .= " <tr " . $u [ 'activestyle' ] . " >
2025-06-24 21:25:19 +02:00
< td style = \ " text-align: center; \" > " . $u [ " uid " ] . " </td>
< td style = \ " text-align: center; \" > " . $u [ " username " ] . " </td>
< td style = \ " text-align: center; \" > " . $u [ " realname " ] . " </td>
< td style = \ " text-align: center; \" > " . $u [ " role_name " ] . " </td>
< td style = \ " text-align: center; \" > " . $u [ 'activetext' ] . " </td> " ;
2025-06-20 19:10:23 +02:00
if ( $u [ " uid " ] == $session -> userdata [ " uid " ]){
2025-06-24 21:25:19 +02:00
$panel -> content .= " <td style= \" text-align: center; \" ><a onclick= \" return confirmLink(this,' " . $lang -> _ ( 'BADIDEA' ) . " ') \" href= \" " . $config [ " path " ] . " /admin/index.php?panel=editusers&action=delete&user= " . $u [ " uid " ] . " \" ><img src= \" " . $config [ " path " ] . " /admin/images/icons/delete.png \" /></a> <a href= \" " . $config [ " path " ] . " /admin/index.php?panel=editusers&edituser= " . $u [ " uid " ] . " \" ><img src= \" " . $config [ " path " ] . " /admin/images/icons/wrench.png \" /></a></td>
2025-06-20 19:10:23 +02:00
</ tr > " ;
} else {
2025-06-24 21:25:19 +02:00
$panel -> content .= " <td style= \" text-align: center; \" ><a onclick= \" return confirmLink(this, ' " . sprintf ( $lang -> _ ( 'DELETEUSER' ), $u [ " username " ]) . " ') \" href= \" " . $config [ " path " ] . " /admin/index.php?panel=editusers&action=delete&user= " . $u [ " uid " ] . " \" ><img src= \" " . $config [ " path " ] . " /admin/images/icons/delete.png \" /></a> <a href= \" " . $config [ " path " ] . " /admin/index.php?panel=editusers&edituser= " . $u [ " uid " ] . " \" ><img src= \" " . $config [ " path " ] . " /admin/images/icons/wrench.png \" /></a></td>
2025-06-20 19:10:23 +02:00
</ tr > " ;
}
}
} else {
$panel -> content .= " <tr>
2025-06-24 21:25:19 +02:00
< td style = \ " text-align: center; \" colspan= \" 5 \" > " . $lang -> _ ( 'NOUSERS' ) . " </td>
2025-06-20 19:10:23 +02:00
</ tr > " ;
}
$panel -> content .= " </tbody></table><br /> " ;
}
}
function meta () {
global $module , $config , $db , $panel , $userinfo , $admin , $root ;
$meta = '<script src="' . $config [ " path " ] . ' / js / jquery / jquery . min . js " type= " text / javascript " >
</ script >
< script src = " '. $config["path"] .'/js/datatables/js/jquery.dataTables.min.js " type = " text/javascript " >
</ script >
< link type = " text/css " rel = " stylesheet " media = " screen " href = " '. $config["path"] .'/js/datatables/css/jquery.dataTables.css " />
< style type = " text/css " >
. loadlayer {
position : absolute ;
padding : 15 px ;
width : 250 px ;
background : #ffffff;
border : 3 px solid #c90000;
text - align : center ;
margin - top : 60 px ;
left : 50 % ;
margin - left : - 150 px ;
margin - top : 100 px ;
font - weight : bold ;
z - index : 5 ;
}
div . section , div #createNew {
border : 1 px solid #CCCCCC;
margin : 30 px 5 px ;
padding : 0 px 0 px 10 px 0 px ;
background - color : #EFEFEF;
}
div #createNew input { margin-left: 5px; }
div #createNew h3, div.section h3{
font - size : 14 px ;
padding : 2 px 5 px ;
margin : 0 0 10 px 0 ;
background - color : #CCCCCC;
display : block ;
}
div . section h3 {
cursor : move ;
}
div . lineitem {
margin : 3 px 10 px ;
padding : 2 px ;
background - color : #FFFFFF;
cursor : move ;
}
h1 {
margin - bottom : 0 ;
font - size : 18 px ;
}
</ style >
< script type = " text/javascript " >
function confirmLink ( theLink , text )
{
// Confirmation is not required in the configuration file
// or browser is Opera (crappy js implementation)
if ( typeof ( window . opera ) != \ ' undefined\ ' ) {
return true ;
}
var is_confirmed = confirm ( text );
if ( is_confirmed ) {
if ( typeof ( theLink . href ) != \ ' undefined\ ' ) {
theLink . href += \ ' & is_js_confirmed = 1 \ ' ;
} else if ( typeof ( theLink . form ) != \ ' undefined\ ' ) {
theLink . form . action += \ ' ? is_js_confirmed = 1 \ ' ;
}
}
return is_confirmed ;
}
</ script >
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
$ ( \ ' #users\').dataTable();
} );
</ script > ' ;
return $meta ;
}
}
?>