Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- *
- * _____ _____ _ _____ _____ _____ _____ _____ _____
- * ___| | __ |_| _ |_ _|___ ___|_ _| __| _ | |
- * |_ -| --| -| | __| | | |- _|___| | | | __| | | | |
- * |___|_____|__|__|_|__| |_| |___| |_| |_____|__|__|_|_|_|
- * |s C R i P T z - T E A M . i N F O|
- *
- * This file was created by sCRiPTz-TEAM.iNFO [DEiONCUBE TEAM]
- * @ IonCube & Zend & NuSphere DeCoder
- *
- * @ Version : 1.0.0.3
- * @ Author : sCRiPTz-TEAM.iNFO
- * @ Released : 26-December-2011
- * @ Official site : http://sCRiPTz-TEAM.iNFO
- *
- */
- class account
- {
- public $config = array( );
- public $skin = NULL;
- public $words = array( );
- public $html = null;
- public $page_title = "";
- public function __construct( &$config, &$output )
- {
- $this->config =& $config;
- $this->output =& $output;
- $this->words = stringClass::loadwords( "account" );
- $this->words = array_merge( $this->words, $output->words );
- $this->skin = $output->loadTemplate( "account", $this->words );
- }
- public function takeOff( )
- {
- $req = isset( $_REQUEST['req'] ) && $_REQUEST['req'] ? $_REQUEST['req'] : "home";
- switch ( $req )
- {
- case "changeEmail" :
- $this->changeEmailForm( );
- break;
- case "doChangeEmail" :
- $this->changeEmailSave( );
- break;
- case "changeName" :
- $this->changeNameForm( );
- break;
- case "doChangeName" :
- $this->changeNameSave( );
- break;
- case "changePass" :
- $this->changePassForm( );
- break;
- case "doChangePass" :
- $this->changePassSave( );
- break;
- case "add" :
- $this->newForm( );
- break;
- case "doAdd" :
- $this->newSave( );
- break;
- case "delete" :
- $this->deleteAccount( );
- break;
- case "home" :
- }
- $this->showHome( );
- break;
- return true;
- }
- public function showHome( )
- {
- $other_accounts = array( );
- foreach ( $this->config as $k => $v )
- {
- if ( preg_match( "/^admin_user_(\\d+)\$/", $k ) )
- {
- if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
- {
- continue;
- }
- $other_accounts[] = $v;
- }
- }
- $this->html = $this->skin->showHome( $this->_am_i_master( ), $other_accounts );
- $this->page_title = $this->words['form__settings_overview'];
- return true;
- }
- public function deleteAccount( )
- {
- if ( !$this->_am_i_master( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- $delete = stringClass::cleaninputdata( $_REQUEST['acct'] );
- if ( $delete == $this->config['admin_user'] )
- {
- $this->html = $this->skin->deleteError( $this->words['error__cannot_delete'] );
- return false;
- }
- $id = 0;
- foreach ( $this->config as $k => $v )
- {
- if ( $v == $delete && preg_match( "/^admin_user_(\\d+)\$/", $k, $matches ) )
- {
- $id = $matches[1];
- }
- }
- if ( !$id )
- {
- $this->html = $this->skin->deleteError( $this->words['error__cannot_find_delete'] );
- return false;
- }
- unset( $this->config["admin_user_".$id] );
- unset( $this->config["admin_email_".$id] );
- unset( $this->config["admin_salt_".$id] );
- unset( $this->config["admin_hash_".$id] );
- $cfg = new configFile( $this->config );
- $config_file = $cfg->_build_config( );
- $cfg->_write_config( $config_file );
- $this->output->redirectScreen( $this->config['script_url']."&action=account", $this->words['redir__account_deleted'] );
- return true;
- }
- public function newForm( $error = "" )
- {
- if ( !$this->_am_i_master( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- $this->html = $this->skin->newForm( $error );
- $this->page_title = $this->words['form__add_account'];
- return true;
- }
- public function newSave( )
- {
- if ( !$this->_am_i_master( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- $name = stringClass::cleaninputdata( $_POST['name'] );
- $pass = stringClass::cleaninputdata( $_POST['password'] );
- $email = stringClass::cleanemail( $_POST['email'] );
- if ( !$name || !$pass || !$email )
- {
- $this->newForm( $this->words['error__missing_input'] );
- return false;
- }
- $used_emails = $this->_return_emails( );
- $used_names = $this->_return_names( );
- if ( in_array( $email, $used_emails ) )
- {
- $this->newForm( $this->words['error__email_exists'] );
- return false;
- }
- if ( in_array( $name, $used_names ) )
- {
- $this->newForm( $this->words['error__name_exists'] );
- return false;
- }
- $new_id = $this->_return_highest_id( );
- ++$new_id;
- $new_salt = stringClass::generatesalt( );
- $new_hash = md5( md5( $name ).md5( $pass ).md5( $new_salt ) );
- $cfg = new configFile( $this->config );
- $config_file = $cfg->_build_config( array(
- "admin_user_".$new_id => $name,
- "admin_email_".$new_id => $email,
- "admin_salt_".$new_id => $new_salt,
- "admin_hash_".$new_id => $new_hash
- ) );
- $cfg->_write_config( $config_file );
- $this->output->redirectScreen( $this->config['script_url']."&action=account", $this->words['redir__account_added'] );
- return true;
- }
- public function changeEmailForm( $error = "" )
- {
- $current = "";
- $input_name = stringClass::cleaninputdata( $_REQUEST['acct'] );
- $used_emails = $this->_return_emails( );
- $used_names = $this->_return_names( );
- if ( !in_array( $input_name, $used_names ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__cannot_find'] );
- return false;
- }
- $id = 0;
- foreach ( $used_names as $k => $v )
- {
- if ( !( $v == $input_name ) )
- {
- continue;
- }
- if ( $k == 0 && !$this->_am_i_master( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- $id = $k;
- break;
- break;
- }
- $current = $used_emails[$id];
- $this->html = $this->skin->changeEmailForm( $error, $current );
- $this->page_title = $this->words['form__change_email'];
- return true;
- }
- public function changeEmailSave( )
- {
- $current = "";
- $input_name = stringClass::cleaninputdata( $_REQUEST['acct'] );
- $used_emails = $this->_return_emails( );
- $used_names = $this->_return_names( );
- if ( !in_array( $input_name, $used_names ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__cannot_find'] );
- return false;
- }
- $id = 0;
- foreach ( $used_names as $k => $v )
- {
- if ( !( $v == $input_name ) )
- {
- continue;
- }
- if ( $k == 0 && !$this->_am_i_master( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- $id = $k;
- break;
- break;
- }
- $current = $used_emails[$id];
- $key = $id == 0 ? "admin_email" : "admin_email_".$id;
- if ( !$current )
- {
- $this->changeEmailForm( $this->words['error__cannot_find'] );
- return false;
- }
- $new_email = stringClass::cleanemail( $_POST['email'] );
- if ( in_array( $new_email, $used_emails ) )
- {
- $this->changeEmailForm( $this->words['error__email_exists'] );
- return false;
- }
- $cfg = new configFile( $this->config );
- $config_file = $cfg->_build_config( array(
- $key => $new_email
- ) );
- $cfg->_write_config( $config_file );
- $this->output->redirectScreen( $this->config['script_url']."&action=account", $this->words['redir__email_changed'] );
- return true;
- }
- public function changeNameForm( $error = "" )
- {
- $current = "";
- $input_name = stringClass::cleaninputdata( $_REQUEST['acct'] );
- $used_names = $this->_return_names( );
- if ( !in_array( $input_name, $used_names ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__cannot_find'] );
- return false;
- }
- $id = 0;
- foreach ( $used_names as $k => $v )
- {
- if ( !( $v == $input_name ) )
- {
- continue;
- }
- if ( $k == 0 && !$this->_am_i_master( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- $id = $k;
- break;
- break;
- }
- $current = $used_names[$id];
- $this->html = $this->skin->changeNameForm( $error, $current );
- $this->page_title = $this->words['form__change_username'];
- return true;
- }
- public function changeNameSave( )
- {
- $current = "";
- $input_name = stringClass::cleaninputdata( $_REQUEST['acct'] );
- $used_names = $this->_return_names( );
- if ( !in_array( $input_name, $used_names ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__cannot_find'] );
- return false;
- }
- $id = 0;
- foreach ( $used_names as $k => $v )
- {
- if ( !( $v == $input_name ) )
- {
- continue;
- }
- if ( $k == 0 && !$this->_am_i_master( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- $id = $k;
- break;
- break;
- }
- $current = $used_names[$id];
- $key = $id == 0 ? "admin_user" : "admin_user_".$id;
- if ( !$current )
- {
- $this->changeNameForm( $this->words['error__cannot_find'] );
- return false;
- }
- $new_name = stringClass::cleaninputdata( $_POST['name'] );
- if ( in_array( $new_name, $used_names ) )
- {
- $this->changeNameForm( $this->words['error__name_exists'] );
- return false;
- }
- $cfg = new configFile( $this->config );
- $config_file = $cfg->_build_config( array(
- $key => $new_name
- ) );
- $cfg->_write_config( $config_file );
- $this->output->redirectScreen( $this->config['script_url']."&action=account", $this->words['redir__name_changed'] );
- return true;
- }
- public function changePassForm( $error = "" )
- {
- $input_name = stringClass::cleaninputdata( $_REQUEST['acct'] );
- $used_names = $this->_return_names( );
- if ( !in_array( $input_name, $used_names ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__cannot_find'] );
- return false;
- }
- $id = 0;
- foreach ( $used_names as $k => $v )
- {
- if ( !( $v == $input_name ) )
- {
- continue;
- }
- if ( $k == 0 && !$this->_am_i_master( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- $id = $k;
- break;
- break;
- }
- $this->html = $this->skin->changePassForm( $error );
- $this->page_title = $this->words['form__change_password'];
- return true;
- }
- public function changePassSave( )
- {
- $input_name = stringClass::cleaninputdata( $_REQUEST['acct'] );
- $used_names = $this->_return_names( );
- if ( !in_array( $input_name, $used_names ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__cannot_find'] );
- return false;
- }
- $id = 0;
- foreach ( $used_names as $k => $v )
- {
- if ( !( $v == $input_name ) )
- {
- continue;
- }
- if ( $k == 0 && !$this->_am_i_master( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
- {
- $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
- return false;
- }
- $id = $k;
- break;
- break;
- }
- $key = $id == 0 ? "admin_salt" : "admin_salt_".$id;
- $key1 = $id == 0 ? "admin_hash" : "admin_hash_".$id;
- $new_salt = stringClass::generatesalt( );
- $new_hash = md5( md5( $used_names[$k] ).md5( stringClass::cleaninputdata( $_POST['password'] ) ).md5( $new_salt ) );
- $cfg = new configFile( $this->config );
- $config_file = $cfg->_build_config( array(
- $key => $new_salt,
- $key1 => $new_hash
- ) );
- $cfg->_write_config( $config_file );
- $this->output->redirectScreen( $this->config['script_url']."&action=account", $this->words['redir__pass_changed'] );
- return true;
- }
- private function _return_emails( )
- {
- $cfg = new configFile( $this->config );
- return $cfg->_return_emails( );
- }
- private function _return_names( )
- {
- $names = array(
- 0 => $this->config['admin_user']
- );
- foreach ( $this->config as $k => $v )
- {
- if ( preg_match( "/^admin_user_(\\d+)\$/", $k, $matches ) )
- {
- $names[$matches[1]] = $v;
- }
- }
- return $names;
- }
- private function _return_highest_id( )
- {
- $id = 0;
- foreach ( $this->config as $k => $v )
- {
- if ( !preg_match( "/^admin_user_(\\d+)\$/", $k, $matches ) && !( $id < intval( $matches[1] ) ) )
- {
- $id = intval( $matches[1] );
- }
- }
- return $id;
- }
- private function _am_i_master( )
- {
- $my_name = session::getsessionname( );
- if ( $my_name == $this->config['admin_user'] )
- {
- return true;
- }
- return false;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement