<?php

require dirname(dirname(__FILE__)) . '/includes/bootstrap.php';
//Getting Current User ID
if (!buckys_check_user_acl(USER_ACL_REGISTERED)) {
    buckys_redirect('/register.php');
}
$classAds = new BuckysAds();
$userID = buckys_is_logged_in();
$page = isset($_GET['page']) ? buckys_escape_query_integer($_GET['page']) : 1;
$status = isset($_GET['status']) ? buckys_escape_query_string($_GET['status']) : 'active';
$activeAdsCount = $classAds->getUserAdsCount($userID, 'active');
$pendingAdsCount = $classAds->getUserAdsCount($userID, 'pending');
$expiredAdsCount = $classAds->getUserAdsCount($userID, 'expired');
switch ($status) {
    case 'active':
        $totalCount = $activeAdsCount;
        break;
    case 'pending':
        $totalCount = $pendingAdsCount;
        break;
    case 'expired':
        $totalCount = $expiredAdsCount;
        break;
}
$pagination = new Pagination($totalCount, BuckysAds::$COUNT_PER_PAGE, $page);
$page = $pagination->getCurrentPage();
$userAds = $classAds->getUserAds($userID, $status, $page, BuckysAds::$COUNT_PER_PAGE);
buckys_enqueue_stylesheet('publisher.css');
$TNB_GLOBALS['headerType'] = "ads";
$TNB_GLOBALS['content'] = "ads/advertiser";
<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
//Getting Current User ID
if (!buckys_check_user_acl(USER_ACL_MODERATOR)) {
    buckys_redirect('/index.php', MSG_PERMISSION_DENIED, MSG_TYPE_ERROR);
}
$classAds = new BuckysAds();
if (isset($_REQUEST['action'])) {
    if (!buckys_check_form_token()) {
        buckys_redirect('/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
    }
    if ($_REQUEST['action'] == 'reject-ads') {
        $classAds->rejectAds($_REQUEST['adID']);
        buckys_redirect('/manage_ads.php', MSG_AD_ADS_REJECTED);
    } else {
        if ($_REQUEST['action'] == 'approve-ads') {
            $classAds->approveAds($_REQUEST['adID']);
            buckys_redirect('/manage_ads.php', MSG_AD_ADS_APPROVED);
        }
    }
}
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$totalCount = $classAds->getPendingAdsCount();
//Init Pagination Class
$pagination = new Pagination($totalCount, BuckysAds::$COUNT_PER_PAGE, $page);
$page = $pagination->getCurrentPage();
$objects = $classAds->getPendingAds($page, BuckysAds::$COUNT_PER_PAGE);
buckys_enqueue_javascript('manage_ads.js');
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('moderator.css');
 $targetPath = DIR_FS_TMP;
 // temp files
 if (!is_dir($targetPath)) {
     mkdir($targetPath, 0777);
     //Create Index.html to prevent directory listing issue
     $fp = fopen($targetPath . "/index.html", "w");
     fclose($fp);
 }
 // Validate the file type
 $fileParts = pathinfo($_FILES['Filedata']['name']);
 //Check the file extension
 if (in_array(strtolower($fileParts['extension']), $TNB_GLOBALS['imageTypes'])) {
     //Check Image Size
     list($width, $height, $type, $attr) = getimagesize($tempFile);
     //Check Size
     $adClass = new BuckysAds();
     $size = $adClass->getAdSizeById($_REQUEST['size']);
     $offset = abs($width - $size['width']) + abs($height - $size['height']);
     if ($offset > 4) {
         echo json_encode(['success' => 0, 'msg' => MSG_INVALID_PHOTO_SIZE]);
         exit;
     }
     if (!in_array($type, [IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_JPEG2000, IMAGETYPE_PNG])) {
         echo json_encode(['success' => 0, 'msg' => MSG_INVALID_PHOTO_TYPE]);
         exit;
     }
     if ($width > MAX_IMAGE_WIDTH || $height > MAX_IMAGE_HEIGHT) {
         echo json_encode(['success' => 0, 'msg' => MSG_PHOTO_MAX_SIZE_ERROR]);
     } else {
         $targetFileName = md5(session_id() . 'ad') . "." . $fileParts['extension'];
         $targetFile = $targetPath . $targetFileName;
    $pageIns = new BuckysPage();
    $pageList = $pageIns->getPagesByUserId($userID);
    if (count($pageList) > 0) {
        foreach ($pageList as $pageD) {
            echo sprintf('<a href="/page.php?pid=%d" class="accountSubLinks">%s</a><br/>', $pageD['pageID'], $pageD['title']);
        }
    }
    ?>

        <!-- Control Panel-->
        <?php 
    if (buckys_check_user_acl(USER_ACL_MODERATOR)) {
        ?>
            <?php 
        $reportedItems = BuckysReport::getReportedObjectCount();
        $pendingAds = BuckysAds::getPendingAdsCount();
        ?>
            <h6>Moderator Panel</h6>
            <a href="/reported.php"
                class="accountSubLinks<?php 
        echo $reportedItems > 0 ? 'Bold' : '';
        ?>
">Reported Items<?php 
        echo $reportedItems > 0 ? ' (' . $reportedItems . ')' : '';
        ?>
</a>
            <br/>
            <a href="/manage_ads.php"
                class="accountSubLinks<?php 
        echo $pendingAds > 0 ? 'Bold' : '';
        ?>
<?php

require dirname(dirname(__FILE__)) . '/includes/bootstrap.php';
//Getting Current User ID
if (!buckys_check_user_acl(USER_ACL_REGISTERED)) {
    buckys_redirect('/index.php', MSG_PERMISSION_DENIED, MSG_TYPE_ERROR);
}
$userID = buckys_is_logged_in();
$adClass = new BuckysAds();
if (isset($_POST['action']) && $_POST['action'] == 'create-ad') {
    if (!buckys_check_form_token()) {
        buckys_redirect('/ads/create_ad.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
    } else {
        if ($adClass->saveAd($userID, $_POST)) {
            buckys_redirect('/ads/advertiser.php?status=pending', $adClass->last_message);
        } else {
            buckys_redirect('/ads/create_ad.php?type=' . $_POST['type'], $adClass->last_message, MSG_TYPE_ERROR);
        }
    }
}
$adSizes = $adClass->getAdSizes();
$adType = isset($_GET['type']) && $_GET['type'] == 'Image' ? 'Image' : 'Text';
buckys_enqueue_stylesheet('publisher.css');
buckys_enqueue_stylesheet('uploadify.css');
buckys_enqueue_javascript('uploadify/jquery.uploadify.js');
buckys_enqueue_javascript('jquery.number.js');
buckys_enqueue_javascript('create_ad.js');
$TNB_GLOBALS['headerType'] = "ads";
$TNB_GLOBALS['content'] = "ads/create_ad";
$TNB_GLOBALS['title'] = "Create New Ad - thenewboston Ads";
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
예제 #6
0
<?php

require dirname(dirname(__FILE__)) . '/includes/bootstrap.php';
//Getting Current User ID
if (!buckys_check_user_acl(USER_ACL_REGISTERED)) {
    buckys_redirect('/index.php', MSG_PERMISSION_DENIED, MSG_TYPE_ERROR);
}
$userID = buckys_is_logged_in();
$classAds = new BuckysAds();
//Add Funds
if (isset($_POST['action']) && $_POST['action'] == 'add-funds') {
    if (!buckys_check_form_token()) {
        buckys_redirect('/ads/advertiser.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
    }
    $adID = buckys_escape_query_integer($_POST['id']);
    $adDetail = $classAds->getAdById($adID);
    if (!$adDetail || $adDetail['ownerID'] != $userID && buckys_check_user_acl(USER_ACL_MODERATOR)) {
        buckys_redirect('/ads/advertiser.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
    }
    $result = $classAds->addFunds($userID, $adID, $_POST['amount']);
    buckys_add_message($classAds->last_message, $result ? MSG_TYPE_SUCCESS : MSG_TYPE_ERROR);
}
buckys_enqueue_stylesheet('publisher.css');
$adID = buckys_escape_query_integer($_GET['id']);
$adDetail = $classAds->getAdById($adID);
if (!$adDetail || $adDetail['ownerID'] != $userID && buckys_check_user_acl(USER_ACL_MODERATOR)) {
    buckys_redirect('/ads/advertiser.php');
}
$TNB_GLOBALS['headerType'] = "ads";
$TNB_GLOBALS['content'] = "ads/view";
buckys_enqueue_javascript('jquery.number.js');
    /**
     * @param $token
     * @return bool|string
     */
    public function renderAd($token)
    {
        global $db;
        //Getting Ad details by token
        $query = $db->prepare("SELECT * FROM " . TABLE_PUBLISHER_ADS . " WHERE token=%s", $token);
        $adDetail = $db->getRow($query);
        if (!$adDetail) {
            return false;
        }
        $classAds = new BuckysAds();
        $sizeDetail = $classAds->getAdSizeById($adDetail['size']);
        //fixes a display issues with vertical ads
        if ($sizeDetail['type'] == 'vertical') {
            $spaceToSubtract = $sizeDetail['width'] - 18;
            //16px for padding, 2px for border
            $displayWidth = 'width:' . $spaceToSubtract . 'px;';
        }
        //changes padding for horizontal ads
        if ($sizeDetail['type'] == 'horizontal' && $sizeDetail['ads'] > 1) {
            $newHorizontalPadding = 'padding: 0px 20px;';
        }
        $query1 = "SELECT AD.* FROM " . TABLE_ADS . " AS AD WHERE AD.defaultAd=0 AND AD.status='" . TNB_AD_STATUS_ACTIVE . "' AND AD.ownerID != '" . $adDetail['publisherID'] . "' AND AD.type = 'Text' ORDER BY rand() LIMIT " . $sizeDetail['ads'];
        $query2 = "SELECT AD.* FROM " . TABLE_ADS . " AS AD WHERE AD.defaultAd=0 AND AD.status='" . TNB_AD_STATUS_ACTIVE . "' AND AD.ownerID != '" . $adDetail['publisherID'] . "' AND AD.type = 'Image' AND AD.adSize='" . $sizeDetail['id'] . "' ORDER BY rand() LIMIT 1";
        if (mt_rand(0, 10) > 5) {
            $results = $db->getResultsArray($query1);
            if (!$results) {
                $results = $db->getResultsArray($query2);
            }
        } else {
            $results = $db->getResultsArray($query2);
            if (!$results) {
                $results = $db->getResultsArray($query1);
            }
        }
        //Do not display borders on Image ads
        if ($results[0]['type'] == 'Image') {
            $displayBorder = ';border:none;';
        }
        if (count($results) < $sizeDetail['ads']) {
            //Getting Buckysroom Default Ads
            $query3 = "SELECT AD.* FROM " . TABLE_ADS . " AS AD WHERE AD.defaultAd=1 AND AD.status='" . TNB_AD_STATUS_ACTIVE . "' AND AD.type = 'Text' ORDER BY rand() LIMIT " . ($sizeDetail['ads'] - count($results));
            $results2 = $db->getResultsArray($query3);
            $results = array_merge($results, $results2);
        }
        $counts = count($results);
        $formToken = buckys_get_form_token();
        $bannerHTML = '<div class="buckysroom-ad-banner" id="buckysroom-ads-preview">';
        $bannerHTML .= '<table cellpadding="0" cellspacing="0" style="width: ' . $sizeDetail['width'] . 'px; height: ' . $sizeDetail['height'] . 'px; border: solid 1px #' . $adDetail['borderColor'] . ';  background-color: #' . $adDetail['bgColor'] . $displayBorder . '">';
        for ($i = 1; $i <= $counts; $i++) {
            if ($sizeDetail['type'] == 'vertical' || $i == 1) {
                $bannerHTML .= '<tr>';
            }
            $bannerHTML .= '<td>';
            if ($results[$i - 1]['type'] == 'Text') {
                $bannerHTML .= '<div class="buckysroom-ad ' . $sizeDetail['class'] . ' " style=" ' . $displayWidth . $newHorizontalPadding . ' ">
                                    <a href="//' . TNB_DOMAIN . '/goto-ad-url.php?key=' . $results[$i - 1]['adKey'] . '&' . $formToken . '=1&url=' . base64_encode($results[$i - 1]['url']) . '" class="bsroom-ad-title" style="color: #' . $adDetail['titleColor'] . '" target="_blank">' . $results[$i - 1]['title'] . '</a>
									<br />
                                    <p class="bsroom-ad-desc" style="color: #' . $adDetail['textColor'] . '">' . $results[$i - 1]['description'] . '</p>
                                    <div style=" ' . $displayWidth . 'overflow:hidden;">
									<a style="color: #' . $adDetail['urlColor'] . '" href="//' . TNB_DOMAIN . '/goto-ad-url.php?key=' . $results[$i - 1]['adKey'] . '&' . $formToken . '=1&url=' . base64_encode($results[$i - 1]['url']) . '" class="bsroom-ad-link" target="_blank">' . $results[$i - 1]['display_url'] . '</a>
									</div>
                                </div>';
            } else {
                $bannerHTML .= '<div class="buckysroom-ad buckysroom-ad-image"  style="padding: 0; margin: 0; line-height: 0; overflow: hidden"><a href="//' . TNB_DOMAIN . '/goto-ad-url.php?key=' . $results[$i - 1]['adKey'] . '&' . $formToken . '=1&url=' . base64_encode($results[$i - 1]['url']) . '" target="_blank"><img src="' . DIR_WS_IMAGE . 'user_ads/' . $results[$i - 1]['fileName'] . '" width="' . $sizeDetail['width'] . '" height="' . $sizeDetail['height'] . '" /></a></div>';
            }
            $bannerHTML .= '</td>';
            if ($sizeDetail['type'] == 'vertical' || $i == $counts) {
                $bannerHTML .= '</tr>';
            }
            if ($results[$i - 1]['defaultAd']) {
                continue;
            }
            $db->query("UPDATE " . TABLE_PUBLISHER_ADS . " SET `impressions` = `impressions` + 1 WHERE id=" . $adDetail['id']);
            $db->query("UPDATE " . TABLE_ADS . " SET `receivedImpressions` = `receivedImpressions` + 1 WHERE id=" . $results[$i - 1]['id']);
            //Make it to expired if all expressions are received
            $db->query("UPDATE " . TABLE_ADS . " SET `status` = " . TNB_AD_STATUS_EXPIRED . " WHERE  id=" . $results[$i - 1]['id'] . " AND `receivedImpressions` >= `impressions` ");
            //Image ads were creating multiple table rows
            if ($results[$i - 1]['type'] == 'Image') {
                break;
            }
        }
        $bannerHTML .= '</table>';
        $bannerHTML .= '</div>';
        return $bannerHTML;
    }
<?php

require dirname(dirname(__FILE__)) . '/includes/bootstrap.php';
//Getting Current User ID
if (!buckys_check_user_acl(USER_ACL_REGISTERED)) {
    buckys_redirect('/index.php', MSG_PERMISSION_DENIED, MSG_TYPE_ERROR);
}
$userID = buckys_is_logged_in();
$classPublisherAd = new BuckysPublisherAds();
buckys_enqueue_stylesheet('publisher.css');
$adID = buckys_escape_query_integer($_GET['id']);
$adDetail = $classPublisherAd->getAdById($adID);
if (!$adDetail || $adDetail['publisherID'] != $userID && buckys_check_user_acl(USER_ACL_MODERATOR)) {
    buckys_redirect('/ads/publisher.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}
$classAds = new BuckysAds();
$sizeDetail = $classAds->getAdSizeById($adDetail['size']);
$TNB_GLOBALS['headerType'] = "ads";
$TNB_GLOBALS['content'] = "ads/publisher_ad_view";
$TNB_GLOBALS['title'] = "View Ad Details - thenewboston Ads";
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
<?php

require dirname(dirname(__FILE__)) . '/includes/bootstrap.php';
//Getting Current User ID
if (!buckys_check_user_acl(USER_ACL_REGISTERED)) {
    buckys_redirect('/index.php', MSG_PERMISSION_DENIED, MSG_TYPE_ERROR);
}
$userID = buckys_is_logged_in();
$classPublisherAd = new BuckysPublisherAds();
if (isset($_POST['action']) && $_POST['action'] == 'create-publisher-ad') {
    if (!buckys_check_form_token()) {
        buckys_redirect('/ads/create_publisher_ad.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
    } else {
        $_POST['adType'] = TNB_AD_TYPE_CUSTOM;
        if ($classPublisherAd->savePublisherAd($userID, $_POST)) {
            buckys_redirect('/ads/publisher.php', $classPublisherAd->last_message);
        } else {
            buckys_redirect('/ads/create_publisher_ad.php', $classPublisherAd->last_message, MSG_TYPE_ERROR);
        }
    }
}
$classAds = new BuckysAds();
$adSizes = $classAds->getAdSizes();
buckys_enqueue_javascript('colorpicker.js');
buckys_enqueue_javascript('create_publisher_ads.js');
buckys_enqueue_stylesheet('colorpicker.css');
buckys_enqueue_stylesheet('publisher.css');
$TNB_GLOBALS['headerType'] = "ads";
$TNB_GLOBALS['content'] = "ads/create_publisher_ad";
$TNB_GLOBALS['title'] = "Create Publisher Ad - thenewboston Ads";
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";