Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-25-2023, 11:41 AM
Scandal's Avatar
Scandal Scandal is offline
 
Join Date: Dec 2005
Location: Athens / Greece
Posts: 409
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default VBSEO - I want to get the full attachment URL (vbseo friendly)

Hello all!

We have vbseo on a vB3 board.

The thing I want to achieve is very simple, but I don't have do it.

I want on a php script to convert an attachment url into vbseo friendly url.

The url is something like this:
$vbulletin->options['bburl'] . "/attachment.php?attachmentid=$attach[attachmentid]&d=$attach[dateline]

(full attachment url / not thumb=1)

I tried this but we receive server error on cloudflare:
PHP Code:
        $temp "<a href=\"" .$vbulletin->options['bburl'] . "/attachment.php?attachmentid=$attach[attachmentid]&amp;d=$attach[dateline]\"></a>";
        
        
$temp make_crawlable($temp);
        
        
$temp str_replace("<a href=\""""$temp);
        
$temp str_replace("\"></a>"""$temp);
        
$attach['full_res_src'] = $temp
I tried also to use this instead:
PHP Code:
$temp vbseo_output_handler($tempfalse); 
I works but it converts only the first url (the $temp is on a loop with more than one $attach).

Finally to notice that this is returning "" (empty):
PHP Code:
$attach['full_res_src'] = vbseo_attachment_url($attach['attachmentid']); 
Any idea?
Reply With Quote
  #2  
Old 10-04-2023, 12:19 PM
Hostboard's Avatar
Hostboard Hostboard is offline
 
Join Date: May 2002
Location: CT
Posts: 843
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

VBSEO is bug ridden and has many security holes. Unless you have custom patched it, it is highly recommended to remove it. There are a zillion posts on this...
Reply With Quote
  #3  
Old 11-08-2023, 03:23 AM
rushabh rushabh is offline
 
Join Date: Dec 2004
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think your best bet would be to try and make it work with vbseo_output_handler, since you've got that partially working already.
Reply With Quote
Благодарность от:
TheLastSuperman
  #4  
Old 11-08-2023, 09:30 PM
TheLastSuperman's Avatar
TheLastSuperman TheLastSuperman is offline
Senior Member
 
Join Date: Sep 2008
Location: North Carolina
Posts: 5,844
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I agree with Hostboard - I don't recommend using vBSEO at all, so proceed and use at your own risk;

To convert an attachment URL into a vBSEO-friendly URL in vBulletin, you are on the right track by trying to utilize vBSEO's built-in functions to rewrite the URLs. However, it appears that you are encountering issues with Cloudflare errors and empty returns. Let's go through some steps that may help resolve these issues:

- Debug the Cloudflare Error:
Cloudflare errors typically indicate some problem with the server configuration or the way the request is being handled. Check your Cloudflare settings to ensure that you are not hitting a security rule that's causing the server error.
Look at the server logs to see if there's more information about the error. It could be that the make_crawlable function or some other part of your script is triggering a rule on Cloudflare's side.

- Correct Use of vbseo_output_handler:
It's important to ensure that the function vbseo_output_handler is designed to handle individual URLs, and not an entire array of URLs at once. If it's designed for individual use, you'll need to call it inside the loop for each attachment URL.
If the function works for the first URL but not subsequent ones, it might be a scoping issue or a problem with the way the loop is structured. Ensure that $temp is being properly reset at each iteration of the loop.

- Investigate vbseo_attachment_url Function:
If vbseo_attachment_url($attach['attachmentid']) is returning empty, it could be due to several reasons. The function might not be able to retrieve the necessary data from the database, or it might require additional parameters.
Check the definition of the vbseo_attachment_url function to ensure that you are using it correctly. There might be required parameters that you are missing or additional setup needed.

- Check vBSEO Documentation:
Refer to the vBSEO documentation for the correct usage of functions like make_crawlable and vbseo_output_handler. There might be specific instructions or prerequisites that you're overlooking.
*Finding official vBSEO documentation can be challenging since the official site is closed. However, some resources may still exist on the Internet Archive. You can search for vBSEO materials using the following link: Internet Archive Search for vBSEO using this link: https://archive.org/search.php?query...%3A%22VBSEO%22

- Ensure Proper Variable Interpolation:
Check that your PHP code is interpolating variables correctly in the string. Sometimes concatenation issues can cause the URL to be malformed, leading to errors.

- Review Server Configuration:
Since you're encountering server errors, it's also a good idea to review your PHP and server configurations. Ensure that the PHP version you are using is compatible with your vBulletin and vBSEO versions.

- Test with Error Reporting:
Enable error reporting in PHP temporarily to get more detailed errors. This can provide clues as to what is going wrong. Remember to turn this off in a production environment.

Here's a very basic example of how your loop should probably look (assuming vbseo_output_handler is the correct function to use):
Code:
foreach ($attachments as $attach) {
    $temp = "<a href=\"" . $vbulletin->options['bburl'] . "/attachment.php?attachmentid={$attach['attachmentid']}&amp;d={$attach['dateline']}\"></a>";
    $temp = vbseo_output_handler($temp, false);
    
    // Now $temp should contain the individual vBSEO-friendly URL
    $attach['full_res_src'] = $temp;
    
    // ... Do something with $attach['full_res_src']
}
Reply With Quote
Reply


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 05:45 PM.


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.04289 seconds
  • Memory Usage 2,208KB
  • Queries Executed 11 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (1)post_thanks_box_bit
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (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_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete