{"id":23869473,"url":"https://github.com/fredwu/kthrottler","last_synced_at":"2025-09-08T19:31:13.317Z","repository":{"id":993546,"uuid":"802334","full_name":"fredwu/kthrottler","owner":"fredwu","description":"A Kohana port of Action Throtller (for Rails): http://github.com/fredwu/action_throttler","archived":false,"fork":false,"pushed_at":"2011-01-24T22:14:48.000Z","size":100,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T05:06:22.488Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://fredwu.me/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fredwu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-07-28T06:48:48.000Z","updated_at":"2023-02-21T06:53:55.000Z","dependencies_parsed_at":"2022-08-16T11:45:19.890Z","dependency_job_id":null,"html_url":"https://github.com/fredwu/kthrottler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fredwu/kthrottler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwu%2Fkthrottler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwu%2Fkthrottler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwu%2Fkthrottler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwu%2Fkthrottler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fredwu","download_url":"https://codeload.github.com/fredwu/kthrottler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwu%2Fkthrottler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274231438,"owners_count":25245585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-03T12:35:30.593Z","updated_at":"2025-09-08T19:31:13.018Z","avatar_url":"https://github.com/fredwu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![](http://stillmaintained.com/fredwu/kthrottler.png)](http://stillmaintained.com/fredwu/kthrottler)\n\n# KThrottler\n\nThere is also a Ruby version (for [Rails](http://rubyonrails.org/)), see here: \u003chttp://github.com/fredwu/action_throttler\u003e\n\n## Introduction\n\nKThrottler is an easy to use Kohana module to quickly throttle application actions based on configurable duration and limit. \n\nBrought to you by [Wuit](http://wuit.com).\n\n## Features\n\n* Easy to use, easy to configure\n* Lightweight\n* Supports Kohana v3\n\n## Prerequisites\n\n* Kohana's built-in DB module\n\n## Usage\n\n### Download and install the module\n\n\tgit clone git://github.com/fredwu/kthrottler.git\n\n### Enable the module\n\nIn your bootstrap file (`application/bootstrap.php`), enable KThrottler like this:\n\n\tKohana::modules(array(\n\t\t'database'    =\u003e MODPATH.'database',\n\t    'kthrottler'  =\u003e MODPATH.'kthrottler',\n\t));\n\n### Set up the database table\n\nImport the `kthrottler_logs_db.sql` file supplied.\n\n### Configure the actions\n\nThe configuration file is located at `config/kthrottler.php`. Please copy it to your `application/config` folder.\n\nThe configuration array looks like this:\n\n\treturn array\n\t(\n\t\t'mail' =\u003e array\n\t\t(\n\t\t\t'duration' =\u003e '1 hour',\n\t\t\t'limit'    =\u003e 10,\n\t\t),\n\t);\n\nYou can add as many configuration elements as you like, just make sure you label them properly (i.e. like `mail` in the example).\n\nIn the example, we are setting the `mail` action to perform at most 10 times within 1 hour duration.\n\n### Register the actions in your app\n\nNow we will need to register the actions so they are recorded in the database.\n\nTo simply run an action, in your app (presumably somewhere in the controller), do this:\n\n\tKThrottler::actions()-\u003erun('mail');\n\n`KThrottler::actions()-\u003erun()` will return true or false depending on whether or not the action is being throttled.\n\n`KThrottler::actions()-\u003erun()` has an alias `KThrottler::actions()-\u003ecan_run()` and a negative alias `KThrottler::actions()-\u003ecannot_run()`.\n\nTypically, we would want to produce feedback to the user when an action is throttled, you can do so by:\n\n\tif (`KThrottler::actions()-\u003ecannot_run('mail')`)\n\t\t// tell the user that this action is not performed\n\tend\n\n`KThrottler::actions()-\u003erun()` also takes an optional reference parameter:\n\n`KThrottler::actions()-\u003erun('mail', $current_user)`\n\nThe reference parameter is very useful because we can track and throttle the action based on a reference, such as a user. The parameter accepts a String, an Integer or an ORM object.\n\nNote that `KThrottler::actions()-\u003erun()` and its aliases will perform the action when possible. If you only want to check to see if an action can be performed, you can do this:\n\n\t`KThrottler::actions()-\u003ecan_be_run('mail', $current_user)`\n\n`KThrottler::actions()-\u003ecan_be_run()` returns true or false without performing the action, and it also has a negative alias, `KThrottler::actions()-\u003ecannot_be_run()`.\n\n## Author\n\nCopyright (c) 2010 Fred Wu (\u003chttp://fredwu.me\u003e) and [Wuit](http://wuit.com), released under the MIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredwu%2Fkthrottler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffredwu%2Fkthrottler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredwu%2Fkthrottler/lists"}