Example #1
0
 function convertData($html)
 {
     // Style according to the Netiquette
     $html = preg_replace('#<(?:b|strong)\\b[^>]*>(\\s*)#iu', '$1*', $html);
     $html = preg_replace('#(\\s*)</(?:b|strong)\\b[^>]*>#iu', '*$1', $html);
     $html = preg_replace('#<u\\b[^>]*>(\\s*)#iu', '$1_', $html);
     $html = preg_replace('#(\\s*)</u\\b[^>]*>#iu', '_$1', $html);
     // Remove <sub> and <sup> tags
     $html = preg_replace('#<(/?)su[bp]\\b([^>]*)>#iu', '<$1span$2>', $html);
     // Fill empty alt attributes with whitespace, clear src attributes
     $html = preg_replace('#(<[^>]+\\balt=")"#iu', '$1 "', $html);
     $html = preg_replace('#(<[^>]+\\bsrc=")(?:[^"]*)"#iu', '$1"', $html);
     // Inline URLs
     $html = preg_replace_callback('#<a\\b[^>]*\\shref="([^"]*)"[^>]*>(.*?)</a\\b[^>]*>#isu', array(__CLASS__, 'buildTextAnchor'), $html);
     // Convert html-entities to UTF-8 for w3m
     $html = str_replace(array('&quot;', '&lt;', '&gt;', '&#039;', '"', '<', '>', "'"), array('&amp;quot;', '&amp;lt;', '&amp;gt;', '&amp;#039;', '&quot;', '&lt;', '&gt;', '&#039;'), FILTER::get($html, 'text'));
     $html = html_entity_decode($html, ENT_COMPAT, 'UTF-8');
     $file = tempnam(PATCHWORK_ZCACHE, 'converter');
     Patchwork::writeFile($file, $html);
     $html = escapeshellarg($file);
     $html = `w3m -dump -cols {$this->cols} -T text/html -I UTF-8 -O UTF-8 {$html}`;
     $html = str_replace(self::$charMap[0], self::$charMap[1], $html);
     $html = strtr($html, self::$textAnchor);
     self::$textAnchor = array();
     unlink($file);
     return $html;
 }
Example #2
0
 protected function init(&$param)
 {
     empty($param['disabled']) || ($this->disabled = true);
     if ($this->disabled || !empty($param['readonly'])) {
         $this->readonly = true;
     }
     $this->validArgs[] = $this->maxlength = isset($param['maxlength']) ? (int) $param['maxlength'] : 0;
     $this->valid = isset($param['valid']) ? $param['valid'] : '';
     if (!$this->valid) {
         $this->valid = 'file';
     }
     $i = 0;
     while (isset($param[$i])) {
         $this->validArgs[] =& $param[$i++];
     }
     if (!empty($param['multiple'])) {
         $this->multiple = true;
         $this->value = array();
     }
     if (!$this->readonly) {
         if ($this->multiple) {
             $this->status = '';
             $value = isset($this->form->filesValues[$this->name]) ? $this->form->filesValues[$this->name] : '';
             if (!empty($value['name'])) {
                 if (is_array($value['name'])) {
                     $status = true;
                     foreach ($value['name'] as $i => $v) {
                         $v = array('name' => $v, 'type' => $value['type'][$i], 'tmp_name' => $value['tmp_name'][$i], 'error' => $value['error'][$i], 'size' => $value['size'][$i]);
                         $v = FILTER::getFile($v, $this->valid, $this->validArgs);
                         if (false === $v) {
                             $status = false;
                         } else {
                             if ('' !== $v) {
                                 $this->value[] = $v;
                                 $status = true && $status;
                             }
                         }
                     }
                     $this->value && ($this->status = $status);
                 } else {
                     $this->status = false;
                 }
             }
         } else {
             $this->status = FILTER::getFile($this->form->filesValues[$this->name], $this->valid, $this->validArgs);
             $this->value = $this->status;
         }
     } else {
         $this->status = '';
     }
 }
Example #3
0
 protected function init(&$param)
 {
     if (isset($this->form->rawValues[$this->name])) {
         $value =& $this->form->rawValues[$this->name];
         $value = FILTER::get($value, 'html');
     }
     parent::init($param);
     if (isset($param['toolbarSet'])) {
         $this->toolbarSet = $param['toolbarSet'];
     }
     if (isset($param['config'])) {
         $this->config = $param['config'];
     }
 }
Example #4
0
 function Close(STREAMWriterInterface $h = NULL)
 {
     if (!sizeof($this->list)) {
         if ($this->zip->open($this->tmpfile, ZIPARCHIVE::CREATE) !== true) {
             throw new ADEIException(translate("Can't open/create ZIP archive (%s)", $this->tmpfile));
         }
         $this->zip->addFromString("no_data_available", "");
         $this->zip->close();
     }
     /*
         $this->zip->close();
     */
     parent::Close($h);
 }
Example #5
0
 public static function startFilter($ip_id)
 {
     //we only do the other checks, if the first ones have failed.
     //we will return the variable filter, if the $filter returns TRUE, when the click is inserted and recorded we will insert the new click already inserted,
     //what was lagign this query is before it would insert a click, then scan it and then update the click, the updating later on was lagging, now we will just insert and it will not stop the clicks from being redirected becuase of a slow update.
     //check the user
     if (!FILTER::checkUserIP($ip_id)) {
         if (FILTER::checkLastIps($ip_id)) {
             return 2;
         }
     } else {
         return 1;
     }
     return 0;
 }
Example #6
0
 public final function __construct($args = array())
 {
     $class = get_class($this);
     isset($this->contentType) or $this->contentType = constant($class . '::contentType');
     $a = (array) $this->get;
     $this->get = (object) array();
     $_GET = array();
     foreach ($a as $key => &$a) {
         if (is_string($key)) {
             $default = $a;
             $a = $key;
         } else {
             $default = '';
         }
         false !== strpos($a, "") && ($a = str_replace("", '', $a));
         if (false !== strpos($a, '\\')) {
             $a = strtr($a, array('\\\\' => '\\', '\\:' => ""));
             $a = explode(':', $a);
             $b = count($a);
             do {
                 false !== strpos($a[--$b], "") && ($a[$b] = strtr($a[$b], "", ':'));
             } while ($b);
         } else {
             $a = explode(':', $a);
         }
         $key = array_shift($a);
         $b = isset($args[$key]) ? (string) $args[$key] : $default;
         false !== strpos($b, "") && ($b = str_replace("", '', $b));
         if ($a) {
             $b = FILTER::get($b, array_shift($a), $a);
             if (false === $b) {
                 $b = $default;
             }
         }
         $_GET[$key] = $this->get->{$key} = $b;
     }
     $this->control();
     if (!$this->contentType && '' !== ($a = strtolower(pathinfo(p\Superloader::class2file($class), PATHINFO_EXTENSION)))) {
         $this->contentType = isset(p\StaticResource::$contentType['.' . $a]) ? p\StaticResource::$contentType['.' . $a] : 'application/octet-stream';
     }
     $this->contentType && header('Content-Type: ' . $this->contentType);
 }
Example #7
0
 function startFilter($db, $click_id, $ip_id, $ip_address, $user_id)
 {
     //we only do the other checks, if the first ones have failed.
     //we will return the variable filter, if the $filter returns TRUE, when the click is inserted and recorded we will insert the new click already inserted,
     //what was lagign this query is before it would insert a click, then scan it and then update the click, the updating later on was lagging, now we will just insert and it will not stop the clicks from being redirected becuase of a slow update.
     //check the user
     $filter = FILTER::checkUserIP($db, $click_id, $ip_id, $user_id);
     if ($filter == false) {
         //check the netrange
         $filter = FILTER::checkNetrange($click_id, $ip_address);
         if ($filter == false) {
             $filter = FILTER::checkLastIps($db, $user_id, $ip_id);
         }
     }
     if ($filter == true) {
         return 1;
     } else {
         return 0;
     }
 }
Example #8
0
 function Close(STREAMWriterInterface $h = NULL)
 {
     if (!$this->block_mode) {
         $res = $this->ClosePipes($h);
         if ($res) {
             return $res . parent::Close($h);
         }
     }
     return parent::Close($h);
 }
Example #9
0
 public static function decode_ip($ip)
 {
     global $db;
     $ip = $db->unescape_binary($ip);
     $l = strlen($ip);
     if ($l == 5 || $l == 17) {
         --$l;
         $ip = substr($ip, 0, -1);
     }
     if ($l == 4 || $l == 16) {
         return inet_ntop($ip);
     } else {
         if ($l == 8) {
             $ip = explode('.', chunk_split($ip, 2, '.'));
             return hexdec($ip[0]) . '.' . hexdec($ip[1]) . '.' . hexdec($ip[2]) . '.' . hexdec($ip[3]);
         } else {
             if ($tmp = FILTER::ipv4($ip, true)) {
                 return $tmp;
             }
         }
     }
     return long2ip($ip);
 }
 public function saveData($campaign, $cloaked = 0, $outbound_url = '')
 {
     $offer_id = 0;
     $landing_page_id = 0;
     if ($campaign->type == 2) {
         $campoffer = rotateDirectCampaign($campaign);
         if (!$campoffer) {
             BTApp::log("Direct Link: Invalid Offers For Tracker: " . $campaign->id(), 'direct', BT_SYSLOG_CRITICAL);
         }
         $payout = $campoffer->offer->payout;
         $offer_id = $campoffer->offer->id();
     } else {
         if ($campaign->type == 1) {
             $camplp = rotateLPCampaign($campaign);
             $payout = 0;
             $landing_page = $camplp->landing_page;
             $landing_page_id = $landing_page->id();
             if (!$landing_page) {
                 BTApp::log("Landing Page: Invalid Landing Page ID: " . $landing_page_id . " For Tracker: " . $campaign->id(), 'direct', BT_SYSLOG_CRITICAL);
             }
         }
     }
     $ip_id = INDEXES::get_ip_id($_SERVER['REMOTE_ADDR']);
     $click = new ClickModel();
     $click->offer_id = $offer_id;
     $click->landing_page_id = $landing_page_id;
     $click->traffic_source_id = $campaign->traffic_source_id;
     $click->payout = $payout;
     $click->filtered = FILTER::startFilter($ip_id);
     $click->user_id = $campaign->user_id;
     $click->cloaked = $cloaked;
     $click->campaign_id = $campaign->id();
     $click->useRuleSet("track");
     $click->save();
     $vars = saveTrackingVariables($campaign);
     //if behind cloaker scripts, we use $_POST. Otherwise (normally) use HTTP_REFERER
     $referer = isset($_POST['referer']) ? $_POST['referer'] : getArrayVar($_SERVER, 'HTTP_REFERER');
     $keyword = getArrayVar($_GET, $campaign->option('var_kw')->value);
     if (!$keyword) {
         $keyword = getArrayVar($_GET, 'kw');
         if (!$keyword) {
             $keyword = getArrayVar($_GET, 'keyword');
         }
     }
     $keyword_id = INDEXES::get_keyword_id($keyword);
     $platform = INDEXES::get_platform_and_browser_id();
     $organization_id = 0;
     $geo_block_id = 0;
     $device_id = 0;
     require BT_ROOT . '/private/includes/traffic/devices_detect_inc.php';
     $adv = new ClickAdvancedModel();
     $adv->click_id = $click->id();
     $adv->keyword_id = $keyword_id;
     $adv->ip_id = $ip_id;
     $adv->platform_id = $platform['platform'];
     $adv->browser_id = $platform['browser'];
     $adv->org_id = $organization_id;
     $adv->device_id = $device_id;
     $adv->v1_id = $vars['v1_id'];
     $adv->v2_id = $vars['v2_id'];
     $adv->v3_id = $vars['v3_id'];
     $adv->v4_id = $vars['v4_id'];
     $adv->location_id = $geo_block_id;
     $adv->campaign_id = $campaign->id();
     $adv->useRuleSet('track');
     $adv->save();
     $data = $vars;
     $data['keyword'] = $keyword;
     $data['clickid'] = base_convert($click->click_id, 10, 36);
     if ($offer_id) {
         if ($outbound_url) {
             $redirect_url = $outbound_url;
         } else {
             $redirect_url = $campoffer->offer->url;
             $redirect_url = replaceTrackerPlaceholders($redirect_url, $data);
         }
         $landing_url = '';
     } else {
         $redirect_url = '';
         if ($outbound_url) {
             $landing_url = $outbound_url;
         } else {
             $landing_url = $landing_page->url;
         }
     }
     //set the cookie
     setClickIdCookie(base_convert($click->click_id, 10, 36));
     $site = new ClickSiteModel();
     $site->click_id = $click->id();
     $site->referer_url = $referer;
     $site->referer_domain = getUrlDomain($referer);
     $site->offer_url = $redirect_url;
     $site->landing_url = $landing_url;
     $site->useRuleSet('track');
     $site->save();
     $pass_vars = array();
     $to_append = '';
     if ($landing_page_id) {
         $type = 'lp';
     } else {
         $type = 'offer';
     }
     foreach ($campaign->options as $option) {
         if (strpos($option->name, 'pass_') === 0) {
             $var_name = substr($option->name, 5);
             $val = getArrayVar($_GET, $var_name, '');
             $pass = new ClickPassthroughModel();
             $pass->click_id = $click->click_id;
             $pass->name = $var_name;
             $pass->value = $val;
             $pass->useRuleSet('track');
             $pass->save();
             $pass_vars[$var_name] = $pass;
         }
     }
     $to_append = http_build_query($this->getPassthroughsToAppend($campaign, $pass_vars, $type));
     if ($offer_id) {
         //direct
         return appendQueryString($redirect_url, $to_append);
     } else {
         //lp
         return appendQueryString($landing_url, $to_append);
     }
 }
Example #11
0
 protected function init(&$param)
 {
     empty($param['disabled']) || ($this->disabled = true);
     if ($this->disabled || !empty($param['readonly'])) {
         $this->readonly = true;
     }
     if (isset($param['valid'])) {
         $this->valid = $param['valid'];
     } else {
         if (!isset($this->valid)) {
             $this->valid = 'char';
             if (!isset($param[0]) && '' !== $this->validDefaultRx) {
                 $this->validArgs[] = $this->validDefaultRx;
                 $this->validmsg = T($this->validDefaultMsg);
             }
         }
     }
     if (!empty($param['multiple'])) {
         $this->isdata = false;
         $this->multiple = true;
     }
     isset($param['isdata']) && ($this->isdata = (bool) $param['isdata']);
     $i = 0;
     while (isset($param[$i])) {
         $this->validArgs[] =& $param[$i++];
     }
     isset($param['validmsg']) && ($this->validmsg = $param['validmsg']);
     isset($param['validMsg']) && ($this->validmsg = $param['validMsg']);
     $this->validmsg || ($this->validmsg = FILTER::getMsg($this->valid, $this->validArgs));
     if (!$this->readonly && isset($this->form->rawValues[$this->name])) {
         $value = $this->form->rawValues[$this->name];
         if (is_string($value) && false !== strpos($value, "")) {
             $value = str_replace("", '', $value);
             $this->form->rawValues[$this->name] = $value;
         }
     } else {
         if (isset($param['default'])) {
             $value = $param['default'];
             if ($this->multiple && !is_array($value)) {
                 $value = explode(',', $value);
                 $value = array_map('rawurldecode', $value);
             }
             $this->setValue($value);
             $value =& $this->value;
         } else {
             $value = '';
         }
     }
     if ($this->multiple) {
         $this->status = '';
         if ($value) {
             if (is_array($value)) {
                 $status = true;
                 foreach ($value as $i => &$v) {
                     if ('' === $v) {
                         unset($value[$i]);
                     } else {
                         $a = FILTER::get($v, $this->valid, $this->validArgs);
                         if (false === $a) {
                             $status = false;
                         } else {
                             $v = $a;
                             $status = true && $status;
                         }
                     }
                 }
                 $value && ($this->status = $status);
             } else {
                 $this->status = false;
                 $value = array();
             }
         } else {
             $value = array();
         }
     } else {
         if ('' === (string) $value) {
             $this->status = '';
         } else {
             $this->status = FILTER::get($value, $this->valid, $this->validArgs);
             if ('' !== $this->status && false !== $this->status) {
                 $value = $this->status;
                 $this->status = true;
             }
         }
     }
     $this->setValue($value);
 }
Example #12
0
             case -1:
                 cpg_error(sprintf(_ERROR_BAD_FORMAT, 'IPv4'));
                 break;
             case -2:
                 cpg_error(sprintf(_ERROR_BAD_FORMAT, 'CIDR'));
                 break;
             default:
                 break;
         }
     } else {
         if (!FILTER::ipv4($_POST['ban_ipv4_s'], true)) {
             cpg_error(sprintf(_ERROR_BAD_FORMAT, 'IPv4 start'));
         } else {
             $ip = inet_pton($_POST['ban_ipv4_s']);
             if (!empty($_POST['ban_ipv4_e'])) {
                 if (!FILTER::ipv4($_POST['ban_ipv4_e'], true)) {
                     cpg_error(sprintf(_ERROR_BAD_FORMAT, 'IPv4 end'));
                 }
                 $ip2 = inet_pton($_POST['ban_ipv4_e']);
             }
         }
     }
 }
 if (!empty($_POST['ban_mac'])) {
 }
 if ($ip === false) {
     cpg_error('Nothing specified');
 }
 $ip_len = strlen($ip);
 $details = $db->sql_escape_string($_POST['description']);
 if ($ip_len == 4) {
Example #13
0
 function convertFile($file)
 {
     $file = escapeshellarg($file);
     $file = `antiword -t -w 0 -m UTF-8 {$file}`;
     return FILTER::get($file, 'text');
 }
Example #14
0
function redirect_process($db, $rule, $ppc_account, $cpc, $rotator_id, $GeoData, $ip_address, $user_id, $IspData, $keyword_type)
{
    $mysql['aff_campaign_id'] = $db->real_escape_string($rule['aff_campaign_id']);
    $mysql['click_cpc'] = $db->real_escape_string($rule['click_cpc']);
    $mysql['click_payout'] = $db->real_escape_string($rule['aff_campaign_payout']);
    $mysql['rule_id'] = $db->real_escape_string($rule['rule_id']);
    $mysql['ppc_account'] = $db->real_escape_string($ppc_account);
    $mysql['cpc'] = $db->real_escape_string($cpc);
    $mysql['click_time'] = time();
    /* ok, if $_GET['OVRAW'] that is a yahoo keyword, if on the REFER, there is a $_GET['q], that is a GOOGLE keyword... */
    //so this is going to check the REFERER URL, for a ?q=, which is the ACUTAL KEYWORD searched.
    $referer_url_parsed = @parse_url($_SERVER['HTTP_REFERER']);
    $referer_url_query = $referer_url_parsed['query'];
    @parse_str($referer_url_query, $referer_query);
    switch ($keyword_type) {
        case "bidded":
            #try to get the bidded keyword first
            if ($_GET['OVKEY']) {
                //if this is a Y! keyword
                $keyword = $db->real_escape_string($_GET['OVKEY']);
            } elseif ($_GET['utm_source']) {
                $keyword = $db->real_escape_string($_GET['utm_source']);
            } elseif ($_GET['t202kw']) {
                $keyword = $db->real_escape_string($_GET['t202kw']);
            } elseif ($referer_query['p']) {
                $keyword = $db->real_escape_string($referer_query['p']);
            } elseif ($_GET['target_passthrough']) {
                //if this is a mediatraffic! keyword
                $keyword = $db->real_escape_string($_GET['target_passthrough']);
            } else {
                //if this is a zango, or more keyword
                $keyword = $db->real_escape_string($_GET['keyword']);
            }
            break;
        case "searched":
            #try to get the searched keyword
            if ($referer_query['q']) {
                $keyword = $db->real_escape_string($referer_query['q']);
            } elseif ($referer_query['p']) {
                $keyword = $db->real_escape_string($referer_query['p']);
            } elseif ($_GET['OVRAW']) {
                //if this is a Y! keyword
                $keyword = $db->real_escape_string($_GET['OVRAW']);
            } elseif ($_GET['target_passthrough']) {
                //if this is a mediatraffic! keyword
                $keyword = $db->real_escape_string($_GET['target_passthrough']);
            } elseif ($_GET['keyword']) {
                //if this is a zango, or more keyword
                $keyword = $db->real_escape_string($_GET['keyword']);
            } elseif ($_GET['search_word']) {
                //if this is a eniro, or more keyword
                $keyword = $db->real_escape_string($_GET['search_word']);
            } elseif ($_GET['query']) {
                //if this is a naver, or more keyword
                $keyword = $db->real_escape_string($_GET['query']);
            } elseif ($_GET['encquery']) {
                //if this is a aol, or more keyword
                $keyword = $db->real_escape_string($_GET['encquery']);
            } elseif ($_GET['terms']) {
                //if this is a about.com, or more keyword
                $keyword = $db->real_escape_string($_GET['terms']);
            } elseif ($_GET['rdata']) {
                //if this is a viola, or more keyword
                $keyword = $db->real_escape_string($_GET['rdata']);
            } elseif ($_GET['qs']) {
                //if this is a virgilio, or more keyword
                $keyword = $db->real_escape_string($_GET['qs']);
            } elseif ($_GET['wd']) {
                //if this is a baidu, or more keyword
                $keyword = $db->real_escape_string($_GET['wd']);
            } elseif ($_GET['text']) {
                //if this is a yandex, or more keyword
                $keyword = $db->real_escape_string($_GET['text']);
            } elseif ($_GET['szukaj']) {
                //if this is a wp.pl, or more keyword
                $keyword = $db->real_escape_string($_GET['szukaj']);
            } elseif ($_GET['qt']) {
                //if this is a O*net, or more keyword
                $keyword = $db->real_escape_string($_GET['qt']);
            } elseif ($_GET['k']) {
                //if this is a yam, or more keyword
                $keyword = $db->real_escape_string($_GET['k']);
            } elseif ($_GET['words']) {
                //if this is a Rambler, or more keyword
                $keyword = $db->real_escape_string($_GET['words']);
            } else {
                $keyword = $db->real_escape_string($_GET['t202kw']);
            }
            break;
    }
    $keyword = str_replace('%20', ' ', $keyword);
    $keyword_id = INDEXES::get_keyword_id($db, $keyword);
    $mysql['keyword_id'] = $db->real_escape_string($keyword_id);
    $c1 = $db->real_escape_string($_GET['c1']);
    $c1 = str_replace('%20', ' ', $c1);
    $c1_id = INDEXES::get_c1_id($db, $c1);
    $mysql['c1_id'] = $db->real_escape_string($c1_id);
    $c2 = $db->real_escape_string($_GET['c2']);
    $c2 = str_replace('%20', ' ', $c2);
    $c2_id = INDEXES::get_c2_id($db, $c2);
    $mysql['c2_id'] = $db->real_escape_string($c2_id);
    $c3 = $db->real_escape_string($_GET['c3']);
    $c3 = str_replace('%20', ' ', $c3);
    $c3_id = INDEXES::get_c3_id($db, $c3);
    $mysql['c3_id'] = $db->real_escape_string($c3_id);
    $c4 = $db->real_escape_string($_GET['c4']);
    $c4 = str_replace('%20', ' ', $c4);
    $c4_id = INDEXES::get_c4_id($db, $c4);
    $mysql['c4_id'] = $db->real_escape_string($c4_id);
    $device_id = PLATFORMS::get_device_info($db, $detect, $_GET['ua']);
    $mysql['platform_id'] = $db->real_escape_string($device_id['platform']);
    $mysql['browser_id'] = $db->real_escape_string($device_id['browser']);
    $mysql['device_id'] = $db->real_escape_string($device_id['device']);
    if ($device_id['type'] == '4') {
        $mysql['click_bot'] = '1';
    }
    $mysql['click_in'] = 1;
    $mysql['click_out'] = 1;
    $ip_id = INDEXES::get_ip_id($db, $ip_address);
    $mysql['ip_id'] = $db->real_escape_string($ip_id);
    $country_id = INDEXES::get_country_id($db, $GeoData['country'], $GeoData['country_code']);
    $mysql['country_id'] = $db->real_escape_string($country_id);
    $region_id = INDEXES::get_region_id($db, $GeoData['region'], $mysql['country_id']);
    $mysql['region_id'] = $db->real_escape_string($region_id);
    $city_id = INDEXES::get_city_id($db, $GeoData['city'], $mysql['country_id']);
    $mysql['city_id'] = $db->real_escape_string($city_id);
    if ($IspData != null) {
        $isp_id = INDEXES::get_isp_id($db, $IspData);
        $mysql['isp_id'] = $db->real_escape_string($isp_id);
    }
    if ($device_id['type'] == '4') {
        $mysql['click_filtered'] = '1';
    } else {
        $click_filtered = FILTER::startFilter($db, $click_id, $ip_id, $ip_address, $user_id);
        $mysql['click_filtered'] = $db->real_escape_string($click_filtered);
    }
    if ($_GET[lpr] != '') {
        $click_sql1 = "\tSELECT \t202_clicks.click_id,keyword,keyword_id\n\t\t\t\t\tFROM \t\t202_clicks\n\t\t\t\t\tLEFT JOIN\t202_clicks_advance USING (click_id)\n\t\t\t\t\tLEFT JOIN \t202_ips USING (ip_id) \n\t\t\t\t\tLEFT JOIN \t202_keywords USING (keyword_id) \n\t\t\t\t\tWHERE \t202_ips.ip_address='" . $ip_address . "'\n\t\t\t\t\tAND\t\t202_clicks.user_id='" . $user_id . "'  \n\t\t\t\t\tAND\t\t202_clicks.click_time >= '30'\n\t\t\t\t\tORDER BY \t202_clicks.click_id DESC \n\t\t\t\t\tLIMIT \t\t1";
        $click_result1 = $db->query($click_sql1) or record_mysql_error($click_sql1);
        $click_row1 = $click_result1->fetch_assoc();
        $mysql['click_id'] = $db->real_escape_string($click_row1['click_id']);
        $keyword = $db->real_escape_string($keyword);
        $keyword_id = $db->real_escape_string($click_row1['keyword_id']);
        $mysql['keyword_id'] = $db->real_escape_string($keyword_id);
    } else {
        //ok we have the main data, now insert this row
        $click_sql = "INSERT INTO  202_clicks_counter SET click_id=DEFAULT";
        $click_result = $db->query($click_sql) or record_mysql_error($db, $click_sql);
        //now gather the info for the advance click insert
        $click_id = $db->insert_id;
        $mysql['click_id'] = $db->real_escape_string($click_id);
    }
    $mysql['click_alp'] = 0;
    $mysql['rotator_id'] = $db->real_escape_string($rotator_id);
    $mysql['user_id'] = $db->real_escape_string($user_id);
    //ok we have the main data, now insert this row
    $click_sql = "REPLACE INTO   202_clicks\n\t\t\t  SET           \tclick_id='" . $mysql['click_id'] . "',\n\t\t\t\t\t\t\tuser_id = '" . $mysql['user_id'] . "',   \n\t\t\t\t\t\t\taff_campaign_id = '" . $mysql['aff_campaign_id'] . "',   \n\t\t\t\t\t\t\tppc_account_id = '" . $mysql['ppc_account'] . "',   \n\t\t\t\t\t\t\tclick_cpc = '" . $mysql['cpc'] . "',   \n\t\t\t\t\t\t\tclick_payout = '" . $mysql['click_payout'] . "',   \n\t\t\t\t\t\t\tclick_alp = '" . $mysql['click_alp'] . "',\n\t\t\t\t\t\t\tclick_filtered = '" . $mysql['click_filtered'] . "',\n\t\t\t\t\t\t\tclick_bot = '" . $mysql['click_bot'] . "',\n\t\t\t\t\t\t\tclick_time = '" . $mysql['click_time'] . "',\n\t\t\t\t\t\t\trotator_id = '" . $mysql['rotator_id'] . "',\n\t\t\t\t\t\t\trule_id = '" . $mysql['rule_id'] . "'";
    $click_result = $db->query($click_sql) or record_mysql_error($db, $click_sql);
    //ok we have the main data, now insert this row
    $click_sql = "REPLACE INTO   202_clicks_spy\n\t\t\t\t  SET           \tclick_id='" . $mysql['click_id'] . "',\n\t\t\t\t\t\t\t\tuser_id = '" . $mysql['user_id'] . "',   \n\t\t\t\t\t\t\t\taff_campaign_id = '" . $mysql['aff_campaign_id'] . "',   \n\t\t\t\t\t\t\t\tppc_account_id = '" . $mysql['ppc_account'] . "',   \n\t\t\t\t\t\t\t\tclick_cpc = '" . $mysql['cpc'] . "',   \n\t\t\t\t\t\t\t\tclick_payout = '" . $mysql['click_payout'] . "',   \n\t\t\t\t\t\t\t\tclick_filtered = '" . $mysql['click_filtered'] . "',\n\t\t\t\t\t\t\t\tclick_bot = '" . $mysql['click_bot'] . "',\n\t\t\t\t\t\t\t\tclick_alp = '" . $mysql['click_alp'] . "',\n\t\t\t\t\t\t\t\tclick_time = '" . $mysql['click_time'] . "'";
    $click_result = $db->query($click_sql) or record_mysql_error($db, $click_sql);
    //now we have the click's advance data, now insert this row
    $click_sql = "REPLACE INTO   202_clicks_advance\n\t\t\t  SET           click_id='" . $mysql['click_id'] . "',\n\t\t\t\t\t\t\ttext_ad_id='" . $mysql['text_ad_id'] . "',\n\t\t\t\t\t\t\tkeyword_id='" . $mysql['keyword_id'] . "',\n\t\t\t\t\t\t\tip_id='" . $mysql['ip_id'] . "',\n\t\t\t\t\t\t\tcountry_id='" . $mysql['country_id'] . "',\n\t\t\t\t\t\t\tregion_id='" . $mysql['region_id'] . "',\n\t\t\t\t\t\t\tisp_id='" . $mysql['isp_id'] . "',\n\t\t\t\t\t\t\tcity_id='" . $mysql['city_id'] . "',\n\t\t\t\t\t\t\tplatform_id='" . $mysql['platform_id'] . "',\n\t\t\t\t\t\t\tbrowser_id='" . $mysql['browser_id'] . "',\n\t\t\t\t\t\t\tdevice_id='" . $mysql['device_id'] . "'";
    $click_result = $db->query($click_sql) or record_mysql_error($db, $click_sql);
    //insert the tracking data
    $click_sql = "\n\tREPLACE INTO\n\t\t202_clicks_tracking\n\tSET\n\t\tclick_id='" . $mysql['click_id'] . "',\n\t\tc1_id = '" . $mysql['c1_id'] . "',\n\t\tc2_id = '" . $mysql['c2_id'] . "',\n\t\tc3_id = '" . $mysql['c3_id'] . "',\n\t\tc4_id = '" . $mysql['c4_id'] . "'";
    $click_result = $db->query($click_sql) or record_mysql_error($db, $click_sql);
    //now gather variables for the clicks record db
    //lets determine if cloaking is on
    if ($rule['aff_campaign_cloaking'] == 1) {
        $cloaking_on = true;
        $mysql['click_cloaking'] = 1;
        //if cloaking is on, add in a click_id_public, because we will be forwarding them to a cloaked /cl/xxxx link
        $click_id_public = rand(1, 9) . $click_id . rand(1, 9);
        $mysql['click_id_public'] = $db->real_escape_string($click_id_public);
    } else {
        $mysql['click_cloaking'] = 0;
    }
    //ok we have our click recorded table, now lets insert theses
    $click_sql = "REPLACE INTO   202_clicks_record\n\t\t\t  SET           click_id='" . $mysql['click_id'] . "',\n\t\t\t\t\t\t\tclick_id_public='" . $mysql['click_id_public'] . "',\n\t\t\t\t\t\t\tclick_cloaking='" . $mysql['click_cloaking'] . "',\n\t\t\t\t\t\t\tclick_in='" . $mysql['click_in'] . "',\n\t\t\t\t\t\t\tclick_out='" . $mysql['click_out'] . "'";
    $click_result = $db->query($click_sql) or record_mysql_error($db, $click_sql);
    //now lets get variables for clicks site
    //so this is going to check the REFERER URL, for a ?url=, which is the ACUTAL URL, instead of the google content, pagead2.google....
    if ($referer_query['url']) {
        $click_referer_site_url_id = INDEXES::get_site_url_id($db, $referer_query['url']);
    } else {
        $click_referer_site_url_id = INDEXES::get_site_url_id($db, $_SERVER['HTTP_REFERER']);
    }
    $mysql['click_referer_site_url_id'] = $db->real_escape_string($click_referer_site_url_id);
    $outbound_site_url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    $click_outbound_site_url_id = INDEXES::get_site_url_id($db, $outbound_site_url);
    $mysql['click_outbound_site_url_id'] = $db->real_escape_string($click_outbound_site_url_id);
    if ($cloaking_on == true) {
        $cloaking_site_url = 'http://' . $_SERVER['SERVER_NAME'] . '/tracking202/redirect/cl.php?pci=' . $click_id_public;
    }
    if ($rule['aff_campaign_id'] != null) {
        //rotate the urls
        $redirect_site_url = rotateTrackerUrl($db, $rule);
    } else {
        if ($rule['default_url'] != null) {
            $redirect_site_url = $rule['default_url'];
        } elseif ($rule['redirect_url'] != null) {
            $redirect_site_url = $rule['redirect_url'];
        }
    }
    $redirect_site_url = replaceTrackerPlaceholders($db, $redirect_site_url, $click_id);
    $click_redirect_site_url_id = INDEXES::get_site_url_id($db, $redirect_site_url);
    $mysql['click_redirect_site_url_id'] = $db->real_escape_string($click_redirect_site_url_id);
    //insert this
    $click_sql = "REPLACE INTO   202_clicks_site\n\t\t\t  SET           click_id='" . $mysql['click_id'] . "',\n\t\t\t\t\t\t\tclick_referer_site_url_id='" . $mysql['click_referer_site_url_id'] . "',\n\t\t\t\t\t\t\tclick_outbound_site_url_id='" . $mysql['click_outbound_site_url_id'] . "',\n\t\t\t\t\t\t\tclick_redirect_site_url_id='" . $mysql['click_redirect_site_url_id'] . "'";
    $click_result = $db->query($click_sql) or record_mysql_error($db, $click_sql);
    //update the click summary table
    $now = time();
    $today_day = date('j', time());
    $today_month = date('n', time());
    $today_year = date('Y', time());
    //the click_time is recorded in the middle of the day
    $click_time = mktime(12, 0, 0, $today_month, $today_day, $today_year);
    $mysql['click_time'] = $db->real_escape_string($click_time);
    //check to make sure this click_summary doesn't already exist
    $check_sql = "SELECT  *\n\t\t\t\t  FROM    202_summary_overview\n\t\t\t\t  WHERE   user_id='" . $mysql['user_id'] . "'\n\t\t\t\t  AND     aff_campaign_id='" . $mysql['aff_campaign_id'] . "'\n\t\t\t\t  AND     ppc_account_id='" . $mysql['ppc_account'] . "'\n\t\t\t\t  AND     click_time='" . $mysql['click_time'] . "'";
    $check_result = $db->query($check_sql) or record_mysql_error($db, $check_sql);
    $check_count = $check_result->num_rows;
    //if this click summary hasn't been recorded do this now
    if ($check_count == 0) {
        $insert_sql = "INSERT INTO 202_summary_overview\n\t\t\t\t\t   SET         user_id='" . $mysql['user_id'] . "',\n\t\t\t\t\t\t\t\t   aff_campaign_id='" . $mysql['aff_campaign_id'] . "',\n\t\t\t\t\t\t\t\t   ppc_account_id='" . $mysql['ppc_account'] . "',\n\t\t\t\t\t\t\t\t   click_time='" . $mysql['click_time'] . "'";
        $insert_result = $db->query($insert_sql);
    }
    if ($rule['aff_campaign_id'] != null) {
        //set the cookie
        setClickIdCookie($mysql['click_id'], $rule['aff_campaign_id']);
    }
    //now we've recorded, now lets redirect them
    if ($cloaking_on == true) {
        //if cloaked, redirect them to the cloaked site.
        return $cloaking_site_url;
    } else {
        return $redirect_site_url;
    }
}
Example #15
0
 public function __construct()
 {
     parent::__construct();
     $this->xml = new DOMDocument();
     foreach (self::$_fractions as $name => $value) {
         $newname = "@(?<=[^\\d]|^)" . $name . "(?=[^\\d]|\$)@";
         $this->fractions[$newname] = $value;
     }
 }
Example #16
0
$GeoData = getGeoData($ip_address);
$country_id = INDEXES::get_country_id($db, $GeoData['country'], $GeoData['country_code']);
$mysql['country_id'] = $db->real_escape_string($country_id);
$region_id = INDEXES::get_region_id($db, $GeoData['region'], $mysql['country_id']);
$mysql['region_id'] = $db->real_escape_string($region_id);
$city_id = INDEXES::get_city_id($db, $GeoData['city'], $mysql['country_id']);
$mysql['city_id'] = $db->real_escape_string($city_id);
if ($user_row['maxmind_isp'] == '1') {
    $IspData = getIspData($ip_address);
    $isp_id = INDEXES::get_isp_id($db, $IspData);
    $mysql['isp_id'] = $db->real_escape_string($isp_id);
}
if ($device_id['type'] == '4') {
    $mysql['click_filtered'] = '1';
} else {
    $click_filtered = FILTER::startFilter($db, $click_id, $ip_id, $ip_address, $user_id);
    $mysql['click_filtered'] = $db->real_escape_string($click_filtered);
}
//ok we have the main data, now insert this row
$click_sql = "INSERT INTO  202_clicks_counter SET click_id=DEFAULT";
$click_result = $db->query($click_sql) or record_mysql_error($db, $click_sql);
//now gather the info for the advance click insert
$click_id = $db->insert_id;
$mysql['click_id'] = $db->real_escape_string($click_id);
//because this is a simple landing page, set click_alp (which stands for click advanced landing page, equal to 0)
$mysql['click_alp'] = 0;
//ok we have the main data, now insert this row
$click_sql = "INSERT INTO   202_clicks\n\t\t\t  SET           \tclick_id='" . $mysql['click_id'] . "',\n\t\t\t\t\t\t\tuser_id = '" . $mysql['user_id'] . "',   \n\t\t\t\t\t\t\taff_campaign_id = '" . $mysql['aff_campaign_id'] . "',   \n\t\t\t\t\t\t\tppc_account_id = '" . $mysql['ppc_account_id'] . "',   \n\t\t\t\t\t\t\tclick_cpc = '" . $mysql['click_cpc'] . "',   \n\t\t\t\t\t\t\tclick_payout = '" . $mysql['click_payout'] . "',   \n\t\t\t\t\t\t\tclick_alp = '" . $mysql['click_alp'] . "',\n\t\t\t\t\t\t\tclick_filtered = '" . $mysql['click_filtered'] . "',\n\t\t\t\t\t\t\tclick_bot = '" . $mysql['click_bot'] . "',\n\t\t\t\t\t\t\tclick_time = '" . $mysql['click_time'] . "'";
$click_result = $db->query($click_sql) or record_mysql_error($db, $click_sql);
//ok we have the main data, now insert this row
$click_sql = "INSERT INTO   202_clicks_spy\n\t\t\t  SET           \tclick_id='" . $mysql['click_id'] . "',\n\t\t\t\t\t\t\tuser_id = '" . $mysql['user_id'] . "',   \n\t\t\t\t\t\t\taff_campaign_id = '" . $mysql['aff_campaign_id'] . "',   \n\t\t\t\t\t\t\tppc_account_id = '" . $mysql['ppc_account_id'] . "',   \n\t\t\t\t\t\t\tclick_cpc = '" . $mysql['click_cpc'] . "',   \n\t\t\t\t\t\t\tclick_payout = '" . $mysql['click_payout'] . "',   \n\t\t\t\t\t\t\tclick_filtered = '" . $mysql['click_filtered'] . "',\n\t\t\t\t\t\t\tclick_bot = '" . $mysql['click_bot'] . "',\n\t\t\t\t\t\t\tclick_alp = '" . $mysql['click_alp'] . "',\n\t\t\t\t\t\t\tclick_time = '" . $mysql['click_time'] . "'";
Example #17
0
 function convertFile($file)
 {
     $file = escapeshellarg($file);
     $file = `pdftotext -enc UTF-8 {$file} -`;
     return FILTER::get($file, 'text');
 }