cache_secqaa.php 751 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: cache_secqaa.php 24522 2011-09-23 02:12:46Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. function build_cache_secqaa() {
  12. $data = array();
  13. $secqaanum = C::t('common_secquestion')->count();
  14. $start_limit = $secqaanum <= 10 ? 0 : mt_rand(0, $secqaanum - 10);
  15. $i = 1;
  16. foreach(C::t('common_secquestion')->fetch_all($start_limit, 10) as $secqaa) {
  17. if(!$secqaa['type']) {
  18. $secqaa['answer'] = md5($secqaa['answer']);
  19. }
  20. $data[$i] = $secqaa;
  21. $i++;
  22. }
  23. while(($secqaas = count($data)) < 9) {
  24. $data[$secqaas + 1] = $data[array_rand($data)];
  25. }
  26. savecache('secqaa', $data);
  27. }
  28. ?>