Example #1
0
function popular_ads($interval)
{
    $num_ads = popular_ads_num_ads();
    // SETS HOW MANY POPULAR ADS TO DISPLAY
    $conn = getConnection();
    $item_array = $conn->osc_dbFetchResults("SELECT i.*, l.*, d.*, SUM(s.i_num_views) AS total_views FROM %st_item_stats s\n\tJOIN %st_item i ON s.fk_i_item_id = i.pk_i_id\n\tJOIN %st_item_location l ON s.fk_i_item_id = l.fk_i_item_id\n\tJOIN %st_item_description d ON s.fk_i_item_id = d.fk_i_item_id\n\tWHERE i.dt_pub_date > CURDATE()-INTERVAL %d DAY\n\tAND i.b_enabled = 1 AND i.b_active = 1 AND i.b_spam = 0 AND (i.b_premium = 1 || i.dt_expiration >= CURDATE())\n\tGROUP BY s.fk_i_item_id\n\tORDER BY total_views DESC\n\tLIMIT 0, %d", DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX, $interval, $num_ads);
    if (count($item_array) > 0) {
        View::newInstance()->_exportVariableToView('customItems', $item_array);
    } else {
        echo __('No listings', 'flatter');
    }
}
Example #2
0
function popular_ads_start()
{
    $num_ads = popular_ads_num_ads();
    // SETS HOW MANY POPULAR ADS TO DISPLAY
    $conn = getConnection();
    $results = $conn->osc_dbFetchResults("SELECT fk_i_item_id, i_num_views FROM %st_item_stats ORDER BY fk_i_item_id ASC", DB_TABLE_PREFIX);
    if (count($results) > 0) {
        foreach ($results as $result) {
            $view_count[$result['fk_i_item_id']] += $result['i_num_views'];
            // Add-up all item views stored in database
        }
        arsort($view_count);
        // sorts array by highest number of item views first
        foreach ($view_count as $item_id => $views) {
            $result = $conn->osc_dbFetchResult("SELECT fk_i_user_id, fk_i_category_id, dt_pub_date, dt_mod_date, f_price, b_active, i_price, fk_c_currency_code, b_premium, s_secret FROM %st_item WHERE pk_i_id = %d", DB_TABLE_PREFIX, $item_id);
            //Get active status of item
            if ($result['b_active'] == 1) {
                //if active...
                //echo 'Item ID: '.$item_id.' Views: '.$views.'<br>'; // display only if item is active
                $index++;
                // get description
                $desc = $conn->osc_dbFetchResult("SELECT fk_c_locale_code, s_title, s_description FROM %st_item_description WHERE fk_i_item_id = %d", DB_TABLE_PREFIX, $item_id);
                //Get active status of item
                $location = $conn->osc_dbFetchResult("SELECT fk_c_country_code, s_country, fk_i_region_id, s_region, fk_i_city_id, s_city FROM %st_item_location WHERE fk_i_item_id = %d", DB_TABLE_PREFIX, $item_id);
                //Get active status of item
                // store the data in an array...
                $item_array[] = array('fk_i_user_id' => $result['fk_i_user_id'], 'fk_i_category_id' => $result['fk_i_category_id'], 'dt_pub_date' => $result['dt_pub_date'], 'dt_mod_date' => $result['dt_mode_date'], 'f_price' => $result['f_price'], 'fk_i_item_id' => $item_id, 'pk_i_id' => $item_id, 'b_active' => $result['b_active'], 'i_price' => $result['i_price'], 'fk_c_currency_code' => $result['fk_c_currency_code'], 'b_premium' => $result['b_premium'], 'fk_c_locale_code' => $desc['fk_c_locale_code'], 's_title' => $desc['s_title'], 's_description' => $desc['s_description'], 'fk_c_country_code' => $location['fk_c_country_code'], 's_country' => $location['s_country'], 'fk_i_region_id' => $location['fk_i_region_id'], 's_region' => $location['s_region'], 'fk_i_city_id' => $location['fk_i_city_id'], 's_city' => $location['s_city'], 's_secret' => $result['s_secret'], 'locale' => array('en_US' => array('fk_i_item_id' => $item_id, 'fk_c_locale_code' => $desc['fk_c_locale_code'], 's_title' => $desc['s_title'], 's_description' => $desc['s_description'], 's_what' => $desc['s_what'])));
            }
            if ($index >= $num_ads) {
                break;
            }
            // limit number of ads to display
        }
        global $stored_items;
        $stored_items = View::newInstance()->_get('item');
        //save existing item array
        View::newInstance()->_exportVariableToView('items', $item_array);
    } else {
        echo 'No Results.';
    }
}
Example #3
0
<?php

$num_ads = '';
if (Params::getParam('num_ads') != '') {
    $num_ads = Params::getParam('num_ads');
} else {
    $num_ads = popular_ads_num_ads();
}
if (Params::getParam('option') == 'update') {
    osc_set_preference('popularads_num_ads', $num_ads, 'plugin-popular_ads', 'INTEGER');
    osc_add_flash_ok_message(__('Number of ads to display successfully updated'), 'admin');
    echo '<script>location.href="' . osc_admin_render_plugin_url('popular_ads/admin_config.php') . '"</script>';
}
?>



<div style="border: 5px solid #ccc; padding:10px; background: #eee;
	    -moz-border-radius:20px;
	    -webkit-border-radius:20px;
	    border-radius: 20px;">

        <fieldset style="border-color:#ccc;">
	    <legend><h2>Popular Ads - Configure</h2></legend>
There is currently only one option that needs to be set for this plugin, and that is the number of popular ads you wish to display.
<br><br>
How are popular ads determined? - They are based on the total number of active item/ad views. That means an item <i>must</i> be active in order to be included.
<br><br>

    <form name="adexpiration" action="<?php 
echo osc_admin_base_url(true);