Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
Prev Previous Post   Next Post Next
  #1  
Old 03-25-2016, 04:03 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default [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
Reply With Quote
 

Thread Tools
Display Modes

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

Forum Jump


All times are GMT. The time now is 11:54 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04203 seconds
  • Memory Usage 2,303KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (5)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete