public function ita_linkredir()
 {
     print $this->pagename;
     if ($this->pagename == '' || $this->pagename == itabase::setting('ita-maskurl')) {
         header(404);
         add_action('template_redirect', 'redirect_canonical');
     } else {
         global $wpdb;
         $tableName = $wpdb->prefix . 'italm';
         $linkName = str_replace(array(itabase::setting('ita-maskurl') . '/'), array(''), $this->pagename);
         $query = sprintf("SELECT * FROM %s WHERE linkName = '%s'", $tableName, urldecode($linkName));
         $row = $wpdb->get_row($query);
         if (sizeof($row) < 1) {
             header(404);
             add_action('template_redirect', 'redirect_canonical');
         } else {
             $link = $row->linkUrl;
             $partnerId = itabase::setting('ita-partner');
             $affilateNetwork = itabase::setting('ita-affiliateNetwork');
             if (trim($partnerId) != "" && trim($affilateNetwork != "")) {
                 $link = $link . "&" . $affilateNetwork . "=" . $partnerId;
             }
             add_action('parse_query', array(&$this, 'ita_parse_query'));
             add_action('parse_request', array(&$this, 'ita_parse_query'));
             header('location: ' . $link);
         }
     }
 }
Exemple #2
0
 /**
  * Upgrades the database from previous versions to the current db version.
  * Shouldn't enter this function unless offered an upgrade from above functions.
  *
  * @global $wpdb $wpdb
  */
 function italm_upgrade()
 {
     global $wpdb;
     $tableName = $wpdb->prefix . 'italm';
     $version = floatval(itabase::setting('ita-version'));
     // The very first upgrade, this could really break
     if ($version > floatval('0') && $version < floatval('0.1')) {
         include WP_PLUGIN_DIR . "/itunes-affiliate-link-maker/dbupgrades/0.1.php";
     } elseif ($version >= floatval('0.1') && $version < floatval('0.5.3')) {
         include WP_PLUGIN_DIR . "/itunes-affiliate-link-maker/dbupgrades/0.5.3.php";
     } elseif ($version >= floatval('0.5.3') && $version < floatval('0.6')) {
         include WP_PLUGIN_DIR . "/itunes-affiliate-link-maker/dbupgrades/0.6.php";
     } else {
         include ita_getDisplayTemplate('dbupgrades/upgrade-noneed.php');
     }
 }
Exemple #3
0
function ita_link($atts, $content = null)
{
    global $wpdb;
    $tableName = $wpdb->prefix . 'italm';
    $ita_linkImage = itabase::setting('ita-linkimage');
    $ita_partnerid = itabase::setting('ita-partner');
    $ita_affiliateNetwork = itabase::setting('ita-affiliateNetwork');
    $ita_mask = itabase::setting('ita-maskenable');
    if (trim($ita_partnerid) != "" && trim($ita_affiliateNetwork) != "") {
        $ita_partnerid = "&" . $ita_affiliateNetwork . "=" . $ita_partnerid;
    }
    $return = "";
    extract(shortcode_atts(array('link' => '', 'title' => '', 'text' => ''), $atts));
    $link = preg_replace('/&#038;(?![a-zA-Z1-4]{1,8};)/', '&$1', $link);
    $link = str_replace('&amp;', '&', $link);
    if ($title != "") {
        $title = 'title="' . attribute_escape($title) . '"';
        $alt = 'alt="' . attribute_escape($title) . '"';
    }
    if ($ita_mask != '1') {
        if (trim($ita_partnerid) != "") {
            $link = $link . trim($ita_partnerid);
        }
    } else {
        $ita_scQuery = 'SELECT * FROM ' . $tableName . ' WHERE linkUrl = \'' . $link . '\';';
        $linkResult = $wpdb->get_row($ita_scQuery, ARRAY_A);
        $maskedUrl = get_option('siteurl') . '/' . itabase::setting('ita-maskurl') . '/%s';
        if (sizeof($linkResult) > 0) {
            $link = sprintf($maskedUrl, urlencode(str_replace(' ', '_', $linkResult['linkName'])));
        } else {
            if (trim($ita_partnerid) != "") {
                $link = $link . trim($ita_partnerid);
            }
        }
    }
    if ($text == "") {
        $return = '<a href="' . $link . '" ' . $title . '><img src="' . $ita_linkImage . '" width="61" height="16" ' . $title . ' /></a>';
    } else {
        $return = '<a href="' . $link . '" ' . $title . '>' . $text . '</a>';
    }
    return $return;
}
 private function buildQueryVars($term, $media, $country, $entity, $attribute = "")
 {
     $limit = "";
     ## TODO: Remove when Search API bug fixed.
     if ($entity == "macSoftware") {
         $media = "";
         $attribute = "allTrackTerm";
     }
     if (itabase::setting('ita-searchlimit') != itabase::$defaultSettings['ita-searchlimit']) {
         $limit = "&limit=" . itabase::setting('ita-searchlimit');
     }
     if (trim($entity != '')) {
         $entity = "&entity=" . $entity;
     }
     if (trim($attribute != '')) {
         $attribute = "&attribute=" . $attribute;
     }
     if (trim($media != '')) {
         $media = "&media=" . $media;
     }
     return "&country=" . $country . "&term=" . urlencode($term) . $media . $entity . $attribute . $limit;
 }
<?php

/**
 * This script when ran with WordPress (the plugin will take care of that) will
 * upgrade your datbase from version 0.4 or so of iTALM to an 0.5+ style DB
 */
$partnerStuff = itabase::setting('ita-partner');
$temp = split('&', $partnerStuff);
array_shift($temp);
$options = array();
foreach ($temp as $option) {
    $res = split('=', $option);
    $name = $res[0];
    $options[$name] = $name == "partnerUrl" ? urldecode($res[1]) : $res[1];
}
// If proceed has been submitted
if (isset($_GET['proceed'])) {
    // Check for the proceed token, allow through if it's correct
    $token = get_option('italm-upgrade-token', '');
    if (trim($token) != "" && $_GET['proceed'] == $token) {
        $version = "0.5.3";
        update_option('ita-version', $version);
        $wpdb->query($wpdb->prepare("DELETE FROM wp_options WHERE option_name = %s;", 'italm-upgrade-token'));
        include ita_getDisplayTemplate('dbupgrade/upgrade-SUCCESS.php');
    } else {
        $err = '<div class="wrap"><h2>Error Upgrading iTALM</h2><div class="error" ><p><strong>Error Upgrading</strong> - Please return to <a href="' . admin_url("options-general.php?page=itunes-affiliate-link-maker/ita.class.admin.php&italm=upgrade") . '">upgrade page</a></p></div></div>';
        print $err;
    }
} else {
    $tokenval = md5(time() . get_option('siteurl'));
    update_option('italm-upgrade-token', $tokenval);