Hello all,
Please excuse that I am a complete novice when it comes to Xenforo, I am also an average coder as my forum is my hobby and in normal day to day life I run a small business of electricians and AV installers. I am also 40 and not in my prime for learning (but your never to old to learn )
I do understand the basics, and I can read the code and understand it (the majority of times).
I do not have the skill to write code directly apart from IF'S, Variables, operators, etc. I normally find in the php manual or google the code I am looking for and modify it to my needs.
Note: I have read the development manual maybe 3 times, very good manual by the way! And I am feeling a lot more confident, however, I have a few queries.
The Scenario:
I am trying to port a few of my small modifications from vBulletin to Xenforo 2, these are quite simple mods that used to just have one page of code and a template association. I would like my modifications to have pages like index.php?micksmodifaction (example)
Where I have got to:
* I used the cmd.php file to create my addon and I understand the versioning etc.
* Now I have a json file and I advanced it to have description and a icon.
* There is also a setup file, as there is no mysql in this addon not sure if I need much here or not (but I understand that this file will upgrade, install, or delete my addon.
* I understand I need to create a route in the development tools area of the admin area
* The prefix will be the part that represents the micksmodification part of the URL after index.php?
* Section context in the route (see below this I am confused) will be 1????
What I need help with:
* With regards to the main code that makes my old modifications work do these go in the controller files or entities or both.
* DO I have to convert my code into Classes and functions to work.
* Can you just make a file in say /Pub/micksmodification.php and then run it from there.
* What is the section context in the routing section of the development tools (I could not grasp the manuals interpretation)
Part of the Code:
Thank you for any help you can give me, I am trying ...
Mick
Please excuse that I am a complete novice when it comes to Xenforo, I am also an average coder as my forum is my hobby and in normal day to day life I run a small business of electricians and AV installers. I am also 40 and not in my prime for learning (but your never to old to learn )
I do understand the basics, and I can read the code and understand it (the majority of times).
I do not have the skill to write code directly apart from IF'S, Variables, operators, etc. I normally find in the php manual or google the code I am looking for and modify it to my needs.
Note: I have read the development manual maybe 3 times, very good manual by the way! And I am feeling a lot more confident, however, I have a few queries.
The Scenario:
I am trying to port a few of my small modifications from vBulletin to Xenforo 2, these are quite simple mods that used to just have one page of code and a template association. I would like my modifications to have pages like index.php?micksmodifaction (example)
Where I have got to:
* I used the cmd.php file to create my addon and I understand the versioning etc.
* Now I have a json file and I advanced it to have description and a icon.
* There is also a setup file, as there is no mysql in this addon not sure if I need much here or not (but I understand that this file will upgrade, install, or delete my addon.
* I understand I need to create a route in the development tools area of the admin area
* The prefix will be the part that represents the micksmodification part of the URL after index.php?
* Section context in the route (see below this I am confused) will be 1????
What I need help with:
* With regards to the main code that makes my old modifications work do these go in the controller files or entities or both.
* DO I have to convert my code into Classes and functions to work.
* Can you just make a file in say /Pub/micksmodification.php and then run it from there.
* What is the section context in the routing section of the development tools (I could not grasp the manuals interpretation)
Part of the Code:
PHP:
//$fileTypes = array('.zip', '.xml', '.');
$myFile = $_FILES["myFile"];
if (!empty($_FILES["myFile"])) {
if (!preg_match("/\.(zip|xml|ipk|tar.gz|txt)$/", $myFile["name"])){
$notzip = "<p>This file is not a ZIP / XML / IPK / TAR.GZ or you did not choose a file, please choose a zip, xml, tar.gz or ipk file only - all other files will not upload</p>";
} else {
if ($myFile["error"] !== UPLOAD_ERR_OK) {
$errorwrong = "<p>An error occurred.</p>";
}
if ($myFile["size"] > 2000000) {
$errorwrong = "<p>file is bigger than 20mb please give Mick a PM to increase this if needed.</p>";
}
// ensure a safe filename
$name = preg_replace("/[^A-Z0-9._-]/i", "_", $myFile["name"]);
$name_dir = $new_upload_dir.$name;
// preserve file from temporary directory
$success = move_uploaded_file($myFile["tmp_name"], $name_dir);
if (!$success) {
$workornot = "<p>Unable to save file please try again etc.</p>";
} else {
// set proper permissions on the new file
chmod($name_dir.$name, 0644);
$congratz = 'Congratulations the file was successfully uploaded';
}
}
Thank you for any help you can give me, I am trying ...
Mick