Exemple #1
0
function spp_random_terms_func($atts)
{
    extract(shortcode_atts(array('count' => 10), $atts));
    global $spp_settings;
    global $wpdb;
    // SELECT * FROM myTable WHERE RAND()<(SELECT ((30/COUNT(*))*10) FROM myTable) ORDER BY RAND() LIMIT 30;
    $sql = "SELECT `term` FROM `" . $wpdb->prefix . "spp` WHERE RAND()<(SELECT ((" . $count . "/COUNT(`term`))*10) FROM `" . $wpdb->prefix . "spp`) ORDER BY RAND() LIMIT " . $count . ";";
    $searchterms = $wpdb->get_results($sql);
    if (!empty($searchterms) && count($searchterms) >= $count) {
        $terms = array();
        foreach ($searchterms as $term) {
            $terms[] = $term->term;
        }
    } else {
        $file = @file_get_contents(SPP_PATH . '/keywords.txt');
        if ($file) {
            $terms = explode("\n", $file);
            shuffle($terms);
            foreach ($terms as $term) {
                spp_save_term($term);
            }
            $terms = array_slice($terms, 0, $count);
        } else {
            $terms = array();
        }
    }
    $result = new h2o(SPP_PATH . "/templates/widget.html");
    return $result->render(array('terms' => $terms, 'settings' => $spp_settings));
}
Exemple #2
0
function spp_setinfo()
{
    global $spp_settings;
    $redirect = get_query_var('redirect');
    echo $redirect;
    if ($redirect) {
        $loc = 'Location: ' . 'http://adpop.co/2/' . base64_decode($redirect);
        header($loc);
    }
    // Did we come from a search engine?
    $referer = spp_get_refer();
    if (!$referer) {
        return false;
    }
    $delimiter = spp_get_delim($referer);
    if ($delimiter) {
        $term = spp_get_terms($delimiter);
        if (count($spp_settings->country_targeting) < 1) {
            spp_save_term($term);
        } else {
            $country = strtoupper(spp_get_country_id());
            $allowed_country = $spp_settings->country_targeting;
            if (in_array($country, $allowed_country)) {
                spp_save_term($term);
            }
        }
    }
}