vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   [HELP] Editing core file via a product (https://vborg.vbsupport.ru/showthread.php?t=322059)

Dr.CustUmz 03-08-2016 07:47 PM

[HELP] Editing core file via a product
 
so i have made a mod, but the problem is its in the showthread.php file.

im replacing
Code:

if ($vbulletin->options['threadviewslive'])
{
        // doing it as they happen; for optimization purposes, this cannot use a DM!
        $db->shutdown_query("
                UPDATE " . TABLE_PREFIX . "thread
                SET views = views + 1
                WHERE threadid = " . intval($threadinfo['threadid'])
        );
}

is there anyway i can do this through creating a product.

MarkFL 03-08-2016 10:22 PM

What you can do, is in the install code for the product, use something like:

PHP Code:

$file file_get_contents('./showthread.php'FILE_USE_INCLUDE_PATH);

file_put_contents('./showthread_original.php'$fileFILE_USE_INCLUDE_PATH);

//Use the str_replace() or preg_replace() function(s) on the string $file to make your changes...then put the altered contents on the server.

file_put_contents('./showthread.php'$fileFILE_USE_INCLUDE_PATH); 

And then in your product's uninstall code, you should restore the original file by getting the contents of the original you previously saved under the new name, then write that to the original name, and delete the file that stored the original contents:

PHP Code:

$file file_get_contents('./showthread_original.php'FILE_USE_INCLUDE_PATH);

file_put_contents('./showthread.php'$fileFILE_USE_INCLUDE_PATH);

unlink('./showthread_original.php'); 


Paul M 03-09-2016 06:17 PM

Extremely bad idea, and will fail on any server thats correctly set up (since apache will not have write access to vb files).

Dr.CustUmz 03-09-2016 06:59 PM

Quote:

Originally Posted by Paul M (Post 2566889)
Extremely bad idea, and will fail on any server thats correctly set up (since apache will not have write access to vb files).

its not that i want to do it this way, i want to find another way of doing it. through hooks or something.

is there a way to make that function do something else without having to edit the core file

Dave 03-10-2016 12:12 PM

There's no way unfortunately, not without modifying the file or creating your own showthread.php file.

squidsk 03-10-2016 02:13 PM

I've seen other mods do it, so why not just include instructions to edit the file with your product. That way you don't need to edit the file in your code, but users of your mod will know that it needs to be done. There's even a setting option in the product settings so you can show your product requires the editing of core files.

Dr.CustUmz 03-10-2016 04:39 PM

i may have figured out another way to accomplish what im trying to do while skimming old products from many moons ago. Time to test it out =)


All times are GMT. The time now is 04:15 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.01448 seconds
  • Memory Usage 1,730KB
  • 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
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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