HEX
Server: LiteSpeed
System: Linux cde2.duelhost.dk 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64
User: dtptviut (1121)
PHP: 8.0.30
Disabled: exec,system,passthru,shell_exec,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/dtptviut/public_html/wp-content/plugins/comparisonfeed-wp/compare-admin.php
<?php
    $adservice_options = get_option("adservice_options");
    if (isset($_POST['adservice-save'])) {
        /* Initialize variables and use stripslashes on input
        because they don't need escaping and it prevents users
        from using ", ' and \ in their login/password. */

        $regularLogin = false;
        $login = null;
        $pwd = null;
        if (isset($_POST['adservice_login']) && isset($_POST['adservice_pwd'])) {
            $regularLogin = true;
            $login = stripslashes($_POST['adservice_login']);
            $pwd = stripslashes($_POST['adservice_pwd']);
        }

        $facebookLogin = false;
        $thirdpartyId = null;
        $thirdpartyProvider = null;
        if (isset($_POST['thirdparty_login_id']) && isset($_POST['thirdparty_login_provider'])) {
            $facebookLogin = true;
            $thirdpartyId = stripslashes($_POST['thirdparty_login_id']);
            $thirdpartyProvider = stripslashes($_POST['thirdparty_login_provider']);
        }

        if ($regularLogin || $facebookLogin) {
            /* Make callback to adservice API using callbackCode to get loginToken */
            $body = ($facebookLogin) ? 
                array('thirdparty_login_id' => $thirdpartyId, 'thirdparty_login_provider' => $thirdpartyProvider) :
                array('username' => $login, 'password' => $pwd);
            $userData = json_remote_post("https://api.adservice.com/v2/publisher/account/logintoken", null, $body);

            # Make sure we got both a LoginToken and PID.
            if (isset($userData->data->login_token) && isset($userData->data->pid)) {
                # If logging in using FB then we need to do another request to get
                # the login of the account.
                if ($facebookLogin) {
                    $auth = array(
                        'pid' => $userData->data->pid,
                        'token' => $userData->data->login_token
                    );
                    $accountData = json_remote_get("https://api.adservice.com/v2/publisher/account", $auth);
                    
                    if (isset($accountData->data->login)) {
                        $login = $accountData->data->login;
                    }
                }

                # Store the account info in our options.
                $adservice_options['login'] = $login;
                $adservice_options['pid'] = $userData->data->pid;
                $adservice_options['token'] = $userData->data->login_token;
            }
        }
        /* save the options */
        update_option('adservice_options', $adservice_options);

        // Register plugin install.
        custom_plugin_activation();
    }

    if (isset($_POST['adservice-unlink'])) {
        $adservice_options['login'] = "";
        $adservice_options['pid'] = "";
        $adservice_options['token'] = "";
        $adservice_options['accounts'] = "";
        update_option('adservice_options', $adservice_options);
    }
?>

<div class="wrap">
    <div id="adserviceadmin">
        <img src="<?php echo plugins_url('comparisonfeed-wp/images/adservice_logo.svg');?>" class="as-logo">
        <?php 
            if (isset($adservice_options['login']) && $adservice_options['login']) {
                /* get accounts and update */
                $adservice_options['accounts'] = getAccounts($adservice_options);
                update_option('adservice_options', $adservice_options);
                $accounts = $adservice_options['accounts'];
        ?>
        <div class="postbox-container metabox-holder as-wrapper" style="width:100%;">
            <div class="postbox">
                <div class="inside">
                    <h3>You successfully connected your Adservice account</h3>
                    <p>This WordPress site is now connected to the Adservice account <strong><?php print $adservice_options['login']; ?></strong>.</p>

                    <!-- Only show this, if there is connected accounts -->
                    <?php if ($accounts > 1) { ?>
                        <h4>Your account is connected to these Adservice accounts:</h4>

                        <ul>
                        <?php foreach ($accounts as $account => $value) { ?>
                            <?php if ($value['countrycode'] === 'dk') {
                                $country = "Denmark";
                            } else if ($value['countrycode'] === 'se') {
                                $country = "Sweden";
                            } else if ($value['countrycode'] === 'no') {
                                $country = "Norway";
                            } else if ($value['countrycode'] === 'fi') {
                                $country = "Finland";
                            } else if ($value['countrycode'] === 'de') {
                                $country = "Germany";
                            } else if ($value['countrycode'] === 'pl') {
                                $country = "Poland";
                            } else if ($value['countrycode'] === 'es') {
                                $country = "Spain";
                            } else if ($value['countrycode'] === 'mx') {
                                $country = "Mexico";
                            }
                            ?>
                            <li><?php echo $value['company_name']; ?><em> (<?php echo $country; ?>)</em></li>
                        <?php } ?>
                        </ul>

                        <p>You can use the data from all these accounts on this WordPress site.</p>

                    <?php } ?>

                    <h5>Getting started</h5>
                    <ul>
                        <li>Create and manage your feeds using our <a href="https://publisher.adservice.com/tools/comparisonfeed/feed" target="_blank" title="Click to open Feed Builder">Feed Builder</a></li>
                        <li>Add feeds to your page, post or widget by inserting the WordPress shortcode</li>
                    </ul>

                    <h5>Disconnecting</h5>
                    <p>You can disconnect the Adservice account <strong><?php print $adservice_options['login']; ?></strong> from your site
                    if you for instance want to use a different account that's not connected to your current one. 
                    </br></br>
                    Warning! This will disable the Adservice Comparison plugin, but enables you to connect another Adservice account.</p>
                    <form method="post">
                        <input class="button as-disconnect-btn" type="submit" value="Disconnect" name="adservice-unlink"/><br/>
                    </form>
                </div>
            </div>

            <!-- <input class="button-primary" type="submit" value="Save Changes" name="adservice-save" /> -->
        </div>
        <?php
            } else {
        ?>
        <?php if (!empty($_POST) && !isset($_POST['adservice-unlink'])) { ?>
            <div class="error" style="margin: 15px 0 5px 0;">
                The submitted credentials are incorrect - please try again.
            </div>
        <?php } ?>
        <div class="postbox-container metabox-holder as-wrapper" style="width:100%;">
            <div class="postbox">

                <div class="inside" >

                    <h3>Connect your Adservice account</h3>
                    To get started using the Adservice Comparison plugin please connect your Adservice account.
                    <br/><br/>
                    <form method="post">
                        <table>
                            <tr>
                                <td>Your Adservice login:</td>
                                <td><input type="text" name="adservice_login"></td>
                            </tr>
                            <tr>
                                <td>Your Adservice password:</td>
                                <td><input type="password" name="adservice_pwd"></td>
                            </tr>
                            <tr>
                                <td> </td>
                                <td><input class="button-primary" type="submit" value="Connect account" name="adservice-save" /></td>
                            </tr>
                        </table>
                    </form>

                    <p>
                        If you have enabled Facebook as a third party login for your account,
                        you may also connect using your Facebook User ID.<br/>
                        You can find it under 
                        <a href="https://publisher.adservice.com/edit-account/information" 
                            title="Go to your account settings" target="_blank">
                            Edit Account -> Account Information</a> on 
                        <a href="https://publisher.adservice.com" target="_blank">publisher.adservice.com</a>.
                    </p>
                    <p><i>
                        NOTE: Your User ID will only be used for the initial authentication.
                        It will not be stored in this plugin or in WordPress in general.
                    </i></p>
                    <form method="post">
                        <input type="hidden" name="thirdparty_login_provider" value="facebook"/>
                        <table>
                            <tr>
                                <td>Your Facebook User ID:</td>
                                <td><input type="password" name="thirdparty_login_id"></td>
                            </tr>
                            <tr>
                                <td></td>
                                <td><input class="button-primary" type="submit" value="Connect using Facebook" name="adservice-save"/></td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    <?php
        }
    ?>
    </form>
</div>