The KupieTools framework provides a highly portable and self-contained PHP environment, designed for deploying single-file apps with minimal configuration. This documentation explains how to customize the framework for your own use by swapping out the provided code with your own application logic.
- Self-contained portability: All assets (e.g., icons, images, and scripts) are embedded directly in the PHP file.
- Bookmarklet support: Automatically generates a bookmarklet for quick access to your app’s functionality.
- Custom URL parameters: Built-in parameter handling provides flexibility for dynamic interaction with your app.
- Utilities for security and portability:
- Functions like
makeSafe()
sanitize input to prevent XSS attacks. curPageURL()
andcurPageURLNoParams()
dynamically adapt to the current hosting environment.
- Functions like
- Built-in customization options: Configurable variables for branding, versioning, and more.
The KupieTools framework is divided into logical sections:
- Standard Functions (Section I): Utility functions like
makeSafe()
,queryParameter()
, andcurPageURL()
. - URL Parameters (Section II): Predefined parameters like
c=vh
(version history) orbs=xxx
(query data). - User-Changeable Variables (Section III): Configurable options for branding (
$user__toolName
), versioning ($user__versionHistory
), and assets ($user__favIcon
). - Custom Logic Section: Add your app's custom code here, replacing or extending the existing logic.
These functions handle URL parameters. Update them to process parameters required by your app.
Example:
// Add a new custom parameter, such as "action=example"
function commandParameter() {
if (!isset($_GET["c"])) return false;
return $_GET["c"];
}
function queryParameter() {
// Example: Return the value of a custom parameter
if (!isset($_GET["action"])) return "";
return $_GET["action"];
}
The main logic is currently split into blocks that handle specific c
parameters (e.g., c=vh
for version history). Replace these blocks with your own functionality.
Example:
if (commandParameter() == "mycustomaction") {
// Your custom logic goes here
echo "<h1>Welcome to My Custom App</h1>";
die;
}
The bookmarklet is generated dynamically by embedding the source code of your app into the page. Ensure that your app’s main function is referenced in the writeAnchor()
function.
Example:
<script>
function writeAnchor(theLabel) {
var lText = (theLabel === "") ? "Run My App" : theLabel;
document.write('<a class="bsbutton" href="javascript:(function(){ /* Your app logic here */ })();">' + lText + '</a>');
}
</script>
Modify these variables to reflect your app’s branding and configuration:
$user__toolName
: Full name of your tool.$user__toolShortName
: Short name for references.$user__bookmarkletLabel
: Label for the bookmarklet button.$user__versionHistory
: Add version details for your app.
Example:
$user__toolName = "My Custom PHP App";
$user__toolShortName = "Custom App";
$user__bookmarkletLabel = "Run App";
$user__versionHistory = "
January 20, 2025 - Initial release of My Custom PHP App
";
If your app relies on JavaScript, embed it within the <script>
tags already provided in the framework. You can also add new <script>
blocks for modularity.
Example:
<script>
function customFunction() {
alert("This is my custom JavaScript function!");
}
</script>
The current framework includes a sample UI for the BS Detector. Modify the HTML structure and CSS as needed to implement your app’s user interface.
Example:
<div id="app">
<h1>Welcome to My Custom App</h1>
<form method="GET">
<label for="input">Enter something:</label>
<input type="text" id="input" name="customparam">
<button type="submit">Submit</button>
</form>
</div>
The framework supports URL parameters like ?bs=example
. Test your app with custom parameters to ensure dynamic functionality works as expected.
Example:
// Access custom parameters
$myParam = isset($_GET['customparam']) ? $_GET['customparam'] : 'default value';
echo "You entered: " . makeSafe($myParam);
- Self-host the PHP file:
- Place the modified PHP file on any web server that supports PHP.
- Test Bookmarklet Functionality:
- Drag the generated bookmarklet to your browser’s bookmarks bar.
- Confirm that it works as expected on various web pages.
- Verify Portability:
- Test the app on different hosting environments (e.g., local server, shared hosting, cloud hosting).
- Enable Version Updates (Optional):
- To allow users to check for updates, implement the
c=dl
(download) andc=vh
(version history) parameters. Ensure compatibility with future updates of the framework.
- To allow users to check for updates, implement the
The KupieTools framework provides a robust foundation for deploying single-file PHP applications. By following the steps above, you can easily swap the existing functionality with your own custom app logic while preserving the framework’s portability and flexibility.