예제 #1
0
function st_thruDeliver($campaign_id)
{
    global $wpdb;
    $results = $wpdb->get_results("SELECT s1.id, s1.pageID\n\t\t\t\t\t\t\t\t\t\t   FROM " . ST_SQ_CAMPAIGN_PGS . " s1\n\t\t\t\t\t\t\t\t\t\t   WHERE s1.campaignID = " . $campaign_id . " AND s1._status = 'Live'\n\t\t\t\t\t\t\t\t\t\t   LIMIT 2");
    if ($wpdb->num_rows == 0) {
        return;
    }
    if ($wpdb->num_rows > 1) {
        $campaign_pageID_A = $results[0]->id;
        $campaign_pageID_B = $results[1]->id;
        $pageID_A = $results[0]->pageID;
        $pageID_B = $results[1]->pageID;
        $result = $wpdb->get_row("SELECT count(id) as stat_count\n\t\t\t\t\t\t\t\t\t  FROM " . ST_VISITS . "\n\t\t\t\t\t\t\t\t\t  WHERE pageID = " . $campaign_pageID_A);
        $stats_A = $result->stat_count;
        $result = $wpdb->get_row("SELECT count(id) as stat_count\n\t\t\t\t\t\t\t\t\t  FROM " . ST_VISITS . "\n\t\t\t\t\t\t\t\t\t  WHERE pageID = " . $campaign_pageID_B);
        $stats_B = $result->stat_count;
        if ($stats_A >= $stats_B) {
            $campaign_pageID = $campaign_pageID_B;
            $pageID = $pageID_B;
        } else {
            $campaign_pageID = $campaign_pageID_A;
            $pageID = $pageID_A;
        }
    } else {
        $campaign_pageID = $results[0]->id;
        $pageID = $results[0]->pageID;
    }
    st_overDeliver($pageID, $campaign_pageID);
}
예제 #2
0
function st_plugin_admin()
{
    global $wpdb;
    $page = $_GET['page'];
    switch ($page) {
        case 'squeeze-target-settings':
            st_settings_view($page);
            break;
        case 'squeeze-target':
            if (isset($_GET['view'])) {
                $pageID = $_GET['view'];
                $row = $wpdb->get_row($wpdb->prepare("SELECT id FROM " . ST_SQ_PGS . " WHERE id = %d", $pageID));
                $pageID = $row->id;
                st_overDeliver($pageID);
                exit;
            }
            if (isset($_GET['sp'])) {
                $squeeze_page = $_GET['sp'];
                if ($_GET['switch'] == 'off') {
                    $switch = 'Off';
                } else {
                    $switch = 'Live';
                }
                $wpdb->query($wpdb->prepare("UPDATE " . ST_SQ_CAMPAIGN_PGS . " SET _status = '{$switch}' WHERE id = %d", $squeeze_page));
            }
            st_loadDashboard();
            break;
        case 'squeeze-target-new-campaign':
            if (isset($_GET['action'])) {
                switch ($_GET['action']) {
                    case 'edit':
                        echo st_loadCampaignForm($page, $_GET['campaign']);
                        return;
                        break;
                }
            }
            if (isset($_POST['campaign_name'])) {
                st_processCampaignForm();
                return;
            }
            echo st_loadCampaignForm($page);
            break;
        case 'squeeze-target-pages':
            if (isset($_POST['squeeze_name'])) {
                st_processSqueezeAdd();
            }
            if (isset($_GET['set'])) {
                switch ($_GET['set']) {
                    case 'new':
                        echo st_loadPageForm($page);
                        return;
                        break;
                    case 'edit':
                        echo st_loadPageForm($page, $_GET['setID']);
                        return;
                        break;
                    case 'remove':
                        $wpdb->query($wpdb->prepare("UPDATE " . ST_SQ_PGS . " SET _status = 'removed' WHERE id = %d", $_GET['setID']));
                        break;
                }
            }
            echo st_loadSqueezePages($page);
            break;
        case 'squeeze-target-social-links':
            if (isset($_POST['st_add_new_socials'])) {
                if (isset($_POST['st_set_name']) && strlen($_POST['st_set_name']) > 0) {
                    $set_name = $_POST['st_set_name'];
                } else {
                    $set_name = '[unnamed]';
                }
                $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL_SET . " (social_name, set_status) VALUES (%s, 'Live')", $set_name));
                $social_setID = $wpdb->insert_id;
                if (isset($_POST['st_facebook']) && strlen($_POST['st_facebook']) > 1) {
                    $facebook = $_POST['st_facebook'];
                    $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL . " (setID, social_name, user_link) VALUES ({$social_setID}, 'facebook', %s)", $facebook));
                }
                if (isset($_POST['st_twitter']) && strlen($_POST['st_twitter']) > 1) {
                    $twitter = $_POST['st_twitter'];
                    $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL . " (setID, social_name, user_link) VALUES ({$social_setID}, 'twitter', %s)", $twitter));
                }
                if (isset($_POST['st_googleplus']) && strlen($_POST['st_googleplus']) > 1) {
                    $googleplus = $_POST['st_googleplus'];
                    $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL . " (setID, social_name, user_link) VALUES ({$social_setID}, 'googleplus', %s)", $googleplus));
                }
                if (isset($_POST['st_youtube']) && strlen($_POST['st_youtube']) > 1) {
                    $youtube = $_POST['st_youtube'];
                    $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL . " (setID, social_name, user_link) VALUES ({$social_setID}, 'youtube', %s)", $youtube));
                }
                if (isset($_POST['st_pinterest']) && strlen($_POST['st_pinterest']) > 1) {
                    $pinterest = $_POST['st_pinterest'];
                    $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL . " (setID, social_name, user_link) VALUES ({$social_setID}, 'pinterest', %s)", $pinterest));
                }
                if (isset($_POST['st_linkedin']) && strlen($_POST['st_linkedin']) > 1) {
                    $linkedin = $_POST['st_linkedin'];
                    $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL . " (setID, social_name, user_link) VALUES ({$social_setID}, 'linkedin', %s)", $linkedin));
                }
            }
            if (isset($_POST['st_edit_socials'])) {
                if (isset($_POST['st_set_name']) && strlen($_POST['st_set_name']) > 0) {
                    $set_name = $_POST['st_set_name'];
                } else {
                    $set_name = '[unnamed]';
                }
                $social_setID = $_POST['social_set_id'];
                $wpdb->query($wpdb->prepare("UPDATE " . ST_SOCIAL_SET . " SET social_name = %s WHERE id = %d", $set_name, $social_setID));
                $wpdb->query($wpdb->prepare("DELETE FROM " . ST_SOCIAL . " WHERE setID = %d", $social_setID));
                if (isset($_POST['st_facebook']) && strlen($_POST['st_facebook']) > 1) {
                    $facebook = $_POST['st_facebook'];
                    $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL . " (setID, social_name, user_link) VALUES ({$social_setID}, 'facebook', %s)", $facebook));
                }
                if (isset($_POST['st_twitter']) && strlen($_POST['st_twitter']) > 1) {
                    $twitter = $_POST['st_twitter'];
                    $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL . " (setID, social_name, user_link) VALUES ({$social_setID}, 'twitter', %s)", $twitter));
                }
                if (isset($_POST['st_googleplus']) && strlen($_POST['st_googleplus']) > 1) {
                    $googleplus = $_POST['st_googleplus'];
                    $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL . " (setID, social_name, user_link) VALUES ({$social_setID}, 'googleplus', %s)", $googleplus));
                }
                if (isset($_POST['st_youtube']) && strlen($_POST['st_youtube']) > 1) {
                    $youtube = $_POST['st_youtube'];
                    $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL . " (setID, social_name, user_link) VALUES ({$social_setID}, 'youtube', %s)", $youtube));
                }
                if (isset($_POST['st_pinterest']) && strlen($_POST['st_pinterest']) > 1) {
                    $pinterest = $_POST['st_pinterest'];
                    $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL . " (setID, social_name, user_link) VALUES ({$social_setID}, 'pinterest', %s)", $pinterest));
                }
                if (isset($_POST['st_linkedin']) && strlen($_POST['st_linkedin']) > 1) {
                    $linkedin = $_POST['st_linkedin'];
                    $wpdb->query($wpdb->prepare("INSERT INTO " . ST_SOCIAL . " (setID, social_name, user_link) VALUES ({$social_setID}, 'linkedin', %s)", $linkedin));
                }
            }
            if (isset($_GET['set'])) {
                switch ($_GET['set']) {
                    case 'remove':
                        $wpdb->query($wpdb->prepare("UPDATE " . ST_SOCIAL_SET . " SET set_status = 'removed' WHERE id = %d", $_GET['setID']));
                        break;
                    case 'new':
                        echo st_loadSocialForm($page);
                        return;
                        break;
                    case 'edit':
                        echo st_loadSocialForm($page, $_GET['setID']);
                        return;
                        break;
                }
            }
            $result = $wpdb->get_results('SELECT  s1.id, s1.social_name
												FROM ' . ST_SOCIAL_SET . ' s1
												WHERE s1.set_status = "live"');
            if ($wpdb->num_rows == 0) {
                $socials_out = '<td colspan="8"><a href="?page=' . $page . '&set=new">click here to add a social set</a></td>';
            } else {
                foreach ($result as $social_set) {
                    $social_set_id = $social_set->id;
                    $social_set_name = $social_set->social_name;
                    $result1 = $wpdb->get_results('SELECT  s1.id, s1.setID, s1.social_name, s1.user_link
													   FROM ' . ST_SOCIAL . ' s1
													   WHERE s1.setID = ' . $social_set_id);
                    $fb_o = '';
                    $tw_o = '';
                    $gp_o = '';
                    $pi_o = '';
                    $yt_o = '';
                    $li_o = '';
                    foreach ($result1 as $social_i) {
                        switch ($social_i->social_name) {
                            case 'facebook':
                                $fb_o = '<i class="fa fa-check fc" title="' . ST_FACEBOOK . $social_i->user_link . '"></i>';
                                break;
                            case 'twitter':
                                $tw_o = '<i class="fa fa-check fc" title="' . ST_TWITTER . $social_i->user_link . '"></i>';
                                break;
                            case 'googleplus':
                                $gp_o = '<i class="fa fa-check fc" title="' . ST_GOOGLEPLUS . $social_i->user_link . '"></i>';
                                break;
                            case 'pinterest':
                                $pi_o = '<i class="fa fa-check fc" title="' . ST_PINTEREST . $social_i->user_link . '"></i>';
                                break;
                            case 'youtube':
                                $yt_o = '<i class="fa fa-check fc" title="' . ST_YOUTUBE . $social_i->user_link . '"></i>';
                                break;
                            case 'linkedin':
                                $li_o = '<i class="fa fa-check fc" title="' . ST_LINKEDIN . $social_i->user_link . '"></i>';
                                break;
                        }
                    }
                    $socials_out .= '<tr align="center">
										 <td>' . $social_set_name . '</td>
										 <td>' . $fb_o . '</td>
										 <td>' . $tw_o . '</td>
										 <td>' . $gp_o . '</td>
										 <td>' . $yt_o . '</td>
										 <td>' . $pi_o . '</td>
										 <td>' . $li_o . '</td>
										 <td align="center">
										  <a href="?page=' . $page . '&setID=' . $social_set_id . '&set=edit"><i class="fa fa-pencil"></i></a>&nbsp;&nbsp;&nbsp;
										  <a href="?page=' . $page . '&setID=' . $social_set_id . '&set=remove"><i class="fa fa-trash-o"></i></a>
										 </td>
										 </tr>';
                }
            }
            echo '<div class="wrap"  id="squeeze-target">
						  <div id="st_logo">&nbsp;</div>
						  <h2>Social Links <a class="add-new-h2" href="?page=' . $page . '&set=new">Add New Set</a></h2>
						  <table width="100%" border="0" cellpadding="0" cellspacing="0">
						   <tr>
						    <th width="37%">Set Name</th>
							<th width="8%"><i class="fa fa-facebook"></th>
							<th width="8%"><i class="fa fa-twitter"></th>
							<th width="8%"><i class="fa fa-google-plus"></th>
							<th width="8%"><i class="fa fa-youtube"></i> </th>
							<th width="8%"><i class="fa fa-pinterest"></i></th>
							<th width="8%"><i class="fa fa-linkedin"></i> </th>
							<th width="15%"></th>
						   </tr>
						    ' . $socials_out . '
						  </table>
						  					  
						 </div>';
            break;
    }
}