Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AutoMod program for THT
This comes PREINSTALLED with THT 1.3.5 Reworked! PLEASE do not install it on 1.3.5 Reworked. You don't need to.

I built a powerful AutoMod system built ff of the same principal as PHPBB3's AutoMod system, but its more powerful than the PHPBB3 AutoMod system in some respects. Below is some information on the AutoMod program. I hope this inspires more people to mod for THT now that mods are much more portable and can be used by people who do not know how to program. You simply upload the module, click install, and away it goes. All of my modules will be released on this AutoMod system from now on. =)

Admin Directory Fix - 3/28/2012 - This module fixes an issue where the custom admin directory is not checked for during file modifications.


Installing AutoMod:

1.) To install the AutoMod, simply upload the files in the "upload" directory to your THT installation directory.
2.) Log into your admin area and use AutoMod. It will automatically set itsself up silently when you go to use it
the first time. (Including adding its link to the admin area sidebar.)

Automod is located at THT DIRECTORY/admin/?page=automod and you need to go there and visit one of the sub links
(Ex. Added modules) to make it start to show in the sidebar.


Installing a module:


1.) Download a module for THT (You can get some of them at
2.) Log into your THT Admin panel and click on the AutoMod link in the sidebar. (After its installed.)
3.) Click on Install Modules and upload your module and follow the on screen instructions. Any modules that
were uploaded, but not installed, will be displayed under the upload section so you can click the link to
install them when you're ready.

Uninstalling a module:


1.) Log into your THT Admin panel and click on the AutoMod link in the sidebar. (After its installed.)
2.) Click on Uninstall Modules and click the uninstall icon next to the module you wish to uninstall
and follow the on screen instructions.

Viewing installed modules:

1.) Log into your THT Admin panel and click on the AutoMod link in the sidebar. (After its installed.)
2.) Click on Added Modules and then click on the module you'd like to see more information about.


AutoMod 1.0

General Features:

1.) Upload and use type of installation.
2.) You can even force the install or uninstall if there are errors. (See the uninstall and install sections below to see what it checks for.)
3.) Modules are developed on the same pricipal as PHPBB3 modules are devloped and installed in much the same way.
4.) The module installs based on an XML file similar to that of PHPBB3.
5.) Documentation is included for installation, creating a module, using AutoMod, and the features of AutoMod. (This document)
6.) A "Hello World" module codes with AutoMod to help you learn the proper structure for AutoMod modules and to give you a demonstration module to see
the install and uninstall process. Below are the features of Hello World.

A.) It adds a variable to variables.php named <HELLOWORLD> and is only able to be seen by admins. If you're not an admin, it will be set to empty.
B.) It adds the variable to Reloaded2's footer.tpl file and an admin will see Hello World at the very bottom of the page.
C.) It adds an admin page named helloworld.php and creates a link to it in the admin area. The page when visited will simply say "Hello World".
D.) The uninstaller will remove the link in the admin area, as well as the file modifications for footer.tpl and variables.php.

7.) You can use modules to modify the AutoMod program, as the AutoMod program is released under the GPL Vers. 3.
8.) Modules must be in zip format and they will be extraced by the same PCL Zip program that ships with THT. If a directory exists with the same
name as the archive being uploaded, the upload will fail and will alert you as to why.
9.) AutoMod will check everything before installing and uninstalling modules and only if you like the results, you can finish the process. This
adds an extra layer of protection to ensure that everything runs smoothly.
10.) All module listing pages truncate the description of the module to 250 characters. You can see the full description when you view the module,
install it, or uninstall it.
11.) AutoMod is compatable with the dynamic admin directory mod I made and if the default directory is not admin, it will rename the root/admin directory
in your module to your admin directory's name before installing.
12.) AutoMod is much more powerful than PHPBB3's AutoMod platform in many respects. It does not require you to place all edits in sequential order. (The draw
back is that you need to make sure that you don't have multiple places with the same code, being looked at by str_replace() unless you wish it to be so.)
It's also more powerful in the fact that it is not dependent on line ending styles. Anything ending in \r\n will be converted to \n.

Added Modules Page:

1.) See a list of installed modules and uninstall the ones you don't want anymore or view more information right from that screen.
2.) View the module's information by clicking on the module's name or the magnifying glass. Below are the things you can see on the view page.

A.) Module's name
B.) Module's version
C.) Your THT version
D.) The THT version the module was developed for
E.) The module's license
F.) The module's author
G.) Support information (Can be a URL or an email address or other info)
H.) The module author's website
I.) The module's website (Usually where new releases are)
J.) Recommendations (This section will let you know if you have latest AutoMod version and THT version.)
K.) The module's description
L.) The DIY/Manual instructions that are to be performed after installation (Helpful reminder)
M.) The option to uninstall the module

Install Modules Page:

1.) Upload a new module - This will upload it and extract it and prepare the module for installation. The contrib directory will be removed at this time to save space.
2.) The modules ready to be installed will appear below the upload box.
3.) When there is a module awaiting installation, you can click the name or the add icon to install it, or the remove icon button to remove the module
waiting to be installed.
4.) If you chose to remove the module, you'll be asked for confirmation before its removed.
5.) If you choose to install the module, you'll be presented with a pre-install page that checks to make sure the installation process will go
smoothly and will alert you of any problems.
6.) The pre-installtion process shows the same information as the view module page, but with any errors from the following checks.

A.) The installer checks the version of your THT installation to make sure it matches the one that the module was designed for.
B.) It checks to make sure there is a way to remove the SQL queries used at the time of installation. It will show you the
queries that the installer will run so you can be aware of them for when you uninstall the module. You'll be shown them
again at the time you uninstall the module as well. Modders are encouraged to include that tag, but its not always useful.
(Ex. It does something like how AutoMod ads the id column to the config table so it has a unique ID and duplicates can be
easily removed.) This will aid you in manually uninstalling the DB entries later on if you choose to.

C.) It will check to make sure that the file modifications specified, are possible on your system. If it can't find the code to
replace or to put code after or before, it will let you know what code it couldn't find and tell you what to replace it with,
add before it, or add after it. (Variables like <HELLOWORLD> will show properly in the textareas instead of showing their values.)

D.) If a theme file gets modified, then you'll be alerted as to how it was modified so you can modify your other themes as well.
E.) If the installer cannot find a file that needs to be modified, it will alert you.
F.) If an existing file will be overwritten, it will let you know. It will rename the old file to filename_OLD.EXT if you choose
to continue installation. The filename will continue to have its current file extension so that people can't just download
the file in their browser.

G.) The installer will also make sure it can find the install.xml file when it goes to install it. Yes, that's important.
I should have said that first. (Wheatly quote)

7.) No matter what, you can always force the install. Its your ditro, you do as you like. lol
8.) After you confirm the installation, the installer will finish and it'll redirect you to the view module page. (This page has the
DIY instructions on it for ease of use, so you can perform the tasks specified.)
9.) The installer checks to see if the module is already installed.

Uninstall modules page:

1.) You'll be presented with a list of installed modules and you can view or uninstall the same way as on the added modules page.
2.) The pre-uninstall page is the same as the pre-install page except that it doesn't have the recommendations section and it has the option
for you to remove files installed by the module and/or rename the _OLD files back and delete the modified version. Oh yeah, and it works
in reverse. Wink
3.) You can alays force the uninstallation.
4.) After uninstallation, you'll be redirected back to the added modules page so you can see that the module was removed.

Check for updates page:

1.) You can see if your THT, AutoMod, and Modules are up to date or not. (Modules will only show links to the new version if the module supports it
and the URL can be reached.)


Read this file before you create your first module. This will help you build a compatable module that runs well.

Creating a module:

1.) Take a look at the Hello World module that came with this script and give it a test install and uninstall so
you know how the AutoMod system works.

2.) Extract that archive on your computer and look at its structure. This is the structure used in building a module.
The contrib directory contains things that you do not what to be moved to the THT directory. The root directory
contains the files you want move to the THT directory and in the format you wish them to be moved in. If you're using
the dynamic admin directory that I made or someone else is, the root/admin directory will become their admin directoy
when its copied over.

3.) Open the install.xml file and look at what's inside. This is the structure that the XML file needs to be in
for the AutoMod program to properly add the module.

4.) Most options are self explanitory,but some options are not in the file, so below I've added some helpful notes.

5.) The AutoMod program will verify that the module will install properly before it installs the module. (It will check
to see that it can find everything you tell it to search for in the code.) All files will be copied from the root
directory to the THT directory, so there's no need to specify any files to transfer.

6.) If the themes gets modified, then AutoMod will let the user know that the theme was modified and how, so they
can manually modify any custom themes.

must be directly in the first part of the archive. When you create the zip file, open it and see if it has a directory
(usually with the same name as the archive's name) in it with the files you just created. If you see the install.xml
file right when you open the archive, you're good to go.

8.) You can create other directories in the archive aside from root and contrib if you need to have files or directories stored
with the module for other things that shouldn't be merged with THT. If you need to run a post install script, you could put it
in this directory and tell people to go to it via the DIY instructions if you wish. The contrib directory is just for people to
use on thier computer and is not meant to be on the server, so it gets deleted when the module is uploaded so we can save some space.

9.) Its good practice to make the module's directoy all one string. (No spaces) If you need a space, use an underslash.
The name of the archive is the same as the name of the module's directory, so you might want to keep that in mind. Also,
the name should be alphanumeric, but it was also tested to work properly with special characters as well.

10.) To replace an entire file in THT with your own code, you'll need to add the replacement file in the same place in the root
directory as the file is in in the THT directory. (Ex. root/includes/compiler.php will replace the file includes/compiler.php)
Be CAREFUL when doing this, as this could hurt other modules that were installed. The user will be warned when a file is being
completely replaced or erased before they install the module. The old file will be backed up for them as well.

11.) To test your module the easy way when you've finished programming it, upload the module's contents to the includes/AutoMod/MODULE_NAME/
directory and then use the uninstaller to uninstall your module and then reinstall it. You'll need to manually add an entry
in the DB for your module in the <PRE>automod_mods table and at least give the uninstaller the module's directory name
(Just the directory name without slashes.) before the uninstaller will work for you. This will take away any edits in your code
you added while creating it, as well as the DB entries and other files. If that works and your installation work, then you know you
should be good to go.

12.) Due to the fact that any strings that match the <find> string will be messed with when you enter your modifications, be sure
to make the find strings long enough as well as the replacement and add before/add after strings. If you need to change something very
small like a 1 or a 0, you should put a comment near that section and have the section of code re-written with the comment as well.
If you add some kind of comment like //igrse79ynhg then be sure that every time you do that, they are all different or you might wind up
having things modified that you didn't mean to. file_get_contents() is used to open the file and it str_replace()s it in and then
file_put_contents()es it back onto the file.

13.) If you want a line break before or after the text you enter in, you need to add the line break manually. This means that if you
don't start the <addafter> with a new line, the text entered will appear on the same line, after what it is appearing after, for instance.
This allows you to have more freedom in how you use <addafter> and <addbefore> and is done intentionally.

14.) You can use $automod->module_data($id_or_dir); to grab the following data from the DB that's stored when the installer runs. (Removed on uninstall)
1.) id (The ID of the module's data)
2.) mod_install_dir (The module's directory that was created when the module was uploaded - Same as the archive's name)
3.) mod_name (The name you gave your module in the XML file <projname>)
4.) mod_version (The version of your module <mod-version>)
5.) mod_thtversion (The version of THT that the module was created for <thtversion>)
6.) mod_descrip (The description of the module entered in the XML file <description>)
7.) mod_author (The developer(s) who created the module <realname>)
8.) mod_link (The link found in the <homepage> tags)
9.) mod_projectpage (The link to the project's website found in the <projectpage> tags)
10.) mod_support (The support information you gave in the <support> tags)
11.) mod_license (The license information you gave in the <license> tags)
12.) mod_diy (The after install instructions you gave in the <diy-instructions> tags)

15.) BE SURE THAT ALL TABS ARE CONVERTED TO SPACES! /rant We don't want another episode of PHPBB3 where they program it using tabs instead of spaces.
This makes modding VERY difficult to perform due to the fact that tabs are not standard. PHPBB3 denied my Akismet for PHP3 module a couple
times before I discovered that it wasn't finding the finds because I was using the universal coding standard of using spaces instead of tabs,
but they were using tabs in their code. This made it so that I had to work out the spacing issues with Notepad++ since it doesn't convert
tabs and it still had some finds that were not found after that for some reason. THT uses the universal standard of converting all tabs to
spaces, so that's not a problem. So, PLEASE keep with the standard. Spaces are always spaces. Tabs are converted to spaces in most programming
interfaces and also are a special type of character. This can cause many bugs as many, I'm sure, have witnessed the troubles with PHPBB3s
non-standard practices. It makes sense that they would use bad standards as PHPBB3 and most OS projects make their code VERY difficult to follow.
Its a wonder they are so big./end rant

16.) PLEASE release your module under the GPL. If your module is payware, it'll still work, but if it seems useful and a lot of people want it and don't
have the money for it, I might wind up making one like yours that is free. Open Source is designed for people to help people and to build a strong
community of people who write code to make the project better. If you release something for payment, you lock code changes down to only authorized
people and it could hurt your module's ability to be used as well. Not everyone can afford software and information should be free. If someone
copies your program and uses it, then you didn't loose a sale if that person couldn't afford it in the first place. You simply helped the person out.

Asking for donations is the way to go for that. If the person really likes your project and they have some money to give, then they will give it to you.
I've built my life around freedom and I've recieved donations before as well. However, there's nothing that says you can't produce a payware module.
It's just suggested that you make it free. You could benefit from linkbacks to your site instead or other pay-offs like ads being shown in the admin
area where you ask people to support you that way. (Google Ads doesn't like you asking for clicks, so if you just say "Advertisement" on there instead,
you're good to go. Just make an ad module that isn't restricted to one site.) You could also put ads on your hompage link's site and people can click
those if they want to donate. There are many more possibilities than simply charging people to use the program.

17.) <updateurl> Should contain a link to a text file that contains the text in the following format [[NEWEST VERSION]][[URL]].
(Ex. [[1.0]][[]] ) This will be used to show the user the newest version's download link. The link can be
a direct download or it can be a place where they can go to download the file.

18.) Template files for your mod go in /includes/tpl/modules/authorname_modulename_version (Ex. navens_coupons_1_0) and classes and other files that do not need
to be in specific dirctory, go in /includes/modules/authorname_modulename_version. (Ex. navens_coupons_1_0) Anything named class_CLASSNAME.php that's in the
/includes/modules/authorname_modulename_version directory, will be picked up on an initialized when the compiler goes to initialize class_automod.php. If you'd
rather have something other than your name be used, please choose something that will be consistent for only your project. This also helps to identify your
module's files so people can easily find them.

19.) Its good practice to put as much of your code into class files or other non-THT files as possible instead of adding massive amounts of data to the existing pages.
This helps to not only keep things consolidated and organized, but it also helps to prevent conflicts with other modules.

20.) Get a copy of K-Diff and before you change any files for THT, back up the original. Call it filename_OLD.EXT and then when you have your module working how you want it,
you can put the old and new files int K-Diff and easily see the differences in the two so you can build your install.xml file with ease. You'll see all the differences
highlighted and then its just a copy and past job. =) Also, after I finished creating my production module, Na'ven's Coupons, since I wanted to test AutoMod with
a production mod before releasing it, I found that some of the replacements were not backwards compatible. By that I mean that some things that I'd replace into the
files during an installation could not be removed properly on uninstallation. I fixed this issue by adding comments to the small replacements so that it would be able to
tell what text I was telling it to replace. So, just like when you test your installation and use K-Diff to check if the replacements were made properly, be sure to check
if all the replacements were undone after you uninstall it. Na'ven's Coupons, needless to say, does not have any problems with its uninstallation after I fixed it using
this method.


1.) Classes must be in the proper directory (See number 18 above) and must be in the following format class_authorname_modulename.php and the class must be called
authorname_modulename. (Ex. class_navens_coupons.php contains a class named navens_coupons) While you technically can name them class_anything with the anything
classs in the file, you really should put your name first. This way other modules will be less likely to conflict. You can have as many underslashes in the class
name as you'd like because it will check if class_ is in the name and take that part out using str_replace() when it initializes the module.

2.) Module templates must go in the proper directory (See number 18 above) and do not requre special names for the templates because THT doesn't look at those
in a special way.

3.) Anything that must go in a directory outside of your /includes/modules/authorname_modulename_version directory, should be prefixed with your name.

4.) DB tables created by your module should be named mod_authorname_tablename as this helps identify it as a module's table as well as a table pertaining to your module.


1.) The <support></support> fection can be a link or an email address. This is only seen in the admin area, so no bots
will find your email address.

2.) You need to add the THT version to the <thtversion></thtversion> section. If the version doesn't match the version
of THT installed, then the user will be notified as a warning before they install the module. The proper format is
"1.3 SPECIAL" where SPECIAL is any name that signifies a difference in the version. For example, "1.3 Reworked" will
signify that its a special release. This means that the installer will say that the version is
the same, but the person installing the module should be aware that the special release is what this was built for.
You can have a release name that's muliple words long as well, but the version needs to be one string.

3.) <sql> and <uninstallsql> both should end with a ; after each query so that it can be imported properly. To make it easier
read if you decide not to use <uninstallsql> which you really should, mind you, please put ever query on a new line.

4.) Below is the framework for different options for files that get opened and edited. Also, keep in mind, that this is done
through str_replace()ments and if you want to keep the whitespace before the first line, you need to put the whitespace in
the modification That goes for the find text as well since add before will replace the find text with the find text and then
after on a new line, or it will replace it with add before text with before then on a new line, the find text.

Replace a section of code (Type REMOVE IT to remove the code.):

<open src="directory/file.php">
<find><![CDATA[Code to find goes here.]]></find>
<replace><![CDATA[Code to replace it with goes here.]]></replace>

<open src="directory/file.php">
<find><![CDATA[Code to find goes here.]]></find>
<replace><![CDATA[REMOVE IT]]></replace>

Add code before other code:

<open src="directory/file.php">
<find><![CDATA[Code to find goes here.]]></find>
<addbefore><![CDATA[Code to add before it goes here.]]></addbefore>

Add code after other code:

<open src="directory/file.php">
<find><![CDATA[Code to find goes here.]]></find>
<addafter><![CDATA[Code to add after it goes here.]]></addafter>

Attached Files Thumbnail(s)

.zip   AutoMod (Size: 55.93 KB / Downloads: 950)
.zip   AutoMod (Size: 336.54 KB / Downloads: 791)
See my GitHub at
Installed great thank you.
Doesn't work!
I can login to Admin without the warning!
Quote:Possible CSRF attack detected. Please make sure cookies are enabled.
They are enabled
Try to upload file and install but get the warning.

How do you install a Module in THT without using AutoMod?

Also See:
It contains other questions on Kloxo with v1.3.5, AutoMod etc

Many thanks in anticipation of a solution!

THT Version: THT v1.3.5
Control Panel Type: Kloxo
Never Say Never, Anything is Possible!
I solved my problem by doing what I posted here:
Never Say Never, Anything is Possible!
Error : Unable to upload file

how to fix that?

Forum Jump:

Users browsing this thread: 1 Guest(s)