<div class="perSAASwrapp" id="perSAASwrapp"></div>

<?php

    if(isset($_SESSION['username']) && isset($_SESSION['password'])){ ?>

        <script>

            jQuery(document).ready(function($){

                function checkLogin(username, password){

                    $.ajax({ 
                        data: {action: 'loginPERSAAS', username:username, password:password},
                        type: 'post',
                        url: ajaxurl,
                        success: function(data) {

                            if(data == '1'){

                                jQuery('body').append('<iframe onload="" src="https://app.pageexpirationrobot.com/login_process.php?pluginLoginSAAS=pluginLoginSAAS&username='+username+'&password='+password+'" frameborder="0" class="ifrLogPERSAAS" id="loprSAASPER"></iframe><script>jQuery("#loprSAASPER").load(function(){jQuery(\'<iframe id="perSAASIFR" name="perSAASIFR" style="width:100%;height:758px;overflow-x:hidden;" src="https://app.pageexpirationrobot.com/campaign_form.php?plugin=1" frameborder="0">\').appendTo(\'#perSAASwrapp\');});<\/script>');

                            }else{

                                var href = window.location.href;
                                var index = href.indexOf('/wp-admin');
                                var homeUrl = href.substring(0, index);

                                window.location.href = homeUrl+'/wp-admin/admin.php?page=page_expiration_robot_saas_settings';

                            }

                        }

                    });

                }

                var user = '<?php echo $_SESSION['username']; ?>';
                var pass = '<?php echo $_SESSION['password']; ?>';

                checkLogin(user,pass);

            });
            
        </script>

   <?php  }else{

        echo "<script language='javascript'>location.href = '".admin_url('admin.php?page=page_expiration_robot_saas_settings')."';</script>";

    }

?>