Advertisement
scriptz-team

DEiONCUBE

Dec 26th, 2011
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 16.61 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. *    
  5. *      _____ _____ _ _____ _____         _____ _____ _____ _____
  6. *  ___|     | __  |_|  _  |_   _|___ ___|_   _|   __|  _  |     |
  7. * |_ -|   --|    -| |   __| | | |- _|___| | | |   __|     | | | |
  8. * |___|_____|__|__|_|__|    |_| |___|     |_| |_____|__|__|_|_|_|
  9. * |s C R i P T z - T E A M . i N F O|
  10. *
  11. * This file was created by sCRiPTz-TEAM.iNFO [DEiONCUBE TEAM]
  12. * @ IonCube & Zend & NuSphere DeCoder
  13. *
  14. * @    Version             :    1.0.0.3
  15. * @    Author              :    sCRiPTz-TEAM.iNFO
  16. * @    Released            :    26-December-2011
  17. * @    Official site       :    http://sCRiPTz-TEAM.iNFO
  18. *
  19. */
  20.  
  21. class account
  22. {
  23.  
  24.     public $config = array( );
  25.     public $skin = NULL;
  26.     public $words = array( );
  27.     public $html = null;
  28.     public $page_title = "";
  29.  
  30.     public function __construct( &$config, &$output )
  31.     {
  32.         $this->config =& $config;
  33.         $this->output =& $output;
  34.         $this->words = stringClass::loadwords( "account" );
  35.         $this->words = array_merge( $this->words, $output->words );
  36.         $this->skin = $output->loadTemplate( "account", $this->words );
  37.     }
  38.  
  39.     public function takeOff( )
  40.     {
  41.         $req = isset( $_REQUEST['req'] ) && $_REQUEST['req'] ? $_REQUEST['req'] : "home";
  42.         switch ( $req )
  43.         {
  44.         case "changeEmail" :
  45.             $this->changeEmailForm( );
  46.             break;
  47.         case "doChangeEmail" :
  48.             $this->changeEmailSave( );
  49.             break;
  50.         case "changeName" :
  51.             $this->changeNameForm( );
  52.             break;
  53.         case "doChangeName" :
  54.             $this->changeNameSave( );
  55.             break;
  56.         case "changePass" :
  57.             $this->changePassForm( );
  58.             break;
  59.         case "doChangePass" :
  60.             $this->changePassSave( );
  61.             break;
  62.         case "add" :
  63.             $this->newForm( );
  64.             break;
  65.         case "doAdd" :
  66.             $this->newSave( );
  67.             break;
  68.         case "delete" :
  69.             $this->deleteAccount( );
  70.             break;
  71.         case "home" :
  72.         }
  73.         $this->showHome( );
  74.         break;
  75.         return true;
  76.     }
  77.  
  78.     public function showHome( )
  79.     {
  80.         $other_accounts = array( );
  81.         foreach ( $this->config as $k => $v )
  82.         {
  83.             if ( preg_match( "/^admin_user_(\\d+)\$/", $k ) )
  84.             {
  85.                 if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
  86.                 {
  87.                     continue;
  88.                 }
  89.                 $other_accounts[] = $v;
  90.             }
  91.         }
  92.         $this->html = $this->skin->showHome( $this->_am_i_master( ), $other_accounts );
  93.         $this->page_title = $this->words['form__settings_overview'];
  94.         return true;
  95.     }
  96.  
  97.     public function deleteAccount( )
  98.     {
  99.         if ( !$this->_am_i_master( ) )
  100.         {
  101.             $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  102.             return false;
  103.         }
  104.         $delete = stringClass::cleaninputdata( $_REQUEST['acct'] );
  105.         if ( $delete == $this->config['admin_user'] )
  106.         {
  107.             $this->html = $this->skin->deleteError( $this->words['error__cannot_delete'] );
  108.             return false;
  109.         }
  110.         $id = 0;
  111.         foreach ( $this->config as $k => $v )
  112.         {
  113.             if ( $v == $delete && preg_match( "/^admin_user_(\\d+)\$/", $k, $matches ) )
  114.             {
  115.                 $id = $matches[1];
  116.             }
  117.         }
  118.         if ( !$id )
  119.         {
  120.             $this->html = $this->skin->deleteError( $this->words['error__cannot_find_delete'] );
  121.             return false;
  122.         }
  123.         unset( $this->config["admin_user_".$id] );
  124.         unset( $this->config["admin_email_".$id] );
  125.         unset( $this->config["admin_salt_".$id] );
  126.         unset( $this->config["admin_hash_".$id] );
  127.         $cfg = new configFile( $this->config );
  128.         $config_file = $cfg->_build_config( );
  129.         $cfg->_write_config( $config_file );
  130.         $this->output->redirectScreen( $this->config['script_url']."&amp;action=account", $this->words['redir__account_deleted'] );
  131.         return true;
  132.     }
  133.  
  134.     public function newForm( $error = "" )
  135.     {
  136.         if ( !$this->_am_i_master( ) )
  137.         {
  138.             $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  139.             return false;
  140.         }
  141.         $this->html = $this->skin->newForm( $error );
  142.         $this->page_title = $this->words['form__add_account'];
  143.         return true;
  144.     }
  145.  
  146.     public function newSave( )
  147.     {
  148.         if ( !$this->_am_i_master( ) )
  149.         {
  150.             $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  151.             return false;
  152.         }
  153.         $name = stringClass::cleaninputdata( $_POST['name'] );
  154.         $pass = stringClass::cleaninputdata( $_POST['password'] );
  155.         $email = stringClass::cleanemail( $_POST['email'] );
  156.         if ( !$name || !$pass || !$email )
  157.         {
  158.             $this->newForm( $this->words['error__missing_input'] );
  159.             return false;
  160.         }
  161.         $used_emails = $this->_return_emails( );
  162.         $used_names = $this->_return_names( );
  163.         if ( in_array( $email, $used_emails ) )
  164.         {
  165.             $this->newForm( $this->words['error__email_exists'] );
  166.             return false;
  167.         }
  168.         if ( in_array( $name, $used_names ) )
  169.         {
  170.             $this->newForm( $this->words['error__name_exists'] );
  171.             return false;
  172.         }
  173.         $new_id = $this->_return_highest_id( );
  174.         ++$new_id;
  175.         $new_salt = stringClass::generatesalt( );
  176.         $new_hash = md5( md5( $name ).md5( $pass ).md5( $new_salt ) );
  177.         $cfg = new configFile( $this->config );
  178.         $config_file = $cfg->_build_config( array(
  179.             "admin_user_".$new_id => $name,
  180.             "admin_email_".$new_id => $email,
  181.             "admin_salt_".$new_id => $new_salt,
  182.             "admin_hash_".$new_id => $new_hash
  183.         ) );
  184.         $cfg->_write_config( $config_file );
  185.         $this->output->redirectScreen( $this->config['script_url']."&amp;action=account", $this->words['redir__account_added'] );
  186.         return true;
  187.     }
  188.  
  189.     public function changeEmailForm( $error = "" )
  190.     {
  191.         $current = "";
  192.         $input_name = stringClass::cleaninputdata( $_REQUEST['acct'] );
  193.         $used_emails = $this->_return_emails( );
  194.         $used_names = $this->_return_names( );
  195.         if ( !in_array( $input_name, $used_names ) )
  196.         {
  197.             $this->html = $this->skin->deleteError( $this->words['error__cannot_find'] );
  198.             return false;
  199.         }
  200.         $id = 0;
  201.         foreach ( $used_names as $k => $v )
  202.         {
  203.             if ( !( $v == $input_name ) )
  204.             {
  205.                 continue;
  206.             }
  207.             if ( $k == 0 && !$this->_am_i_master( ) )
  208.             {
  209.                 $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  210.                 return false;
  211.             }
  212.             if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
  213.             {
  214.                 $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  215.                 return false;
  216.             }
  217.             $id = $k;
  218.             break;
  219.             break;
  220.         }
  221.         $current = $used_emails[$id];
  222.         $this->html = $this->skin->changeEmailForm( $error, $current );
  223.         $this->page_title = $this->words['form__change_email'];
  224.         return true;
  225.     }
  226.  
  227.     public function changeEmailSave( )
  228.     {
  229.         $current = "";
  230.         $input_name = stringClass::cleaninputdata( $_REQUEST['acct'] );
  231.         $used_emails = $this->_return_emails( );
  232.         $used_names = $this->_return_names( );
  233.         if ( !in_array( $input_name, $used_names ) )
  234.         {
  235.             $this->html = $this->skin->deleteError( $this->words['error__cannot_find'] );
  236.             return false;
  237.         }
  238.         $id = 0;
  239.         foreach ( $used_names as $k => $v )
  240.         {
  241.             if ( !( $v == $input_name ) )
  242.             {
  243.                 continue;
  244.             }
  245.             if ( $k == 0 && !$this->_am_i_master( ) )
  246.             {
  247.                 $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  248.                 return false;
  249.             }
  250.             if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
  251.             {
  252.                 $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  253.                 return false;
  254.             }
  255.             $id = $k;
  256.             break;
  257.             break;
  258.         }
  259.         $current = $used_emails[$id];
  260.         $key = $id == 0 ? "admin_email" : "admin_email_".$id;
  261.         if ( !$current )
  262.         {
  263.             $this->changeEmailForm( $this->words['error__cannot_find'] );
  264.             return false;
  265.         }
  266.         $new_email = stringClass::cleanemail( $_POST['email'] );
  267.         if ( in_array( $new_email, $used_emails ) )
  268.         {
  269.             $this->changeEmailForm( $this->words['error__email_exists'] );
  270.             return false;
  271.         }
  272.         $cfg = new configFile( $this->config );
  273.         $config_file = $cfg->_build_config( array(
  274.             $key => $new_email
  275.         ) );
  276.         $cfg->_write_config( $config_file );
  277.         $this->output->redirectScreen( $this->config['script_url']."&amp;action=account", $this->words['redir__email_changed'] );
  278.         return true;
  279.     }
  280.  
  281.     public function changeNameForm( $error = "" )
  282.     {
  283.         $current = "";
  284.         $input_name = stringClass::cleaninputdata( $_REQUEST['acct'] );
  285.         $used_names = $this->_return_names( );
  286.         if ( !in_array( $input_name, $used_names ) )
  287.         {
  288.             $this->html = $this->skin->deleteError( $this->words['error__cannot_find'] );
  289.             return false;
  290.         }
  291.         $id = 0;
  292.         foreach ( $used_names as $k => $v )
  293.         {
  294.             if ( !( $v == $input_name ) )
  295.             {
  296.                 continue;
  297.             }
  298.             if ( $k == 0 && !$this->_am_i_master( ) )
  299.             {
  300.                 $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  301.                 return false;
  302.             }
  303.             if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
  304.             {
  305.                 $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  306.                 return false;
  307.             }
  308.             $id = $k;
  309.             break;
  310.             break;
  311.         }
  312.         $current = $used_names[$id];
  313.         $this->html = $this->skin->changeNameForm( $error, $current );
  314.         $this->page_title = $this->words['form__change_username'];
  315.         return true;
  316.     }
  317.  
  318.     public function changeNameSave( )
  319.     {
  320.         $current = "";
  321.         $input_name = stringClass::cleaninputdata( $_REQUEST['acct'] );
  322.         $used_names = $this->_return_names( );
  323.         if ( !in_array( $input_name, $used_names ) )
  324.         {
  325.             $this->html = $this->skin->deleteError( $this->words['error__cannot_find'] );
  326.             return false;
  327.         }
  328.         $id = 0;
  329.         foreach ( $used_names as $k => $v )
  330.         {
  331.             if ( !( $v == $input_name ) )
  332.             {
  333.                 continue;
  334.             }
  335.             if ( $k == 0 && !$this->_am_i_master( ) )
  336.             {
  337.                 $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  338.                 return false;
  339.             }
  340.             if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
  341.             {
  342.                 $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  343.                 return false;
  344.             }
  345.             $id = $k;
  346.             break;
  347.             break;
  348.         }
  349.         $current = $used_names[$id];
  350.         $key = $id == 0 ? "admin_user" : "admin_user_".$id;
  351.         if ( !$current )
  352.         {
  353.             $this->changeNameForm( $this->words['error__cannot_find'] );
  354.             return false;
  355.         }
  356.         $new_name = stringClass::cleaninputdata( $_POST['name'] );
  357.         if ( in_array( $new_name, $used_names ) )
  358.         {
  359.             $this->changeNameForm( $this->words['error__name_exists'] );
  360.             return false;
  361.         }
  362.         $cfg = new configFile( $this->config );
  363.         $config_file = $cfg->_build_config( array(
  364.             $key => $new_name
  365.         ) );
  366.         $cfg->_write_config( $config_file );
  367.         $this->output->redirectScreen( $this->config['script_url']."&amp;action=account", $this->words['redir__name_changed'] );
  368.         return true;
  369.     }
  370.  
  371.     public function changePassForm( $error = "" )
  372.     {
  373.         $input_name = stringClass::cleaninputdata( $_REQUEST['acct'] );
  374.         $used_names = $this->_return_names( );
  375.         if ( !in_array( $input_name, $used_names ) )
  376.         {
  377.             $this->html = $this->skin->deleteError( $this->words['error__cannot_find'] );
  378.             return false;
  379.         }
  380.         $id = 0;
  381.         foreach ( $used_names as $k => $v )
  382.         {
  383.             if ( !( $v == $input_name ) )
  384.             {
  385.                 continue;
  386.             }
  387.             if ( $k == 0 && !$this->_am_i_master( ) )
  388.             {
  389.                 $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  390.                 return false;
  391.             }
  392.             if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
  393.             {
  394.                 $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  395.                 return false;
  396.             }
  397.             $id = $k;
  398.             break;
  399.             break;
  400.         }
  401.         $this->html = $this->skin->changePassForm( $error );
  402.         $this->page_title = $this->words['form__change_password'];
  403.         return true;
  404.     }
  405.  
  406.     public function changePassSave( )
  407.     {
  408.         $input_name = stringClass::cleaninputdata( $_REQUEST['acct'] );
  409.         $used_names = $this->_return_names( );
  410.         if ( !in_array( $input_name, $used_names ) )
  411.         {
  412.             $this->html = $this->skin->deleteError( $this->words['error__cannot_find'] );
  413.             return false;
  414.         }
  415.         $id = 0;
  416.         foreach ( $used_names as $k => $v )
  417.         {
  418.             if ( !( $v == $input_name ) )
  419.             {
  420.                 continue;
  421.             }
  422.             if ( $k == 0 && !$this->_am_i_master( ) )
  423.             {
  424.                 $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  425.                 return false;
  426.             }
  427.             if ( !$this->_am_i_master( ) && $v != session::getsessionname( ) )
  428.             {
  429.                 $this->html = $this->skin->deleteError( $this->words['error__no_permission'] );
  430.                 return false;
  431.             }
  432.             $id = $k;
  433.             break;
  434.             break;
  435.         }
  436.         $key = $id == 0 ? "admin_salt" : "admin_salt_".$id;
  437.         $key1 = $id == 0 ? "admin_hash" : "admin_hash_".$id;
  438.         $new_salt = stringClass::generatesalt( );
  439.         $new_hash = md5( md5( $used_names[$k] ).md5( stringClass::cleaninputdata( $_POST['password'] ) ).md5( $new_salt ) );
  440.         $cfg = new configFile( $this->config );
  441.         $config_file = $cfg->_build_config( array(
  442.             $key => $new_salt,
  443.             $key1 => $new_hash
  444.         ) );
  445.         $cfg->_write_config( $config_file );
  446.         $this->output->redirectScreen( $this->config['script_url']."&amp;action=account", $this->words['redir__pass_changed'] );
  447.         return true;
  448.     }
  449.  
  450.     private function _return_emails( )
  451.     {
  452.         $cfg = new configFile( $this->config );
  453.         return $cfg->_return_emails( );
  454.     }
  455.  
  456.     private function _return_names( )
  457.     {
  458.         $names = array(
  459.             0 => $this->config['admin_user']
  460.         );
  461.         foreach ( $this->config as $k => $v )
  462.         {
  463.             if ( preg_match( "/^admin_user_(\\d+)\$/", $k, $matches ) )
  464.             {
  465.                 $names[$matches[1]] = $v;
  466.             }
  467.         }
  468.         return $names;
  469.     }
  470.  
  471.     private function _return_highest_id( )
  472.     {
  473.         $id = 0;
  474.         foreach ( $this->config as $k => $v )
  475.         {
  476.             if ( !preg_match( "/^admin_user_(\\d+)\$/", $k, $matches ) && !( $id < intval( $matches[1] ) ) )
  477.             {
  478.                 $id = intval( $matches[1] );
  479.             }
  480.         }
  481.         return $id;
  482.     }
  483.  
  484.     private function _am_i_master( )
  485.     {
  486.         $my_name = session::getsessionname( );
  487.         if ( $my_name == $this->config['admin_user'] )
  488.         {
  489.             return true;
  490.         }
  491.         return false;
  492.     }
  493.  
  494. }
  495.  
  496. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement