PDA

View Full Version : [HELP] Editing core file via a product


Dr.CustUmz
03-08-2016, 07:47 PM
so i have made a mod, but the problem is its in the showthread.php file.

im replacing
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:

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

file_put_contents('./showthread_original.php', $file, FILE_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', $file, FILE_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:

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

file_put_contents('./showthread.php', $file, FILE_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
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 =)