So you want to build your own tools or expand the suite?
That's great!
Luckily it's easy to build your own tools, you don't even have to write everything by yourself because of the development tools that were introduced in version 0.4.
Still you need to make sure (if you want your code to be featured in the hacksuite on this site) that you follow some guidelines, which I will discuss here.
tabs: please use tabs instead of align code with spaces, tabs are much more flexible in order to make modifications in code, is program independent(some programs will remove spaces) and is better readable.
context: if you have settings or anything else you want to make available for later use, you can make use of the context array:
$_CONTEXT
This is an array, so make sure the key doesn't exist, if you're not sure if the key has been set, just dump the context array in your script:
var_export($_CONTEXT);
paths: if you want to make shortcuts to (http) files you can add them to
$_PATHS which contains the paths(basically shortcuts) and is also an array.
Again if you want to add new items to this array, make sure they aren't defined in your script:
var_export($_PATHS);
buffer output: unless you are building a hacksuite app or you're using the hacksuite in order to feed your application, you must buffer the output in
$sCode until the script ends
functions: use the functions of folder
Functions as much as possible, rather than creating new functions
folder consistency: always make sure that you put new files into folders that make sense
variable naming: you're not exactly forced to do this but since most in the suite is coded like this it's recommended to follow the structure below.
boolean: bSomeVar
string: sSomeVar
array: aSomeVar
integer: iSomeVar
double: dSomeVar
resource: rConnect
object: oSomeObject
object from selfmade class: cSomeObject
As you can see this makes the code better readable and you can find out right away what type the variable contains.
Protect include files
You also need to protect your include files from being accessed directly. You can do this by simply checking if the constant
IN_SCRIPT has been defined.
if(!defined('IN_SCRIPT')){
exit;
}
You can put this code at the start of the code in all of your include files.
If you have any questions, feel free to contact me.