vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   [help] Displaying Variable after links (https://vborg.vbsupport.ru/showthread.php?t=322221)

Dr.CustUmz 03-25-2016 04:03 PM

[help] Displaying Variable after links
 
this should be my last request for help regarding this.

I am trying to show external link clicks next to links in post, like how twitter forums do:


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



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 (which is effecting imgs if using highslide or w/e is built in currently which i also will need to fix)

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 used
Code:

$drclf = $vbulletin->db->query_first("
  SELECT SUM(hits) AS hits
  FROM " . TABLE_PREFIX . "redirect
  WHERE url = 'http://google.com'
");

in global
and placed $drclf[hits] in header and it worked properly (just to test)

I just don't know where to hook it without causing severe queries in every postbit, or maybe even a cron task, where it updates the count every so often, and how can I get it to show after every link without modifying core files. I just need some help getting the final result like the first IMG.

sorry for all the help needed, I'm better when it comes to design lol.

--------------- Added [DATE]1458967207[/DATE] at [TIME]1458967207[/TIME] ---------------

really really need some help.

I been working non stop on this I managed to get the location where i need the number i just cant get the result to display in it.

and i know this is going to cause massive queries when ever i do get it working, so i need help figuring out another way to do it.

in global_start i have:
Code:

$drc_url = $_GET['link'];

$drclf = $vbulletin->db->query_first("
  SELECT SUM(hits) AS hits
  FROM " . TABLE_PREFIX . "redirect
  WHERE url = '$drc_url'
");

that doesnt feel right to me though.

then in postbit_display_complete is:
Code:

$post['message']=preg_replace ('</a>' , '</a>('.$drclf[hits].')' , $post['message']);
this isn't working though which im almost certain is because of the query in global. I think im off a little.

also my preg replace is f'd up and looks like <(this)> in posts <> shouldnt be in it but when i remove them i get an infinite load on showthread.

this is just driving me insane and i didnt think it would be this difficult.

all the data is ready, i just need to return it.

end goal:
Attachment 154574

the table:
Attachment 154575


All times are GMT. The time now is 03:59 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00966 seconds
  • Memory Usage 1,741KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete