PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/class/Plugin/Smarty/function.uniqid.php

http://github.com/ethna/ethna
PHP | 25 lines | 10 code | 1 blank | 14 comment | 4 complexity | a3bab3332d416b77422839dd65bf80b8 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * smarty function:ユニークIDを生成する(double postチェック用)
  4. *
  5. * sample:
  6. * <code>
  7. * {uniqid}
  8. * </code>
  9. * <code>
  10. * <input type="hidden" name="uniqid" value="a0f24f75e...e48864d3e">
  11. * </code>
  12. *
  13. * @param string $type 表示タイプ("get" or "post"−デフォルト="post")
  14. * @see isDuplicatePost
  15. */
  16. function smarty_function_uniqid($params, &$smarty)
  17. {
  18. $uniqid = Ethna_Util::getRandom();
  19. if (isset($params['type']) && $params['type'] == 'get') {
  20. return "uniqid=$uniqid";
  21. } else {
  22. return "<input type=\"hidden\" name=\"uniqid\" value=\"$uniqid\" />\n";
  23. }
  24. }