форум vBSupport.ru > vBulletin > vBulletin 3.8.x > Вопросы по vBulletin 3.8
  • »
VBsupport перешел с домена .ORG на родной .RU Ура! Пожалуйста, обновите свои закладки - VBsupport.ru
 
 
 
 
DrCustUmz
Знаток
 
DrCustUmz's Avatar
Unhappy product I'm developing
0

I am trying to show external link clicks next to links in post, like how twitter forums do:
Click image for larger version

Name:	2016-03-25_11-54-41.png
Views:	51
Size:	255.0 KB
ID:	28713

I have everything ready, I just need help getting the count to show next to links in post through plugins.
Click image for larger version

Name:	2016-03-25_11-56-53.png
Views:	65
Size:	191.6 KB
ID:	28714


plugin:
postbit_display_complete
Code:
$this->post['message'] = str_replace('href="', 'href="./out.php?link=', $this->post['message']);
$this->post['signature'] = str_replace('href="', 'href="./out.php?link=', $this->post['signature']);
this captures any link posted and sends it through out.php

out.php which captures the link to the database:
PHP Code:
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''drc-lf');
require_once(
'./global.php');

if (isset(
$_GET['link'])) {
    
// format passed url
    
$drc_url $_GET['link'];
    unset(
$_GET['link']);
    if(
count($_GET))
        
$drc_url $drc_url '&' http_build_query($_GET);

    
// deals w/ the display if $drc_url is a valid URL
    
if (filter_var($drc_urlFILTER_VALIDATE_URL)) {
        
$site parse_url($_SERVER['HTTP_HOST']);
        
$site $site['path'];
        
$url parse_url($drc_url);
        
        
// the passed url is not an external link
        
if ($site == $url['host']) {
            
Header"Location: "$drc_url);
        }
        
// the passed url is an external link
        
else {
          
$query $db->query_first("SELECT * FROM "TABLE_PREFIX ."redirect WHERE url = '" $drc_url "'"); 
          if (!
$query){ 
              
$db->query_write("INSERT INTO "TABLE_PREFIX ."redirect (url, hits) VALUES ('" $drc_url "', 1)");
          } else { 
              
$db->query_write("UPDATE "TABLE_PREFIX ."redirect SET hits = hits + 1 WHERE url = '" $drc_url "'"); 
          }  
           
            eval(
'print_output("' fetch_template('drc_lf') . '");');
        }
    
// open invalid link
    
} else {
        
Header"Location: "$drc_url);
    }

So I have the data I need, I just don't know where to go from here.
Something like this should return the results:
Code:
$vbulletin->db->query_first("
  SELECT SUM(hits) AS hits
  FROM " . TABLE_PREFIX . "redirect
  WHERE url = '$drc_url'
");
I just don't know what to do with it, what plugin to create it in, or maybe even a cron task. I just need some help getting the final result like the first IMG
Bot
Yandex Bot Yandex Bot is online now
 
Join Date: 05.05.2005
Реклама на форуме А что у нас тут интересного? =)
 
 
kerk
k0t
 
kerk's Avatar
Default
0

PHP Code:
filter_var($drc_urlFILTER_VALIDATE_URL
this function (filter_var) won't work with national domains like россия.рф
PHP does not support yet http://php.net/manual/ru/function.filter-var.php#111828
debug:
PHP Code:
$url1 'http://россия.рф/';
$url2 'http://russia.ru/';
print 
'<pre>';
var_dump(filter_var($url1FILTER_VALIDATE_URL));
print 
'<br />';
var_dump(filter_var($url2FILTER_VALIDATE_URL));
print 
'</pre>'
result


more reasons do not use this function in your projects
http://php.net/manual/ru/function.filter-var.php#118257
http://php.net/manual/ru/function.filter-var.php#108769
http://php.net/manual/ru/function.filter-var.php#118676
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT +4. The time now is 01:13 AM.


Powered by vBulletin® Version PreModed
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Loading...