checkcode.php 1.5 KB

1234567891011121314151617181920212223242526272829
  1. <?php
  2. defined('IN_PHPCMS') or exit('No permission resources.');
  3. $session_storage = 'session_'.pc_base::load_config('system','session_storage');
  4. pc_base::load_sys_class($session_storage);
  5. $checkcode = pc_base::load_sys_class('checkcode');
  6. if (isset($_GET['code_len']) && intval($_GET['code_len'])) $checkcode->code_len = intval($_GET['code_len']);
  7. if ($checkcode->code_len > 8 || $checkcode->code_len < 2) {
  8. $checkcode->code_len = 4;
  9. }
  10. if (isset($_GET['font_size']) && intval($_GET['font_size'])) $checkcode->font_size = intval($_GET['font_size']);
  11. if (isset($_GET['width']) && intval($_GET['width'])) $checkcode->width = intval($_GET['width']);
  12. if ($checkcode->width <= 0) {
  13. $checkcode->width = 130;
  14. }
  15. if (isset($_GET['height']) && intval($_GET['height'])) $checkcode->height = intval($_GET['height']);
  16. if ($checkcode->height <= 0) {
  17. $checkcode->height = 50;
  18. }
  19. $max_width = $checkcode->code_len * 28;
  20. $max_height = $checkcode->font_size * 2;
  21. if($checkcode->width > $max_width) $checkcode->width = $max_width;
  22. if($checkcode->height > $max_height) $checkcode->height = $max_height;
  23. if (isset($_GET['font_color']) && trim(urldecode($_GET['font_color'])) && preg_match('/(^#[a-z0-9]{6}$)/im', trim(urldecode($_GET['font_color'])))) $checkcode->font_color = trim(urldecode($_GET['font_color']));
  24. if (isset($_GET['background']) && trim(urldecode($_GET['background'])) && preg_match('/(^#[a-z0-9]{6}$)/im', trim(urldecode($_GET['background'])))) $checkcode->background = trim(urldecode($_GET['background']));
  25. $checkcode->doimage();
  26. $_SESSION['code']=$checkcode->get_code();