Esempio n. 1
0
function getAdValue($val)
{
    if (isset($_GET['ad_id'])) {
        return bsa_ad($_GET['ad_id'], $val);
    } else {
        if (isset($_POST[$val]) || isset($_SESSION['bsa_ad_status'])) {
            if (isset($_SESSION['bsa_ad_status']) == 'ad_added') {
                $_SESSION['bsa_clear_form'] = 'ad_added';
                unset($_SESSION['bsa_ad_status']);
            }
            $status = isset($_SESSION['bsa_clear_form']) ? $_SESSION['bsa_clear_form'] : '';
            if ($status == 'ad_added') {
                return '';
            } else {
                return $_POST[$val];
            }
        } else {
            return '';
        }
    }
}
Esempio n. 2
0
 }
 if (isset($sid) && bsa_space($sid, 'title') != '' or isset($sid) && bsa_space($sid, 'add_new') != '') {
     // -- START -- HEADER
     echo '<div class="bsaProHeader" style="background-color:' . bsa_space($sid, 'header_bg') . '">';
     // -- START -- HEADER
     echo '<h3 class="bsaProHeader__title" style="color:' . bsa_space($sid, 'header_color') . '"><span>' . bsa_space($sid, 'title') . '</span></h3>';
     // -- HEADER -- TITLE
     echo '<a class="bsaProHeader__formUrl" href="' . $form_url . '" target="_blank" style="color:' . bsa_space($sid, 'link_color') . '"><span>' . bsa_space($sid, 'add_new') . '</span></a>';
     // -- HEADER -- LINK TO ORDERING FORM
     echo '</div>';
     // -- END -- HEADER
 }
 echo '<div class="bsaProItems ' . bsa_space($sid, "grid_system") . ' ' . (bsa_space($sid, "display_type") == 'carousel' ? 'bsa-owl-carousel bsa-owl-carousel-' . $sid : '') . '" style="background-color:' . bsa_space($sid, 'ads_bg') . '">';
 // -- START -- ITEMS
 foreach ($ads as $key => $ad) {
     if ($ad['id'] != 0 && bsa_ad($ad['id']) != NULL) {
         // -- COUNTING FUNCTION (DO NOT REMOVE!)
         $model = new BSA_PRO_Model();
         $model->bsaProCounter($ad['id']);
     }
     echo '<div class="bsaProItem ' . ($key % $col_per_row == 0 ? "bsaReset" : "") . '" data-animation="' . bsa_space($sid, "animation") . '" style="' . ((bsa_space($sid, "animation") == "none" or bsa_space($sid, "animation") == NULL) ? "opacity:1" : "") . '">';
     // -- START -- ITEM
     $url = parse_url($ad['url']);
     // -- START -- LINK
     $agency_form = get_option('bsa_pro_plugin_agency_ordering_form_url');
     if ($ad['url'] != '') {
         if (isset($example)) {
             // url to form if example in ad space
             echo '<a class="bsaProItem__url" href="' . $form_url . '" target="_blank">';
         } else {
             if (isset($type) && $type == 'agency') {
Esempio n. 3
0
 public function bsaProCounter($ad_id = NULL)
 {
     $user_ip = $_SERVER['REMOTE_ADDR'];
     $browser = $this->bsaGetBrowser();
     if (isset($_GET['bsa_pro_url']) && isset($_GET['bsa_pro_id'])) {
         $aid = $_GET['bsa_pro_id'];
         $sid = bsa_ad($aid, 'space_id');
         $url = bsa_ad($aid, 'url');
         if ($_GET['bsa_pro_url'] != '' && $_GET['bsa_pro_url'] != 1) {
             $url = $url != '' && $url != null ? $url : $_GET['bsa_pro_url'];
         }
         $counterValidator = $this->counterValidator($aid, $user_ip);
         if ($counterValidator == 0) {
             // If not clicked
             update_option('bsa_pro_plugin_dashboard_clicks', get_option('bsa_pro_plugin_dashboard_clicks') + 1);
             // increase clicks stats
         }
         $table_name = $this->getTableName('stats');
         $sql = "SELECT custom FROM {$table_name} WHERE ad_id = {$aid} AND action_type = 'click' AND status = 'correct' ORDER BY id DESC LIMIT 1";
         $get_result = $this->wpdb->get_col($sql);
         $get_counter = isset($get_result[0]) && $get_result[0] != null && $get_result[0] != '' ? $get_result[0] + 1 : null;
         // add new action
         $this->wpdb->insert($this->getTableName('stats'), array('id' => NULL, 'space_id' => $sid, 'ad_id' => $aid, 'action_type' => 'click', 'action_time' => time(), 'user_ip' => $user_ip, 'browser' => $browser, 'status' => $counterValidator == 0 ? 'correct' : 'incorrect', 'custom' => $counterValidator == 0 ? $get_counter : null));
         // decrease click limit
         if (bsa_ad($aid, 'ad_model') == 'cpc' && $counterValidator == 0) {
             $this->wpdb->query("\n\t\t\t\t\tUPDATE {$this->getTableName('ads')}\n\t\t\t\t\tSET ad_limit = `ad_limit` - 1\n\t\t\t\t\tWHERE id = {$aid} LIMIT 1\n\t\t\t\t\t");
         }
         $url = apply_filters("bsa-pro-changeURL", $url, $aid);
         if ($url != NULL) {
             return $url;
         } else {
             return get_site_url();
         }
     } else {
         $aid = $ad_id;
         $sid = bsa_ad($aid, 'space_id');
         $curr_time = time();
         $table_name = $this->getTableName('stats');
         $sql = "SELECT id, action_time, custom FROM {$table_name} WHERE ad_id = {$aid} AND action_type = 'view' AND status = 'correct' ORDER BY id DESC LIMIT 1";
         $get_result = $this->wpdb->get_row($sql, ARRAY_A);
         $get_counter = isset($get_result) && $get_result['id'] != null && $get_result['custom'] != null && $get_result['custom'] != '' ? $get_result['custom'] + 1 : null;
         if (isset($get_counter) && $get_result['action_time'] >= strtotime(date('Y-m-d', $curr_time))) {
             // row exists && today counter
             $this->wpdb->query("\n\t\t\t\t\tUPDATE {$this->getTableName('stats')}\n\t\t\t\t\tSET custom = {$get_counter}, action_time = {$curr_time}\n\t\t\t\t\tWHERE id = {$get_result['id']} LIMIT 1\n\t\t\t\t\t");
         } else {
             $this->wpdb->insert($this->getTableName('stats'), array('id' => NULL, 'space_id' => $sid, 'ad_id' => $aid, 'action_type' => 'view', 'action_time' => $curr_time, 'user_ip' => $user_ip, 'browser' => $browser, 'status' => 'correct', 'custom' => 1));
         }
         // decrease view limit
         if (bsa_ad($aid, 'ad_model') == 'cpm') {
             $this->wpdb->query("\n\t\t\t\t\tUPDATE {$this->getTableName('ads')}\n\t\t\t\t\tSET ad_limit = `ad_limit` - 1\n\t\t\t\t\tWHERE id = {$aid} LIMIT 1\n\t\t\t\t\t");
         }
         return TRUE;
     }
 }
Esempio n. 4
0
function bsaAddNewAd()
{
    $plugin_id = 'bsa_pro_plugin_';
    if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["bsaProAction"] == 'updateAd') {
        if (isset($_SESSION['bsa_ad_' . $_GET['ad_id']])) {
            unset($_SESSION['bsa_ad_' . $_GET['ad_id']]);
            // Reset cache
        }
        // validate form
        foreach (explode(',', str_replace('desc', 'description', $_POST['inputs_required'])) as $input) {
            $error = FALSE;
            if ($input == 'img') {
                if ($_FILES['img']["name"] == '') {
                    $error = FALSE;
                    // img not required for updateAd Action
                }
            } else {
                if ($_POST[$input] == '') {
                    $error = TRUE;
                }
            }
            if ($error == TRUE) {
                echo '
				<div class="updated settings-error">
					<p><strong>Ad not saved.</strong> The ' . str_replace(',', ', ', str_replace('desc', 'description', $_POST['inputs_required'])) . ' fields are required!</p>
				</div>';
                return;
            }
        }
        if ($_POST["buyer_email"] != '') {
            // if isset img
            $uploadName = strtolower($_FILES["img"]["name"]);
            if ($uploadName) {
                $allowedExts = array("gif", "jpeg", "jpg", "png");
                $temp = explode(".", $uploadName);
                $extension = end($temp);
                $fileName = NULL;
                if (($_FILES["img"]["type"] == "image/gif" || $_FILES["img"]["type"] == "image/jpeg" || $_FILES["img"]["type"] == "image/jpg" || $_FILES["img"]["type"] == "image/pjpeg" || $_FILES["img"]["type"] == "image/x-png" || $_FILES["img"]["type"] == "image/png") && $_FILES["img"]["error"] == 0 && in_array($extension, $allowedExts)) {
                    $fileName = time() . '-' . $uploadName;
                    $path = bsa_upload_url('basedir') . $fileName;
                    $thumbLoc = $_FILES["img"]["tmp_name"];
                    list($width, $height) = getimagesize($thumbLoc);
                    $maxSize = get_option($plugin_id . 'thumb_size');
                    $maxWidth = get_option($plugin_id . 'thumb_w');
                    $maxHeight = get_option($plugin_id . 'thumb_h');
                    if ($_FILES["img"]["size"] > $maxSize * 1024 or $width > $maxWidth or $height > $maxHeight) {
                        echo '
						<div class="updated settings-error">
							<p><strong>Ad not saved.</strong> Images was too high.</p>
						</div>';
                        return;
                    } else {
                        // save img
                        move_uploaded_file($thumbLoc, $path);
                    }
                } else {
                    echo '
					<div class="updated settings-error">
						<p><strong>Ad not saved.</strong> Type of image invalid.</p>
					</div>
					';
                    return;
                }
            } else {
                $fileName = NULL;
            }
            $limit = bsa_ad($_GET['ad_id'], 'ad_limit');
            if (isset($_POST["increase_limit"]) && $_POST["increase_limit"] != '') {
                if ($_POST["increase_limit"] > 0 || $_POST["increase_limit"] < 0) {
                    // increase / decrease limit
                    if (bsa_ad($_GET['ad_id'], 'ad_model') == 'cpd') {
                        $time = time();
                        $increase = $_POST["increase_limit"] * 24 * 60 * 60;
                        $diff = $limit - $time;
                        $increase_limit = $diff <= 0 ? $time + $increase : $limit + $increase;
                    } else {
                        $increase_limit = $limit + $_POST["increase_limit"];
                    }
                } else {
                    $increase_limit = bsa_ad($_GET['ad_id'], 'ad_limit');
                }
            } else {
                $increase_limit = null;
            }
            //			var_dump(stripslashes( wp_filter_post_kses( addslashes( $_POST["html"] ) ) ));
            if (bsa_role() == 'user') {
                $status = get_option('bsa_pro_plugin_auto_accept') == 'no' ? 'pending' : null;
                $increase_limit = null;
            } else {
                $status = null;
            }
            $capping = $_POST["capping"] > 0 ? number_format($_POST["capping"], 0, '', '') : 0;
            $model = new BSA_PRO_Model();
            $model->updateAd($_GET['ad_id'], $_POST["buyer_email"], $_POST["title"], $_POST["description"], $_POST["url"], $fileName, stripslashes($_POST["html"]), $capping, $increase_limit, $status);
            unset($_SESSION['bsa_ad_' . $_GET['ad_id']]);
            // Reset cache
            echo '
						<div class="updated settings-error">
							<p><strong>Success!</strong> Ad saved.</p>
						</div>';
        } else {
            echo '
			<div class="updated settings-error">
				<p><strong>Ad not saved.</strong> The buyer email field is required!</p>
			</div>';
        }
    } elseif ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["bsaProAction"] == 'addNewAd') {
        // validate form
        foreach (explode(',', str_replace('desc', 'description', $_POST['inputs_required'])) as $input) {
            $error = FALSE;
            if ($input == 'img') {
                if ($_FILES['img']["name"] == '') {
                    $error = TRUE;
                }
            } else {
                if ($_POST[$input] == '') {
                    $error = TRUE;
                }
            }
            if ($error == TRUE) {
                echo '
				<div class="updated settings-error">
					<p><strong>Ad not saved.</strong> The ' . str_replace(',', ', ', str_replace('desc', 'description', $_POST['inputs_required'])) . ' fields are required!</p>
				</div>';
                return;
            }
        }
        if (isset($_POST["buyer_email"]) && $_POST["buyer_email"] != '' && isset($_POST["space_id"]) && $_POST["space_id"] != '' && isset($_POST["ad_model"]) && $_POST["ad_model"] != '' && isset($_POST["ad_limit_" . $_POST["ad_model"]]) && $_POST["ad_limit_" . $_POST["ad_model"]] != '') {
            // if isset img
            if ($_FILES['img']["name"]) {
                $allowedExts = array("gif", "jpeg", "jpg", "png", "GIF", "JPEG", "JPG", "PNG");
                $temp = explode(".", $_FILES["img"]["name"]);
                $extension = end($temp);
                $fileName = NULL;
                if (($_FILES["img"]["type"] == "image/gif" || $_FILES["img"]["type"] == "image/jpeg" || $_FILES["img"]["type"] == "image/jpg" || $_FILES["img"]["type"] == "image/pjpeg" || $_FILES["img"]["type"] == "image/x-png" || $_FILES["img"]["type"] == "image/png") && $_FILES["img"]["error"] == 0 && in_array($extension, $allowedExts)) {
                    $fileName = time() . '-' . $_FILES["img"]["name"];
                    $path = bsa_upload_url('basedir') . $fileName;
                    $thumbLoc = $_FILES["img"]["tmp_name"];
                    list($width, $height) = getimagesize($thumbLoc);
                    $maxSize = get_option($plugin_id . 'thumb_size');
                    $maxWidth = get_option($plugin_id . 'thumb_w');
                    $maxHeight = get_option($plugin_id . 'thumb_h');
                    if ($_FILES["img"]["size"] > $maxSize * 1024 or $width > $maxWidth or $height > $maxHeight) {
                        echo '
						<div class="updated settings-error">
							<p><strong>Ad not saved.</strong> Images was too high.</p>
						</div>';
                        return;
                    } else {
                        // save img
                        move_uploaded_file($thumbLoc, $path);
                    }
                } else {
                    echo '
					<div class="updated settings-error">
						<p><strong>Ad not saved.</strong> Type of image invalid.</p>
					</div>
					';
                    return;
                }
            } else {
                $fileName = '';
            }
            // set limit for cpd - change days to timestamp
            if ($_POST["ad_model"] == 'cpd') {
                $ad_limit = time() + $_POST["ad_limit_" . $_POST["ad_model"]] * 24 * 60 * 60;
            } else {
                $ad_limit = $_POST["ad_limit_" . $_POST["ad_model"]];
            }
            $model = new BSA_PRO_Model();
            if (bsa_role() == 'user') {
                $status = get_option('bsa_pro_plugin_auto_accept') == 'no' ? 'pending' : 'active';
            } else {
                $status = 'active';
            }
            $capping = $_POST["capping"] > 0 ? number_format($_POST["capping"], 0, '', '') : 0;
            $model->addNewAd(NULL, $_POST["space_id"], $_POST["buyer_email"], $_POST["title"], $_POST["description"], $_POST["url"], $fileName, stripslashes($_POST["html"]), $capping, $_POST["ad_model"], $ad_limit, 0.0, 2, $status);
            // paid 2 - Added via Admin Panel
            $_SESSION['bsa_ad_status'] = 'ad_added';
            echo '
						<div class="updated settings-error">
							<p><strong>Success!</strong> Ad saved.</p>
						</div>';
        } else {
            echo '
			<div class="updated settings-error">
				<p><strong>Ad not saved.</strong> The buyer email, space id, billing model fields are required!</p>
			</div>';
        }
    }
}
        }
        $space_verify = $space_verify != '' ? explode(',', $space_verify) : FALSE;
    }
    if (isset($_GET['oid']) && $_GET['oid'] != '' && bsa_ad($_GET['oid'], 'id') != null) {
        // Payments
        if (empty($_GET)) {
            $checkGET = '?';
        } else {
            $checkGET = '&';
        }
        $orderId = $_GET['oid'];
        $userEmail = bsa_ad($_GET['oid'], 'buyer_email');
        $amount = bsa_ad($_GET['oid'], 'cost');
        // reset cache sessions
        unset($_SESSION['bsa_ad_' . $orderId]);
        if (bsa_ad($_GET['oid'], 'paid') == 1 || bsa_ad($_GET['oid'], 'paid') == 2) {
            ?>
				<div class="bsaProAlert bsaProAlertSuccess">
					<strong><?php 
            echo get_option($bsaTrans . "alert_success");
            ?>
</strong>
					<p><?php 
            echo get_option($bsaTrans . "payment_paid");
            ?>
</p>
				</div>
				<small style="margin-top: -10px;display: block;">
					<a href="<?php 
            echo get_option('bsa_pro_plugin_agency_ordering_form_url');
            ?>
Esempio n. 6
0
		</div>

		<div class="bsaCompare bsaCompareB <?php 
    echo $ctrA <= $ctrB ? 'bsaCompareWinner' : null;
    ?>
">

			<div class="bsaCompareSignature">B</div>

			<div class="bsaCompareAdId">Ad ID: <strong><?php 
    echo $get_ad_B;
    ?>
</strong></div>
			<div class="bsaCompareTemplate">Template: <strong><?php 
    echo bsa_space(bsa_ad($get_ad_B, 'space_id'), 'template');
    ?>
</strong></div>
			<div class="bsaCompareWeight">Traffic Weight: <strong><?php 
    echo $trafficB . '%';
    ?>
</strong></div>

			<div class="bsaCompareCTR"><div class="bsaCompareCTRInner"><strong><?php 
    echo $ctrB . '%';
    ?>
</strong><br>CTR</div></div>

			<div class="bsaCompareViews"><span><?php 
    echo $viewsB;
    ?>
Esempio n. 7
0
function create_bsa_pro_short_code_agency_form()
{
    ob_start();
    if (isset($_GET['bsa_pro_stats']) && isset($_GET['bsa_pro_id']) && isset($_GET['bsa_pro_email']) && bsa_ad($_GET['bsa_pro_id'], 'buyer_email') == $_GET['bsa_pro_email']) {
        require dirname(__FILE__) . '/BSA_PRO_Agency_Stats.php';
    } else {
        require dirname(__FILE__) . '/BSA_PRO_Agency_Ordering_form.php';
    }
    return ob_get_clean();
}