2011-03-28 14:21:28 +00:00
< ?
/*****************************************************************
Tools switch center
This page acts as a switch for the tools pages .
TODO !
- Unify all the code standards and file names ( tool_list . php , tool_add . php , tool_alter . php )
*****************************************************************/
2013-04-13 08:00:19 +00:00
if ( isset ( $argv [ 1 ])) {
if ( $argv [ 1 ] == " cli_sandbox " ) {
2011-03-28 14:21:28 +00:00
include ( " misc/cli_sandbox.php " );
die ();
}
$_REQUEST [ 'action' ] = $argv [ 1 ];
} else {
2013-04-13 08:00:19 +00:00
if ( empty ( $_REQUEST [ 'action' ]) || ( $_REQUEST [ 'action' ] != " public_sandbox " && $_REQUEST [ 'action' ] != " ocelot " )) {
2011-03-28 14:21:28 +00:00
enforce_login ();
}
}
2013-04-13 08:00:19 +00:00
if ( ! isset ( $_REQUEST [ 'action' ])) {
2011-03-28 14:21:28 +00:00
include ( SERVER_ROOT . '/sections/tools/tools.php' );
die ();
}
if ( substr ( $_REQUEST [ 'action' ], 0 , 7 ) == 'sandbox' && ! isset ( $argv [ 1 ])) {
if ( ! check_perms ( 'site_debug' )) {
error ( 403 );
}
}
2011-09-14 08:00:13 +00:00
if ( substr ( $_REQUEST [ 'action' ], 0 , 12 ) == 'update_geoip' && ! isset ( $argv [ 1 ])) {
if ( ! check_perms ( 'site_debug' )) {
error ( 403 );
}
}
2011-03-28 14:21:28 +00:00
include ( SERVER_ROOT . " /classes/class_validate.php " );
$Val = NEW VALIDATE ;
include ( SERVER_ROOT . '/classes/class_feed.php' );
$Feed = new FEED ;
switch ( $_REQUEST [ 'action' ]){
case 'phpinfo' :
if ( ! check_perms ( 'site_debug' )) error ( 403 );
phpinfo ();
break ;
//Services
case 'get_host' :
include ( 'services/get_host.php' );
break ;
case 'get_cc' :
include ( 'services/get_cc.php' );
break ;
//Managers
case 'forum' :
include ( 'managers/forum_list.php' );
break ;
case 'forum_alter' :
include ( 'managers/forum_alter.php' );
break ;
case 'whitelist' :
include ( 'managers/whitelist_list.php' );
break ;
case 'whitelist_alter' :
include ( 'managers/whitelist_alter.php' );
break ;
case 'login_watch' :
include ( 'managers/login_watch.php' );
break ;
case 'recommend' :
include ( 'managers/recommend_list.php' );
break ;
case 'recommend_add' :
include ( 'managers/recommend_add.php' );
break ;
case 'recommend_alter' :
include ( 'managers/recommend_alter.php' );
break ;
2013-02-22 08:00:24 +00:00
2013-01-01 08:00:24 +00:00
case 'recommend_restore' :
include ( 'managers/recommend_restore.php' );
break ;
2011-03-28 14:21:28 +00:00
case 'email_blacklist' :
include ( 'managers/eb.php' );
break ;
case 'eb_alter' :
include ( 'managers/eb_alter.php' );
2013-01-21 08:00:33 +00:00
break ;
2013-02-22 08:00:24 +00:00
2013-01-21 08:00:33 +00:00
case 'eb_search' :
include ( 'managers/eb_search.php' );
2011-03-28 14:21:28 +00:00
break ;
case 'dnu' :
include ( 'managers/dnu_list.php' );
break ;
case 'dnu_alter' :
include ( 'managers/dnu_alter.php' );
break ;
case 'editnews' :
case 'news' :
include ( 'managers/news.php' );
break ;
case 'takeeditnews' :
2013-04-13 08:00:19 +00:00
if ( ! check_perms ( 'admin_manage_news' )) {
error ( 403 );
}
if ( is_number ( $_POST [ 'newsid' ])){
2011-03-28 14:21:28 +00:00
$DB -> query ( " UPDATE news SET Title=' " . db_string ( $_POST [ 'title' ]) . " ', Body=' " . db_string ( $_POST [ 'body' ]) . " ' WHERE ID=' " . db_string ( $_POST [ 'newsid' ]) . " ' " );
$Cache -> delete_value ( 'news' );
$Cache -> delete_value ( 'feed_news' );
}
header ( 'Location: index.php' );
break ;
case 'deletenews' :
2013-04-13 08:00:19 +00:00
if ( ! check_perms ( 'admin_manage_news' )) {
error ( 403 );
}
if ( is_number ( $_GET [ 'id' ])){
2011-03-28 14:21:28 +00:00
authorize ();
$DB -> query ( " DELETE FROM news WHERE ID=' " . db_string ( $_GET [ 'id' ]) . " ' " );
$Cache -> delete_value ( 'news' );
$Cache -> delete_value ( 'feed_news' );
// Deleting latest news
$LatestNews = $Cache -> get_value ( 'news_latest_id' );
2013-04-13 08:00:19 +00:00
if ( $LatestNews !== false && $LatestNews == $_GET [ 'id' ]) {
2011-03-28 14:21:28 +00:00
$Cache -> delete_value ( 'news_latest_id' );
}
}
header ( 'Location: index.php' );
break ;
case 'takenewnews' :
2013-04-13 08:00:19 +00:00
if ( ! check_perms ( 'admin_manage_news' )) {
error ( 403 );
}
2011-03-28 14:21:28 +00:00
$DB -> query ( " INSERT INTO news (UserID, Title, Body, Time) VALUES (' $LoggedUser[ID] ', ' " . db_string ( $_POST [ 'title' ]) . " ', ' " . db_string ( $_POST [ 'body' ]) . " ', ' " . sqltime () . " ') " );
2013-02-22 08:00:24 +00:00
2012-10-27 08:00:09 +00:00
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
$Cache -> cache_value ( 'news_latest_id' , $DB -> inserted_id (), 0 );
$Cache -> delete_value ( 'news' );
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
header ( 'Location: index.php' );
break ;
2013-02-22 08:00:24 +00:00
2011-10-08 08:00:14 +00:00
case 'tokens' :
include ( 'managers/tokens.php' );
break ;
2011-10-17 08:00:16 +00:00
case 'ocelot' :
include ( 'managers/ocelot.php' );
break ;
2012-02-10 08:00:19 +00:00
case 'official_tags' :
include ( 'managers/official_tags.php' );
break ;
2011-03-28 14:21:28 +00:00
2013-02-07 08:00:47 +00:00
case 'tag_aliases' :
include ( 'managers/tag_aliases.php' );
break ;
case 'permissions' :
2013-04-13 08:00:19 +00:00
if ( ! check_perms ( 'admin_manage_permissions' )) {
error ( 403 );
}
2011-03-28 14:21:28 +00:00
if ( ! empty ( $_REQUEST [ 'id' ])) {
$Val -> SetFields ( 'name' , true , 'string' , 'You did not enter a valid name for this permission set.' );
$Val -> SetFields ( 'level' , true , 'number' , 'You did not enter a valid level for this permission set.' );
2011-10-17 08:00:16 +00:00
$Val -> SetFields ( 'maxcollages' , true , 'number' , 'You did not enter a valid number of personal collages.' );
2011-03-28 14:21:28 +00:00
//$Val->SetFields('test',true,'number','You did not enter a valid level for this permission set.');
if ( is_numeric ( $_REQUEST [ 'id' ])) {
2012-03-28 08:00:20 +00:00
$DB -> query ( " SELECT p.ID,p.Name,p.Level,p.Secondary,p.PermittedForums,p.Values,p.DisplayStaff,COUNT(u.ID) FROM permissions AS p LEFT JOIN users_main AS u ON u.PermissionID=p.ID WHERE p.ID=' " . db_string ( $_REQUEST [ 'id' ]) . " ' GROUP BY p.ID " );
list ( $ID , $Name , $Level , $Secondary , $Forums , $Values , $DisplayStaff , $UserCount ) = $DB -> next_record ( MYSQLI_NUM , array ( 5 ));
2011-03-28 14:21:28 +00:00
2013-04-13 08:00:19 +00:00
if ( $Level > $LoggedUser [ 'EffectiveClass' ] || $_REQUEST [ 'level' ] > $LoggedUser [ 'EffectiveClass' ]) {
2011-07-13 08:00:06 +00:00
error ( 403 );
}
2012-03-28 08:00:20 +00:00
$Values = unserialize ( $Values );
2013-02-22 08:00:24 +00:00
}
2011-03-28 14:21:28 +00:00
if ( ! empty ( $_POST [ 'submit' ])) {
$Err = $Val -> ValidateForm ( $_POST );
if ( ! is_numeric ( $_REQUEST [ 'id' ])) {
$DB -> query ( " SELECT ID FROM permissions WHERE Level=' " . db_string ( $_REQUEST [ 'level' ]) . " ' " );
list ( $DupeCheck ) = $DB -> next_record ();
if ( $DupeCheck ) {
$Err = " There is already a permission class with that level. " ;
}
}
$Values = array ();
foreach ( $_REQUEST as $Key => $Perms ) {
2013-04-13 08:00:19 +00:00
if ( substr ( $Key , 0 , 5 ) == 'perm_' ) {
$Values [ substr ( $Key , 5 )] = ( int ) $Perms ;
}
2011-03-28 14:21:28 +00:00
}
2013-04-13 08:00:19 +00:00
$Name = $_REQUEST [ 'name' ];
$Level = $_REQUEST [ 'level' ];
$Secondary = empty ( $_REQUEST [ 'secondary' ]) ? 0 : 1 ;
2012-03-28 08:00:20 +00:00
$Forums = $_REQUEST [ 'forums' ];
2013-04-13 08:00:19 +00:00
$DisplayStaff = $_REQUEST [ 'displaystaff' ];
$Values [ 'MaxCollages' ] = $_REQUEST [ 'maxcollages' ];
2011-03-28 14:21:28 +00:00
if ( ! $Err ) {
if ( ! is_numeric ( $_REQUEST [ 'id' ])) {
2012-03-28 08:00:20 +00:00
$DB -> query ( " INSERT INTO permissions (Level,Name,Secondary,PermittedForums,`Values`,DisplayStaff)
2013-02-07 08:00:47 +00:00
VALUES ( '".db_string($Level)."' ,
'".db_string($Name)."' ,
2012-03-28 08:00:20 +00:00
" . $Secondary . " ,
'".db_string($Forums)."' ,
'".db_string(serialize($Values))."' ,
'".db_string($DisplayStaff)."' ) " );
2011-03-28 14:21:28 +00:00
} else {
2012-03-28 08:00:20 +00:00
$DB -> query ( " UPDATE permissions SET Level=' " . db_string ( $Level ) . " ',
2013-02-07 08:00:47 +00:00
Name = '".db_string($Name)."' ,
2012-03-28 08:00:20 +00:00
Secondary = " . $Secondary . " ,
PermittedForums = '".db_string($Forums)."' ,
`Values` = '".db_string(serialize($Values))."' ,
DisplayStaff = '".db_string($DisplayStaff)."'
WHERE ID = '".db_string($_REQUEST[' id '])."' " );
2011-03-28 14:21:28 +00:00
$Cache -> delete_value ( 'perm_' . $_REQUEST [ 'id' ]);
2012-03-28 08:00:20 +00:00
if ( $Secondary ) {
$DB -> query ( " SELECT DISTINCT UserID FROM users_levels WHERE PermissionID = " . db_string ( $_REQUEST [ 'id' ]));
while ( $UserID = $DB -> next_record ()) {
$Cache -> delete_value ( 'user_info_heavy_' . $UserID );
}
}
2011-03-28 14:21:28 +00:00
}
$Cache -> delete_value ( 'classes' );
} else {
error ( $Err );
}
}
include ( 'managers/permissions_alter.php' );
} else {
if ( ! empty ( $_REQUEST [ 'removeid' ])) {
$DB -> query ( " DELETE FROM permissions WHERE ID=' " . db_string ( $_REQUEST [ 'removeid' ]) . " ' " );
2012-03-28 08:00:20 +00:00
$DB -> query ( " SELECT UserID FROM users_levels WHERE PermissionID=' " . db_string ( $_REQUEST [ 'removeid' ]) . " ' " );
while ( list ( $UserID ) = $DB -> next_record ()) {
$Cache -> delete_value ( 'user_info_' . $UserID );
$Cache -> delete_value ( 'user_info_heavy_' . $UserID );
}
$DB -> query ( " DELETE FROM users_levels WHERE PermissionID=' " . db_string ( $_REQUEST [ 'removeid' ]) . " ' " );
$DB -> query ( " SELECT ID FROM users_main WHERE PermissionID=' " . db_string ( $_REQUEST [ 'removeid' ]) . " ' " );
while ( list ( $UserID ) = $DB -> next_record ()) {
$Cache -> delete_value ( 'user_info_' . $UserID );
$Cache -> delete_value ( 'user_info_heavy_' . $UserID );
}
2011-03-28 14:21:28 +00:00
$DB -> query ( " UPDATE users_main SET PermissionID=' " . USER . " ' WHERE PermissionID=' " . db_string ( $_REQUEST [ 'removeid' ]) . " ' " );
$Cache -> delete_value ( 'classes' );
}
include ( 'managers/permissions_list.php' );
}
break ;
case 'ip_ban' :
//TODO: Clean up db table ip_bans.
include ( " managers/bans.php " );
break ;
2012-07-22 08:00:16 +00:00
case 'quick_ban' :
include ( " misc/quick_ban.php " );
break ;
2011-03-28 14:21:28 +00:00
//Data
case 'registration_log' :
include ( 'data/registration_log.php' );
break ;
case 'donation_log' :
include ( 'data/donation_log.php' );
break ;
case 'upscale_pool' :
include ( 'data/upscale_pool.php' );
break ;
case 'invite_pool' :
include ( 'data/invite_pool.php' );
break ;
case 'torrent_stats' :
include ( 'data/torrent_stats.php' );
break ;
case 'user_flow' :
include ( 'data/user_flow.php' );
break ;
case 'economic_stats' :
include ( 'data/economic_stats.php' );
break ;
case 'opcode_stats' :
include ( 'data/opcode_stats.php' );
break ;
case 'service_stats' :
include ( 'data/service_stats.php' );
break ;
case 'database_specifics' :
include ( 'data/database_specifics.php' );
break ;
case 'special_users' :
include ( 'data/special_users.php' );
break ;
case 'browser_support' :
include ( 'data/browser_support.php' );
break ;
//END Data
//Misc
case 'update_geoip' :
include ( 'misc/update_geoip.php' );
break ;
case 'dupe_ips' :
include ( 'misc/dupe_ip.php' );
break ;
case 'clear_cache' :
include ( 'misc/clear_cache.php' );
break ;
case 'create_user' :
include ( 'misc/create_user.php' );
break ;
case 'manipulate_tree' :
include ( 'misc/manipulate_tree.php' );
break ;
case 'recommendations' :
include ( 'misc/recommendations.php' );
break ;
case 'analysis' :
include ( 'misc/analysis.php' );
break ;
case 'sandbox1' :
include ( 'misc/sandbox1.php' );
break ;
case 'sandbox2' :
include ( 'misc/sandbox2.php' );
break ;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'sandbox3' :
include ( 'misc/sandbox3.php' );
break ;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'sandbox4' :
include ( 'misc/sandbox4.php' );
break ;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'sandbox5' :
include ( 'misc/sandbox5.php' );
break ;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'sandbox6' :
include ( 'misc/sandbox6.php' );
break ;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'sandbox7' :
include ( 'misc/sandbox7.php' );
break ;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'sandbox8' :
include ( 'misc/sandbox8.php' );
break ;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'public_sandbox' :
include ( 'misc/public_sandbox.php' );
break ;
case 'mod_sandbox' :
2013-04-13 08:00:19 +00:00
if ( check_perms ( 'users_mod' )) {
2011-03-28 14:21:28 +00:00
include ( 'misc/mod_sandbox.php' );
} else {
error ( 403 );
}
break ;
default :
include ( SERVER_ROOT . '/sections/tools/tools.php' );
}
?>