Plugin Directory

Changeset 584829


Ignore:
Timestamp:
08/13/2012 11:32:58 AM (14 years ago)
Author:
kotori83
Message:

Added user logged in protection to sensitive scripts.

Location:
trinitycore-server-management-suite/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trinitycore-server-management-suite/trunk/pass_processor.php

    r584742 r584829  
    3232 */
    3333
    34 include( plugin_dir_path( __FILE__ ) . 'wow_funcs/db_sanitizer.php' );
    35 
    36 /* Setup the MySQL connection with settings from the admin page */
    37 $user_options = get_option('trinitymanagementsuite_plugin_options');
    38 
    39 global $current_user;
    40 get_currentuserinfo();
    41 
    42 $plugindir =  str_replace(basename(__FILE__),"",__FILE__);
    43 $plugindir = str_replace('\\','/',$plugindir);
    44 $plugindir = rtrim($plugindir,"/");
    45 
    46 $ipi = getenv("REMOTE_ADDR");
    47 $httprefi = getenv ("HTTP_REFERER");
    48 $httpagenti = getenv ("HTTP_USER_AGENT");
    49 
    50 /* Check to see if this script was posted to from the form */
    51 $post = (!empty($_POST)) ? true : false;
    52 
    5334echo '<h2>Password Management</h2>';
    5435
    55 /*
    56  * If the form has been posted to, validate the form for pass change.
    57  */
    58 if($post && isset($_POST['thepassword']) && isset($_POST['recaptcha_response_field']))
     36if ( is_user_logged_in() )
    5937{
    60     /* the error code from reCAPTCHA, if any */
    61     $error = null;
    62 
    63     /* Set the key values from our wordpress options and POST values */
    64     $privatekey = $user_options['trinitymanagementsuite_recaptcha_apikey_priv_string'];
    65 
    66     /* Captcha Values */
    67     $post_thecaptchachallenge = stripslashes($_POST['recaptcha_challenge_field']);
    68     $post_thecaptcharesponse = stripslashes($_POST['recaptcha_response_field']);
    69 
    70     /* The actual password */
    71     $post_thepassword = stripslashes($_POST['thepassword']);
    72 
    73     /* A little information about the host that posted to the form */
    74     $post_client_ip = ($_POST['ip']);
    75     $post_client_referrer = ($_POST['httpref']);
    76     $post_client_agent = ($_POST['httpagent']);
    77    
    78     $this_user = $current_user->user_login;
    79    
    80     //echo 'Client IP: '. $post_client_ip .'<br />';
    81    
    82     /* Check the response with the Captcha */
    83     $resp = recaptcha_check_answer(
    84         $privatekey,
    85         $_SERVER["REMOTE_ADDR"],
    86         $_POST["recaptcha_challenge_field"],
    87         $_POST["recaptcha_response_field"]
    88     );
    89            
    90     if ($resp->is_valid)
     38    include( plugin_dir_path( __FILE__ ) . 'wow_funcs/db_sanitizer.php' );
     39
     40    /* Setup the MySQL connection with settings from the admin page */
     41    $user_options = get_option('trinitymanagementsuite_plugin_options');
     42
     43    global $current_user;
     44    get_currentuserinfo();
     45
     46    $plugindir =  str_replace(basename(__FILE__),"",__FILE__);
     47    $plugindir = str_replace('\\','/',$plugindir);
     48    $plugindir = rtrim($plugindir,"/");
     49
     50    $ipi = getenv("REMOTE_ADDR");
     51    $httprefi = getenv ("HTTP_REFERER");
     52    $httpagenti = getenv ("HTTP_USER_AGENT");
     53
     54    /* Check to see if this script was posted to from the form */
     55    $post = (!empty($_POST)) ? true : false;
     56
     57    /*
     58     * If the form has been posted to, validate the form for pass change.
     59     */
     60    if($post && isset($_POST['thepassword']) && isset($_POST['recaptcha_response_field']))
    9161    {
    92         $manage_password_mysqli_conn = new mysqli(
    93             $user_options['trinitymanagementsuite_db_hostname_string'],  /* Hostname */
    94             $user_options['trinitymanagementsuite_db_user_string'],      /* Username */
    95             $user_options['trinitymanagementsuite_db_pass_string'],      /* Password */
    96             $user_options['trinitymanagementsuite_db_auth_text_string']  /* Database */
     62        /* the error code from reCAPTCHA, if any */
     63        $error = null;
     64
     65        /* Set the key values from our wordpress options and POST values */
     66        $privatekey = $user_options['trinitymanagementsuite_recaptcha_apikey_priv_string'];
     67
     68        /* Captcha Values */
     69        $post_thecaptchachallenge = stripslashes($_POST['recaptcha_challenge_field']);
     70        $post_thecaptcharesponse = stripslashes($_POST['recaptcha_response_field']);
     71
     72        /* The actual password */
     73        $post_thepassword = stripslashes($_POST['thepassword']);
     74
     75        /* A little information about the host that posted to the form */
     76        $post_client_ip = ($_POST['ip']);
     77        $post_client_referrer = ($_POST['httpref']);
     78        $post_client_agent = ($_POST['httpagent']);
     79       
     80        $this_user = $current_user->user_login;
     81       
     82        //echo 'Client IP: '. $post_client_ip .'<br />';
     83       
     84        /* Check the response with the Captcha */
     85        $resp = recaptcha_check_answer(
     86            $privatekey,
     87            $_SERVER["REMOTE_ADDR"],
     88            $_POST["recaptcha_challenge_field"],
     89            $_POST["recaptcha_response_field"]
    9790        );
    98        
    99         /* Check MySQL connection */
    100         if ($manage_password_mysqli_conn->connect_errno)
     91               
     92        if ($resp->is_valid)
    10193        {
    102             error_log('MySQL Error: ' . $manage_password_mysqli_conn->connect_error, 0);
     94            $manage_password_mysqli_conn = new mysqli(
     95                $user_options['trinitymanagementsuite_db_hostname_string'],  /* Hostname */
     96                $user_options['trinitymanagementsuite_db_user_string'],      /* Username */
     97                $user_options['trinitymanagementsuite_db_pass_string'],      /* Password */
     98                $user_options['trinitymanagementsuite_db_auth_text_string']  /* Database */
     99            );
     100           
     101            /* Check MySQL connection */
     102            if ($manage_password_mysqli_conn->connect_errno)
     103            {
     104                error_log('MySQL Error: ' . $manage_password_mysqli_conn->connect_error, 0);
     105            }
     106            else
     107            {
     108                //echo 'Checking for matching player in database...<br />';
     109                /* Convert the passed password into a valid login string */
     110                $wow_password = trinitymanager_sha_password( $this_user, $post_thepassword );
     111
     112                $wow_password = $manage_password_mysqli_conn->real_escape_string($wow_password);
     113                $blog_password = $post_thepassword;
     114                $this_user = $manage_password_mysqli_conn->real_escape_string($this_user);
     115
     116                $wow_sql = "UPDATE `account` SET `sha_pass_hash` = '$wow_password' WHERE `username` = '$this_user'";
     117                $blog_sql = "UPDATE `wp_users` SET `user_pass` = MD5('$blog_password') WHERE `user_login` = '$this_user'";
     118               
     119                echo '<font color="blue">[DEBUG]</font><br />';
     120                echo '<font color="blue">Account User: </font>'. $this_user .'<br />';
     121                echo '<font color="blue">WoW Password: </font>'. $wow_password .'<br />';
     122                echo '<font color="blue">Blog Password: </font>'. $blog_password .'<br />';
     123                echo '<font color="blue">SQL INSERTS: </font>'. $sql .'<br />';
     124                           
     125                /* Will return true if sucessful else it will return false */
     126                if($manage_password_mysqli_conn->query($wow_sql))
     127                {
     128                    if ($manage_password_mysqli_conn->affected_rows==1)
     129                    {
     130                        /** TODO
     131                         * Now that we've successfully updated our TrinityCore password,
     132                         *  we should also update the blog password as well.
     133                         */
     134                        global $wowdb;
     135                        $hash = wp_hash_password( $post_thepassword );
     136                        $user_id = $current_user->ID;
     137                        $wowdb->update($wowdb->users, array('user_pass' => $hash, 'user_activation_key' => ''), array('ID' => $user_id) );
     138
     139                        wp_cache_delete( $user_id, 'users' );
     140
     141                        /* Finish inserting new password into Wordpress */
     142
     143                        echo '<font color="green">Success!</font><br />';
     144                        echo 'Your New Password: <b>'. $thepassword .'</b><br />';
     145                       
     146                        $admin_email = get_option('admin_email');
     147                        $from = '<'. $admin_info->user_login .'> '. $admin_email;
     148                        $to = $current_user->user_email;
     149                        $cc =  '<'. $admin_info->user_login .'> '. $admin_email;
     150                        $subject = 'Password Reset';
     151                        $message = 'Your password has been reset via the player change form.\n
     152                                    Please report this immediately if you did not perform this action!\n
     153                                    Your password was reset from the the IP: '. $post_client_ip .', Agent: '. $post_client_agent .'\n\n
     154                                    Thank You,\n
     155                                    Administration';
     156                       
     157                        /* Build the email headers */
     158                        $headers[] = "MIME-Version: 1.0\r\n";
     159                        $headers[] .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
     160                        $headers[] .= 'Cc: '. $cc . "\r\n";
     161                        $headers[] .= 'From: '. $from . "\r\n";
     162                        $headers[] .= 'Reply-To: ' . $from . "\r\n";
     163                        $headers[] .= "X-Priority: 1\r\n";
     164                        $headers[] .= 'X-Mailer: PHP';
     165
     166                        /* Actually send out the password change email */
     167                        wp_mail( $to, $subject, $message, $headers );
     168                    }
     169                    else
     170                    {
     171                        echo '<font color="red">UPDATE Failure. No Matching User Found!</font><br />';
     172                    }
     173                }
     174                else
     175                {
     176                    //
     177                }
     178            }
     179           
     180            $manage_password_mysqli_conn->close();
    103181        }
    104182        else
    105183        {
    106             //echo 'Checking for matching player in database...<br />';
    107             /* Convert the passed password into a valid login string */
    108             $wow_password = trinitymanager_sha_password( $this_user, $post_thepassword );
    109 
    110             $wow_password = $manage_password_mysqli_conn->real_escape_string($wow_password);
    111             $blog_password = $post_thepassword;
    112             $this_user = $manage_password_mysqli_conn->real_escape_string($this_user);
    113 
    114             $wow_sql = "UPDATE `account` SET `sha_pass_hash` = '$wow_password' WHERE `username` = '$this_user'";
    115             $blog_sql = "UPDATE `wp_users` SET `user_pass` = MD5('$blog_password') WHERE `user_login` = '$this_user'";
     184            echo '<font color="red">Invalid Captcha</font><br />';
     185            $error = $resp->error;
     186        }
     187       
     188        /* If the error string is not empty, display it */
     189        if($error)
     190        {
     191            //echo $error .'<br /><br />';
     192        }
     193    }
     194
     195
     196    /*
     197     * Now that we've passed our post detection, go ahead and create the form
     198     */
     199
     200    $manage_password_mysqli_conn = new mysqli(
     201        $user_options['trinitymanagementsuite_db_hostname_string'],  /* Hostname */
     202        $user_options['trinitymanagementsuite_db_user_string'],      /* Username */
     203        $user_options['trinitymanagementsuite_db_pass_string'],      /* Password */
     204        $user_options['trinitymanagementsuite_db_auth_text_string']  /* Database */
     205    );
     206
     207    /* Check MySQL connection */
     208    if ($manage_password_mysqli_conn->connect_errno)
     209    {
     210        echo '<b>Error Establishing a database connection.</b>';
     211    }
     212    else
     213    {
     214        $recaptcha_key = $user_options['trinitymanagementsuite_recaptcha_apikey_pub_string'];
     215
     216        if ($_SERVER['HTTPS'] == "on")
     217            {
     218                    $recaptcha_challenge_url = 'https://www.google.com/recaptcha/api/challenge?k=' . $recaptcha_key .'&error=incorrect-captcha-sol';
     219                    $recaptcha_noscript_url = 'https://www.google.com/recaptcha/api/noscript?k=' . $recaptcha_key;
     220            }
     221            else
     222            {
     223                    $recaptcha_challenge_url = 'http://www.google.com/recaptcha/api/challenge?k=' . $recaptcha_key .'&error=incorrect-captcha-sol';
     224                    $recaptcha_noscript_url = 'http://www.google.com/recaptcha/api/noscript?k=' . $recaptcha_key;
     225            }
     226
     227        $sql_query = sprintf(__("SELECT `id` FROM `account` WHERE `username`='%s'"),
     228            mysql_real_escape_string($current_user->user_login));
     229
     230        $manage_password_mysqli_conn->real_query( $sql_query );
     231        if( $manage_password_mysqli_conn->field_count )
     232        {
     233            $sql_result = $manage_password_mysqli_conn->store_result();
     234            /* If sql_result is true, we have a matching user, so print the change password form */
     235            if( $sql_result )
     236            {
     237                $row_cnt = $sql_result->num_rows;
     238                if( !$row_cnt > 0 )
     239                {                   
     240                    $row = $sql_result->fetch_assoc();
     241
     242                    /* First make sure our user actually has access to change a password */
     243                    echo 'Greetings ' . $current_user->user_login . ',<br />';
     244                    echo 'Type in your NEW password twice, once accepted this will change your website and WoW credentials <br />';
     245                    echo 'Please note that you will need to logout and back in after this change <br />';
     246                    echo '<br />Password Guidelines:';
     247                    echo '<ul><li><b>Minimum Length:</b> 6 Characters</li>';
     248                    echo '<li><b>Format:</b> at least one number, one lowercase and one uppercase letter, no spaces</li>';
     249                    echo '<li><b>Please note</b> your IP is being logged.</ul><p>';
    116250           
    117             echo '<font color="blue">[DEBUG]</font><br />';
    118             echo '<font color="blue">Account User: </font>'. $this_user .'<br />';
    119             echo '<font color="blue">WoW Password: </font>'. $wow_password .'<br />';
    120             echo '<font color="blue">Blog Password: </font>'. $blog_password .'<br />';
    121             echo '<font color="blue">SQL INSERTS: </font>'. $sql .'<br />';
    122                        
    123             /* Will return true if sucessful else it will return false */
    124             if($manage_password_mysqli_conn->query($wow_sql))
    125             {
    126                 if ($manage_password_mysqli_conn->affected_rows==1)
    127                 {
    128                     /** TODO
    129                      * Now that we've successfully updated our TrinityCore password,
    130                      *  we should also update the blog password as well.
    131                      */
    132                     global $wowdb;
    133                     $hash = wp_hash_password( $post_thepassword );
    134                     $user_id = $current_user->ID;
    135                     $wowdb->update($wowdb->users, array('user_pass' => $hash, 'user_activation_key' => ''), array('ID' => $user_id) );
    136 
    137                     wp_cache_delete( $user_id, 'users' );
    138 
    139                     /* Finish inserting new password into Wordpress */
    140 
    141                     echo '<font color="green">Success!</font><br />';
    142                     echo 'Your New Password: <b>'. $thepassword .'</b><br />';
    143                    
    144                     $admin_email = get_option('admin_email');
    145                     $from = '<'. $admin_info->user_login .'> '. $admin_email;
    146                     $to = $current_user->user_email;
    147                     $cc =  '<'. $admin_info->user_login .'> '. $admin_email;
    148                     $subject = 'Password Reset';
    149                     $message = 'Your password has been reset via the player change form.\n
    150                                 Please report this immediately if you did not perform this action!\n
    151                                 Your password was reset from the the IP: '. $post_client_ip .', Agent: '. $post_client_agent .'\n\n
    152                                 Thank You,\n
    153                                 Administration';
    154                    
    155                     /* Build the email headers */
    156                     $headers[] = "MIME-Version: 1.0\r\n";
    157                     $headers[] .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
    158                     $headers[] .= 'Cc: '. $cc . "\r\n";
    159                     $headers[] .= 'From: '. $from . "\r\n";
    160                     $headers[] .= 'Reply-To: ' . $from . "\r\n";
    161                     $headers[] .= "X-Priority: 1\r\n";
    162                     $headers[] .= 'X-Mailer: PHP';
    163 
    164                     /* Actually send out the password change email */
    165                     wp_mail( $to, $subject, $message, $headers );
     251                    /* Begin the password reset form */
     252                    ?>
     253                    <form name="passchange_form" action="" onsubmit="return ValidateCompleteForm(this);" method="post" >
     254                       
     255                        <input type="hidden" name="ip" value="<?php echo $ipi ?>" />
     256                        <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
     257                        <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
     258                       
     259                                <table>
     260                                    <tr>
     261                                        <td>
     262                                                <!-- New Password -->
     263                                                <label for="thepassword">Password</label>
     264                                        </td>
     265                                        <td>
     266                                                <input name="thepassword" id="thepassword" required class="thepassword" placeholder="Password" type="password" tabindex="1" size="25" value="" />
     267                                        </td>
     268                                    </tr>
     269                                    <tr>
     270                                        <td>
     271                                                <!-- New Password Repeated-->
     272                                            <label for="thepasswordrepeat">Repeat Password</label>
     273                                        </td>
     274                                        <td>
     275                                                <input name="thepasswordrepeat" id="thepasswordrepeat" required class="thepasswordrepeat" placeholder="Repeat Password" type="password" tabindex="2" size="25" value="" />
     276                                        </td>
     277                                    </tr>
     278                                </table>
     279                       
     280                        <!-- Captcha Response-->
     281                        <label for="recaptcha_response_field"></label>
     282                        <?php echo recaptcha_get_html($recaptcha_key, $error, true); ?>
     283                       
     284                        <div id="recaptcha_widget" style="display:none">
     285                            <div><a href="javascript:Recaptcha.reload()">Refresh CAPTCHA</a></div>
     286                            <div id="recaptcha_image"></div>
     287                           
     288                            <!-- <div><a href="javascript:Recaptcha.reload()">New CAPTCHA</a></div> -->
     289                            <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">image CAPTCHA</a></div>
     290                           
     291                            <span class="recaptcha_only_if_image">Captcha:</span>
     292
     293                            <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />
     294                        </div>
     295                       
     296                        <!-- Captcha Challenge-->
     297                        <?php echo '<script type="text/javascript" src="'. $recaptcha_challenge_url .'"> </script>'; ?>
     298
     299                        <noscript>
     300                            <?php echo '<iframe src="'. $recaptcha_noscript_url .'"height="100" width="200" ></iframe><br>'; ?>
     301                            <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
     302                            <input type="hidden" name="recaptcha_response_field" value="manual_challenge">
     303                        </noscript>
     304                       
     305                        <!-- Submit Button -->
     306                        <input class="button-primary" type="submit" name="btnSubmit" value="<?php esc_attr_e('Update'); ?>"/>
     307                    </form>
     308                    <?php
     309                    /* End the password reset form */
    166310                }
    167311                else
    168312                {
    169                     echo '<font color="red">UPDATE Failure. No Matching User Found!</font><br />';
     313                    echo '<b>ERROR:</b> No Player found matching your ID!<br />';
    170314                }
    171315            }
    172             else
    173             {
    174                 //
    175             }
     316            mysqli_free_result( $sql_result );
    176317        }
    177        
    178         $manage_password_mysqli_conn->close();
    179318    }
    180     else
    181     {
    182         echo '<font color="red">Invalid Captcha</font><br />';
    183         $error = $resp->error;
    184     }
    185    
    186     /* If the error string is not empty, display it */
    187     if($error)
    188     {
    189         //echo $error .'<br /><br />';
    190     }
    191 }
    192 
    193 
    194 /*
    195  * Now that we've passed our post detection, go ahead and create the form
    196  */
    197 
    198 $manage_password_mysqli_conn = new mysqli(
    199     $user_options['trinitymanagementsuite_db_hostname_string'],  /* Hostname */
    200     $user_options['trinitymanagementsuite_db_user_string'],      /* Username */
    201     $user_options['trinitymanagementsuite_db_pass_string'],      /* Password */
    202     $user_options['trinitymanagementsuite_db_auth_text_string']  /* Database */
    203 );
    204 
    205 /* Check MySQL connection */
    206 if ($manage_password_mysqli_conn->connect_errno)
    207 {
    208     echo '<b>Error Establishing a database connection.</b>';
     319
     320    $manage_password_mysqli_conn->close();
    209321}
    210322else
    211323{
    212     $recaptcha_key = $user_options['trinitymanagementsuite_recaptcha_apikey_pub_string'];
    213 
    214     if ($_SERVER['HTTPS'] == "on")
    215         {
    216                 $recaptcha_challenge_url = 'https://www.google.com/recaptcha/api/challenge?k=' . $recaptcha_key .'&error=incorrect-captcha-sol';
    217                 $recaptcha_noscript_url = 'https://www.google.com/recaptcha/api/noscript?k=' . $recaptcha_key;
    218         }
    219         else
    220         {
    221                 $recaptcha_challenge_url = 'http://www.google.com/recaptcha/api/challenge?k=' . $recaptcha_key .'&error=incorrect-captcha-sol';
    222                 $recaptcha_noscript_url = 'http://www.google.com/recaptcha/api/noscript?k=' . $recaptcha_key;
    223         }
    224 
    225     $sql_query = sprintf(__("SELECT `id` FROM `account` WHERE `username`='%s'"),
    226         mysql_real_escape_string($current_user->user_login));
    227 
    228     $manage_password_mysqli_conn->real_query( $sql_query );
    229     if( $manage_password_mysqli_conn->field_count )
    230     {
    231         $sql_result = $manage_password_mysqli_conn->store_result();
    232         /* If sql_result is true, we have a matching user, so print the change password form */
    233         if( $sql_result )
    234         {
    235             $row_cnt = $sql_result->num_rows;
    236             if( !$row_cnt > 0 )
    237             {                   
    238                 $row = $sql_result->fetch_assoc();
    239 
    240                 /* First make sure our user actually has access to change a password */
    241                 echo 'Greetings ' . $current_user->user_login . ',<br />';
    242                 echo 'Type in your NEW password twice, once accepted this will change your website and WoW credentials <br />';
    243                 echo 'Please note that you will need to logout and back in after this change <br />';
    244                 echo '<br />Password Guidelines:';
    245                 echo '<ul><li><b>Minimum Length:</b> 6 Characters</li>';
    246                 echo '<li><b>Format:</b> at least one number, one lowercase and one uppercase letter, no spaces</li>';
    247                 echo '<li><b>Please note</b> your IP is being logged.</ul><p>';
    248        
    249                 /* Begin the password reset form */
    250                 ?>
    251                 <form name="passchange_form" action="" onsubmit="return ValidateCompleteForm(this);" method="post" >
    252                    
    253                     <input type="hidden" name="ip" value="<?php echo $ipi ?>" />
    254                     <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
    255                     <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
    256                    
    257                             <table>
    258                                 <tr>
    259                                     <td>
    260                                             <!-- New Password -->
    261                                             <label for="thepassword">Password</label>
    262                                     </td>
    263                                     <td>
    264                                             <input name="thepassword" id="thepassword" required class="thepassword" placeholder="Password" type="password" tabindex="1" size="25" value="" />
    265                                     </td>
    266                                 </tr>
    267                                 <tr>
    268                                     <td>
    269                                             <!-- New Password Repeated-->
    270                                         <label for="thepasswordrepeat">Repeat Password</label>
    271                                     </td>
    272                                     <td>
    273                                             <input name="thepasswordrepeat" id="thepasswordrepeat" required class="thepasswordrepeat" placeholder="Repeat Password" type="password" tabindex="2" size="25" value="" />
    274                                     </td>
    275                                 </tr>
    276                             </table>
    277                    
    278                     <!-- Captcha Response-->
    279                     <label for="recaptcha_response_field"></label>
    280                     <?php echo recaptcha_get_html($recaptcha_key, $error, true); ?>
    281                    
    282                     <div id="recaptcha_widget" style="display:none">
    283                         <div><a href="javascript:Recaptcha.reload()">Refresh CAPTCHA</a></div>
    284                         <div id="recaptcha_image"></div>
    285                        
    286                         <!-- <div><a href="javascript:Recaptcha.reload()">New CAPTCHA</a></div> -->
    287                         <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">image CAPTCHA</a></div>
    288                        
    289                         <span class="recaptcha_only_if_image">Captcha:</span>
    290 
    291                         <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />
    292                     </div>
    293                    
    294                     <!-- Captcha Challenge-->
    295                     <?php echo '<script type="text/javascript" src="'. $recaptcha_challenge_url .'"> </script>'; ?>
    296 
    297                     <noscript>
    298                         <?php echo '<iframe src="'. $recaptcha_noscript_url .'"height="100" width="200" ></iframe><br>'; ?>
    299                         <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
    300                         <input type="hidden" name="recaptcha_response_field" value="manual_challenge">
    301                     </noscript>
    302                    
    303                     <!-- Submit Button -->
    304                     <input class="button-primary" type="submit" name="btnSubmit" value="<?php esc_attr_e('Update'); ?>"/>
    305                 </form>
    306                 <?php
    307                 /* End the password reset form */
    308             }
    309             else
    310             {
    311                 echo '<b>ERROR:</b> No Player found matching your ID!<br />';
    312             }
    313         }
    314         mysqli_free_result( $sql_result );
    315     }
     324    echo 'Welcome, Visitor!<p>You must login before you can use this feature.';
    316325}
    317326
    318 $manage_password_mysqli_conn->close();
     327
     328
    319329
    320330?>
  • trinitycore-server-management-suite/trunk/playerlist.php

    r584180 r584829  
    1717*/
    1818
    19 /* Setup the MySQL connection with settings from the admin page */
    20 $trinity_options = get_option('trinitymanagementsuite_plugin_options');
     19echo '<h2>Player Listing</h2>';
    2120
    22 $mysqli_conn_playerlist = new mysqli(
    23     $trinity_options['trinitymanagementsuite_db_hostname_string'],  // Hostname
    24     $trinity_options['trinitymanagementsuite_db_user_string'],  // Username
    25     $trinity_options['trinitymanagementsuite_db_pass_string'],  // Password
    26     $trinity_options['trinitymanagementsuite_db_char_text_string']  // Database
    27 );
    28 
    29 /* Check MySQL connection */
    30 if ( !$mysqli_conn_playerlist->connect_errno )
     21if ( is_user_logged_in() )
    3122{
    3223
    33     $sql_result = $mysqli_conn_playerlist->query( mysql_real_escape_string("SELECT * FROM characters WHERE online > 0") );
     24    /* Setup the MySQL connection with settings from the admin page */
     25    $trinity_options = get_option('trinitymanagementsuite_plugin_options');
    3426
    35     if( $sql_result )
    36     {
    37         // Determine number of rows result set
    38         $row_cnt = $sql_result->num_rows;
    39         echo '<center>';
    40         if($row_cnt == 0)
    41         {
    42             echo '<b>Server Empty</b><br>';
    43             echo '</center>';
    44         }
    45         else
    46         {
    47             echo "<b>($row_cnt) Players Online:</b><br><br>";
    48             echo '<table style="border:none;padding:0;">';
     27    $mysqli_conn_playerlist = new mysqli(
     28        $trinity_options['trinitymanagementsuite_db_hostname_string'],  // Hostname
     29        $trinity_options['trinitymanagementsuite_db_user_string'],  // Username
     30        $trinity_options['trinitymanagementsuite_db_pass_string'],  // Password
     31        $trinity_options['trinitymanagementsuite_db_char_text_string']  // Database
     32    );
    4933
    50             echo '<th style="vertical-align:bottom;padding-right:10px;">Account</th>';
    51             echo '<th style="vertical-align:bottom;padding-right:10px;">Level</th>';
    52             echo '<th style="vertical-align:bottom;padding-right:10px;">Name</th>';
    53             echo '<th style="vertical-align:bottom;padding-right:10px;">Race</th>';
    54             echo '<th style="vertical-align:bottom;padding-right:10px;">Class</th>';
    55             echo '<th style="vertical-align:bottom;padding-right:10px;">Faction</th>';
     34    /* Check MySQL connection */
     35    if ( !$mysqli_conn_playerlist->connect_errno )
     36    {
    5637
    57             while( $row = $sql_result->fetch_assoc() )
    58             {
    59                 echo '<tr>';
     38        $sql_result = $mysqli_conn_playerlist->query( mysql_real_escape_string("SELECT * FROM characters WHERE online > 0") );
    6039
    61                 echo '<td style="vertical-align:bottom;padding-right:10px;">' . $row['account'] . '</td>';
    62                 echo '<td style="vertical-align:bottom;padding-right:10px;">' . $row['level'] . '</td>';
    63                 echo '<td style="vertical-align:bottom;padding-right:10px;">' . $row['name'] . '</td> ';
    64                 echo '<td style="vertical-align:bottom;padding-right:10px;">' . $character_race[$row['race']] . '</td>';
    65                 echo '<td style="vertical-align:bottom;padding-right:10px;">' . $character_class[$row['class']] . '</td>';
     40        if( $sql_result )
     41        {
     42            // Determine number of rows result set
     43            $row_cnt = $sql_result->num_rows;
     44            echo '<center>';
     45            if($row_cnt == 0)
     46            {
     47                echo '<b>Server Empty</b><br>';
     48                echo '</center>';
     49            }
     50            else
     51            {
     52                echo "<b>($row_cnt) Players Online:</b><br><br>";
     53                echo '<table style="border:none;padding:0;">';
    6654
    67                 if($row['race'] == 4 || $row['race'] == 5 || $row['race'] == 6 || $row['race'] == 8 || $row['race'] == 10)
    68                 {
    69                     echo '<td style="vertical-align:bottom;padding-right:10px;">' . '<img name="Horde" src="' . get_bloginfo('stylesheet_directory') . '/images/faction_horde.png" border="0" height="32" width="32"/>' . '</td>';
    70                 }
    71                 else
    72                 {
    73                     echo '<td style="vertical-align:bottom;padding-right:10px;">' . '<img name="Alliance" src="' . get_bloginfo('stylesheet_directory') . '/images/faction_alliance.png" border="0" height="32" width="32" />' . '</td>';
    74                 }
     55                echo '<th style="vertical-align:bottom;padding-right:10px;">Account</th>';
     56                echo '<th style="vertical-align:bottom;padding-right:10px;">Level</th>';
     57                echo '<th style="vertical-align:bottom;padding-right:10px;">Name</th>';
     58                echo '<th style="vertical-align:bottom;padding-right:10px;">Race</th>';
     59                echo '<th style="vertical-align:bottom;padding-right:10px;">Class</th>';
     60                echo '<th style="vertical-align:bottom;padding-right:10px;">Faction</th>';
    7561
    76                 echo '</tr>';
    77             }
    78             echo '</table></center><br>';
    79         }
    80     }
    81     else
    82     {
    83         echo '<center><b>Unable to Execute SQL Query.</b><p>';
    84         echo '<b>Ensure you have specified the corrent database</b></center>';
    85     }
    86      $sql_result->close();
     62                while( $row = $sql_result->fetch_assoc() )
     63                {
     64                    echo '<tr>';
    8765
     66                    echo '<td style="vertical-align:bottom;padding-right:10px;">' . $row['account'] . '</td>';
     67                    echo '<td style="vertical-align:bottom;padding-right:10px;">' . $row['level'] . '</td>';
     68                    echo '<td style="vertical-align:bottom;padding-right:10px;">' . $row['name'] . '</td> ';
     69                    echo '<td style="vertical-align:bottom;padding-right:10px;">' . $character_race[$row['race']] . '</td>';
     70                    echo '<td style="vertical-align:bottom;padding-right:10px;">' . $character_class[$row['class']] . '</td>';
     71
     72                    if($row['race'] == 4 || $row['race'] == 5 || $row['race'] == 6 || $row['race'] == 8 || $row['race'] == 10)
     73                    {
     74                        echo '<td style="vertical-align:bottom;padding-right:10px;">' . '<img name="Horde" src="' . get_bloginfo('stylesheet_directory') . '/images/faction_horde.png" border="0" height="32" width="32"/>' . '</td>';
     75                    }
     76                    else
     77                    {
     78                        echo '<td style="vertical-align:bottom;padding-right:10px;">' . '<img name="Alliance" src="' . get_bloginfo('stylesheet_directory') . '/images/faction_alliance.png" border="0" height="32" width="32" />' . '</td>';
     79                    }
     80
     81                    echo '</tr>';
     82                }
     83                echo '</table></center><br>';
     84            }
     85        }
     86        else
     87        {
     88            echo '<center><b>Unable to Execute SQL Query.</b><p>';
     89            echo '<b>Ensure you have specified the corrent database</b></center>';
     90        }
     91         $sql_result->close();
     92
     93    }
     94
     95    $mysqli_conn_playerlist->close();
     96}
     97else
     98{
     99    echo 'Welcome, Visitor!<p>You must login before you can use this feature.';
    88100}
    89101
    90 $mysqli_conn_playerlist->close();
    91 
    92102?>
  • trinitycore-server-management-suite/trunk/trinitymanagementsuite.php

    r584789 r584829  
    2727    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2828*/
    29 require( ABSPATH . '/wp-load.php' );
     29
    3030require_once( plugin_dir_path( __FILE__ ) . '/admin_page_settings.php' );
    3131require_once( plugin_dir_path( __FILE__ ) . '/manage_emails.php' );
     
    129129function my_login_stylesheet()
    130130{
    131 ?>
    132     <link rel="stylesheet" id="custom_wp_admin_css"  href="<?php echo plugins_url( 'css/login.css', __FILE__ ); ?>" type="text/css" media="all" />
    133 <?php
     131    if ( in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) )
     132    {
     133        ?>
     134            <link rel="stylesheet" id="login_css"
     135                href="<?php echo plugins_url( 'css/login.css', __FILE__ ); ?>"
     136                type="text/css" media="all" />
     137        <?php
     138    }
    134139}
    135140add_action( 'login_enqueue_scripts', 'my_login_stylesheet' );
     141
     142function my_login_logo_url()
     143{
     144    return get_bloginfo( 'url' );
     145}
     146add_filter( 'login_headerurl', 'my_login_logo_url' );
Note: See TracChangeset for help on using the changeset viewer.