Simple and fast integration of the perso / custom Smiirl counter. This repo let you show custom number in your custom smiirl counter, and add simple possibility to edit the number with a basic user interface (folder edit).
- Print out your custom number in JSON format for you Smiirl Counter.
- Custom number can be edited thanks to a User Interface.
- Included 1 responsive template.
- Included 6 default actions.
- User Interface can easily be configured with the API in order to write your template with ease.
- Add your custom action and mathematical operation setup with ease.
- Editing history can be printed.
- All editing actions are logged in app/log/actions.log.
- No MySQL database needed.
Demo API
Demo User Interface
Username : 'public'
Password : 'smiirl counter'
Please, you maybe need to read the official documentation of Smiirl.
Edit the config/client.php file as you want.
You can just edit $_PROJECT_FOLDER
and you are good to go !
$_PROJECT_FOLDER
: absolute path of the folder which contain this project on your remote server$_PATH_JSON_FILE
: the path to .json file relative to$_PROJECT_FOLDER
$_PATH_LOG_FILE
: the path to .log file relative to$_PROJECT_FOLDER
$_KEY_NAME
: the name of the key relative to the number in your .json file (exemple :number
orlikes
orcount
)$_MAX_DIGIT_COUNTER
: set your max digit number counter. (exemple :5
for 5 digit counter Smiirl,7
for the 7 digit counter Smiirl)$_ACTIVE_EASTER_EGGS
: Active easter eggs after submitting new number value$_DEFAULT_INPUT_VALUE
: The default input value of the form$_HTML_COUNT
: The output HTML in top of counter's number$_ACTIONS
: You can here change or create custom actions
You can customise actions. See $_ACTIONS
in config/client.php :
-
Default actions are :
- Action
AJOUTER
: Add the input number value to the existing number. - Action
ENLEVER
: Remove the input number value to the existing number - Action
ECRASER
: Erase the existing number by the input number value. - Action
AJOUTE_POURCENT
: Add input % to the existing number. - Action
ENLEVE_POURCENT
: Remove input % to the existing number. - Action
RESET
: Reset existing number to zero.
- Action
-
Add a new action : Add your action configuration to
$_ACTIONS
array :ACTIVE
: active the action or not.HTML_RADIO
: HTML Output in front of the html's radio.HTML_INPUT
: HTML Output in front of the html's input when the radio is selected.DISPLAY_INPUT
: Display or not the form's input if the action is selected.HTML_SUBMIT
: HTML value of the submit button when the radio is selected.MATH
: An operation function with 2 parameters (old value counter and new input value). Please note that your callback function must have 2 parameters, the first ($old
in the exemple below) is the current value of the counter and the second ($new
in the exemple below) is the form's input value.
'MY_NEW_ACTION' => [
ACTIVE => true,
HTML_RADIO => 'Custom text',
HTML_INPUT => 'Add value and multiply by 100',
DISPLAY_INPUT => true,
HTML_SUBMIT => 'Do it !',
MATH => function ($old, $new) {
return ($old + $new) * 100;
}
]
Just learn CSS language and see edit/index.css
You can construct your home made solution. You need to add this php code on every top of your .php files (don't forget to edit the include directive with the right path):
// Exemple of include
// Edit this include path with your directive directory
include_once 'app/custom-smiirl-counter-api.php';
use CSmiirl\CSmiirl as CSmiirl;
$CSmiirl = new CSmiirl;
Legend :
- 🍁 --> Configuration file
CSmiirl method | Params | Return | Description and exemple |
---|---|---|---|
initSmiirlApiPage() |
none | [json] | Init functions and class needed to your api custom page. Return the json data after reading .json file 🍁$_PATH_JSON_FILE .Exemple : echo $CSmiirl->initSmiirlApiPage(); |
initEditPage() |
none | null | Init the function needed to your edit custom page. Listen $_POST[] , Read and write json file 🍁$_PATH_JSON_FILE , read and write log file 🍁$_PATH_LOG_FILE .Exemple : $CSmiirl->initEditPage(); |
... IN PROGRESS ...
- Just upload files in your apache or nginx server where you specify
$_PROJECT_FOLDER
.
Exemple : If you uploaded the project to http://your-domaine-name.com/Smiirl/ your
$_PROJECT_FOLDER
need to be :$_PROJECT_FOLDER = '/Smiirl'
-
Don't forget to edit file permission of
app/log/actions.log
andapp/json/number.json
to 775chmod 755 $file
on your server in order to write in those files. -
Go to your Smiirl Account and specify your configuration.
Exemple : If you follow the exemple above, specify http://your-domaine-name.com/Smiirl/ as URL in your Smiirl Account
- (Optional) Protect the editing action with php (restrictive IP / cookie / account session ...) or with .htpasswd (Ask Google)
- Enjoy !
To access the edit user interface, add /edit
to your smiirl URL :
Exemple : If you follow the installation exemple, Go to http://your-domaine-name.com/Smiirl/edit